Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/Logger.java157
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/StructuredTextViewerConfigurationXSD.java43
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java250
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlineConfiguration.java354
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlinePage.java561
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditor.java867
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorAdapter.java27
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorContextIds.java460
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorPlugin.java326
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlink.java86
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlinkDetector.java251
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java1762
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMultiPageEditorPart.java645
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDSelectionManager.java96
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AbstractAction.java68
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddAttributeAction.java40
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddEnumsAction.java92
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java57
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddSchemaNodeAction.java61
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/BackAction.java90
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAnnotationAction.java55
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAttributeAndRequired.java115
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java365
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateGroupAction.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateIdentityConstraintsAction.java74
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalComplexTypeAction.java68
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalSimpleTypeAction.java85
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleContentAction.java115
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleTypeAction.java68
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DeleteAction.java234
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/GraphRenameAction.java34
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ISchemaEditorActionConstants.java22
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MakeAnonymousGlobal.java66
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ModelMessage.java36
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MoveAction.java183
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/OpenSchemaAction.java62
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ReloadDependenciesAction.java58
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetBaseTypeAction.java383
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetMultiplicityAction.java42
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetTypeAction.java47
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java58
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java223
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AbstractCommand.java71
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddAttributeDeclarationCommand.java140
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddComplexTypeDefinitionCommand.java53
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddElementDeclarationCommand.java53
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java103
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddSimpleTypeDefinitionCommand.java56
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeAnonymousTypeGlobalCommand.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeLocalElementGlobalCommand.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/RenameCommand.java70
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetMultiplicityCommand.java66
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetTypeCommand.java103
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/ComponentSelectionDialog.java445
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentList.java18
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentSelectionProvider.java27
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/ResourceView.java141
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java114
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionDialog.java180
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java141
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java57
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java130
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java70
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionDialog.java28
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java346
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java358
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/BaseDragNodesCommand.java103
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/DragNodesCommand.java77
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/XSDDragAndDropManager.java57
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/editparts/AbstractComponentViewerRootEditPart.java63
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectedEditPartFigure.java138
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectionRenderingFigure.java215
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerFigure.java60
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerLayout.java217
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/FillLayout.java161
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedEditPartFigure.java30
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedFigure.java18
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectionRenderingViewer.java16
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IExpandable.java19
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/SpacingFigure.java27
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/BaseGraphicalViewer.java199
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/FigureCanvasKeyboardHandler.java125
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphContextMenuProvider.java56
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphicsConstants.java36
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/LinkedGraphViewer.java160
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/PrintGraphAction.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDChildUtility.java285
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDComponentViewer.java104
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphUtil.java35
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java460
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphicalViewerKeyHandler.java352
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDInheritanceViewer.java97
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupChildUtility.java46
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupsViewer.java98
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java86
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java187
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java214
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java149
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java460
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java189
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java144
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java17
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java38
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java204
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java187
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java72
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java121
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java105
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java60
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java206
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java69
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java319
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java72
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java85
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java102
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComboBoxCellEditorManager.java203
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComponentNameDirectEditManager.java105
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DirectEditPolicyDelegate.java18
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropCommand.java161
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropEditPolicy.java47
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/GraphNodeDragTracker.java34
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SelectionHandlesEditPolicyImpl.java257
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SimpleDirectEditPolicy.java58
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TextCellEditorManager.java74
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TypeReferenceDirectEditManager.java118
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/BogusLayout.java61
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenterLayout.java117
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenteredIconFigure.java39
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ConnectionFigure.java210
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerFigure.java71
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerLayout.java248
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ExpandableGraphNodeFigure.java133
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FillLayout.java160
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FloatableFigure.java29
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeContainerFigure.java29
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeFigure.java184
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/Interactor.java54
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/LabelFigure.java88
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/PostLayoutManager.java19
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RepeatableGraphNodeFigure.java85
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RoundedLineBorder.java67
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/Category.java265
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapter.java27
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapterListener.java18
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/XSDModelAdapterFactory.java559
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateDtd.gifbin605 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateJava.gifbin609 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GraphViewElementRef.gifbin860 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/NewXSD.gifbin3261 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/RegexWizardArrow.gifbin54 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/ValidateXSD.gifbin558 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAll.gifbin88 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnnotate.gifbin594 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAny.gifbin613 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnyAttribute.gifbin384 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAppInfo.gifbin121 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttribute.gifbin167 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroup.gifbin235 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroupRef.gifbin361 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeRef.gifbin350 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDChoice.gifbin145 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexContent.gifbin211 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexType.gifbin155 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDDoc.gifbin368 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElement.gifbin351 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElementRef.gifbin585 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDExtension.gifbin101 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDField.gifbin227 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDFile.gifbin361 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalAttribute.gifbin167 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalElement.gifbin351 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroup.gifbin205 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroupRef.gifbin347 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDImport.gifbin114 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDInclude.gifbin324 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKey.gifbin323 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKeyRef.gifbin558 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDNotation.gifbin177 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDRedefine.gifbin373 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSelector.gifbin136 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSequence.gifbin91 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleContent.gifbin210 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleEnum.gifbin105 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleList.gifbin347 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimplePattern.gifbin120 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleRestrict.gifbin141 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleType.gifbin150 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleTypeForEditPart.gifbin150 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleUnion.gifbin138 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDUnique.gifbin210 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/back.gifbin873 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/browsebutton.gifbin825 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/forward.gifbin874 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/generate_xml.gifbin612 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/regx_wiz.gifbin3241 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/reloadgrammar.gifbin365 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/sort.gifbin159 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/preferences/XSDPreferencePage.java254
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyAttributePropertySource.java173
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyContentPropertyDescriptor.java154
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyElementPropertySource.java226
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AppInfoPropertySource.java216
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributeGroupRefPropertySource.java172
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributePropertySource.java294
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributesTable.java331
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/BasePropertySource.java126
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ComplexTypePropertySource.java341
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DocumentationPropertySource.java243
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DynamicCellEditor.java1174
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ElementPropertySource.java545
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/EnumerationPropertySource.java131
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/FixedOrDefaultTextPropertyDescriptor.java304
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/GroupRefPropertySource.java226
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ImportPropertySource.java310
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/IncludePropertySource.java237
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/KeyrefPropertySource.java208
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ModelGroupPropertySource.java261
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NamePropertySource.java219
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NotationPropertySource.java186
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/OptionsTextCellEditor.java239
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/PatternPropertySource.java272
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ReadOnlyPropertySource.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaDirectiveHelperPropertySource.java191
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaPropertySource.java520
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertyDescriptor.java209
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertySource.java226
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleRestrictPropertySource.java328
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeListPropertySource.java144
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypePropertySource.java183
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeUnionPropertySource.java493
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/TypesPropertyDescriptor.java1145
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XPathPropertySource.java150
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDComboBoxPropertyDescriptor.java304
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDPropertySourceProvider.java285
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java495
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSectionDescriptor.java113
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSection.java592
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSectionDescriptor.java109
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewContentProvider.java289
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSection.java419
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSectionDescriptor.java101
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/CommonDirectivesSection.java157
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSection.java236
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSectionDescriptor.java82
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSection.java424
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSectionDescriptor.java87
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetViewer.java492
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSection.java802
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSectionDescriptor.java87
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSection.java282
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSectionDescriptor.java145
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSection.java144
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSectionDescriptor.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSection.java434
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSectionDescriptor.java168
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationDescriptor.java87
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationSection.java361
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSection.java192
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSectionDescriptor.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSection.java430
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSectionDescriptor.java86
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSection.java108
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSectionDescriptor.java143
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSection.java165
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSectionDescriptor.java85
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSection.java288
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSectionDescriptor.java173
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationDescriptor.java88
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationSection.java207
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentBaseTypeOptionsDialog.java158
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentUnionMemberTypesDialog.java311
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSection.java570
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSectionDescriptor.java91
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSection.java185
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSectionDescriptor.java73
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TextChangeHelper.java102
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java721
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSection.java359
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSectionDescriptor.java120
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSection.java118
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSectionDescriptor.java82
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/WindowUtility.java115
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionDescriptorProvider.java57
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionLabelProvider.java178
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDTabbedPropertySheetPage.java180
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbook.java97
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbookPage.java51
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/CategoryAdapter.java168
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAbstractAdapter.java165
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAdapterFactoryLabelProvider.java143
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAnnotationAdapter.java83
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeDeclarationAdapter.java113
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeGroupDefinitionAdapter.java96
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeUseAdapter.java90
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDComplexTypeDefinitionAdapter.java182
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDContentProvider.java228
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDElementDeclarationAdapter.java183
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelAdapterFactoryImpl.java359
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupAdapter.java162
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupDefinitionAdapter.java95
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDNotationDeclarationAdapter.java44
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDParticleAdapter.java61
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaAdapter.java379
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaDirectiveAdapter.java102
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSimpleTypeDefinitionAdapter.java188
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDWildcardAdapter.java112
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java49
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/XSDVisitor.java217
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java162
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java79
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RefactorActionGroup.java261
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java104
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java139
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java75
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java56
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java199
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java107
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java29
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java104
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java100
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java143
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java299
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties33
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseRenamer.java61
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameChange.java193
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeGroupRenamer.java57
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeRenamer.java66
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalElementRenamer.java41
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalGroupRenamer.java43
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalSimpleOrComplexTypeRenamer.java91
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/INameUpdating.java32
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java227
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameInputWizardPage.java253
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameRefactoringWizard.java70
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java170
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameSupport.java205
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java107
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java83
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/SchemaPrefixChangeHandler.java211
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/TargetNamespaceChangeHandler.java154
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java171
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java219
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java103
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelQueryExtension.java204
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java303
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/OpenOnSelectionHelper.java329
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/SelectionAdapter.java83
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/TypesHelper.java714
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/ViewUtility.java429
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDDOMHelper.java1136
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaHelper.java72
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java31
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverImpl.java39
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/validation/DelegatingSourceValidatorForXSD.java40
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/EnumerationsDialog.java106
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/SetBaseTypeDialog.java178
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/TypeSection.java335
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/XSDEditSchemaInfoDialog.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java161
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexCompositionPage.java958
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexNode.java421
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexTestingPage.java150
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexWizard.java63
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDLocationChoicePage.java69
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDNewFilePage.java129
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDSelectIncludeFileWizard.java371
371 files changed, 0 insertions, 59032 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/Logger.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/Logger.java
deleted file mode 100644
index 3ba5a01abb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/Logger.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.Bundle;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if
- * desired, the console. This class should only be used by classes in this
- * plugin. Other plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static final String PLUGIN_ID = "org.eclipse.wst.xsd.ui"; //$NON-NLS-1$
-
- public static final int ERROR = IStatus.ERROR; // 4
- public static final int ERROR_DEBUG = 200 + ERROR;
- public static final int INFO = IStatus.INFO; // 1
- public static final int INFO_DEBUG = 200 + INFO;
-
- public static final int OK = IStatus.OK; // 0
-
- public static final int OK_DEBUG = 200 + OK;
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int WARNING_DEBUG = 200 + WARNING;
-
- /**
- * Adds message to log.
- *
- * @param level
- * severity level of the message (OK, INFO, WARNING, ERROR,
- * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message
- * text to add to the log
- * @param exception
- * exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- *
- * @param message
- * text to print
- * @param category
- * category of the message, to be compared with
- * /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
- }
-
- /**
- * @return true if the platform is debugging
- */
- public static boolean isDebugging() {
- return Platform.inDebugMode();
- }
-
- /**
- * Determines if currently tracing a category
- *
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/StructuredTextViewerConfigurationXSD.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/StructuredTextViewerConfigurationXSD.java
deleted file mode 100644
index 1b68b130cf..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/StructuredTextViewerConfigurationXSD.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
-
-/**
- * Configuration for editing XSD content type
- */
-public class StructuredTextViewerConfigurationXSD extends StructuredTextViewerConfigurationXML {
- public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
- return null;
-
- List allDetectors = new ArrayList(0);
- // add XSD Hyperlink detector
- allDetectors.add(new XSDHyperlinkDetector());
-
- IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
- for (int m = 0; m < superDetectors.length; m++) {
- IHyperlinkDetector detector = superDetectors[m];
- if (!allDetectors.contains(detector)) {
- allDetectors.add(detector);
- }
- }
- return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java
deleted file mode 100644
index 3c90b2149f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.RetargetAction;
-import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor;
-import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants;
-import org.eclipse.wst.xsd.ui.internal.actions.ISchemaEditorActionConstants;
-import org.eclipse.wst.xsd.ui.internal.actions.ReloadDependenciesAction;
-import org.eclipse.wst.xsd.ui.internal.actions.SourcePageActionContributor;
-import org.eclipse.wst.xsd.ui.internal.refactor.actions.RefactorActionGroup;
-
-public class XSDActionBarContributor extends MultiPageEditorActionBarContributor
-{
- protected XSDEditor xsdEditor;
- protected ITextEditor textEditor;
- protected IEditorActionBarContributor sourceViewerActionContributor = null;
-
- protected ReloadDependenciesAction reloadDependenciesAction;
-
- protected List fPartListeners= new ArrayList();
-
- protected RetargetAction retargetReloadDependenciesAction;
- private RetargetTextEditorAction renameElementAction = null;
- private IMenuManager refactorMenu = null;
-
- /**
- * Constructor for XSDActionBarContributor.
- */
- public XSDActionBarContributor()
- {
- super();
-
- sourceViewerActionContributor = new SourcePageActionContributor();
-
- // Reload Dependencies
- reloadDependenciesAction = new ReloadDependenciesAction(XSDEditorPlugin.getXSDString("_UI_MENU_RELOAD_DEPENDENCIES"));
- retargetReloadDependenciesAction = new RetargetAction(ISchemaEditorActionConstants.RETARGET_RELOAD_DEPENDENCIES_ACTION_ID, XSDEditorPlugin.getXSDString("_UI_MENU_RELOAD_DEPENDENCIES"));
- retargetReloadDependenciesAction.setToolTipText(XSDEditorPlugin.getXSDString("_UI_MENU_RELOAD_DEPENDENCIES_TOOLTIP"));
- retargetReloadDependenciesAction.setImageDescriptor(
- ImageDescriptor.createFromFile(XSDEditorPlugin.getPlugin().getClass(), "icons/reloadgrammar.gif"));
- fPartListeners.add(retargetReloadDependenciesAction);
-
- ResourceBundle bundle = Platform.getResourceBundle(XSDEditorPlugin.getPlugin().getBundle());
- renameElementAction = new RetargetTextEditorAction(bundle, ISchemaEditorActionConstants.RETARGET_RENAME_ELEMENT_ACTION_ID + StructuredTextEditorActionConstants.DOT);
- renameElementAction.setActionDefinitionId("org.eclipse.wst.xsd.ui.refactor.rename.element"); // TODO: add to contstants command id
-
- // the refactor menu, add the menu itself to add all refactor actions
- refactorMenu = new MenuManager(XSDEditorPlugin.getXSDString("refactoring.menu.label"), RefactorActionGroup.MENU_ID); //TODO: externalize string
- refactorMenu.add(this.renameElementAction);
- }
-
- protected void updateActions()
- {
- if (xsdEditor != null && xsdEditor.getCurrentPageType().equals(XSDEditorPlugin.GRAPH_PAGE))
- {
- IAction deleteAction = xsdEditor.getGraphViewer().getComponentViewer().getMenuListener().getDeleteAction();
- getActionBars().setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
-
- IAction printGraphAction = xsdEditor.getGraphViewer().getPrintGraphAction();
- getActionBars().setGlobalActionHandler(ActionFactory.PRINT.getId(), printGraphAction);
- }
- else
- {
- getActionBars().setGlobalActionHandler(ActionFactory.DELETE.getId(), null);
- // always enable print regardless of whether we are on source or design
- updateAction(ActionFactory.PRINT.getId(), ITextEditorActionConstants.PRINT, true);
- }
- }
-
- public void setActivePage(IEditorPart activeEditor)
- {
- updateActions();
-
- if (activeEditor != null && activeEditor instanceof StructuredTextEditor)
- {
- activateSourcePage(activeEditor, true);
- }
- else
- {
- activateSourcePage(xsdEditor, false);
- }
-
- IActionBars actionBars = getActionBars();
- if (actionBars != null) {
- // update menu bar and tool bar
- actionBars.updateActionBars();
- }
-
- updateAction(IWorkbenchActionConstants.UNDO, ITextEditorActionConstants.UNDO, true);
- updateAction(IWorkbenchActionConstants.REDO, ITextEditorActionConstants.REDO, true);
-
- getActionBars().updateActionBars();
- }
-
- protected void activateSourcePage(IEditorPart activeEditor, boolean state)
- {
- if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)
- {
- sourceViewerActionContributor.setActiveEditor(activeEditor);
- ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(state);
- }
- }
-
- protected void updateAction(String globalActionId, String textEditorActionId, boolean enable)
- {
- getActionBars().setGlobalActionHandler(globalActionId,
- enable ? getAction(textEditor, textEditorActionId) :
- null);
- }
-
- /**
- * Returns the action registed with the given text editor.
- * @return IAction or null if editor is null.
- */
- protected IAction getAction(ITextEditor editor, String actionID)
- {
- try
- {
- return (editor == null ? null : editor.getAction(actionID));
- }
- catch (Exception e)
- {
- return null;
- }
- }
-
- public void addToMenu(IMenuManager menuManager)
- {
- MenuManager treeMenu = new MenuManager(XSDEditorPlugin.getXSDString("_UI_MENU_XSD_EDITOR"));
- menuManager.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, treeMenu);
-
- treeMenu.add(new Separator("group1"));
-// Add retarget actions
-
- treeMenu.add(retargetReloadDependenciesAction);
-
- treeMenu.add(new Separator("group2"));
- }
-
-
-public void addToToolBar(IToolBarManager toolBarManager)
- {
- toolBarManager.add(new Separator("XMLSchema.2"));
-// Add retarget actions
- toolBarManager.add(retargetReloadDependenciesAction);
-
- toolBarManager.add(new Separator("XMLSchema.1"));
-
- toolBarManager.add(new Separator());
- }
-
- public void contributeToToolBar(IToolBarManager toolBarManager)
- {
- addToToolBar(toolBarManager);
- }
-
- public void contributeToMenu(IMenuManager menuManager)
- {
- addToMenu(menuManager);
- }
-
- /**
- * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart targetEditor)
- {
- if (targetEditor instanceof XSDEditor)
- {
- xsdEditor = (XSDEditor) targetEditor;
- reloadDependenciesAction.setEditor((XSDEditor)targetEditor);
-
- textEditor = ((XSDEditor)targetEditor).getTextEditor();
- if (textEditor != null)
- {
-
- renameElementAction.setAction(getAction(textEditor, ISchemaEditorActionConstants.RETARGET_RENAME_ELEMENT_ACTION_ID));
- updateActions();
- getActionBars().updateActionBars();
- }
- }
- super.setActiveEditor(targetEditor);
-
- updateAction(IWorkbenchActionConstants.UNDO, ITextEditorActionConstants.UNDO, true);
- updateAction(IWorkbenchActionConstants.REDO, ITextEditorActionConstants.REDO, true);
- }
-
- public void init(IActionBars bars, IWorkbenchPage page)
- {
- Iterator e = fPartListeners.iterator();
- while (e.hasNext())
- {
- page.addPartListener((RetargetAction) e.next());
- }
-
- // register actions that have a dynamic editor.
-
- bars.setGlobalActionHandler(ISchemaEditorActionConstants.RETARGET_RELOAD_DEPENDENCIES_ACTION_ID, reloadDependenciesAction);
-
- initSourceViewerActionContributor(bars);
-
- super.init(bars, page);
- }
-
- protected void initSourceViewerActionContributor(IActionBars actionBars) {
- if (sourceViewerActionContributor != null)
- sourceViewerActionContributor.init(actionBars, getPage());
- }
-
-
- public void dispose()
- {
- super.dispose();
-
- if (sourceViewerActionContributor != null)
- sourceViewerActionContributor.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlineConfiguration.java
deleted file mode 100644
index 09e105e9f7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlineConfiguration.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-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.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-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.sse.ui.internal.contentoutline.PropertyChangeUpdateAction;
-import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateActionContributionItem;
-import org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xsd.ui.internal.actions.OpenSchemaAction;
-import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDAdapterFactoryLabelProvider;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDContentProvider;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl;
-import org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Outline configuration for XSD
- */
-public class XSDContentOutlineConfiguration extends ContentOutlineConfiguration {
- private XSDContentProvider fContentProvider;
- private ILabelProvider fLabelProvider;
- private KeyListener[] fKeyListeners = null;
- private IMenuListener fMenuListener = null;
- private XSDEditor fEditor = null;
- private TreeViewer treeViewer;
- protected SelectionManagerSelectionChangeListener selectionManagerSelectionChangeListener = new SelectionManagerSelectionChangeListener();
-
- public XSDContentOutlineConfiguration()
- {
- super();
- }
-
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null) {
- fContentProvider = new XSDContentProvider(XSDModelAdapterFactoryImpl.getInstance());
- }
- this.treeViewer = viewer;
- getXSDEditor().getSelectionManager().addSelectionChangedListener(selectionManagerSelectionChangeListener);
- return fContentProvider;
- }
-
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fLabelProvider == null) {
- fLabelProvider = new XSDAdapterFactoryLabelProvider(XSDModelAdapterFactoryImpl.getInstance());
- }
- return fLabelProvider;
- }
-
- public IMenuListener getMenuListener(TreeViewer viewer) {
- if (fMenuListener == null) {
- // ISSUE: what happens if cannot get XSD Editor? (See
- // getXSDEditor comment)
- if (getXSDEditor() != null)
- fMenuListener = new XSDMenuListener(getXSDEditor().getSelectionManager());
- }
- return fMenuListener;
- }
-
- public KeyListener[] getKeyListeners(TreeViewer viewer) {
- if (fKeyListeners == null) {
- final TreeViewer finalViewer = viewer;
- KeyAdapter keyListener = new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- if (e.character == SWT.DEL) {
- IMenuListener menuListener = getMenuListener(finalViewer);
- if (menuListener instanceof XSDMenuListener)
- ((XSDMenuListener) menuListener).getDeleteAction().run();
- }
- else if (e.keyCode == SWT.F3) // open editor on any
- // include/import/redefine
- {
- if (e.widget instanceof Tree) {
- Tree tree = (Tree) e.widget;
- TreeItem[] selection = tree.getSelection();
- if (selection.length > 0) {
- if (selection[0].getData() instanceof XSDSchemaDirective) {
- XSDSchemaDirective comp = (XSDSchemaDirective) selection[0].getData();
- OpenSchemaAction openSchema = new OpenSchemaAction(XSDEditorPlugin.getXSDString("_UI_ACTION_OPEN_SCHEMA"), comp);
- openSchema.run();
- }
- }
- }
- }
- }
- };
- fKeyListeners = new KeyListener[]{keyListener};
- }
-
- return fKeyListeners;
- }
-
- public ISelection getSelection(TreeViewer viewer, ISelection selection) {
- ISelection sel = selection;
-
- if (selection instanceof IStructuredSelection) {
- List xsdSelections = new ArrayList();
- for (Iterator i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
- Object domNode = i.next();
- Object xsdNode = getXSDNode(domNode, viewer);
- if (xsdNode != null) {
- xsdSelections.add(xsdNode);
- }
- }
-
- if (!xsdSelections.isEmpty()) {
- sel = new StructuredSelection(xsdSelections);
- }
- }
- return sel;
- }
-
- /**
- * Determines XSD node based on object (DOM node)
- *
- * @param object
- * @return
- */
- private Object getXSDNode(Object object, TreeViewer viewer) {
- // get the element node
- Element element = null;
- if (object instanceof Node) {
- Node node = (Node) object;
- if (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- element = (Element) node;
- }
- else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- element = ((Attr) node).getOwnerElement();
- }
- }
- }
- Object o = element;
- if (element != null) {
- Object modelObject = getXSDSchema(viewer).getCorrespondingComponent(element);
- if (modelObject != null) {
- o = modelObject;
- }
- }
- return o;
- }
-
- /**
- * Gets the xsd schema from treeviewer's input
- *
- * @param model
- * (of type Object but really should be IStructuredModel)
- * @return Definition
- */
- private XSDSchema getXSDSchema(TreeViewer viewer) {
- XSDSchema xsdSchema = null;
- Object model = null;
- if (viewer != null)
- model = viewer.getInput();
-
- if (model instanceof IDOMModel) {
- IDOMDocument domDoc = ((IDOMModel) model).getDocument();
- if (domDoc != null) {
- XSDModelAdapter modelAdapter = (XSDModelAdapter) domDoc.getExistingAdapter(XSDModelAdapter.class);
- /*
- * ISSUE: Didn't want to go through initializing schema if it
- * does not already exist, so just attempted to get existing
- * adapter. If doesn't exist, just don't bother working.
- */
- if (modelAdapter != null)
- xsdSchema = modelAdapter.getSchema();
- }
- }
- return xsdSchema;
- }
-
- // ISSUE: There are some cases where outline comes up before editor
- private XSDEditor getXSDEditor() {
- if (fEditor == null) {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor instanceof XSDEditor)
- fEditor = (XSDEditor) editor;
- }
- }
- }
- }
- return fEditor;
- }
-
- protected IContributionItem[] createMenuContributions(TreeViewer viewer) {
- IContributionItem[] items = super.createMenuContributions(viewer);
-
- referenceAction = new FilterAction(XSDEditorPlugin.getPlugin().getPreferenceStore(), "referenceContentAction", new ReferenceFilter("Reference Content"), XSDEditorPlugin.getXSDString("_UI_OUTLINE_SHOW_REFERENCES"), ImageDescriptor.createFromFile(XSDEditorPlugin.getPlugin().getClass(), "icons/XSDElementRef.gif"));
- boolean initialRef = getXSDEditor().getXSDModelAdapterFactory().getShowReferences();
- referenceAction.setChecked(initialRef);
-
- inheritedAction = new FilterAction(XSDEditorPlugin.getPlugin().getPreferenceStore(), "inheritedContentAction", new ReferenceFilter("Inherited Content"), XSDEditorPlugin.getXSDString("_UI_OUTLINE_SHOW_INHERITED"), ImageDescriptor.createFromFile(XSDEditorPlugin.getPlugin().getClass(), "icons/XSDComplexContent.gif"));
-
- IContributionItem toggleReferenceItem = new PropertyChangeUpdateActionContributionItem(referenceAction);
- IContributionItem toggleInheritedItem = new PropertyChangeUpdateActionContributionItem(inheritedAction);
-
- List list = new ArrayList();
- list.addAll(Arrays.asList(items));
- list.add(toggleReferenceItem);
- list.add(toggleInheritedItem);
-
- int length = list.size();
- IContributionItem[] newItems = new IContributionItem[length];
- int i = 0;
- for (Iterator iter = list.iterator(); iter.hasNext(); i++)
- {
- newItems[i] = (IContributionItem)iter.next();
- }
-
- return newItems;
- }
-
- // expose
- public TreeViewer getTreeViewer()
- {
- return treeViewer;
- }
-
- FilterAction referenceAction, inheritedAction;
-
- private void updateActions(Action current)
- {
- if (referenceAction.isChecked())
- {
- getXSDEditor().getXSDModelAdapterFactory().setShowReferences(true);
- }
- else
- {
- getXSDEditor().getXSDModelAdapterFactory().setShowReferences(false);
- }
- if (inheritedAction.isChecked())
- {
- getXSDEditor().getXSDModelAdapterFactory().setShowInherited(true);
- }
- else
- {
- getXSDEditor().getXSDModelAdapterFactory().setShowInherited(false);
- }
- getTreeViewer().refresh();
- }
-
- public class FilterAction extends PropertyChangeUpdateAction
- {
- ViewerFilter filter;
-
- public FilterAction(IPreferenceStore store, String preference, ViewerFilter filter, String label, ImageDescriptor image)
- {
- super(label, store, preference, true);
- setImageDescriptor(image);
- setUpdateFromPropertyChange(false);
- this.filter = filter;
- setChecked(false);
- }
-
- public void update()
- {
- super.update();
- updateActions(this);
- }
- }
-
- class ReferenceFilter extends ViewerFilter // Dummy filter
- {
- public ReferenceFilter(String elementTag)
- {
- this.elementTag = elementTag;
- }
- protected String elementTag;
-
- public boolean select(Viewer viewer, Object parentElement, Object element)
- {
- return true;
- }
- }
-
- class SelectionManagerSelectionChangeListener implements ISelectionChangedListener
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- if (event.getSelectionProvider() != getTreeViewer())
- {
- StructuredSelection selection = (StructuredSelection)event.getSelection();
- if (selection.getFirstElement() instanceof XSDSchema)
- {
- StructuredSelection s = (StructuredSelection)getTreeViewer().getSelection();
- if (!(s.getFirstElement() instanceof CategoryAdapter))
- {
- getTreeViewer().setSelection(event.getSelection(), true);
- }
- }
- else
- {
- getTreeViewer().setSelection(event.getSelection(), true);
- }
- }
- }
- }
-
- public void unconfigure(TreeViewer viewer) {
- super.unconfigure(viewer);
- getXSDEditor().getSelectionManager().removeSelectionChangedListener(selectionManagerSelectionChangeListener);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlinePage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlinePage.java
deleted file mode 100644
index f6ab990276..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDContentOutlinePage.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-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.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
-import org.eclipse.wst.xsd.ui.internal.actions.OpenSchemaAction;
-import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.w3c.dom.Element;
-
-/**
- * @deprecated Using SSE's ConfiguratbleContentOutlinePage
- * instead via XSDContentOutlineCOnfiguration
- */
-public class XSDContentOutlinePage extends ContentOutlinePage implements ISelectionListener
-{
- protected XSDEditor xsdEditor;
- protected int level = 0;
- protected Object model;
- protected ITreeContentProvider contentProvider;
- protected ILabelProvider labelProvider;
- protected XSDSelectionManager selectionManager;
- protected SelectionManagerSelectionChangeListener selectionManagerSelectionChangeListener = new SelectionManagerSelectionChangeListener();
- protected TreeSelectionChangeListener treeSelectionChangeListener = new TreeSelectionChangeListener();
- XSDEditor xsdTextEditor;
- XSDMenuListener menuListener;
- SelectionProvider fSelectionProvider = null;
-
- /**
- *
- */
- public XSDContentOutlinePage(XSDEditor xsdTextEditor)
- {
- super();
- this.xsdTextEditor = xsdTextEditor;
- fSelectionProvider = new SelectionProvider();
- }
-
- public void init(IPageSite pageSite)
- {
- super.init(pageSite);
- getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
- getSite().setSelectionProvider(fSelectionProvider);
- }
-
- public void dispose()
- {
- super.dispose();
- getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(this);
- }
-
- public void setModel(Object newModel)
- {
- model = newModel;
- }
-
- public void setContentProvider(ITreeContentProvider contentProvider)
- {
- this.contentProvider = contentProvider;
- }
-
- public void setLabelProvider(ILabelProvider labelProvider)
- {
- this.labelProvider = labelProvider;
- }
-
- // expose
- public TreeViewer getTreeViewer()
- {
- return super.getTreeViewer();
- }
-
- public void createControl(Composite parent)
- {
- super.createControl(parent);
- getTreeViewer().setContentProvider(contentProvider);
- getTreeViewer().setLabelProvider(labelProvider);
- getTreeViewer().setInput(model);
-// getTreeViewer().addSelectionChangedListener(this);
- MenuManager menuManager = new MenuManager("#popup");//$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- Menu menu = menuManager.createContextMenu(getTreeViewer().getControl());
- getTreeViewer().getControl().setMenu(menu);
- menuListener = new XSDMenuListener(xsdTextEditor.getSelectionManager());
-// menuListener.setSelectionProvider(getTreeViewer());
- menuManager.addMenuListener(menuListener);
-
- // enable popupMenus extension
- getSite().registerContextMenu("org.eclipse.wst.xsd.ui.popup.outline", menuManager, xsdTextEditor.getSelectionManager());
-
- setSelectionManager(xsdTextEditor.getSelectionManager());
- // cs... why are we doing this from the outline view?
- //
- //xsdTextEditor.getXSDEditor().getSelectionManager().setSelection(new
- // StructuredSelection(xsdTextEditor.getXSDSchema()));
- XSDKeyListener keyListener = new XSDKeyListener(getTreeViewer(), menuListener);
- getTreeViewer().getControl().addKeyListener(keyListener);
- // drill down from outline view
- getTreeViewer().getControl().addMouseListener(new MouseAdapter()
- {
- public void mouseDoubleClick(MouseEvent e)
- {
- ISelection iSelection = getTreeViewer().getSelection();
- if (iSelection instanceof StructuredSelection)
- {
- StructuredSelection selection = (StructuredSelection)iSelection;
- Object obj = selection.getFirstElement();
- if (obj instanceof XSDConcreteComponent)
- {
- XSDConcreteComponent comp = (XSDConcreteComponent)obj;
- if (comp.getContainer() instanceof XSDSchema)
- {
- xsdTextEditor.getGraphViewer().setInput(obj);
- }
- }
- }
-
- }
- });
-
-
- getTreeViewer().addPostSelectionChangedListener(fSelectionProvider.getPostSelectionChangedListener());
- getTreeViewer().addSelectionChangedListener(fSelectionProvider.getSelectionChangedListener());
-
- }
- class XSDKeyListener extends KeyAdapter
- {
- TreeViewer viewer;
- XSDMenuListener menuListener;
-
- public XSDKeyListener(TreeViewer viewer, XSDMenuListener menuListener)
- {
- super();
- this.viewer = viewer;
- this.menuListener = menuListener;
- }
-
- /**
- * @see org.eclipse.swt.events.KeyAdapter#keyReleased(KeyEvent)
- */
- public void keyReleased(KeyEvent e)
- {
- if (e.character == SWT.DEL)
- {
- menuListener.getDeleteAction().run();
- }
- else if (e.keyCode == SWT.F3) // open editor on any
- // include/import/redefine
- {
- if (e.widget instanceof Tree)
- {
- Tree tree = (Tree) e.widget;
- TreeItem[] selection = tree.getSelection();
- if (selection.length > 0)
- {
- if (selection[0].getData() instanceof XSDSchemaDirective)
- {
- XSDSchemaDirective comp = (XSDSchemaDirective) selection[0].getData();
- OpenSchemaAction openSchema = new OpenSchemaAction(XSDEditorPlugin.getXSDString("_UI_ACTION_OPEN_SCHEMA"), comp);
- openSchema.run();
- }
- }
- }
- }
- }
- }
-
- public void setExpandToLevel(int i)
- {
- level = i;
- }
-
- public void setInput(Object value)
- {
- getTreeViewer().setInput(value);
- getTreeViewer().expandToLevel(level);
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection)
- {
- if (selectionManager != null)
- {
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object o = structuredSelection.getFirstElement();
- // TODO ...
- // we need to implement a selectionManagerMapping extension point
- // so that extensions can specify how they'd like to map view objects
- // to selection objects
- //
- if (o instanceof Element)
- {
- try
- {
- Object modelObject = xsdTextEditor.getXSDSchema().getCorrespondingComponent((Element) o);
- if (modelObject != null)
- {
- o = modelObject;
- }
- }
- catch (Exception e)
- {
- }
- }
- else if (o instanceof CategoryAdapter)
- {
- // todo... we need to ensure we eliminate the propagation
- // of 'view' specific objects into the SelectionManager.
- // We need to do some work to ensure all views utilize the 'Category' model object
- // so we can get rid of this CategoryAdapter class.
-// CategoryAdapter adapter = (CategoryAdapter) o;
-// o = adapter.getXSDSchema();
- }
- if (o != null)
- {
- if (getControl() != null && !getControl().isDisposed() && !getControl().isFocusControl() && getControl().isVisible()) {
- /*
- * Do not allow selection from other parts to affect selection
- * in the tree widget if it has focus. Selection events
- * "bouncing" off of other parts are all that we can receive
- * if we have focus (since we forward selection to the
- * service), and only the user should affect selection if we
- * have focus.
- */
- getTreeViewer().setSelection(new StructuredSelection(o), true);
- }
- selectionManager.setSelection(new StructuredSelection(o), getTreeViewer());
-// selectionManager.selectionChanged(new SelectionChangedEvent(getTreeViewer(),new StructuredSelection(o)));
- }
- else
- {
- // selectionManager.setSelection(new StructuredSelection(),
- // getTreeViewer());
- }
- }
- }
- }
-
- public void setSelectionManager(XSDSelectionManager newSelectionManager)
- {
- TreeViewer treeViewer = getTreeViewer();
- // disconnect from old one
- if (selectionManager != null)
- {
- selectionManager.removeSelectionChangedListener(selectionManagerSelectionChangeListener);
- treeViewer.removeSelectionChangedListener(treeSelectionChangeListener);
- }
- selectionManager = newSelectionManager;
- // connect to new one
- if (selectionManager != null)
- {
- selectionManager.addSelectionChangedListener(selectionManagerSelectionChangeListener);
- treeViewer.addSelectionChangedListener(treeSelectionChangeListener);
- }
- }
-
- class SelectionManagerSelectionChangeListener implements ISelectionChangedListener
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- if (event.getSelectionProvider() != getTreeViewer())
- {
- getTreeViewer().setSelection(event.getSelection(), true);
- }
- }
- }
- class TreeSelectionChangeListener implements ISelectionChangedListener
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- if (selectionManager != null)
- {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object o = structuredSelection.getFirstElement();
- // TODO ...
- // we need to implement a selectionManagerMapping extension point
- // so that extensions can specify how they'd like to map view objects
- // to selection objects
- //
- if (o instanceof Element)
- {
- try
- {
- Object modelObject = xsdTextEditor.getXSDSchema().getCorrespondingComponent((Element) o);
- if (modelObject != null)
- {
- o = modelObject;
- }
- }
- catch (Exception e)
- {
- }
- }
- else if (o instanceof CategoryAdapter)
- {
- // todo... we need to ensure we eliminate the propagation
- // of 'view' specific objects into the SelectionManager.
- // We need to do some work to ensure all views utilize the 'Category' model object
- // so we can get rid of this CategoryAdapter class.
-// CategoryAdapter adapter = (CategoryAdapter) o;
-// o = adapter.getXSDSchema();
- }
- if (o != null)
- {
- selectionManager.setSelection(new StructuredSelection(o), getTreeViewer());
-// selectionManager.selectionChanged(new SelectionChangedEvent(getTreeViewer(),new StructuredSelection(o)));
- }
- }
- }
- }
- }
- FilterAction referenceAction, inheritedAction;
-
- public void setActionBars(IActionBars actionBars)
- {
- super.setActionBars(actionBars);
- // Uncomment to add sort action
- // SortAction sortAction = new SortAction();
- //
- // actionBars.getToolBarManager().add(sortAction);
- // sortAction.setChecked(false);
- referenceAction = new FilterAction(new ReferenceFilter("Reference Content"), XSDEditorPlugin.getXSDString("_UI_OUTLINE_SHOW_REFERENCES"), ImageDescriptor.createFromFile(XSDEditorPlugin
- .getPlugin().getClass(), "icons/XSDElementRef.gif"));
- boolean initialRef = xsdTextEditor.getXSDModelAdapterFactory().getShowReferences();
- referenceAction.setChecked(initialRef);
- inheritedAction = new FilterAction(new ReferenceFilter("Inherited Content"), XSDEditorPlugin.getXSDString("_UI_OUTLINE_SHOW_INHERITED"), ImageDescriptor.createFromFile(XSDEditorPlugin.getPlugin()
- .getClass(), "icons/XSDComplexContent.gif"));
- IMenuManager menu = actionBars.getMenuManager();
- menu.add(referenceAction);
- menu.add(inheritedAction);
- }
-
- private void updateActions(Action current)
- {
- if (referenceAction.isChecked())
- {
- xsdTextEditor.getXSDModelAdapterFactory().setShowReferences(true);
- }
- else
- {
- xsdTextEditor.getXSDModelAdapterFactory().setShowReferences(false);
- }
- if (inheritedAction.isChecked())
- {
- xsdTextEditor.getXSDModelAdapterFactory().setShowInherited(true);
- }
- else
- {
- xsdTextEditor.getXSDModelAdapterFactory().setShowInherited(false);
- }
- }
- private Sorter sorter = new Sorter();
- public class Sorter extends org.eclipse.jface.viewers.ViewerSorter
- {
- }
- public class SortAction extends Action
- {
- public SortAction()
- {
- super("Sort", ImageDescriptor.createFromFile(XSDEditorPlugin.getPlugin().getClass(), "icons/sort.gif"));
- }
-
- public void run()
- {
- getTreeViewer().getControl().setVisible(false);
- Object[] expandedElements = getTreeViewer().getExpandedElements();
- getTreeViewer().setSorter(isChecked() ? sorter : null);
- Object input = getTreeViewer().getInput();
- getTreeViewer().setInput(input);
- getTreeViewer().setExpandedElements(expandedElements);
- getTreeViewer().getControl().setVisible(true);
- }
-
- public void setChecked(boolean checked)
- {
- super.setChecked(checked);
- setToolTipText(checked ? XSDEditorPlugin.getXSDString("_UI_OUTLINE_DO_NOT_SORT") : XSDEditorPlugin.getXSDString("_UI_OUTLINE_SORT"));
- }
- }
- public class FilterAction extends Action
- {
- ViewerFilter filter;
-
- public FilterAction(ViewerFilter filter, String label, ImageDescriptor image)
- {
- super(label, image);
- this.filter = filter;
- setChecked(false);
- }
-
- public void run()
- {
- updateActions(this);
- if (isChecked())
- {
- getTreeViewer().resetFilters();
- getTreeViewer().addFilter(filter);
- }
- else
- {
- getTreeViewer().removeFilter(filter);
- }
- }
- }
- class ReferenceFilter extends ViewerFilter // Dummy filter
- {
- public ReferenceFilter(String elementTag)
- {
- this.elementTag = elementTag;
- }
- protected String elementTag;
-
- public boolean select(Viewer viewer, Object parentElement, Object element)
- {
- return true;
- }
- }
-
- /**
- * Forwards post-selection from the tree viewer to the listeners while
- * acting as this page's selection provider.
- */
- private class SelectionProvider implements IPostSelectionProvider {
- private class PostSelectionChangedListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- if (!isFiringSelection()) {
- fireSelectionChanged(event, postListeners);
- }
- }
- }
-
- private class SelectionChangedListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- if (!isFiringSelection()) {
- fireSelectionChanged(event, listeners);
- }
- }
- }
-
- private boolean isFiringSelection = false;
- private ListenerList listeners = new ListenerList();
- private ListenerList postListeners = new ListenerList();
- private ISelectionChangedListener postSelectionChangedListener = new PostSelectionChangedListener();
- private ISelectionChangedListener selectionChangedListener = new SelectionChangedListener();
-
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- postListeners.add(listener);
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- listeners.add(listener);
- }
-
- public void fireSelectionChanged(final SelectionChangedEvent event, ListenerList listenerList) {
- isFiringSelection = true;
- Object[] listeners = listenerList.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
- Platform.run(new SafeRunnable() {
- public void run() {
- l.selectionChanged(event);
- }
- });
- }
- isFiringSelection = false;
- }
-
- public void fireSelectionChanged(final SelectionChangedEvent event) {
- isFiringSelection = true;
- Object[] listeners = postListeners.getListeners();
- for (int i = 0; i < listeners.length; ++i) {
- final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
- Platform.run(new SafeRunnable() {
- public void run() {
- l.selectionChanged(event);
- }
- });
- }
- isFiringSelection = false;
- }
-
- public ISelectionChangedListener getPostSelectionChangedListener() {
- return postSelectionChangedListener;
- }
-
- public ISelection getSelection() {
- if (getTreeViewer() != null) {
- return getTreeViewer().getSelection();
- }
- return StructuredSelection.EMPTY;
- }
-
- public ISelectionChangedListener getSelectionChangedListener() {
- return selectionChangedListener;
- }
-
- public boolean isFiringSelection() {
- return isFiringSelection;
- }
-
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- postListeners.remove(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- listeners.remove(listener);
- };
-
- public void setSelection(ISelection selection) {
- if (isFiringSelection) {
- getTreeViewer().setSelection(selection);
- }
- };
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditor.java
deleted file mode 100644
index c8ec40183d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditor.java
+++ /dev/null
@@ -1,867 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStackListener;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartListener;
-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.editors.text.ILocationProvider;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage;
-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.graph.XSDGraphViewer;
-import org.eclipse.wst.xsd.ui.internal.properties.section.XSDTabbedPropertySheetPage;
-import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDAdapterFactoryLabelProvider;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl;
-import org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter;
-import org.eclipse.wst.xsd.ui.internal.util.OpenOnSelectionHelper;
-import org.eclipse.xsd.XSDComponent;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-
-// public class XSDEditor extends StructuredTextMultiPageEditorPart
-public class XSDEditor extends XSDMultiPageEditorPart implements ITabbedPropertySheetPageContributor {
- protected StructuredTextEditor textEditor;
- IFile resourceFile;
- XSDSelectionManager xsdSelectionManager;
- XSDModelAdapter schemalNodeAdapter;
-
- private IStructuredModel result;
-
- /**
- * Listener on SSE's outline page's selections that converts DOM
- * selections into wsdl selections and notifies WSDL selection manager
- */
- class OutlineTreeSelectionChangeListener implements ISelectionChangedListener, IDoubleClickListener {
- public OutlineTreeSelectionChangeListener() {
- }
-
- private ISelection getXSDSelection(ISelection selection) {
- ISelection sel = null;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object o = structuredSelection.getFirstElement();
- if (o != null)
- sel = new StructuredSelection(o);
- }
- return sel;
- }
-
- /**
- * Determines DOM node based on object (xsd node)
- *
- * @param object
- * @return
- */
- private Object getObjectForOtherModel(Object object) {
- Node node = null;
-
- if (object instanceof Node) {
- node = (Node) object;
- }
- else if (object instanceof XSDComponent) {
- node = ((XSDComponent) object).getElement();
- }
- else if (object instanceof CategoryAdapter) {
- node = ((CategoryAdapter) object).getXSDSchema().getElement();
- }
-
- // the text editor can only accept sed nodes!
- //
- if (!(node instanceof IDOMNode)) {
- node = null;
- }
- return node;
- }
-
- public void doubleClick(DoubleClickEvent event) {
- /*
- * Selection in outline tree changed so set outline tree's
- * selection into editor's selection and say it came from outline
- * tree
- */
- if (getSelectionManager() != null && getSelectionManager().enableNotify) {
- ISelection selection = getXSDSelection(event.getSelection());
- if (selection != null) {
- getSelectionManager().setSelection(selection, fOutlinePage);
- }
-
- if (getTextEditor() != null && selection instanceof IStructuredSelection) {
- int start = -1;
- int length = 0;
- Object o = ((IStructuredSelection) selection).getFirstElement();
- if (o != null)
- o = getObjectForOtherModel(o);
- if (o instanceof IndexedRegion) {
- start = ((IndexedRegion) o).getStartOffset();
- length = ((IndexedRegion) o).getEndOffset() - start;
- }
- if (start > -1) {
- getTextEditor().selectAndReveal(start, length);
- }
- }
- }
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- /*
- * Selection in outline tree changed so set outline tree's
- * selection into editor's selection and say it came from outline
- * tree
- */
- if (getSelectionManager() != null) { // && getSelectionManager().enableNotify) {
-
- ISelection selection = getXSDSelection(event.getSelection());
- if (selection != null) {
- getSelectionManager().setSelection(selection, fOutlinePage);
- }
- }
- }
- }
-
- /**
- * Listener on SSE's source editor's selections that converts DOM
- * selections into xsd selections and notifies XSD selection manager
- */
- private class SourceEditorSelectionListener implements ISelectionChangedListener {
- /**
- * Determines XSD node based on object (DOM node)
- *
- * @param object
- * @return
- */
- private Object getXSDNode(Object object) {
- // get the element node
- Element element = null;
- if (object instanceof Node) {
- Node node = (Node) object;
- if (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- element = (Element) node;
- }
- else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- element = ((Attr) node).getOwnerElement();
- }
- }
- }
- Object o = element;
- if (element != null) {
- Object modelObject = getXSDSchema().getCorrespondingComponent(element);
- if (modelObject != null) {
- o = modelObject;
- }
- }
- return o;
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- List xsdSelections = new ArrayList();
- for (Iterator i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
- Object domNode = i.next();
- Object xsdNode = getXSDNode(domNode);
- if (xsdNode != null) {
- xsdSelections.add(xsdNode);
- }
- }
-
- if (!xsdSelections.isEmpty()) {
- StructuredSelection xsdSelection = new StructuredSelection(xsdSelections);
- getSelectionManager().setSelection(xsdSelection, getTextEditor().getSelectionProvider());
- }
- }
- }
- }
-
- /**
- * Listener on XSD's selection manager's selections that converts XSD
- * selections into DOM selections and notifies SSE's selection provider
- */
- private class XSDSelectionManagerSelectionListener implements ISelectionChangedListener {
- /**
- * Determines DOM node based on object (xsd node)
- *
- * @param object
- * @return
- */
- private Object getObjectForOtherModel(Object object) {
- Node node = null;
-
- if (object instanceof Node) {
- node = (Node) object;
- }
- else if (object instanceof XSDComponent) {
- node = ((XSDComponent) object).getElement();
- }
- else if (object instanceof CategoryAdapter) {
- node = ((CategoryAdapter) object).getXSDSchema().getElement();
- }
-
- // the text editor can only accept sed nodes!
- //
- if (!(node instanceof IDOMNode)) {
- node = null;
- }
- return node;
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- // do not fire selection in source editor if selection event came
- // from source editor
- if (event.getSource() != getTextEditor().getSelectionProvider()) {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- List otherModelObjectList = new ArrayList();
- for (Iterator i = ((IStructuredSelection) selection).iterator(); i.hasNext();) {
- Object modelObject = i.next();
- Object otherModelObject = getObjectForOtherModel(modelObject);
- if (otherModelObject != null) {
- otherModelObjectList.add(otherModelObject);
- }
- }
- if (!otherModelObjectList.isEmpty()) {
- StructuredSelection nodeSelection = new StructuredSelection(otherModelObjectList);
- getTextEditor().getSelectionProvider().setSelection(nodeSelection);
- }
- }
- }
- }
- }
-
- public XSDEditor() {
- super();
- xsdSelectionManager = new XSDSelectionManager();
- }
-
- InternalPartListener partListener = new InternalPartListener(this);
-
- // show outline view - defect 266116
- public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
- super.init(site, editorInput);
- IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = dw.getActivePage();
- getSite().getPage().addPartListener(partListener);
- try {
- if (page != null) {
- // page.showView("org.eclipse.ui.views.ContentOutline");
- page.showView("org.eclipse.ui.views.PropertySheet");
- }
- }
- catch (PartInitException e) {
- // e.printStackTrace();
- }
- }
-
- // For team support
- // protected PropertyDirtyChangeListener propertyChangeListener;
-
- /**
- * Creates the pages of this multi-page editor.
- * <p>
- * Subclasses of <code>MultiPageEditor</code> must implement this
- * method.
- * </p>
- */
- protected void createPages() {
- try {
- if (!loadFile())
- return;
-
- xsdModelAdapterFactory = XSDModelAdapterFactoryImpl.getInstance();
- adapterFactoryLabelProvider = new XSDAdapterFactoryLabelProvider(xsdModelAdapterFactory);
-
- // source page MUST be created before design page, now
- createSourcePage();
-
- addSourcePage();
- buildXSDModel();
-
- // comment this line out to hide the graph page
- //
- createAndAddGraphPage();
-
- int pageIndexToShow = getDefaultPageTypeIndex();
- setActivePage(pageIndexToShow);
-
- openOnSelectionHelper = new OpenOnSelectionHelper(textEditor, getXSDSchema());
- // added selection listeners after setting selection to avoid
- // navigation exception
- ISelectionProvider provider = getTextEditor().getSelectionProvider();
- fSourceEditorSelectionListener = new SourceEditorSelectionListener();
- if (provider instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) provider).addPostSelectionChangedListener(fSourceEditorSelectionListener);
- }
- else {
- provider.addSelectionChangedListener(fSourceEditorSelectionListener);
- }
- fXSDSelectionListener = new XSDSelectionManagerSelectionListener();
- getSelectionManager().addSelectionChangedListener(fXSDSelectionListener);
-
- addCommandStackListener();
-
- XSDEditorPlugin.getPlugin().getPreferenceStore().addPropertyChangeListener(preferenceStoreListener);
- }
- catch (PartInitException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
-
- public void buildXSDModel() {
- try {
- Document document = ((IDOMModel) getModel()).getDocument();
-
- boolean schemaNodeExists = document.getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "schema").getLength() == 1;
-
- if (document.getChildNodes().getLength() == 0 || !schemaNodeExists) {
- createDefaultSchemaNode(document);
- }
-
- if (document instanceof INodeNotifier) {
- INodeNotifier notifier = (INodeNotifier) document;
- schemalNodeAdapter = (XSDModelAdapter) notifier.getAdapterFor(XSDModelAdapter.class);
- if (schemalNodeAdapter == null) {
- schemalNodeAdapter = new XSDModelAdapter();
- notifier.addAdapter(schemalNodeAdapter);
- schemalNodeAdapter.createSchema(document.getDocumentElement());
- }
- }
- }
- catch (Exception e) {
- // XSDEditorPlugin.getPlugin().getMsgLogger().write("Failed to
- // create Model");
- // XSDEditorPlugin.getPlugin().getMsgLogger().write(e);
- // e.printStackTrace();
- }
-
-
-
- // XSDResourceFactoryImpl.validate(xsdSchema,
- // input.getFile().getContents(true));
- }
-
- public String[] getPropertyCategories() {
- return new String[]{"general", "namespace", "other", "attributes", "documentation", "facets"}; //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor#getContributorId()
- */
- public String getContributorId() {
- return "org.eclipse.wst.xsd.ui.internal.XSDEditor";
- // return getSite().getId();
- }
-
- protected CommandStackListener commandStackListener;
-
- protected void addCommandStackListener() {
- if (commandStackListener == null) {
- IStructuredTextUndoManager undoManager = getModel().getUndoManager();
- commandStackListener = new CommandStackListener() {
- /**
- * @see org.eclipse.emf.common.command.CommandStackListener#commandStackChanged(EventObject)
- */
- public void commandStackChanged(EventObject event) {
- Object obj = event.getSource();
- if (obj instanceof BasicCommandStack) {
- BasicCommandStack stack = (BasicCommandStack) obj;
- Command recentCommand = stack.getMostRecentCommand();
- Command redoCommand = stack.getRedoCommand();
- Command undoCommand = stack.getUndoCommand();
- if (recentCommand == redoCommand) {
- // there must have been an undo reset info tasks
- resetInformationTasks();
- }
- }
- }
- };
-
- // TODO WTP Port
- // undoManager.getCommandStack().addCommandStackListener(commandStackListener);
-
- }
- }
-
- protected void pageChange(int arg) {
- super.pageChange(arg);
- }
-
- protected void removeCommandStackListener() {
- if (commandStackListener != null) {
- IStructuredTextUndoManager undoManager = getModel().getUndoManager();
- // TODO WTP Port
- // undoManager.getCommandStack().removeCommandStackListener(commandStackListener);
- }
- }
-
- // This is from the IValidateEditEditor interface
- /*
- * public void undoChange() { StructuredTextUndoManager undoManager =
- * textEditor.getModel().getUndoManager(); undoManager.undo(); // Make the
- * editor clean textEditor.getModel().setDirtyState(false); }
- */
-
- private class PreferenceStoreListener implements IPropertyChangeListener {
- /**
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- }
- }
-
- protected IPropertyChangeListener preferenceStoreListener = new PreferenceStoreListener();
-
- protected int getDefaultPageTypeIndex() {
- int pageIndex = sourcePageIndex;
-
- if (XSDEditorPlugin.getPlugin().getDefaultPage().equals(XSDEditorPlugin.GRAPH_PAGE)) {
- if (graphPageIndex != -1)
- pageIndex = graphPageIndex;
- }
-
- return pageIndex;
- }
-
- int currentPage = -1;
-
- public String getCurrentPageType() {
- // should update pref. for valid pages
- if (getActivePage() != -1) {
- currentPage = getActivePage();
- }
- if (currentPage == graphPageIndex) {
- return XSDEditorPlugin.GRAPH_PAGE;
- }
- else {
- return XSDEditorPlugin.SOURCE_PAGE;
- }
- }
-
- public Object getActivePart() {
- return getSite().getWorkbenchWindow().getActivePage().getActivePart();
- }
-
- public void dispose() {
- // some things in the configuration need to clean
- // up after themselves
- if (fOutlinePage != null) {
- if (fOutlinePage instanceof ConfigurableContentOutlinePage && fOutlineListener != null) {
- ((ConfigurableContentOutlinePage) fOutlinePage).removeDoubleClickListener(fOutlineListener);
- }
- if (fOutlineListener != null) {
- fOutlinePage.removeSelectionChangedListener(fOutlineListener);
- }
- }
- ISelectionProvider provider = getTextEditor().getSelectionProvider();
- if (provider instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) provider).removePostSelectionChangedListener(fSourceEditorSelectionListener);
- }
- else {
- provider.removeSelectionChangedListener(fSourceEditorSelectionListener);
- }
- getSelectionManager().removeSelectionChangedListener(fXSDSelectionListener);
-
- // propertyChangeListener.dispose();
- removeCommandStackListener();
-
- XSDEditorPlugin.getPlugin().setDefaultPage(getCurrentPageType());
- XSDEditorPlugin.getPlugin().getPreferenceStore().removePropertyChangeListener(preferenceStoreListener);
-
- getSite().getPage().removePartListener(partListener);
-
- // KB: Temporary solution for bug 99468
- IStructuredModel myModel = textEditor.getModel();
- if (myModel != null && myModel instanceof IStructuredDocumentListener)
- myModel.getStructuredDocument().removeDocumentChangingListener((IStructuredDocumentListener) myModel);
-
- textEditor = null;
- resourceFile = null;
- xsdSelectionManager = null;
- schemalNodeAdapter = null;
- result = null;
- partListener = null;
- commandStackListener = null;
- preferenceStoreListener = null;
- openOnSelectionHelper = null;
- graphViewer = null;
-
- super.dispose();
-
- // release the schema model
- //
- if (schemalNodeAdapter != null) {
- schemalNodeAdapter.clear();
- schemalNodeAdapter = null;
- }
- }
-
- protected boolean loadFile() {
- Object input = getEditorInput();
-
- if (input instanceof IFileEditorInput) {
- resourceFile = ((IFileEditorInput) input).getFile();
- }
- else if (input instanceof ILocationProvider) {
- IPath path = ((ILocationProvider) input).getPath(input);
- String ext = path.getFileExtension();
- if (ext != null && ext.equals("xsd")) {
- return true;
- }
- return false;
- }
- else {
- return false;
- }
- return true;
- }
-
- /**
- * Method openOnGlobalReference. The comp argument is a resolved xsd
- * schema object from another file. This is created and called from
- * another schema model to allow F3 navigation to open a new editor and
- * choose the referenced object within that editor context
- *
- * @param comp
- */
- public void openOnGlobalReference(XSDConcreteComponent comp) {
- openOnSelectionHelper.openOnGlobalReference(comp);
- }
-
- protected OpenOnSelectionHelper openOnSelectionHelper;
-
- public OpenOnSelectionHelper getOpenOnSelectionHelper() {
- return openOnSelectionHelper;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.XSDMultiPageEditorPart#createTextEditor()
- */
- protected StructuredTextEditor createTextEditor() {
- textEditor = new StructuredTextEditor();
- return textEditor;
- }
-
- /*
- * @see StructuredTextMultiPageEditorPart#createSourcePage()
- */
- protected void createSourcePage() throws PartInitException {
- super.createSourcePage();
- }
-
- int sourcePageIndex = -1;
-
- /**
- * Adds the source page of the multi-page editor.
- */
- protected void addSourcePage() throws PartInitException {
-
- sourcePageIndex = addPage(textEditor, getEditorInput());
- setPageText(sourcePageIndex, XSDEditorPlugin.getXSDString("_UI_TAB_SOURCE"));
-
- // the update's critical, to get viewer selection manager and
- // highlighting to work
- textEditor.update();
- firePropertyChange(PROP_TITLE);
- }
-
- int graphPageIndex = -1;
- XSDGraphViewer graphViewer;
-
- /**
- * Creates the graph page and adds it to the multi-page editor.
- */
- protected void createAndAddGraphPage() throws PartInitException {
- graphViewer = new XSDGraphViewer(this);
- graphViewer.setSchema(getXSDSchema());
- Control graphControl = graphViewer.createControl(getContainer());
- graphPageIndex = addPage(graphControl);
- setPageText(graphPageIndex, XSDEditorPlugin.getXSDString("_UI_TAB_GRAPH"));
-
- // graphViewer.setViewerSelectionManager(textEditor.getViewerSelectionManager());
- graphViewer.setSelectionManager(getSelectionManager());
-
- // this forces the editor to initially select the top level schema
- // object
- //
- if (getXSDSchema() != null) {
- getSelectionManager().setSelection(new StructuredSelection(getXSDSchema()));
- }
- }
-
- protected XSDModelAdapterFactoryImpl xsdModelAdapterFactory;
- protected XSDAdapterFactoryLabelProvider adapterFactoryLabelProvider;
- private IPropertySheetPage fPropertySheetPage;
- private IContentOutlinePage fOutlinePage;
- private OutlineTreeSelectionChangeListener fOutlineListener;
- private SourceEditorSelectionListener fSourceEditorSelectionListener;
- private XSDSelectionManagerSelectionListener fXSDSelectionListener;
-
- /*
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class key) {
- Object result = null;
- if (key == ISelectionProvider.class) {
- result = xsdSelectionManager;
- }
- if (IPropertySheetPage.class.equals(key)) {
- fPropertySheetPage = new XSDTabbedPropertySheetPage(this);
-
- ((XSDTabbedPropertySheetPage) fPropertySheetPage).setXSDModelAdapterFactory(xsdModelAdapterFactory);
- ((XSDTabbedPropertySheetPage) fPropertySheetPage).setSelectionManager(getSelectionManager());
- ((XSDTabbedPropertySheetPage) fPropertySheetPage).setXSDSchema(getXSDSchema());
-
- return fPropertySheetPage;
- }
- else if (IContentOutlinePage.class.equals(key)) {
- if (fOutlinePage == null || fOutlinePage.getControl() == null || fOutlinePage.getControl().isDisposed()) {
- IContentOutlinePage page = (IContentOutlinePage) super.getAdapter(key);
- if (page != null) {
- fOutlineListener = new OutlineTreeSelectionChangeListener();
- page.addSelectionChangedListener(fOutlineListener);
- if (page instanceof ConfigurableContentOutlinePage) {
- ((ConfigurableContentOutlinePage) page).addDoubleClickListener(fOutlineListener);
- }
- }
- fOutlinePage = page;
- // XSDContentOutlinePage outlinePage = new
- // XSDContentOutlinePage(this);
- // XSDContentProvider xsdContentProvider = new
- // XSDContentProvider(xsdModelAdapterFactory);
- // xsdContentProvider.setXSDSchema(getXSDSchema());
- // outlinePage.setContentProvider(xsdContentProvider);
- // outlinePage.setLabelProvider(adapterFactoryLabelProvider);
- // outlinePage.setModel(getXSDSchema().getDocument());
- //
- // fOutlinePage = outlinePage;
- }
- return fOutlinePage;
- }
- else {
- result = super.getAdapter(key);
- }
- return result;
- }
-
-
- public XSDModelAdapterFactoryImpl getXSDModelAdapterFactory() {
- return xsdModelAdapterFactory;
- }
-
- public XSDAdapterFactoryLabelProvider getLabelProvider() {
- return adapterFactoryLabelProvider;
- }
-
-
- public XSDSelectionManager getSelectionManager() {
- return xsdSelectionManager;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.XSDMultiPageEditorPart#doSaveAs()
- */
- public void doSaveAs() {
- super.doSaveAs();
- }
-
- public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor) {
- super.doSave(monitor);
- }
-
- public void reparseSchema() {
- // TODO cs : Are there no better ways to make the model
- // reload it's dependencies? This seems rather extreme.
- //
- Document document = ((IDOMModel) getModel()).getDocument();
- if (schemalNodeAdapter != null) {
- schemalNodeAdapter.createSchema(document.getDocumentElement());
- }
- }
-
- /**
- * Returns the xsdSchema.
- *
- * @return XSDSchema
- */
- public XSDSchema getXSDSchema() {
- return schemalNodeAdapter != null ? schemalNodeAdapter.getSchema() : null;
- }
-
-
- /**
- * Returns the resourceFile.
- *
- * @return IFile
- */
- public IFile getFileResource() {
- return resourceFile;
- }
-
- /**
- * Get the IDocument from the text viewer
- */
- public IDocument getEditorIDocument() {
- IDocument document = textEditor.getTextViewer().getDocument();
- return document;
- }
-
- /**
- * Create ref integrity tasks in task list
- */
- public void createTasksInTaskList(ArrayList messages) {
- // DisplayErrorInTaskList tasks = new
- // DisplayErrorInTaskList(getEditorIDocument(), getFileResource(),
- // messages);
- // tasks.run();
- }
-
- public void resetInformationTasks() {
- // DisplayErrorInTaskList.removeInfoMarkers(getFileResource());
- }
-
- public XSDGraphViewer getGraphViewer() {
- return graphViewer;
- }
-
- public IEditorPart getActiveEditorPage() {
- return getActiveEditor();
- }
-
- public StructuredTextEditor getTextEditor() {
- return textEditor;
- }
-
- class InternalPartListener implements IPartListener {
- XSDEditor editor;
-
- public InternalPartListener(XSDEditor editor) {
- this.editor = editor;
- }
-
- public void partActivated(IWorkbenchPart part) {
- if (part == editor) {
- ISelection selection = getSelectionManager().getSelection();
- if (selection != null) {
- if (getCurrentPageType().equals(XSDEditorPlugin.GRAPH_PAGE)) {
- getSelectionManager().selectionChanged(new SelectionChangedEvent(editor.getGraphViewer().getComponentViewer(), selection));
- }
- else if (getCurrentPageType().equals(XSDEditorPlugin.SOURCE_PAGE)) {
- getSelectionManager().setSelection(selection);
- }
- }
- }
- }
-
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- public void partClosed(IWorkbenchPart part) {
- }
-
- public void partDeactivated(IWorkbenchPart part) {
- }
-
- public void partOpened(IWorkbenchPart part) {
- }
- }
-
-
- /**
- * Method createDefaultSchemaNode. Should only be called to insert a
- * schema node into an empty document
- */
- public void createDefaultSchemaNode(Document document) {
- if (document.getChildNodes().getLength() == 0) {
- // if it is a completely empty file, then add the encoding and
- // version processing instruction
- // TODO String encoding = EncodingHelper.getDefaultEncodingTag();
- String encoding = "UTF-8";
- ProcessingInstruction instr = document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + encoding + "\"");
- document.appendChild(instr);
- }
-
- // Create a default schema tag now
-
- // String defaultPrefixForTargetNamespace =
- // getFileResource().getProjectRelativePath().removeFileExtension().lastSegment();
- String defaultPrefixForTargetNamespace = "tns";
- String prefixForSchemaNamespace = "";
- String schemaNamespaceAttribute = "xmlns";
- if (XSDEditorPlugin.getPlugin().isQualifyXMLSchemaLanguage()) {
- // Added this if check before disallowing blank prefixes in the
- // preferences...
- // Can take this out. See also NewXSDWizard
- if (XSDEditorPlugin.getPlugin().getXMLSchemaPrefix().trim().length() > 0) {
- prefixForSchemaNamespace = XSDEditorPlugin.getPlugin().getXMLSchemaPrefix() + ":";
- schemaNamespaceAttribute += ":" + XSDEditorPlugin.getPlugin().getXMLSchemaPrefix();
- }
- }
-
- document.appendChild(document.createTextNode("\n"));
- Element element = document.createElement(prefixForSchemaNamespace + XSDConstants.SCHEMA_ELEMENT_TAG);
-
- element.setAttribute(schemaNamespaceAttribute, "http://www.w3.org/2001/XMLSchema");
-
- String defaultTargetURI = XSDEditorPlugin.getPlugin().getXMLSchemaTargetNamespace();
- element.setAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE, defaultTargetURI);
- element.setAttribute("xmlns:" + defaultPrefixForTargetNamespace, defaultTargetURI);
-
- document.appendChild(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorAdapter.java
deleted file mode 100644
index 7591376fb3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.IDocument;
-
-public interface XSDEditorAdapter
-{
- public IFile getFileResource();
-
- public IDocument getEditorIDocument();
-
- public void createTasksInTaskList(ArrayList messages);
-
- public void resetInformationTasks();
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorContextIds.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorContextIds.java
deleted file mode 100644
index 8f95f5c6eb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorContextIds.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-/**
- * Context help id constants.
- */
-public interface XSDEditorContextIds
-{
- public static final String PLUGIN_NAME = "org.eclipse.wst.xsd.ui.internal";
-
- /* CONTEXT_IDs New XSD Wizard uses the WizardNewFileCreationPage from org.eclipse.ui.dialogs */
-
- /* CONTEXT_IDs for XSDEditor follow the xsdexxx context IDs */
-
- /* CONTEXT_ID xsde0010 for XSD Editor Design View */
- public static final String XSDE_SCHEMA_DESIGN_VIEW = PLUGIN_NAME + ".xsde0010";
- /* no CONTEXT_ID for File Name Text Edit (not editable) */
- /* CONTEXT_ID xsde0020 for Version Text Edit */
- public static final String XSDE_SCHEMA_VERSION = PLUGIN_NAME + ".xsde0020";
- /* CONTEXT_ID xsde0030 for Language Text Edit */
- public static final String XSDE_SCHEMA_LANGUAGE = PLUGIN_NAME + ".xsde0030";
- /* CONTEXT_ID xsde0040 for Namespace Group */
- public static final String XSDE_SCHEMA_NAMESPACE_GROUP = PLUGIN_NAME + ".xsde0040";
- /* CONTEXT_ID xsde0050 for Prefix Text Edit */
- public static final String XSDE_SCHEMA_PREFIX = PLUGIN_NAME + ".xsde0050";
- /* CONTEXT_ID xsde0060 for Target namespace Text Edit */
- public static final String XSDE_SCHEMA_TARGET_NAMESPACE = PLUGIN_NAME + ".xsde0060";
- /* CONTEXT_ID xsde0070 for Apply Push Button */
- public static final String XSDE_SCHEMA_APPLY = PLUGIN_NAME + ".xsde0070";
- /* CONTEXT_ID xsde0080 for Attribute form default Combo Box */
- public static final String XSDE_SCHEMA_ATTRIBUTE = PLUGIN_NAME + ".xsde0080";
- /* CONTEXT_ID xsde0090 for Element form default Combo Box */
- public static final String XSDE_SCHEMA_ELEMENT = PLUGIN_NAME + ".xsde0090";
- /* CONTEXT_ID xsde0100 for Block default Combo Box */
- public static final String XSDE_SCHEMA_BLOCK = PLUGIN_NAME + ".xsde0100";
- /* CONTEXT_ID xsde0110 for Final Default Combo Box */
- public static final String XSDE_SCHEMA_FINAL = PLUGIN_NAME + ".xsde0110";
-
-
- /* CONTEXT_ID xsde0200 for Annotations Comment Group - only used generically */
- /* CONTEXT_ID - used in Documentation Design View */
- /* CONTEXT_ID - used in App Info Design View */
- public static final String XSDE_ANNOTATION_COMMENT_GROUP = PLUGIN_NAME + ".xsde0200";
- /* CONTEXT_ID xsde0210 for Annotations Comment Group - only used generically */
- /* CONTEXT_ID - used in Documentation Design View */
- /* CONTEXT_ID - used in App Info Design View */
- public static final String XSDE_ANNOTATION_COMMENT = PLUGIN_NAME + ".xsde0210";
-
- /* CONTEXT_ID xsde0300 for Documentation Design View */
- public static final String XSDE_DOCUMENTATION_DESIGN_VIEW = PLUGIN_NAME + ".xsde0300";
- /* CONTEXT_ID xsde0310 for Source Text Edit */
- public static final String XSDE_DOCUMENTATION_SOURCE = PLUGIN_NAME + ".xsde0310";
- /* CONTEXT_ID xsde0320 for Language Text Edit */
- public static final String XSDE_DOCUMENTATION_LANGUAGE = PLUGIN_NAME + ".xsde0320";
- /* CONTEXT_ID Comment Group is from Annotations Window xsde0200 */
- /* CONTEXT_ID Comment Multi-line Edit is from Annotations Window xsd0210 */
-
- /* CONTEXT_ID xsde0400 for App Info Design View */
- public static final String XSDE_APP_INFO_DESIGN_VIEW = PLUGIN_NAME + ".xsde0400";
- /* CONTEXT_ID xsde0410 for App Info Source Text Edit */
- public static final String XSDE_APP_INFO_SOURCE = PLUGIN_NAME + ".xsde0410";
- /* CONTEXT_ID Comment Group is from Annotations Window xsde0200 */
- /* CONTEXT_ID Comment Multi-line Edit is from Annotations Window xsd0210 */
-
- /* CONTEXT_ID xsde0500 for Complex Type Design View */
- public static final String XSDE_COMPLEX_DESIGN_VIEW = PLUGIN_NAME + ".xsde0500";
- /* CONTEXT_ID xsde0510 for Name Text Edit */
- public static final String XSDE_COMPLEX_NAME = PLUGIN_NAME + ".xsde0510";
- /* CONTEXT_ID xsde0520 for Abstract Combo Box */
- public static final String XSDE_COMPLEX_ABSTRACT = PLUGIN_NAME + ".xsde0520";
- /* CONTEXT_ID xsde0530 for Mixed Combo Box */
- public static final String XSDE_COMPLEX_MIXED = PLUGIN_NAME + ".xsde0530";
- /* CONTEXT_ID xsde0540 for Block Combo Box */
- public static final String XSDE_COMPLEX_BLOCK = PLUGIN_NAME + ".xsde0540";
- /* CONTEXT_ID xsde0550 for Final Combo Box */
- public static final String XSDE_COMPLEX_FINAL = PLUGIN_NAME + ".xsde0550";
-
- /* CONTEXT_ID xsde0600 for Simple Type Design View */
- public static final String XSDE_SIMPLE_DESIGN_VIEW = PLUGIN_NAME + ".xsde0600";
- /* CONTEXT_ID xsde0610 for Name Text Edit */
- public static final String XSDE_SIMPLE_NAME = PLUGIN_NAME + ".xsde0610";
-
- /* CONTEXT_ID for Global Element and Element Design Views are the same */
- /* CONTEXT_ID xsde0700 for Element Design View */
- public static final String XSDE_ELEMENT_DESIGN_VIEW = PLUGIN_NAME + ".xsde0700";
- /* CONTEXT_ID xsde0710 for Element Name Text Edit */
- public static final String XSDE_ELEMENT_NAME = PLUGIN_NAME + ".xsde0710";
- /* CONTEXT_ID Type Information Group is from Type Helper xsde0900 */
- /* CONTEXT_ID Built-in simple type Radio Button is from Type Helper xsde0920 */
- /* CONTEXT_ID User-defined simple type Radio Button is from Type Helper xsde0930 */
- /* CONTEXT_ID User-defined complex type Radio Button is from Type Helper xsde0940 */
- /* CONTEXT_ID Type information Combo Box is from Type Helper xsde0950 */
- /* CONTEXT_ID xsde0720 for Abstract Check Box */
- public static final String XSDE_ELEMENT_ABSTRACT = PLUGIN_NAME + ".xsde0720";
- /* CONTEXT_ID xsde0730 for Nillable Check Box */
- public static final String XSDE_ELEMENT_NILLABLE = PLUGIN_NAME + ".xsde0730";
- /* CONTEXT_ID xsde0740 for Value Group */
- public static final String XSDE_ELEMENT_VALUE = PLUGIN_NAME + ".xsde0740";
- /* CONTEXT_ID xsde0750 for Fixed Radio Button */
- public static final String XSDE_ELEMENT_FIXED = PLUGIN_NAME + ".xsde0750";
- /* CONTEXT_ID xsde0760 for Default Radio Button */
- public static final String XSDE_ELEMENT_DEFAULT = PLUGIN_NAME + ".xsde0760";
- /* CONTEXT_ID xsde0770 for Value Group */
- public static final String XSDE_ELEMENT_VALUE_GROUP = PLUGIN_NAME + ".xsde0770";
- /* CONTEXT_ID xsde0780 for Minimum Text Edit */
- public static final String XSDE_ELEMENT_MINIMUM = PLUGIN_NAME + ".xsde0780";
- /* CONTEXT_ID xsde0790 for Maximum Text Edit */
- public static final String XSDE_ELEMENT_MAXIMUM = PLUGIN_NAME + ".xsde0790";
- /* CONTEXT_ID xsde0800 for Block Combo Box */
- public static final String XSDE_ELEMENT_BLOCK = PLUGIN_NAME + ".xsde0800";
- /* CONTEXT_ID xsde0810 for Final Combo Box */
- public static final String XSDE_ELEMENT_FINAL = PLUGIN_NAME + ".xsde0810";
- /* CONTEXT_ID xsde0820 for Substitution Group Combo Box */
- public static final String XSDE_ELEMENT_SUBSTITUTION = PLUGIN_NAME + ".xsde0820";
- /* CONTEXT_ID xsde0830 for Form Qualification Combo Box */
- public static final String XSDE_ELEMENT_FORM = PLUGIN_NAME + ".xsde0830";
-
- /* CONTEXT_ID xsde0900 for Type Helper Group - only used generically */
- /* CONTEXT_ID - used in Global Element Design View */
- /* CONTEXT_ID - used in Global Attribute Design View */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Restriction Design View */
- /* CONTEXT_ID - used in List Design View */
- /* CONTEXT_ID - used in Union Design View */
- public static final String XSDE_TYPE_HELPER_GROUP = PLUGIN_NAME + ".xsde0900";
- /* CONTEXT_ID xsde0910 for None Radio Button - only used generically */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Restriction Design View */
- /* CONTEXT_ID - used in List Design View */
- /* CONTEXT_ID - used in Union Design View */
- public static final String XSDE_TYPE_HELPER_NONE = PLUGIN_NAME + ".xsde0910";
- /* CONTEXT_ID xsde0920 for Built-in simple type Radio Button - only used generically */
- /* CONTEXT_ID - used in Global Element Design View */
- /* CONTEXT_ID - used in Global Attribute Design View */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Restriction Design View */
- /* CONTEXT_ID - used in List Design View */
- /* CONTEXT_ID - used in Union Design View */
- public static final String XSDE_TYPE_HELPER_BUILT_IN = PLUGIN_NAME + ".xsde0920";
- /* CONTEXT_ID xsde0930 for User-defined simple type Radio Button - only used generically */
- /* CONTEXT_ID - used in Global Element Design View */
- /* CONTEXT_ID - used in Global Attribute Design View */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Restriction Design View */
- /* CONTEXT_ID - used in List Design View */
- /* CONTEXT_ID - used in Union Design View */
- public static final String XSDE_TYPE_HELPER_USER_DEFINED_SIMPLE = PLUGIN_NAME + ".xsde0930";
- /* CONTEXT_ID xsde0940 for User-defined complex type Radio Button - only used generically */
- /* CONTEXT_ID - used in Global Element Design View */
- public static final String XSDE_TYPE_HELPER_USER_DEFINED_COMPLEX = PLUGIN_NAME + ".xsde0940";
- /* CONTEXT_ID xsde0950 for Type information Combo Box - only used generically */
- /* CONTEXT_ID - used in Global Element Design View */
- /* CONTEXT_ID - used in Global Attribute Design View */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Restriction Design View */
- /* CONTEXT_ID - used in List Design View */
- public static final String XSDE_TYPE_HELPER_TYPE = PLUGIN_NAME + ".xsde0950";
-
- /* CONTEXT_ID xsde1000 for Attribute Design View */
- public static final String XSDE_ATTRIBUTE_DESIGN_VIEW = PLUGIN_NAME + ".xsde1000";
- /* CONTEXT_ID xsde1010 for Attribute Name Text Edit */
- public static final String XSDE_ATTRIBUTE_NAME = PLUGIN_NAME + ".xsde1010";
- /* CONTEXT_ID Type Information Group is from Type Helper xsde0900 */
- /* CONTEXT_ID Built-in simple type Radio Button is from Type Helper xsde0920 */
- /* CONTEXT_ID User-defined simple type Radio Button is from Type Helper xsde0930 */
- /* CONTEXT_ID Type information Combo Box is from Type Helper xsde0950 */
- /* CONTEXT_ID xsde1020 for Value Group */
- public static final String XSDE_ATTRIBUTE_VALUE_GROUP = PLUGIN_NAME + ".xsde1020";
- /* CONTEXT_ID xsde1030 for Fixed Radio Button */
- public static final String XSDE_ATTRIBUTE_FIXED = PLUGIN_NAME + ".xsde1030";
- /* CONTEXT_ID xsde1040 for Default Radio Button */
- public static final String XSDE_ATTRIBUTE_DEFAULT = PLUGIN_NAME + ".xsde1040";
- /* CONTEXT_ID xsde1050 for Value Text Edit */
- public static final String XSDE_ATTRIBUTE_VALUE = PLUGIN_NAME + ".xsde1050";
- /* CONTEXT_ID xsde1060 for Usage Combo Box */
- public static final String XSDE_ATTRIBUTE_USAGE = PLUGIN_NAME + ".xsde1060";
- /* CONTEXT_ID xsde1070 for Form qualificaiton Combo Box */
- public static final String XSDE_ATTRIBUTE_FORM = PLUGIN_NAME + ".xsde1070";
-
- /* CONTEXT_ID xsde1100 for Element Ref Window Design View */
- public static final String XSDE_ELEMENT_REF_DESIGN_VIEW = PLUGIN_NAME + ".xsde1100";
- /* CONTEXT_ID xsde1110 for Reference Name Combo Box */
- public static final String XSDE_ELEMENT_REF_REFERENCE = PLUGIN_NAME + ".xsde1110";
- /* CONTEXT_ID xsde1120 for Minimum Text Edit */
- public static final String XSDE_ELEMENT_REF_MINIMUM = PLUGIN_NAME + ".xsde1120";
- /* CONTEXT_ID xsde1130 for Maximum Text Edit */
- public static final String XSDE_ELEMENT_REF_MAXIMUM = PLUGIN_NAME + ".xsde1130";
-
- /* CONTEXT_ID xsde1200 for Simple Content Design View - used generically */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Complex Content Design View */
- public static final String XSDE_SIMPLE_CONTENT_DESIGN_VIEW = PLUGIN_NAME + ".xsde1200";
- /* CONTEXT_ID Base Type Group is from Type Helper xsde0900 */
- /* CONTEXT_ID None Radio Button is from Type Helper xsde0910 */
- /* CONTEXT_ID Built-in simple type Radio Button is from Type Helper xsde0920 */
- /* CONTEXT_ID User-defined simple type Radio Button is from Type Helper xsde0930 */
- /* CONTEXT_ID Type information Combo Box is from Type Helper xsde0950 */
- /* CONTEXT_ID xsde1210 for Derived by Combo Box - used generically */
- /* CONTEXT_ID - used in Simple Content Design View */
- /* CONTEXT_ID - used in Complex Content Design View */
- public static final String XSDE_SIMPLE_CONTENT_DERIVED = PLUGIN_NAME + ".xsde1210";
-
- /* CONTEXT_ID xsde1300 for Restriction Design View */
- public static final String XSDE_RESTRICTION_DESIGN_VIEW = PLUGIN_NAME + ".xsde1300";
- /* CONTEXT_ID Base Type Group is from Type Helper xsde0900 */
- /* CONTEXT_ID None Radio Button is from Type Helper xsde0910 */
- /* CONTEXT_ID Built-in simple type Radio Button is from Type Helper xsde0920 */
- /* CONTEXT_ID User-defined simple type Radio Button is from Type Helper xsde0930 */
- /* CONTEXT_ID Type information Combo Box is from Type Helper xsde0950 */
- /* CONTEXT_ID xsde1310 for Facets Group */
- public static final String XSDE_RESTRICTION_FACETS_GROUP = PLUGIN_NAME + ".xsde1310";
- /* CONTEXT_ID xsde1320 for Facets Table */
- public static final String XSDE_RESTRICTION_FACETS = PLUGIN_NAME + ".xsde1320";
-
- /* CONTEXT_ID xsde1400 for List Design View */
- public static final String XSDE_LIST_DESIGN_VIEW = PLUGIN_NAME + ".xsde1400";
- /* CONTEXT_ID Base Type Group is from Type Helper xsde0900 */
- /* CONTEXT_ID None Radio Button is from Type Helper xsde0910 */
- /* CONTEXT_ID Built-in simple type Radio Button is from Type Helper xsde0920 */
- /* CONTEXT_ID User-defined simple type Radio Button is from Type Helper xsde0930 */
- /* CONTEXT_ID Type information Combo Box is from Type Helper xsde0950 */
-
- /* CONTEXT_ID xsde1500 for Attribute Group Design View */
- public static final String XSDE_ATTRIBUTE_GROUP_DESIGN_VIEW = PLUGIN_NAME + ".xsde1500";
- /* CONTEXT_ID xsde1510 for Name Text Edit */
- public static final String XSDE_ATTRIBUTE_GROUP_NAME = PLUGIN_NAME + ".xsde1510";
-
- /* CONTEXT_ID for Global Attribute and Attribute Design Views are the same */
- /* CONTEXT_ID xsde1600 for Attribute Group Reference Design View */
- public static final String XSDE_ATTRIBUTE_GROUP_REF_DESIGN_VIEW = PLUGIN_NAME + ".xsde1600";
- /* CONTEXT_ID xsde1610 for Reference Name Combo Box */
- public static final String XSDE_ATTRIBUTE_GROUP_REF_NAME = PLUGIN_NAME + ".xsde1610";
-
- /* CONTEXT_ID xsde1700 for Attribute Reference Design View */
- public static final String XSDE_ATTRIBUTE_REF_DESIGN_VIEW = PLUGIN_NAME + ".xsde1700";
- /* CONTEXT_ID xsde1710 for Reference Name Combo Box */
- public static final String XSDE_ATTRIBUTE_REF_NAME = PLUGIN_NAME + ".xsde1710";
-
- /* CONTEXT_ID xsde1800 for Pattern Design View */
- public static final String XSDE_PATTERN_DESIGN_VIEW = PLUGIN_NAME + ".xsde1800";
- /* CONTEXT_ID xsde1810 for Value Text Edit */
- public static final String XSDE_PATTERN_VALUE = PLUGIN_NAME + ".xsde1810";
- /* CONTEXT_ID xsde1820 for Create Regular Expression Push Button */
- public static final String XSDE_PATTERN_REGULAR = PLUGIN_NAME + ".xsde1820";
-
- /* CONTEXT_ID xsde1900 for Enum Design View */
- public static final String XSDE_ENUM_DESIGN_VIEW = PLUGIN_NAME + ".xsde1900";
- /* CONTEXT_ID xsde1910 for Value Text Edit */
- public static final String XSDE_ENUM_VALUE = PLUGIN_NAME + ".xsde1910";
-
- /* CONTEXT_ID xsde2000 for Include Design Page */
- public static final String XSDE_INCLUDE_DESIGN_VIEW = PLUGIN_NAME + ".xsde2000";
- /* no CONTEXT_ID for Schema Location Text Edit (not editable) */
- /* CONTEXT_ID Select Push Button is from Include Helper xsde2100 */
-
- /* CONTEXT_ID xsde2100 for Include Helper Select Push Button - used generically */
- /* CONTEXT_ID - used in Include Design View */
- /* CONTEXT_ID - used in Import Design View */
- public static final String XSDE_INCLUDE_HELPER_SELECT = PLUGIN_NAME + ".xsde2100";
-
- /* CONTEXT_ID xsde2200 for Import Design Page */
- public static final String XSDE_IMPORT_DESIGN_VIEW = PLUGIN_NAME + ".xsde2200";
- /* no CONTEXT_ID for Schema Location Text Edit (not editable) */
- /* CONTEXT_ID Select Push Button is from Include Helper xsde2100 */
- /* CONTEXT_ID xsde2210 for Prefix Text Edit */
- public static final String XSDE_IMPORT_PREFIX = PLUGIN_NAME + ".xsde2210";
- /* no CONTEXT_ID for Namespace Text Edit (not editable) */
-
- /* CONTEXT_ID xsde2300 for Redefine Design View */
- public static final String XSDE_REDEFINE_DESIGN_VIEW = PLUGIN_NAME + ".xsde2300";
- /* no CONTEXT_ID for Schema Location Text Edit (not editable) */
- /* CONTEXT_ID Select Push Button is from Include Helper xsde2100 */
-
- /* CONTEXT_ID xsde2400 for Group Design View */
- public static final String XSDE_GROUP_DESIGN_VIEW = PLUGIN_NAME + ".xsde2400";
- /* CONTEXT_ID xsde2410 for Name Text Edit */
- public static final String XSDE_GROUP_NAME = PLUGIN_NAME + ".xsde2410";
-
- /* CONTEXT_ID xsde2500 for Group Scope Design View */
- public static final String XSDE_GROUP_SCOPE_DESIGN_VIEW = PLUGIN_NAME + ".xsde2500";
- /* CONTEXT_ID xsde2510 for Content model Group */
- public static final String XSDE_GROUP_SCOPE_CONTENT_GROUP = PLUGIN_NAME + ".xsde2510";
- /* CONTEXT_ID xsde2520 for Sequence Radio Button */
- public static final String XSDE_GROUP_SCOPE_SEQUENCE = PLUGIN_NAME + ".xsde2520";
- /* CONTEXT_ID xsde2530 for Choice Radio Button */
- public static final String XSDE_GROUP_SCOPE_CHOICE = PLUGIN_NAME + ".xsde2530";
- /* CONTEXT_ID xsde2540 for All Radio Button */
- public static final String XSDE_GROUP_SCOPE_ALL = PLUGIN_NAME + ".xsde2540";
- /* CONTEXT_ID xsde2550 for Minimum Text Edit */
- public static final String XSDE_GROUP_SCOPE_MINIMUM = PLUGIN_NAME + ".xsde2550";
- /* CONTEXT_ID xsde2560 for Maximum Text Edit*/
- public static final String XSDE_GROUP_SCOPE_MAXIMUM = PLUGIN_NAME + ".xsde2560";
-
- /* CONTEXT_ID xsde2600 for Group Ref Design View */
- public static final String XSDE_GROUP_REF_DESIGN_VIEW = PLUGIN_NAME + ".xsde2600";
- /* CONTEXT_ID xsde2610 for Reference name Combo Box */
- public static final String XSDE_GROUP_REF_REFERENCE = PLUGIN_NAME + ".xsde2610";
- /* CONTEXT_ID xsde2620 for Minimum Text Edit */
- public static final String XSDE_GROUP_REF_MINIMUM = PLUGIN_NAME + ".xsde2620";
- /* CONTEXT_ID xsde2630 for Maximum Text Edit */
- public static final String XSDE_GROUP_REF_MAXIMUM = PLUGIN_NAME + ".xsde2630";
-
- /* CONTEXT_ID xsde2700 for Unique Design View */
- public static final String XSDE_UNIQUE_DESIGN_VIEW = PLUGIN_NAME + ".xsde2700";
- /* CONTEXT_ID Name Text Edit is from Unique Base xsde2800 */
- /* CONTEXT_ID Selector Group is from Unique Base xsde2810 */
- /* CONTEXT_ID Selector Mulit-line Edit is from Unique Base xsde2820 */
- /* CONTEXT_ID Fields Group is from Unique Base xsde2830 */
- /* CONTEXT_ID Source Text Edit is from Unique Base xsde2840 */
- /* CONTEXT_ID Add Push Button is from Unique Base xsde2850 */
- /* CONTEXT_ID Remove Push Button is from Unique Base xsde2860 */
- /* CONTEXT_ID Target List Box is from Unique Base xsde2870 */
-
- /* CONTEXT_ID xsde2800 for Unique Base Name Text Edit - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_NAME = PLUGIN_NAME + ".xsde2800";
- /* CONTEXT_ID xsde2810 for Selector Group - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_SELECTOR_GROUP = PLUGIN_NAME + ".xsde2810";
- /* CONTEXT_ID xsde2820 for Selector Multi-line Edit - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_SELECTOR = PLUGIN_NAME + ".xsde2820";
- /* CONTEXT_ID xsde2830 for Fields Group - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_FIELDS_GROUP = PLUGIN_NAME + ".xsde2830";
- /* CONTEXT_ID xsde2840 for Source Text Edit - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_SOURCE = PLUGIN_NAME + ".xsde2840";
- /* CONTEXT_ID xsde2850 for Add Push Button - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_ADD = PLUGIN_NAME + ".xsde2850";
- /* CONTEXT_ID xsde2860 for Remove Push Button - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_REMOVE = PLUGIN_NAME + ".xsde2860";
- /* CONTEXT_ID xsde2870 for Target List Box - used generically */
- /* CONTEXT_ID - used in Unique Design View */
- /* CONTEXT_ID - used in Key Design View */
- /* CONTEXT_ID - used in Key Ref Design View */
- public static final String XSDE_UNIQUE_BASE_TARGET = PLUGIN_NAME + ".xsde2870";
-
- /* CONTEXT_ID xsde2900 for Key Design View */
- public static final String XSDE_KEY_DESIGN_VIEW = PLUGIN_NAME + ".xsde2900";
- /* CONTEXT_ID Name Text Edit is from Unique Base xsde2800 */
- /* CONTEXT_ID Selector Group is from Unique Base xsde2810 */
- /* CONTEXT_ID Selector Mulit-line Edit is from Unique Base xsde2820 */
- /* CONTEXT_ID Fields Group is from Unique Base xsde2830 */
- /* CONTEXT_ID Source Text Edit is from Unique Base xsde2840 */
- /* CONTEXT_ID Add Push Button is from Unique Base xsde2850 */
- /* CONTEXT_ID Remove Push Button is from Unique Base xsde2860 */
- /* CONTEXT_ID Target List Box is from Unique Base xsde2870 */
- /* CONTEXT_ID xsde2900 for Key Design View */
-
- /* CONTEXT_ID xsde2950 for Key Ref Design View */
- public static final String XSDE_KEY_REF_DESIGN_VIEW = PLUGIN_NAME + ".xsde2950";
- /* CONTEXT_ID Name Text Edit is from Unique Base xsde2800 */
- /* CONTEXT_ID xsde2960 for Reference Key Combo Box */
- public static final String XSDE_KEY_REF_REFERENCE = PLUGIN_NAME + ".xsde2960";
- /* CONTEXT_ID Selector Group is from Unique Base xsde2810 */
- /* CONTEXT_ID Selector Mulit-line Edit is from Unique Base xsde2820 */
- /* CONTEXT_ID Fields Group is from Unique Base xsde2830 */
- /* CONTEXT_ID Source Text Edit is from Unique Base xsde2840 */
- /* CONTEXT_ID Add Push Button is from Unique Base xsde2850 */
- /* CONTEXT_ID Remove Push Button is from Unique Base xsde2860 */
- /* CONTEXT_ID Target List Box is from Unique Base xsde2870 */
-
- /* CONTEXT_ID xsde3000 for Any Element Design View */
- public static final String XSDE_ANY_ELEMENT_VIEW = PLUGIN_NAME + ".xsde3000";
- /* CONTEXT_ID xsde3010 for Namespace Text Edit */
- public static final String XSDE_ANY_ELEMENT_NAMESPACE = PLUGIN_NAME + ".xsde3010";
- /* CONTEXT_ID xsde3020 for Process Contents Combo Box */
- public static final String XSDE_ANY_ELEMENT_PROCESS = PLUGIN_NAME + ".xsde3020";
- /* CONTEXT_ID xsde3030 for Minimum Text Edit */
- public static final String XSDE_ANY_ELEMENT_MINIMUM = PLUGIN_NAME + ".xsde3030";
- /* CONTEXT_ID xsde3040 for Maximum Text Edit */
- public static final String XSDE_ANY_ELEMENT_MAXIMUM = PLUGIN_NAME + ".xsde3040";
-
- /* CONTEXT_ID xsde3100 for Any Attribute Design View */
- public static final String XSDE_ANY_ATTRIBUTE_VIEW = PLUGIN_NAME + ".xsde3100";
- /* CONTEXT_ID xsde3110 for Namespace Text Edit */
- public static final String XSDE_ANY_ATTRIBUTE_NAMESPACE = PLUGIN_NAME + ".xsde3110";
- /* CONTEXT_ID xsde3120 for Process Contents Combo Box */
- public static final String XSDE_ANY_ATTRIBUTE_PROCESS = PLUGIN_NAME + ".xsde3120";
-
- /* no CONTEXT_ID for Union Design View - uses a generic interface */
- /* CONTEXT_ID Type Information Group is from Type Helper xsde0900 */
- /* CONTEXT_ID Built-in simple type Radio Button is from Type Helper xsde0920 */
- /* CONTEXT_ID User-defined simple type Radio Button is from Type Helper xsde0930 */
- /* CONTEXT_ID Type information Combo Box is from Type Helper xsde0950 */
-
- /* CONTEXT_ID xsde3200 for Notation Design View */
- public static final String XSDE_NOTATION_VIEW = PLUGIN_NAME + ".xsde3200";
-
- /* CONTEXT_ID xsde4000 for Source View */
- public static final String XSDE_SOURCE_VIEW = PLUGIN_NAME + ".xsde4000";
-
- /* CONTEXT_IDs for Regular Expression Wizard follow the xsdrxxx context IDs */
-
- /* CONTEXT_ID xsdr0010 for Compose Regular Expression Page */
- public static final String XSDR_COMPOSITION_PAGE = PLUGIN_NAME + ".xsdr0010";
- /* CONTEXT_ID xsdr0015 for Token Contents Combo Box */
- public static final String XSDR_COMPOSITION_TOKEN = PLUGIN_NAME + ".xsdr0015";
- /* CONTEXT_ID xsdr0020 for Occurrece Group */
- public static final String XSDR_COMPOSITION_OCCURRENCE_GROUP = PLUGIN_NAME + ".xsdr0020";
- /* CONTEXT_ID xsdr0030 for Just once Radio Button */
- public static final String XSDR_COMPOSITION_JUST_ONCE = PLUGIN_NAME + ".xsdr0030";
- /* CONTEXT_ID xsdr0040 for Zero or more Radio Button */
- public static final String XSDR_COMPOSITION_ZERO_OR_MORE = PLUGIN_NAME + ".xsdr0040";
- /* CONTEXT_ID xsdr0050 for One or more Radio Button */
- public static final String XSDR_COMPOSITION_ONE_OR_MORE = PLUGIN_NAME + ".xsdr0050";
- /* CONTEXT_ID xsdr0060 for Optional Radio Button */
- public static final String XSDR_COMPOSITION_OPTIONAL = PLUGIN_NAME + ".xsdr0060";
- /* CONTEXT_ID xsdr0070 for Repeat Radio Button */
- public static final String XSDR_COMPOSITION_REPEAT = PLUGIN_NAME + ".xsdr0070";
- /* CONTEXT_ID xsdr0080 for Range Radio Button */
- public static final String XSDR_COMPOSITION_RANGE = PLUGIN_NAME + ".xsdr0080";
- /* CONTEXT_ID xsdr0090 for Repeat Text Edit */
- public static final String XSDR_COMPOSITION_REPEAT_TEXT = PLUGIN_NAME + ".xsdr0090";
- /* CONTEXT_ID xsdr0100 for Range Minimum Text Edit */
- public static final String XSDR_COMPOSITION_RANGE_MIN = PLUGIN_NAME + ".xsdr0100";
- /* CONTEXT_ID xsdr0110 for Range Maximum Text Edit */
- public static final String XSDR_COMPOSITION_RANGE_MAX = PLUGIN_NAME + ".xsdr0110";
- /* CONTEXT_ID xsdr0120 for Add Push Button */
- public static final String XSDR_COMPOSITION_ADD = PLUGIN_NAME + ".xsdr0120";
- /* CONTEXT_ID xsdr0130 for Current Regular Expression Text Edit */
- public static final String XSDR_COMPOSITION_CURRENT = PLUGIN_NAME + ".xsdr0130";
-
- /* CONTEXT_ID xsdr0200 for Test Regular Expression Page */
- public static final String XSDR_TEST_PAGE = PLUGIN_NAME + ".xsdr0200";
- /* no CONTEXT_ID for Regular Expression Text Edit (not editable) */
- /* CONTEXT_ID xsdr0210 for Sample Text Text Edit */
- public static final String XSDR_TEST_SAMPLE = PLUGIN_NAME + ".xsdr0210";
-
- /* CONTEXT_IDs for Preferences Page follows the xsdpxxx context IDs */
-
- /* CONTEXT_ID xsdp0010 for XML Schema Preferences Page */
- public static final String XSDP_PREFERENCE_PAGE = PLUGIN_NAME + ".xsdp0010";
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorPlugin.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorPlugin.java
deleted file mode 100644
index 8c334f88ba..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDEditorPlugin.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-
-
-public class XSDEditorPlugin extends AbstractUIPlugin {
- public final static String PLUGIN_ID = "org.eclipse.wst.xsd.ui";
- public final static String XSD_EDITOR_ID = "org.eclipse.wst.xsd.ui.XSDEditor";
-
- public final static String DEFAULT_TARGET_NAMESPACE = "http://www.example.org";
-
- protected static XSDEditorPlugin plugin;
-
- // protected XMLSchemaPackage xmlschemaPackage;
- // KCPort private static MsgLogger myMsgLogger;
-
- public XSDEditorPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- plugin = this;
- // KCPort myMsgLogger = getMsgLogger();
- // myMsgLogger.write(Level.CONFIG, new BuildInfo());
- // myMsgLogger.write(Level.CONFIG, BuildInfo.getWSABuildLevel());
- }
-
- /**
- * Copy the w3c XMLSchema.dtd and datatypes.dtd into the plugin metadata
- * directory for validation purposes
- *
- * @throws CoreException
- *
- * ISSUE: should be removed.
- */
- public void startup() throws CoreException {
- super.startup();
- }
-
-
- /**
- * @deprecated use StructuredModelManager.getModelManager(); instead.
- */
- public static IModelManager getModelManager() {
- return StructuredModelManager.getModelManager();
- }
-
-
- /**
- * Get the Install URL
- */
- public static URL getInstallURL() {
- return getPlugin().getDescriptor().getInstallURL();
- }
-
- /**
- * Return the plugin physical directory location
- */
- public static IPath getPluginLocation() {
- try {
- IPath installPath = new Path(getInstallURL().toExternalForm()).removeTrailingSeparator();
- String installStr = Platform.asLocalURL(new URL(installPath.toString())).getFile();
- return new Path(installStr);
- }
- catch (IOException e) {
-
- }
- return null;
- }
-
- /**
- * Get the metadata directory for this plugin
- */
- public static String getMetaDataDirectory() {
- return getPlugin().getStateLocation().toOSString();
- }
-
- /**
- * Get the one xmlschema package.
- */
- // public XMLSchemaPackage getXMLSchemaPackage()
- // {
- // return xmlschemaPackage;
- // }
- // /**
- // * Get the one xmlschema factory.
- // */
- // public XMLSchemaFactory getXMLSchemaFactory()
- // {
- // return (XMLSchemaFactory)xmlschemaPackage.getEFactoryInstance();
- // }
- /**
- * Get the singleton instance.
- */
- public static XSDEditorPlugin getPlugin() {
- return plugin;
- }
-
- public static Image getXSDImage(String iconName) {
- return getPlugin().getImage(iconName);
- }
-
- public Image getImage(String iconName) {
- ImageRegistry imageRegistry = getImageRegistry();
-
- if (imageRegistry.get(iconName) != null) {
- return imageRegistry.get(iconName);
- }
- else {
- imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName));
- return imageRegistry.get(iconName);
- }
- }
-
- public static String getXSDString(String key) {
- return Platform.getResourceBundle(plugin.getBundle()).getString(key);
- }
-
- /**
- * This gets the string resource and does one substitution.
- */
- public String getString(String key, Object s1) {
- return MessageFormat.format(Platform.getResourceBundle(getBundle()).getString(key), new Object[]{s1});
- }
-
- // public IWorkspace getWorkspace()
- // {
- // return ResourcesPlugin.getWorkspace();
- // }
-
- public static Shell getShell() {
- return getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
- /**
- * Get the xml schema default namespace prefix
- */
- public String getXMLSchemaPrefix() {
- return getPreferenceStore().getString(CONST_XSD_DEFAULT_PREFIX_TEXT);
- }
-
- /**
- * Get the xml schema default target namespace
- */
- public String getXMLSchemaTargetNamespace() {
- String targetNamespace = getPreferenceStore().getString(CONST_DEFAULT_TARGET_NAMESPACE);
- if (!targetNamespace.endsWith("/")) {
- targetNamespace = targetNamespace + "/";
- }
- return targetNamespace;
- }
-
- /**
- * Get the xml schema language qualification
- */
- public boolean isQualifyXMLSchemaLanguage() {
- return getPreferenceStore().getBoolean(CONST_XSD_LANGUAGE_QUALIFY);
- }
-
- /**
- * Method isCombinedDesignAndSourceView.
- *
- * @return boolean if the editor should have a single page that is a
- * combined design and source page
- */
- public boolean isCombinedDesignAndSourceView() {
- return COMBINED_LAYOUT.equals(getPreferenceStore().getString(EDITOR_LAYOUT));
- }
-
- public int getDesignLayout() {
- if (TOP_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return SWT.VERTICAL;
- }
- else if (BOTTOM_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return SWT.VERTICAL;
- }
- else if (LEFT_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return SWT.HORIZONTAL;
- }
- else if (RIGHT_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return SWT.HORIZONTAL;
- }
- return SWT.HORIZONTAL;
- }
-
- public String getDesignLayoutPosition() {
- if (TOP_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return TOP_LAYOUT;
- }
- else if (BOTTOM_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return BOTTOM_LAYOUT;
- }
- else if (LEFT_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return LEFT_LAYOUT;
- }
- else if (RIGHT_LAYOUT.equals(getPreferenceStore().getString(DESIGN_LAYOUT))) {
- return RIGHT_LAYOUT;
- }
- return RIGHT_LAYOUT;
- }
-
- /*---------------------------------------------------------------------------*/
- /* the following methods are impls for the IPluginHelper interface */
- /*---------------------------------------------------------------------------*/
- // public void setMsgLoggerConfig(Hashtable msgLoggerConfig)
- // {
- // getMsgLogger().setMsgLoggerConfig(msgLoggerConfig);
- // }
- //
- // public Hashtable getMsgLoggerConfig(Plugin plugin)
- // {
- // return (new PluginHelperImpl().getMsgLoggerConfig(plugin));
- // }
- //
- // public Hashtable getMsgLoggerConfig()
- // {
- // return (getMsgLoggerConfig(this));
- // }
- //
- // /**
- // * XSDEditor and XSDModel use the same logger. See plugin.xml
- // */
- // public MsgLogger getMsgLogger()
- // {
- // if (myMsgLogger == null)
- // {
- // myMsgLogger = (MsgLogger) MsgLogger.getFactory().getLogger(new
- // PluginHelperImpl().getMsgLoggerName(this), this);
- // }
- // return (myMsgLogger);
- // }
- public static final String CONST_XSD_DEFAULT_PREFIX_TEXT = "org.eclipse.wst.xmlschema.xsdDefaultPrefixText";
- public static final String CONST_XSD_LANGUAGE_QUALIFY = "org.eclipse.wst.xmlschema.xsdQualify";
- public static final String CONST_DEFAULT_TARGET_NAMESPACE = "org.eclipse.wst.xmlschema.defaultTargetnamespaceText";
-
- // Preference to store which page should come up as the default page in
- // the editor. This setting is based
- // on the page that was left showing the last time the editor was closed.
- public static String DEFAULT_PAGE = "org.eclipse.wst.xsd.ui.internal.defaultPage";
- public static String DESIGN_PAGE = "org.eclipse.wst.xsd.ui.internal.designPage";
- public static String SOURCE_PAGE = "org.eclipse.wst.xsd.ui.internal.sourcePage";
- public static String GRAPH_PAGE = "org.eclipse.wst.xsd.ui.internal.graphPage";
-
- public static String EDITOR_LAYOUT = "org.eclipse.wst.xsd.ui.internal.editorlayout";
- public static String COMBINED_LAYOUT = "org.eclipse.wst.xsd.ui.internal.combined";
- public static String SEPARATE_LAYOUT = "org.eclipse.wst.xsd.ui.internal.separate";
-
- public static String DESIGN_LAYOUT = "org.eclipse.wst.xsd.ui.internal.designlayout";
- public static String TOP_LAYOUT = "org.eclipse.wst.xsd.ui.internal.top";
- public static String BOTTOM_LAYOUT = "org.eclipse.wst.xsd.ui.internal.bottom";
- public static String LEFT_LAYOUT = "org.eclipse.wst.xsd.ui.internal.left";
- public static String RIGHT_LAYOUT = "org.eclipse.wst.xsd.ui.internal.right";
-
- /**
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(IPreferenceStore)
- */
- protected void initializeDefaultPreferences(IPreferenceStore store) {
- super.initializeDefaultPreferences(store);
-
- store.setDefault(CONST_XSD_DEFAULT_PREFIX_TEXT, "xsd");
- store.setDefault(CONST_XSD_LANGUAGE_QUALIFY, false);
-
- store.setDefault(DEFAULT_PAGE, DESIGN_PAGE);
- store.setDefault(EDITOR_LAYOUT, COMBINED_LAYOUT);
- store.setDefault(DESIGN_LAYOUT, RIGHT_LAYOUT);
-
- store.setDefault(XSDEditorPlugin.CONST_DEFAULT_TARGET_NAMESPACE, DEFAULT_TARGET_NAMESPACE);
- }
-
- public void setDefaultPage(String page) {
- getPreferenceStore().setValue(DEFAULT_PAGE, page);
- }
-
- /**
- * Method getDefaultPage.
- *
- * @return String value of the string constant that is the default page
- * the editor should turn to when first opened. Changes to the
- * last visible page when the editor was closed
- */
- public String getDefaultPage() {
- return getPreferenceStore().getString(DEFAULT_PAGE);
- }
-
- protected URL baseURL;
-
- public URL getBaseURL() {
- return getDescriptor().getInstallURL();
- }
-
- public Image getIconImage(String object) {
- try {
- return ExtendedImageRegistry.getInstance().getImage(new URL(getBaseURL() + "icons/" + object + ".gif"));
- }
- catch (MalformedURLException exception) {
- System.out.println("Failed to load image for '" + object + "'");
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlink.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlink.java
deleted file mode 100644
index eb1f306668..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlink.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-/**
- * WSDL Hyperlink that knows how to open links from wsdl files
- */
-public class XSDHyperlink implements IHyperlink {
- private IRegion fRegion;
- private XSDConcreteComponent fComponent;
-
- public XSDHyperlink(IRegion region, XSDConcreteComponent component) {
- fRegion = region;
- fComponent = component;
- }
-
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- public String getTypeLabel() {
- return null;
- }
-
- public String getHyperlinkText() {
- return null;
- }
-
- public void open() {
- // if hyperlink points to schema already in editor, select the correct
- // node
- // if (fComponent.getRootContainer().equals(xsdSchema)) {
- // Node element = fComponent.getElement();
- // if (element instanceof IndexedRegion) {
- // IndexedRegion indexNode = (IndexedRegion) element;
- // textEditor.getTextViewer().setRangeIndication(indexNode.getStartOffset(),
- // indexNode.getEndOffset() - indexNode.getStartOffset(), true);
- // }
- // }
- // else {
- 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 {
- IEditorPart editorPart = IDE.openEditor(page, schemaFile, true);
- if (editorPart instanceof XSDEditor) {
- ((XSDEditor) editorPart).openOnGlobalReference(fComponent);
- }
- }
- catch (PartInitException pie) {
- Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlinkDetector.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlinkDetector.java
deleted file mode 100644
index 133e6120b8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDHyperlinkDetector.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Detects hyperlinks for XSD files
- */
-public class XSDHyperlinkDetector implements IHyperlinkDetector {
- /**
- * Gets the xsd schema from document
- *
- * @param document
- * @return XSDSchema or null of one does not exist yet for document
- */
- private XSDSchema getXSDSchema(IDocument document) {
- XSDSchema schema = null;
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- try {
- if (model instanceof IDOMModel) {
- IDOMDocument domDoc = ((IDOMModel) model).getDocument();
- if (domDoc != null) {
- XSDModelAdapter modelAdapter = (XSDModelAdapter) domDoc.getExistingAdapter(XSDModelAdapter.class);
- /*
- * ISSUE: Didn't want to go through initializing
- * schema if it does not already exist, so just
- * attempted to get existing adapter. If doesn't
- * exist, just don't bother working.
- */
- if (modelAdapter != null)
- schema = modelAdapter.getSchema();
- }
- }
- }
- finally {
- model.releaseFromRead();
- }
- }
- return schema;
- }
-
- /**
- *
- * @param xsdSchema
- * cannot be null
- * @param node
- * cannot be null
- * @return XSDConcreteComponent
- */
- private XSDConcreteComponent getXSDComponent(XSDSchema xsdSchema, Node node) {
- XSDConcreteComponent objectToReveal = null;
-
- XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent((Node) node);
- if (xsdComp instanceof XSDElementDeclaration) {
- XSDElementDeclaration elementDecl = (XSDElementDeclaration) xsdComp;
- if (elementDecl.isElementDeclarationReference()) {
- objectToReveal = elementDecl.getResolvedElementDeclaration();
- }
- else {
- XSDConcreteComponent typeDef = null;
- if (elementDecl.getAnonymousTypeDefinition() == null) {
- typeDef = elementDecl.getTypeDefinition();
- }
-
- XSDConcreteComponent subGroupAffiliation = elementDecl.getSubstitutionGroupAffiliation();
-
- if (typeDef != null && subGroupAffiliation != null) {
- // we have 2 things we can navigate to, if the
- // cursor is anywhere on the substitution
- // attribute
- // then jump to that, otherwise just go to the
- // typeDef.
- if (node instanceof Attr && ((Attr) node).getLocalName().equals(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE)) {
- objectToReveal = subGroupAffiliation;
- }
- else {
- // try to reveal the type now. On success,
- // then we return true.
- // if we fail, set the substitution group
- // as
- // the object to reveal as a backup plan.
- // ISSUE: how to set backup?
- // if (revealObject(typeDef)) {
- objectToReveal = typeDef;
- // }
- // else {
- // objectToReveal = subGroupAffiliation;
- // }
- }
- }
- else {
- // one or more of these is null. If the
- // typeDef is
- // non-null, use it. Otherwise
- // try and use the substitution group
- objectToReveal = typeDef != null ? typeDef : subGroupAffiliation;
- }
- }
- }
- else if (xsdComp instanceof XSDModelGroupDefinition) {
- XSDModelGroupDefinition elementDecl = (XSDModelGroupDefinition) xsdComp;
- if (elementDecl.isModelGroupDefinitionReference()) {
- objectToReveal = elementDecl.getResolvedModelGroupDefinition();
- }
- }
- else if (xsdComp instanceof XSDAttributeDeclaration) {
- XSDAttributeDeclaration attrDecl = (XSDAttributeDeclaration) xsdComp;
- if (attrDecl.isAttributeDeclarationReference()) {
- objectToReveal = attrDecl.getResolvedAttributeDeclaration();
- }
- else if (attrDecl.getAnonymousTypeDefinition() == null) {
- objectToReveal = attrDecl.getTypeDefinition();
- }
- }
- else if (xsdComp instanceof XSDAttributeGroupDefinition) {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) xsdComp;
- if (attrGroupDef.isAttributeGroupDefinitionReference()) {
- objectToReveal = attrGroupDef.getResolvedAttributeGroupDefinition();
- }
- }
- else if (xsdComp instanceof XSDIdentityConstraintDefinition) {
- XSDIdentityConstraintDefinition idConstraintDef = (XSDIdentityConstraintDefinition) xsdComp;
- if (idConstraintDef.getReferencedKey() != null) {
- objectToReveal = idConstraintDef.getReferencedKey();
- }
- }
- else if (xsdComp instanceof XSDSimpleTypeDefinition) {
- XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComp;
- objectToReveal = typeDef.getItemTypeDefinition();
- if (objectToReveal == null) {
- // if itemType attribute is not set, then check
- // for memberType
- List memberTypes = typeDef.getMemberTypeDefinitions();
- if (memberTypes != null && memberTypes.size() > 0) {
- objectToReveal = (XSDConcreteComponent) memberTypes.get(0);
- }
- }
- }
- else if (xsdComp instanceof XSDTypeDefinition) {
- XSDTypeDefinition typeDef = (XSDTypeDefinition) xsdComp;
- objectToReveal = typeDef.getBaseType();
- }
- else if (xsdComp instanceof XSDSchemaDirective) {
- XSDSchemaDirective directive = (XSDSchemaDirective) xsdComp;
- // String schemaLocation =
- // URIHelper.removePlatformResourceProtocol(directive.getResolvedSchema().getSchemaLocation());
- // openXSDEditor(schemaLocation);
- // return false;
- objectToReveal = directive.getResolvedSchema();
- }
- return objectToReveal;
- }
-
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
- // for now, only capable of creating 1 hyperlink
- List hyperlinks = new ArrayList(0);
-
- if (region != null && textViewer != null) {
- IDocument document = textViewer.getDocument();
- Node node = getCurrentNode(document, region.getOffset());
- if (node != null) {
- XSDSchema xsdSchema = getXSDSchema(textViewer.getDocument());
- if (xsdSchema != null) {
- XSDConcreteComponent objectToReveal = getXSDComponent(xsdSchema, node);
- // now reveal the object if this isn't null
- if (objectToReveal != null) {
- IRegion nodeRegion = region;
- if (node instanceof IndexedRegion) {
- IndexedRegion indexed = (IndexedRegion) node;
- int start = indexed.getStartOffset();
- int end = indexed.getEndOffset();
- nodeRegion = new Region(start, end - start);
- }
- hyperlinks.add(new XSDHyperlink(nodeRegion, objectToReveal));
- }
- }
- }
- }
-
- if (hyperlinks.size() == 0)
- return null;
- return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
- }
-
- /**
- * Returns the node the cursor is currently on in the document. null if no
- * node is selected
- *
- * @param offset
- * @return Node either element, doctype, text, or null
- */
- private Node getCurrentNode(IDocument document, int offset) {
- // get the current node at the offset (returns either: element,
- // doctype, text)
- IndexedRegion inode = null;
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- inode = sModel.getIndexedRegion(offset);
- if (inode == null)
- inode = sModel.getIndexedRegion(offset - 1);
- }
- finally {
- if (sModel != null)
- sModel.releaseFromRead();
- }
-
- if (inode instanceof Node) {
- return (Node) inode;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java
deleted file mode 100644
index 61093bee01..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMenuListener.java
+++ /dev/null
@@ -1,1762 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-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.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.wst.xsd.ui.internal.actions.AddEnumsAction;
-import org.eclipse.wst.xsd.ui.internal.actions.AddModelGroupAction;
-import org.eclipse.wst.xsd.ui.internal.actions.BackAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateAnnotationAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateElementAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateGroupAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateIdentityConstraintsAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateLocalComplexTypeAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateLocalSimpleTypeAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateSimpleContentAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateSimpleTypeAction;
-import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute;
-import org.eclipse.wst.xsd.ui.internal.actions.DeleteAction;
-import org.eclipse.wst.xsd.ui.internal.actions.OpenSchemaAction;
-import org.eclipse.wst.xsd.ui.internal.actions.SetBaseTypeAction;
-import org.eclipse.wst.xsd.ui.internal.actions.SetMultiplicityAction;
-import org.eclipse.wst.xsd.ui.internal.actions.SetTypeAction;
-import org.eclipse.wst.xsd.ui.internal.actions.XSDEditNamespacesAction;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter;
-import org.eclipse.wst.xsd.ui.internal.refactor.actions.RefactorActionGroup;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDParticle;
-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.NodeList;
-
-public class XSDMenuListener implements IMenuListener
-{
- protected ISelectionProvider selectionProvider;
- protected DeleteAction deleteAction;
- protected CreateElementAction addComplexTypeAction;
- protected XSDSchema xsdSchema;
- protected boolean isReadOnly;
- protected Object sourceContext;
- private RefactorActionGroup fRefactorMenuGroup;
-
- /**
- * Constructor for XSDMenuListener.
- */
- public XSDMenuListener(ISelectionProvider selectionProvider)
- {
- super();
- this.selectionProvider = selectionProvider;
-
- deleteAction = new DeleteAction(XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE"), null, getXSDSchema());
- deleteAction.setSelectionProvider(selectionProvider);
- selectionProvider.addSelectionChangedListener(deleteAction);
- }
-
- public void setSourceContext(Object sourceContext)
- {
- this.sourceContext = sourceContext;
- }
-
- public void setSelectionProvider(ISelectionProvider selectionProvider)
- {
- this.selectionProvider = selectionProvider;
- }
-
- protected XSDSchema getXSDSchema()
- {
- return xsdSchema;
- }
-
- protected Object getSelectedElement()
- {
- ISelection selection = selectionProvider.getSelection();
- if (selection.isEmpty())
- {
- return null;
- }
- return ((IStructuredSelection) selection).getFirstElement();
- }
-
- protected boolean isSchemaReadOnly()
- {
- XSDSchema editorSchema = ((XSDEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getXSDSchema();
- if (editorSchema == xsdSchema) {
- return false;
- }
-
- return true;
- }
-
- protected XSDSchema getCurrentSchemaInEditor()
- {
- return ((XSDEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getXSDSchema();
- }
-
- protected void updateXSDSchema()
- {
- isReadOnly = false;
-
- Object object = getSelectedElement();
- if (object instanceof XSDConcreteComponent)
- {
- xsdSchema = ((XSDConcreteComponent) object).getSchema();
- isReadOnly = isSchemaReadOnly();
- }
- else if (object instanceof Category)
- {
- Category cg = (Category) object;
- xsdSchema = cg.getXSDSchema();
- }
- else if (object instanceof CategoryAdapter)
- {
- CategoryAdapter category = (CategoryAdapter) object;
- xsdSchema = category.getXSDSchema();
- }
- }
-
- /*
- * @see IMenuListener#menuAboutToShow(IMenuManager)
- */
- public void menuAboutToShow(IMenuManager manager)
- {
- isReadOnly = false;
- updateXSDSchema();
- if (xsdSchema == null)
- {
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- return;
- }
-
- deleteAction.setXSDSchema(xsdSchema);
- deleteAction.setEnabled(!isReadOnly);
-
- BackAction backAction = new BackAction(XSDEditorPlugin.getXSDString("_UI_ACTION_BACK_TO_SCHEMA_VIEW")); //$NON-NLS-1$
- backAction.setXSDSchema(getCurrentSchemaInEditor());
- backAction.setSelectionProvider(selectionProvider);
-
- Object selectedElementObj = getSelectedElement();
-
- if (selectedElementObj instanceof XSDSchema || selectedElementObj instanceof Category || selectedElementObj instanceof CategoryAdapter)
- {
- backAction.setEnabled(false);
- }
- manager.add(backAction);
- manager.add(new Separator());
-// if (undoAction == null && textEditor != null)
-// {
-// undoAction = textEditor.getAction(org.eclipse.ui.texteditor.ITextEditorActionConstants.UNDO);
-// redoAction = textEditor.getAction(org.eclipse.ui.texteditor.ITextEditorActionConstants.REDO);
-// }
- // Element selectedElement = getSelectedElement();
-
- Element selectedElement = null;
-
- if (selectedElementObj instanceof Element)
- {
- selectedElement = (Element) selectedElementObj;
- }
- else if (selectedElementObj instanceof XSDConcreteComponent)
- {
- selectedElement = ((XSDConcreteComponent) selectedElementObj).getElement();
- }
- else if (selectedElementObj instanceof Category || selectedElementObj instanceof CategoryAdapter)
- {
- int groupType = -1;
- if (selectedElementObj instanceof Category)
- {
- Category category = (Category) selectedElementObj;
- groupType = category.getGroupType();
- }
- // todo... We need to ensure we eliminate the need for
- // this case. The XSDMenuListener class should not have
- // view dependant code. We need to do some work to ensure all
- // views utilize the 'Category' model object
- else if (selectedElementObj instanceof CategoryAdapter)
- {
- CategoryAdapter categoryAdapter = (CategoryAdapter) selectedElementObj;
- groupType = categoryAdapter.getGroupType();
- }
- ArrayList attributes = null;
- Element parent = getXSDSchema().getElement();
-
- if (parent == null)
- {
- return;
- }
-
- Node relativeNode = null;
- switch (groupType)
- {
- case Category.TYPES : {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("ComplexType")));
- Action action = addCreateElementAction(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_COMPLEX_TYPE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("SimpleType")));
- Action action2 = addCreateSimpleTypeAction(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SIMPLE_TYPE"), attributes, parent, relativeNode);
- ((CreateElementAction) action2).setIsGlobal(true);
- break;
- }
- case Category.ELEMENTS : {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.ELEMENT_ELEMENT_TAG, "GlobalElement")));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- Action action = addCreateElementAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ELEMENT"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- break;
- }
- case Category.GROUPS : {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.GROUP_ELEMENT_TAG, "Group")));
- CreateGroupAction groupAction = addCreateGroupAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GROUP"), attributes, parent, relativeNode);
- groupAction.setIsGlobal(true);
- break;
- }
- case Category.ATTRIBUTES : {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.ATTRIBUTE_ELEMENT_TAG, "GlobalAttribute")));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- Action action = addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GLOBAL_ATTRIBUTE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- break;
- }
- case Category.ATTRIBUTE_GROUPS : {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, "AttributeGroup")));
- Action action = addCreateElementAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- break;
- }
- case Category.NOTATIONS : {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.NOTATION_ELEMENT_TAG, "Notation")));
- attributes.add(new DOMAttribute(XSDConstants.PUBLIC_ATTRIBUTE, ""));
- Action action = addCreateElementAction(manager, XSDConstants.NOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_NOTATION"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- break;
- }
- case Category.DIRECTIVES : {
- boolean b = true;
- NodeList children = parent.getChildNodes();
- int length = children.getLength();
- Node effectiveRelativeNode = parent.getFirstChild();
- for (int i = 0; i < length && b; i++)
- {
- Node child = children.item(i);
- if (child != null && child instanceof Element)
- {
- if (XSDDOMHelper.inputEquals((Element) child, XSDConstants.INCLUDE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.IMPORT_ELEMENT_TAG, false)
- || XSDDOMHelper.inputEquals((Element) child, XSDConstants.REDEFINE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.ANNOTATION_ELEMENT_TAG, false))
- {
- effectiveRelativeNode = child;
- }
- else
- {
- b = false;
- }
- }
- }
- relativeNode = effectiveRelativeNode != null ? XSDDOMHelper.getNextElementNode(effectiveRelativeNode) : null;
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, ""));
- Action action = addCreateElementAction(manager, XSDConstants.INCLUDE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_INCLUDE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- action = addCreateElementAction(manager, XSDConstants.IMPORT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_IMPORT"), null, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- action = addCreateElementAction(manager, XSDConstants.REDEFINE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_REDEFINE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- break;
- }
- case Category.ANNOTATIONS : {
- Action action = addCreateElementAction(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), null, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- break;
- }
- }
-// manager.add(new Separator());
-// if (undoAction != null)
-// {
-// manager.add(undoAction);
-// manager.add(redoAction);
-// }
-
- // insertion point for popupMenus extension
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
-
- return;
- }
- if (selectedElement != null)
- {
- addContextItems(manager, selectedElement, null);
- manager.add(new Separator());
- }
-
- manager.add(new Separator());
- if (deleteAction != null)
- {
- manager.add(deleteAction);
- }
-
- // insertion point for popupMenus extension
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- protected String getBuiltInStringQName()
- {
- String stringName = "string";
- if (getXSDSchema() != null)
- {
- String schemaForSchemaPrefix = getXSDSchema().getSchemaForSchemaQNamePrefix();
- if (schemaForSchemaPrefix != null && schemaForSchemaPrefix.length() > 0)
- {
- String prefix = getXSDSchema().getSchemaForSchemaQNamePrefix();
- if (prefix != null && prefix.length() > 0)
- {
- stringName = prefix + ":" + stringName;
- }
- }
- }
- return stringName;
- }
-
- /**
- * Method addContextItems.
- *
- * @param manager
- * @param parent -
- * menu items should be context sensitive to this node
- * @param relativeNode -
- * anything inserted, should be inserted before this node (which is a
- * child of the parent node. A value of null means add to the end
- */
- protected void addContextItems(IMenuManager manager, Element parent, Node relativeNode)
- {
- ArrayList attributes = null;
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- { //
- addSchemaElementItems(manager, parent, relativeNode);
- manager.add(new Separator());
- boolean b = true;
- NodeList children = parent.getChildNodes();
- Node effectiveRelativeNode = parent.getFirstChild();
- for (int i = 0; i < children.getLength() && b; i++)
- {
- Node child = children.item(i);
- if (child != null && child instanceof Element)
- {
- if (XSDDOMHelper.inputEquals((Element) child, XSDConstants.INCLUDE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.IMPORT_ELEMENT_TAG, false)
- || XSDDOMHelper.inputEquals((Element) child, XSDConstants.REDEFINE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.ANNOTATION_ELEMENT_TAG, false))
- {
- effectiveRelativeNode = child;
- }
- else
- {
- b = false;
- }
- }
- }
- relativeNode = effectiveRelativeNode != null ? effectiveRelativeNode.getNextSibling() : null;
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, ""));
- addCreateElementAction(manager, XSDConstants.INCLUDE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_INCLUDE"), attributes, parent, relativeNode);
- addCreateElementAction(manager, XSDConstants.IMPORT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_IMPORT"), null, parent, relativeNode);
- addCreateElementAction(manager, XSDConstants.REDEFINE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_REDEFINE"), attributes, parent, relativeNode);
- attributes = null;
- addCreateAnnotationAction(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), null, parent, relativeNode);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false))
- { //
- addCreateElementAction(manager, XSDConstants.DOCUMENTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_DOC"), attributes, parent, null);
- addCreateElementAction(manager, XSDConstants.APPINFO_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_APP_INFO"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- XSDConcreteComponent concreteComponent = getXSDSchema().getCorrespondingComponent(parent);
- Element parentNode = (Element) parent.getParentNode();
- boolean isGlobalElement = false;
- if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- isGlobalElement = true;
- }
- boolean annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- boolean simpleTypeExists = elementExists(XSDConstants.SIMPLETYPE_ELEMENT_TAG, parent);
- boolean complexTypeExists = elementExists(XSDConstants.COMPLEXTYPE_ELEMENT_TAG, parent);
- manager.add(new Separator());
- if (annotationExists)
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- if (!(simpleTypeExists || complexTypeExists) && annotationNode != null)
- {
- manager.add(new Separator());
- }
- }
- else
- {
- if (concreteComponent != null)
- {
- AddModelGroupAction addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.SEQUENCE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.CHOICE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.ALL_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- manager.add(new Separator());
- }
- }
- XSDDOMHelper domHelper = new XSDDOMHelper();
- Element anonymousType = (Element) domHelper.getChildNode(parent, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (anonymousType != null)
- {
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("ComplexType")));
- addMoveAnonymousGlobal(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"), attributes, anonymousType, null);
- attributes = null;
- }
- anonymousType = (Element) domHelper.getChildNode(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (anonymousType != null)
- {
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("SimpleType")));
- addMoveAnonymousGlobal(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"), attributes, anonymousType, null);
- attributes = null;
- }
-
- manager.add(new Separator());
- MenuManager setTypeCascadeMenu = new MenuManager(XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"));
- manager.add(setTypeCascadeMenu);
-
- SetTypeAction setNewComplexTypeAction = new SetTypeAction(XSDEditorPlugin.getXSDString("_UI_LABEL_NEW_COMPLEX_TYPE"), ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/XSDComplexType.gif"), concreteComponent);
- setNewComplexTypeAction.setTypeKind(XSDConstants.COMPLEXTYPE_ELEMENT);
- setNewComplexTypeAction.setEnabled(!isReadOnly);
- setTypeCascadeMenu.add(setNewComplexTypeAction);
-
- SetTypeAction setNewSimpleTypeAction = new SetTypeAction(XSDEditorPlugin.getXSDString("_UI_LABEL_NEW_SIMPLE_TYPE"), ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/XSDSimpleType.gif"), concreteComponent);
- setNewSimpleTypeAction.setTypeKind(XSDConstants.SIMPLETYPE_ELEMENT);
- setNewSimpleTypeAction.setEnabled(!isReadOnly);
- setTypeCascadeMenu.add(setNewSimpleTypeAction);
-
- SetTypeAction setExistingTypeAction = new SetTypeAction(XSDEditorPlugin.getXSDString("_UI_LABEL_SET_EXISTING_TYPE"), concreteComponent);
- setExistingTypeAction.setTypeKind(0);
- setExistingTypeAction.setEnabled(!isReadOnly);
- setTypeCascadeMenu.add(setExistingTypeAction);
- manager.add(new Separator());
-
- if (!isGlobalElement)
- {
- addMultiplicityMenu(concreteComponent, manager);
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.SEQUENCE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals(parent, XSDConstants.CHOICE_ELEMENT_TAG, false))
- { //
- XSDConcreteComponent concreteComponent = getXSDSchema().getCorrespondingComponent(parent);
-
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- manager.add(new Separator());
- addCreateElementAction(manager, XSDConstants.CHOICE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CHOICE"), attributes, parent, null);
- addCreateElementAction(manager, XSDConstants.SEQUENCE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SEQUENCE"), attributes, parent, null);
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, null);
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ELEMENT_ELEMENT_TAG, "Element", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ELEMENT"), attributes, parent, null);
- addCreateElementRefAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ELEMENT_REF"), parent, null);
- manager.add(new Separator());
- attributes = null;
- addCreateElementAction(manager, XSDConstants.ANY_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ELEMENT"), attributes, parent, null);
-
- if (concreteComponent.getContainer() instanceof XSDParticle)
- {
- addMultiplicityMenu(concreteComponent, manager);
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ALL_ELEMENT_TAG, false))
- { //
- XSDConcreteComponent concreteComponent = getXSDSchema().getCorrespondingComponent(parent);
-
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ELEMENT_ELEMENT_TAG, "Element", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ELEMENT"), attributes, parent, null);
- addCreateElementRefAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ELEMENT_REF"), parent, null);
-
- if (concreteComponent.getContainer() instanceof XSDParticle)
- {
- addMultiplicityMenu(concreteComponent, manager);
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false))
- { //
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- boolean anyAttributeExists = elementExists(XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, parent);
- Node anyAttributeNode = null;
- manager.add(new Separator());
- if (anyAttributeExists)
- {
- anyAttributeNode = getFirstChildNodeIfExists(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, anyAttributeNode);
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, anyAttributeNode);
- }
- else
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, parent.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, parent.getLastChild());
- }
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.NOTATION_ELEMENT_TAG, false))
- { //
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- { //
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- boolean restrictionExists = elementExists(XSDConstants.RESTRICTION_ELEMENT_TAG, parent);
- boolean unionExists = elementExists(XSDConstants.UNION_ELEMENT_TAG, parent);
- boolean listExists = elementExists(XSDConstants.LIST_ELEMENT_TAG, parent);
- if (!(restrictionExists || unionExists || listExists))
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.BASE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementActionIfNotExist(manager, XSDConstants.RESTRICTION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_RESTRICTION"), attributes, parent, null);
- attributes = null;
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementActionIfNotExist(manager, XSDConstants.UNION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_UNION"), attributes, parent, null);
- attributes = null;
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementActionIfNotExist(manager, XSDConstants.LIST_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LIST"), attributes, parent, null);
- attributes = null;
- }
- if (XSDDOMHelper.inputEquals(parent.getParentNode(), XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("SimpleType")));
- addMoveAnonymousGlobal(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"), attributes, parent, null);
- attributes = null;
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.GROUP_ELEMENT_TAG, false))
- { //
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- addCreateElementActionIfNotExist(manager, XSDConstants.SEQUENCE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CONTENT_MODEL"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- { //
- boolean annotationExists = false;
- boolean contentExists = false;
- Node annotationNode = null;
- NodeList children = parent.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
- if (child != null && child instanceof Element)
- {
- if (XSDDOMHelper.inputEquals((Element) child, XSDConstants.ANNOTATION_ELEMENT_TAG, false))
- {
- annotationNode = child;
- annotationExists = true;
- }
- else if (XSDDOMHelper.inputEquals((Element) child, XSDConstants.SEQUENCE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.ALL_ELEMENT_TAG, false)
- || XSDDOMHelper.inputEquals((Element) child, XSDConstants.CHOICE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.GROUP_ELEMENT_TAG, true)
- || XSDDOMHelper.inputEquals((Element) child, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals((Element) child, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- contentExists = true;
- }
- }
- }
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- manager.add(new Separator());
- addSetBaseTypeAction(manager, parent);
- XSDConcreteComponent concreteComponent = getXSDSchema().getCorrespondingComponent(parent);
- if (annotationExists)
- {
- if (!contentExists)
- {
- if (concreteComponent != null)
- {
- AddModelGroupAction addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.SEQUENCE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.CHOICE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.ALL_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- }
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, annotationNode.getNextSibling());
- attributes = null;
- }
- }
- else
- {
- if (!contentExists)
- {
- if (concreteComponent != null)
- {
- AddModelGroupAction addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.SEQUENCE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.CHOICE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.ALL_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- }
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, parent.getFirstChild());
- attributes = null;
- }
- }
- manager.add(new Separator());
- if (XSDDOMHelper.inputEquals(parent.getParentNode(), XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("ComplexType")));
- addMoveAnonymousGlobal(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"), attributes, parent, null);
- attributes = null;
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- { //
- XSDDOMHelper xsdDOMHelper = new XSDDOMHelper();
- Element derivedByNode = xsdDOMHelper.getDerivedByElement(parent);
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- if (derivedByNode == null)
- {
- TypesHelper typesHelper = new TypesHelper(getXSDSchema());
- String firstType = "";
- List listOfCT = typesHelper.getUserComplexTypeNamesList();
- if (listOfCT.size() > 0)
- {
- firstType = (String) (listOfCT).get(0);
- }
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.BASE_ATTRIBUTE, firstType));
- addCreateElementActionIfNotExist(manager, XSDConstants.RESTRICTION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_RESTRICTION"), attributes, parent, null);
- addCreateElementActionIfNotExist(manager, XSDConstants.EXTENSION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_EXTENSION"), attributes, parent, null);
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- { //
- XSDDOMHelper xsdDOMHelper = new XSDDOMHelper();
- Element derivedByNode = xsdDOMHelper.getDerivedByElement(parent);
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- if (derivedByNode == null)
- {
- TypesHelper typesHelper = new TypesHelper(getXSDSchema());
- String firstType = "";
- List listOfCT = typesHelper.getUserComplexTypeNamesList();
- if (listOfCT.size() > 0)
- {
- firstType = (String) (listOfCT).get(0);
- }
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.BASE_ATTRIBUTE, firstType));
- addCreateElementActionIfNotExist(manager, XSDConstants.RESTRICTION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_RESTRICTION"), attributes, parent, null);
- addCreateElementActionIfNotExist(manager, XSDConstants.EXTENSION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_EXTENSION"), attributes, parent, null);
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.RESTRICTION_ELEMENT_TAG, false))
- {
- Element parentNode = (Element) parent.getParentNode();
- // <simpleContent>
- // <restriction>
- // ...
- if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- boolean annotationExists = false;
- boolean anyAttributeExists = false;
- Node anyAttributeNode = null;
- anyAttributeExists = elementExists(XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, parent);
- annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent
- .getFirstChild());
- if (annotationExists)
- {
- getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- }
-
- manager.add(new Separator());
- if (anyAttributeExists)
- {
- anyAttributeNode = getFirstChildNodeIfExists(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, anyAttributeNode);
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, anyAttributeNode);
- }
- else
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, parent.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, parent.getLastChild());
- }
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- }
- // <simpleType>
- // <restriction>
- // ...
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- boolean annotationExists = false;
- attributes = null;
- annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent
- .getFirstChild());
- if (annotationExists)
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- addCreateLocalSimpleTypeActionIfNotExist(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LOCAL_SIMPLE_TYPE"), attributes, parent, annotationNode
- .getNextSibling());
- }
- else
- {
- addCreateLocalSimpleTypeActionIfNotExist(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LOCAL_SIMPLE_TYPE"), attributes, parent, parent
- .getFirstChild());
- }
- manager.add(new Separator());
- addCreateElementAction(manager, XSDConstants.PATTERN_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_PATTERN"), attributes, parent, null);
- addCreateElementAction(manager, XSDConstants.ENUMERATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ENUM"), attributes, parent, null);
- addEnumsAction(manager, XSDConstants.ENUMERATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ENUMS"), attributes, parent, null);
- }
- // <complexContent>
- // <restriction>
- // ...
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- boolean annotationExists = false;
- boolean anyAttributeExists = false;
- Node anyAttributeNode = null;
- boolean sequenceExists = elementExists(XSDConstants.SEQUENCE_ELEMENT_TAG, parent);
- boolean choiceExists = elementExists(XSDConstants.CHOICE_ELEMENT_TAG, parent);
- boolean allExists = elementExists(XSDConstants.ALL_ELEMENT_TAG, parent);
- boolean groupExists = elementExists(XSDConstants.GROUP_ELEMENT_TAG, parent);
- anyAttributeExists = elementExists(XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, parent);
- annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent
- .getFirstChild());
- manager.add(new Separator());
- if (annotationExists)
- {
- if (!(sequenceExists || choiceExists || allExists || groupExists))
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- addCreateElementActionIfNotExist(manager, XSDConstants.SEQUENCE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CONTENT_MODEL"), attributes, parent, annotationNode
- .getNextSibling());
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, annotationNode.getNextSibling());
- }
- }
- else
- {
- if (!(sequenceExists || choiceExists || allExists || groupExists))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.SEQUENCE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CONTENT_MODEL"), attributes, parent, parent.getFirstChild());
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, parent.getFirstChild());
- }
- }
- manager.add(new Separator());
- if (anyAttributeExists)
- {
- anyAttributeNode = getFirstChildNodeIfExists(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, anyAttributeNode);
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, anyAttributeNode);
- }
- else
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, parent.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, parent.getLastChild());
- }
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.EXTENSION_ELEMENT_TAG, false))
- {
- Element parentNode = (Element) parent.getParentNode();
- // <simpleContent>
- // <extension>
- // ...
- if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- boolean anyAttributeExists = false;
- Node anyAttributeNode = null;
- anyAttributeExists = elementExists(XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, parent);
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent
- .getFirstChild());
- manager.add(new Separator());
- if (anyAttributeExists)
- {
- anyAttributeNode = getFirstChildNodeIfExists(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, anyAttributeNode);
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, anyAttributeNode);
- }
- else
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, parent.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, parent.getLastChild());
- }
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- }
- // <complexContent>
- // <extension>
- // ...
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- boolean annotationExists = false;
- boolean anyAttributeExists = false;
- Node anyAttributeNode = null;
- boolean sequenceExists = elementExists(XSDConstants.SEQUENCE_ELEMENT_TAG, parent);
- boolean choiceExists = elementExists(XSDConstants.CHOICE_ELEMENT_TAG, parent);
- boolean allExists = elementExists(XSDConstants.ALL_ELEMENT_TAG, parent);
- boolean groupExists = elementExists(XSDConstants.GROUP_ELEMENT_TAG, parent);
- anyAttributeExists = elementExists(XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, parent);
- annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent
- .getFirstChild());
- manager.add(new Separator());
- if (annotationExists)
- {
- if (!(sequenceExists || choiceExists || allExists || groupExists))
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- addCreateElementActionIfNotExist(manager, XSDConstants.SEQUENCE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CONTENT_MODEL"), attributes, parent, annotationNode
- .getNextSibling());
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, annotationNode.getNextSibling());
- }
- }
- else
- {
- if (!(sequenceExists || choiceExists || allExists || groupExists))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.SEQUENCE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CONTENT_MODEL"), attributes, parent, parent.getFirstChild());
- addCreateElementRefAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ADD_GROUP_REF"), parent, parent.getFirstChild());
- }
- }
- manager.add(new Separator());
- if (anyAttributeExists)
- {
- anyAttributeNode = getFirstChildNodeIfExists(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, anyAttributeNode);
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, anyAttributeNode);
- }
- else
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, parent.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, parent.getLastChild());
- }
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- }
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.REDEFINE_ELEMENT_TAG, false))
- { //
- addCreateElementAction(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, null);
- addCreateElementAction(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SIMPLE_TYPE"), attributes, parent, null);
- addCreateElementAction(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_COMPLEX_TYPE"), attributes, parent, null);
- addCreateGroupAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GROUP"), attributes, parent, null);
- addCreateElementAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP"), attributes, parent, null);
- manager.add(new Separator());
- addOpenSchemaAction(manager, XSDEditorPlugin.getXSDString("_UI_ACTION_OPEN_SCHEMA"), parent);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.LIST_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- addCreateLocalSimpleTypeActionIfNotExist(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LOCAL_SIMPLE_TYPE"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- addCreateLocalSimpleTypeAction(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LOCAL_SIMPLE_TYPE"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.UNIQUE_ELEMENT_TAG, false))
- {
- boolean annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, ""));
- if (annotationExists)
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- addCreateElementActionIfNotExist(manager, XSDConstants.SELECTOR_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SELECTOR"), attributes, parent, annotationNode.getNextSibling());
- }
- else
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.SELECTOR_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SELECTOR"), attributes, parent, parent.getFirstChild());
- }
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, ""));
- addCreateElementAction(manager, XSDConstants.FIELD_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_FIELD"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.KEYREF_ELEMENT_TAG, false))
- {
- boolean annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, ""));
- if (annotationExists)
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- addCreateElementActionIfNotExist(manager, XSDConstants.SELECTOR_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SELECTOR"), attributes, parent, annotationNode.getNextSibling());
- }
- else
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.SELECTOR_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SELECTOR"), attributes, parent, parent.getFirstChild());
- }
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, ""));
- addCreateElementAction(manager, XSDConstants.FIELD_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_FIELD"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.KEY_ELEMENT_TAG, false))
- {
- boolean annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, ""));
- if (annotationExists)
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- addCreateElementActionIfNotExist(manager, XSDConstants.SELECTOR_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SELECTOR"), attributes, parent, annotationNode.getNextSibling());
- }
- else
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.SELECTOR_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SELECTOR"), attributes, parent, parent.getFirstChild());
- }
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, ""));
- addCreateElementAction(manager, XSDConstants.FIELD_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_FIELD"), attributes, parent, null);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.IMPORT_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- manager.add(new Separator());
- addOpenSchemaAction(manager, XSDEditorPlugin.getXSDString("_UI_ACTION_OPEN_SCHEMA"), parent);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.SELECTOR_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.FIELD_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.INCLUDE_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- manager.add(new Separator());
- addOpenSchemaAction(manager, XSDEditorPlugin.getXSDString("_UI_ACTION_OPEN_SCHEMA"), parent);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ANY_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- // need to add adapters for the ANY element. I'd rather not provide this menu
- // and let users see that the graph view doesn't update
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- addCreateElementActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- addCreateLocalSimpleTypeActionIfNotExist(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LOCAL_SIMPLE_TYPE"), attributes, parent, null);
- }
- // Facets all have optional annotation nodes
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.MINEXCLUSIVE_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.MININCLUSIVE_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.MAXEXCLUSIVE_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.MAXINCLUSIVE_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.TOTALDIGITS_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.FRACTIONDIGITS_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.LENGTH_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.MINLENGTH_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.MAXLENGTH_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ENUMERATION_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.WHITESPACE_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.PATTERN_ELEMENT_TAG, false))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent, parent.getFirstChild());
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.ELEMENT_ELEMENT_TAG, true))
- {
- XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent)getXSDSchema().getCorrespondingComponent(parent);
- if (xsdConcreteComponent instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdConcreteComponent;
- XSDElementDeclaration resolvedElementDeclaration = xsdElementDeclaration.getResolvedElementDeclaration();
- if (resolvedElementDeclaration.getRootContainer() == xsdSchema)
- {
- parent = resolvedElementDeclaration.getElement();
-
- boolean annotationExists = addCreateAnnotationActionIfNotExist(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), attributes, parent,
- parent.getFirstChild());
- boolean simpleTypeExists = elementExists(XSDConstants.SIMPLETYPE_ELEMENT_TAG, parent);
- boolean complexTypeExists = elementExists(XSDConstants.COMPLEXTYPE_ELEMENT_TAG, parent);
- manager.add(new Separator());
- if (annotationExists)
- {
- Node annotationNode = getFirstChildNodeIfExists(parent, XSDConstants.ANNOTATION_ELEMENT_TAG, false);
- if (!(simpleTypeExists || complexTypeExists) && annotationNode != null)
- {
- manager.add(new Separator());
- }
- }
- else
- {
- XSDConcreteComponent concreteComponent = getXSDSchema().getCorrespondingComponent(parent);
- if (concreteComponent != null)
- {
- AddModelGroupAction addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.SEQUENCE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.CHOICE_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- addModelGroupAction = new AddModelGroupAction(concreteComponent, XSDCompositor.ALL_LITERAL);
- addModelGroupAction.setEnabled(!isReadOnly);
- manager.add(addModelGroupAction);
-
- manager.add(new Separator());
- }
- }
- XSDDOMHelper domHelper = new XSDDOMHelper();
- Element anonymousType = (Element) domHelper.getChildNode(parent, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (anonymousType != null)
- {
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("ComplexType")));
- addMoveAnonymousGlobal(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"), attributes, anonymousType, null);
- attributes = null;
- }
- anonymousType = (Element) domHelper.getChildNode(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (anonymousType != null)
- {
- manager.add(new Separator());
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("SimpleType")));
- addMoveAnonymousGlobal(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"), attributes, anonymousType, null);
- attributes = null;
- }
- }
- addMultiplicityMenu(xsdConcreteComponent, manager);
- }
- }
-
- XSDConcreteComponent concreteComponent = getXSDSchema().getCorrespondingComponent(parent);
- if (concreteComponent instanceof XSDNamedComponent)
- {
- addRefactorMenuGroup(manager);
- }
- }
-
- protected void addContextInsertItems(IMenuManager manager, Element parent, Element currentElement, Node relativeNode)
- {
- ArrayList attributes = null;
- if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.INCLUDE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals(currentElement, XSDConstants.IMPORT_ELEMENT_TAG, false)
- || XSDDOMHelper.inputEquals(currentElement, XSDConstants.REDEFINE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals(currentElement, XSDConstants.ANNOTATION_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, ""));
- addCreateElementAction(manager, XSDConstants.INCLUDE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_INCLUDE"), attributes, parent, relativeNode);
- addCreateElementAction(manager, XSDConstants.IMPORT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_IMPORT"), null, parent, relativeNode);
- addCreateElementAction(manager, XSDConstants.REDEFINE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_REDEFINE"), attributes, parent, relativeNode);
- attributes = null;
- addCreateElementAction(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), null, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- addCreateLocalSimpleTypeAction(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LOCAL_SIMPLE_TYPE"), attributes, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.GROUP_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.NOTATION_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- addSchemaElementItems(manager, parent, relativeNode);
- }
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.DOCUMENTATION_ELEMENT_TAG, false))
- {
- addCreateElementAction(manager, XSDConstants.DOCUMENTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_DOC"), attributes, parent, relativeNode);
- addCreateElementAction(manager, XSDConstants.APPINFO_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_APP_INFO"), attributes, parent, relativeNode);
- }
- else if (XSDDOMHelper.inputEquals(currentElement, XSDConstants.APPINFO_ELEMENT_TAG, false))
- {
- addCreateElementAction(manager, XSDConstants.DOCUMENTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_DOC"), attributes, parent, relativeNode);
- addCreateElementAction(manager, XSDConstants.APPINFO_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_APP_INFO"), attributes, parent, relativeNode);
- }
- }
-
- protected String getNewGlobalName(String elementTag, String description)
- {
- return getNewGlobalName(elementTag, description, false);
- }
-
- protected String getNewGlobalTypeName(String description)
- {
- return getNewGlobalName(null, description, true);
- }
-
- protected String getNewGlobalName(String elementTag, String description, boolean isSimpleOrComplexType)
- {
- return getNewName(getXSDSchema().getDocument(), elementTag, description, isSimpleOrComplexType);
- }
-
- // TODO.. .we need to rewrite this code to me model driven... not document driven
- //
- protected String getNewName(Node parentNode, String elementTag, String description, boolean isSimpleOrComplexType)
- {
- NodeList list = null;
- NodeList typeList2 = null;
- // if the global name is for a simple or complex type, we ignore the
- // elementTag and populate 2 lists
- // one to look for all simple types and the other to look for all complex
- // types
- if (isSimpleOrComplexType)
- {
- if (parentNode instanceof Document)
- {
- list = ((Document) parentNode).getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- typeList2 = ((Document) parentNode).getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- else if (parentNode instanceof Element)
- {
- list = ((Element) parentNode).getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- typeList2 = ((Element) parentNode).getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- }
- else
- {
- if (parentNode instanceof Document)
- {
- list = ((Document) parentNode).getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, elementTag);
- }
- else if (parentNode instanceof Element)
- {
- list = ((Element) parentNode).getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, elementTag);
- }
- }
- String name = "New" + description;
- if (list == null || list.getLength() == 0 && (typeList2 != null && typeList2.getLength() == 0))
- {
- return name;
- }
- for (int i = 1; i < 100; i++)
- {
- boolean newName = false;
- for (int j = 0; j < list.getLength(); j++)
- {
- String currName = ((Element) list.item(j)).getAttribute(XSDConstants.NAME_ATTRIBUTE);
- if (currName == null || currName.length() == 0)
- {
- continue;
- }
- if (currName.equals(name))
- {
- name = "New" + description + String.valueOf(i);
- newName = true;
- break;
- }
- }
- // if there is another type list and we haven't created a new name, then
- // check the type list
- if (typeList2 != null && !newName)
- {
- for (int j = 0; j < typeList2.getLength(); j++)
- {
- String currName = ((Element) typeList2.item(j)).getAttribute(XSDConstants.NAME_ATTRIBUTE);
- if (currName == null || currName.length() == 0)
- {
- continue;
- }
- if (currName.equals(name))
- {
- name = "New" + description + String.valueOf(i);
- break;
- }
- }
- }
- }
- return name;
- }
-
- protected String getFirstGlobalElementTagName(String elementTag)
- {
- //XMLModel model = getXMLModel();
- //if (model != null)
- {
- XSDSchema schema = getXSDSchema();
- TypesHelper helper = new TypesHelper(schema);
- String prefix = "";
- if (schema != null)
- {
- prefix = helper.getPrefix(schema.getTargetNamespace(), true);
- }
- // get the schema node
- NodeList slist = schema.getDocument().getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, XSDConstants.SCHEMA_ELEMENT_TAG);
- Node schemaNode = null;
- if (slist != null && slist.getLength() > 0)
- {
- schemaNode = slist.item(0);
- }
- NodeList list = null;
- // get the schema's direct children - hence, globals
- if (schemaNode != null)
- {
- list = schemaNode.getChildNodes();
- }
- String name = null;
- if (list != null)
- {
- for (int i = 0; i < list.getLength(); i++)
- {
- if (list.item(i) instanceof Element)
- {
- if (list.item(i).getLocalName().equals(elementTag))
- {
- name = ((Element) list.item(i)).getAttribute(XSDConstants.NAME_ATTRIBUTE);
- if (name != null && name.length() > 0)
- {
- return prefix + name;
- }
- }
- }
- }
- }
- if (elementTag.equals(XSDConstants.ELEMENT_ELEMENT_TAG))
- {
- return helper.getGlobalElement(schema);
- }
- else if (elementTag.equals(XSDConstants.ATTRIBUTE_ELEMENT_TAG))
- {
- return helper.getGlobalAttribute(schema);
- }
- else if (elementTag.equals(XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG))
- {
- return helper.getGlobalAttributeGroup(schema);
- }
- else if (elementTag.equals(XSDConstants.GROUP_ELEMENT_TAG))
- {
- return helper.getModelGroup(schema);
- }
- }
- return null;
- }
-
- protected void addSchemaElementItems(IMenuManager manager, Element parent, Node relativeNode)
- {
- ArrayList attributes = null;
- // Add Edit Namespaces menu action
- XSDEditNamespacesAction nsAction = new XSDEditNamespacesAction(XSDEditorPlugin.getXSDString("_UI_ACTION_EDIT_NAMESPACES"), parent, relativeNode, getXSDSchema());
- manager.add(nsAction);
- manager.add(new Separator());
- DOMAttribute nameAttribute = new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("ComplexType"));
- attributes = new ArrayList();
- attributes.add(nameAttribute);
- Action action = addCreateElementAction(manager, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_COMPLEX_TYPE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalTypeName("SimpleType")));
- action = addCreateElementAction(manager, XSDConstants.SIMPLETYPE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SIMPLE_TYPE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.ELEMENT_ELEMENT_TAG, "GlobalElement")));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- action = addCreateElementAction(manager, XSDConstants.ELEMENT_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GLOBAL_ELEMENT"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.ATTRIBUTE_ELEMENT_TAG, "GlobalAttribute")));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- action = addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GLOBAL_ATTRIBUTE"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, "AttributeGroup")));
- action = addCreateElementAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.GROUP_ELEMENT_TAG, "Group")));
- CreateGroupAction groupAction = addCreateGroupAction(manager, XSDConstants.GROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_GROUP"), attributes, parent, relativeNode);
- groupAction.setIsGlobal(true);
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE, getNewGlobalName(XSDConstants.NOTATION_ELEMENT_TAG, "Notation")));
- attributes.add(new DOMAttribute(XSDConstants.PUBLIC_ATTRIBUTE, ""));
- action = addCreateElementAction(manager, XSDConstants.NOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_NOTATION"), attributes, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- action = addCreateElementAction(manager, XSDConstants.ANNOTATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANNOTATION"), null, parent, relativeNode);
- ((CreateElementAction) action).setIsGlobal(true);
- }
-
- // returns whether element exists already
- protected boolean addCreateElementActionIfNotExist(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- if (getFirstChildNodeIfExists(parent, elementTag, false) == null)
- {
- addCreateElementAction(manager, elementTag, label, attributes, parent, relativeNode);
- return false;
- }
- return true;
- }
-
- protected Action addCreateElementAction(IMenuManager manager, 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);
- action.setXSDSchema(getXSDSchema());
- action.setSelectionProvider(selectionProvider);
- action.setEnabled(!isReadOnly);
- action.setSourceContext(sourceContext);
- manager.add(action);
- return action;
- }
-
- protected void addCreateElementAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode, boolean isEnabled)
- {
- Action action = addCreateElementAction(manager, elementTag, label, attributes, parent, relativeNode);
- action.setEnabled(isEnabled);
- }
-
- protected void addCreateElementRefAction(IMenuManager manager, String elementTag, String label, Element parent, Node relativeNode)
- {
- ArrayList attributes = new ArrayList();
- String ref = getFirstGlobalElementTagName(elementTag);
- attributes.add(new DOMAttribute(XSDConstants.REF_ATTRIBUTE, ref));
- Action action = addCreateElementAction(manager, elementTag, label, attributes, parent, relativeNode);
- action.setEnabled(ref != null && !isReadOnly);
- }
-
- protected void addCreateSimpleContentAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- if (getFirstChildNodeIfExists(parent, elementTag, false) == null)
- {
- CreateSimpleContentAction action = new CreateSimpleContentAction(label, getXSDSchema());
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
- }
-
- protected CreateGroupAction addCreateGroupAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- CreateGroupAction action = new CreateGroupAction(label, getXSDSchema());
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setXSDSchema(getXSDSchema());
- action.setSelectionProvider(selectionProvider);
- action.setEnabled(!isReadOnly);
- action.setSourceContext(sourceContext);
- manager.add(action);
- return action;
- }
-
- protected void addCreateIdentityConstraintsAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- CreateIdentityConstraintsAction action = new CreateIdentityConstraintsAction(label, getXSDSchema());
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setXSDSchema(getXSDSchema());
- action.setSelectionProvider(selectionProvider);
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
-
- protected void addEnumsAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- AddEnumsAction action = new AddEnumsAction(label);
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setDescription(XSDEditorPlugin.getXSDString("_UI_ENUMERATIONS_DIALOG_TITLE"));
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
-
- protected Action addCreateSimpleTypeAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- CreateSimpleTypeAction action = new CreateSimpleTypeAction(label);
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setXSDSchema(getXSDSchema());
- action.setSelectionProvider(selectionProvider);
- action.setEnabled(!isReadOnly);
- action.setSourceContext(sourceContext);
- manager.add(action);
- return action;
- }
-
- protected boolean addCreateLocalSimpleTypeActionIfNotExist(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- if (getFirstChildNodeIfExists(parent, elementTag, false) == null)
- {
- addCreateLocalSimpleTypeAction(manager, elementTag, label, attributes, parent, relativeNode);
- return false;
- }
- return true;
- }
-
- protected void addSetBaseTypeAction(IMenuManager manager, Element element)
- {
- SetBaseTypeAction action = new SetBaseTypeAction(XSDEditorPlugin.getXSDString("_UI_ACTION_SET_BASE_TYPE"));// +
- // "...");
- action.setComplexTypeElement(element);
- action.setXSDSchema(getXSDSchema());
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
-
- protected void addCreateLocalSimpleTypeAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- CreateLocalSimpleTypeAction action = new CreateLocalSimpleTypeAction(label);
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setXSDSchema(getXSDSchema());
- action.setSelectionProvider(selectionProvider);
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
-
- protected boolean addCreateLocalComplexTypeActionIfNotExist(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- if (getFirstChildNodeIfExists(parent, elementTag, false) == null)
- {
- addCreateLocalComplexTypeAction(manager, elementTag, label, attributes, parent, relativeNode);
- return false;
- }
- return true;
- }
-
- protected void addCreateLocalComplexTypeAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- CreateLocalComplexTypeAction action = new CreateLocalComplexTypeAction(label);
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setXSDSchema(getXSDSchema());
- action.setSelectionProvider(selectionProvider);
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
-
- protected boolean addCreateAnnotationActionIfNotExist(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- return false;
- }
-
- protected void addOpenSchemaAction(IMenuManager manager, String label, Element parent)
- {
- OpenSchemaAction openAction = new OpenSchemaAction(label, getXSDSchema().getCorrespondingComponent(parent));
- manager.add(openAction);
- }
-
- protected void addMoveAnonymousGlobal(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
-// MakeAnonymousGlobal action = new MakeAnonymousGlobal(label, parent, getXSDSchema());
-// action.setElementTag(elementTag);
-// action.setAttributes(attributes);
-// action.setParentNode(getXSDSchema().getElement());
-// action.setRelativeNode(relativeNode);
-// action.setEnabled(!isReadOnly);
-// //manager.add(action);
-// addRefactorMenuGroup(manager);
-// fRefactorMenuGroup.addAction(action);
- }
-
- protected void addRefactorMenuGroup(IMenuManager manager){
- fRefactorMenuGroup = new RefactorActionGroup(selectionProvider, getXSDSchema());
- ActionContext context= new ActionContext(selectionProvider.getSelection());
- fRefactorMenuGroup.setContext(context);
- fRefactorMenuGroup.fillContextMenu(manager);
- fRefactorMenuGroup.setContext(null);
- }
-
- protected void addCreateAnnotationAction(IMenuManager manager, String elementTag, String label, List attributes, Element parent, Node relativeNode)
- {
- CreateAnnotationAction action = new CreateAnnotationAction(label);
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(parent);
- action.setRelativeNode(relativeNode);
- action.setEnabled(!isReadOnly);
- manager.add(action);
- }
-
- protected Node getFirstChildNodeIfExists(Node parent, String elementTag, boolean isRef)
- {
- if (parent == null)
- return null;
- NodeList children = parent.getChildNodes();
- Node targetNode = null;
- for (int i = 0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
- if (child != null && child instanceof Element)
- {
- if (XSDDOMHelper.inputEquals((Element) child, elementTag, isRef))
- {
- targetNode = child;
- break;
- }
- }
- }
- return targetNode;
- }
-
- protected boolean elementExists(String elementTag, Element parent)
- {
- if (!(parent.getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, elementTag).getLength() > 0))
- {
- return false;
- }
- return true;
- }
-
- /**
- * Returns the deleteAction.
- *
- * @return DeleteAction
- */
- public DeleteAction getDeleteAction()
- {
- return deleteAction;
- }
-
- protected void addMultiplicityMenu(XSDConcreteComponent concreteComponent, IMenuManager manager)
- {
- SetMultiplicityAction oneMultiplicity = new SetMultiplicityAction(concreteComponent, "1");
- oneMultiplicity.setMaxOccurs(1);
- oneMultiplicity.setMinOccurs(1);
- oneMultiplicity.setEnabled(!isReadOnly);
- SetMultiplicityAction zeroOrMoreMultiplicity = new SetMultiplicityAction(concreteComponent, "0..* (" + XSDEditorPlugin.getXSDString("_ZERO_OR_MORE") + ")");
- zeroOrMoreMultiplicity.setMaxOccurs(-1);
- zeroOrMoreMultiplicity.setMinOccurs(0);
- zeroOrMoreMultiplicity.setEnabled(!isReadOnly);
- SetMultiplicityAction zeroOrOneMultiplicity = new SetMultiplicityAction(concreteComponent, "0..1 (" + XSDEditorPlugin.getXSDString("_ZERO_OR_ONE") + ")");
- zeroOrOneMultiplicity.setMaxOccurs(1);
- zeroOrOneMultiplicity.setMinOccurs(0);
- zeroOrOneMultiplicity.setEnabled(!isReadOnly);
- SetMultiplicityAction oneOrMoreMultiplicity = new SetMultiplicityAction(concreteComponent, "1..* (" + XSDEditorPlugin.getXSDString("_ONE_OR_MORE") + ")");
- oneOrMoreMultiplicity.setMaxOccurs(-1);
- oneOrMoreMultiplicity.setMinOccurs(1);
- oneOrMoreMultiplicity.setEnabled(!isReadOnly);
-
- MenuManager multiplicityMenu = new MenuManager(XSDEditorPlugin.getXSDString("_UI_ACTION_SET_MULTIPLICITY"));
- manager.add(multiplicityMenu);
- multiplicityMenu.add(oneMultiplicity);
- multiplicityMenu.add(zeroOrOneMultiplicity);
- multiplicityMenu.add(zeroOrMoreMultiplicity);
- multiplicityMenu.add(oneOrMoreMultiplicity);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMultiPageEditorPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMultiPageEditorPart.java
deleted file mode 100644
index 009efb1ebc..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDMultiPageEditorPart.java
+++ /dev/null
@@ -1,645 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.wst.common.ui.provisional.editors.PostMultiPageEditorSite;
-import org.eclipse.wst.common.ui.provisional.editors.PostSelectionMultiPageEditorPart;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLPreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
-import org.eclipse.wst.xml.ui.internal.tabletree.XMLEditorMessages;
-import org.w3c.dom.Document;
-
-public class XSDMultiPageEditorPart extends PostSelectionMultiPageEditorPart implements IPropertyListener
-{
-
- /**
- *
- */
- public XSDMultiPageEditorPart()
- {
- super();
- }
-
- /**
- * Internal part activation listener
- */
- class PartListener extends ShellAdapter implements IPartListener {
- private IWorkbenchPart fActivePart;
- private boolean fIsHandlingActivation = false;
-
- private void handleActivation() {
-
- if (fIsHandlingActivation)
- return;
-
- if (fActivePart == XSDMultiPageEditorPart.this) {
- fIsHandlingActivation = true;
- try {
- safelySanityCheckState();
- }
- finally {
- fIsHandlingActivation = false;
- }
- }
- }
-
- /**
- * @see IPartListener#partActivated(IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart part) {
- fActivePart = part;
- handleActivation();
- }
-
- /**
- * @see IPartListener#partBroughtToTop(IWorkbenchPart)
- */
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- /**
- * @see IPartListener#partClosed(IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part) {
- }
-
- /**
- * @see IPartListener#partDeactivated(IWorkbenchPart)
- */
- public void partDeactivated(IWorkbenchPart part) {
- fActivePart = null;
- }
-
- /**
- * @see IPartListener#partOpened(IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part) {
- }
-
- /*
- * @see ShellListener#shellActivated(ShellEvent)
- */
- public void shellActivated(ShellEvent e) {
- handleActivation();
- }
- }
-
- class TextInputListener implements ITextInputListener {
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- }
-
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- }
- }
-
- /** The source page index. */
- private int fSourcePageIndex;
- /** The text editor. */
- private StructuredTextEditor fTextEditor;
-
- private PartListener partListener;
-
-
- /*
- * This method is just to make firePropertyChanged accessbible from some
- * (anonomous) inner classes.
- */
- protected void _firePropertyChange(int property) {
- super.firePropertyChange(property);
- }
-
- /**
- * Adds the source page of the multi-page editor.
- */
- protected void addSourcePage() throws PartInitException {
- try {
- fSourcePageIndex = addPage(fTextEditor, getEditorInput());
- setPageText(fSourcePageIndex, XSDEditorPlugin.getXSDString("_UI_TAB_SOURCE")); //$NON-NLS-1$
- // the update's critical, to get viewer selection manager and
- // highlighting to work
- fTextEditor.update();
-
- firePropertyChange(PROP_TITLE);
-
- // Changes to the Text Viewer's document instance should also force an
- // input refresh
- fTextEditor.getTextViewer().addTextInputListener(new TextInputListener());
- }
- catch (PartInitException e) {
- // dispose editor
- dispose();
-
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.MultiPageEditorPart#createPages()
- */
- protected void createPages()
- {
- try
- {
- // source page MUST be created before design page, now
- createSourcePage();
- addSourcePage();
- setActivePage();
-
- // future_TODO: add a catch block here for any exception the design
- // page throws and convert it into a more informative message.
- }
- catch (PartInitException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * @see org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclipse.ui.IEditorPart)
- */
- protected IEditorSite createSite(IEditorPart editor) {
- IEditorSite site = null;
- if (editor == fTextEditor) {
- site = new PostMultiPageEditorSite(this, editor) {
- public IEditorActionBarContributor getActionBarContributor() {
- IEditorActionBarContributor contributor = super.getActionBarContributor();
- XSDMultiPageEditorPart.this.getEditorSite().getActionBarContributor();
- return contributor;
- }
-
- public String getId() {
- // sets this id so nested editor is considered xml source
- // page
- return ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$;
- }
- };
- }
- else {
- site = super.createSite(editor);
- }
- return site;
- }
-
- /**
- * Creates the source page of the multi-page editor.
- */
- protected void createSourcePage() throws PartInitException {
- fTextEditor = createTextEditor();
- fTextEditor.setEditorPart(this);
-
- // Set the SourceViewerConfiguration now so the text editor won't use
- // the default configuration first
- // and switch to the StructuredTextViewerConfiguration later.
- // DMW removed setSourceViewerConfiguration 3/26/2003 since added
- // createPartControl to our text editor.
- // fTextEditor.setSourceViewerConfiguration();
- fTextEditor.addPropertyListener(this);
- }
-
- /**
- * Method createTextEditor.
- *
- * @return StructuredTextEditor
- */
- protected StructuredTextEditor createTextEditor() {
- return new StructuredTextEditor();
- }
-
- public void dispose()
- {
- IWorkbenchWindow window = getSite().getWorkbenchWindow();
- window.getPartService().removePartListener(partListener);
- window.getShell().removeShellListener(partListener);
-
- getSite().getPage().removePartListener(partListener);
- if (fTextEditor != null) {
- fTextEditor.removePropertyListener(this);
- }
- fTextEditor = null;
-
- // moved to last when added window ... seems like
- // we'd be in danger of losing some data, like site,
- // or something.
- super.dispose();
- }
-
- /*
- * (non-Javadoc) Saves the contents of this editor. <p> Subclasses must
- * override this method to implement the open-save-close lifecycle for an
- * editor. For greater details, see <code> IEditorPart </code></p>
- *
- * @see IEditorPart
- */
- public void doSave(IProgressMonitor monitor) {
- fTextEditor.doSave(monitor);
- // // this is a temporary way to force validation.
- // // when the validator is a workbench builder, the following lines
- // can be removed
- // if (fDesignViewer != null)
- // fDesignViewer.saveOccurred();
-
- }
-
- /*
- * (non-Javadoc) Saves the contents of this editor to another object. <p>
- * Subclasses must override this method to implement the open-save-close
- * lifecycle for an editor. For greater details, see <code> IEditorPart
- * </code></p>
- *
- * @see IEditorPart
- */
- public void doSaveAs() {
- fTextEditor.doSaveAs();
- // 253619
- // following used to be executed here, but is
- // now called "back" from text editor (since
- // mulitiple paths to the performSaveAs in StructuredTextEditor.
- //doSaveAsForStructuredTextMulitPagePart();
- }
-
- private void editorInputIsAcceptable(IEditorInput input) throws PartInitException {
- if (input instanceof IFileEditorInput) {
- // verify that it can be opened
- CoreException[] coreExceptionArray = new CoreException[1];
- if (fileDoesNotExist((IFileEditorInput) input, coreExceptionArray)) {
- CoreException coreException = coreExceptionArray[0];
- if (coreException.getStatus().getCode() == IResourceStatus.FAILED_READ_LOCAL) {
- // I'm assuming this is always 'does not exist'
- // we'll refresh local go mimic behavior of default
- // editor, where the
- // troublesome file is refreshed (and will cause it to
- // 'disappear' from Navigator.
- try {
- ((IFileEditorInput) input).getFile().refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
- } catch (CoreException ce) {
- // very unlikely
- Logger.logException(ce);
- }
- throw new PartInitException(NLS.bind(XMLEditorMessages.Resource__does_not_exist, (new Object[]{input.getName()})));
- } else {
- throw new PartInitException(NLS.bind(XMLEditorMessages.Editor_could_not_be_open, (new Object[]{input.getName()})));
- }
- }
- } else if (input instanceof IStorageEditorInput) {
- InputStream contents = null;
- try {
- contents = ((IStorageEditorInput) input).getStorage().getContents();
- } catch (CoreException noStorageExc) {
- }
- if (contents == null) {
- throw new PartInitException(NLS.bind(XMLEditorMessages.Editor_could_not_be_open, (new Object[]{input.getName()})));
- } else {
- try {
- contents.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- // void doSaveAsForStructuredTextMulitPagePart() {
- // setPageText(getActivePage(), fTextEditor.getTitle());
- // setInput(fTextEditor.getEditorInput());
- // if (fDesignViewer != null) {
- // //fDesignViewer.setEditorInput(fTextEditor.getEditorInput());
- // fDesignViewer.setModel(getModel());
- // fDesignViewer.saveAsOccurred();
- // }
- // // even though we've set title etc., several times already!
- // // only now is all prepared for it.
- // firePropertyChange(IWorkbenchPart.PROP_TITLE);
- // firePropertyChange(PROP_DIRTY);
- // }
- /*
- * (non-Javadoc) Initializes the editor part with a site and input. <p>
- * Subclasses of <code> EditorPart </code> must implement this method.
- * Within the implementation subclasses should verify that the input type
- * is acceptable and then save the site and input. Here is sample code:
- * </p><pre> if (!(input instanceof IFileEditorInput)) throw new
- * PartInitException("Invalid Input: Must be IFileEditorInput");
- * setSite(site); setInput(editorInput); </pre>
- */
- protected boolean fileDoesNotExist(IFileEditorInput input, Throwable[] coreException) {
- boolean result = false;
- InputStream inStream = null;
- if ((!(input.exists())) || (!(input.getFile().exists()))) {
- result = true;
- }
- else {
- try {
- inStream = input.getFile().getContents(true);
- }
- catch (CoreException e) {
- // very likely to be file not found
- result = true;
- coreException[0] = e;
- }
- finally {
- if (input != null) {
- try {
- if (inStream != null) {
- inStream.close();
- }
- }
- catch (IOException e) {
-
- }
- }
- }
- }
- return result;
- }
-
- public Object getAdapter(Class key) {
- Object result = null;
-
- // DMW: I'm bullet-proofing this because
- // its been reported (on 4.03 version) a null pointer sometimes
- // happens here on startup, when an editor has been left
- // open when workbench shutdown.
- if (fTextEditor != null) {
- result = fTextEditor.getAdapter(key);
- }
- return result;
- }
-
- public Document getDOMDocument() {
- if (getTextEditor() == null)
- return null;
-
- ISourceEditingTextTools tools = (ISourceEditingTextTools) getAdapter(ISourceEditingTextTools.class);
- if(tools != null && tools instanceof IDOMSourceEditingTextTools) {
- return ((IDOMSourceEditingTextTools)tools).getDOMDocument();
- }
- return null;
- }
-
- protected IStructuredModel getModel() {
- IStructuredModel model = null;
- if (fTextEditor != null)
- model = fTextEditor.getModel();
- return model;
- }
-
- protected IPreferenceStore getPreferenceStore() {
- return XSDEditorPlugin.getPlugin().getPreferenceStore();
- }
-
- public StructuredTextEditor getTextEditor() {
- return fTextEditor;
- }
-
- /*
- * (non-Javadoc) Method declared on IWorkbenchPart.
- */
- public String getTitle() {
- String title = null;
- if (getTextEditor() == null) {
- if (getEditorInput() != null) {
- title = getEditorInput().getName();
- }
- }
- else {
- title = getTextEditor().getTitle();
- }
- if (title == null) {
- title = getPartName();
- }
- return title;
- }
-
- /*
- * (non-Javadoc) Sets the cursor and selection state for this editor to
- * the passage defined by the given marker. <p> Subclasses may override.
- * For greater details, see <code> IEditorPart </code></p>
- *
- * @see IEditorPart
- */
- public void gotoMarker(IMarker marker) {
- // (pa) 20020217 this was null when opening an editor that was
- // already open
- if (fTextEditor != null) {
- IGotoMarker markerGotoer = (IGotoMarker) fTextEditor.getAdapter(IGotoMarker.class);
- markerGotoer.gotoMarker(marker);
- }
- }
-
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-// editorInputIsAcceptable(input);
- try {
- super.init(site, input);
- if (partListener == null) {
- partListener = new PartListener();
- }
- //getSite().getPage().addPartListener(partListner);
- // we want to listen for our own activation
- IWorkbenchWindow window = getSite().getWorkbenchWindow();
- window.getPartService().addPartListener(partListener);
- window.getShell().addShellListener(partListener);
- }
- catch (Exception e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- setPartName(input.getName());
- }
-
- /*
- * (non-Javadoc) Returns whether the "save as" operation is supported by
- * this editor. <p> Subclasses must override this method to implement the
- * open-save-close lifecycle for an editor. For greater details, see
- * <code> IEditorPart </code></p>
- *
- * @see IEditorPart
- */
- public boolean isSaveAsAllowed() {
- return fTextEditor != null && fTextEditor.isSaveAsAllowed();
- }
-
- /*
- * (non-Javadoc) Returns whether the contents of this editor should be
- * saved when the editor is closed. <p> This method returns <code> true
- * </code> if and only if the editor is dirty ( <code> isDirty </code> ).
- * </p>
- */
- public boolean isSaveOnCloseNeeded() {
- // overriding super class since it does a lowly isDirty!
- if (fTextEditor != null)
- return fTextEditor.isSaveOnCloseNeeded();
- return isDirty();
- }
-
- /**
- * Notifies this multi-page editor that the page with the given id has
- * been activated. This method is called when the user selects a different
- * tab.
- *
- * @param newPageIndex
- * the index of the activated page
- */
- protected void pageChange(int newPageIndex) {
- super.pageChange(newPageIndex);
-
- saveLastActivePageIndex(newPageIndex);
- }
-
- /**
- * Posts the update code "behind" the running operation.
- */
- protected void postOnDisplayQue(Runnable runnable) {
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
- if (windows != null && windows.length > 0) {
- Display display = windows[0].getShell().getDisplay();
- display.asyncExec(runnable);
- }
- else
- runnable.run();
- }
-
- /**
- * Indicates that a property has changed.
- *
- * @param source
- * the object whose property has changed
- * @param propId
- * the id of the property which has changed; property ids are
- * generally defined as constants on the source class
- */
- public void propertyChanged(Object source, int propId) {
- switch (propId) {
- // had to implement input changed "listener" so that
- // strucutedText could tell it containing editor that
- // the input has change, when a 'resource moved' event is
- // found.
- case IEditorPart.PROP_INPUT :
- case IEditorPart.PROP_DIRTY : {
- if (source == fTextEditor) {
- if (fTextEditor.getEditorInput() != getEditorInput()) {
- setInput(fTextEditor.getEditorInput());
- // title should always change when input changes.
- // create runnable for following post call
- Runnable runnable = new Runnable() {
- public void run() {
- _firePropertyChange(IWorkbenchPart.PROP_TITLE);
- }
- };
- // Update is just to post things on the display queue
- // (thread). We have to do this to get the dirty
- // property to get updated after other things on the
- // queue are executed.
- postOnDisplayQue(runnable);
- }
- }
- break;
- }
- case IWorkbenchPart.PROP_TITLE : {
- // update the input if the title is changed
- if (source == fTextEditor) {
- if (fTextEditor.getEditorInput() != getEditorInput()) {
- setInput(fTextEditor.getEditorInput());
- }
- }
- break;
- }
- default : {
- // propagate changes. Is this needed? Answer: Yes.
- if (source == fTextEditor) {
- firePropertyChange(propId);
- }
- break;
- }
- }
-
- }
-
- protected void safelySanityCheckState() {
- // If we're called before editor is created, simply ignore since we
- // delegate this function to our embedded TextEditor
- if (getTextEditor() == null)
- return;
-
- getTextEditor().safelySanityCheckState(getEditorInput());
-
- }
-
- protected void saveLastActivePageIndex(int newPageIndex) {
- // save the last active page index to preference manager
- getPreferenceStore().setValue(IXMLPreferenceNames.LAST_ACTIVE_PAGE, newPageIndex);
- }
-
- /**
- * Sets the currently active page.
- */
- protected void setActivePage() {
- // retrieve the last active page index from preference manager
- int activePageIndex = getPreferenceStore().getInt(IXMLPreferenceNames.LAST_ACTIVE_PAGE);
-
- // We check this range since someone could hand edit the XML
- // preference file to an invalid value ... which I know from
- // experience :( ... if they do, we'll reset to default and continue
- // rather than throw an assertion error in the setActivePage(int)
- // method.
- if (activePageIndex < 0 || activePageIndex >= getPageCount()) {
- activePageIndex = fSourcePageIndex;
- }
- setActivePage(activePageIndex);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
- */
- protected void setInput(IEditorInput input) {
- // If driven from the Source page, it's "model" may not be up to date
- // with the input just yet. We'll rely on later notification from the
- // TextViewer to set us straight
- super.setInput(input);
- setPartName(input.getName());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDSelectionManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDSelectionManager.java
deleted file mode 100644
index 22f0354d2b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDSelectionManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
-public class XSDSelectionManager implements ISelectionProvider, ISelectionChangedListener
-{
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
- */
- public ISelection getSelection()
- {
- return currentSelection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.remove(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
- */
- public void setSelection(ISelection selection)
- {
- setSelection(selection, this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event)
- {
- if (enableNotify)
- {
- setSelection(event.getSelection(), event.getSelectionProvider());
- }
- }
-
-
- protected List listenerList = new ArrayList();
- protected ISelection currentSelection;
- protected boolean enableNotify = true;
-
- public void setSelection(ISelection selection, ISelectionProvider source)
- {
-// System.out.println("SelectionManager.setSelection() " + selection + ", " + source);
- if (enableNotify)
- {
- currentSelection = selection;
- enableNotify = false;
- try
- {
- SelectionChangedEvent event = new SelectionChangedEvent(source, selection);
- List copyOfListenerList = new ArrayList(listenerList);
- for (Iterator i = copyOfListenerList.iterator(); i.hasNext(); )
- {
- ISelectionChangedListener listener = (ISelectionChangedListener)i.next();
- listener.selectionChanged(event);
- }
- }
- finally
- {
- enableNotify = true;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AbstractAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AbstractAction.java
deleted file mode 100644
index b421416adf..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AbstractAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-public class AbstractAction extends Action
-{
- XSDConcreteComponent xsdConcreteComponent;
-
- /**
- * @param text
- */
- public AbstractAction(String text, XSDConcreteComponent xsdConcreteComponent)
- {
- super(text);
- this.xsdConcreteComponent = xsdConcreteComponent;
- }
-
- /**
- * @param text
- * @param image
- */
- public AbstractAction(String text, ImageDescriptor image, XSDConcreteComponent xsdConcreteComponent)
- {
- super(text, image);
- this.xsdConcreteComponent = xsdConcreteComponent;
- }
-
- /**
- * @param text
- * @param style
- */
- public AbstractAction(String text, int style)
- {
- super(text, style);
- }
-
- public DocumentImpl getDocument()
- {
- return (DocumentImpl) xsdConcreteComponent.getElement().getOwnerDocument();
- }
-
- public void beginRecording(String description)
- {
- getDocument().getModel().beginRecording(this, description);
- }
-
- public void endRecording()
- {
- DocumentImpl doc = (DocumentImpl) getDocument();
-
- doc.getModel().endRecording(this);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddAttributeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddAttributeAction.java
deleted file mode 100644
index f1a9f3ffe3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddAttributeAction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.commands.AddAttributeDeclarationCommand;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-public class AddAttributeAction extends AbstractAction
-{
- protected AddAttributeDeclarationCommand command;
-
- public AddAttributeAction(String text, XSDConcreteComponent parent)
- {
- super(text, parent);
- command = new AddAttributeDeclarationCommand(parent);
- }
-
- public AddAttributeAction(String text, ImageDescriptor image, XSDConcreteComponent parent)
- {
- super(text, image, parent);
- command = new AddAttributeDeclarationCommand(parent);
- }
-
- public void run()
- {
- beginRecording(getText());
- command.run();
-
- endRecording();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddEnumsAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddEnumsAction.java
deleted file mode 100644
index ecc2f4b9d4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddEnumsAction.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xsd.ui.internal.widgets.EnumerationsDialog;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-/**
- * Pattern is scoped to Enum Type
- */
-public class AddEnumsAction extends CreateElementAction
-{
- public AddEnumsAction(String label)
- {
- super(label);
- }
-
- public Element createAndAddNewChildElement(String token)
- {
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- Element childNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + elementTag);
- if (getAttributes() != null)
- {
- List attributes = getAttributes();
- for (int i = 0; i < attributes.size(); i++)
- {
- DOMAttribute attr = (DOMAttribute) attributes.get(i);
- childNode.setAttribute(attr.getName(), attr.getValue());
- }
- }
- if (getRelativeNode() == null)
- {
- parentNode.appendChild(childNode);
- }
- else
- {
- ((Element)parentNode).insertBefore(childNode,getRelativeNode());
- }
- childNode.setAttribute("value", token);
- return childNode;
- }
-
- public void run()
- {
- 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)
- {
- beginRecording(getDescription());
-
- String text = dialog.getText();
- String delimiter = dialog.getDelimiter();
- StringTokenizer tokenizer = new StringTokenizer(text, delimiter);
- while (tokenizer.hasMoreTokens())
- {
- String token = tokenizer.nextToken();
- if (dialog.isPreserveWhitespace() == false)
- {
- token = token.trim();
- }
-
- Element child = createAndAddNewChildElement(token);
- formatChild(child);
- }
- endRecording();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java
deleted file mode 100644
index fcfdc77f2d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.commands.AddModelGroupCommand;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-
-public class AddModelGroupAction extends Action
-{
- protected AddModelGroupCommand command;
- protected XSDConcreteComponent parent;
-
- public static 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;
- }
-
- public AddModelGroupAction(XSDConcreteComponent parent, XSDCompositor compositor)
- {
- command = new AddModelGroupCommand(parent, compositor);
- this.parent = parent;
- setText(getLabel(compositor));
- }
-
- public void run()
- {
- DocumentImpl doc = (DocumentImpl) parent.getElement().getOwnerDocument();
- doc.getModel().beginRecording(this, getText());
- command.run();
- doc.getModel().endRecording(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddSchemaNodeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddSchemaNodeAction.java
deleted file mode 100644
index d890af0e2a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddSchemaNodeAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-
-
-public class AddSchemaNodeAction extends Action
-{
- /**
- * Constructor for AddSchemaNodeAction.
- */
- public AddSchemaNodeAction()
- {
- super();
- }
-
- /**
- * Constructor for AddSchemaNodeAction.
- * @param text
- */
- public AddSchemaNodeAction(String text)
- {
- super(text);
- }
-
- /**
- * Constructor for AddSchemaNodeAction.
- * @param text
- * @param image
- */
- public AddSchemaNodeAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public void setEditor(XSDEditor editor)
- {
- this.editor = editor;
- }
-
- protected XSDEditor editor;
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run()
- {
- editor.createDefaultSchemaNode(editor.getDOMDocument());
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/BackAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/BackAction.java
deleted file mode 100644
index 0ab518d244..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/BackAction.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphViewer;
-import org.eclipse.xsd.XSDSchema;
-
-/**
- * @author kchong
- *
- * <a href="mailto:kchong@ca.ibm.com">kchong@ca.ibm.com</a>
- *
- */
-public class BackAction extends Action
-{
- ISelectionProvider selectionProvider;
- XSDGraphViewer xsdGraphViewer;
- XSDSchema xsdSchema;
-
- /**
- *
- */
- public BackAction()
- {
- super();
- }
-
- /**
- * @param text
- */
- public BackAction(String text)
- {
- super(text);
- }
-
- public BackAction(String text, XSDGraphViewer viewer)
- {
- super(text);
- xsdGraphViewer = viewer;
- }
-
- /**
- * @param text
- * @param image
- */
- public BackAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- /**
- * @param text
- * @param style
- */
- public BackAction(String text, int style)
- {
- super(text, style);
- }
-
- public void setSelectionProvider(ISelectionProvider selectionProvider)
- {
- this.selectionProvider = selectionProvider;
- }
-
- public void setXSDSchema(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- /*
- * @see IAction#run()
- */
- public void run()
- {
- StructuredSelection selection = new StructuredSelection(xsdSchema);
- selectionProvider.setSelection(selection);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAnnotationAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAnnotationAction.java
deleted file mode 100644
index 698d433eea..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAnnotationAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class CreateAnnotationAction extends CreateElementAction
-{
- XSDSchema xsdSchema;
- Element documentationNode;
-
- public CreateAnnotationAction()
- {
- super();
- }
-
- public CreateAnnotationAction(String text)
- {
- super(text);
- }
-
- public CreateAnnotationAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- Element childNode = super.createAndAddNewChildElement();
-
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- documentationNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.DOCUMENTATION_ELEMENT_TAG);
- childNode.appendChild(documentationNode);
-
- formatChild(childNode);
- formatChild(documentationNode);
- formatChild(childNode);
-
- return childNode;
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAttributeAndRequired.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAttributeAndRequired.java
deleted file mode 100644
index 155577b58f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateAttributeAndRequired.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-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.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFactory;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-
-/*
- * Class which creates an Attribute and necessary Elements required before
- * an Attribute can be added. For example, if we wish to add an Attribute
- * to a GlobalElement without a ComplexType, a ComplexType will be created.
- */
-public class CreateAttributeAndRequired extends Action {
- String elementTag;
- String label;
- List attributes;
- XSDSchema xsdSchema;
- ISelectionProvider selectionProvider;
- Object parent;
-
- public CreateAttributeAndRequired(String elementTag, String label, List attributes, XSDSchema xsdSchema, ISelectionProvider selProvider, Object parent) {
- super(label);
-
- this.elementTag = elementTag;
- this.label = label;
- this.attributes = attributes;
- this.xsdSchema = xsdSchema;
- this.selectionProvider = selProvider;
- this.parent = parent;
- }
-
- public void run() {
- if (parent instanceof XSDElementDeclaration) {
- XSDElementDeclaration ed = (XSDElementDeclaration) parent;
- beginRecording(ed.getElement());
- ed.setTypeDefinition(null);
- XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
- ed.setAnonymousTypeDefinition(td);
-
- CreateElementAction action = new CreateElementAction(label);
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(td.getElement());
- action.setRelativeNode(null);
- action.setXSDSchema(xsdSchema);
- action.setSelectionProvider(selectionProvider);
- action.run();
-
- formatChild(td.getElement());
- if (td.getAttributeContents().size() > 0)
- {
- selectObject(td.getAttributeContents().get(0));
- }
- endRecording(ed.getElement());
- }
- }
-
- protected void beginRecording(Element element) {
- ((DocumentImpl) element.getOwnerDocument()).getModel().beginRecording(this, getText());
- }
-
- protected void endRecording(Element element) {
- ((DocumentImpl) element.getOwnerDocument()).getModel().endRecording(this);
- }
-
- public void selectObject(Object object) {
- if (selectionProvider != null)
- {
- selectionProvider.setSelection(new StructuredSelection(object));
- }
- }
-
- 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();
- }
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java
deleted file mode 100644
index 0dacfb617a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-import java.util.List;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.ui.parts.AbstractEditPartViewer;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-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.graph.editparts.ComplexTypeDefinitionEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ElementDeclarationEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ModelGroupDefinitionEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-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.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-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.Text;
-
-public class CreateElementAction extends Action
-{
- protected String description;
- protected Element parentNode;
-
- protected ISelectionProvider selectionProvider;
- protected XSDSchema xsdSchema;
-
- protected Object sourceContext;
-
- /**
- * Constructor for CreateElementAction.
- */
- public CreateElementAction()
- {
- super();
- }
- /**
- * Constructor for CreateElementAction.
- * @param text
- */
- public CreateElementAction(String text)
- {
- super(text);
- }
- /**
- * Constructor for CreateElementAction.
- * @param text
- * @param image
- */
- public CreateElementAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public void setXSDSchema(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- public void setSelectionProvider(ISelectionProvider selectionProvider)
- {
- this.selectionProvider = selectionProvider;
- }
-
- public void setSourceContext(Object sourceContext)
- {
- this.sourceContext = sourceContext;
- }
-
- /**
- * Gets the parentNode.
- * @return Returns a Element
- */
- public Element getParentNode()
- {
- return parentNode;
- }
-
- /**
- * Sets the parentNode.
- * @param parentNode The parentNode to set
- */
- public void setParentNode(Element parentNode)
- {
- this.parentNode = parentNode;
- }
-
- boolean isGlobal = false;
-
- public void setIsGlobal(boolean isGlobal)
- {
- this.isGlobal = isGlobal;
- }
-
- public boolean getIsGlobal()
- {
- return isGlobal;
- }
-
- protected Node relativeNode;
- protected String elementTag;
- public void setElementTag(String elementTag)
- {
- this.elementTag = elementTag;
- }
-
- public DocumentImpl getDocument()
- {
- return (DocumentImpl) getParentNode().getOwnerDocument();
- }
-
- public void beginRecording(String description)
- {
- getDocument().getModel().beginRecording(this, description);
- }
-
- public void endRecording()
- {
- DocumentImpl doc = (DocumentImpl) getDocument();
-
- doc.getModel().endRecording(this);
- }
-
- public Element createAndAddNewChildElement()
- {
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- Element childNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + elementTag);
- if (getAttributes() != null)
- {
- List attributes = getAttributes();
- for (int i = 0; i < attributes.size(); i++)
- {
- DOMAttribute attr = (DOMAttribute) attributes.get(i);
- childNode.setAttribute(attr.getName(), attr.getValue());
- }
- }
- if (getRelativeNode() == null)
- {
- parentNode.appendChild(childNode);
- }
- else
- {
- ((Element)parentNode).insertBefore(childNode,getRelativeNode());
- }
-
- if (isGlobal && getRelativeNode() == null)
- {
- Text textNode = getDocument().createTextNode("\n\n");
- parentNode.appendChild(textNode);
- }
- else if (isGlobal && getRelativeNode() != null)
- {
- Text textNode = getDocument().createTextNode("\n\n");
- parentNode.insertBefore(textNode, getRelativeNode());
- }
-
- formatChild(childNode);
-
- return childNode;
- }
-
- 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();
- }
- }
- }
- /*
- * @see IAction#run()
- */
- public void run()
- {
- beginRecording(getDescription());
- final Element child = createAndAddNewChildElement();
- endRecording();
-
- if (selectionProvider != null)
- {
- final XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(child);
-// selectionProvider.setSelection(new StructuredSelection(comp));
-
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- if (comp instanceof XSDAttributeDeclaration)
- {
- if (((XSDAttributeDeclaration)comp).getContainer() instanceof XSDAttributeUse)
- {
- if (comp.getContainer().getContainer() instanceof XSDAttributeGroupDefinition)
- {
- selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
- }
- else if (comp.getContainer().getContainer() instanceof XSDComplexTypeDefinition)
- {
- if (XSDDOMHelper.inputEquals((Element)child, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- if (comp instanceof XSDNamedComponent)
- {
- if (sourceContext instanceof AbstractEditPartViewer)
- {
- AbstractEditPartViewer viewer = (AbstractEditPartViewer)sourceContext;
-
- Object obj = viewer.getSelectedEditParts().get(0);
-
- if (obj instanceof GraphicalEditPart)
- {
- if (obj instanceof ElementDeclarationEditPart)
- {
- XSDElementDeclaration elem = ((ElementDeclarationEditPart)obj).getXSDElementDeclaration();
- if (!elem.isElementDeclarationReference())
- {
- ((ElementDeclarationEditPart)obj).doEditName();
- }
- }
- else if (obj instanceof ModelGroupDefinitionEditPart)
- {
- XSDModelGroupDefinition group = ((ModelGroupDefinitionEditPart)obj).getXSDModelGroupDefinition();
- if (!group.isModelGroupDefinitionReference())
- {
- ((ModelGroupDefinitionEditPart)obj).doEditName();
- }
- }
- else if (obj instanceof ComplexTypeDefinitionEditPart)
- {
- XSDComplexTypeDefinition ct = ((ComplexTypeDefinitionEditPart)obj).getXSDComplexTypeDefinition();
- if (ct.getName() != null)
- {
- ((ComplexTypeDefinitionEditPart)obj).doEditName();
- }
- }
- else if (obj instanceof TopLevelComponentEditPart)
- {
- ((TopLevelComponentEditPart)obj).doEditName();
- }
- }
-
- }
- }
- }
- };
- Display.getDefault().timerExec(50,runnable);
- }
- }
-
- /**
- * Gets the relativeNode.
- * @return Returns a Element
- */
- public Node getRelativeNode()
- {
- return relativeNode;
- }
-
- /**
- * Sets the relativeNode.
- * @param relativeNode The relativeNode to set
- */
- public void setRelativeNode(Node relativeNode)
- {
- this.relativeNode = relativeNode;
- }
-
- /**
- * Gets the description.
- * @return Returns a String
- */
- public String getDescription()
- {
- if (description == null)
- {
- return getText();
- }
- return description;
- }
-
- /**
- * Sets the description.
- * @param description The description to set
- */
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- protected List attributes;
- /**
- * Gets the nameAttribute.
- * @return Returns a String
- */
- public List getAttributes()
- {
- return attributes;
- }
-
- /**
- * Sets the attributes.
- * @param attributes The attributes to set
- */
- public void setAttributes(List attributes)
- {
- this.attributes = attributes;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateGroupAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateGroupAction.java
deleted file mode 100644
index f9eadae541..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateGroupAction.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class CreateGroupAction extends CreateElementAction
-{
- XSDSchema xsdSchema;
-
- /**
- * Constructor for CreateGroupAction.
- */
- public CreateGroupAction()
- {
- super();
- }
- /**
- * Constructor for CreateGroupAction.
- * @param text
- */
- public CreateGroupAction(String text)
- {
- super(text);
- }
- /**
- * Constructor for CreateGroupAction.
- * @param text
- * @param XSDSchema
- */
- public CreateGroupAction(String text, XSDSchema xsdSchema)
- {
- super(text);
- this.xsdSchema = xsdSchema;
- }
- /**
- * Constructor for CreateGroupAction.
- * @param text
- * @param image
- */
- public CreateGroupAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent(parentNode);
- Element childNode = super.createAndAddNewChildElement();
-
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- Element contentModelNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SEQUENCE_ELEMENT_TAG);
- childNode.appendChild(contentModelNode);
-
- formatChild(childNode);
-
- xsdComp.setElement(parentNode);
-
- return childNode;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateIdentityConstraintsAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateIdentityConstraintsAction.java
deleted file mode 100644
index ca933f334e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateIdentityConstraintsAction.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class CreateIdentityConstraintsAction extends CreateElementAction
-{
- XSDSchema xsdSchema;
-
- /**
- * Constructor for CreateIdentityConstraintsAction.
- */
- public CreateIdentityConstraintsAction()
- {
- super();
- }
- /**
- * Constructor for CreateIdentityConstraintsAction.
- * @param text
- */
- public CreateIdentityConstraintsAction(String text)
- {
- super(text);
- }
- /**
- * Constructor for CreateIdentityConstraintsAction.
- * @param text
- * @param XSDSchema
- */
- public CreateIdentityConstraintsAction(String text, XSDSchema xsdSchema)
- {
- super(text);
- this.xsdSchema = xsdSchema;
- }
- /**
- * Constructor for CreateIdentityConstraintsAction.
- * @param text
- * @param image
- */
- public CreateIdentityConstraintsAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- Element childNode = super.createAndAddNewChildElement();
-
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- Element selectorNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SELECTOR_ELEMENT_TAG);
-
- DOMAttribute attr = new DOMAttribute(XSDConstants.XPATH_ATTRIBUTE, "");
- selectorNode.setAttribute(attr.getName(), attr.getValue());
-
- childNode.appendChild(selectorNode);
-
- return childNode;
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalComplexTypeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalComplexTypeAction.java
deleted file mode 100644
index e8b0cd027a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalComplexTypeAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class CreateLocalComplexTypeAction extends CreateElementAction
-{
- /**
- * Constructor for CreateLocalComplexTypeAction.
- */
- public CreateLocalComplexTypeAction()
- {
- super();
- }
- /**
- * Constructor for CreateLocalComplexTypeAction.
- * @param text
- */
- public CreateLocalComplexTypeAction(String text)
- {
- super(text);
- }
- /**
- * Constructor for CreateLocalComplexTypeAction.
- * @param text
- * @param image
- */
- public CreateLocalComplexTypeAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent(parentNode);
-
- Element childNode = super.createAndAddNewChildElement();
-
- if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- parentNode.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- }
-
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- childNode.appendChild(getDocument().createElement(prefix + XSDConstants.SEQUENCE_ELEMENT_TAG));
-
- formatChild(childNode);
-
- xsdComp.setElement(parentNode);
-
- return childNode;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalSimpleTypeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalSimpleTypeAction.java
deleted file mode 100644
index d2e1065c41..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateLocalSimpleTypeAction.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class CreateLocalSimpleTypeAction extends CreateElementAction
-{
- XSDSchema xsdSchema;
-
- /**
- * Constructor for CreateLocalSimpleTypeAction.
- */
- public CreateLocalSimpleTypeAction()
- {
- super();
- }
- /**
- * Constructor for CreateLocalSimpleTypeAction.
- * @param text
- */
- public CreateLocalSimpleTypeAction(String text)
- {
- super(text);
- }
-
- /**
- * Constructor for CreateLocalSimpleTypeAction.
- * @param text
- * @param image
- */
- public CreateLocalSimpleTypeAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- Element childNode = super.createAndAddNewChildElement();
-
- if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.UNION_ELEMENT_TAG, false))
- {
-// parentNode.removeAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE);
- }
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.LIST_ELEMENT_TAG, false))
- {
- parentNode.removeAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE);
- }
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- parentNode.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- }
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.RESTRICTION_ELEMENT_TAG, false))
- {
- Node parent = parentNode.getParentNode();
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- parentNode.removeAttribute(XSDConstants.BASE_ATTRIBUTE);
- }
- }
- else if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- parentNode.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- }
-
- formatChild(childNode);
-
- return childNode;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleContentAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleContentAction.java
deleted file mode 100644
index d9d9eb7c44..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleContentAction.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-/**
- * @version 1.0
- * @author
- */
-public class CreateSimpleContentAction extends CreateElementAction
-{
- XSDSchema xsdSchema;
- //IDocument document;
-
- /**
- * Constructor for CreateSimpleContentAction.
- */
- public CreateSimpleContentAction()
- {
- super();
- }
- /**
- * Constructor for CreateSimpleContentAction.
- * @param text
- */
- public CreateSimpleContentAction(String text)
- {
- super(text);
- }
- /**
- * Constructor for CreateSimpleContentAction.
- * @param text
- * @param XSDSchema
- */
- public CreateSimpleContentAction(String text, XSDSchema xsdSchema)
- {
- super(text);
- this.xsdSchema = xsdSchema;
- }
- /**
- * Constructor for CreateSimpleContentAction.
- * @param text
- * @param image
- */
- public CreateSimpleContentAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- Element childNode = super.createAndAddNewChildElement();
-
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- Element derivedByNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + "restriction");
- childNode.appendChild(derivedByNode);
- Element sequence = null;
-
- if (XSDDOMHelper.inputEquals(childNode, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- sequence = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + "sequence");
- derivedByNode.appendChild(sequence);
- }
-
- // now add the required base attribute for the derived by node
- TypesHelper typesHelper = new TypesHelper(xsdSchema);
- List listOfCT = typesHelper.getUserComplexTypeNamesList();
- String firstType = "";
- if (listOfCT.size() > 0)
- {
- firstType = (String)(listOfCT).get(0);
- }
- DOMAttribute attr = new DOMAttribute(XSDConstants.BASE_ATTRIBUTE, firstType);
- derivedByNode.setAttribute(attr.getName(), attr.getValue());
-
- formatChild(derivedByNode);
- if (sequence != null)
- {
- formatChild(sequence);
- formatChild(derivedByNode);
- }
- formatChild(childNode);
-
-
- return childNode;
- }
-
- /*
- * @see IAction#run()
- */
- public void run()
- {
- beginRecording(getDescription());
-
- createAndAddNewChildElement();
- endRecording();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleTypeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleTypeAction.java
deleted file mode 100644
index 5e5c29cce1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/CreateSimpleTypeAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-public class CreateSimpleTypeAction extends CreateElementAction
-{
- /**
- *
- */
- public CreateSimpleTypeAction()
- {
- super();
- }
-
- /**
- * @param text
- */
- public CreateSimpleTypeAction(String text)
- {
- super(text);
- }
-
- public CreateSimpleTypeAction(String text, XSDSchema xsdSchema)
- {
- super(text);
- this.xsdSchema = xsdSchema;
- }
-
- /**
- * @param text
- * @param image
- */
- public CreateSimpleTypeAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public Element createAndAddNewChildElement()
- {
- XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent(parentNode);
- Element childNode = super.createAndAddNewChildElement();
-
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- Element contentModelNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.RESTRICTION_ELEMENT_TAG);
- contentModelNode.setAttribute(XSDConstants.BASE_ATTRIBUTE, prefix + "string");
- childNode.appendChild(contentModelNode);
-
- formatChild(childNode);
-
- xsdComp.setElement(parentNode);
-
- return childNode;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java
deleted file mode 100644
index 5580b40fc4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-// TODO Remove this
-
-/**
- * @version 1.0
- * @author
- */
-public class DOMAttribute
-{
- /**
- * Constructor for DOMAttribute.
- */
- public DOMAttribute()
- {
- super();
- }
-
- /**
- * Constructor for DOMAttribute.
- */
- public DOMAttribute(String name, String value)
- {
- super();
- this.name = name;
- this.value = value;
- }
-
- protected String name, value;
- /**
- * Gets the value.
- * @return Returns a String
- */
- public String getValue()
- {
- return value;
- }
-
- /**
- * Sets the value.
- * @param value The value to set
- */
- public void setValue(String value)
- {
- this.value = value;
- }
-
- /**
- * Gets the name.
- * @return Returns a String
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Sets the name.
- * @param name The name to set
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DeleteAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DeleteAction.java
deleted file mode 100644
index d2e4c235f3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/DeleteAction.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.actions.SelectionListenerAction;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.BaseGlobalCleanup;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.GlobalAttributeCleanup;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.GlobalAttributeGroupCleanup;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.GlobalElementCleanup;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.GlobalGroupCleanup;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.GlobalSimpleOrComplexTypeCleanup;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.XSDExternalFileCleanup;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Node;
-
-
-public class DeleteAction extends SelectionListenerAction
-{
- protected IEditorPart editor;
- protected XSDSchema xsdSchema;
- protected ISelectionProvider selectionProvider;
- protected XSDConcreteComponent parentXSDComponent;
-
- /**
- * Constructor for DeleteAction.
- * @param text
- */
- public DeleteAction(String text, IEditorPart editor, XSDSchema xsdSchema)
- {
- super(text);
- this.editor = editor;
- this.xsdSchema = xsdSchema;
- }
-
- public void setSelectionProvider(ISelectionProvider selectionProvider)
- {
- this.selectionProvider = selectionProvider;
- }
-
- public IEditorPart getEditor()
- {
- return editor;
- }
-
- public XSDSchema getSchema()
- {
- return xsdSchema;
- }
-
- public void setXSDSchema(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- /*
- * @see IAction#run()
- */
- public void run()
- {
- IStructuredSelection selection = getStructuredSelection();
-
- if (selection.isEmpty())
- {
- return;
- }
-
- Iterator iter = selection.iterator();
- DocumentImpl doc = null;
- while (iter.hasNext())
- {
- Object obj = iter.next();
- Node node = null;
- if (obj instanceof Node)
- {
- node = (Node)obj;
- }
- else if (obj instanceof XSDConcreteComponent)
- {
- xsdSchema = ((XSDConcreteComponent)obj).getSchema();
-
- node = ((XSDConcreteComponent)obj).getElement();
- if (node instanceof IDOMNode)
- {
- parentXSDComponent = ((XSDConcreteComponent)obj).getContainer();
-
- if (parentXSDComponent instanceof XSDParticle)
- {
- // need to get the modelGroup
- parentXSDComponent = parentXSDComponent.getContainer();
- }
- }
-
- }
- if (!XSDDOMHelper.inputEquals(node, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- if (node instanceof IDOMNode)
- {
- if (doc == null)
- {
- doc = (DocumentImpl) node.getOwnerDocument();
- doc.getModel().beginRecording(this, XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE_NODES"));
- }
-
- boolean refresh = cleanupReferences(node);
- if (node != null)
- {
- XSDDOMHelper.removeNodeAndWhitespace(node);
- }
-
- // Workaround to reset included elements in XSD model
- if (refresh)
- {
- // getEditor().reparseSchema();
- // getEditor().getGraphViewer().setSchema(getEditor().getXSDSchema());
- }
- }
- }
- }
-
- if (parentXSDComponent != null && selectionProvider != null)
- {
- selectionProvider.setSelection(new StructuredSelection(parentXSDComponent));
- }
-
- if (doc != null)
- {
- doc.getModel().endRecording(this);
- }
- }
-
- protected boolean cleanupReferences(Node deletedNode)
- {
- boolean refresh = false;
- XSDConcreteComponent comp = getSchema().getCorrespondingComponent(deletedNode);
-
- if (comp instanceof XSDInclude ||
- comp instanceof XSDImport ||
- comp instanceof XSDRedefine)
- {
- XSDSchema referencedSchema = null;
- if (comp instanceof XSDInclude)
- {
- referencedSchema = ((XSDInclude)comp).getIncorporatedSchema();
- refresh = true;
- }
- else if (comp instanceof XSDRedefine)
- {
- referencedSchema = ((XSDRedefine)comp).getIncorporatedSchema();
- refresh = true;
- }
- else if (comp instanceof XSDImport)
- {
- referencedSchema = ((XSDImport)comp).getResolvedSchema();
- refresh = true;
- }
-
- if (referencedSchema != null)
- {
- XSDExternalFileCleanup cleanHelper = new XSDExternalFileCleanup(referencedSchema);
- cleanHelper.visitSchema(getSchema());
- // populate messages
-// TODO getEditor().createTasksInTaskList(cleanHelper.getMessages());
- }
- if (comp instanceof XSDImport)
- {
- TypesHelper typesHelper = new TypesHelper(getSchema());
- typesHelper.updateMapAfterDelete((XSDImport)comp);
- }
- }
- else if (getSchema().equals(comp.getContainer()))
- {
- BaseGlobalCleanup cleanHelper = null;
- // Only need to clean up references if the component being deleted is global scoped
- if (comp instanceof XSDElementDeclaration)
- {
- cleanHelper = new GlobalElementCleanup(comp);
- }
- else if (comp instanceof XSDModelGroupDefinition)
- {
- cleanHelper = new GlobalGroupCleanup(comp);
- }
- else if (comp instanceof XSDTypeDefinition)
- {
- cleanHelper = new GlobalSimpleOrComplexTypeCleanup(comp);
- }
- else if (comp instanceof XSDAttributeDeclaration)
- {
- cleanHelper = new GlobalAttributeCleanup(comp);
- }
- else if (comp instanceof XSDAttributeGroupDefinition)
- {
- cleanHelper = new GlobalAttributeGroupCleanup(comp);
- }
-
-
- if (cleanHelper != null)
- {
- cleanHelper.visitSchema(getSchema());
- }
- }
- return refresh;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/GraphRenameAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/GraphRenameAction.java
deleted file mode 100644
index cea3fd9e35..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/GraphRenameAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2005 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - Initial API and implementation
-*******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.actions;
-
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.jface.action.Action;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.commands.RenameCommand;
-import org.eclipse.xsd.XSDNamedComponent;
-
-
-public class GraphRenameAction extends Action
-{
- protected RenameCommand command;
-
- public GraphRenameAction(XSDNamedComponent namedComponent, GraphicalEditPart editPart)
- {
- command = new RenameCommand(namedComponent, editPart);
- setText(XSDEditorPlugin.getXSDString("_UI_LABEL_RENAME"));
- }
-
- public void run()
- {
- command.run();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ISchemaEditorActionConstants.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ISchemaEditorActionConstants.java
deleted file mode 100644
index 39836ff077..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ISchemaEditorActionConstants.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-public interface ISchemaEditorActionConstants
-{
- public static final String RETARGET_VALIDATE_SCHEMA_ACTION_ID = "retargetValidateSchemaAction"; //$NON-NLS-1$
- public static final String RETARGET_RELOAD_DEPENDENCIES_ACTION_ID = "retargetReloadDependenciesAction"; //$NON-NLS-1$
- public static final String RETARGET_GENERATE_JAVA_ACTION_ID = "retargetGenerateJavaAction"; //$NON-NLS-1$
- public static final String RETARGET_GENERATE_DTD_ACTION_ID = "retargetGenerateDtdAction"; //$NON-NLS-1$
- public static final String RETARGET_GENERATE_XML_ACTION_ID = "retargetGenerateXMLAction"; //$NON-NLS-1$
- public static final String RETARGET_RENAME_ELEMENT_ACTION_ID = "RenameElement"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MakeAnonymousGlobal.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MakeAnonymousGlobal.java
deleted file mode 100644
index 9a9638a03f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MakeAnonymousGlobal.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-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 MakeAnonymousGlobal extends CreateElementAction
-{
- XSDSchema xsdSchema;
- Element type;
-
- public MakeAnonymousGlobal(String text, Element type, XSDSchema xsdSchema)
- {
- super(text);
- this.xsdSchema = xsdSchema;
- this.type = type;
- isGlobal = true;
- }
-
- public Element createAndAddNewChildElement()
- {
- // create the new global type
- Element childNode = super.createAndAddNewChildElement();
- // add the anonymous type's children to the new global type
- if (type.hasChildNodes())
- {
- NodeList nodes = type.getChildNodes();
- // use clones so we don't have a refresh problem
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- childNode.appendChild(node.cloneNode(true));
- }
- }
-
- // clean up the element whose type was anonymous
- // and set its type attribute to the new global type
- TypesHelper helper = new TypesHelper(xsdSchema);
- String prefix = helper.getPrefix(xsdSchema.getTargetNamespace(), true);
- helper = null;
-
- Element parentElementOfAnonymousType = (Element)type.getParentNode();
-
- parentElementOfAnonymousType.removeChild(type);
- parentElementOfAnonymousType.setAttribute(XSDConstants.TYPE_ATTRIBUTE, prefix + childNode.getAttribute(XSDConstants.NAME_ATTRIBUTE));
-
- formatChild(childNode);
-
- return childNode;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ModelMessage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ModelMessage.java
deleted file mode 100644
index aa30618d02..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ModelMessage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.w3c.dom.Node;
-
-public class ModelMessage
-{
- protected String message;
- protected Node node;
-
- public ModelMessage(String message, Node node)
- {
- this.message = message;
- this.node = node;
- }
-
- public String getMessage()
- {
- return message;
- }
-
- public Node getNode()
- {
- return node;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MoveAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MoveAction.java
deleted file mode 100644
index e3606c99ae..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/MoveAction.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-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.XSDEditorPlugin;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-public class MoveAction extends Action
-{
- protected List selectedNodes;
- protected Node parentNode;
- protected Node refChild;
-
- /**
- * Constructor for DeleteAction.
- * @param text
- */
- public MoveAction(Node parentNode, List selectedNodes, Node refChild)
- {
- this.parentNode = parentNode;
- this.selectedNodes = selectedNodes;
- this.refChild = refChild;
- }
-
- public MoveAction(XSDConcreteComponent parentComponent, List selectedComponents, XSDConcreteComponent refChildComponent)
- {
- selectedNodes = new ArrayList(selectedComponents.size());
- for (Iterator i = selectedComponents.iterator(); i.hasNext(); )
- {
- XSDConcreteComponent concreteComponent = (XSDConcreteComponent)i.next();
- selectedNodes.add(concreteComponent.getElement());
- }
- parentNode = parentComponent.getElement();
- refChild = refChildComponent != null ? refChildComponent.getElement() : null;
- }
-
- public boolean canMove()
- {
- // TODO... there are likely more restriction to consider here
- boolean result = true;
- for (Iterator i = selectedNodes.iterator(); i.hasNext(); )
- {
- Node child = (Node)i.next();
- if (isDecendantOrSelf(child, parentNode))
- {
- result = false;
- break;
- }
- }
- return result;
- }
-
- protected boolean isDecendantOrSelf(Node potentialParent, Node node)
- {
- boolean result = false;
- while (node != null)
- {
- if (node == potentialParent)
- {
- result = true;
- break;
- }
- node = node.getParentNode();
- }
- return result;
- }
-
-
- protected void beginRecording()
- {
- IDOMModel model = getModel();
- if (model != null)
- {
- model.beginRecording(this, XSDEditorPlugin.getXSDString("_UI_LABEL_MOVE"));
- }
- }
-
- protected void endRecording()
- {
- IDOMModel model = getModel();
- if (model != null)
- {
- model.endRecording(this);
- }
- }
-
- protected IDOMModel getModel()
- {
- IDOMModel model = null;
- if (parentNode instanceof IDOMNode)
- {
- model = ((IDOMNode)parentNode).getModel();
- }
- return model;
- }
-
-
-
- /*
- * @see IAction#run()
- */
- public void run()
- {
- beginRecording();
- try
- {
- for (Iterator i = selectedNodes.iterator(); i.hasNext(); )
- {
- Node child = (Node)i.next();
- repositionBefore(parentNode, child, refChild);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- endRecording();
- }
-
-
- public void repositionBefore(Node parent, Node child, Node refChild)
- {
- // TODO... when the refChild (inserting as the last element) we need to
- // special case the way we preserve indentation
- Node oldParent = child.getParentNode();
- if (oldParent != null && refChild != child)
- {
- // consider any indentation text node that preceeds the child
- //
- Node textNode = isWhitespaceTextNode(child.getPreviousSibling()) ? child.getPreviousSibling() : null;
-
- // remove the child
- //
- oldParent.removeChild(child);
-
- // Instead of inserting the child immediatlely infront of the refChild, we first check to see if there
- // is an indentation text node preceeding the refChild. If we find such a node, we perform the insertion
- // so that the child is inserted before the indentation text node.
- Node adjustedRefChild = refChild;
- if (refChild != null && isWhitespaceTextNode(refChild.getPreviousSibling()))
- {
- adjustedRefChild = refChild.getPreviousSibling();
- }
-
- // reposition the child and any indentation text node
- //
- parent.insertBefore(child, adjustedRefChild);
- if (textNode != null)
- {
- oldParent.removeChild(textNode);
- parent.insertBefore(textNode, child);
- }
- }
- }
-
-
- protected static boolean isWhitespaceTextNode(Node node)
- {
- boolean result = false;
- if (node != null && node.getNodeType() == Node.TEXT_NODE)
- {
- String data = ((Text)node).getData();
- result = (data == null || data.trim().length() == 0);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/OpenSchemaAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/OpenSchemaAction.java
deleted file mode 100644
index ce9216f10d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/OpenSchemaAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xsd.ui.internal.util.OpenOnSelectionHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.impl.XSDImportImpl;
-
-
-public class OpenSchemaAction extends Action
-{
- XSDConcreteComponent component;
- public OpenSchemaAction(String label, XSDConcreteComponent component)
- {
- super(label);
- this.component = component;
- }
-
- public void run()
- {
- if (component != null)
- {
- revealObject();
- }
- }
-
- boolean lastResult = false;
- protected boolean revealObject()
- {
- String schemaLocation = "";
- XSDSchemaDirective dir;
- if (component instanceof XSDSchemaDirective)
- {
- dir = (XSDSchemaDirective)component;
- // 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);
- }
- }
- }
- return lastResult;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ReloadDependenciesAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ReloadDependenciesAction.java
deleted file mode 100644
index 73e239f2f1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/ReloadDependenciesAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-
-
-public class ReloadDependenciesAction extends Action
-{
- /**
- * Constructor for ReloadDependenciesAction.
- */
- public ReloadDependenciesAction()
- {
- super();
- }
-
- /**
- * Constructor for ReloadDependenciesAction.
- * @param text
- */
- public ReloadDependenciesAction(String text)
- {
- super(text);
- }
-
- /**
- * Constructor for ReloadDependenciesAction.
- * @param text
- * @param image
- */
- public ReloadDependenciesAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public void setEditor(XSDEditor editor)
- {
- this.editor = editor;
- }
-
- protected XSDEditor editor;
-
- public void run()
- {
- editor.reparseSchema();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetBaseTypeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetBaseTypeAction.java
deleted file mode 100644
index 31d9753d26..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetBaseTypeAction.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-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.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.wst.xsd.ui.internal.widgets.SetBaseTypeDialog;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public class SetBaseTypeAction extends Action
-{
- XSDSchema xsdSchema;
- Element element;
- String type = "";
- String derivedByString = "";
- XSDDOMHelper domHelper;
-
- /**
- * Constructor for SetBaseTypeAction.
- */
- public SetBaseTypeAction()
- {
- super();
- domHelper = new XSDDOMHelper();
- }
- /**
- * Constructor for SetBaseTypeAction.
- * @param arg0
- */
- public SetBaseTypeAction(String arg0)
- {
- super(arg0);
- domHelper = new XSDDOMHelper();
- }
- /**
- * Constructor for SetBaseTypeAction.
- * @param arg0
- * @param arg1
- */
- public SetBaseTypeAction(String arg0, ImageDescriptor arg1)
- {
- super(arg0, arg1);
- domHelper = new XSDDOMHelper();
- }
- /**
- * Constructor for SetBaseTypeAction.
- * @param arg0
- * @param arg1
- */
- public SetBaseTypeAction(String arg0, int arg1)
- {
- super(arg0, arg1);
- domHelper = new XSDDOMHelper();
- }
-
-
- public void setXSDSchema(XSDSchema schema)
- {
- this.xsdSchema = schema;
- }
-
- public void setComplexTypeElement(Element element)
- {
- this.element = element;
- }
-
- public void setType(String type)
- {
- this.type = type;
- }
-
- public void setDerivedBy(String derivedByString)
- {
- this.derivedByString = derivedByString;
- }
-
- public void run()
- {
- Display display = Display.getCurrent();
- // if it is null, get the default one
- display = display == null ? Display.getDefault() : display;
- Shell parentShell = display.getActiveShell();
-
- SetBaseTypeDialog dialog = new SetBaseTypeDialog(parentShell, xsdSchema, element);
- dialog.setBlockOnOpen(true);
-
- Element contentModelElement = domHelper.getContentModelFromParent(element);
- if (contentModelElement != null)
- {
- // to set the current values to show in the dialog
- if (XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- Element derivedByElement = domHelper.getDerivedByElementFromComplexType(element);
- if (derivedByElement != null)
- {
- String currentBaseType = derivedByElement.getAttribute(XSDConstants.BASE_ATTRIBUTE);
- dialog.setCurrentBaseType(currentBaseType);
- dialog.setCurrentDerivedBy(derivedByElement.getLocalName());
- }
- else
- {
- dialog.setCurrentBaseType("");
- dialog.setCurrentDerivedBy("");
- }
- }
- }
-
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- type = dialog.getBaseType();
- derivedByString = dialog.getDerivedBy();
- performAction();
- }
- }
-
- XSDTypeDefinition newTypeDefinition = null;
- public XSDTypeDefinition getXSDTypeDefinition()
- {
- return newTypeDefinition;
- }
-
- public void performAction()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
-
- XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent(element);
-
- Element contentModelElement = domHelper.getContentModelFromParent(element);
- boolean contentModelExists = true;
- if (contentModelElement == null)
- {
- contentModelExists = false;
- }
-
-// get XSD component of the new type chosen
- newTypeDefinition = null;
- for (Iterator i = xsdSchema.getTypeDefinitions().iterator(); i.hasNext(); )
- {
- XSDTypeDefinition typeDef = (XSDTypeDefinition)i.next();
- if (typeDef.getQName().equals(type))
- {
- newTypeDefinition = typeDef;
- break;
- }
- }
-
- boolean needsComplexContent = false;
- boolean needsSimpleContent = false;
-
- if (helper.getBuiltInTypeNamesList().contains(type) ||
- helper.getUserSimpleTypeNamesList().contains(type))
-// if (newTypeDefinition instanceof XSDSimpleTypeDefinition)
- {
- needsSimpleContent = true;
- }
- else if (newTypeDefinition instanceof XSDComplexTypeDefinition)
- {
- needsComplexContent = true;
-// XSDComplexTypeDefinition newCTObj = (XSDComplexTypeDefinition)newTypeDefinition;
-// XSDContentTypeCategory category = newCTObj.getContentTypeCategory();
- }
-
- beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_SET_BASE_TYPE"), element);
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
-
- DOMAttribute attr = new DOMAttribute(XSDConstants.BASE_ATTRIBUTE, type);
- if (!contentModelExists) // if no content model exists, then add the new nodes
- {
- if (helper.getBuiltInTypeNamesList().contains(type) ||
- helper.getUserSimpleTypeNamesList().contains(type))
- {
- updateModelAndDerivedByKind(prefix + XSDConstants.SIMPLECONTENT_ELEMENT_TAG, prefix + XSDConstants.EXTENSION_ELEMENT_TAG, attr);
- }
- else if (helper.getUserComplexTypeNamesList().contains(type))
- {
- if (derivedByString.equals("")) // default
- {
- derivedByString = XSDConstants.EXTENSION_ELEMENT_TAG;
- }
- Element derivedByElement = updateModelAndDerivedByKind(prefix + XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, prefix + derivedByString, attr);
- Element newModelGroupElement = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SEQUENCE_ELEMENT_TAG);
- derivedByElement.appendChild(newModelGroupElement);
- formatChild(derivedByElement);
- }
- }
- else // else there is a content model
- {
- if (type.equals("")) // the chosen type is blank, ie. there is no base type
- {
- Element derivedByElement = domHelper.getDerivedByElementFromComplexType(element);
- Element sourceContentModelElement = domHelper.getContentModelFromParent(derivedByElement);
- // Retain the content model if there is one from the complex or simple content derive by element
- if (XSDDOMHelper.inputEquals(sourceContentModelElement, XSDConstants.SEQUENCE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(sourceContentModelElement, XSDConstants.CHOICE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(sourceContentModelElement, XSDConstants.ALL_ELEMENT_TAG, false))
- {
- Element newNode = domHelper.cloneElement(element, sourceContentModelElement);
- element.replaceChild(newNode, contentModelElement);
- formatChild(element);
- }
- else // otherwise just add the nodes
- {
- XSDDOMHelper.removeNodeAndWhitespace(contentModelElement);
- Element newSequenceElement = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SEQUENCE_ELEMENT_TAG);
- element.appendChild(newSequenceElement);
- formatChild(newSequenceElement);
- }
- }
- else // a base type is specified
- {
- Element sequenceChoiceOrAllElement = null; // copy the model to reposition it off of the new derived by element
- if (XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.SEQUENCE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.CHOICE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.ALL_ELEMENT_TAG, false))
- {
- sequenceChoiceOrAllElement = domHelper.cloneElement(element, contentModelElement);
- }
-
- if (needsComplexContent)
- {
- if (!(XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)))
- {
- domHelper.changeContentModel(element, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, sequenceChoiceOrAllElement);
- contentModelElement = domHelper.getContentModelFromParent(element);
- }
- }
- if (needsSimpleContent)
- {
- if (!(XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false)))
- {
- // we don't want to append the element content to a simple content
- sequenceChoiceOrAllElement = null;
- domHelper.changeContentModel(element, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, sequenceChoiceOrAllElement);
- contentModelElement = domHelper.getContentModelFromParent(element);
- }
- }
-
- Element derivedByElement = domHelper.getDerivedByElementFromComplexType(element);
- if (derivedByElement == null)
- {
- if (derivedByString == null || (derivedByString != null && derivedByString.equals("")))
- {
- derivedByString = XSDConstants.EXTENSION_ELEMENT_TAG; // since there is no derivedByElement
- }
- derivedByElement = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, derivedByString);
- contentModelElement.appendChild(derivedByElement);
- formatChild(contentModelElement);
- if (sequenceChoiceOrAllElement != null)
- {
- derivedByElement.appendChild(sequenceChoiceOrAllElement);
- formatChild(derivedByElement);
- }
- }
- else
- {
- if (helper.getBuiltInTypeNamesList().contains(type) ||
- helper.getUserSimpleTypeNamesList().contains(type))
- {
- derivedByString = XSDConstants.EXTENSION_ELEMENT_TAG;
- Element aContentModelElement = domHelper.getContentModelFromParent(derivedByElement);
- if (aContentModelElement != null)
- {
- XSDDOMHelper.removeNodeAndWhitespace(aContentModelElement);
- }
- }
- domHelper.changeDerivedByType(contentModelElement, derivedByString, type);
- }
- derivedByElement.setAttribute(attr.getName(), attr.getValue());
- }
- }
-
- xsdComp.setElement(element);
- endRecording(element);
- }
-
- private Element updateModelAndDerivedByKind(String modelType, String derivedByKind, DOMAttribute attr)
- {
- Element newContentModelElement = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, modelType);
- element.appendChild(newContentModelElement);
-
- Element newDerivedByElement = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, derivedByKind);
- newContentModelElement.appendChild(newDerivedByElement);
-
- newDerivedByElement.setAttribute(attr.getName(), attr.getValue());
-
- NodeList children = element.getChildNodes();
- int length = children.getLength();
- ArrayList nodesToRemove = new ArrayList();
- for (int i = 0; i < length; i++)
- {
- Node node = children.item(i);
- if (XSDDOMHelper.inputEquals(node, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(node, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true) ||
- XSDDOMHelper.inputEquals(node, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true) ||
- XSDDOMHelper.inputEquals(node, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false))
- {
- newDerivedByElement.appendChild(node.cloneNode(true));
- nodesToRemove.add(node);
- }
- }
- for (Iterator i = nodesToRemove.iterator(); i.hasNext(); )
- {
- XSDDOMHelper.removeNodeAndWhitespace((Node)i.next());
- }
-
- formatChild(newContentModelElement);
-
- return newDerivedByElement;
- }
-
- 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();
- }
- }
-
- }
-
- public DocumentImpl getDocument(Element element)
- {
- return (DocumentImpl) element.getOwnerDocument();
- }
-
- public void beginRecording(String description, Element element)
- {
- getDocument(element).getModel().beginRecording(this, description);
- }
-
- public void endRecording(Element element)
- {
- DocumentImpl doc = (DocumentImpl) getDocument(element);
-
- doc.getModel().endRecording(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetMultiplicityAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetMultiplicityAction.java
deleted file mode 100644
index 7de436d55d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetMultiplicityAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.wst.xsd.ui.internal.commands.SetMultiplicityCommand;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-public class SetMultiplicityAction extends AbstractAction
-{
- SetMultiplicityCommand command;
-
- public SetMultiplicityAction(XSDConcreteComponent parent, String multiplicity)
- {
- super(multiplicity, parent);
- command = new SetMultiplicityCommand(parent);
- }
-
- public void setMaxOccurs(int i)
- {
- command.setMaxOccurs(i);
- }
-
- public void setMinOccurs(int i)
- {
- command.setMinOccurs(i);
- }
-
- public void run()
- {
- beginRecording(getText());
- command.run();
- endRecording();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetTypeAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetTypeAction.java
deleted file mode 100644
index b91339860d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SetTypeAction.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2005 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - Initial API and implementation
-*******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.wst.xsd.ui.internal.commands.SetTypeCommand;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-public class SetTypeAction extends AbstractAction
-{
- int typeKind;
- SetTypeCommand command;
-
- public SetTypeAction(String text, ImageDescriptor image, XSDConcreteComponent xsdConcreteComponent)
- {
- super(text, image, xsdConcreteComponent);
- command = new SetTypeCommand(xsdConcreteComponent);
- }
-
- public SetTypeAction(String text, XSDConcreteComponent xsdConcreteComponent)
- {
- super(text, xsdConcreteComponent);
- command = new SetTypeCommand(xsdConcreteComponent);
- }
-
- public void setTypeKind(int type)
- {
- this.typeKind = type;
- command.setTypeKind(type);
- }
-
- public void run()
- {
- beginRecording(getText());
- command.run();
- endRecording();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java
deleted file mode 100644
index 8bc62ca765..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML;
-
-
-/**
- * SourcePageActionContributor
- *
- * This class is for multi page editor's source page contributor.
- *
- *
- */
-public class SourcePageActionContributor extends ActionContributorXML {
-
- private IActionBars fBars;
-
- /**
- * This method calls:
- * <ul>
- * <li><code>contributeToMenu</code> with <code>bars</code>' menu manager</li>
- * <li><code>contributeToToolBar</code> with <code>bars</code>' tool bar
- * manager</li>
- * <li><code>contributeToStatusLine</code> with <code>bars</code>' status line
- * manager</li>
- * </ul>
- * The given action bars are also remembered and made accessible via
- * <code>getActionBars</code>.
- *
- * @param bars the action bars
- *
- */
- public void init(IActionBars bars) {
- fBars = bars;
- contributeToMenu(bars.getMenuManager());
- contributeToToolBar(bars.getToolBarManager());
- contributeToStatusLine(bars.getStatusLineManager());
- }
-
- /**
- * Returns this contributor's action bars.
- *
- * @return the action bars
- */
- public IActionBars getActionBars() {
- return fBars;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java
deleted file mode 100644
index 736beca145..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.actions;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceInfoManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.ui.internal.actions.ReplacePrefixAction;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonResources;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.SchemaPrefixChangeHandler;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.TargetNamespaceChangeHandler;
-import org.eclipse.wst.xsd.ui.internal.widgets.XSDEditSchemaInfoDialog;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class XSDEditNamespacesAction extends Action {
- private Element element;
- private String resourceLocation;
- private XSDSchema xsdSchema;
- private DOMNamespaceInfoManager namespaceInfoManager = new DOMNamespaceInfoManager();
-
- public XSDEditNamespacesAction(String label, Element element, Node node) {
- super();
- setText(label);
-
- this.element = element;
- ///////////////////// This needs to be changed....
- this.resourceLocation = "dummy";
- }
-
- public XSDEditNamespacesAction(String label, Element element, Node node, XSDSchema schema) {
- this (label, element, node);
- xsdSchema = schema;
- }
-
- public void run() {
- if (element != null)
- {
- Shell shell = XMLCommonResources.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- String targetNamespace = null;
- if (xsdSchema != null) {
- targetNamespace = xsdSchema.getTargetNamespace();
- }
- XSDEditSchemaInfoDialog dialog = new XSDEditSchemaInfoDialog(shell, new Path(resourceLocation), targetNamespace);
-
- List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element);
- List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList);
-
- // here we store a copy of the old info for each NamespaceInfo
- // this info will be used in createPrefixMapping() to figure out how to update the document
- // in response to these changes
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext(); )
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- NamespaceInfo oldCopy = new NamespaceInfo(info);
- info.setProperty("oldCopy", oldCopy);
- }
-
- dialog.setNamespaceInfoList(namespaceInfoList);
- dialog.create();
- //dialog.getShell().setSize(500, 300);
- dialog.getShell().setText(XMLCommonResources.getInstance().getString("_UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE"));
- dialog.setBlockOnOpen(true);
- dialog.open();
- String xsdPrefix = "";
-
- if (dialog.getReturnCode() == Window.OK)
- {
- Element xsdSchemaElement = xsdSchema.getElement();
- DocumentImpl doc = (DocumentImpl) xsdSchemaElement.getOwnerDocument();
-
- List newInfoList = dialog.getNamespaceInfoList();
-
- // see if we need to rename any prefixes
- Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList);
-
- Map map2 = new Hashtable();
- for (Iterator iter = newInfoList.iterator(); iter.hasNext(); )
- {
- NamespaceInfo ni = (NamespaceInfo)iter.next();
- String pref = ni.prefix;
- String uri = ni.uri;
- if (pref == null) pref = "";
- if (uri == null) uri = "";
- if (XSDConstants.isSchemaForSchemaNamespace(uri))
- {
- xsdPrefix = pref;
- }
- map2.put(pref, uri);
- }
-
- if (map2.size() > 0)
- {
- try {
-
- doc.getModel().beginRecording(this, XSDEditorPlugin.getXSDString("_UI_NAMESPACE_CHANGE"));
-
- if (xsdPrefix != null && xsdPrefix.length() == 0)
- {
- xsdSchema.setSchemaForSchemaQNamePrefix(null);
- }
- else
- {
- xsdSchema.setSchemaForSchemaQNamePrefix(xsdPrefix);
- }
-
- xsdSchema.setTargetNamespace(dialog.getTargetNamespace());
- xsdSchema.update();
-
- SchemaPrefixChangeHandler spch = new SchemaPrefixChangeHandler(xsdSchema, xsdPrefix);
- spch.resolve();
- xsdSchema.update();
-
- xsdSchema.setIncrementalUpdate(false);
- namespaceInfoManager.removeNamespaceInfo(element);
- namespaceInfoManager.addNamespaceInfo(element, newInfoList, false);
- xsdSchema.setIncrementalUpdate(true);
-
- // don't need these any more?
- ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(null, element, prefixMapping);
- replacePrefixAction.run();
-
- TargetNamespaceChangeHandler targetNamespaceChangeHandler = new TargetNamespaceChangeHandler(xsdSchema, targetNamespace, dialog.getTargetNamespace());
- targetNamespaceChangeHandler.resolve();
- }
- catch (Exception e)
- {
-// e.printStackTrace();
- }
- finally
- {
- xsdSchema.update();
- doc.getModel().endRecording(this);
- }
- }
- }
-
- }
- }
-
- protected Map createPrefixMapping(List oldList, List newList)
- {
- Map map = new Hashtable();
-
- Hashtable oldURIToPrefixTable = new Hashtable();
- for (Iterator i = oldList.iterator(); i.hasNext(); )
- {
- NamespaceInfo oldInfo = (NamespaceInfo)i.next();
- oldURIToPrefixTable.put(oldInfo.uri, oldInfo);
- }
-
- for (Iterator i = newList.iterator(); i.hasNext(); )
- {
- NamespaceInfo newInfo = (NamespaceInfo)i.next();
- NamespaceInfo oldInfo = (NamespaceInfo)oldURIToPrefixTable.get(newInfo.uri != null ? newInfo.uri : "");
-
-
- // if oldInfo is non null ... there's a matching URI in the old set
- // we can use its prefix to detemine out mapping
- //
- // if oldInfo is null ... we use the 'oldCopy' we stashed away
- // assuming that the user changed the URI and the prefix
- if (oldInfo == null)
- {
- oldInfo = (NamespaceInfo)newInfo.getProperty("oldCopy");
- }
-
- if (oldInfo != null)
- {
- String newPrefix = newInfo.prefix != null ? newInfo.prefix : "";
- String oldPrefix = oldInfo.prefix != null ? oldInfo.prefix : "";
- if (!oldPrefix.equals(newPrefix))
- {
- map.put(oldPrefix, newPrefix);
- }
- }
- }
- return map;
- }
-
-// 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);
-// }
-// }
-// }
-// }
-// }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AbstractCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AbstractCommand.java
deleted file mode 100644
index 3c0ae2598f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AbstractCommand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-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.xsd.XSDConcreteComponent;
-import org.w3c.dom.Element;
-
-public abstract class AbstractCommand
-{
- private XSDConcreteComponent parent;
- private XSDConcreteComponent model;
-
- protected AbstractCommand(XSDConcreteComponent parent)
- {
- this.parent = parent;
- }
-
- public abstract void run();
-
- protected XSDConcreteComponent getParent()
- {
- return parent;
- }
-
- public XSDConcreteComponent getModelObject()
- {
- return model;
- }
-
- protected void setModelObject(XSDConcreteComponent model)
- {
- this.model = model;
- }
-
- // Establish part-whole relationship
- protected abstract boolean adopt(XSDConcreteComponent model);
-
- 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();
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddAttributeDeclarationCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddAttributeDeclarationCommand.java
deleted file mode 100644
index 0430149d7d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddAttributeDeclarationCommand.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDFactory;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-public class AddAttributeDeclarationCommand extends AbstractCommand
-{
- XSDAttributeDeclaration refAttribute = null;
- /**
- * @param parent
- */
- public AddAttributeDeclarationCommand(XSDConcreteComponent parent)
- {
- super(parent);
- }
-
- public AddAttributeDeclarationCommand(XSDConcreteComponent parent, XSDAttributeDeclaration ref)
- {
- super(parent);
- this.refAttribute = ref;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#run()
- */
- public void run()
- {
- XSDConcreteComponent parent = getParent();
- if (parent instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)parent;
-
- XSDAttributeDeclaration attribute = XSDFactory.eINSTANCE.createXSDAttributeDeclaration();
- attribute.setName(getNewName("Attribute")); //$NON-NLS-1$
- attribute.setTypeDefinition(ct.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string")); //$NON-NLS-1$
-
- XSDAttributeUse attributeUse = XSDFactory.eINSTANCE.createXSDAttributeUse();
- attributeUse.setAttributeDeclaration(attribute);
- attributeUse.setContent(attribute);
-
- if (ct.getAttributeContents() != null)
- {
- ct.getAttributeContents().add(attributeUse);
- formatChild(attribute.getElement());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
- */
- protected boolean adopt(XSDConcreteComponent model)
- {
- return false;
- }
-
- ArrayList names;
-
- protected String getNewName(String description)
- {
- String candidateName = "New" + description; //$NON-NLS-1$
- XSDConcreteComponent parent = getParent();
- 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/org/eclipse/wst/xsd/ui/internal/commands/AddComplexTypeDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddComplexTypeDefinitionCommand.java
deleted file mode 100644
index 72da36a17a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddComplexTypeDefinitionCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-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;
-
-public final class AddComplexTypeDefinitionCommand extends AbstractCommand
-{
- private String name;
-
- public AddComplexTypeDefinitionCommand
- (XSDConcreteComponent parent,
- String name)
- {
- super(parent);
- this.name = name; // this may be null for anonymous type
- }
-
- public void run()
- {
- XSDComplexTypeDefinition typeDef =
- XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
- typeDef.setName(name);
-
- if (adopt(typeDef))
- setModelObject(typeDef);
- }
-
- protected boolean adopt(XSDConcreteComponent model)
- {
- XSDConcreteComponent parent = getParent();
- if (parent instanceof XSDSchema)
- ((XSDSchema)parent).getTypeDefinitions().add(model);
- else if (parent instanceof XSDElementDeclaration)
- ((XSDElementDeclaration)parent).setAnonymousTypeDefinition((XSDComplexTypeDefinition)model);
- else
- return false; // invalid parent
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddElementDeclarationCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddElementDeclarationCommand.java
deleted file mode 100644
index fa087dd777..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddElementDeclarationCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFactory;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-
-public final class AddElementDeclarationCommand extends AbstractCommand
-{
- private String name; // element name
-
- public AddElementDeclarationCommand
- (XSDConcreteComponent parent,
- String name)
- {
- super(parent);
- this.name = name;
- }
-
- public void run()
- {
- XSDElementDeclaration elementDecl =
- XSDFactory.eINSTANCE.createXSDElementDeclaration();
- elementDecl.setName(name);
-
- adopt(elementDecl);
- setModelObject(elementDecl);
- }
-
- protected boolean adopt(XSDConcreteComponent model)
- {
- XSDConcreteComponent parent = getParent();
- if (parent instanceof XSDSchema)
- ((XSDSchema)parent).getElementDeclarations().add(model);
- else if (parent instanceof XSDParticle)
- ((XSDParticle)parent).setContent((XSDElementDeclaration)model);
- else
- return false; // invalid parent
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java
deleted file mode 100644
index f5518e2dd4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.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;
-
-public class AddModelGroupCommand extends AbstractCommand
-{
- protected XSDCompositor compositor;
-
- public AddModelGroupCommand(XSDConcreteComponent parent, XSDCompositor compositor)
- {
- super(parent);
- this.compositor = compositor;
- }
-
- public void run()
- {
- XSDConcreteComponent parent = getParent();
- 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)
- {
- ((XSDModelGroup) parent).getContents().add(createModelGroup());
- }
- else if (parent instanceof XSDComplexTypeDefinition)
- {
- owner = ((XSDComplexTypeDefinition)parent);
- }
- if (owner != null)
- {
- XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
- XSDModelGroup modelGroup = createModelGroup();
- particle.setContent(modelGroup);
-
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)owner;
- ctd.setContent(particle);
- formatChild(parent.getElement());
- }
- }
-
- protected boolean adopt(XSDConcreteComponent model)
- {
- return false;
- }
-
- protected XSDModelGroup createModelGroup()
- {
- XSDModelGroup modelGroup = XSDFactory.eINSTANCE.createXSDModelGroup();
- modelGroup.setCompositor(compositor);
- return modelGroup;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddSimpleTypeDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddSimpleTypeDefinitionCommand.java
deleted file mode 100644
index b0c347b430..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddSimpleTypeDefinitionCommand.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-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;
-
-public final class AddSimpleTypeDefinitionCommand extends AbstractCommand
-{
- private String name;
-
- public AddSimpleTypeDefinitionCommand
- (XSDConcreteComponent parent,
- String name)
- {
- super(parent);
- this.name = name; // this may be null for anonymous type
- }
-
- public void run()
- {
- XSDSimpleTypeDefinition typeDef =
- XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
- typeDef.setName(name);
-
- if (adopt(typeDef))
- setModelObject(typeDef);
- }
-
- protected boolean adopt(XSDConcreteComponent model)
- {
- XSDConcreteComponent parent = getParent();
- if (parent instanceof XSDSchema)
- ((XSDSchema)parent).getTypeDefinitions().add(model);
- else if (parent instanceof XSDElementDeclaration)
- ((XSDElementDeclaration)parent).setAnonymousTypeDefinition((XSDSimpleTypeDefinition)model);
- else if (parent instanceof XSDAttributeDeclaration)
- ((XSDAttributeDeclaration)parent).setAnonymousTypeDefinition((XSDSimpleTypeDefinition)model);
- else
- return false; // invalid parent
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeAnonymousTypeGlobalCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeAnonymousTypeGlobalCommand.java
deleted file mode 100644
index 7562a18eb9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeAnonymousTypeGlobalCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-public final class MakeAnonymousTypeGlobalCommand extends AbstractCommand {
-
- String fNewName;
-
- public MakeAnonymousTypeGlobalCommand(XSDConcreteComponent element,
- String newName) {
- super(element.getContainer());
- setModelObject(element);
- fNewName = newName;
- }
-
- public void run() {
- XSDConcreteComponent model = getModelObject();
- XSDConcreteComponent parent = model.getContainer();
- XSDTypeDefinition globalTypeDef = null;
- if (model instanceof XSDComplexTypeDefinition) {
- if (parent instanceof XSDElementDeclaration) {
- // clone typedef with it's content and set it global
- globalTypeDef = (XSDComplexTypeDefinition) model
- .cloneConcreteComponent(true, false);
- globalTypeDef.setName(fNewName);
- parent.getSchema().getContents().add(globalTypeDef);
- ((XSDElementDeclaration) parent)
- .setTypeDefinition(globalTypeDef);
- }
- } else if (model instanceof XSDSimpleTypeDefinition) {
-
- XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) model;
- if (parent instanceof XSDElementDeclaration) {
- // clone typedef with it's content and set it global
- globalTypeDef = (XSDSimpleTypeDefinition) typeDef
- .cloneConcreteComponent(true, false);
- globalTypeDef.setName(fNewName);
- parent.getSchema().getContents().add(globalTypeDef);
- ((XSDElementDeclaration) parent)
- .setTypeDefinition(globalTypeDef);
- formatChild(globalTypeDef.getElement());
-
- } else if (parent instanceof XSDAttributeDeclaration) {
- // clone typedef with it's content and set it global
- globalTypeDef = (XSDSimpleTypeDefinition) typeDef
- .cloneConcreteComponent(true, false);
- globalTypeDef.setName(fNewName);
- parent.getSchema().getContents().add(globalTypeDef);
- ((XSDAttributeDeclaration) parent)
- .setTypeDefinition((XSDSimpleTypeDefinition) globalTypeDef);
-
- }
-
- }
-
- formatChild(globalTypeDef.getElement());
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
- */
- protected boolean adopt(XSDConcreteComponent model) {
- // TODO Auto-generated method stub
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeLocalElementGlobalCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeLocalElementGlobalCommand.java
deleted file mode 100644
index 73039198cc..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/MakeLocalElementGlobalCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-import org.eclipse.xsd.XSDComplexTypeContent;
-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.XSDTypeDefinition;
-
-public final class MakeLocalElementGlobalCommand extends AbstractCommand
-{
-
- public MakeLocalElementGlobalCommand
- (XSDConcreteComponent element)
- {
- super(element.getContainer());
- setModelObject(element);
- }
-
- public void run()
- {
-
- if(getModelObject() instanceof XSDElementDeclaration){
-
- XSDElementDeclaration element = (XSDElementDeclaration)getModelObject();
- XSDConcreteComponent parent = getParent();
- XSDConcreteComponent container = parent.getContainer();
-
- // clone element with it's content and set it global
- XSDConcreteComponent elementDecl = ((XSDElementDeclaration)getModelObject()).cloneConcreteComponent(true, true);
- container.getSchema().getContents().add(elementDecl);
-
- // create local element and set it's reference to the global one
- XSDElementDeclaration elementRef =
- XSDFactory.eINSTANCE.createXSDElementDeclaration();
- elementRef.setValue(element.getValue());
- elementRef.setResolvedElementDeclaration((XSDElementDeclaration)elementDecl);
-
- // now set content models
- if(parent instanceof XSDComplexTypeContent){
- if(container instanceof XSDModelGroup){
- XSDModelGroup modelGroup = (XSDModelGroup)container;
- // disconnect parent from its container
- int index = modelGroup.getContents().indexOf(parent);
- XSDParticle particle =
- XSDFactory.eINSTANCE.createXSDParticle();
- particle.setContent(elementRef);
- modelGroup.getContents().add(index, particle);
-
- modelGroup.getContents().remove(parent);
- modelGroup.updateElement(true);
- formatChild(modelGroup.getElement());
- }
- }
- else if(parent instanceof XSDTypeDefinition){
- System.out.println("MakeLocalElementGlobalCommand.run: parent instanceof XSDTypeDefinition");
-
- }
-
- container.getSchema().updateElement(true);
- formatChild(elementDecl.getElement());
-
- }
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
- */
- protected boolean adopt(XSDConcreteComponent model) {
- // TODO Auto-generated method stub
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/RenameCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/RenameCommand.java
deleted file mode 100644
index 4ecd336701..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/RenameCommand.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2005 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - Initial API and implementation
-*******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.commands;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ComplexTypeDefinitionEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ElementDeclarationEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ModelGroupDefinitionEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-
-
-/**
- * @author kchong
- *
- * <a href="mailto:kchong@ca.ibm.com">kchong@ca.ibm.com</a>
- *
- */
-public class RenameCommand
-{
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- Label label = new Label();
- XSDNamedComponent namedComponent;
- GraphicalEditPart editPart;
-
- public RenameCommand(XSDNamedComponent namedComponent, GraphicalEditPart editPart)
- {
- this.namedComponent = namedComponent;
- this.editPart = editPart;
- }
-
- public void run()
- {
- if (editPart instanceof ElementDeclarationEditPart)
- {
- ElementDeclarationEditPart elementDeclarationEditPart = (ElementDeclarationEditPart)editPart;
- elementDeclarationEditPart.doEditName();
- }
- else if (editPart instanceof TopLevelComponentEditPart)
- {
- TopLevelComponentEditPart topLevelEditPart = (TopLevelComponentEditPart)editPart;
- topLevelEditPart.doEditName();
- }
- else if (editPart instanceof ComplexTypeDefinitionEditPart)
- {
- ((ComplexTypeDefinitionEditPart)editPart).doEditName();
- }
- else if (editPart instanceof ModelGroupDefinitionEditPart)
- {
- ((ModelGroupDefinitionEditPart)editPart).doEditName();
- }
- }
-
- protected boolean adopt(XSDConcreteComponent model)
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetMultiplicityCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetMultiplicityCommand.java
deleted file mode 100644
index 4c8c27db08..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetMultiplicityCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.commands;
-
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDParticleContent;
-
-public class SetMultiplicityCommand extends AbstractCommand
-{
- int maxOccurs, minOccurs;
-
- /**
- * @param parent
- */
- public SetMultiplicityCommand(XSDConcreteComponent parent)
- {
- super(parent);
- }
-
- public void setMaxOccurs(int i)
- {
- maxOccurs=i;
- }
-
- public void setMinOccurs(int i)
- {
- minOccurs=i;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#run()
- */
- public void run()
- {
- XSDConcreteComponent parent = getParent();
- 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);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
- */
- protected boolean adopt(XSDConcreteComponent model)
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetTypeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetTypeCommand.java
deleted file mode 100644
index ce76482e7f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/SetTypeCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2005 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - Initial API and implementation
-*******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.commands;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDSetTypeHelper;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class SetTypeCommand extends AbstractCommand
-{
- protected int typeKind = XSDConstants.COMPLEXTYPE_ELEMENT;
-
- public SetTypeCommand(XSDConcreteComponent parent)
- {
- super(parent);
- }
-
- public void setTypeKind(int type)
- {
- this.typeKind = type;
- }
-
- public void run()
- {
- XSDConcreteComponent parent = getParent();
- if (parent instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration element = (XSDElementDeclaration)parent;
- XSDSchema schema = element.getSchema();
- if (typeKind == XSDConstants.COMPLEXTYPE_ELEMENT)
- {
- AddModelGroupCommand sequenceCommand = new AddModelGroupCommand(element, XSDCompositor.SEQUENCE_LITERAL);
- sequenceCommand.run();
- }
- else if (typeKind == XSDConstants.SIMPLETYPE_ELEMENT)
- {
- AddSimpleTypeDefinitionCommand stCommand = new AddSimpleTypeDefinitionCommand(element, null);
- stCommand.run();
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)stCommand.getModelObject();
- XSDSimpleTypeDefinition base = schema.resolveSimpleTypeDefinition(schema.getSchemaForSchemaNamespace(), "string");
- st.setBaseTypeDefinition(base);
- }
- else
- {
- Shell shell = Display.getCurrent().getActiveShell();
- IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile();
-
- XSDComponentSelectionProvider provider = new XSDComponentSelectionProvider(currentIFile, schema);
- XSDComponentSelectionDialog dialog = new XSDComponentSelectionDialog(shell, XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"), provider);
- provider.setDialog(dialog);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- if (dialog.open() == Window.OK) {
- XSDSetTypeHelper helper = new XSDSetTypeHelper(currentIFile, schema);
- helper.setType(element.getElement(), "type", dialog.getSelection());
- }
- }
- formatChild(element.getElement());
- }
-
- }
-
- private IEditorPart getActiveEditor()
- {
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
-// IEditorPart editorPart = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
-
- return editorPart;
- }
-
- protected boolean adopt(XSDConcreteComponent model)
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/ComponentSelectionDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/ComponentSelectionDialog.java
deleted file mode 100644
index 77ce6ad4d0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/ComponentSelectionDialog.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.common;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-
-public class ComponentSelectionDialog extends Dialog {
- private Display display = Display.getCurrent();
- private String dialogTitle;
-
- protected IComponentSelectionProvider provider;
- private List componentTreeViewerInput;
- private List masterComponentList;
-
- // widgets
- protected Composite topComposite;
- protected Composite bottomComposite;
- private String filterTextLabel = "";
- private String componentListLabel = XSDEditorPlugin.getXSDString("_UI_LABEL_COMPONENTS");
- private Text textFilter;
- protected TreeViewer componentTreeViewer;
- private org.eclipse.swt.widgets.List qualifierList;
-
- protected Object componentSelection;
- protected Object qualifierTextSelection;
-
- public ComponentSelectionDialog(Shell shell, String dialogTitle, IComponentSelectionProvider provider) {
- super(shell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.dialogTitle = dialogTitle;
- this.provider = provider;
-
- componentTreeViewerInput = new ArrayList();
- masterComponentList = new ArrayList();
- }
-
- /*
- * This method should be called before createDialogArea(Composite)
- */
- public void setComponentTreeLabel(String string) {
- componentListLabel = string;
- }
-
- /*
- * This method should be called before createDialogArea(Composite)
- */
- public void setFilterLabel(String string) {
- filterTextLabel = string;
- }
-
- public void create() {
- super.create();
- setTextFilterFocus();
- }
-
- protected void setTextFilterFocus() {
- textFilter.setFocus();
- }
-
- public Control createDialogArea(Composite parent) {
- getShell().setText(dialogTitle);
-
- Composite mainComposite = (Composite) super.createDialogArea(parent);
- GridData gData = (GridData) mainComposite.getLayoutData();
- gData.heightHint = 500;
- gData.widthHint = 400;
-
- // Subclasses may use this Composite to add desired widgets
- //topComposite = new Composite(mainComposite, SWT.NONE);
- //topComposite.setLayoutData(new GridData());
- //topComposite.setLayout(new GridLayout());
-
- // do we need to introduce a method here to contain this
- // so we can add different parent other than 'topComposite'
- Composite filterLabelAndTree = new Composite(mainComposite, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- filterLabelAndTree.setLayoutData(new GridData(GridData.FILL_BOTH));
- filterLabelAndTree.setLayout(layout);
-
- // Create Text textFilter
- Label filterLabel = new Label(filterLabelAndTree, SWT.NONE);
- filterLabel.setText(filterTextLabel);// + "(? = any character, * = any string):"); // TODO: Externalize String
-
- textFilter = new Text(filterLabelAndTree, SWT.SINGLE | SWT.BORDER);
- textFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- textFilter.addModifyListener(new TextFilterModifyAdapter());
- GridData textFilterData = new GridData();
- textFilterData.horizontalAlignment = GridData.FILL;
- textFilterData.grabExcessHorizontalSpace = true;
- textFilter.setLayoutData(textFilterData);
-
- //textFilter.setSelection(0);
- //textFilter.setf
-
-
- // Create Component TreeViewer
- createComponentTreeViewer(filterLabelAndTree);
-
- // Create Qualifier List widget
- Label qualifierLabel = new Label(mainComposite, SWT.NONE);
- qualifierLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_QUALIFIER"));
-
- qualifierList = new org.eclipse.swt.widgets.List(mainComposite, SWT.BORDER | SWT.SINGLE);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.heightHint = 45;
- qualifierList.setLayoutData(data);
-
- bottomComposite = new Composite(mainComposite, SWT.NONE);
- bottomComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- bottomComposite.setLayout(new GridLayout());
-
- // Populate the Component TreeViewer via the provider
- // TODO: Is this the right way to set/get the ContentProvider?
- componentTreeViewer.setContentProvider(new ComponentTreeContentProvider());
- componentTreeViewer.setLabelProvider(provider.getLabelProvider());
- componentTreeViewer.setSorter(new ViewerSorter());
- componentTreeViewer.setInput(componentTreeViewerInput);
-
- populateMasterComponentList();
- refreshTreeViewer("");
-
- return mainComposite;
- }
-
- protected TreeViewer createTreeViewer(Composite comp, String title) {
- Label label = new Label(comp, SWT.NONE);
- label.setText(title);
-
- TreeViewer treeViewer = new TreeViewer(new Tree(comp, SWT.SINGLE | SWT.BORDER));
- Control treeWidget = treeViewer.getTree();
- GridData gd = new GridData(GridData.FILL_BOTH);
- treeWidget.setLayoutData(gd);
-
- return treeViewer;
- }
-
- /*
- * Creates the Component TreeViewer.
- */
- private void createComponentTreeViewer(Composite base) {
- componentTreeViewer = createTreeViewer(base, componentListLabel);
-
- componentTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
- List qualifiers = provider.getQualifiers(structuredSelection.getFirstElement());
- updateQualifierList(qualifiers);
- updateCanFinish();
- }
- });
- }
-
- private void updateQualifierList(List qualifiers) {
- qualifierList.removeAll();
- Iterator it = qualifiers.iterator();
- while (it.hasNext()) {
- qualifierList.add(it.next().toString());
- }
- }
-
-
- /*
- * Returns the processed filter text for the Text field. Inserts a "."
- * before each supported meta-character.
- */
- protected String getProcessedFilterString() {
- return processFilterString(textFilter.getText());
- }
-
- /*
- * If supported metacharacters are used in the filter string, we need to
- * insert a "." before each metacharacter.
- */
- private String processFilterString(String inputString) {
- if (!(inputString.equals(""))) {
- inputString = insertString("*", ".", inputString);
- inputString = insertString("?", ".", inputString);
- inputString = inputString + ".*";
- } else {
- inputString = ".*";
- }
-
- return inputString.toLowerCase();
- }
-
- /*
- * Helper method to insert a "." before each metacharacter in the
- * search/filter string.
- */
- private String insertString(String target, String newString, String string) {
- StringBuffer stringBuffer = new StringBuffer(string);
-
- int index = stringBuffer.indexOf(target);
- while (index != -1) {
- stringBuffer = stringBuffer.insert(index, newString);
- index = stringBuffer.indexOf(target, index + newString.length() + target.length());
- }
-
- return stringBuffer.toString();
- }
-
- /*
- * Listens to changes made in the text filter widget
- */
- private class TextFilterModifyAdapter implements ModifyListener {
- public void modifyText(ModifyEvent e) {
- if (e.widget == textFilter) {
- if (delayedEvent != null) {
- delayedEvent.CANCEL = true;
- }
-
- delayedEvent = new DelayedEvent();
- Display.getCurrent().timerExec(400, delayedEvent);
- }
- }
- }
-
- //TODO... do we really need one instance?
- private DelayedEvent delayedEvent;
-
- /*
- * Update the component TreeViewer when the text filter is modified.
- * Use a DelayedEvent so we don't update on every keystroke.
- */
- private class DelayedEvent implements Runnable {
- public boolean CANCEL = false;
-
- public void run() {
- if (!CANCEL) {
- refreshTreeViewer(getProcessedFilterString());
-
- // Select first match
- if (componentTreeViewer.getTree().getItemCount() > 0) {
- TreeItem item = componentTreeViewer.getTree().getItems()[0];
- TreeItem items[] = new TreeItem[1];
- items[0] = item;
- componentTreeViewer.getTree().setSelection(items);
- }
-
- // Update qualifierList
- IStructuredSelection structuredSelection = (IStructuredSelection) componentTreeViewer.getSelection();
- List qualifiers = provider.getQualifiers(structuredSelection.getFirstElement());
- updateQualifierList(qualifiers);
-
- updateCanFinish();
- }
- }
- }
-
- class ComponentList implements IComponentList {
- private Vector objectVector = new Vector();
- private long currentChangeCounter = 0;
-
- public void addComponent(Object o) {
- objectVector.add(o);
- currentChangeCounter++;
- doViewerUpdate();
- }
-
- private void doViewerUpdate() {
- // TODO: Investigate if we should also add a timer condition??
- if (currentChangeCounter == 10) {
- currentChangeCounter = 0;
- fireUpdateList(this);
- }
- }
-
- public int size() {
- return objectVector.size();
- }
-
- public List subList(int startIndex, int endIndex) {
- return objectVector.subList(startIndex, endIndex);
- }
-
- public Iterator iterator() {
- return objectVector.iterator();
- }
- }
-
-
- // this method gets called from a non-ui thread so needs to call
- // asyncExec to ensure the UI updates happen on the UI thread
- //
- protected void fireUpdateList(final ComponentList list) {
- Runnable runnable = new Runnable() {
- public void run(){
- // add new objects
- int growingListSize = list.size();
- int currentSize = masterComponentList.size();
- if (growingListSize > currentSize) {
- masterComponentList.addAll(list.subList(currentSize, growingListSize));
- }
-
- refreshTreeViewer(getProcessedFilterString());
- }
- };
- display.asyncExec(runnable);
- }
-
-
- /*
- * Populate the Component TreeViewer with items.
- */
- protected void populateMasterComponentList() {
- masterComponentList.clear();
-
- final ComponentList componentList = new ComponentList();
- provider.getComponents(componentList, true);
-
- Job job = new Job("read components") {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- // this stuff gets executed on a non-UI thread
- //
- provider.getComponents(componentList, false);
-
- // Do a final update of our Input for the component tree viewer.
- fireUpdateList(componentList);
- }
- catch (Exception e) {
- }
- return Status.OK_STATUS;
- }
- };
- job.schedule();
- }
-
- protected void refreshTreeViewer(String filterText) {
- componentTreeViewerInput.clear();
- ILabelProvider labelProvider = provider.getLabelProvider();
- Pattern regex = Pattern.compile(filterText);
- Iterator it = masterComponentList.iterator();
- while (it.hasNext()) {
- Object item = it.next();
- String itemString = labelProvider.getText(item);
- Matcher m = regex.matcher(itemString.toLowerCase());
- if (itemString.toLowerCase().startsWith(filterText) || m.matches()) {
- componentTreeViewerInput.add(item);
- }
- }
-
- componentTreeViewer.refresh();
- }
-
- /*
- * If there is a selection in the ComponentTreeViewer, enable OK
- */
- protected void updateCanFinish() {
- IStructuredSelection selection = (IStructuredSelection) componentTreeViewer.getSelection();
- if (selection.getFirstElement() != null) {
- getButton(IDialogConstants.OK_ID).setEnabled(true);
- }
- else {
- getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
- }
-
- protected void okPressed() {
- IStructuredSelection selection = (IStructuredSelection) componentTreeViewer.getSelection();
- componentSelection = selection.getFirstElement();
- int qualifierIndex = qualifierList.getSelectionIndex();
- if (qualifierIndex < 0) {
- qualifierIndex = 0;
- }
- qualifierTextSelection = qualifierList.getItem(qualifierIndex);
-
- super.okPressed();
- }
-
- private class ComponentTreeContentProvider implements ITreeContentProvider {
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof List) {
- return ((List) parentElement).toArray();
- }
- return new Object[0];
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (getChildren(element).length > 0) {
- return true;
- }
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentList.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentList.java
deleted file mode 100644
index 5c5d46ad84..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentList.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.common;
-
-import java.util.Iterator;
-
-public interface IComponentList {
- public void addComponent(Object o);
- public Iterator iterator();
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentSelectionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentSelectionProvider.java
deleted file mode 100644
index de68271167..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/common/IComponentSelectionProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.common;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-
-public interface IComponentSelectionProvider {
-
- // warning ... this will get called on a non UI thread
- void getComponents(IComponentList list, boolean quick);
-
- String getType(Object component);
- ILabelProvider getLabelProvider();
- List getQualifiers(Object component);
- String getNameFieldTitle();
- String getListTitle();
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/ResourceView.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/ResourceView.java
deleted file mode 100644
index 2a61449b58..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/ResourceView.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xml;
-
-public class ResourceView {
-/*
- Label scopeComboLabel = new Label(topComposite, SWT.NONE);
- scopeComboLabel.setText(searchScopeComboLabel);
- scopeCombo = new Combo(topComposite, SWT.NONE);
- initializeSearchScopeCombo();
-
- sashForm = new SashForm(topComposite, SWT.VERTICAL);
- GridData sashGD = new GridData(GridData.FILL_BOTH);
- sashGD.grabExcessHorizontalSpace = true;
- sashGD.grabExcessVerticalSpace = true;
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
- sashForm.setLayout(new GridLayout());
-
- int[] sashFormWeights = new int[2];
- sashFormWeights[0] = 0;
- sashFormWeights[1] = 7;
- sashForm.setWeights(sashFormWeights);
-
- // Create PageBook for High Level TreeViewer
- highLevelPageBook = new PageBook(sashForm, SWT.NONE);
- GridData fileSystemPBData = new GridData();
- fileSystemPBData.horizontalAlignment = SWT.FILL;
- highLevelPageBook.setLayoutData(fileSystemPBData);
-
- blankHighLevelComposite = new Composite(highLevelPageBook, SWT.NONE);
- highLevelComposite = new Composite(highLevelPageBook, SWT.NONE);
- GridLayout fileSystemLayout = new GridLayout();
- fileSystemLayout.marginWidth = 0;
- highLevelComposite.setLayout(fileSystemLayout);
- highLevelComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createHighLevelTreeViewer(highLevelComposite);
- populateHighLevelTreeViewer();
-
- highLevelPageBook.showPage(blankHighLevelComposite);
-////////////////////////////////////////////////////////////////////////////// //
-
- /*
- * Creates the High Level TreeViewer (Top TreeViewer).
- *
- private void createHighLevelTreeViewer(Composite base) {
- highLevelTreeViewer = createTreeViewer(highLevelComposite, "Resources");
- initializeHighLevelTreeViewer();
- String ext[] = new String[1];
- ext[0] = "xsd";
- addFilterExtensions(highLevelTreeViewer, ext, new IFile[0]);
-
- initializeHighLevelTreeViewer();
- populateHighLevelTreeViewer();
- }
-
-
- protected void showHighLevelView(boolean show) {
- if (show) {
- int[] sashFormWeights = new int[2];
- sashFormWeights[0] = 4;
- sashFormWeights[1] = 5;
- sashForm.setWeights(sashFormWeights);
-
- highLevelPageBook.showPage(highLevelComposite);
- topComposite.layout(true, true);
-
- showHighLevelView();
- } else {
- int[] sashFormWeights = new int[2];
- sashFormWeights[0] = 0;
- sashFormWeights[1] = 7;
- sashForm.setWeights(sashFormWeights);
-
- highLevelPageBook.showPage(blankHighLevelComposite);
- topComposite.layout(true, true);
-
- hideHighLevelView();
- }
- }
-
- protected void setFilter(TreeViewer treeViewer, ViewerFilter filter) {
- treeViewer.getTree().setRedraw(false);
- treeViewer.resetFilters();
- treeViewer.addFilter(filter);
- treeViewer.getTree().setRedraw(true);
- treeViewer.getTree().redraw();
- }
-
- // ///////////////////////////////////////////////////
- // This is a convenience method that allows filtering of the given file
- // exensions. It internally creates a ResourceFilter so that users of this
- // class don't have to construct one.
- // If the extensions provided don't have '.', one will be added.
- protected void addFilterExtensions(TreeViewer treeViewer, String[] filterExtensions, IFile[] excludedFiles) {
- // First add the '.' to the filterExtensions if they don't already have
- // one
- String[] correctedFilterExtensions = new String[filterExtensions.length];
- for (int i = 0; i < filterExtensions.length; i++) {
- // If the extension doesn't start with a '.', then add one.
- if (filterExtensions[i].startsWith(".")) {
- correctedFilterExtensions[i] = filterExtensions[i];
- } else {
- correctedFilterExtensions[i] = "." + filterExtensions[i];
- }
- }
- ViewerFilter filter;
- if (excludedFiles != null) {
- filter = new SetTypeResourceFilter(correctedFilterExtensions, excludedFiles, null);
- } else {
- filter = new SetTypeResourceFilter(correctedFilterExtensions, null);
- }
- setFilter(treeViewer, filter);
- }
-
-
-
- * Creates a Generic TreeViewer object with the specified label and sets
- * it's GridData value.
-
- protected TreeViewer createTreeViewer(Composite comp, String title) {
- Label label = new Label(comp, SWT.NONE);
- label.setText(title);
-
- TreeViewer treeViewer = new TreeViewer(new Tree(comp, SWT.SINGLE | SWT.BORDER));
- Control treeWidget = treeViewer.getTree();
- GridData gd = new GridData(GridData.FILL_BOTH);
- treeWidget.setLayoutData(gd);
-
- return treeViewer;
- }
-*/
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java
deleted file mode 100644
index d73adcb0b8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentFinder.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-/**
- * this thing parsers xml artifacts and picks out the specified components attributes
- *
- */
-public class XMLComponentFinder {
- public static final int ENCLOSING_PROJECT_SCOPE = 0;
- public static final int ENTIRE_WORKSPACE_SCOPE = 1;
-
- protected IFile currentIFile;
- protected List validExtensions; // List of extensions as String objects
- protected List excludeFiles; // List of files (full path) as String objects
-
- public XMLComponentFinder() {
- validExtensions = new ArrayList();
- excludeFiles = new ArrayList();
- }
-
- /*
- * Takes in the IFile we are currently editing.
- * The currentIFile must be set before the getEnclosingProjectFiles()
- * method will return correctly.
- */
- public void setFile(IFile file) {
- currentIFile = file;
- }
-
- public void setValidExtensions(List newExtensions) {
- validExtensions.clear();
- validExtensions.addAll(newExtensions);
- }
-
- public void addExcludeFiles(List newExclude) {
- excludeFiles.addAll(newExclude);
- }
-
- /*
- * Returns a List of absolute file locations. For example
- * "D:\files\....\file.xsd"
- */
- protected List getEnclosingProjectFiles() {
- List files = new ArrayList();
-
- if (currentIFile != null) {
- IProject project = currentIFile.getProject();
- try {
- traverseIContainer(project, validExtensions, excludeFiles, files);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- return files;
- }
-
- protected List getWorkspaceFiles() {
- List files = new ArrayList();
- IWorkspaceRoot iwr = ResourcesPlugin.getWorkspace().getRoot();
- IProject[] projects = iwr.getProjects();
-
- try {
- for (int index = 0; index < projects.length; index++) {
- traverseIContainer(projects[index], validExtensions, excludeFiles, files);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return files;
- }
-
- /**
- * Returns a List of absolute file locations. For example
- * "D:\files\....\file.xsd"
- */
- protected void traverseIContainer(IContainer container, List extensions, List excludeFiles, List list) throws Exception {
- IResource[] children = container.members();
-
- for (int index = 0; index < children.length; index++) {
- if (children[index] instanceof IFolder) {
- traverseIContainer((IFolder) children[index], extensions, excludeFiles, list);
- } else if (children[index] instanceof IFile) {
- IFile file = (IFile) children[index];
- String fileName = file.getLocation().toOSString();
- String ext = file.getFileExtension();
- if (extensions.contains(ext) && !excludeFiles.contains(fileName)) {
- list.add(file.getLocation());
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionDialog.java
deleted file mode 100644
index d9a74d5813..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionDialog.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xml;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.ComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionProvider.XMLComponentTreeObject;
-
-public class XMLComponentSelectionDialog extends ComponentSelectionDialog {
-
- protected final static String DEFAULT_NAME_FIELD_TITLE = XSDEditorPlugin.getXSDString("_UI_LABEL_COMPONENT_NAME");
- protected final static String DEFAULT_LIST_TITLE = XSDEditorPlugin.getXSDString("_UI_LABEL_MATCHING_COMPONENTS");
-
- public static final String SCOPE_SPECIFIED_FILE = XSDEditorPlugin.getXSDString("_UI_LABEL_SPECIFIED_FILE");
-
- public static final String SCOPE_ENCLOSING_PROJECT = XSDEditorPlugin.getXSDString("_UI_LABEL_ENCLOSING_PROJECT");
-
- public static final String SCOPE_WORKSPACE = XSDEditorPlugin.getXSDString("_UI_LABEL_WORKSPACE");
-
- public static final String SCOPE_CURRENT_RESOURCE = XSDEditorPlugin.getXSDString("_UI_LABEL_CURRENT_RESOURCE");
-
- private String currentSearchScope = SCOPE_CURRENT_RESOURCE;
-
- protected Button chooseButton;
- protected Button[] radioButton = new Button[3];
-
- public XMLComponentSelectionDialog(Shell shell, String dialogTitle,
- IComponentSelectionProvider provider) {
- super(shell, dialogTitle, provider);
- }
-
-public Control createDialogArea(Composite parent) {
-
- setFilterLabel(provider.getNameFieldTitle() != null ? provider.getNameFieldTitle() : DEFAULT_NAME_FIELD_TITLE);
- setComponentTreeLabel(provider.getListTitle() != null ? provider.getListTitle() : DEFAULT_LIST_TITLE);
- super.createDialogArea(parent);
-
- // We use the Composite topComposite to create additional widgets
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- bottomComposite.setLayout(layout);
-
-
- Group group = new Group(bottomComposite, SWT.NONE);
- GridLayout gridLayout = new GridLayout(3, false);
- //gridLayout.marginWidth = 0;
- //gridLayout.marginLeft = 2;
- group.setLayout(gridLayout);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_SEARCH_SCOPE"));
-
- ScopeChangeListener scopeChangeListener = new ScopeChangeListener();
- radioButton[0] = new Button(group, SWT.RADIO);
- radioButton[0].setText(SCOPE_WORKSPACE);
-
- radioButton[1] = new Button(group, SWT.RADIO);
- radioButton[1].setText(SCOPE_ENCLOSING_PROJECT);
-
- radioButton[2] = new Button(group, SWT.RADIO);
- radioButton[2].setText(SCOPE_CURRENT_RESOURCE);
-
- //radioButton[3] = new Button(group, SWT.RADIO);
- //radioButton[3].setText("Resource Set");
-
-
- for (int i = 0; i < radioButton.length; i++)
- {
- if (radioButton[i].getText().equals(currentSearchScope))
- {
- radioButton[i].setSelection(true);
- }
- radioButton[i].addSelectionListener(scopeChangeListener);
- }
- if (false){
- Composite selectFileGroup = new Composite(group, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- selectFileGroup.setLayoutData(gd);
- GridLayout gridLayout3 = new GridLayout(2, false);
- gridLayout3.marginWidth = 0;
- gridLayout3.marginHeight = 0;
- selectFileGroup.setLayout(gridLayout3);
- Text t = new Text(selectFileGroup, SWT.BORDER | SWT.READ_ONLY);
- t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Button choose = new Button(selectFileGroup, SWT.NONE);
- choose.setText("Choose...");
- choose.addSelectionListener(scopeChangeListener);
- }
-
-
- Button check = new Button(group, SWT.CHECK);
- check.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_NARROW_SEARCH_SCOPE_RESOURCE"));
- GridData gd = new GridData();
- gd.horizontalSpan = 3;
- check.setLayoutData(gd);
- check.setEnabled(false);
-
- return parent;
- } /*
- * Returns the selected search scope.
- */
- public String getSearchScope() {
- return currentSearchScope;
- }
-
- public XMLComponentSpecification getSelection() {
- XMLComponentTreeObject treeObject = (XMLComponentTreeObject) componentSelection;
- List specs = treeObject.getXMLComponentSpecification();
-
- int matchingIndex = 0;
- for (int index = 0; index < specs.size(); index++) {
- XMLComponentSpecification spec = (XMLComponentSpecification) specs
- .get(index);
- IPath path = new Path(spec.getFileLocation());
- String specText = spec.getTargetNamespace() + " - "
- + path.lastSegment();
- if (specText.equals(qualifierTextSelection)) {
- matchingIndex = index;
- break;
- }
- }
-
- return (XMLComponentSpecification) specs.get(matchingIndex);
- }
-
- private class ScopeChangeListener extends SelectionAdapter {
- public void widgetSelected(SelectionEvent e) {
-
- if (e.widget instanceof Button) {
- Button b = (Button) e.widget;
- if ((b.getStyle() & SWT.RADIO) != 0) {
- currentSearchScope = b.getText();
- populateMasterComponentList();
- refreshTreeViewer(getProcessedFilterString());
-
- // Select the first matching component. Though we should be
- // smarter here
- // and determine if there was a selection before the scope
- // switch (and if
- // the component is still available.
- Tree tree = componentTreeViewer.getTree();
- TreeItem items[] = tree.getItems();
- if (items.length > 0) {
- TreeItem select[] = new TreeItem[1];
- select[0] = items[0];
- tree.setSelection(select);
- }
-
- updateCanFinish();
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java
deleted file mode 100644
index aef0a011aa..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSelectionProvider.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xml;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentList;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentSelectionProvider;
-
-public abstract class XMLComponentSelectionProvider implements IComponentSelectionProvider {
- public List getQualifiers(Object component) {
- List qualifiers = new ArrayList();
- if (component != null) {
- XMLComponentTreeObject specification = (XMLComponentTreeObject) component;
- Iterator it = specification.getXMLComponentSpecification().iterator();
- while (it.hasNext()) {
- XMLComponentSpecification spec = (XMLComponentSpecification) it.next();
- qualifiers.add(createQualifierText(spec));
- }
- }
-
- return qualifiers;
- }
-
- protected String createQualifierText(XMLComponentSpecification spec) {
- IPath path = new Path(spec.getFileLocation());
- return spec.getTargetNamespace() + " - " + path.lastSegment();
- }
-
- protected void addDataItemToTreeNode(IComponentList comps, XMLComponentSpecification dataItem) {
- boolean foundMatch = false;
- Iterator it = comps.iterator();
- XMLComponentTreeObject containingTreeObject = null;
-
- while (it.hasNext()) {
- XMLComponentTreeObject treeObject = (XMLComponentTreeObject) it.next();
- if (treeObject.getName().equals(dataItem.getAttributeInfo("name"))) {
- // If the existing data item and the new data item have the same names
- if (treeObject.getXMLComponentSpecification().size() > 0) {
- String existingPath = ((XMLComponentSpecification) treeObject.getXMLComponentSpecification().get(0)).getTagPath();
- if (existingPath.equals(dataItem.getTagPath())) {
- // If they are the same 'type' of items (according to the path value)
- containingTreeObject = treeObject;
- foundMatch = true;
- break;
- }
- }
- }
- }
-
- if (!foundMatch) {
- containingTreeObject = new XMLComponentTreeObject(dataItem);
- comps.addComponent(containingTreeObject);
- }
- else {
- // Only add to the tree object if the qualifier text differs than existing
- // qualifier information contained in the tree object.
- Iterator existingQualifiers = getQualifiers(containingTreeObject).iterator();
- boolean alreadyExists = false;
- while (existingQualifiers.hasNext()) {
- String existingText = (String) existingQualifiers.next();
- String newItemText = createQualifierText(dataItem);
- if (existingText.equals(newItemText)) {
- alreadyExists = true;
- break;
- }
- }
-
- if (!alreadyExists) {
- containingTreeObject.addXMLComponentSpecification(dataItem);
- }
- }
- }
-
- protected String getNormalizedLocation(String location) {
- try {
- URL url = new URL(location);
- URL resolvedURL = Platform.resolve(url);
- location = resolvedURL.getPath();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
-
- return location;
- }
-
-
- /*
- * Object used to hold components with the same name but different qualifiers.
- * This object will contain a list of XMLComponentSpecifications (with the same
- * names but different qualifiers).
- */
- public class XMLComponentTreeObject {
- private String name;
- private List xmlComponentSpecifications;
-
- public XMLComponentTreeObject(XMLComponentSpecification spec) {
- xmlComponentSpecifications = new ArrayList();
- xmlComponentSpecifications.add(spec);
- name = (String) spec.getAttributeInfo("name");
- }
-
- public String getName() {
- return name;
- }
-
- public void addXMLComponentSpecification(XMLComponentSpecification spec) {
- xmlComponentSpecifications.add(spec);
- }
-
- public List getXMLComponentSpecification() {
- return xmlComponentSpecifications;
- }
- }
-
- /*
- * Used to provide labels to the ComponentSeletionDialog
- */
- public class XMLComponentSelectionLabelProvider extends LabelProvider {
- public String getText(Object element) {
- XMLComponentTreeObject specification = (XMLComponentTreeObject) element;
- return specification.getName();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java
deleted file mode 100644
index 04c2546485..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLComponentSpecification.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xml;
-
-import java.util.Hashtable;
-
-/*
- * Simple class which keeps track of attribute information.
- * This class is basically a Hashtable with convenience methods.
- */
-public class XMLComponentSpecification {
- String tagPath;
- Hashtable hashtable;
- String targetNamespace;
- String fileLocation;
-
- public XMLComponentSpecification(String path) {
- this.tagPath = path;
- hashtable = new Hashtable();
- }
-
- public void addAttributeInfo(Object attribute, Object value) {
- hashtable.put(attribute, value);
- }
-
- public Object getAttributeInfo(Object attribute) {
- return hashtable.get(attribute);
- }
-
- public String getTagPath() {
- return tagPath;
- }
-
- public String getTargetNamespace() {
- return targetNamespace;
- }
-
- public void setTargetNamespace(String tns) {
- targetNamespace = tns;
- }
-
- public String getFileLocation() {
- return fileLocation;
- }
-
- public void setFileLocation(String location) {
- fileLocation = location;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java
deleted file mode 100644
index 30409c23d9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xml/XMLQuickScan.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- *
- */
-public class XMLQuickScan {
-
- /*
- * Returns information about matches encountered
- * based on the criteria provided.
- */
- public static List getTagInfo(String fullFilePath, List paths, List attributes) {
- XSDGlobalElementTypeContentHandler handler = new XSDGlobalElementTypeContentHandler();
- handler.stringTagPaths = paths;
- handler.searchAttributes = attributes;
- handler.fileLocation = fullFilePath;
-
- ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
-
- try {
- IPath path = new Path(fullFilePath);
- FileInputStream inputStream = new FileInputStream(new File(path.toOSString()));
-
-
-// SAXParser sparser = SAXParserFactory.newInstance().newSAXParser();
-// XMLReader reader = sparser.getXMLReader();
-
- // Line below is a hack to get XMLReader working
- Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader());
-
- XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
- reader.setContentHandler(handler);
- reader.parse(new InputSource(inputStream));
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- Thread.currentThread().setContextClassLoader(prevClassLoader);
- }
- return handler.getSearchAttributeValues();
- }
-
- public static class XSDGlobalElementTypeContentHandler extends DefaultHandler {
- protected List stringTagPaths;
- protected List searchAttributes;
- private List matchingTags = new ArrayList();
- private String targetNamespace = "";
- private String fileLocation;
-
- StringBuffer currentPath = new StringBuffer();
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- currentPath.append("/" + localName);
-
- // Search for targetNamespace if we haven't encountered it yet.
- if (targetNamespace.equals("")) {
- int nAttributes = attributes.getLength();
- for (int i = 0; i < nAttributes; i++)
- {
- if (attributes.getLocalName(i).equals("targetNamespace"))
- {
- targetNamespace = attributes.getValue(i);
- break;
- }
- }
- }
-
- // Search for the path
- for (int index = 0; index < stringTagPaths.size(); index++) {
- String path = (String) stringTagPaths.get(index);
- if (currentPath.length() == path.length() && currentPath.toString().equals(path)) {
- // Found a path match
- createTagInfo(attributes, (String[]) searchAttributes.get(index));
- }
- }
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- int slashIndex = currentPath.lastIndexOf("/");
- currentPath.delete(slashIndex, currentPath.length());
- }
-
- /*
- * Information about a tag is stored in a TagInfo class.
- */
- private void createTagInfo(Attributes attributes, String[] attributesToSearch) {
- XMLComponentSpecification spec = new XMLComponentSpecification(currentPath.toString());
-
-// tagInfo.addAttributeInfo("name", attributes.getValue("name"));
- for (int index = 0; index < attributesToSearch.length; index++) {
- String attrString = (String) attributesToSearch[index];
- String value = attributes.getValue(attrString);
- if (value != null) {
- spec.addAttributeInfo(attrString, value);
- }
- }
- spec.setTargetNamespace(targetNamespace);
- spec.setFileLocation(fileLocation);
- matchingTags.add(spec);
- }
-
- public List getSearchAttributeValues() {
- return matchingTags;
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java
deleted file mode 100644
index 7f9fc7d20b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentFinder.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xsd;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentFinder;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLQuickScan;
-
-public class XSDComponentFinder extends XMLComponentFinder {
- public XSDComponentFinder() {
- validExtensions.add("xsd");
- }
-
- public List getWorkbenchResourceComponents(int scope) {
- List components = new ArrayList();
- List filePaths = new ArrayList();
-
- // We don't want to search through the current file we're working on.
- if (currentIFile != null) {
- excludeFiles.add(currentIFile.getLocation().toOSString());
- }
-
- // Find files matching the search criteria specified in List extensions and
- // List excludeFiles.
- switch (scope) {
- case ENCLOSING_PROJECT_SCOPE:
- filePaths = getEnclosingProjectFiles();
- break;
-
- case ENTIRE_WORKSPACE_SCOPE:
- filePaths = getWorkspaceFiles();
- break;
-
- default:
- break;
- }
-
- // Search for the components in each of the files specified in the path.
- List paths = new ArrayList();
- paths.add("/schema/complexType");
- paths.add("/schema/simpleType");
-
- List attributes = new ArrayList();
- String[] nameAttr = new String[1];
- nameAttr[0] = "name";
- attributes.add(nameAttr);
- attributes.add(nameAttr);
-
- Iterator pathsIterator = filePaths.iterator();
- while (pathsIterator.hasNext()) {
-// String stringPath = ((Path) pathsIterator.next()).toOSString();
- String stringPath = ((Path) pathsIterator.next()).toString();
- components.addAll(XMLQuickScan.getTagInfo(stringPath, paths, attributes));
- }
-
- return components;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionDialog.java
deleted file mode 100644
index b66e13c777..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionDialog.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xsd;
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionDialog;
-
-public class XSDComponentSelectionDialog extends XMLComponentSelectionDialog {
-
- public static final int ELEMENT = 1;
- public static final int TYPE = 2;
-
- public XSDComponentSelectionDialog(Shell shell, String dialogTitle,
- IComponentSelectionProvider provider) {
- super(shell, dialogTitle, provider);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java
deleted file mode 100644
index d1936d485a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDComponentSelectionProvider.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xsd;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.common.IComponentList;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentFinder;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.impl.XSDImportImpl;
-import org.eclipse.xsd.util.XSDConstants;
-
-/*
- *
- */
-public class XSDComponentSelectionProvider extends XMLComponentSelectionProvider {
- private XSDComponentFinder xsdComponentFinder;
- private XSDComponentSelectionDialog dialog;
- private XSDSchema schema;
- private XSDComponentLabelProvider labelProvider;
-
- private boolean showComplexTypes = true;
-
- /*
- * Takes in the IFile we are currently editing.
- */
- public XSDComponentSelectionProvider(IFile file, XSDSchema schema) {
- xsdComponentFinder = new XSDComponentFinder();
- xsdComponentFinder.setFile(file);
- this.schema = schema;
- labelProvider = new XSDComponentLabelProvider();
- }
-
- public void setDialog(XSDComponentSelectionDialog dialog) {
- this.dialog = dialog;
- }
-
- public void showComplexTypes(boolean show) {
- showComplexTypes = show;
- }
-
- public String getType(Object element) {
- return null;
- }
-
- /*
- * The return value is a List of XMLComponentTreeObjects.
- *
- */
- public void getComponents(IComponentList list, boolean quick) {
- if (quick) {
- // Populate IComponentList list with components most easily accessible (fastest)
- // Grab Built-In types
- Iterator builtInIt = getBuiltInTypes().iterator();
- while (builtInIt.hasNext()) {
- XMLComponentSpecification tagItem = (XMLComponentSpecification) builtInIt.next();
- addDataItemToTreeNode(list, tagItem);
- }
-
- // Create current Schema's complex and simple types
- createComplexTypes(list);
- createSimpleTypes(list);
- }
- else {
- getComponents(list);
- }
- }
-
- /*
- * TODO: Need to revisit how we build up our treeObject list....
- * And it's somewhat messy, clean this up.
- */
- private void getComponents(IComponentList list) {
- List extensions = new ArrayList();
- extensions.add("xsd");
-
- String scope = "";
- if (dialog != null) {
- scope = dialog.getSearchScope();
- }
-
- List comps = new ArrayList();
- if (scope.equals(XSDComponentSelectionDialog.SCOPE_ENCLOSING_PROJECT)) {
- comps = xsdComponentFinder.getWorkbenchResourceComponents(XMLComponentFinder.ENCLOSING_PROJECT_SCOPE);
- }
- else if (scope.equals(XSDComponentSelectionDialog.SCOPE_WORKSPACE)) {
- comps = xsdComponentFinder.getWorkbenchResourceComponents(XMLComponentFinder.ENTIRE_WORKSPACE_SCOPE);
- }
-
-// Group same item types together (simple/complex)
- List complex = new ArrayList();
- List simple = new ArrayList();
- Iterator itemsIterator = comps.iterator();
- while (itemsIterator.hasNext()) {
- XMLComponentSpecification tagItem = (XMLComponentSpecification) itemsIterator.next();
- if (tagItem.getTagPath().equals("/schema/complexType")) {
- complex.add(tagItem);
- }
- else if (tagItem.getTagPath().equals("/schema/simpleType")) {
- simple.add(tagItem);
- }
- }
-
- Iterator complexIt = complex.iterator();
- Iterator simpleIt = simple.iterator();
- if (showComplexTypes) {
- while (complexIt.hasNext()) {
- XMLComponentSpecification item = (XMLComponentSpecification) complexIt.next();
- addDataItemToTreeNode(list, item);
- }
- }
-
- while (simpleIt.hasNext()) {
- XMLComponentSpecification item = (XMLComponentSpecification) simpleIt.next();
- addDataItemToTreeNode(list, item);
- }
-
- // Create from imports, includes, and redefines
- createFromImport(list);
- createFromInclude(list);
- createFromRedefine(list);
- }
-
-////////////////////////////////////////////////////////////////////////////////
- private List getBuiltInTypes() {
- List items = new ArrayList();
- for (int i = 0; i < XSDDOMHelper.dataType.length; i++) {
- items.add(XSDDOMHelper.dataType[i][0]);
- }
- Iterator it = items.iterator();
-
- List builtInComponentSpecs = new ArrayList();
- while (it.hasNext()) {
- Object item = it.next();
- String itemString = item.toString();
-
- XMLComponentSpecification builtInTypeItem = new XMLComponentSpecification("BUILT_IN_SIMPLE_TYPE");
- builtInTypeItem.addAttributeInfo("name", itemString);
- builtInTypeItem.setTargetNamespace(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
-// String normalizedFile = getNormalizedLocation(schema.getSchemaLocation());
-// builtInTypeItem.setFileLocation(normalizedFile);
- builtInTypeItem.setFileLocation("Built-In");
-
- builtInComponentSpecs.add(builtInTypeItem);
- }
-
- return builtInComponentSpecs;
- }
-
- private void createComplexTypes(IComponentList treeObjectList) {
- TypesHelper typesHelper = new TypesHelper(schema);
- List complexTypes = typesHelper.getUserComplexTypes();
- createComplexSimpleTreeObject(treeObjectList, complexTypes, true);
- }
-
- private void createSimpleTypes(IComponentList treeObjectList) {
- TypesHelper typesHelper = new TypesHelper(schema);
- List complexTypes = typesHelper.getUserSimpleTypes();
- createComplexSimpleTreeObject(treeObjectList, complexTypes, true);
- }
-
-
- private void createFromImport(IComponentList treeObjectList) {
- Iterator imports = getXSDImports().iterator();
- while (imports.hasNext()) {
- XSDImport importItem = (XSDImport) imports.next();
- if (importItem.getSchemaLocation() != null) {
- ((XSDImportImpl) importItem).importSchema();
- TypesHelper helper = new TypesHelper(importItem.getResolvedSchema());
-
- List types = helper.getUserComplexTypes();
- types.addAll(helper.getUserSimpleTypes());
- createComplexSimpleTreeObject(treeObjectList, types, false);
- }
- }
- }
-
- private void createFromInclude(IComponentList treeObjectList) {
- Iterator imports = getXSDIncludes().iterator();
- while (imports.hasNext()) {
- XSDInclude includeItem = (XSDInclude) imports.next();
- if (includeItem.getSchemaLocation() != null) {
- TypesHelper helper = new TypesHelper(includeItem.getResolvedSchema());
-
- List types = helper.getUserComplexTypes();
- types.addAll(helper.getUserSimpleTypes());
- createComplexSimpleTreeObject(treeObjectList, types, false);
- }
- }
- }
-
- private void createFromRedefine(IComponentList treeObjectList) {
- Iterator redefines = getXSDRedefines().iterator();
- while (redefines.hasNext()) {
- XSDRedefine redefineItem = (XSDRedefine) redefines.next();
- if (redefineItem.getSchemaLocation() != null) {
- TypesHelper helper = new TypesHelper(redefineItem.getResolvedSchema());
-
- List types = helper.getUserComplexTypes();
- types.addAll(helper.getUserSimpleTypes());
- createComplexSimpleTreeObject(treeObjectList, types, false);
- }
- }
- }
-
- protected List getXSDImports() {
- List imports = new ArrayList();
-
- Iterator contents = schema.getContents().iterator();
- while (contents.hasNext()) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImport) {
- imports.add(content);
- }
- }
-
- return imports;
- }
-
- protected List getXSDIncludes() {
- List includes = new ArrayList();
-
- Iterator contents = schema.getContents().iterator();
- while (contents.hasNext()) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDInclude) {
- includes.add(content);
- }
- }
-
- return includes;
- }
-
- protected List getXSDRedefines() {
- List includes = new ArrayList();
-
- Iterator contents = schema.getContents().iterator();
- while (contents.hasNext()) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDRedefine) {
- includes.add(content);
- }
- }
-
- return includes;
- }
-
- private void createComplexSimpleTreeObject(IComponentList treeObjectList, List complexTypes, boolean sameNS) {
- boolean proceed = true;
-
- for (int i = 0; i < complexTypes.size(); i++) {
- XSDNamedComponent item = (XSDNamedComponent) complexTypes.get(i);
-
- if (sameNS) {
- // We do this check because Types from Includes might show up. However, we don't want to show them
- String itemLocation = item.getSchema().getSchemaLocation();
- String currentSchemaLocation = schema.getSchemaLocation();
- if (itemLocation != null) {
- proceed = itemLocation.equals(currentSchemaLocation);
- }
- else {
- proceed = false;
- }
- }
-
- if (proceed) {
- XMLComponentSpecification typeItem = null;
- if (showComplexTypes && item instanceof XSDComplexTypeDefinition) {
- typeItem = new XMLComponentSpecification("/schema/complexType");
- typeItem.addAttributeInfo("name", ((XSDComplexTypeDefinition) item).getName());
- }
- else if (item instanceof XSDSimpleTypeDefinition) {
- typeItem = new XMLComponentSpecification("/schema/simpleType");
- typeItem.addAttributeInfo("name", ((XSDSimpleTypeDefinition) item).getName());
- }
-
- if (typeItem != null) {
- typeItem.setTargetNamespace(item.getTargetNamespace());
- String normalizedFile = getNormalizedLocation(schema.getSchemaLocation());
- typeItem.setFileLocation(normalizedFile);
-
- addDataItemToTreeNode(treeObjectList, typeItem);
- }
- }
- }
- }
-
-
- public ILabelProvider getLabelProvider() {
- return labelProvider;
- }
-
-
- public class XSDComponentLabelProvider extends XMLComponentSelectionLabelProvider {
- public Image getImage(Object element) {
- XMLComponentTreeObject specification = (XMLComponentTreeObject) element;
- XMLComponentSpecification spec = (XMLComponentSpecification) specification.getXMLComponentSpecification().get(0);
- if (spec.getTagPath().equals("/schema/complexType")) {
- return XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif");
- }
- else if (spec.getTagPath().equals("/schema/simpleType")) {
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
- else if (spec.getTagPath().equals("BUILT_IN_SIMPLE_TYPE")) {
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
-
- return null;
- }
- }
-
-
-
- public String getListTitle() {
- return XSDEditorPlugin.getXSDString("_UI_LABEL_MATCHING_TYPES");
- }
-
- public String getNameFieldTitle() {
- return XSDEditorPlugin.getXSDString("_UI_LABEL_TYPE_NAME");
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java
deleted file mode 100644
index a5b8e170fa..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dialogs/types/xsd/XSDSetTypeHelper.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dialogs.types.xsd;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-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.dialogs.types.xml.XMLComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.XSDExternalFileCleanup;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.util.XSDConstants;
-import org.eclipse.xsd.util.XSDParser;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class XSDSetTypeHelper {
- private XSDSchema xsdSchema;
- private IFile currentIFile;
-
- public XSDSetTypeHelper(IFile iFile, XSDSchema schema) {
- currentIFile = iFile;
- xsdSchema = schema;
- }
-
- public void setType(Element element, String property, XMLComponentSpecification spec) {
- addImportIfNecessary(element, spec);
- String typeObject = getPrefixedTypeName(spec);
-
- // Get the previous type --> previousStringType
- String previousStringType = "";
- Attr attr = element.getAttributeNode(property);
- if (attr != null) {
- attr.getValue();
- }
-
- if (!XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- if (spec != null && spec.getTagPath().equals("**anonymous**"))
- {
- if (spec.getTagPath().equals("ANONYMOUS_SIMPLE_TYPE"))
- {
- if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- }
- else
- {
- if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- }
- // element.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- element.removeAttribute(property);
- }
- else
- {
- XSDDOMHelper.updateElementToNotAnonymous(element);
- //element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, typeObject.toString());
- element.setAttribute(property, typeObject.toString());
- }
- }
- }
-
- public void addImportIfNecessary(Element element, XMLComponentSpecification spec) {
-
- // Get the new type --> typeObject
- if (spec != null) {
- String itemType = spec.getTagPath();
-
- if (!itemType.equals("BUILT_IN_SIMPLE_TYPE")) {
- // Do an actual import if needed
- XSDParser parser = new XSDParser();
- parser.parse(spec.getFileLocation());
- XSDSchema schema = parser.getSchema();
- String tns = schema.getTargetNamespace();
-
- boolean exists = false;
- // Check if the type is defined in the 'current' file itself.
- String currentFile = getNormalizedLocation(xsdSchema.getSchemaLocation());
- IPath currentFilePath = new Path(currentFile);
- if (currentFilePath.equals(new Path(spec.getFileLocation()))) {
- exists = true;
- }
-
- if (!exists) {
- if (tns.equals(xsdSchema.getTargetNamespace())) {
- // Check if the schema is in a redefine/include
- List existingList = getXSDIncludes();
- existingList.addAll(getXSDRedefines());
- Iterator it = existingList.iterator();
- while (it.hasNext()) {
- XSDSchemaDirective existingSchema = (XSDSchemaDirective) it.next();
- String normalizedFile = getNormalizedLocation(existingSchema.getResolvedSchema().getSchemaLocation());
- String normalizedSpec = spec.getFileLocation();
-
- if (normalizedFile.equals(normalizedSpec)) {
- // Found and existing one
- exists = true;
- }
- }
- }
- else {
- // Check if the schema is in a import
- List existingList = getXSDImports();
- Iterator it = existingList.iterator();
- while (it.hasNext()) {
- XSDSchemaDirective existingSchema = (XSDSchemaDirective) it.next();
- String normalizedFile = getNormalizedLocation(existingSchema.getResolvedSchema().getSchemaLocation());
- String normalizedSpec = spec.getFileLocation();
-
- if (normalizedFile.equals(normalizedSpec)) {
- // Found and existing one
- exists = true;
- }
- }
- }
- }
-
- if (!exists) {
- doImport(spec.getFileLocation(), schema);
- }
- }
- }
- }
-
- /*
- * Return the prefixed type name for the type described by the given
- * XMLComponentSpecification object.
- * If the type described is a Built-in type, do not add the prefix
- */
- public String getPrefixedTypeName(XMLComponentSpecification spec) {
- String typeObject = (String) spec.getAttributeInfo("name");
-
- TypesHelper typesHelper = new TypesHelper(xsdSchema); // ???? Is this correct?
- List prefixedNames = typesHelper.getPrefixedNames(spec.getTargetNamespace(), typeObject);
- if (prefixedNames.size() > 0) {
- // Grab the first prefixed name
- typeObject = (String) prefixedNames.get(0);
- }
-
- return typeObject;
- }
-
- private void updateElementToAnonymous(Element element, String xsdType) {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- XSDDOMHelper.updateElementToNotAnonymous(element);
- Element childNode = null;
- if (xsdType.equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG)) {
- childNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG)) {
- childNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
-
- if (childNode != null) {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node annotationNode = helper.getChildNode(element, XSDConstants.ANNOTATION_ELEMENT_TAG);
- if (annotationNode == null) {
- Node firstChild = element.getFirstChild();
- element.insertBefore(childNode, firstChild);
- } else {
- Node nextSibling = annotationNode.getNextSibling();
- element.insertBefore(childNode, nextSibling);
- }
- XSDDOMHelper.formatChild(childNode);
- }
- }
-
- // TODO: We shouldn't need to pass in IPath externalSchemaPath.
- private void doImport(String externalSchemaPath, XSDSchema externalSchema) {
- // Determine schemaLocation
- String locationAttribute = URIHelper.getRelativeURI(externalSchemaPath, currentIFile.getLocation().toOSString());
-
- boolean isInclude = false;
- if (externalSchema.getTargetNamespace().equals(xsdSchema.getTargetNamespace())) {
- isInclude = true;
- }
-
- if (externalSchema != null) { // In case we have problems loading the file.... we should display an error message.
- Element newElement;
- if (isInclude) {
- List attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, locationAttribute));
- newElement = createElement(XSDConstants.INCLUDE_ELEMENT_TAG, attributes);
- }
- else if (!isInclude) {
- List attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAMESPACE_ATTRIBUTE, externalSchema.getTargetNamespace()));
- attributes.add(new DOMAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, locationAttribute));
- newElement = createElement(XSDConstants.IMPORT_ELEMENT_TAG, attributes);
- handleImportNS(newElement, externalSchema);
- }
- }
- }
-
- private void handleImportNS(Element importElement, XSDSchema externalSchema) {
- String namespace = externalSchema.getTargetNamespace();
- if (namespace == null) namespace = "";
-
- XSDImport xsdImport = (XSDImport) xsdSchema.getCorrespondingComponent(importElement);
- xsdImport.setResolvedSchema(externalSchema);
-
- java.util.Map map = xsdSchema.getQNamePrefixToNamespaceMap();
-
-// System.out.println("changed Import Map is " + map.values());
-// System.out.println("changed import Map keys are " + map.keySet());
-
- // 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);
- }
- }
-
-
-// System.out.println("changed Import Map is " + map.values());
-// System.out.println("changed import Map keys are " + map.keySet());
- }
-
- private Element createElement(String elementTag, List attributes) {
- Node relativeNode = XSDDOMHelper.getNextElementNode(xsdSchema.getElement().getFirstChild());
-
- CreateElementAction action = new CreateElementAction("");
- action.setElementTag(elementTag);
- action.setAttributes(attributes);
- action.setParentNode(xsdSchema.getElement());
- action.setRelativeNode(relativeNode);
- action.setXSDSchema(xsdSchema);
- return action.createAndAddNewChildElement();
- }
-
- private String getNormalizedLocation(String location) {
- try {
- URL url = new URL(location);
- URL resolvedURL = Platform.resolve(url);
- location = resolvedURL.getPath();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
-
- return location;
- }
-
- private List getXSDImports() {
- List imports = new ArrayList();
-
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext()) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImport) {
- imports.add(content);
- }
- }
-
- return imports;
- }
-
- private List getXSDIncludes() {
- List includes = new ArrayList();
-
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext()) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDInclude) {
- includes.add(content);
- }
- }
-
- return includes;
- }
-
- private List getXSDRedefines() {
- List includes = new ArrayList();
-
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext()) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDRedefine) {
- includes.add(content);
- }
- }
-
- return includes;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/BaseDragNodesCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/BaseDragNodesCommand.java
deleted file mode 100644
index d83fc478aa..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/BaseDragNodesCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dnd;
-
-import java.util.Collection;
-
-import org.eclipse.wst.common.ui.internal.dnd.DefaultDragAndDropCommand;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Node;
-
-
-public abstract class BaseDragNodesCommand extends DefaultDragAndDropCommand
-{
- /**
- * Constructor for BaseDragNodesCommand.
- * @param target
- * @param location
- * @param operations
- * @param operation
- * @param sources
- */
- public BaseDragNodesCommand(
- Object target,
- float location,
- int operations,
- int operation,
- Collection sources)
- {
- super(target, location, operations, operation, sources);
- }
-
- protected boolean isDirectSchemaChild(Node node)
- {
- Node parent = node.getParentNode();
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false) &&
- parent.getParentNode().equals(parent.getOwnerDocument()))
- {
- return true;
- }
- return false;
- }
-
- protected boolean isSiblingNodes(Node first, Node second)
- {
- if (first.getParentNode() != null)
- {
- return first.getParentNode().equals(second.getParentNode());
- }
- return false;
- }
-
- protected void beginRecording()
- {
- if (target != null)
- {
- IDOMModel model = getModel((Node)target);
-
- if (model != null)
- {
- model.beginRecording(this, XSDEditorPlugin.getXSDString("_UI_LABEL_MOVE"));
- }
- }
- }
-
- protected void endRecording()
- {
- if (target != null)
- {
- IDOMModel model = getModel((Node)target);
-
- if (model != null)
- {
- model.endRecording(this);
- }
- }
- }
- protected IDOMModel getModel(Node node)
- {
- Object object = node.getOwnerDocument();
- if (object instanceof DocumentImpl)
- {
- return ((DocumentImpl) object).getModel();
- }
- return null;
- }
-
- protected void moveNode(Node referenceNode, Node nodeToMove, boolean isBefore)
- {
- XSDDOMHelper.moveNode(referenceNode, nodeToMove, isBefore);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/DragNodesCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/DragNodesCommand.java
deleted file mode 100644
index fa0d0b9a79..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/DragNodesCommand.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dnd;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.format.NodeFormatter;
-import org.w3c.dom.Node;
-
-public class DragNodesCommand extends BaseDragNodesCommand
-{
- /**
- * Constructor for DragNodesCommand.
- * @param target
- * @param location
- * @param operations
- * @param operation
- * @param sources
- */
- public DragNodesCommand(
- Object target,
- float location,
- int operations,
- int operation,
- Collection sources)
- {
- super(target, location, operations, operation, sources);
- }
-
- /**
- * @see org.eclipse.wst.common.ui.internal.dnd.DragAndDropCommand#canExecute()
- */
- public boolean canExecute()
- {
- if (sources.size() > 0)
- {
- Node firstSource = (Node) sources.toArray()[0];
- return isSiblingNodes((Node) target, firstSource);
- }
- return false;
-// return isDirectSchemaChild((Node)target);
- }
-
-
- /**
- * @see org.eclipse.wst.common.ui.internal.dnd.DragAndDropCommand#execute()
- */
- public void execute()
- {
- NodeFormatter formatProcessor = new NodeFormatter();
- Node referenceNode = (Node) target;
- Iterator iter = sources.iterator();
- beginRecording();
-
- while (iter.hasNext())
- {
- Node node = (Node) iter.next();
- if (isSiblingNodes(referenceNode,node))
- {
- moveNode(referenceNode, node, !isAfter());
- formatProcessor.format((IDOMNode)node);
- }
- }
-// formatProcessor.format((XMLNode)referenceNode.getParentNode());
- endRecording();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/XSDDragAndDropManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/XSDDragAndDropManager.java
deleted file mode 100644
index 7c52cc947c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/dnd/XSDDragAndDropManager.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.dnd;
-
-import java.util.Collection;
-
-import org.eclipse.wst.common.ui.internal.dnd.DragAndDropCommand;
-import org.eclipse.wst.common.ui.internal.dnd.DragAndDropManager;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Node;
-
-public class XSDDragAndDropManager implements DragAndDropManager
-{
- /**
- * Constructor for XSDDragAndDropManager.
- */
- public XSDDragAndDropManager()
- {
- }
-
- protected boolean isDirectSchemaChild(Node node)
- {
- Node parent = node.getParentNode();
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SCHEMA_ELEMENT_TAG, false) &&
- parent.getParentNode().equals(parent.getOwnerDocument()))
- {
- return true;
- }
- return false;
- }
-
- /**
- * @see org.eclipse.wst.common.ui.internal.dnd.DragAndDropManager#createCommand(Object, float, int, int, Collection)
- */
- public DragAndDropCommand createCommand(
- Object target,
- float location,
- int operations,
- int operation,
- Collection source)
- {
- if (target instanceof Node)
- {
- return new DragNodesCommand(target, location, operations, operation, source);
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/editparts/AbstractComponentViewerRootEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/editparts/AbstractComponentViewerRootEditPart.java
deleted file mode 100644
index caef3974c8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/editparts/AbstractComponentViewerRootEditPart.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Panel;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ContainerLayout;
-
-
-public abstract class AbstractComponentViewerRootEditPart extends AbstractGraphicalEditPart
-{
- protected final static String MESSAGE_PLACE_HOLDER = "MESSAGE_PLACE_HOLDER";
- protected Object input;
-
- public void setInput(Object input)
- {
- this.input = input;
- refreshChildren();
- }
-
- protected IFigure createFigure()
- {
- Panel panel = new Panel();
- ContainerLayout layout = new ContainerLayout();
- layout.setBorder(60);
- panel.setLayoutManager(layout);
- return panel;
- }
-
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- if (input != null)
- {
- list.add(input);
- }
- else
- {
- list.add(MESSAGE_PLACE_HOLDER);
- }
- return list;
- }
-
- protected abstract EditPart createChild(Object model);
-
- protected void createEditPolicies()
- {
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectedEditPartFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectedEditPartFigure.java
deleted file mode 100644
index f25f67787d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectedEditPartFigure.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-
-
-public class ConnectedEditPartFigure extends ContainerFigure implements IConnectedEditPartFigure
-{
- protected EditPart editPart;
- protected boolean childConnectionsEnabled = true;
- protected List connectedFigures = new ArrayList();
- protected int connectionType = RIGHT_CONNECTION;
-
- public ConnectedEditPartFigure(EditPart editPart)
- {
- this.editPart = editPart;
- }
-
- public void setChildConnectionsEnabled(boolean enabled)
- {
- childConnectionsEnabled = enabled;
- }
-
- protected IConnectedEditPartFigure getParentGraphNodeFigure()
- {
- IConnectedEditPartFigure result = null;
- for (EditPart parentEditPart = editPart.getParent(); parentEditPart != null; parentEditPart = parentEditPart.getParent())
- {
- IFigure figure = ((AbstractGraphicalEditPart)parentEditPart).getFigure();
- if (figure instanceof IConnectedEditPartFigure)
- {
- IConnectedEditPartFigure graphNodeFigure = (IConnectedEditPartFigure)figure;
- if (graphNodeFigure.getConnectionFigure() != null)
- {
- result = graphNodeFigure;
- break;
- }
- }
- }
- return result;
- }
-
- public void addNotify()
- {
- super.addNotify();
- if (getConnectionFigure() != null)
- {
- IConnectedEditPartFigure parentGraphNodeFigure = getParentGraphNodeFigure();
- if (parentGraphNodeFigure != null)
- {
- parentGraphNodeFigure.addConnectedFigure(this);
- }
- }
- }
-
- public void removeNotify()
- {
- super.removeNotify();
- if (getConnectionFigure() != null)
- {
- IConnectedEditPartFigure parentGraphNodeFigure = getParentGraphNodeFigure();
- if (parentGraphNodeFigure != null)
- {
- parentGraphNodeFigure.removeConnectedFigure(this);
- }
- }
- }
-
- public void addConnectedFigure(IConnectedEditPartFigure figure)
- {
- if (childConnectionsEnabled)
- {
- // this test is required since we sometimes receive the 'addNotify' call twice
- //
- if (!connectedFigures.contains(figure))
- {
- connectedFigures.add(figure);
- }
- }
- }
-
- public void removeConnectedFigure(IConnectedEditPartFigure figure)
- {
- if (childConnectionsEnabled)
- {
- connectedFigures.remove(figure);
- }
- }
-
- public IFigure getSelectionFigure()
- {
- return this;
- }
-
- public IFigure getConnectionFigure()
- {
- return this;
- }
-
- public List getConnectedFigures(int type)
- {
- List list = new ArrayList();
- for (Iterator i = connectedFigures.iterator(); i.hasNext(); )
- {
- IConnectedEditPartFigure figure = (IConnectedEditPartFigure)i.next();
- //if (type == 0 || type == figure.getConnectionType())
- {
- list.add(figure);
- }
- }
- return list;
- }
-
- public int getConnectionType()
- {
- return connectionType;
- }
-
- public void setConnectionType(int type)
- {
- connectionType = type;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectionRenderingFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectionRenderingFigure.java
deleted file mode 100644
index 7192108cd9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ConnectionRenderingFigure.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-
-
-public class ConnectionRenderingFigure extends RectangleFigure
-{
- protected boolean isOutlined = true;
- protected IFigure primaryLayer;
-
- public ConnectionRenderingFigure(IFigure primaryLayer)
- {
- setOpaque(false);
- this.primaryLayer = primaryLayer;
- //setFocusTraversable(false);
- //setEnabled(false);
- }
-
- protected boolean isMouseEventTarget()
- {
- return false;
- }
-
- public boolean containsPoint(int x, int y)
- {
- return false;
- }
-
- protected void fillShape(Graphics graphics)
- {
- graphics.setForegroundColor(ColorConstants.black);
- drawLines(graphics, primaryLayer);
- }
-
- protected void outlineShape(Graphics graphics)
- {
- if (isOutlined)
- {
- super.outlineShape(graphics);
- }
- }
-
- protected void drawLines(Graphics graphics, IFigure figure)
- {
- if (figure instanceof IConnectedEditPartFigure)
- {
- IConnectedEditPartFigure graphNodeFigure = (IConnectedEditPartFigure)figure;
- List connectedFigures = graphNodeFigure.getConnectedFigures(IConnectedEditPartFigure.RIGHT_CONNECTION);
- int connectedFiguresSize = connectedFigures.size();
-
- if (connectedFiguresSize > 0)
- {
- IConnectedEditPartFigure firstGraphNodeFigure = (IConnectedEditPartFigure)connectedFigures.get(0);
- Rectangle r = graphNodeFigure.getConnectionFigure().getBounds();
-
- int x1 = r.x + r.width;
- int y1 = r.y + r.height/2;
-
- int startOfChildBox = firstGraphNodeFigure.getConnectionFigure().getBounds().x;
- int x2 = x1 + (startOfChildBox - x1) / 3;
- int y2 = y1;
-
- if (connectedFiguresSize == 1)
- {
- graphics.drawLine(x1, y1, startOfChildBox, y2);
- }
- else // (connectedFigures.length > 1)
- {
- graphics.drawLine(x1, y1, x2, y2);
-
- int minY = Integer.MAX_VALUE;
- int maxY = -1;
-
- for (Iterator i = connectedFigures.iterator(); i.hasNext(); )
- {
- IConnectedEditPartFigure connectedFigure = (IConnectedEditPartFigure)i.next();
- Rectangle childConnectionRectangle = connectedFigure.getConnectionFigure().getBounds();
- int y = childConnectionRectangle.y + childConnectionRectangle.height / 2;
- minY = Math.min(minY, y);
- maxY = Math.max(maxY, y);
- graphics.drawLine(x2, y, childConnectionRectangle.x, y);
- }
- graphics.drawLine(x2, minY, x2, maxY);
- }
- }
- }
-
- //boolean visitChildren = true;
- List children = figure.getChildren();
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- drawLines(graphics, child);
- }
- }
-
- // This method supports the preview connection line function related to drag and drop
- //
- public PointList getConnectionPoints(GraphicalEditPart parentEditPart, GraphicalEditPart childRefEditPart, Rectangle draggedFigureBounds)
- {
- PointList pointList = new PointList();
- int[] data = new int[1];
- Point a = getConnectionPoint(parentEditPart, childRefEditPart, data);
- if (a != null)
- {
- int draggedFigureBoundsY = draggedFigureBounds.y + draggedFigureBounds.height/2;
-
- pointList.addPoint(a);
- //pointList.addPoint(new Point(draggedFigureBounds.x, draggedFigureBoundsY));
-
- if (data[0] == 0) // insert between 2 items
- {
- int x = a.x + (draggedFigureBounds.x - a.x)/2;
- pointList.addPoint(new Point(x, a.y));
- pointList.addPoint(new Point(x, draggedFigureBoundsY));
- pointList.addPoint(new Point(draggedFigureBounds.x, draggedFigureBoundsY));
- }
- else // insert at first or last position
- {
- pointList.addPoint(new Point(a.x, draggedFigureBoundsY));
- pointList.addPoint(new Point(draggedFigureBounds.x, draggedFigureBoundsY));
- }
- }
- return pointList;
- }
-
-
- // This method supports the preview connection line function related to drag and drop
- //
- protected Point getConnectionPoint(GraphicalEditPart parentEditPart, GraphicalEditPart childRefEditPart, int[] data)
- {
- Point point = null;
- List childList = parentEditPart.getChildren();
-
- if (parentEditPart.getFigure() instanceof IConnectedEditPartFigure && childList.size() > 0)
- {
- point = new Point();
-
- GraphicalEditPart prev = null;
- GraphicalEditPart next = null;
-
- for (Iterator i = childList.iterator(); i.hasNext(); )
- {
- Object o = i.next();
- if (o instanceof GraphicalEditPart)
- {
- GraphicalEditPart childEditPart = (GraphicalEditPart)o;
- if (childEditPart.getFigure() instanceof IConnectedEditPartFigure)
- {
- if (childEditPart == childRefEditPart)
- {
- next = childEditPart;
- break;
- }
- prev = childEditPart;
- }
- }
- }
-
-
- if (next != null && prev != null)
- {
- int ya = getConnectedEditPartConnectionBounds(prev).getCenter().y;
- int yb = getConnectedEditPartConnectionBounds(next).getCenter().y;
- point.y = ya + (yb - ya)/2;
- data[0] = 0;
- }
- else if (prev != null) // add it last
- {
- point.y = getConnectedEditPartConnectionBounds(prev).getCenter().y;
- data[0] = 1;
- }
- else if (next != null) // add it first!
- {
- point.y = getConnectedEditPartConnectionBounds(next).getCenter().y;
- data[0] = -1;
- }
-
- if (next != null || prev != null)
- {
- GraphicalEditPart child = prev != null ? prev : next;
- int startOfChildBox = getConnectedEditPartConnectionBounds(child).x;
- Rectangle r = getConnectedEditPartConnectionBounds(parentEditPart);
- int x1 = r.x + r.width;
- point.x = x1 + (startOfChildBox - x1) / 3;
- }
- }
- return point;
- }
-
- protected Rectangle getConnectedEditPartConnectionBounds(GraphicalEditPart editPart)
- {
- return ((IConnectedEditPartFigure)editPart.getFigure()).getConnectionFigure().getBounds();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerFigure.java
deleted file mode 100644
index d7a77ac685..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerFigure.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.RectangleFigure;
-
-public class ContainerFigure extends RectangleFigure implements IExpandable
-{
- protected boolean isOutlined = false;
- protected boolean isExpanded = true;
-
- public ContainerFigure()
- {
- setLayoutManager(new ContainerLayout());
- setFill(false);
- }
-
- public void doLayout()
- {
- layout();
- setValid(true);
- }
-
- public ContainerLayout getContainerLayout()
- {
- return (ContainerLayout)getLayoutManager();
- }
-
- public void setOutlined(boolean isOutlined)
- {
- this.isOutlined = isOutlined;
- }
-
- protected void outlineShape(Graphics graphics)
- {
- if (isOutlined)
- {
- super.outlineShape(graphics);
- }
- }
-
- public boolean isExpanded()
- {
- return isExpanded;
- }
-
- public void setExpanded(boolean isExpanded)
- {
- this.isExpanded = isExpanded;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerLayout.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerLayout.java
deleted file mode 100644
index 78480f9566..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/ContainerLayout.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import java.util.List;
-
-import org.eclipse.draw2d.AbstractLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-public class ContainerLayout extends AbstractLayout
-{
- protected boolean isHorizontal;
- protected int spacing = 0;
- protected int border = 0;
-
- public ContainerLayout()
- {
- this(true, 0);
- }
-
- public ContainerLayout(boolean isHorizontal, int spacing)
- {
- this.isHorizontal = isHorizontal;
- this.spacing = spacing;
- }
-
- public void setHorizontal(boolean isHorizontal)
- {
- this.isHorizontal = isHorizontal;
- }
-
- public void setSpacing(int spacing)
- {
- this.spacing = spacing;
- }
-
- public void setBorder(int border)
- {
- this.border = border;
- }
-
- protected int alignFigure(IFigure parent, IFigure child)
- {
- return -1;
- }
-
- /**
- * Calculates and returns the preferred size of the container
- * given as input.
- *
- * @param figure Figure whose preferred size is required.
- * @return The preferred size of the passed Figure.
- */
- protected Dimension calculatePreferredSizeHelper(IFigure parent)
- {
- Dimension preferred = new Dimension();
- List children = parent.getChildren();
-
- for (int i=0; i < children.size(); i++)
- {
- IFigure child = (IFigure)children.get(i);
-
- Dimension childSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- preferred.width += childSize.width;
- preferred.height = Math.max(preferred.height, childSize.height);
- }
- else
- {
- preferred.height += childSize.height;
- preferred.width = Math.max(preferred.width, childSize.width);
- }
- }
-
- int childrenSize = children.size();
- if (childrenSize > 1)
- {
- if (isHorizontal)
- {
- preferred.width += spacing * (childrenSize - 1);
- }
- else
- {
- preferred.height += spacing * (childrenSize - 1);
- }
- }
-
- preferred.width += border * 2;
- preferred.height += border * 2;
- preferred.width += parent.getInsets().getWidth();
- preferred.height += parent.getInsets().getHeight();
-
- return preferred;
- }
-
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension preferred = null;
-
- // Here we ensure that an unexpanded container is given a size of (0,0)
- //
- if (parent instanceof IExpandable)
- {
- IExpandable expandableFigure = (IExpandable)parent;
- if (!expandableFigure.isExpanded())
- {
- preferred = new Dimension();
- }
- }
-
- if (preferred == null)
- {
- preferred = calculatePreferredSizeHelper(parent);
- }
-
- return preferred;
- }
-
-
- protected void adjustLayoutLocation(IFigure parent, Dimension dimension)
- {
- }
-
- public void layout(IFigure parent)
- {
- List children = parent.getChildren();
-
- int rx = 0;
- Dimension dimension = new Dimension();
-
-
- for (int i=0; i < children.size(); i++)
- {
- IFigure child = (IFigure)children.get(i);
- Dimension childSize = child.getPreferredSize();
- if (isHorizontal)
- {
- dimension.height = Math.max(dimension.height, childSize.height);
- rx += childSize.width;
- }
- else
- {
- dimension.width = Math.max(dimension.width, childSize.width);
- }
- }
-
- //dimension.width += parent.getInsets().left;
- //dimension.height += parent.getInsets().top;
-
- if (isHorizontal)
- {
- dimension.height += border*2;
- dimension.width += border;
- }
- else
- {
- dimension.width += border*2;
- dimension.height += border;
- }
- adjustLayoutLocation(parent, dimension);
-
- for (int i=0; i < children.size(); i++)
- {
- IFigure child = (IFigure)children.get(i);
- Dimension childSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- int y = -1;
-
- y = alignFigure(parent, child);
-
- if (y == -1)
- {
- y = (dimension.height - childSize.height) / 2;
- }
-
- Rectangle rectangle = new Rectangle(dimension.width, y, childSize.width, childSize.height);
- rectangle.translate(parent.getClientArea().getLocation());
-
-
- child.setBounds(rectangle);
- dimension.width += childSize.width;
- dimension.width += spacing;
-
- if (child instanceof SpacingFigure)
- {
- int availableHorizontalSpace = parent.getClientArea().width - rx;
- dimension.width += availableHorizontalSpace;
- }
- }
- else
- {
- Rectangle rectangle = new Rectangle(0, dimension.height, childSize.width, childSize.height);
- rectangle.translate(parent.getClientArea().getLocation());
-
-
- child.setBounds(rectangle);
- dimension.height += childSize.height;
- dimension.height += spacing;
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/FillLayout.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/FillLayout.java
deleted file mode 100644
index 9f3de7c503..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/FillLayout.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.AbstractLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-public class FillLayout extends AbstractLayout
-{
- protected boolean isHorizontal = false;
- protected int spacing = 0;
- public Dimension min;
-
- public FillLayout(){}
-
- public FillLayout(int spacing)
- {
- this.spacing = spacing;
- }
-
- public void setHorizontal(boolean isHorizontal)
- {
- this.isHorizontal = isHorizontal;
- }
-
- /**
- * Calculates and returns the preferred size of the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- *
- * @param figure Container figure for which preferred size is required.
- * @return The preferred size of the input figure.
- */
-
- protected Dimension calculatePreferredSize(IFigure figure, int width, int height)
- {
- Dimension d = calculatePreferredClientAreaSize(figure);
- d.expand(figure.getInsets().getWidth(),
- figure.getInsets().getHeight());
- d.union(getBorderPreferredSize(figure));
- return d;
- }
-
- protected Dimension calculatePreferredClientAreaSize(IFigure figure)
- {
- Dimension d = new Dimension();
- List children = figure.getChildren();
-
-
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- Dimension childSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- d.width += childSize.width;
- d.height = Math.max(childSize.height, d.height);
- }
- else
- {
- d.height += childSize.height;
- d.width = Math.max(childSize.width, d.width);
- }
- }
-
-
- int childrenSize = children.size();
- if (childrenSize > 0)
- {
- if (isHorizontal)
- {
- d.width += spacing * (childrenSize - 1);
- }
- else
- {
- d.height += spacing * (childrenSize - 1);
- }
- }
-
- if (min != null)
- {
- d.width = Math.max(d.width, min.width);
- d.height = Math.max(d.height, min.height);
- }
- return d;
- }
-
- /*
- * Returns the minimum size required by the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- */
- public Dimension getMinimumSize(IFigure figure, int width, int height)
- {
- Dimension d = new Dimension();
- List children = figure.getChildren();
- IFigure child;
-
- for (int i=0; i < children.size(); i++)
- {
- child = (IFigure)children.get(i);
- d.union(child.getMinimumSize());
- }
- d.expand(figure.getInsets().getWidth(),
- figure.getInsets().getHeight());
- return d;
- }
-
- public Dimension getPreferredSize(IFigure figure, int width, int height)
- {
- return calculatePreferredSize(figure, width, height);
- }
-
- /*
- * Lays out the children on top of each other with
- * their sizes equal to that of the available
- * paintable area of the input container figure.
- */
- public void layout(IFigure figure)
- {
- Dimension preferredSize = calculatePreferredClientAreaSize(figure);
- Rectangle r = figure.getClientArea().getCopy();
- List children = figure.getChildren();
-
- int nChildren = children.size();
- int extraHorizontalSpace = r.width - preferredSize.width;
-
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- Dimension preferredChildSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- int w = preferredChildSize.width + (extraHorizontalSpace / nChildren);
- child.setBounds(new Rectangle(r.x, r.y, w, Math.max(preferredSize.height, r.height)));
- r.x += w + spacing;
- }
- else
- {
- child.setBounds(new Rectangle(r.x, r.y, Math.max(preferredSize.width, r.width), preferredChildSize.height));
- r.y += preferredChildSize.height + spacing;
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedEditPartFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedEditPartFigure.java
deleted file mode 100644
index 4c778d7e20..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedEditPartFigure.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-
-public interface IConnectedEditPartFigure extends IConnectedFigure
-{
- public static final int UP_CONNECTION = 1;
- public static final int DOWN_CONNECTION = 2;
- public static final int LEFT_CONNECTION = 3;
- public static final int RIGHT_CONNECTION = 4;
-
- public IFigure getSelectionFigure();
- public IFigure getConnectionFigure();
- public List getConnectedFigures(int type);
- public int getConnectionType();
- public void addConnectedFigure(IConnectedEditPartFigure figure);
- public void removeConnectedFigure(IConnectedEditPartFigure figure);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedFigure.java
deleted file mode 100644
index 4a6d7ded2c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectedFigure.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import org.eclipse.draw2d.IFigure;
-
-public interface IConnectedFigure extends IFigure
-{
- public IFigure getConnectionFigure();
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectionRenderingViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectionRenderingViewer.java
deleted file mode 100644
index 6ed611d9d7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IConnectionRenderingViewer.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-public interface IConnectionRenderingViewer
-{
- public ConnectionRenderingFigure getConnectionRenderingFigure();
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IExpandable.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IExpandable.java
deleted file mode 100644
index 161581bb00..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/IExpandable.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import org.eclipse.draw2d.IFigure;
-
-public interface IExpandable extends IFigure
-{
- boolean isExpanded();
- void setExpanded(boolean isExpanded);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/SpacingFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/SpacingFigure.java
deleted file mode 100644
index e245d6960c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/gef/util/figures/SpacingFigure.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.gef.util.figures;
-
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-
-public class SpacingFigure extends RectangleFigure
-{
- public SpacingFigure()
- {
- setFill(false);
- setPreferredSize(new Dimension(0, 0));
- }
-
- //protected void outlineShape(Graphics graphics)
- //{
- //}
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/BaseGraphicalViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/BaseGraphicalViewer.java
deleted file mode 100644
index 9f1bbec837..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/BaseGraphicalViewer.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.Iterator;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.StackLayout;
-import org.eclipse.gef.DefaultEditDomain;
-import org.eclipse.gef.EditDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.KeyHandler;
-import org.eclipse.gef.LayerConstants;
-import org.eclipse.gef.editparts.ScalableRootEditPart;
-import org.eclipse.gef.tools.SelectionTool;
-import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.XSDMenuListener;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ConnectionRenderingFigure;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IConnectionRenderingViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenterLayout;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-
-/**
- * @author ernest
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public abstract class BaseGraphicalViewer extends ScrollingGraphicalViewer implements IConnectionRenderingViewer
-{
- protected FigureCanvasKeyboardHandler figureCanvasKeyboardHandler;
-
- protected EditDomain editDomain;
-
- protected boolean isInputEnabled = true;
-
- protected boolean isSelectionEnabled = true;
-
- protected ISelectionProvider menuSelectionProvider;
-
- protected GraphContextMenuProvider menuProvider;
-
- protected XSDEditor editor;
-
- protected XSDConcreteComponent input;
-
- protected ConnectionRenderingFigure connectionRenderingFigure;
-
- public BaseGraphicalViewer(XSDEditor editor, ISelectionProvider selectionProvider)
- {
- super();
- this.editor = editor;
- menuSelectionProvider = selectionProvider;
- }
-
- public ConnectionRenderingFigure getConnectionRenderingFigure()
- {
- return connectionRenderingFigure;
- }
-
- public void setInputEnabled(boolean enabled)
- {
- isInputEnabled = enabled;
- }
-
- public void setSelectionEnabled(boolean enabled)
- {
- isSelectionEnabled = enabled;
- }
-
- public XSDMenuListener getMenuListener()
- {
- return menuProvider.getMenuListener();
- }
-
- protected static Color white = null;
- protected void hookControl()
- {
- super.hookControl();
-
- if (white == null)
- {
- white = new Color(getControl().getDisplay(), 255, 255, 255);
- }
- getControl().setBackground(white);
-
- editDomain = new DefaultEditDomain(null);
- ((DefaultEditDomain)editDomain).setDefaultTool(new SelectionTool());
- editDomain.loadDefaultTool();
- editDomain.addViewer(this);
-
- //jvh - gef port - moved this from below so it is available when adding context menu below
- menuProvider = new GraphContextMenuProvider(this, menuSelectionProvider);
- setContextMenu(menuProvider);
-
- // add context menu to the graph
- MenuManager manager = new MenuManager();
- manager.addMenuListener(getMenuListener()); //jvh - gef port
- manager.setRemoveAllWhenShown(true);
- Menu menu = manager.createContextMenu(getControl());
- getControl().setMenu(menu);
-
- // enable popupMenus extension
- //BUG 68938 eclipse bug fixed. Bug 112955 - Filter out menu contributions.
- editor.getEditorSite().registerContextMenu("org.eclipse.wst.xsd.ui.popup.graph", manager, menuSelectionProvider, false);
-
-// KeyAdapter keyListener = new KeyAdapter()
-// {
-// /**
-// * @see org.eclipse.swt.events.KeyAdapter#keyReleased(KeyEvent)
-// */
-// public void keyReleased(KeyEvent e)
-// {
-// if (e.character == SWT.DEL)
-// {
-// getMenuListener().getDeleteAction().run();
-// }
-// }
-// };
-
- setKeyHandler(new XSDGraphicalViewerKeyHandler(this).setParent(new KeyHandler()));
-
-// getControl().addKeyListener(keyListener);
-
- figureCanvasKeyboardHandler = new FigureCanvasKeyboardHandler(this);
- getFigureCanvas().addKeyListener(figureCanvasKeyboardHandler);
-
- getRootEditPart().activate();
-
- ScalableRootEditPart graphicalRootEditPart = (ScalableRootEditPart)getRootEditPart();
-
- // set the layout for the primary layer so that the children are always centered
- //
- graphicalRootEditPart.getLayer(LayerConstants.PRIMARY_LAYER).setLayoutManager(new CenterLayout());
-
- // add the ConnectionRenderingFigure which is responsible for drawing all of the lines in the view
- //
- IFigure figure = graphicalRootEditPart.getLayer(LayerConstants.HANDLE_LAYER);
- figure.setLayoutManager(new StackLayout());
- connectionRenderingFigure = new ConnectionRenderingFigure(graphicalRootEditPart.getLayer(LayerConstants.PRIMARY_LAYER));
- figure.add(connectionRenderingFigure);
-
- figure.validate();
- }
-
- public XSDConcreteComponent getInput()
- {
- return input;
- }
-
- protected EditPart getEditPart(EditPart parent, Object object)
- {
- EditPart result = null;
- for (Iterator i = parent.getChildren().iterator(); i.hasNext(); )
- {
- EditPart editPart = (EditPart)i.next();
- if (editPart.getModel() == object)
- {
- result = editPart;
- break;
- }
- }
-
- if (result == null)
- {
- for (Iterator i = parent.getChildren().iterator(); i.hasNext(); )
- {
- EditPart editPart = getEditPart((EditPart)i.next(), object);
- if (editPart != null)
- {
- result = editPart;
- break;
- }
- }
- }
-
- return result;
- }
-
- public abstract void setInput(XSDConcreteComponent comp);
-
- public abstract void setSelection(XSDConcreteComponent comp);
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/FigureCanvasKeyboardHandler.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/FigureCanvasKeyboardHandler.java
deleted file mode 100644
index 012e15eedd..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/FigureCanvasKeyboardHandler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.draw2d.RangeModel;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.CategoryEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart;
-
-public class FigureCanvasKeyboardHandler extends KeyAdapter
-{
- public static final int H_SCROLL_INCREMENT = 5;
- public static final int V_SCROLL_INCREMENT = 30;
-
- BaseGraphicalViewer viewer;
-
- /**
- * Constructor for FigureCanvasKeyboardHandler.
- */
- public FigureCanvasKeyboardHandler(BaseGraphicalViewer viewer)
- {
- super();
- this.viewer = viewer;
- }
-
- public void keyPressed(KeyEvent e)
- {
- Widget w = e.widget;
- if (w instanceof FigureCanvas)
- {
- processKey(e.keyCode, (FigureCanvas)w);
- update();
- }
- }
-
- private void processKey(int keyCode, FigureCanvas figureCanvas)
- {
- switch (keyCode)
- {
- case SWT.ARROW_DOWN :
- scrollVertical(figureCanvas, false);
- break;
- case SWT.ARROW_UP :
- scrollVertical(figureCanvas, true);
- break;
- case SWT.ARROW_LEFT :
- scrollHorizontal(figureCanvas, true);
- break;
- case SWT.ARROW_RIGHT :
- scrollHorizontal(figureCanvas, false);
- break;
- case SWT.PAGE_UP :
- scrollPage(figureCanvas, true);
- break;
- case SWT.PAGE_DOWN :
- scrollPage(figureCanvas, false);
- break;
- }
- }
-
- private int verifyScrollBarOffset(RangeModel model, int value)
- {
- value = Math.max(model.getMinimum(), value);
- return Math.min(model.getMaximum() - model.getExtent(), value);
- }
-
- private void scrollVertical(FigureCanvas figureCanvas, boolean up)
- {
- Point location = figureCanvas.getViewport().getViewLocation();
- int vOffset = up ? -V_SCROLL_INCREMENT : V_SCROLL_INCREMENT;
- int x = verifyScrollBarOffset(figureCanvas.getViewport().getHorizontalRangeModel(), location.x);
- int y = verifyScrollBarOffset(figureCanvas.getViewport().getVerticalRangeModel(), location.y + vOffset);
- figureCanvas.scrollSmoothTo(x, y);
- }
-
- private void scrollHorizontal(FigureCanvas figureCanvas, boolean left)
- {
- Point location = figureCanvas.getViewport().getViewLocation();
- int hOffset = left ? -H_SCROLL_INCREMENT : H_SCROLL_INCREMENT;
- int x = verifyScrollBarOffset(figureCanvas.getViewport().getHorizontalRangeModel(), location.x + hOffset);
- int y = verifyScrollBarOffset(figureCanvas.getViewport().getVerticalRangeModel(), location.y);
- figureCanvas.scrollSmoothTo(x, y);
- }
-
- private void scrollPage(FigureCanvas figureCanvas, boolean up)
- {
- Rectangle clientArea = figureCanvas.getClientArea();
- int increment = up ? -clientArea.height : clientArea.height;
- Point location = figureCanvas.getViewport().getViewLocation();
- int x = verifyScrollBarOffset(figureCanvas.getViewport().getHorizontalRangeModel(), location.x);
- int y = verifyScrollBarOffset(figureCanvas.getViewport().getVerticalRangeModel(), location.y + increment);
- figureCanvas.scrollSmoothTo(x, y);
- }
-
- private void update()
- {
- StructuredSelection s = (StructuredSelection)viewer.getSelection();
- Object newSelectedEditPart = s.getFirstElement();
-
- if (newSelectedEditPart instanceof TopLevelComponentEditPart)
- {
- TopLevelComponentEditPart topLevel = (TopLevelComponentEditPart) newSelectedEditPart;
- CategoryEditPart categoryEP = (CategoryEditPart) topLevel.getParent();
- categoryEP.scrollTo(topLevel);
- viewer.reveal((TopLevelComponentEditPart)newSelectedEditPart);
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphContextMenuProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphContextMenuProvider.java
deleted file mode 100644
index dc539e2479..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphContextMenuProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import org.eclipse.gef.ContextMenuProvider;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.XSDMenuListener;
-
-
-public class GraphContextMenuProvider extends ContextMenuProvider
-{
-
- XSDMenuListener xsdMenuListener;
-
- /**
- * Constructor for GraphContextMenuProvider.
- * @param selectionProvider
- * @param editor
- */
- public GraphContextMenuProvider(
- EditPartViewer viewer,
- ISelectionProvider selectionProvider)
- {
- super(viewer);
- this.viewer = viewer;
- xsdMenuListener = new XSDMenuListener(selectionProvider);
- xsdMenuListener.setSourceContext(viewer);
- }
-
- public XSDMenuListener getMenuListener()
- {
- return xsdMenuListener;
- }
-
-
- /**
- * @see org.eclipse.gef.ui.parts.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager, org.eclipse.gef.EditPartViewer)
- */
- public void buildContextMenu(IMenuManager arg0)
- {
- xsdMenuListener.menuAboutToShow(arg0);
- }
-
- protected EditPartViewer viewer;
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphicsConstants.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphicsConstants.java
deleted file mode 100644
index 691996dec0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/GraphicsConstants.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * A collection of color-related constants.
- */
-public interface GraphicsConstants
-{
- public final static Display display = Display.getDefault();
- public final static Color categoryBorderColor = new Color(null, 118, 134, 164);
- public final static Color elementBorderColor = new Color(null, 138, 154, 184);
- public final static Color elementBackgroundColor = new Color(null, 236, 242, 252);
- public final static Color elementLabelColor = new Color(null, 80, 96, 144);
- public final static Color readOnlyBorderColor = new Color(null, 164, 164, 164);
-
- public final static Color readOnlyBackgroundColor = ColorConstants.white;
-
- public final static Font smallFont = new Font(Display.getCurrent(), "Small Fonts", 6, SWT.NONE);
- public final static Font medium = new Font(Display.getCurrent(), "Tahoma", 8, SWT.NONE);
- public final static Font mediumBoldFont = new Font(Display.getCurrent(), "Tahoma", 8, SWT.BOLD);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/LinkedGraphViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/LinkedGraphViewer.java
deleted file mode 100644
index 73e21aadc1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/LinkedGraphViewer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.Iterator;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.w3c.dom.Element;
-
-
-
-public class LinkedGraphViewer
-{
-
- protected ISelectionProvider menuSelectionProvider;
- protected XSDEditor editor;
- protected BaseGraphicalViewer majorViewer, minorViewer;
-
- /**
- *
- */
- public LinkedGraphViewer(XSDEditor editor, ISelectionProvider selectionProvider)
- {
- menuSelectionProvider = selectionProvider;
- this.editor = editor;
- }
-
- public void setMajorViewer(BaseGraphicalViewer majorViewer)
- {
- this.majorViewer = majorViewer;
- }
-
- public void setMinorViewer(BaseGraphicalViewer minorViewer)
- {
- this.minorViewer = minorViewer;
- }
-
- protected Composite control;
- protected SashForm sashForm;
-
- public Control createControl(Composite parent)
- {
- //control = new Composite(parent, SWT.DEFAULT);
-
- control = sashForm = new SashForm(parent, SWT.VERTICAL | SWT.BORDER);
- sashForm.setLayoutData(ViewUtility.createFill());
-
- majorViewer.createControl(sashForm);
- minorViewer.createControl(sashForm);
-// control.setLayout(new GridLayout());
-// control.setLayoutData(ViewUtility.createFill());
- return control;
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener selectionListener)
- {
- if (majorViewer != null)
- {
- majorViewer.addSelectionChangedListener(selectionListener);
- majorViewer.addSelectionChangedListener(majorViewerListener);
- }
- if (minorViewer != null)
- {
- minorViewer.addSelectionChangedListener(selectionListener);
- }
- }
-
- /**
- * @return Composite
- */
- public Composite getControl()
- {
- return control;
- }
-
- /**
- *
- */
- protected XSDConcreteComponent getInput()
- {
- return majorViewer.getInput();
- }
-
- /**
- * @param schema
- */
- protected void setInput(XSDConcreteComponent input)
- {
- majorViewer.setInput(input);
- minorViewer.setInput(input);
- }
-
- /**
- * @param component
- */
- public void setSelection(XSDConcreteComponent component)
- {
- majorViewer.setSelection(component);
- }
-
- protected MajorViewerSelectionChangedListener majorViewerListener = new MajorViewerSelectionChangedListener();
-
- private class MajorViewerSelectionChangedListener implements ISelectionChangedListener
- {
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event)
- {
- ISelection editPartSelection = event.getSelection();
- if (editPartSelection instanceof IStructuredSelection)
- {
- for (Iterator i = ((IStructuredSelection)editPartSelection).iterator(); i.hasNext(); )
- {
- EditPart editPart = (EditPart)i.next();
- if (editPart != null)
- {
- Object model = editPart.getModel();
- if (model instanceof XSDConcreteComponent)
- {
- Element element = ((XSDConcreteComponent)model).getElement();
-
- // this test ensures that we don't attempt to select an element for an external schema
- //
- if (element instanceof IDOMNode)
- {
- // now update the minor viewer based on the selected component in the major viewer
- minorViewer.setInput((XSDConcreteComponent)model);
- minorViewer.setSelection((XSDConcreteComponent)model);
- }
- }
- }
- }
- }
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/PrintGraphAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/PrintGraphAction.java
deleted file mode 100644
index 53df913a12..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/PrintGraphAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.printing.PrintDialog;
-import org.eclipse.swt.printing.Printer;
-import org.eclipse.swt.printing.PrinterData;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-
-public class PrintGraphAction extends Action
-{
- protected XSDComponentViewer componentViewer;
-
- public PrintGraphAction(XSDComponentViewer componentViewer)
- {
- super("Print");
- this.componentViewer = componentViewer;
- }
-
- public void run()
- {
- try
- {
- PrintDialog dialog = new PrintDialog(Display.getCurrent().getActiveShell());
- PrinterData data = dialog.open();
- Printer printer = new Printer(data);
-
- Control control = componentViewer.getControl();
- Display display = Display.getCurrent();
- Image graphImage = new Image(display, control.getSize().x, control.getSize().y);
- GC graphGC = new GC(control);
- graphGC.copyArea(graphImage, 0, 0);
-
- ImageData graphImageData = graphImage.getImageData();
- graphImageData.transparentPixel = -1;
-
- Point screenDPI = display.getDPI();
- Point printerDPI = printer.getDPI();
- int scaleFactor = printerDPI.x / screenDPI.x;
- Rectangle trim = printer.computeTrim(0, 0, 0, 0);
- if (printer.startJob("Print XML Schema Graph"))
- {
- GC gc = new GC(printer);
- if (printer.startPage())
- {
- gc.drawImage(
- graphImage,
- 0,
- 0,
- graphImageData.width,
- graphImageData.height,
- -trim.x,
- -trim.y,
- scaleFactor * graphImageData.width,
- scaleFactor * graphImageData.height);
- printer.endPage();
- }
- printer.endJob();
- }
- printer.dispose();
- graphGC.dispose();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDChildUtility.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDChildUtility.java
deleted file mode 100644
index 887889cc36..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDChildUtility.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.util.XSDSwitch;
-
-
-public class XSDChildUtility
-{
- static public List getModelChildren(Object model)
- {
- XSDChildVisitor visitor = new XSDChildVisitor(model);
- visitor.visitXSDObject(model);
- return visitor.list;
- }
-
- static public List getImmediateDerivedTypes(XSDComplexTypeDefinition complexType)
- {
- ArrayList typesDerivedFrom = new ArrayList();
-
- // A handy convenience method quickly gets all
- // typeDefinitions within our schema; note that
- // whether or not this returns types in included,
- // imported, or redefined schemas is subject to change
- List typedefs = complexType.getSchema().getTypeDefinitions();
-
- for (Iterator iter = typedefs.iterator(); iter.hasNext(); )
- {
- XSDTypeDefinition typedef = (XSDTypeDefinition)iter.next();
- // Walk the baseTypes from this typedef seeing if any
- // of them match the requested one
- if (complexType.equals(typedef.getBaseType()))
- {
- // We found it, return the original one and continue
- typesDerivedFrom.add(typedef);
- }
- }
- return typesDerivedFrom;
- }
- // TODO... use the XSDVisitor defined in xsdeditor.util instead
- //
- public static class XSDChildVisitor extends XSDVisitor
- {
- Object root;
- List list = new ArrayList();
-
- public XSDChildVisitor(Object root)
- {
- this.root = root;
- }
-
- public void visitXSDModelGroup(XSDModelGroup xsdModelGroup)
- {
- if (xsdModelGroup != root)
- {
- list.add(xsdModelGroup);
- }
- else
- {
- super.visitXSDModelGroup(xsdModelGroup);
- }
- }
-
- public void visitXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition)
- {
- if (xsdModelGroupDefinition != root)
- {
- list.add(xsdModelGroupDefinition);
- }
- else
- {
- super.visitXSDModelGroupDefinition(xsdModelGroupDefinition);
- }
- }
-
- public void visitXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration)
- {
- if (xsdElementDeclaration != root)
- {
- list.add(xsdElementDeclaration);
- }
- else
- {
- super.visitXSDElementDeclaration(xsdElementDeclaration);
- }
- }
-
- public void visitXSDComplexTypeDefinition(XSDComplexTypeDefinition xsdComplexTypeDefinition)
- {
- if (xsdComplexTypeDefinition != root)
- {
- if (xsdComplexTypeDefinition.getName() != null || getModelChildren(xsdComplexTypeDefinition).size() > 0)
- {
- list.add(xsdComplexTypeDefinition);
- }
- }
- else
- {
- super.visitXSDComplexTypeDefinition(xsdComplexTypeDefinition);
- }
- }
-
- public void visitXSDWildcard(XSDWildcard xsdWildCard)
- {
- if (xsdWildCard != root)
- {
- list.add(xsdWildCard);
- }
- else
- {
- super.visitXSDWildcard(xsdWildCard);
- }
- }
- }
-
-
- public static class XSDVisitor
- {
- int indent = 0;
-
- public void visitXSDObject(Object object)
- {
- if (object == null)
- return;
-
- XSDSwitch theSwitch = new XSDSwitch()
- {
- public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object)
- {
- visitXSDComplexTypeDefinition(object);
- return null;
- }
-
- public Object caseXSDAttributeUse(XSDAttributeUse object)
- {
- visitXSDAttributeUse(object);
- return null;
- }
-
- public Object caseXSDElementDeclaration(XSDElementDeclaration object)
- {
- visitXSDElementDeclaration(object);
- return null;
- }
-
- public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object)
- {
- visitXSDModelGroupDefinition(object);
- return super.caseXSDModelGroupDefinition(object);
- }
-
- public Object caseXSDModelGroup(XSDModelGroup object)
- {
- visitXSDModelGroup(object);
- return super.caseXSDModelGroup(object);
- }
-
- public Object caseXSDParticle(XSDParticle object)
- {
- visitXSDParticle(object);
- return null;
- }
-
- public Object caseXSDSchema(XSDSchema object)
- {
- visitXSDSchema(object);
- return null;
- }
-
- public Object caseXSDWildcard(XSDWildcard object)
- {
- visitXSDWildcard(object);
- return null;
- }
- };
- theSwitch.doSwitch((EObject)object);
- }
-
- public void visitXSDAttributeUse(XSDAttributeUse xsdAttributeUse)
- {
-// printIndented("@" + xsdAttributeUse.getAttributeDeclaration().getName());
- }
-
- public void visitXSDSchema(XSDSchema xsdSchema)
- {
-// printIndented("XSDSchema");
- indent += 2;
- for (Iterator iterator = xsdSchema.getElementDeclarations().iterator(); iterator.hasNext(); )
- {
- visitXSDObject(iterator.next());
- }
- indent -= 2;
- }
-
- public void visitXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration)
- {
-// printIndented(xsdElementDeclaration.getName());
- indent += 2;
- XSDTypeDefinition td = xsdElementDeclaration.getTypeDefinition();
- if (td == null)
- {
- td = xsdElementDeclaration.getAnonymousTypeDefinition();
- }
- visitXSDObject(td);
- indent -= 2;
- }
-
- public void visitXSDComplexTypeDefinition(XSDComplexTypeDefinition xsdComplexTypeDefinition)
- {
-// printIndented("XSDComplexTypeDefinition : " + xsdComplexTypeDefinition.getContent());
- indent += 2;
- for (Iterator i = xsdComplexTypeDefinition.getAttributeUses().iterator(); i.hasNext(); )
- {
- visitXSDObject((XSDAttributeUse)i.next());
- }
- visitXSDObject(xsdComplexTypeDefinition.getContent());
- indent -= 2;
- }
-
- public void visitXSDModelGroup(XSDModelGroup xsdModelGroup)
- {
-// printIndented("XSDModelGroup");
- indent += 2;
- for (Iterator iterator = xsdModelGroup.getContents().iterator(); iterator.hasNext(); )
- {
- visitXSDObject(iterator.next());
- }
- indent -= 2;
- }
-
- public void visitXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition)
- {
-// printIndented("XSDModelGroupDefinition");
- indent += 2;
- visitXSDObject(xsdModelGroupDefinition.getResolvedModelGroupDefinition().getModelGroup());
- indent -= 2;
- }
-
- public void visitXSDParticle(XSDParticle xsdParticle)
- {
-// printIndented("XSDParticle");
- indent += 2;
- if (xsdParticle.getContent() != null)
- visitXSDObject(xsdParticle.getContent());
- indent -= 2;
- }
-
- public void visitXSDWildcard(XSDWildcard object)
- {
-// printIndented("XSDWildcard");
- }
-
- public void printIndented(String string)
- {
- //String spaces = "";
- //for (int i = 0; i < indent; i++)
- //{
- // spaces += " ";
- //}
- //System.out.println(spaces + string);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDComponentViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDComponentViewer.java
deleted file mode 100644
index a8a05259dc..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDComponentViewer.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ComponentViewerRootEditPart;
-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;
-
-
-public class XSDComponentViewer extends BaseGraphicalViewer
-{
- protected ComponentViewerRootEditPart componentViewerRootEditPart;
- public XSDComponentViewer(XSDEditor editor, ISelectionProvider menuSelectionProvider)
- {
- super(editor, menuSelectionProvider);
- }
-
- public void setInput(XSDConcreteComponent component)
- {
- if (isInputEnabled)
- {
- input = null;
-
- if (component instanceof XSDElementDeclaration ||
- component instanceof XSDSchema ||
- component instanceof XSDModelGroup ||
- component instanceof XSDModelGroupDefinition ||
- component instanceof XSDComplexTypeDefinition)
- {
- input = component;
- }
-
- componentViewerRootEditPart.setInput(input);
- if (!(input instanceof XSDSchema))
- {
- editor.getGraphViewer().backButton.setEnabled(true);
- }
- }
- }
-
- public void setSelection(XSDConcreteComponent component)
- {
- if (isSelectionEnabled)
- {
- //System.out.println("XSDComponentViewer.setSelection(" + component + ")");
- List editPartList = new ArrayList();
- if (component instanceof XSDElementDeclaration ||
- component instanceof XSDSchema ||
- component instanceof XSDModelGroup ||
- component instanceof XSDModelGroupDefinition ||
- component instanceof XSDComplexTypeDefinition)
- {
- if (component != null)
- {
- EditPart editPart = getEditPart(componentViewerRootEditPart, component);
- if (editPart != null)
- {
- // TODO ... take a look at this to figure our why a newly added component
- // seems to have the wrong bounds at this point... is this a layout issue?
- // As a temp hack I'm ignoring the selection of component with bounds (x, y) == (0, 0)
- // Perhaps a delayed selection is required?
- Rectangle bounds = ((GraphicalEditPart)editPart).getFigure().getBounds();
- if (bounds.x > 0 || bounds.y > 0)
- {
- editPartList.add(editPart);
- }
- }
- }
- }
- setSelection(new StructuredSelection(editPartList));
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.gef.ui.parts.AbstractEditPartViewer#hookControl()
- */
- protected void hookControl()
- {
- super.hookControl();
- componentViewerRootEditPart = new ComponentViewerRootEditPart();
- setContents(componentViewerRootEditPart);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphUtil.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphUtil.java
deleted file mode 100644
index f66c2796d2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.w3c.dom.Element;
-
-
-public class XSDGraphUtil
-{
- public static boolean isEditable(Object model)
- {
- boolean result = false;
- if (model instanceof XSDConcreteComponent)
- {
- Element element = ((XSDConcreteComponent)model).getElement();
- // this test ensures that we don't attempt to select an element for an external schema
- //
- if (element instanceof IDOMNode)
- {
- result = true;
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java
deleted file mode 100644
index 95bcd15e5b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.XSDSelectionManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart;
-import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNotationDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-public class XSDGraphViewer implements ISelectionChangedListener
-{
- protected PageBook pageBook;
- protected Control componentViewerControl;
- protected Control inheritanceViewerControl;
- protected Control subGroupsViewerControl;
- protected XSDComponentViewer componentViewer;
- protected XSDInheritanceViewer inheritanceViewer;
- protected XSDSubstitutionGroupsViewer subGroupsViewer;
- protected XSDSelectionManager xsdSelectionManager;
- protected XSDSchema schema;
- protected InternalSelectionProvider internalSelectionProvider = new InternalSelectionProvider();
- protected XSDEditor editor;
- protected PrintGraphAction printGraphAction;
- protected SashForm sashForm;
- protected ToolItem backButton;
-
- public XSDGraphViewer(XSDEditor editor)
- {
- super();
- this.editor = editor;
- }
-
- public void setSchema(XSDSchema schema)
- {
- this.schema = schema;
- }
- ToolBar graphToolBar; // the toolbar at the top of the graph view
- ToolItem toolItem; // the view tool item
- ViewForm form; // view form for holding all the views
- Composite frameBar; // The composite that contains the toolbar
- Composite c; // temporary blank page. Clean this up when all views completed
- LinkedGraphViewer linkInheritanceViewer;
-
- protected void createInheritanceViewer(Composite parent)
- {
- linkInheritanceViewer = new LinkedGraphViewer(editor, internalSelectionProvider);
- BaseGraphicalViewer graphViewer = new XSDInheritanceViewer(editor, internalSelectionProvider);
- linkInheritanceViewer.setMajorViewer(graphViewer);
- graphViewer = new XSDComponentViewer(editor, editor.getSelectionManager());
- linkInheritanceViewer.setMinorViewer(graphViewer);
- linkInheritanceViewer.createControl(parent);
- }
- LinkedGraphViewer linkSubstitutionGroupViewer;
-
- protected void createSubstitutionGroupViewer(Composite parent)
- {
- linkSubstitutionGroupViewer = new LinkedGraphViewer(editor, internalSelectionProvider);
- BaseGraphicalViewer graphViewer = new XSDSubstitutionGroupsViewer(editor, internalSelectionProvider);
- linkSubstitutionGroupViewer.setMajorViewer(graphViewer);
- graphViewer = new XSDComponentViewer(editor, internalSelectionProvider);
- linkSubstitutionGroupViewer.setMinorViewer(graphViewer);
- linkSubstitutionGroupViewer.createControl(parent);
- }
- static private Color dividerColor;
-
- public Control createControl(Composite parent)
- {
- pageBook = new PageBook(parent, 0);
-
- componentViewer = new XSDComponentViewer(editor, editor.getSelectionManager());
- form = new ViewForm(pageBook, SWT.NONE);
- frameBar = new Composite(form, SWT.NONE);
- org.eclipse.swt.layout.GridLayout frameLayout = new org.eclipse.swt.layout.GridLayout();
- frameLayout.marginWidth = 0;
- frameLayout.marginHeight = 0;
- frameBar.setLayout(frameLayout);
- graphToolBar = new ToolBar(frameBar, SWT.FLAT);
- graphToolBar.addTraverseListener(new TraverseListener()
- {
- public void keyTraversed(TraverseEvent e)
- {
- if (e.detail == SWT.TRAVERSE_MNEMONIC)
- e.doit = false;
- }
- });
- backButton = new ToolItem(graphToolBar, SWT.PUSH);
- backButton.setImage(XSDEditorPlugin.getXSDImage("icons/back.gif")); //$NON-NLS-1$
- backButton.setToolTipText(XSDEditorPlugin.getXSDString("_UI_HOVER_BACK_TO_SCHEMA_VIEW")); //$NON-NLS-1$
- backButton.setEnabled(false);
- backButton.addSelectionListener(new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent e)
- {
- editor.getGraphViewer().setInput(editor.getXSDSchema());
- editor.getSelectionManager().setSelection(new StructuredSelection(editor.getXSDSchema()));
- }
- });
- form.setTopLeft(frameBar);
- componentViewerControl = componentViewer.createControl(form);
- c = ViewUtility.createComposite(form, 1);
- form.setContent(componentViewerControl);
- form.setData("layout ratio", new Float(0.65));
- if (dividerColor == null)
- {
- dividerColor = new Color(componentViewerControl.getDisplay(), 143, 141, 138);
- }
- pageBook.showPage(form);
- componentViewer.addSelectionChangedListener(internalSelectionProvider);
- printGraphAction = new PrintGraphAction(componentViewer);
- return pageBook;
- }
-
- public Action getPrintGraphAction()
- {
- return printGraphAction;
- }
-
- public void updateDesignLayout(int newLayout)
- {
- sashForm.setOrientation(newLayout);
- sashForm.layout();
- }
-
- public SashForm getSashForm()
- {
- return sashForm;
- }
-
- public void enableDesignView(boolean enable)
- {
- }
-
- public XSDComponentViewer getComponentViewer()
- {
- return componentViewer;
- }
-
- public void setBackButtonEnabled(boolean state)
- {
- backButton.setEnabled(state);
- }
-
- public void setInput(Object object)
- {
- if (object instanceof XSDConcreteComponent)
- {
- XSDConcreteComponent xsdComp = (XSDConcreteComponent) object;
- if (xsdComp instanceof XSDSchema)
- {
- setBackButtonEnabled(false);
- }
- else
- {
- setBackButtonEnabled(true);
- }
- componentViewer.setInput(xsdComp);
- componentViewer.setSelection(xsdComp);
- }
- }
-
- protected boolean isDeleted(XSDConcreteComponent component)
- {
- boolean result = false;
- if (component != null && component.getElement() != null)
- {
- result = component.getElement().getParentNode() == null;
- }
- return result;
- }
-
- public void setSelectionManager(XSDSelectionManager newSelectionManager)
- {
- // disconnect from old one
- if (xsdSelectionManager != null)
- {
- xsdSelectionManager.removeSelectionChangedListener(this);
- internalSelectionProvider.removeSelectionChangedListener(xsdSelectionManager);
- }
- xsdSelectionManager = newSelectionManager;
- // connect to new one
- if (xsdSelectionManager != null)
- {
- xsdSelectionManager.addSelectionChangedListener(this);
- internalSelectionProvider.addSelectionChangedListener(xsdSelectionManager);
- }
- }
-
- // this method is called by the SelectionManager to notify the graph view
- // that the editor selection has changed
- //
- public void selectionChanged(SelectionChangedEvent event)
- {
- // here we check the selection source to ensure that this selection came
- // from a different view (not from the graph view)
- if (event.getSource() != getComponentViewer())
- {
- handleSelection(event, true);
- }
- }
-
- protected XSDConcreteComponent getTopLevelComponent(XSDConcreteComponent component)
- {
- XSDConcreteComponent prev = component;
- XSDConcreteComponent container = component;
- while ( container != null && !(container instanceof XSDSchema))
- {
- prev = container;
- container = container.getContainer();
- }
- return container != null ? prev : null;
- }
-
- // TODO.. we need to clean this method up and add comments to clarify what's going on
- //
- protected void handleSelection(SelectionChangedEvent event, boolean isSelectionRequired)
- {
- StructuredSelection s = (StructuredSelection)event.getSelection();
- Object obj = s.getFirstElement();
- if (obj instanceof XSDConcreteComponent)
- {
- XSDConcreteComponent selectedComponent = (XSDConcreteComponent)obj;
- Object currentInput = getComponentViewer().getInput();
-
- // in this case we're looking at a top level view
- // so if the selection is a 'non-top-level' component we need to do a set input
- XSDSchema topLevelSchema = null;
- if (currentInput instanceof XSDSchema)
- {
- if (selectedComponent instanceof XSDSchema ||
- selectedComponent.getContainer() instanceof XSDSchema)
- {
- topLevelSchema = (XSDSchema)currentInput;
- }
- }
- if (selectedComponent instanceof XSDSchemaDirective ||
- selectedComponent instanceof XSDNotationDeclaration)
- {
- topLevelSchema = selectedComponent.getSchema();
- }
- else if (selectedComponent instanceof XSDAttributeGroupContent ||
- selectedComponent instanceof XSDWildcard)
- {
- if (selectedComponent.getContainer() instanceof XSDAttributeGroupDefinition)
- {
- topLevelSchema = selectedComponent.getSchema();
- }
- }
- else if (selectedComponent instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)selectedComponent;
- EditPart editPart = componentViewer.getEditPart(componentViewer.getRootEditPart(), st);
- if (editPart == null)
- {
- if (st.getContainer() == editor.getXSDSchema())
- {
- topLevelSchema = selectedComponent.getSchema();
- }
- }
- }
-
- if (topLevelSchema != null)
- {
- setInput(topLevelSchema);
- // TODO... this is not 'quite' right
- // it should be possible to view in
- }
- else
- {
- EditPart editPart = getComponentViewer().getEditPart(getComponentViewer().getRootEditPart(), obj);
- if (editPart == null)
- {
- XSDConcreteComponent topLevelComponent = getTopLevelComponent(selectedComponent);
- if (topLevelComponent != null)
- {
- setInput(topLevelComponent);
- }
- }
- }
- // now we handle the selection
- //
- if (isSelectionRequired)
- {
- EditPart editPart = getComponentViewer().getRootEditPart();
- EditPart newSelectedEditPart = getComponentViewer().getEditPart(editPart, obj);
- if (newSelectedEditPart != null)
- {
- if (newSelectedEditPart instanceof TopLevelComponentEditPart)
- {
- ((TopLevelComponentEditPart)newSelectedEditPart).setScroll(true);
- }
- getComponentViewer().setSelection(new StructuredSelection(newSelectedEditPart));
- }
- }
- }
- else if (obj instanceof CategoryAdapter)
- {
- setInput(((CategoryAdapter)obj).getXSDSchema());
- }
- }
-
- protected Element getElementNode(Node node)
- {
- while (!(node instanceof Element))
- {
- if (node instanceof Attr)
- {
- node = ((Attr) node).getOwnerElement();
- }
- else if (node instanceof Text)
- {
- Node sibling = node.getNextSibling();
- if (sibling == null)
- {
- break;
- }
- node = sibling;
- }
- else
- {
- Node parent = node.getParentNode();
- if (parent == null)
- {
- break;
- }
- node = node.getParentNode();
- }
- }
- return node instanceof Element ? (Element) node : null;
- }
-
-
-
- // This class listens to the graph view and converts edit part selection
- // events
- // into XSD component selection events that can be 'fired' to the
- // selectionManager
- //
- class InternalSelectionProvider implements ISelectionProvider, ISelectionChangedListener
- {
- protected List listenerList = new ArrayList();
- protected ISelection selection = new StructuredSelection();
-
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.add(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.remove(listener);
- }
-
- public ISelection getSelection()
- {
- return selection;
- }
-
- protected void notifyListeners(SelectionChangedEvent event)
- {
- for (Iterator i = listenerList.iterator(); i.hasNext();)
- {
- ISelectionChangedListener listener = (ISelectionChangedListener) i.next();
- listener.selectionChanged(event);
- }
- }
-
- public StructuredSelection convertSelectionFromEditPartToModel(ISelection editPartSelection)
- {
- List selectedModelObjectList = new ArrayList();
- if (editPartSelection instanceof IStructuredSelection)
- {
- for (Iterator i = ((IStructuredSelection) editPartSelection).iterator(); i.hasNext();)
- {
- Object obj = i.next();
- Object model = null;
- if (obj instanceof EditPart)
- {
- EditPart editPart = (EditPart) obj;
- model = editPart.getModel();
- // Convert category to XSDSchema
- // if (editPart instanceof CategoryEditPart)
- // {
- // model = ((Category)((CategoryEditPart)editPart).getModel()).getXSDSchema();
- // }
- }
- else if (obj instanceof XSDConcreteComponent)
- {
- //cs .. not sure why would we'd ever hit this case?
- model = obj;
- }
- if (model != null)//&& model instanceof XSDConcreteComponent)
- {
- selectedModelObjectList.add(model);
- }
- }
- }
- return new StructuredSelection(selectedModelObjectList);
- }
-
- public void setSelection(ISelection selection)
- {
- this.selection = selection;
- }
-
- // This method gets called when an edit part in the graph view is selected
- //
- public void selectionChanged(SelectionChangedEvent event)
- {
- ISelection newSelection = convertSelectionFromEditPartToModel(event.getSelection());
- this.selection = newSelection;
- SelectionChangedEvent newEvent = new SelectionChangedEvent(getComponentViewer(), newSelection);
- notifyListeners(newEvent);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphicalViewerKeyHandler.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphicalViewerKeyHandler.java
deleted file mode 100644
index b6c80263ec..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphicalViewerKeyHandler.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.GraphicalViewer;
-import org.eclipse.gef.KeyHandler;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ExpandableGraphNodeEditPart;
-
-
-public class XSDGraphicalViewerKeyHandler extends KeyHandler
-{
- public XSDGraphicalViewerKeyHandler(GraphicalViewer viewer)
- {
- this.viewer = viewer;
- }
-
- private WeakReference cachedNode;
- int counter;
- private GraphicalViewer viewer;
-
- private boolean acceptConnection(KeyEvent event)
- {
- return event.character == '/'
- || event.character == '?'
- || event.character == '\\'
- || event.character == '|';
- }
- private boolean acceptIntoContainer(KeyEvent event)
- {
- return (((event.stateMask & SWT.ALT) != 0)
- && (event.keyCode == SWT.ARROW_RIGHT)) || (event.keyCode == SWT.ARROW_RIGHT);
-// return (event.keyCode == SWT.ARROW_RIGHT);
- }
- private boolean acceptLeaveConnection(KeyEvent event)
- {
- int key = event.keyCode;
- if (getFocus() instanceof ConnectionEditPart)
- if ((key == SWT.ARROW_UP)
- || (key == SWT.ARROW_RIGHT)
- || (key == SWT.ARROW_DOWN)
- || (key == SWT.ARROW_LEFT))
- return true;
- return false;
- }
- private boolean acceptLeaveContents(KeyEvent event)
- {
- int key = event.keyCode;
- return getFocus() == getViewer().getContents()
- && ((key == SWT.ARROW_UP)
- || (key == SWT.ARROW_RIGHT)
- || (key == SWT.ARROW_DOWN)
- || (key == SWT.ARROW_LEFT));
- }
- private boolean acceptOutOf(KeyEvent event)
- {
- return (((event.stateMask & SWT.ALT) != 0) && (event.keyCode == SWT.ARROW_LEFT)) || (event.keyCode == SWT.ARROW_LEFT);
-// return (event.keyCode == SWT.ARROW_LEFT);
- }
- private ConnectionEditPart findConnection(
- GraphicalEditPart node,
- ConnectionEditPart current,
- boolean forward)
- {
- List connections = new ArrayList(node.getSourceConnections());
- connections.addAll(node.getTargetConnections());
- if (connections.isEmpty())
- return null;
- if (forward)
- counter++;
- else
- counter--;
- while (counter < 0)
- counter += connections.size();
- counter %= connections.size();
- return (ConnectionEditPart) connections.get(counter % connections.size());
- }
- /*
- * pStart is a point in absolute coordinates.
- */
- private GraphicalEditPart findSibling(
- List siblings,
- Point pStart,
- int direction,
- EditPart exclude)
- {
- GraphicalEditPart epCurrent;
- GraphicalEditPart epFinal = null;
- IFigure figure;
- Point pCurrent;
- int distance = Integer.MAX_VALUE;
- Iterator iter = siblings.iterator();
- while (iter.hasNext())
- {
- epCurrent = (GraphicalEditPart) iter.next();
- if (epCurrent == exclude)
- continue;
- figure = epCurrent.getFigure();
- pCurrent = getInterestingPoint(figure);
- figure.translateToAbsolute(pCurrent);
- if (pStart.getPosition(pCurrent) != direction)
- continue;
- int d = pCurrent.getDistanceOrthogonal(pStart);
- if (d < distance)
- {
- distance = d;
- epFinal = epCurrent;
- }
- }
- return epFinal;
- }
- Point getInterestingPoint(IFigure figure)
- {
-// return figure.getBounds().getCenter();
- return figure.getBounds().getTopLeft();
- }
- /**
- * Returns the cached node. It is possible that the node is not longer in the viewer but has
- * not been garbage collected yet.
- */
- private GraphicalEditPart getCachedNode()
- {
- if (cachedNode == null)
- return null;
- if (cachedNode.isEnqueued())
- return null;
- return (GraphicalEditPart) cachedNode.get();
- }
- GraphicalEditPart getFocus()
- {
- return (GraphicalEditPart) getViewer().getFocusEditPart();
- }
- List getNavigationSiblings()
- {
- return getFocus().getParent().getChildren();
- }
- protected GraphicalViewer getViewer()
- {
- return viewer;
- }
- public boolean keyPressed(KeyEvent event)
- {
- if (event.character == ' ')
- {
- processSelect(event);
- return true;
- }
- else if (acceptIntoContainer(event))
- {
- navigateIntoContainer(event);
- return true;
- }
- else if (acceptOutOf(event))
- {
- navigateOut(event);
- return true;
- }
- else if (acceptConnection(event))
- {
- navigateConnections(event);
- return true;
- }
- else if (acceptLeaveConnection(event))
- {
- navigateOutOfConnection(event);
- return true;
- }
- else if (acceptLeaveContents(event))
- {
- navigateIntoContainer(event);
- return true;
- }
- switch (event.keyCode)
- {
- case SWT.ARROW_LEFT :
- return navigateNextSibling(event, PositionConstants.WEST);
- case SWT.ARROW_RIGHT :
- return navigateNextSibling(event, PositionConstants.EAST);
- case SWT.ARROW_UP :
- return navigateNextSibling(event, PositionConstants.NORTH);
- case SWT.ARROW_DOWN :
- return navigateNextSibling(event, PositionConstants.SOUTH);
- case SWT.HOME :
- return navigateJumpSibling(event, PositionConstants.WEST);
- case SWT.END :
- return navigateJumpSibling(event, PositionConstants.EAST);
- case SWT.PAGE_DOWN :
- return navigateJumpSibling(event, PositionConstants.SOUTH);
- case SWT.PAGE_UP :
- return navigateJumpSibling(event, PositionConstants.NORTH);
- }
- return super.keyPressed(event);
- }
- private void navigateConnections(KeyEvent event)
- {
- GraphicalEditPart focus = getFocus();
- ConnectionEditPart current = null;
- GraphicalEditPart node = getCachedNode();
- if (focus instanceof ConnectionEditPart)
- {
- current = (ConnectionEditPart) focus;
- if (node == null
- || (node != current.getSource() && node != current.getTarget()))
- {
- node = (GraphicalEditPart) current.getSource();
- counter = 0;
- }
- }
- else
- {
- node = focus;
- }
- setCachedNode(node);
- boolean forward = event.character == '/' || event.character == '?';
- ConnectionEditPart next = findConnection(node, current, forward);
- navigateTo(next, event);
- }
- private void navigateIntoContainer(KeyEvent event)
- {
- GraphicalEditPart focus = getFocus();
- List childList = focus.getChildren();
-
- if (focus instanceof ExpandableGraphNodeEditPart)
- {
- if (!((ExpandableGraphNodeEditPart)focus).isExpanded())
- {
- ((ExpandableGraphNodeEditPart)focus).doPerformExpandOrCollapse();
- }
- }
-
- Point tl = focus.getContentPane().getBounds().getTopLeft();
- int minimum = Integer.MAX_VALUE;
- int current;
- GraphicalEditPart closestPart = null;
- for (int i = 0; i < childList.size(); i++)
- {
- GraphicalEditPart ged = (GraphicalEditPart) childList.get(i);
- Rectangle childBounds = ged.getFigure().getBounds();
- current = (childBounds.x - tl.x) + (childBounds.y - tl.y);
- if (current < minimum)
- {
- minimum = current;
- closestPart = ged;
- }
- }
- if (closestPart != null)
- navigateTo(closestPart, event);
- }
- private boolean navigateJumpSibling(KeyEvent event, int direction)
- {
- return false;
- }
- private boolean navigateNextSibling(KeyEvent event, int direction)
- {
- GraphicalEditPart epStart = getFocus();
- IFigure figure = epStart.getFigure();
- Point pStart = getInterestingPoint(figure);
- figure.translateToAbsolute(pStart);
- EditPart next =
- findSibling(getNavigationSiblings(), pStart, direction, epStart);
- if (next == null)
- return false;
- navigateTo(next, event);
- return true;
- }
- private void navigateOut(KeyEvent event)
- {
- if (getFocus() == null
- || getFocus() == getViewer().getContents()
- || getFocus().getParent() == getViewer().getContents())
- return;
-
- EditPart parent = getFocus().getParent();
- if (((event.stateMask & SWT.ALT) != 0) && (event.keyCode == SWT.ARROW_LEFT))
- {
- if ((parent != null) && (parent instanceof ExpandableGraphNodeEditPart))
- {
- if (((ExpandableGraphNodeEditPart)parent).isExpanded())
- {
- ((ExpandableGraphNodeEditPart)parent).doPerformExpandOrCollapse();
- }
- }
- }
- navigateTo(parent, event);
-// navigateTo(getFocus().getParent(), event);
- }
- private void navigateOutOfConnection(KeyEvent event)
- {
- GraphicalEditPart cached = getCachedNode();
- ConnectionEditPart conn = (ConnectionEditPart) getFocus();
- if (cached != null
- && (cached == conn.getSource() || cached == conn.getTarget()))
- navigateTo(cached, event);
- else
- navigateTo(conn.getSource(), event);
- }
- void navigateTo(EditPart part, KeyEvent event)
- {
- if (part == null)
- return;
- if ((event.stateMask & SWT.SHIFT) != 0)
- {
- getViewer().appendSelection(part);
- getViewer().setFocus(part);
- }
- else if ((event.stateMask & SWT.CONTROL) != 0)
- getViewer().setFocus(part);
- else
- getViewer().select(part);
- }
- private void processSelect(KeyEvent event)
- {
- EditPart part = getViewer().getFocusEditPart();
- if ((event.stateMask & SWT.CONTROL) != 0
- && part.getSelected() != EditPart.SELECTED_NONE)
- {
- getViewer().deselect(part);
- }
- else
- {
- getViewer().appendSelection(part);
- }
- getViewer().setFocus(part);
- }
- private void setCachedNode(GraphicalEditPart node)
- {
- if (node == null)
- cachedNode = null;
- else
- cachedNode = new WeakReference(node);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDInheritanceViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDInheritanceViewer.java
deleted file mode 100644
index de95c0c331..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDInheritanceViewer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.SubstitutionGroupViewerRootEditPart;
-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;
-
-
-public class XSDInheritanceViewer extends BaseGraphicalViewer
-{
- protected SubstitutionGroupViewerRootEditPart inheritanceViewerRootEditPart;
- public XSDInheritanceViewer(XSDEditor editor, ISelectionProvider menuSelectionProvider)
- {
- super(editor, menuSelectionProvider);
- }
-
- public void setInput(XSDConcreteComponent component)
- {
- if (isInputEnabled)
- {
- input = null;
-
- if (component instanceof XSDSchema ||
- component instanceof XSDComplexTypeDefinition)
- {
- input = component;
- }
-
- inheritanceViewerRootEditPart.setInput(input);
- }
- }
-
- public void setSelection(XSDConcreteComponent component)
- {
- if (isSelectionEnabled)
- {
- //System.out.println("XSDComponentViewer.setSelection(" + component + ")");
- List editPartList = new ArrayList();
- if (component instanceof XSDElementDeclaration ||
- component instanceof XSDSchema ||
- component instanceof XSDModelGroup ||
- component instanceof XSDModelGroupDefinition ||
- component instanceof XSDComplexTypeDefinition)
- {
- if (component != null)
- {
- EditPart editPart = getEditPart(inheritanceViewerRootEditPart, component);
- if (editPart != null)
- {
- // TODO ... take a look at this to figure our why a newly added component
- // seems to have the wrong bounds at this point... is this a layout issue?
- // As a temp hack I'm ignoring the selection of component with bounds (x, y) == (0, 0)
- // Perhaps a delayed selection is required?
- Rectangle bounds = ((GraphicalEditPart)editPart).getFigure().getBounds();
- if (bounds.x > 0 || bounds.y > 0)
- {
- editPartList.add(editPart);
- }
- }
- }
- }
- setSelection(new StructuredSelection(editPartList));
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.gef.ui.parts.AbstractEditPartViewer#hookControl()
- */
- protected void hookControl()
- {
- super.hookControl();
- inheritanceViewerRootEditPart = new SubstitutionGroupViewerRootEditPart();
- setContents(inheritanceViewerRootEditPart);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupChildUtility.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupChildUtility.java
deleted file mode 100644
index 9fa84bd867..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupChildUtility.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.xsd.XSDElementDeclaration;
-
-/**
- * @author ernest
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class XSDSubstitutionGroupChildUtility
-{
-
- /**
- * @param declaration
- * @return List
- */
- public static List getModelChildren(XSDElementDeclaration declaration)
- {
- ArrayList children = new ArrayList();
- List substitutionGroup = declaration.getSubstitutionGroup();
- for (int i = 0, size = substitutionGroup.size(); i < size; i++)
- {
- XSDElementDeclaration element = (XSDElementDeclaration) substitutionGroup.get(i);
- if (declaration.equals(element.getSubstitutionGroupAffiliation()))
- {
- children.add(element);
- }
- }
- return children;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupsViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupsViewer.java
deleted file mode 100644
index cd3074f457..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDSubstitutionGroupsViewer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.SubstitutionGroupViewerRootEditPart;
-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;
-
-
-public class XSDSubstitutionGroupsViewer extends BaseGraphicalViewer
-{
- protected SubstitutionGroupViewerRootEditPart subGroupViewerRootEditPart;
- public XSDSubstitutionGroupsViewer(XSDEditor editor, ISelectionProvider menuSelectionProvider)
- {
- super(editor, menuSelectionProvider);
- }
-
- public void setInput(XSDConcreteComponent component)
- {
- if (isInputEnabled)
- {
- input = null;
-
- if (component instanceof XSDElementDeclaration ||
- component instanceof XSDSchema)
- {
- input = component;
- }
-
- subGroupViewerRootEditPart.setInput(input);
- }
- }
-
- public void setSelection(XSDConcreteComponent component)
- {
- if (isSelectionEnabled)
- {
- //System.out.println("XSDComponentViewer.setSelection(" + component + ")");
- List editPartList = new ArrayList();
- if (component instanceof XSDElementDeclaration ||
- component instanceof XSDSchema ||
- component instanceof XSDModelGroup ||
- component instanceof XSDModelGroupDefinition ||
- component instanceof XSDComplexTypeDefinition)
- {
- if (component != null)
- {
- EditPart editPart = getEditPart(subGroupViewerRootEditPart, component);
- if (editPart != null)
- {
- // TODO ... take a look at this to figure our why a newly added component
- // seems to have the wrong bounds at this point... is this a layout issue?
- // As a temp hack I'm ignoring the selection of component with bounds (x, y) == (0, 0)
- // Perhaps a delayed selection is required?
- Rectangle bounds = ((GraphicalEditPart)editPart).getFigure().getBounds();
- if (bounds.x > 0 || bounds.y > 0)
- {
- editPartList.add(editPart);
- }
- }
- }
- }
- setSelection(new StructuredSelection(editPartList));
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.gef.ui.parts.AbstractEditPartViewer#hookControl()
- */
- protected void hookControl()
- {
- super.hookControl();
- subGroupViewerRootEditPart = new SubstitutionGroupViewerRootEditPart();
- setContents(subGroupViewerRootEditPart);
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java
deleted file mode 100644
index f98da1abb1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/BaseEditPart.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapterListener;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-
-
-public abstract class BaseEditPart extends AbstractGraphicalEditPart implements ModelAdapterListener, GraphicsConstants, IFeedbackHandler
-{
- protected boolean isSelected = false;
- /**
- * Activates the <code>EditPart</code> by setting the
- * appropriate flags, and activating its children.
- * activation signals to the EditPart that is should start observing
- * it's model, and that is should support editing at this time.
- * An EditPart will have a parent prior to activiation.
- * @see #deactivate()
- */
- public void activate()
- {
- super.activate();
- XSDModelAdapterFactory.addModelAdapterListener(getModel(), this);
- }
- /**
- * Apart from the deactivation done in super, the source
- * and target connections are deactivated, and the visual
- * part of the this is removed.
- *
- * @see #activate()
- */
- public void deactivate()
- {
- XSDModelAdapterFactory.removeModelAdapterListener(getModel(), this);
- super.deactivate();
- }
-
- protected void createEditPolicies()
- {
- }
-
- protected EditPart createChild(Object model)
- {
- return XSDEditPartFactory.getInstance().createEditPart(this, model);
- }
-
- public void propertyChanged(Object object, String property)
- {
- refresh();
- }
-
- //public BaseGraphicalViewer getBaseGraphicalViewer()
- //{
- // return (BaseGraphicalViewer)getViewer();
- //}
-
- public IFigure getSelectionFigure()
- {
- return getFigure();
- }
-
-
- public void addFeedback()
- {
- isSelected = true;
- refreshVisuals();
- }
-
- public void removeFeedback()
- {
- isSelected = false;
- refreshVisuals();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
deleted file mode 100644
index afffaad700..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.ScrollPane;
-import org.eclipse.draw2d.Viewport;
-import org.eclipse.draw2d.ViewportLayout;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-
-
-public class CategoryEditPart extends BaseEditPart
-{
- protected ScrollPane scrollpane;
- protected Label label;
- protected ContainerFigure outerPane, r;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- public int getType()
- {
- return ((Category)getModel()).getGroupType();
- }
-
- protected IFigure createFigure()
- {
- outerPane = new ContainerFigure();
- outerPane.setBorder(new RoundedLineBorder(1, 6));
- outerPane.setForegroundColor(categoryBorderColor);
-
- r = new ContainerFigure();
- r.setOutline(false);
- r.setMinimumSize(new Dimension(0, 0));
- r.setFill(true);
- r.setBackgroundColor(GraphicsConstants.elementBackgroundColor);
- outerPane.add(r);
-
- int minHeight = 250;
- switch (getType())
- {
- case Category.DIRECTIVES :
- case Category.NOTATIONS :
- {
- minHeight = 50;
- break;
- }
- case Category.ATTRIBUTES :
- case Category.GROUPS :
- {
- minHeight = 100;
- break;
- }
- }
-
- final int theMinHeight = minHeight;
- FillLayout outerLayout = new FillLayout()
- {
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension d = super.calculatePreferredSize(parent, width, height);
- d.union(new Dimension(100, theMinHeight));
- return d;
- }
- };
- //outerLayout.setHorizontal(false);
- outerPane.setLayoutManager(outerLayout);
-
-
- label = new Label();
- label.setForegroundColor(ColorConstants.black);
- label.setBorder(new MarginBorder(2, 4, 2, 4));
- r.add(label); //Holder);
-
- RectangleFigure line = new RectangleFigure();
- line.setPreferredSize(20, 1);
- outerPane.add(line);
-
-
- scrollpane = new ScrollPane();
- scrollpane.setForegroundColor(ColorConstants.black);
- scrollpane.setVerticalScrollBarVisibility(ScrollPane.AUTOMATIC); //ScrollPane.ALWAYS);
- outerPane.add(scrollpane);
-
- ContainerFigure pane = new ContainerFigure();
- pane.setBorder(new MarginBorder(5, 8, 5, 8));
- ContainerLayout layout = new ContainerLayout();
- layout.setHorizontal(false);
- layout.setSpacing(0);
- pane.setLayoutManager(layout);
-
- Viewport viewport = new Viewport();
- viewport.setContentsTracksHeight(true);
- ViewportLayout viewportLayout = new ViewportLayout()
- {
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension d = super.calculatePreferredSize(parent, width, height);
- d.height = Math.min(d.height, theMinHeight - 25); //getViewer().getControl().getBounds().height);
- return d;
- }
- };
- viewport.setLayoutManager(viewportLayout);
-
- scrollpane.setViewport(viewport);
- scrollpane.setContents(pane);
-
- return outerPane;
- }
-
- protected List getModelChildren()
- {
- return ((Category)getModel()).getChildren();
- }
-
- public void refreshVisuals()
- {
- outerPane.setBorder(new RoundedLineBorder(isSelected ? ColorConstants.black : categoryBorderColor, isSelected ? 1 : 1, 6));
- outerPane.repaint();
-// Uncomment this for coloured titles
-// r.setBackgroundColor(isSelected ? ColorConstants.blue : GraphicsConstants.elementBackgroundColor);
-// label.setForegroundColor(isSelected ? ColorConstants.white : ColorConstants.black);
-// r.repaint();
-// outerPane.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
-
- Category category = (Category)getModel();
- // temp hack --- added empty space to make the min width of groups bigger
- label.setText(" " + category.getName() + " ");
- }
-
- public ScrollPane getScrollPane()
- {
- return scrollpane;
- }
-
- public IFigure getContentPane()
- {
- return scrollpane.getContents();
- }
-
- public void scrollTo(AbstractGraphicalEditPart topLevel)
- {
- Rectangle topLevelBounds = topLevel.getFigure().getBounds();
- Rectangle categoryBounds = getFigure().getBounds();
- int scrollValue = scrollpane.getVerticalScrollBar().getValue();
- int location = topLevelBounds.y + scrollValue - categoryBounds.y;
- scrollpane.scrollVerticalTo(location - categoryBounds.height/2);
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = new TopLevelComponentEditPart();
- editPart.setModel(model);
- editPart.setParent(this);
- return editPart;
- }
-
- protected void createEditPolicies()
- {
- selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java
deleted file mode 100644
index 620cdc5278..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeDefinitionEditPart.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenteredIconFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-
-
-
-public class ComplexTypeDefinitionEditPart extends GraphNodeEditPart
-{
- protected ContainerFigure contentFigure;
- protected Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected CenteredIconFigure centeredIconFigure;
- protected RectangleFigure preceedingSpace;
- protected ContainerFigure contentPane;
-
- public XSDComplexTypeDefinition getXSDComplexTypeDefinition()
- {
- return (XSDComplexTypeDefinition)getModel();
- }
-
- protected boolean isConnectedEditPart()
- {
- return false;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- GraphNodeFigure figure = new GraphNodeFigure();
-
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getOutlinedArea().setFill(true);
- figure.getOutlinedArea().setLayoutManager(new FillLayout(true));
-
- figure.getInnerContentArea().getContainerLayout().setHorizontal(true);
-
- preceedingSpace = new RectangleFigure();
- preceedingSpace.setVisible(false);
- figure.getInnerContentArea().add(preceedingSpace, 0);
-
- contentPane = new ContainerFigure();
- contentPane.getContainerLayout().setHorizontal(false);
- contentPane.getContainerLayout().setSpacing(5);
- contentPane.setBorder(new MarginBorder(5, 5, 5, 5));
- figure.getInnerContentArea().add(contentPane);
-
- label = new Label();
- label.setBorder(new MarginBorder(0, 5, 5, 5));
- figure.getIconArea().add(label);
- label.setFont(mediumBoldFont);
-
- figure.getInnerContentArea().getContainerLayout().setSpacing(5);
- figure.getInnerContentArea().setBorder(new MarginBorder(5, 5, 5, 5));
-
- return figure;
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = null;
- if (model == getModel())
- {
- editPart = new ComplexTypeInheritedContentEditPart();
- editPart.setModel(model);
- editPart.setParent(this);
- }
- else
- {
- editPart = super.createChild(model);
- }
- return editPart;
- }
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
-
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)getModel();
-
- if (ct.getDerivationMethod().getName().equals("extension"))
- {
- list.add(getModel());
- }
-
- list.addAll(XSDChildUtility.getModelChildren(getModel()));
- return list;
- }
-
- public IFigure getContentPane()
- {
- return contentPane;
- }
-
- protected void refreshVisuals()
- {
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)getModel();
-
- String name = ctd.getName();
- if (name == null)
- {
- try
- {
- if (label != null)
- {
- graphNodeFigure.getIconArea().remove(label);
- }
- label = null;
- }
- catch (Exception e)
- {
- }
- }
- else
- {
- if (label == null)
- {
- label = new Label();
- label.setBorder(new MarginBorder(0, 5, 5, 5));
- ((GraphNodeFigure)getFigure()).getIconArea().add(label);
- label.setFont(mediumBoldFont);
- }
- graphNodeFigure.getIconArea().add(label);
- label.setText(name);
- }
-
- // provides some room if we need to draw lines for the inherited
- boolean includesInheritedContent = getModelChildren().contains(getModel());
- preceedingSpace.setPreferredSize(includesInheritedContent ? new Dimension(10, 1) : new Dimension(0, 0));
-
- if (XSDGraphUtil.isEditable(getModel()))
- {
- graphNodeFigure.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
- if (label != null)
- label.setForegroundColor(elementBorderColor);
- }
- else
- {
- graphNodeFigure.setForegroundColor(isSelected ? ColorConstants.black : readOnlyBorderColor);
- if (label != null)
- label.setForegroundColor(readOnlyBorderColor);
- }
- }
-
- protected void performDirectEdit()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDComplexTypeDefinition)getModel());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
- request.getType() == RequestConstants.REQ_OPEN)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
-
- if (label != null && hitTest(label, p))
- {
- performDirectEdit();
- }
- }
- }
- }
-
- public void doEditName()
- {
- performDirectEdit();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java
deleted file mode 100644
index 02952650a2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComplexTypeInheritedContentEditPart.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-// This is a dashed box that displays the inherited content of a complex type
-//
-public class ComplexTypeInheritedContentEditPart extends BaseEditPart
-{
- protected Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected boolean isParentExpanded;
-
- public ComplexTypeInheritedContentEditPart()
- {
- super();
- }
-
- public XSDComplexTypeDefinition getXSDComplexTypeDefinition()
- {
- return (XSDComplexTypeDefinition)getModel();
- }
-
- protected IFigure createFigure()
- {
- ContainerFigure figure = new ContainerFigure();
- figure.getContainerLayout().setHorizontal(false);
- figure.getContainerLayout().setBorder(5);
- figure.getContainerLayout().setSpacing(5);
- figure.setBorder(new RoundedLineBorder(ColorConstants.gray, 1, 6, Graphics.LINE_DASH));
- return figure;
- }
-
- protected List getModelChildren()
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)getModel();
-
- List list = new ArrayList();
-
- if (ct.getDerivationMethod().getName().equals("extension") && !isParentExpanded)
- {
- XSDTypeDefinition type = ct.getBaseTypeDefinition();
- Iterator iter = XSDChildUtility.getModelChildren(type).iterator();
- boolean cont = true;
- while (cont)
- {
- while (iter.hasNext())
- {
- list.add(0, iter.next());
- }
-
- if (type instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)type;
- type = ctd.getBaseTypeDefinition();
-
- // defect 264957 - workbench hangs when modifying complex content
- // Since we don't filter out the current complexType from
- // the combobox, we can potentially have an endless loop
- if (ctd == type)
- {
- cont = false;
- break;
- }
-
- if (ctd.getDerivationMethod().getName().equals("extension"))
- {
- iter = XSDChildUtility.getModelChildren(type).iterator();
- }
- else
- {
- cont = false;
- }
- }
- else
- {
- cont = false;
- }
- }
- }
- return list;
- }
-
- protected void refreshVisuals()
- {
- List children = getModelChildren();
- figure.setVisible(children.size() > 0);
- // todo set preferredSize to 0 ?
- }
-
- protected void performDirectEdit()
- {
- // Why are we allowing direct editing when the label is null?
- // Should remove the policy
- if (label != null)
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDComplexTypeDefinition)getModel());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java
deleted file mode 100644
index fa8d191fd4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ComponentViewerRootEditPart.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Panel;
-import org.eclipse.gef.EditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
-
-
-
-public class ComponentViewerRootEditPart extends BaseEditPart
-{
- protected final static String MESSAGE_PLACE_HOLDER = "MESSAGE_PLACE_HOLDER";
- protected Object input;
-
- public void setInput(Object input)
- {
- this.input = input;
- refreshChildren();
- }
-
- protected IFigure createFigure()
- {
- Panel panel = new Panel();
- ContainerLayout layout = new ContainerLayout();
- layout.setBorder(60);
- panel.setLayoutManager(layout);
- return panel;
- }
-
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- if (input != null)
- {
- list.add(input);
- }
- else
- {
- list.add(MESSAGE_PLACE_HOLDER);
- }
- return list;
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = null;
- if (model == MESSAGE_PLACE_HOLDER)
- {
- editPart = new MessageEditPart();
- editPart.setModel(model);
- }
- else
- {
- editPart = super.createChild(model);
- }
- return editPart;
- }
-
- protected void createEditPolicies()
- {
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
deleted file mode 100644
index 249c88b893..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDSetTypeHelper;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.SpacingFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDSubstitutionGroupChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDSubstitutionGroupsViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComboBoxCellEditorManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.w3c.dom.Element;
-
-
-
-public class ElementDeclarationEditPart extends ExpandableGraphNodeEditPart
-{
- public Label label;
- protected Label contentIconLabel;
- protected Label typeValueLabel;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected boolean isContentIconLabelSelected = false;
-
- protected final static String ELEMENT_TYPE_PLACE_HOLDER = "ELEMENT_TYPE_PLACE_HOLDER";
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDElementDeclaration().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
- public XSDElementDeclaration getXSDElementDeclaration()
- {
- return (XSDElementDeclaration)getModel();
- }
-
- protected boolean isDefaultExpanded()
- {
- // hack to expand up to its content. The previous test didn't appear to work
- int depth = 0;
- for (EditPart part = this; part != null; part = part.getParent())
- {
- depth++;
- }
- return depth <= 3;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
-
- figure.getOutlinedArea().setFill(true);
- figure.getOutlinedArea().setLayoutManager(new FillLayout());
-
- label = new Label();
- figure.getIconArea().add(label);
- label.setFont(mediumBoldFont);
-
- SpacingFigure spacingFigure = new SpacingFigure();
- figure.getIconArea().add(spacingFigure);
-
- contentIconLabel = new Label();
- //contentIcon.setBorder(new MarginBorder(2, 2, 2, 10));
- figure.getIconArea().add(contentIconLabel);
-
- // A sneaky null check.... getViewer() does a getRoot(), but getRoot() might be null
- // same with getParent()
- if (getParent() != null && getRoot() != null && getViewer() instanceof XSDSubstitutionGroupsViewer)
- {
- figure.getOuterContentArea().getContainerLayout().setSpacing(5);
- }
- else
- {
- RectangleFigure line = new RectangleFigure();
- line.setPreferredSize(20, 1);
- figure.getOutlinedArea().add(line, 1);
-
- figure.getInnerContentArea().setLayoutManager(new FillLayout(2));
- figure.getInnerContentArea().setBorder(new MarginBorder(2,2,2,1));
-
- ContainerFigure labelGroup = new ContainerFigure();
- Label typeLabel = new Label("type");
- labelGroup.add(typeLabel);
- labelGroup.setBorder(new MarginBorder(0, 4, 0, 4));
-
- Label equalsLabel = new Label(" = ");
- labelGroup.add(equalsLabel);
-
- typeValueLabel = new Label();
- labelGroup.add(typeValueLabel);
- figure.getOutlinedArea().add(labelGroup, 2);
- }
- return figure;
- }
-
- protected ExpandableGraphNodeFigure getExpandableGraphNodeFigure()
- {
- return (ExpandableGraphNodeFigure)graphNodeFigure;
- }
-
- protected List getModelChildren()
- {
- XSDTypeDefinition typeDef = getXSDElementDeclaration().getTypeDefinition();
-
- // Special case simple type. Need to add it to the list as well
- List list = new ArrayList();
- if (typeDef instanceof XSDSimpleTypeDefinition)
- {
- list.add((XSDSimpleTypeDefinition)typeDef);
- if (getExpandableGraphNodeFigure().isExpanded())
- {
- list.addAll(getModelChildrenHelper());
- }
- return list;
- }
- return getExpandableGraphNodeFigure().isExpanded() ? getModelChildrenHelper() : Collections.EMPTY_LIST;
- }
-
- protected List getModelChildrenHelper()
- {
- if (getViewer() instanceof XSDSubstitutionGroupsViewer)
- {
- return XSDSubstitutionGroupChildUtility.getModelChildren(getXSDElementDeclaration().getResolvedElementDeclaration());
- }
- else
- {
- return XSDChildUtility.getModelChildren(getXSDElementDeclaration().getResolvedElementDeclaration());
- }
- }
-
- protected void refreshContentIcon()
- {
- String iconName = null;
- XSDTypeDefinition td = getXSDElementDeclaration().getResolvedElementDeclaration().getTypeDefinition();
-
- if (td instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition)td;
- if (complexTypeDefinition.getAttributeUses().size() > 0)
- {
- iconName = "icons/XSDAttribute.gif";
- }
- }
- Image image = iconName != null ? XSDEditorPlugin.getXSDImage(iconName) : null;
- contentIconLabel.setIcon(image);
- }
-
- protected void refreshVisuals()
- {
- String text = getXSDElementDeclaration().isElementDeclarationReference() ?
- getXSDElementDeclaration().getResolvedElementDeclaration().getQName(getXSDElementDeclaration().getSchema()) :
- getXSDElementDeclaration().getName();
-
- label.setText(text);
-
- ContainerFigure rectangle = graphNodeFigure.getOutlinedArea();
- if (XSDGraphUtil.isEditable(getXSDElementDeclaration()))
- {
- rectangle.setBorder(new LineBorder(isSelected ? ColorConstants.black : elementBorderColor, 2));
- rectangle.setBackgroundColor(elementBackgroundColor);
- rectangle.setForegroundColor(elementBorderColor);
-
- graphNodeFigure.getInnerContentArea().setForegroundColor(ColorConstants.black);
- if (XSDGraphUtil.isEditable(getXSDElementDeclaration().getResolvedElementDeclaration()))
- {
- // give label 'editable' colour
- graphNodeFigure.getInnerContentArea().setForegroundColor(elementLabelColor);
- }
- else
- {
- // give label 'read only' colour
- graphNodeFigure.getInnerContentArea().setForegroundColor(elementBorderColor);
- }
- label.setBackgroundColor(elementBackgroundColor);
- label.setForegroundColor(elementLabelColor);
- }
- else
- {
- rectangle.setBorder(new LineBorder(isSelected ? ColorConstants.black : readOnlyBorderColor, 2));
- rectangle.setBackgroundColor(readOnlyBackgroundColor);
- rectangle.setForegroundColor(readOnlyBorderColor);
- graphNodeFigure.getInnerContentArea().setForegroundColor(readOnlyBorderColor);
- label.setBackgroundColor(readOnlyBackgroundColor);
- }
-
- if (getXSDElementDeclaration().isElementDeclarationReference())
- {
- label.setIcon(XSDEditorPlugin.getXSDImage("icons/GraphViewElementRef.gif"));
- label.setBorder(new MarginBorder(0, 0, 0, 4));
- }
- else
- {
- label.setIcon(null);
- label.setBorder(new MarginBorder(0, 6, 0, 4));
- }
-
- if (getXSDParticle() != null)
- {
- refreshOccurenceLabel(getXSDParticle().getMinOccurs(), getXSDParticle().getMaxOccurs());
- }
-
-
- if (typeValueLabel != null)
- {
- XSDElementDeclaration ed = getXSDElementDeclaration();
- if (ed.getElement() != null)
- {
- String type = ed.getElement().getAttribute("type");
- if (type == null)
- {
- type = "";
- }
- if (!getXSDElementDeclaration().isElementDeclarationReference())
- {
- typeValueLabel.setText(type.equals("") ? "<anonymous>" : type);
- }
- else // if it is a ref, we show the resolved type
- {
- String resolvedType = "";
- if (ed.getResolvedElementDeclaration() != null)
- {
- if (ed.getResolvedElementDeclaration().getTypeDefinition() != null)
- {
- resolvedType = ed.getResolvedElementDeclaration().getTypeDefinition().getQName(ed.getSchema());
-
- // if null, it has an anonymous type that has no resolved type
- if (resolvedType == null)
- {
- resolvedType = "<anonymous>";
- }
- }
- }
- typeValueLabel.setText(resolvedType);
- }
- }
- }
- refreshContentIcon();
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
- request.getType() == RequestConstants.REQ_OPEN)
- {
- if (XSDGraphUtil.isEditable(getXSDElementDeclaration()))
- {
- if (request instanceof LocationRequest)
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
- isContentIconLabelSelected = false;
-
- if (hitTest(label, p))
- {
- performDirectEditForLabel();
- }
- else if (hitTest(typeValueLabel, p))
- {
- performDirectEditForTypeValueLabel();
- }
- }
- }
- }
- }
-
- private void performDirectEditForTypeValueLabel()
- {
- if (!getXSDElementDeclaration().isElementDeclarationReference())
- {
-// TypeReferenceDirectEditManager manager = new TypeReferenceDirectEditManager(this, getXSDElementDeclaration(), typeValueLabel);
-// simpleDirectEditPolicy.setDelegate(manager);
-// manager.show();
-//TODO remove TypeReferenceDirectEditManager since it is not used any longer
-
- Shell shell = Display.getCurrent().getActiveShell();
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
- IFile currentIFile = ((IFileEditorInput)editorPart.getEditorInput()).getFile();
-
- XSDSchema schema = getXSDElementDeclaration().getSchema();
-
- XSDComponentSelectionProvider provider = new XSDComponentSelectionProvider(currentIFile, schema);
- XSDComponentSelectionDialog dialog = new XSDComponentSelectionDialog(shell, XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"), provider);
- provider.setDialog(dialog);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- if (dialog.open() == Window.OK) {
- Element element = getXSDElementDeclaration().getElement();
- XSDSetTypeHelper helper = new XSDSetTypeHelper(currentIFile, schema);
- helper.setType(element, "type", dialog.getSelection());
- }
-
-
- }
- // just ignore type edit for element ref's
- }
-
-
- private void performDirectEditForLabel()
- {
- if (getXSDElementDeclaration().isElementDeclarationReference())
- {
- ComboBoxCellEditorManager manager = new ComboBoxCellEditorManager(this, label)
- {
- protected List computeComboContent()
- {
- XSDSchema schema = getXSDElementDeclaration().getSchema();
- List globalElementNameList = new ArrayList();
- if (schema != null)
- {
- TypesHelper typesHelper = new TypesHelper(schema);
- globalElementNameList = typesHelper.getGlobalElements();
- }
- return globalElementNameList;
- }
-
- public void performModify(String value)
- {
- getXSDElementDeclaration().getElement().setAttribute("ref", value);
- }
- };
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- else
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDElementDeclaration());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- public void activate()
- {
- super.activate();
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.addModelAdapterListener(getXSDParticle(), this);
- }
- }
- /**
- * Apart from the deactivation done in super, the source
- * and target connections are deactivated, and the visual
- * part of the this is removed.
- *
- * @see #activate()
- */
- public void deactivate()
- {
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.removeModelAdapterListener(getXSDParticle(), this);
- }
- super.deactivate();
- }
-
- public boolean isContentIconLabelSelected()
- {
- return isContentIconLabelSelected;
- }
-
- protected void addChildVisual(EditPart childEditPart, int index)
- {
- IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
- if (childEditPart instanceof SimpleTypeDefinitionEditPart)
- {
- graphNodeFigure.getIconArea().add(child, index+ 1);
- SpacingFigure spacingFigure = new SpacingFigure();
- graphNodeFigure.getIconArea().add(spacingFigure, index+1);
- }
- else
- {
- getContentPane().add(child, index);
- }
- }
-
- protected void removeChildVisual(EditPart childEditPart)
- {
- IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
- if (childEditPart instanceof SimpleTypeDefinitionEditPart)
- {
- graphNodeFigure.getIconArea().remove(child);
- }
- else
- {
- super.removeChildVisual(childEditPart);
- }
- }
-
- public void doEditName()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDElementDeclaration());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java
deleted file mode 100644
index 1ad4057fed..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ExpandableGraphNodeEditPart.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ActionEvent;
-import org.eclipse.draw2d.ActionListener;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LayoutManager;
-import org.eclipse.draw2d.MouseEvent;
-import org.eclipse.draw2d.MouseListener;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-
-
-
-public abstract class ExpandableGraphNodeEditPart extends RepeatableGraphNodeEditPart implements MouseListener, ActionListener
-{
- protected boolean needToPerformDefaultExpansion = true;
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- return new ExpandableGraphNodeFigure();
- }
-
- protected void addGraphNodeFigureListeners()
- {
- getExpandableGraphNodeFigure().getInteractor().addMouseListener(this);
- }
-
- protected ExpandableGraphNodeFigure getExpandableGraphNodeFigure()
- {
- return (ExpandableGraphNodeFigure)graphNodeFigure;
- }
-
- public IFigure getContentPane()
- {
- return getExpandableGraphNodeFigure().getOuterContentArea();
- }
-
- protected boolean isDefaultExpanded()
- {
- return false;
- }
-
- protected boolean hasChildren()
- {
- return getModelChildrenHelper().size() > 0;
- }
-
- protected abstract List getModelChildrenHelper();
-
-
- protected List getModelChildren()
- {
- return getExpandableGraphNodeFigure().isExpanded() ? getModelChildrenHelper() : Collections.EMPTY_LIST;
- }
-
- protected void refreshChildren()
- {
- if (needToPerformDefaultExpansion && isDefaultExpanded())
- {
- needToPerformDefaultExpansion = false;
- performExpandOrCollapseHelper();
-
- super.refreshChildren();
-
- EditPart root = getRoot();
- if (root instanceof AbstractGraphicalEditPart)
- {
- getContentPane().setVisible(true);
-
- IFigure rootFigure = ((AbstractGraphicalEditPart)root).getFigure();
- invalidateAll(rootFigure);
- rootFigure.validate();
- rootFigure.repaint();
- }
- getExpandableGraphNodeFigure().getInteractor().repaint();
- }
- else
- {
- super.refreshChildren();
- }
- getExpandableGraphNodeFigure().getInteractor().setVisible(hasChildren());
- }
-
-
- protected void performExpandOrCollapseHelper()
- {
- boolean isButtonExpanded = !getExpandableGraphNodeFigure().isExpanded();
- getExpandableGraphNodeFigure().setExpanded(isButtonExpanded);
- }
-
- public void doPerformExpandOrCollapse()
- {
- performExpandOrCollapse();
- }
-
- public boolean isExpanded()
- {
- return getExpandableGraphNodeFigure().isExpanded();
- }
-
- protected void performExpandOrCollapse()
- {
- performExpandOrCollapseHelper();
-
- boolean isButtonExpanded = getExpandableGraphNodeFigure().isExpanded();
-
- refreshChildren();
-
- EditPart root = getRoot();
- if (root instanceof AbstractGraphicalEditPart)
- {
- getContentPane().setVisible(isButtonExpanded);
-
- IFigure rootFigure = ((AbstractGraphicalEditPart)root).getFigure();
- invalidateAll(rootFigure);
- rootFigure.validate();
- rootFigure.repaint();
- }
- getExpandableGraphNodeFigure().getInteractor().repaint();
- }
-
-
- protected void refreshOccurenceLabel(int min, int max)
- {
- super.refreshOccurenceLabel(min, max);
-
- // TODO: revisit the 'hack' to understand why we need to do this
- // in order to get the view to layout propetly
- //
- IFigure thisFigure = getFigure();
- invalidateAll(thisFigure);
- thisFigure.validate();
- thisFigure.repaint();
- }
-
- protected void invalidateAll(IFigure figure)
- {
- figure.invalidate();
- LayoutManager manager = figure.getLayoutManager();
- if (manager != null)
- {
- manager.invalidate();
- }
- for (Iterator i = figure.getChildren().iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- invalidateAll(child);
- }
- }
-
-
- // implements MouseListener
- //
- public void mouseDoubleClicked(MouseEvent me)
- {
- }
-
- public void mousePressed(MouseEvent me)
- {
- me.consume();
- needToPerformDefaultExpansion = false;
- performExpandOrCollapse();
- }
-
- public void mouseReleased(MouseEvent me)
- {
- }
-
- public void actionPerformed(ActionEvent event)
- {
- performExpandOrCollapse();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java
deleted file mode 100644
index ce6ad0a9cb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/GraphNodeEditPart.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.ConnectedEditPartFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.GraphNodeDragTracker;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-
-
-
-public abstract class GraphNodeEditPart extends BaseEditPart
-{
- protected GraphNodeFigure graphNodeFigure;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- protected boolean isConnectedEditPart()
- {
- return true;
- }
-
- protected IFigure createFigure()
- {
- IFigure result = graphNodeFigure = createGraphNodeFigure();
- addGraphNodeFigureListeners();
-
- if (isConnectedEditPart())
- {
- ConnectedEditPartFigure connectedEditPartFigure = createConnectedEditPartFigure();
- connectedEditPartFigure.add(graphNodeFigure);
- result = connectedEditPartFigure;
- }
- return result;
- }
-
- protected ConnectedEditPartFigure createConnectedEditPartFigure()
- {
- ConnectedEditPartFigure connectedEditPartFigure = new ConnectedEditPartFigure(this)
- {
- public IFigure getSelectionFigure()
- {
- return graphNodeFigure.getOutlinedArea();
- }
-
- public IFigure getConnectionFigure()
- {
- return graphNodeFigure.getConnectionFigure();
- }
- };
- return connectedEditPartFigure;
- }
-
- protected abstract GraphNodeFigure createGraphNodeFigure();
-
- protected void addGraphNodeFigureListeners()
- {
- }
-
- public IFigure getSelectionFigure()
- {
- return graphNodeFigure.getOutlinedArea();
- }
-
- public Rectangle getConnectionRectangle()
- {
- return graphNodeFigure.getConnectionRectangle();
- }
-
- protected void createEditPolicies()
- {
- //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new NonResizableEditPolicy());
- selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- }
-
- public DragTracker getDragTracker(Request request)
- {
- return new GraphNodeDragTracker((EditPart)this);
- }
-
- protected EditPart getApplicableEditPart(EditPart editPart, Point p)
- {
- while (true)
- {
- EditPart parent = null;
- if (editPart instanceof GraphNodeEditPart)
- {
- IFigure f = ((GraphNodeEditPart)editPart).getSelectionFigure();
- if (!hitTest(f, p))
- {
- parent = editPart.getParent();
- }
- }
-
- if (parent != null)
- {
- editPart = parent;
- }
- else
- {
- break;
- }
- }
- return editPart;
- }
-
- public EditPart getTargetEditPart(Request request)
- {
- EditPart editPart = null;
- if (request.getType() == REQ_SELECTION)
- {
- if (request instanceof LocationRequest)
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
- editPart = getApplicableEditPart(this, p);
- }
- }
- return (editPart != null) ? editPart : super.getTargetEditPart(request);
- }
-
- public boolean hitTest(IFigure target, Point location)
- {
- Rectangle b = target.getBounds().getCopy();
- target.translateToAbsolute(b);
- return b.contains(location);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java
deleted file mode 100644
index 24a05377c7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/IFeedbackHandler.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-public interface IFeedbackHandler
-{
- public void addFeedback();
- public void removeFeedback();
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java
deleted file mode 100644
index bbb7f92dd2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/MessageEditPart.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-
-
-
-public class MessageEditPart extends BaseEditPart
-{
- public MessageEditPart()
- {
- }
-
- protected IFigure createFigure()
- {
- Label label = new Label(XSDEditorPlugin.getXSDString("_UI_GRAPH_VIEW_NOT_AVAILABLE"));
- return label;
- }
-
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java
deleted file mode 100644
index af5804abb2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupDefinitionEditPart.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComboBoxCellEditorManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RepeatableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-
-
-public class ModelGroupDefinitionEditPart extends RepeatableGraphNodeEditPart
-{
- protected Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
- public XSDModelGroupDefinition getXSDModelGroupDefinition()
- {
- return (XSDModelGroupDefinition)getModel();
- }
-
- protected boolean isConnectedEditPart()
- {
- return false;
- }
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDModelGroupDefinition().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- RepeatableGraphNodeFigure figure = new RepeatableGraphNodeFigure();
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getInnerContentArea().setBorder(new MarginBorder(10, 0, 10, 0));
-
- label = new Label();
- label.setFont(mediumBoldFont);
- figure.getIconArea().add(label);
-
-
- return figure;
- }
-
- public IFigure getContentPane()
- {
- return graphNodeFigure.getInnerContentArea();
- }
-
- protected List getModelChildren()
- {
- return XSDChildUtility.getModelChildren(getModel());
- }
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
-
- if (getXSDModelGroupDefinition().isModelGroupDefinitionReference())
- {
- label.setText(getXSDModelGroupDefinition().getResolvedModelGroupDefinition().getQName());
- label.setIcon(XSDEditorPlugin.getXSDImage("icons/GraphViewElementRef.gif"));
- label.setBorder(new MarginBorder(0, 0, 0, 4));
-
- // todo update occurence label
- //
- }
- else
- {
- label.setText(getXSDModelGroupDefinition().getName());
- label.setIcon(null);
- label.setBorder(new MarginBorder(0, 6, 0, 4));
- }
-
- if (XSDGraphUtil.isEditable(getModel()))
- {
- graphNodeFigure.getOutlinedArea().setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
- label.setForegroundColor(elementLabelColor);
- }
- else
- {
- graphNodeFigure.getOutlinedArea().setForegroundColor(readOnlyBackgroundColor);
- label.setForegroundColor(readOnlyBackgroundColor);
- }
-
- refreshOccurenceLabel(getXSDParticle());
- }
-
-
- protected void performDirectEdit()
- {
- if (getXSDModelGroupDefinition().isModelGroupDefinitionReference())
- {
- ComboBoxCellEditorManager manager = new ComboBoxCellEditorManager(this, label)
- {
- protected List computeComboContent()
- {
- XSDSchema schema = getXSDModelGroupDefinition().getSchema();
- List nameList = new ArrayList();
- if (schema != null)
- {
- TypesHelper typesHelper = new TypesHelper(schema);
- nameList = typesHelper.getModelGroups();
- }
- return nameList;
- }
-
- public void performModify(String value)
- {
- Display.getCurrent().asyncExec(new DelayedModelGroupRenameAction(getXSDModelGroupDefinition(), value));
- }
- };
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- else
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDModelGroupDefinition());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- protected class DelayedModelGroupRenameAction implements Runnable
- {
- XSDModelGroupDefinition modelGroupDefinition;
- String value;
-
- DelayedModelGroupRenameAction(XSDModelGroupDefinition modelGroupDefinition, String value)
- {
- this.modelGroupDefinition = modelGroupDefinition;
- this.value = value;
- }
-
- public void run()
- {
- modelGroupDefinition.getElement().setAttribute("ref", value);
- }
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-
- // TODO... I added this as a quick fix to makesure the title gets redrawn when the groupRef is changed
- // we should probably fix the ModelListenerUtil to fire both call both 'change' methods for the ref property
- //public void modelChildrenChanged()
- //{
- // super.modelChildrenChanged();
- // refreshVisuals();
- //}
-
- public void doEditName()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, getXSDModelGroupDefinition());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java
deleted file mode 100644
index b793ebab46..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ModelGroupEditPart.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.DragAndDropEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenteredIconFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticle;
-
-
-
-public class ModelGroupEditPart extends ExpandableGraphNodeEditPart
-{
- protected CenteredIconFigure centeredIconFigure;
-
- protected static Color editableBackgroundColor = null;
- protected static Color editableForegroundColor = null;
- protected static Color nonEditableForegroundColor = null;
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDModelGroup().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
- public XSDModelGroup getXSDModelGroup()
- {
- return (XSDModelGroup)getModel();
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
-
- centeredIconFigure = new CenteredIconFigure();
- centeredIconFigure.setPreferredSize(new Dimension(32, 20));
- //centeredIconFigure.setBackgroundColor(new Color(Display.getCurrent(), 255, 0, 0));
- figure.getIconArea().add(centeredIconFigure);
- //figure.getIconArea().setLayout(new CenterLayout());
-
- ContainerFigure outlinedArea = figure.getOutlinedArea();
- outlinedArea.setBorder(new RoundedLineBorder(1, 10));
- //outlinedArea.setPreferredSize(new Dimension(32, 20));
-
- // set layout so that children are aligned vertically with some spacing
- //
- figure.getOuterContentArea().getContainerLayout().setHorizontal(false);
- figure.getOuterContentArea().getContainerLayout().setSpacing(10);
-
- return figure;
- }
-
- protected List getModelChildrenHelper()
- {
- return XSDChildUtility.getModelChildren(getXSDModelGroup());
- }
-
- protected void refreshVisuals()
- {
- String iconName = "icons/XSDSequence.gif";
- switch (getXSDModelGroup().getCompositor().getValue())
- {
- case XSDCompositor.ALL : { iconName = "icons/XSDAll.gif"; break; }
- case XSDCompositor.CHOICE : { iconName = "icons/XSDChoice.gif"; break; }
- case XSDCompositor.SEQUENCE : { iconName = "icons/XSDSequence.gif"; break; }
- }
- centeredIconFigure.image = XSDEditorPlugin.getXSDImage(iconName);
- centeredIconFigure.repaint();
-
-
- ContainerFigure outlinedArea = graphNodeFigure.getOutlinedArea() ;
- if (XSDGraphUtil.isEditable(getXSDModelGroup()))
- {
- if (editableForegroundColor == null)
- editableForegroundColor = new Color(Display.getCurrent(), 120, 152, 184);
-
- if (editableBackgroundColor == null)
- editableBackgroundColor = new Color(Display.getCurrent(), 232, 240, 248);
-
- outlinedArea.setForegroundColor(isSelected ? ColorConstants.black : editableForegroundColor);
- outlinedArea.setBackgroundColor(editableBackgroundColor);
- }
- else
- {
- if (nonEditableForegroundColor == null)
- nonEditableForegroundColor = new Color(Display.getCurrent(), 164, 164, 164);
-
- outlinedArea.setForegroundColor(isSelected ? ColorConstants.black : nonEditableForegroundColor);
- outlinedArea.setBackgroundColor(ColorConstants.white);
- }
-
- refreshOccurenceLabel(getXSDParticle());
- }
-
- protected boolean isChildLayoutHorizontal()
- {
- return false;
- }
-
- protected boolean isDefaultExpanded()
- {
- return isPossibleCycle() ? false : true;
- }
-
- // This test ensures that we don't end up with an infinite default expansion (e.g. when a group contains a cyclic group ref)
- // TODO... we probably need some more extensible 'OO' way of computing this information
- protected boolean isPossibleCycle()
- {
- boolean result = false;
- if (getParent() instanceof ModelGroupDefinitionEditPart)
- {
- ModelGroupDefinitionEditPart group = (ModelGroupDefinitionEditPart)getParent();
- for (EditPart parent = group.getParent(); parent != null; parent = parent.getParent())
- {
- if (parent.getModel() instanceof ElementDeclarationEditPart)
- {
- break;
- }
- else
- {
- if (parent.getModel() == group.getModel())
- {
- result = true;
- break;
- }
- }
- }
- }
- return result;
- }
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
- }
-
- public void activate()
- {
- super.activate();
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.addModelAdapterListener(getXSDParticle(), this);
- }
- }
- /**
- * Apart from the deactivation done in super, the source
- * and target connections are deactivated, and the visual
- * part of the this is removed.
- *
- * @see #activate()
- */
- public void deactivate()
- {
- if (getXSDParticle() != null)
- {
- XSDModelAdapterFactory.removeModelAdapterListener(getXSDParticle(), this);
- }
- super.deactivate();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java
deleted file mode 100644
index 6fdf7d61ca..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RepeatableGraphNodeEditPart.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.DragAndDropEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RepeatableGraphNodeFigure;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDSchema;
-
-
-
-public class RepeatableGraphNodeEditPart extends GraphNodeEditPart
-{
- protected RepeatableGraphNodeFigure getRepeatableGraphNodeFigure()
- {
- return (RepeatableGraphNodeFigure)graphNodeFigure;
- }
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- return new RepeatableGraphNodeFigure();
- }
-
- protected void refreshOccurenceLabel(XSDParticle particle)
- {
- if (particle != null)
- {
- refreshOccurenceLabel(particle.getMinOccurs(), particle.getMaxOccurs());
- }
- }
-
- protected void refreshOccurenceLabel(int min, int max)
- {
- if (min == 1 && max == 1)
- {
- getRepeatableGraphNodeFigure().getOccurenceLabel().setText("");
- }
- else
- {
- String maxString = max == -1 ? "*" : "" + max;
- getRepeatableGraphNodeFigure().getOccurenceLabel().setText(min + ".." + maxString);
- }
- getRepeatableGraphNodeFigure().getOccurenceLabel().repaint();
- }
-
- protected void createEditPolicies()
- {
- super.createEditPolicies();
-
- if (getModel() instanceof XSDElementDeclaration) {
- Object parent = ((XSDElementDeclaration) getModel()).eContainer();
-
- if (!(parent instanceof XSDSchema)) {
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
- }
- }
- else {
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DragAndDropEditPolicy(getViewer(), selectionHandlesEditPolicy));
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java
deleted file mode 100644
index 853a2dfa19..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootComplexTypeDefinitionEditPart.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDInheritanceViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-
-
-
-public class RootComplexTypeDefinitionEditPart extends ExpandableGraphNodeEditPart
-{
- public Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getOutlinedArea().setLayoutManager(new FillLayout());
- figure.getOutlinedArea().setFill(true);
-
- if (getViewer() instanceof XSDInheritanceViewer)
- {
- figure.getOuterContentArea().getContainerLayout().setSpacing(10);
- }
-
- label = new Label();
- label.setFont(mediumBoldFont);
- label.setBorder(new MarginBorder(5, 8, 5, 8));
- figure.getIconArea().add(label);
-
- return figure;
- }
-
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
-
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)getModel();
- label.setText(ctd.getName() != null ? ctd.getName(): "");
-
- if (XSDGraphUtil.isEditable(ctd))
- {
- figure.setForegroundColor(elementBorderColor);
- label.setForegroundColor(elementBorderColor);
- }
- else
- {
- figure.setForegroundColor(readOnlyBorderColor);
- label.setForegroundColor(readOnlyBorderColor);
- }
- }
-
-
- protected List getModelChildrenHelper()
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)getModel();
- if (getViewer() instanceof XSDInheritanceViewer)
- {
- return XSDChildUtility.getImmediateDerivedTypes(ct);
- }
- else
- {
- return XSDChildUtility.getModelChildren(getModel());
- }
- }
-
-
- protected void createEditPolicies()
- {
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- protected void performDirectEdit()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDComplexTypeDefinition)getModel());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java
deleted file mode 100644
index 35f4486708..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/RootModelGroupDefinitionEditPart.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.List;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ExpandableGraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-
-
-public class RootModelGroupDefinitionEditPart extends ExpandableGraphNodeEditPart
-{
- public Label label;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
- figure.getOutlinedArea().setBorder(new RoundedLineBorder(1, 6));
- figure.getOutlinedArea().setLayoutManager(new FillLayout());
- figure.getOutlinedArea().setFill(true);
-
- label = new Label();
- label.setFont(mediumBoldFont);
- label.setBorder(new MarginBorder(5, 8, 5, 8));
- figure.getIconArea().add(label);
-
- return figure;
- }
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
-
- XSDModelGroupDefinition mgd = (XSDModelGroupDefinition)getModel();
- String name = mgd.getResolvedModelGroupDefinition().getName();
- label.setText(name);
-
- if (XSDGraphUtil.isEditable(getModel()))
- {
- figure.setForegroundColor(elementBorderColor);
- label.setForegroundColor(elementBorderColor);
- }
- else
- {
- figure.setForegroundColor(readOnlyBorderColor);
- label.setForegroundColor(readOnlyBorderColor);
- }
- }
-
- protected List getModelChildrenHelper()
- {
- return XSDChildUtility.getModelChildren(getModel());
- }
-
-
- protected void createEditPolicies()
- {
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
-
- protected void performDirectEdit()
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, ((XSDModelGroupDefinition)getModel()).getResolvedModelGroupDefinition());
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
-
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT)
- {
- if (XSDGraphUtil.isEditable(getModel()))
- {
- performDirectEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java
deleted file mode 100644
index c0697d5fc5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaDirectiveEditPart.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.CenteredIconFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.xsd.XSDSchemaDirective;
-
-
-public class SchemaDirectiveEditPart extends BaseEditPart
-{
- protected CenteredIconFigure centeredIconFigure;
- protected Label label;
- /**
- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
- */
- protected IFigure createFigure()
- {
-
- ContainerFigure figure = new ContainerFigure();
-
- figure.setLayoutManager(new FillLayout());
- figure.setBorder(new RoundedLineBorder(1, 8));
-
- ContainerFigure fig = new ContainerFigure();
- fig.setLayoutManager(new FillLayout());
- fig.setBorder(new MarginBorder(10, 0, 10, 0));
- figure.add(fig);
-
-
- label = new Label();
- label.setBorder(new MarginBorder(4, 2, 2, 10));
- fig.add(label);
-
- return figure;
- }
-
- public void refreshVisuals()
- {
- XSDSchemaDirective directive = (XSDSchemaDirective)getModel();
- String schemaLocation = directive.getSchemaLocation();
- if (schemaLocation == null) schemaLocation = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- if (schemaLocation.equals("")) schemaLocation = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- label.setText(" " + directive.getElement().getLocalName() + " " + schemaLocation);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java
deleted file mode 100644
index ad1f64b55d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SchemaEditPart.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.gef.EditPart;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDSchema;
-
-public class SchemaEditPart extends BaseEditPart
-{
- protected ContainerFigure containerFigure;
- protected Label label;
-
- //protected ContainerFigure childExpansionContainer;
- public IFigure getContentPane()
- {
- return containerFigure;
- }
-
- protected IFigure createFigure()
- {
- ContainerFigure outer = new ContainerFigure();
- outer.setBorder(new RoundedLineBorder(1, 6));
- outer.setForegroundColor(categoryBorderColor);
- FillLayout fillLayout = new FillLayout(4);
- outer.setLayoutManager(fillLayout);
- //outer.getContainerLayout().setHorizontal(false);
-
- ContainerFigure r = new ContainerFigure();
- r.setOutline(false);
- r.setMinimumSize(new Dimension(0, 0));
- r.setFill(true);
- r.setBackgroundColor(GraphicsConstants.elementBackgroundColor);
- outer.add(r);
-
- final int theMinHeight = 200;
- FillLayout outerLayout = new FillLayout()
- {
- protected Dimension calculatePreferredSize(IFigure parent, int width, int height)
- {
- Dimension d = super.calculatePreferredSize(parent, width, height);
- d.union(new Dimension(100, theMinHeight));
- return d;
- }
- };
- outerLayout.setHorizontal(false);
- outer.setLayoutManager(outerLayout);
-
- label = new Label();
- label.setForegroundColor(ColorConstants.black);
- label.setBorder(new MarginBorder(2, 4, 2, 4));
- r.add(label);
-
- RectangleFigure line = new RectangleFigure();
- line.setPreferredSize(20, 1);
- outer.add(line);
-
- containerFigure = new ContainerFigure();
- //containerFigure.setBackgroundColor(ColorConstants.red);
- containerFigure.setBorder(new MarginBorder(4, 4, 4, 4));
- fillLayout = new FillLayout(4);
- containerFigure.setLayoutManager(fillLayout);
- //containerFigure.setLayoutManager(new FillLayout(false));
- /*
- * FlowLayout layout1 = new FlowLayout(false); layout1.setMajorSpacing(0);
- * layout1.setMinorSpacing(0); layout1.setStretchMinorAxis(true);
- * containerFigure.setLayoutManager(layout1);
- */
- outer.add(containerFigure);
- //childExpansionContainer = new ContainerFigure();
- //childExpansionContainer.getContainerLayout().setHorizontal(false);
- //childExpansionContainer.setOutlined(true);
- return outer;
- }
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- list.add(CategoryRowEditPart.DIRECTIVES_AND_NOTATIONS);
- list.add(CategoryRowEditPart.ELEMENTS_AND_TYPES);
- list.add(CategoryRowEditPart.MODEL_GROUPS_AND_ATTRIBUTES);
- return list;
- }
-
- protected EditPart createChild(Object model)
- {
- CategoryRowEditPart result = new CategoryRowEditPart();
- result.setModel(model);
- result.setParent(this);
- result.setSchema((XSDSchema)getModel());
- return result;
- }
-
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- String targetNamespaceValue = ((XSDSchema)getModel()).getTargetNamespace();
- if (targetNamespaceValue == null || targetNamespaceValue.length() == 0)
- {
- targetNamespaceValue = XSDEditorPlugin.getXSDString("_UI_GRAPH_XSDSCHEMA_NO_NAMESPACE");
- }
- label.setText(XSDEditorPlugin.getXSDString("_UI_GRAPH_XSDSCHEMA") + " : " + targetNamespaceValue);
- }
-}
-
-class CategoryRowEditPart extends BaseEditPart
-{
- public static final int[] ELEMENTS_AND_TYPES = {Category.ELEMENTS, Category.TYPES };
- public static final int[] DIRECTIVES_AND_NOTATIONS = {Category.DIRECTIVES, Category.NOTATIONS };
- public static final int[] MODEL_GROUPS_AND_ATTRIBUTES = {Category.GROUPS, Category.ATTRIBUTES};//, Category.COMPLEX_TYPES };
-
- protected XSDSchema schema;
- protected Figure contentPane;
-
- protected IFigure createFigure()
- {
- ContainerFigure containerFigure = new ContainerFigure();
- //containerFigure.setBackgroundColor(ColorConstants.red);
- containerFigure.setFill(true);
- containerFigure.setBorder(new MarginBorder(4, 4, 4, 4));
- org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout fillLayout = new org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout(4);
- fillLayout.setHorizontal(true);
- containerFigure.setLayoutManager(fillLayout);
- //containerFigure.setLayoutManager(new FillLayout(4));
- return containerFigure;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getContentPane()
- */
- public IFigure getContentPane()
- {
- return super.getContentPane();
- }
-
- public XSDSchema getSchema()
- {
- return schema;
- }
-
- public void setSchema(XSDSchema schema)
- {
- this.schema = schema;
- }
-
-
- protected List getModelChildren()
- {
- List categoryList = (List) XSDModelAdapterFactory.getAdapter(schema).getProperty(schema, "groups");
- return filterCategoryList(categoryList);
- }
-
- protected List filterCategoryList(List list)
- {
- List result = new ArrayList();
- int[] categoryTypes = (int[])getModel();
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- Category category = (Category)i.next();
- if (isMatching(categoryTypes, category))
- {
- result.add(category);
- }
- }
- return result;
- }
-
- private boolean isMatching(int[] categoryTypes, Category category)
- {
- boolean result = false;
- for (int i = 0; i < categoryTypes.length; i++)
- {
- if (categoryTypes[i] == category.getGroupType())
- {
- result = true;
- break;
- }
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java
deleted file mode 100644
index df1afad070..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.ImageFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-
-public class SimpleTypeDefinitionEditPart extends BaseEditPart
-{
- protected Label label;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- ImageFigure figure;
- Image image;
-
- protected IFigure createFigure()
- {
- String iconName = "icons/XSDSimpleTypeForEditPart.gif";
- image = XSDEditorPlugin.getXSDImage(iconName);
-
- figure = new ImageFigure(image);
- return figure;
- }
-
- protected void refreshVisuals()
- {
- if (isSelected)
- {
- image = XSDEditorPlugin.getXSDImage("icons/XSDSimpleTypeForEditPart.gif");
- }
- else
- {
- image = XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
- figure.setImage(image);
- figure.repaint();
- }
-
- protected boolean isConnectedEditPart()
- {
- return false;
- }
-
- public void deactivate()
- {
- super.deactivate();
- image = null; // where do we dispose the image?
- }
-
-
- protected void createEditPolicies()
- {
- selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java
deleted file mode 100644
index 3899e8e6f3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SubstitutionGroupViewerRootEditPart.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Panel;
-import org.eclipse.gef.EditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
-
-
-
-public class SubstitutionGroupViewerRootEditPart extends BaseEditPart
-{
- protected final static String MESSAGE_PLACE_HOLDER = "MESSAGE_PLACE_HOLDER";
- protected Object input;
-
- public void setInput(Object input)
- {
- this.input = input;
- refreshChildren();
- }
-
- protected IFigure createFigure()
- {
- Panel panel = new Panel();
- ContainerLayout layout = new ContainerLayout();
- layout.setBorder(60);
- panel.setLayoutManager(layout);
- return panel;
- }
-
-
- protected List getModelChildren()
- {
- List list = new ArrayList();
- if (input != null)
- {
- list.add(input);
- }
- else
- {
- list.add(MESSAGE_PLACE_HOLDER);
- }
- return list;
- }
-
- protected EditPart createChild(Object model)
- {
- EditPart editPart = null;
- if (model == MESSAGE_PLACE_HOLDER)
- {
- editPart = new MessageEditPart();
- editPart.setModel(model);
- }
- else
- {
- editPart = super.createChild(model);
- }
- return editPart;
- }
-
- protected void createEditPolicies()
- {
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java
deleted file mode 100644
index 04b686af7e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TopLevelComponentEditPart.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.RequestConstants;
-import org.eclipse.gef.editpolicies.SelectionEditPolicy;
-import org.eclipse.gef.requests.LocationRequest;
-import org.eclipse.gef.ui.parts.AbstractEditPartViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.gef.util.editparts.AbstractComponentViewerRootEditPart;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.FillLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDComponentViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.ComponentNameDirectEditManager;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.model.ModelAdapter;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-
-
-public class TopLevelComponentEditPart extends BaseEditPart implements IFeedbackHandler
-{
- protected Label label;
- //protected Label arrowLabel;
- protected ContainerFigure labelHolder = new ContainerFigure();
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
- protected boolean isReadOnly;
- protected boolean isSelected;
- protected Font font;
-
- protected IFigure createFigure()
- {
- ContainerFigure typeGroup = new ContainerFigure();
- typeGroup.getContainerLayout().setHorizontal(true);
-
- //arrowLabel = new Label();
- //arrowLabel.setIcon(XSDEditorPlugin.getPlugin().getImage("icons/forward.gif"));
- //typeGroup.add(arrowLabel);
-
- labelHolder = new ContainerFigure();
- FillLayout fillLayout = new FillLayout();
- labelHolder.setLayoutManager(fillLayout);
- labelHolder.setFill(true);
- typeGroup.add(labelHolder);
-
- label = new Label();
- label.setBorder(new MarginBorder(0, 2, 2, 1));
- label.setForegroundColor(ColorConstants.black);
- labelHolder.add(label);
-
- try
- {
- // evil hack to provide underlines
- Object model = getModel();
-
- boolean isLinux = java.io.File.separator.equals("/");
- if (model instanceof XSDComplexTypeDefinition ||
- model instanceof XSDElementDeclaration ||
- model instanceof XSDModelGroupDefinition)
- {
- if (!isLinux)
- {
- FontData oldData = GraphicsConstants.medium.getFontData()[0];
- FontData fontData = new FontData(oldData.getName(), oldData.getHeight(), SWT.NONE);
-
- // TODO... clean this awful code up... we seem to be leaking here too
- // we can't call this directly since the methods are OS dependant
- // fontData.data.lfUnderline = 1
- // so instead we use reflection
- Object data = fontData.getClass().getField("data").get(fontData);
-// System.out.println("data" + data.getClass());
- data.getClass().getField("lfUnderline").setByte(data, (byte)1);
- font = new Font(Display.getCurrent(), fontData);
- label.setFont(font);
- }
- }
- }
- catch (Exception e)
- {
-
- }
-
- return typeGroup;
- }
-
- public void deactivate()
- {
- super.deactivate();
- if (font != null)
- {
- font.dispose();
- font = null;
- }
- }
-
- public void refreshVisuals()
- {
- ModelAdapter adapter = XSDModelAdapterFactory.getAdapter(getModel());
- if (adapter != null)
- {
- // isReadOnly = Boolean.TRUE.equals(adapter.getProperty(getModel(), "isReadOnly"));
- isReadOnly = !XSDGraphUtil.isEditable(getModel());
- label.setForegroundColor(computeLabelColor());
- label.setText((String)adapter.getProperty(getModel(), ModelAdapter.LABEL_PROPERTY));
- Image image = (Image)adapter.getProperty(getModel(), ModelAdapter.IMAGE_PROPERTY);
- if (image != null) label.setIcon(image);
- //arrowLabel.setVisible(Boolean.TRUE.equals(adapter.getProperty(getModel(), "drillDown")));
- }
- else
- {
- label.setText(XSDEditorPlugin.getXSDString("_UI_GRAPH_UNKNOWN_OBJECT") + getModel().getClass().getName());
- //arrowLabel.setVisible(false);
- }
-
- if (reselect)
- {
- getViewer().select(this);
- setReselect(false);
- }
- }
-
-
- public XSDNamedComponent getXSDNamedComponent()
- {
- return (XSDNamedComponent) getModel();
- }
-
- public List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- protected void createEditPolicies()
- {
- //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new NonResizableEditPolicy());
- //selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
- //installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);
-
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
-
- SelectionEditPolicy feedBackSelectionEditPolicy = new SelectionEditPolicy()
- {
- protected void hideSelection()
- {
- EditPart editPart = getHost();
- if (editPart instanceof IFeedbackHandler)
- {
- ((IFeedbackHandler)editPart).removeFeedback();
- }
- }
-
- protected void showSelection()
- {
- EditPart editPart = getHost();
- if (editPart instanceof IFeedbackHandler)
- {
- ((IFeedbackHandler)editPart).addFeedback();
- }
- }
- };
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, feedBackSelectionEditPolicy);
-
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, simpleDirectEditPolicy);
- }
-
- public Color computeLabelColor()
- {
- Color color = ColorConstants.black;
- if (isSelected)
- {
- color = ColorConstants.white;
- }
- else if (isReadOnly)
- {
- color = ColorConstants.gray;
- }
- return color;
- }
-
-
- public void addFeedback()
- {
- isSelected = true;
-
- labelHolder.setBackgroundColor(ColorConstants.black);
- label.setForegroundColor(computeLabelColor());
- labelHolder.setFill(true);
-
- if (doScroll)
- {
- CategoryEditPart categoryEP = (CategoryEditPart)getParent();
- categoryEP.scrollTo(this);
- setScroll(false);
- }
- }
-
- private boolean doScroll = false;
- public void setScroll(boolean doScroll)
- {
- this.doScroll = doScroll;
- }
-
- public void removeFeedback()
- {
- isSelected = false;
- labelHolder.setBackgroundColor(null);
- label.setForegroundColor(computeLabelColor());
- labelHolder.setFill(false);
- }
-
- public void performRequest(Request request)
- {
- if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
- request.getType() == RequestConstants.REQ_OPEN)
- {
-
- Object model = getModel();
- if (model instanceof XSDComplexTypeDefinition ||
- model instanceof XSDElementDeclaration ||
- model instanceof XSDModelGroupDefinition)
- {
- if (request instanceof LocationRequest)
- {
- LocationRequest locationRequest = (LocationRequest)request;
- Point p = locationRequest.getLocation();
-
- if (hitTest(labelHolder, p))
- {
- performDrillDownAction();
- }
- }
- }
- }
- }
-
- public boolean hitTest(IFigure target, Point location)
- {
- Rectangle b = target.getBounds().getCopy();
- target.translateToAbsolute(b);
- return b.contains(location);
- }
-
- protected void performDrillDownAction()
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- //((XSDComponentViewer)getViewer()).setInput((XSDConcreteComponent)getModel());
-
- EditPart editPart = ((AbstractEditPartViewer)getViewer()).getRootEditPart().getContents();
- if (editPart instanceof AbstractComponentViewerRootEditPart)
- {
- AbstractComponentViewerRootEditPart rootEditPart = (AbstractComponentViewerRootEditPart)editPart;
- rootEditPart.setInput((XSDConcreteComponent)getModel());
- }
- else if (editPart instanceof BaseEditPart)
- {
- ((XSDComponentViewer)getViewer()).setInput((XSDConcreteComponent)getModel());
- }
- }
- };
- Display.getCurrent().asyncExec(runnable);
- }
-
- public void doEditName()
- {
- removeFeedback();
- Object object = getModel();
- if (object instanceof XSDNamedComponent)
- {
- ComponentNameDirectEditManager manager = new ComponentNameDirectEditManager(this, label, (XSDNamedComponent)object);
- simpleDirectEditPolicy.setDelegate(manager);
- manager.show();
- }
- }
-
-
- static boolean reselect = false;
-
- public void setReselect(boolean state)
- {
- reselect = state;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java
deleted file mode 100644
index 37a83e11ba..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/TypeEditPart.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
-import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SimpleDirectEditPolicy;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-public class TypeEditPart extends BaseEditPart
-{
- protected SimpleDirectEditPolicy simpleDirectEditPolicy = new SimpleDirectEditPolicy();
-
- protected IFigure createFigure()
- {
- ContainerFigure typeGroup = new ContainerFigure();
-// typeGroup.setBorder(new SimpleRaisedBorder(1));
-// typeGroup.setBorder(new LineBorder(1));
-// typeGroup.setBorder(new RoundedLineBorder(1,5));
-
- Label typeLabel = new Label("type");
- typeLabel.setBorder(new MarginBorder(0,2,2,1));
- typeGroup.add(typeLabel);
-
- return typeGroup;
- }
-
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- }
-
- public XSDTypeDefinition getXSDTypeDefinition()
- {
- return (XSDTypeDefinition)getModel();
- }
-
-
- public List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- protected void createEditPolicies()
- {
- SelectionHandlesEditPolicyImpl policy = new SelectionHandlesEditPolicyImpl();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, policy);
- }
-
-
- public void performRequest(Request request)
- {
- super.performRequest(request);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java
deleted file mode 100644
index 53a86a19d0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/WildcardEditPart.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.MarginBorder;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDGraphUtil;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.GraphNodeFigure;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.RepeatableGraphNodeFigure;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDWildcard;
-
-
-public class WildcardEditPart extends RepeatableGraphNodeEditPart
-{
- protected Label label;
-
-
- public XSDParticle getXSDParticle()
- {
- Object o = getXSDWildcard().getContainer();
- return (o instanceof XSDParticle) ? (XSDParticle)o : null;
- }
-
-
- public XSDWildcard getXSDWildcard()
- {
- return (XSDWildcard)getModel();
- }
-
-
- protected GraphNodeFigure createGraphNodeFigure()
- {
- RepeatableGraphNodeFigure figure = new RepeatableGraphNodeFigure();
- figure.setConnected(true);
- figure.getOutlinedArea().setFill(true);
-
- label = new Label();
- label.setText(XSDEditorPlugin.getXSDString("_UI_ANY_ELEMENT"));
- label.setBorder(new MarginBorder(0, 6, 0, 4));
- label.setFont(mediumBoldFont);
-
- figure.getIconArea().add(label);
-
- return figure;
- }
-
-
- protected void refreshVisuals()
- {
- ContainerFigure rectangle = graphNodeFigure.getOutlinedArea();
- if (XSDGraphUtil.isEditable(getModel()))
- {
- rectangle.setBorder(new LineBorder(2));
- rectangle.setBackgroundColor(elementBackgroundColor);
- rectangle.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
-
- label.setBackgroundColor(elementBackgroundColor);
- label.setForegroundColor(elementLabelColor);
- }
- else
- {
- rectangle.setBorder(new LineBorder(readOnlyBorderColor, 2));
- rectangle.setBackgroundColor(readOnlyBackgroundColor);
- rectangle.setForegroundColor(isSelected ? ColorConstants.black : readOnlyBorderColor);
-
- label.setBackgroundColor(readOnlyBackgroundColor);
- label.setForegroundColor(readOnlyBorderColor);
- }
-
- refreshOccurenceLabel(getXSDParticle());
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
deleted file mode 100644
index 5d6ed1e13b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editparts;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartFactory;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDInheritanceViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-
-
-
-public class XSDEditPartFactory implements EditPartFactory
-{
- protected static XSDEditPartFactory instance;
-
- public static XSDEditPartFactory getInstance()
- {
- if (instance == null)
- {
- instance = new XSDEditPartFactory();
- }
- return instance;
- }
-
- public EditPart createEditPart(EditPart parent, Object model)
- {
- EditPart editPart = null;
-
- if (model instanceof Category)
- {
- editPart = new CategoryEditPart();
- }
- else if (model instanceof XSDElementDeclaration)
- {
- editPart = new ElementDeclarationEditPart();
- }
- else if (model instanceof XSDComplexTypeDefinition)
- {
- if (parent.getViewer() instanceof XSDInheritanceViewer)
- {
- editPart = new RootComplexTypeDefinitionEditPart();
- }
- else
- {
- if (parent instanceof CategoryEditPart)
- editPart = new RootComplexTypeDefinitionEditPart();
- else
- editPart = new ComplexTypeDefinitionEditPart();
- }
- }
- else if (model instanceof XSDModelGroup)
- {
- editPart = new ModelGroupEditPart();
- }
- else if (model instanceof XSDModelGroupDefinition)
- {
- if (parent instanceof CategoryEditPart)
- editPart = new RootModelGroupDefinitionEditPart();
- else
- editPart = new ModelGroupDefinitionEditPart();
- }
- else if (model instanceof XSDSchema)
- {
- editPart = new SchemaEditPart();
- }
- else if (model instanceof XSDWildcard)
- {
- editPart = new WildcardEditPart();
- }
- else if (model instanceof XSDSimpleTypeDefinition)
- {
- editPart = new SimpleTypeDefinitionEditPart();
- }
-
- if (editPart != null)
- {
- editPart.setModel(model);
- editPart.setParent(parent);
- }
- else
- {
-// System.out.println("can't create editPart for " + model);
-// Thread.dumpStack();
- }
- return editPart;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComboBoxCellEditorManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComboBoxCellEditorManager.java
deleted file mode 100644
index a7b23298b3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComboBoxCellEditorManager.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.tools.CellEditorLocator;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.ICellEditorListener;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public abstract class ComboBoxCellEditorManager extends DirectEditManager implements DirectEditPolicyDelegate
-{
- protected Label label;
-
- public ComboBoxCellEditorManager(GraphicalEditPart source, Label label)
- {
- super(source, ComboBoxCellEditor.class, new InternalCellEditorLocator(label));
- this.label = label;
- }
-
- protected void initCellEditor()
- {
- String initialLabelText = label.getText();
-
- CCombo combo = (CCombo)getCellEditor().getControl();
- combo.setFont(label.getFont());
- combo.setForeground(label.getForegroundColor());
- combo.setBackground(label.getBackgroundColor());
- /*
- combo.addKeyListener(new KeyAdapter() {
- // hook key pressed - see PR 14201
- public void keyPressed(KeyEvent keyEvent) {
- if (keyEvent.character == 'z') {
- getCellEditor().applyEditorValue();
- }
- }
- });
-*/
- ICellEditorListener cellEditorListener = new ICellEditorListener()
- {
- public void cancelEditor()
- {
-// System.out.println("cancelEditor");
- }
- public void applyEditorValue()
- {
-// System.out.println("applyEditorValue");
- }
- public void editorValueChanged(boolean old, boolean newState)
- {
-// System.out.println("editorValueChanged");
- }
- };
- getCellEditor().addListener(cellEditorListener);
-
- String[] item = combo.getItems();
- for (int i = 0; i < item.length; i++)
- {
- if (item[i].equals(initialLabelText))
- {
- getCellEditor().setValue(new Integer(i));
- break;
- }
- }
- }
-
- // hack... for some reason the ComboBoxCellEditor does't fire an editorValueChanged to set the dirty flag
- // unless we overide this method to return true, the manager is not notified of changes made in the cell editor
- protected boolean isDirty()
- {
- return true;
- }
-
- protected CellEditor createCellEditorOn(Composite composite)
- {
- boolean isLabelTextInList = false;
- List list = computeComboContent();
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- String string = (String)i.next();
- if (string.equals(label.getText()))
- {
- isLabelTextInList = true;
- break;
- }
- }
-
- if (!isLabelTextInList)
- {
- list.add(label.getText());
- }
-
- List sortedList = computeSortedList(list);
- String[] stringArray = new String[sortedList.size()];
- for (int i = 0; i < stringArray.length; i++)
- {
- stringArray[i] = (String)sortedList.get(i);
- }
- return new ComboBoxCellEditor(composite, stringArray);
- }
-
- protected List computeSortedList(List list)
- {
- return list;
- }
-
- protected abstract List computeComboContent();
-
- protected abstract void performModify(String value);
-
- public static class InternalCellEditorLocator implements CellEditorLocator
- {
- protected Label label;
-
- public InternalCellEditorLocator(Label label)
- {
- this.label = label;
- }
-
- public void relocate(CellEditor celleditor)
- {
- CCombo combo = (CCombo)celleditor.getControl();
- Point pref = combo.computeSize(-1, -1);
- Rectangle rect = label.getTextBounds().getCopy();
- label.translateToAbsolute(rect);
- combo.setBounds(rect.x-4, rect.y-1, pref.x+1, pref.y+1);
- }
- }
-
- // implements DirectEditPolicyDelegate
- //
- public void performEdit(CellEditor cellEditor)
- {
- CCombo combo = (CCombo)getCellEditor().getControl();
- int index = combo.getSelectionIndex();
- if (index != -1)
- {
- performModify(combo.getItem(index));
- }
- else
- {
- String typedValue = combo.getText();
- if (combo.indexOf(typedValue) != -1)
- {
- performModify(typedValue);
- }
- else
- {
- String closeMatch = getCloseMatch(typedValue, combo.getItems());
- if (closeMatch != null)
- {
- performModify(closeMatch);
- }
- else
- {
- Display.getCurrent().beep();
- }
- }
- }
- }
-
- protected String getCloseMatch(String value, String[] items)
- {
- int matchIndex = -1;
-
- for (int i = 0; i < items.length; i++)
- {
- String item = items[i];
- String a = getLocalName(value);
- String b = getLocalName(item);
- if (a.equalsIgnoreCase(b))
- {
- matchIndex = i;
- break;
- }
- }
- return matchIndex != -1 ? items[matchIndex] : null;
- }
-
- protected String getLocalName(String string)
- {
- int index = string.indexOf(":");
- return (index != -1) ? string.substring(index + 1) : string;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComponentNameDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComponentNameDirectEditManager.java
deleted file mode 100644
index 5f25abc244..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/ComponentNameDirectEditManager.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.TopLevelComponentEditPart;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalElementRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalGroupRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalSimpleOrComplexTypeRenamer;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDSwitch;
-
-
-
-public class ComponentNameDirectEditManager extends TextCellEditorManager
-{
- protected XSDNamedComponent component;
- protected static GraphicalEditPart mySource;
-
- public ComponentNameDirectEditManager(GraphicalEditPart source, Label label, XSDNamedComponent component)
- {
- super(source, label);
- this.component = component;
- mySource = source;
- }
-
- public void performModify(final String value)
- {
- if (value.length() > 0)
- {
- DelayedRenameRunnable runnable = new DelayedRenameRunnable(component, value);
- Display.getCurrent().asyncExec(runnable);
- }
- }
-
- protected static class DelayedRenameRunnable implements Runnable
- {
- protected XSDNamedComponent component;
- protected String name;
-
- public DelayedRenameRunnable(XSDNamedComponent component, String name)
- {
- this.component = component;
- this.name = name;
- }
-
- public void run()
- {
- XSDSwitch xsdSwitch = new XSDSwitch()
- {
- public Object caseXSDTypeDefinition(XSDTypeDefinition object)
- {
- new GlobalSimpleOrComplexTypeRenamer(object, name).visitSchema(object.getSchema());
- return null;
- }
-
- public Object caseXSDElementDeclaration(XSDElementDeclaration object)
- {
- if (object.isGlobal())
- {
- new GlobalElementRenamer(object, name).visitSchema(object.getSchema());
- }
- return null;
- }
-
- public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object)
- {
- new GlobalGroupRenamer(object, name).visitSchema(object.getSchema());
- return null;
- }
- };
- xsdSwitch.doSwitch(component);
- component.setName(name);
- if (mySource instanceof TopLevelComponentEditPart)
- {
- ((TopLevelComponentEditPart)mySource).setReselect(true);
- }
- }
- }
-
- protected void bringDown()
- {
- super.bringDown();
- if (mySource != null)
- {
- if (mySource instanceof TopLevelComponentEditPart)
- {
- ((TopLevelComponentEditPart)mySource).setReselect(true);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DirectEditPolicyDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DirectEditPolicyDelegate.java
deleted file mode 100644
index b5cce8b090..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DirectEditPolicyDelegate.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import org.eclipse.jface.viewers.CellEditor;
-
-public interface DirectEditPolicyDelegate
-{
- public void performEdit(CellEditor cellEditor);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropCommand.java
deleted file mode 100644
index aa7a60d95f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropCommand.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.FigureCanvas;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
-import org.eclipse.wst.xsd.ui.internal.actions.MoveAction;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.IConnectionRenderingViewer;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ComplexTypeDefinitionEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.GraphNodeEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ModelGroupDefinitionEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.ModelGroupEditPart;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-
-public class DragAndDropCommand extends Command //AbstractCommand
-{
- protected EditPartViewer viewer;
- protected ChangeBoundsRequest request;
- protected GraphNodeEditPart childRefEditPart;
- public GraphNodeEditPart parentEditPart;
- public Point location;
- protected MoveAction action;
- protected boolean canExecute;
-
- public DragAndDropCommand(EditPartViewer viewer, ChangeBoundsRequest request)
- {
- this.viewer = viewer;
- this.request = request;
-
- location = request.getLocation();
- EditPart target = viewer.findObjectAt(location);
- if (viewer instanceof ScrollingGraphicalViewer)
- {
- ScrollingGraphicalViewer sgv = (ScrollingGraphicalViewer)viewer;
- Point p = ((FigureCanvas)sgv.getControl()).getViewport().getViewLocation();
- location.y += p.y;
- location.x += p.x;
- }
-
- List list = request.getEditParts();
- if (list.size() > 0)
- {
- parentEditPart = getParentEditPart(target);
- if (parentEditPart != null)
- {
- for (Iterator i = parentEditPart.getChildren().iterator(); i.hasNext(); )
- {
- EditPart child = (EditPart)i.next();
- if (child instanceof GraphNodeEditPart)
- {
- GraphNodeEditPart childGraphNodeEditPart = (GraphNodeEditPart)child;
- Rectangle rectangle = childGraphNodeEditPart.getSelectionFigure().getBounds();
-
- if (location.y < rectangle.getCenter().y)
- {
- childRefEditPart = childGraphNodeEditPart;
- break;
- }
- }
- }
-
- List editPartsList = request.getEditParts();
- List concreteComponentList = new ArrayList(editPartsList.size());
- for (Iterator i = editPartsList.iterator(); i.hasNext(); )
- {
- EditPart editPart = (EditPart)i.next();
- concreteComponentList.add((XSDConcreteComponent)editPart.getModel());
- }
- XSDConcreteComponent refComponent = childRefEditPart != null ? (XSDConcreteComponent)childRefEditPart.getModel() : null;
-
- action = new MoveAction((XSDConcreteComponent)parentEditPart.getModel(), concreteComponentList, refComponent);
- canExecute = action.canMove();
- }
- }
- }
-
- protected GraphNodeEditPart getParentEditPart(EditPart target)
- {
- GraphNodeEditPart result = null;
- while (target != null)
- {
- if (target instanceof ModelGroupEditPart)
- {
- result = (GraphNodeEditPart)target;
- break;
- }
- else if (target instanceof ComplexTypeDefinitionEditPart ||
- target instanceof ModelGroupDefinitionEditPart)
- {
- List list = target.getChildren();
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- Object child = i.next();
- if (child instanceof ModelGroupEditPart)
- {
- result = (GraphNodeEditPart)child;
- break;
- }
- }
- if (result != null)
- {
- break;
- }
- }
- target = target.getParent();
- }
- return result;
- }
-
- public void execute()
- {
- if (canExecute)
- {
- action.run();
- }
- }
-
- public void redo()
- {
-
- }
-
- public void undo()
- {
- }
-
- public boolean canExecute()
- {
- return canExecute;
- }
-
- public PointList getConnectionPoints(Rectangle draggedFigureBounds)
- {
- PointList pointList = null;
- if (parentEditPart != null && childRefEditPart != null && viewer instanceof IConnectionRenderingViewer)
- {
- pointList = ((IConnectionRenderingViewer)viewer).getConnectionRenderingFigure().getConnectionPoints(parentEditPart, childRefEditPart, draggedFigureBounds);
- }
- return pointList != null ? pointList : new PointList();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropEditPolicy.java
deleted file mode 100644
index 18468c8457..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/DragAndDropEditPolicy.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import org.eclipse.gef.EditPartViewer;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-
-public class DragAndDropEditPolicy extends org.eclipse.gef.editpolicies.GraphicalEditPolicy
-{
- protected EditPartViewer viewer;
- protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
-
- public DragAndDropEditPolicy(EditPartViewer viewer, SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy)
- {
- this.viewer = viewer;
- this.selectionHandlesEditPolicy = selectionHandlesEditPolicy;
- }
-
- public boolean understandsRequest(Request req)
- {
- return true;
- }
-
- static int count2 = 0;
- boolean theCommandResult = true;
-
- public org.eclipse.gef.commands.Command getCommand(Request request)
- {
- // this block is commented out to disable move for now
- DragAndDropCommand command = null;
- if (request instanceof ChangeBoundsRequest)
- {
- command = new DragAndDropCommand(viewer, (ChangeBoundsRequest)request);
- selectionHandlesEditPolicy.setDragAndDropCommand(command);
- }
- return command;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/GraphNodeDragTracker.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/GraphNodeDragTracker.java
deleted file mode 100644
index 58fbaac656..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/GraphNodeDragTracker.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.tools.DragEditPartsTracker;
-
-
-public class GraphNodeDragTracker extends DragEditPartsTracker
-{
- protected EditPart editPart;
-
- public GraphNodeDragTracker(EditPart editPart)
- {
- super(editPart);
- this.editPart = editPart;
- }
-
- protected Command getCommand()
- {
- Request request = getTargetRequest();
- return editPart.getCommand(request);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SelectionHandlesEditPolicyImpl.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SelectionHandlesEditPolicyImpl.java
deleted file mode 100644
index d09b53a7c1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SelectionHandlesEditPolicyImpl.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.FigureUtilities;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Polyline;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.handles.MoveHandleLocator;
-import org.eclipse.gef.requests.ChangeBoundsRequest;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.BaseEditPart;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.IFeedbackHandler;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.BogusLayout;
-import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
-
-
-
-
-
-public class SelectionHandlesEditPolicyImpl extends SelectionHandlesEditPolicy
-{
- protected IFigure feedback;
- protected Rectangle originalLocation;
- protected DragAndDropCommand dragAndDropCommand;
-
- protected List createSelectionHandles()
- {
- List list = new ArrayList();
- EditPart editPart = getHost();
-
- if (editPart instanceof GraphicalEditPart)
- {
- GraphicalEditPart graphicalEditPart = (GraphicalEditPart)editPart;
- IFigure figure = (graphicalEditPart instanceof BaseEditPart) ?
- ((BaseEditPart)graphicalEditPart).getSelectionFigure() :
- graphicalEditPart.getFigure();
-
- Cursor cursorFigure = figure.getCursor();
- MoveHandleLocator loc = new MoveHandleLocator(figure);
- MoveHandle moveHandle = new MoveHandle(graphicalEditPart, loc);
- moveHandle.setCursor(cursorFigure);
- list.add(moveHandle);
- }
-
- return list;
- }
-
-
- public boolean understandsRequest(Request request)
- {
- boolean result = false;
-
- if (REQ_MOVE.equals(request.getType()))
- {
- result = false; // return false to disable move for now
- }
- else
- {
- result = super.understandsRequest(request);
- }
- return result;
- }
-
-
- public org.eclipse.gef.commands.Command getCommand(Request request)
- {
- return null;
- }
-
- public void setDragAndDropCommand(DragAndDropCommand dragAndDropCommand)
- {
- this.dragAndDropCommand = dragAndDropCommand;
- }
-
- protected org.eclipse.gef.commands.Command getMoveCommand(ChangeBoundsRequest request)
- {
- ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_MOVE_CHILDREN);
- req.setEditParts(getHost());
-
- req.setMoveDelta(request.getMoveDelta());
- req.setSizeDelta(request.getSizeDelta());
- req.setLocation(request.getLocation());
-
- return getHost().getParent().getCommand(req);
- }
-
- public void showSourceFeedback(Request request)
- {
- if (REQ_MOVE.equals(request.getType()) ||
- REQ_ADD.equals(request.getType()))
- showChangeBoundsFeedback((ChangeBoundsRequest)request);
- }
-
- protected void showChangeBoundsFeedback(ChangeBoundsRequest request)
- {
- IFigure p = getDragSourceFeedbackFigure();
- Rectangle r = originalLocation.getTranslated(request.getMoveDelta());
- Dimension resize = request.getSizeDelta();
- r.width += resize.width;
- r.height+= resize.height;
-
- ((GraphicalEditPart)getHost()).getFigure().translateToAbsolute(r);
- p.translateToRelative(r);
-
- Rectangle pBounds = r.getCopy();
-
- if (dragAndDropCommand != null && dragAndDropCommand.canExecute())
- {
- int size = request.getEditParts().size();
- if (size > 0 && request.getEditParts().get(size - 1) == getHost())
- {
- PointList pointList = dragAndDropCommand.getConnectionPoints(r);
- if (pointList != null && pointList.size() > 0)
- {
- polyLine.setPoints(pointList);
-
- Point firstPoint = pointList.getFirstPoint();
- if (firstPoint != null)
- {
- pBounds = pBounds.getUnion(new Rectangle(firstPoint.x, firstPoint.y, 1, 1));
- }
- }
- }
- }
- p.setBounds(pBounds);
- ghostShape.setBounds(r);
- p.validate();
- }
-
-
-
-
- protected IFigure getDragSourceFeedbackFigure()
- {
- EditPart editPart = getHost();
- if (feedback == null && editPart instanceof BaseEditPart)
- {
- BaseEditPart baseEditPart = (BaseEditPart)editPart;
- originalLocation = new Rectangle(baseEditPart.getSelectionFigure().getBounds());
- feedback = createDragSourceFeedbackFigure(baseEditPart.getSelectionFigure());
- }
- return feedback;
- }
-
- Polyline polyLine;
- RectangleFigure ghostShape;
-
- protected IFigure createDragSourceFeedbackFigure(IFigure draggedFigure)
- {
- // Use a ghost rectangle for feedback
- ContainerFigure panel = new ContainerFigure();
- panel.setLayoutManager(new BogusLayout());//new FreeformLayout());
-
- ghostShape = new RectangleFigure();
- FigureUtilities.makeGhostShape(ghostShape);
- ghostShape.setLineStyle(Graphics.LINE_DASHDOT);
- ghostShape.setForegroundColor(ColorConstants.white);
-
- Rectangle r = draggedFigure.getBounds();
- panel.setOpaque(false);
- panel.add(ghostShape);
-
- polyLine = new Polyline();
- //polyLine.setLineStyle(Graphics.LINE_DASHDOT);
- polyLine.setLineWidth(3);
- panel.add(polyLine);
-
- panel.setBounds(r);
- ghostShape.setBounds(r);
-
- addFeedback(panel);
-
- return panel;
- }
-
- public void deactivate()
- {
- if (feedback != null)
- {
- removeFeedback(feedback);
- feedback = null;
- }
- hideFocus();
- super.deactivate();
- }
-
- /**
- * Erase feedback indicating that the receiver object is
- * being dragged. This method is called when a drag is
- * completed or cancelled on the receiver object.
- * @param dragTracker org.eclipse.gef.tools.DragTracker The drag tracker of the tool performing the drag.
- */
- protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request)
- {
- if (feedback != null)
- {
- removeFeedback(feedback);
- }
- feedback = null;
- originalLocation = null;
- }
-
- /**
- * Erase feedback indicating that the receiver object is
- * being dragged. This method is called when a drag is
- * completed or cancelled on the receiver object.
- * @param dragTracker org.eclipse.gef.tools.DragTracker The drag tracker of the tool performing the drag.
- */
- public void eraseSourceFeedback(Request request)
- {
- if (REQ_MOVE.equals(request.getType()) || REQ_ADD.equals(request.getType()))
- {
- eraseChangeBoundsFeedback((ChangeBoundsRequest)request);
- }
- }
-
- protected void hideSelection()
- {
- EditPart editPart = getHost();
- if (editPart instanceof IFeedbackHandler)
- {
- ((IFeedbackHandler)editPart).removeFeedback();
- }
- }
-
- protected void showSelection()
- {
- EditPart editPart = getHost();
- if (editPart instanceof IFeedbackHandler)
- {
- ((IFeedbackHandler)editPart).addFeedback();
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SimpleDirectEditPolicy.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SimpleDirectEditPolicy.java
deleted file mode 100644
index 531eef2c86..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/SimpleDirectEditPolicy.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.DirectEditPolicy;
-import org.eclipse.gef.requests.DirectEditRequest;
-
-public class SimpleDirectEditPolicy extends DirectEditPolicy
-{
- protected DirectEditPolicyDelegate delegate;
-
- public void setDelegate(DirectEditPolicyDelegate delegate)
- {
- this.delegate = delegate;
- }
-
- protected org.eclipse.gef.commands.Command getDirectEditCommand(final DirectEditRequest request)
- {
- return new Command() //AbstractCommand()
- {
- public void execute()
- {
- if (delegate != null)
- {
- delegate.performEdit(request.getCellEditor());
- }
- }
-
- public void redo()
- {
- }
-
- public void undo()
- {
- }
-
- public boolean canExecute()
- {
- return true;
- }
- };
- }
-
- protected void showCurrentEditValue(DirectEditRequest request)
- {
- //hack to prevent async layout from placing the cell editor twice.
- getHostFigure().getUpdateManager().performUpdate();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TextCellEditorManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TextCellEditorManager.java
deleted file mode 100644
index 6409937fc3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TextCellEditorManager.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.tools.CellEditorLocator;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Text;
-
-public abstract class TextCellEditorManager extends DirectEditManager implements DirectEditPolicyDelegate
-{
- protected Label label;
-
- public TextCellEditorManager(GraphicalEditPart source, Label label)
- {
- super(source, TextCellEditor.class, new InternalCellEditorLocator(label));
- this.label = label;
- }
-
- protected void initCellEditor()
- {
- String initialLabelText = label.getText();
- getCellEditor().setValue(initialLabelText);
- Text text = (Text)getCellEditor().getControl();
- text.setFont(label.getFont());
- text.setForeground(label.getForegroundColor());
- text.setBackground(label.getBackgroundColor());
- text.selectAll();
- }
-
- protected abstract void performModify(String value);
-
- public static class InternalCellEditorLocator implements CellEditorLocator
- {
- protected Label label;
-
- public InternalCellEditorLocator(Label label)
- {
- this.label = label;
- }
-
- public void relocate(CellEditor celleditor)
- {
- Text text = (Text)celleditor.getControl();
- Point sel = text.getSelection();
- Point pref = text.computeSize(-1, -1);
- Rectangle rect = label.getTextBounds().getCopy();
- label.translateToAbsolute(rect);
- text.setBounds(rect.x-4, rect.y-1, pref.x+1, pref.y+1);
- text.setSelection(0);
- text.setSelection(sel);
- }
- }
-
- // implements DirectEditPolicyDelegate
- //
- public void performEdit(CellEditor cellEditor)
- {
- performModify((String)cellEditor.getValue());
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TypeReferenceDirectEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TypeReferenceDirectEditManager.java
deleted file mode 100644
index c62d1e9515..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editpolicies/TypeReferenceDirectEditManager.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.editpolicies;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.Label;
-import org.eclipse.gef.EditPart;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.BaseEditPart;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-
-
-
-public class TypeReferenceDirectEditManager extends ComboBoxCellEditorManager
-{
- protected BaseEditPart editPart;
- protected XSDElementDeclaration ed;
-
-
- public TypeReferenceDirectEditManager(BaseEditPart source, XSDElementDeclaration ed, Label label)
- {
- super(source, label);
- editPart = source;
- this.ed = ed;
- }
-
- protected List computeComboContent()
- {
- XSDSchema schema = ed.getSchema();
- List typeNameList = new ArrayList();
- if (schema != null)
- {
- TypesHelper typesHelper = new TypesHelper(schema);
- typeNameList.addAll(typesHelper.getUserSimpleTypeNamesList());
- typeNameList.addAll(typesHelper.getUserComplexTypeNamesList());
- typeNameList.addAll(typesHelper.getBuiltInTypeNamesList());
- }
- return typeNameList;
- }
-
- public void performModify(String value)
- {
- // we need to perform an asyncExec here since the 'host' editpart may be removed
- // as a side effect of performing the action
- DelayedRenameRunnable runnable = new DelayedRenameRunnable(editPart, ed, value);
- Display.getCurrent().asyncExec(runnable);
- }
-
-
- protected List computeSortedList(List list)
- {
- return TypesHelper.sortList(list);
- }
-
- protected static class DelayedRenameRunnable implements Runnable
- {
- protected BaseEditPart editPart;
- protected EditPart editPartParent;
- protected XSDElementDeclaration ed;
- protected String name;
-
- public DelayedRenameRunnable(BaseEditPart editPart, XSDElementDeclaration ed, String name)
- {
- this.editPart = editPart;
- editPartParent = editPart.getParent();
- this.ed = ed;
- this.name = name;
- }
-
- public void run()
- {
- //BaseGraphicalViewer viewer = editPart.getBaseGraphicalViewer();
- //viewer.setInputEnabled(false);
- //viewer.setSelectionEnabled(false);
- if (name.equals("<anonymous>"))
- {
- try
- {
- ed.getResolvedElementDeclaration().getElement().removeAttribute("type");
- }
- catch (Exception e)
- {
- }
- }
- else
- {
- if (ed.getResolvedElementDeclaration().getAnonymousTypeDefinition() != null) // isSetAnonymousTypeDefinition())
- {
- if (!(name.equals("<anonymous>")))
- {
- ed.getResolvedElementDeclaration().getElement().setAttribute("type", name);
- XSDDOMHelper.updateElementToNotAnonymous(ed.getResolvedElementDeclaration().getElement());
-// ed.getResolvedElementDeclaration().setAnonymousTypeDefinition(null);
- return;
- }
- }
- ed.getResolvedElementDeclaration().getElement().setAttribute("type", name);
- }
- //viewer.setInputEnabled(true);
- //viewer.setSelectionEnabled(true);
- //viewer.setSelection(new StructuredSelection(editPartParent));
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/BogusLayout.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/BogusLayout.java
deleted file mode 100644
index cfa8c75b4a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/BogusLayout.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.AbstractLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-
-
-/**
- * Figures using the StackLayout as their layout manager have
- * their children placed on top of one another. Order of
- * placement is determined by the order in which the children
- * were added, first child added placed on the bottom.
- */
-public class BogusLayout
- extends AbstractLayout
-{
-
-protected int spacing;
-
-public BogusLayout(){}
-
-protected Dimension calculatePreferredSize(IFigure figure, int w, int h)
-{
- Dimension d = new Dimension();
- return d;
-}
-
-/*
- * Returns the minimum size required by the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- */
-/*jvh - final
-public Dimension getMinimumSize(IFigure figure){
- return new Dimension();
-}
-
-public Dimension getPreferredSize(IFigure figure){
- return new Dimension();
-} */
-
-/*
- * Lays out the children on top of each other with
- * their sizes equal to that of the available
- * paintable area of the input container figure.
- */
-public void layout(IFigure figure){
-
-}
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenterLayout.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenterLayout.java
deleted file mode 100644
index a0087abeb5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenterLayout.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.AbstractLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-/**
- * Figures using the StackLayout as their layout manager have
- * their children placed on top of one another. Order of
- * placement is determined by the order in which the children
- * were added, first child added placed on the bottom.
- */
-public class CenterLayout
- extends AbstractLayout
-{
-
-protected int spacing;
-
-public CenterLayout(){}
-public CenterLayout(int spacing){ this.spacing = spacing; }
-
-/**
- * Calculates and returns the preferred size of the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- *
- * @param figure Container figure for which preferred size is required.
- * @return The preferred size of the input figure.
- */
-protected Dimension calculatePreferredSize(IFigure figure, int w, int h){
- Dimension d = calculatePreferredClientAreaSize(figure);
- /*d.expand(figure.getInsets().getWidth(),
- figure.getInsets().getHeight()); */
- d.expand(w,
- h);
- d.union(getBorderPreferredSize(figure));
- return d;
-}
-
-protected Dimension calculatePreferredClientAreaSize(IFigure figure){
- Dimension d = new Dimension();
- List children = figure.getChildren();
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- Dimension childSize = child.getPreferredSize();
- d.height += childSize.height;
- d.width = Math.max(childSize.width, d.width);
- }
- int childrenSize = children.size();
- if (childrenSize > 0)
- {
- d.height += spacing * children.size() - 1;
- }
- return d;
-}
-
-/*
- * Returns the minimum size required by the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- */
-public Dimension getMinimumSize(IFigure figure, int wHint, int hHint){
- Dimension d = new Dimension();
- List children = figure.getChildren();
- IFigure child;
- for (int i=0; i < children.size(); i++){
- child = (IFigure)children.get(i);
- d.union(child.getMinimumSize());
- }
- d.expand(figure.getInsets().getWidth(),
- figure.getInsets().getHeight());
- return d;
-}
-
-public Dimension getPreferredSize(IFigure figure, int wHint, int hHint){
- return calculatePreferredSize(figure, wHint, hHint);
-}
-
-
-/*
- * Lays out the children on top of each other with
- * their sizes equal to that of the available
- * paintable area of the input container figure.
- */
-public void layout(IFigure figure){
- Rectangle r = figure.getClientArea();
- List children = figure.getChildren();
-
- Dimension preferredClientAreaSize = calculatePreferredClientAreaSize(figure);
- int x = r.x + (r.width - preferredClientAreaSize.width) / 2;
- int y = r.y + (r.height - preferredClientAreaSize.height) / 2;
-
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- Dimension childSize = child.getPreferredSize();
- child.setBounds(new Rectangle(x, y, childSize.width, childSize.height));
- y += childSize.height + spacing;
- }
-}
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenteredIconFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenteredIconFigure.java
deleted file mode 100644
index 3426bb00d8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/CenteredIconFigure.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.graphics.Image;
-
-
-public class CenteredIconFigure extends ContainerFigure
-{
- public Image image;
-
- public CenteredIconFigure()
- {
- super();
- setFill(true);
- }
-
- protected void fillShape(Graphics g)
- {
- super.fillShape(g);
- if (image != null)
- {
- Rectangle r = getBounds();
- Dimension imageSize = new Dimension(16, 16);
- g.drawImage(image, r.x + (r.width - imageSize.width)/2, r.y + (r.height - imageSize.height)/2);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ConnectionFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ConnectionFigure.java
deleted file mode 100644
index aaa05f11c2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ConnectionFigure.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.wst.xsd.ui.internal.graph.editparts.GraphNodeEditPart;
-
-
-
-public class ConnectionFigure extends RectangleFigure
-{
- protected boolean isOutlined = true;
- protected IFigure xsdFigure;
-
- public ConnectionFigure(IFigure xsdFigure)
- {
- setOpaque(false);
- this.xsdFigure = xsdFigure;
- //setFocusTraversable(false);
- //setEnabled(false);
- }
-
- protected boolean isMouseEventTarget()
- {
- return false;
- }
-
- public boolean containsPoint(int x, int y){return false;}
-
- protected void fillShape(Graphics graphics)
- {
- graphics.setForegroundColor(ColorConstants.black);
- drawLines(graphics, xsdFigure);
- }
-
- protected void drawLines(Graphics graphics, IFigure figure)
- {
- if (figure instanceof GraphNodeFigure)
- {
- GraphNodeFigure graphNodeFigure = (GraphNodeFigure)figure;
- if (graphNodeFigure.isConnected() && graphNodeFigure.isExpanded())
- {
- List childList = graphNodeFigure.getChildGraphNodeFigures();
- if (childList.size() > 0)
- {
- Rectangle r = graphNodeFigure.getConnectionRectangle();
-
- int x1 = r.x + r.width;
- int y1 = r.y + r.height/2;
-
- int startOfChildBox = ((GraphNodeFigure)childList.get(0)).getConnectionRectangle().x;
-
- int x2 = x1 + (startOfChildBox - x1) / 3;
- int y2 = y1;
-
- if (childList.size() > 1)
- {
- graphics.drawLine(x1, y1, x2, y2);
-
- int minY = Integer.MAX_VALUE;
- int maxY = -1;
-
- for (Iterator i = childList.iterator(); i.hasNext(); )
- {
- GraphNodeFigure childGraphNodeFigure = (GraphNodeFigure)i.next();
- Rectangle childConnectionRectangle = childGraphNodeFigure.getConnectionRectangle();
- int y = childConnectionRectangle.y + childConnectionRectangle.height / 2;
-
- minY = Math.min(minY, y);
- maxY = Math.max(maxY, y);
- graphics.drawLine(x2, y, childConnectionRectangle.x, y);
- }
- graphics.drawLine(x2, minY, x2, maxY);
- }
- else
- {
- graphics.drawLine(x1, y1, startOfChildBox, y2);
- }
- }
- }
- }
-
- //boolean visitChildren = true;
- List children = figure.getChildren();
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- drawLines(graphics, child);
- }
- }
-
-
- // This method supports the preview connection line function related to drag and drop
- //
- public PointList getConnectionPoints(GraphNodeEditPart parentEditPart, GraphNodeEditPart childRefEditPart, Rectangle draggedFigureBounds)
- {
- PointList pointList = new PointList();
- int[] data = new int[1];
- Point a = getConnectionPoint(parentEditPart, childRefEditPart, data);
- if (a != null)
- {
- int draggedFigureBoundsY = draggedFigureBounds.y + draggedFigureBounds.height/2;
-
- pointList.addPoint(a);
- //pointList.addPoint(new Point(draggedFigureBounds.x, draggedFigureBoundsY));
-
- if (data[0] == 0) // insert between 2 items
- {
- int x = a.x + (draggedFigureBounds.x - a.x)/2;
- pointList.addPoint(new Point(x, a.y));
- pointList.addPoint(new Point(x, draggedFigureBoundsY));
- pointList.addPoint(new Point(draggedFigureBounds.x, draggedFigureBoundsY));
- }
- else // insert at first or last position
- {
- pointList.addPoint(new Point(a.x, draggedFigureBoundsY));
- pointList.addPoint(new Point(draggedFigureBounds.x, draggedFigureBoundsY));
- }
- }
- return pointList;
- }
-
-
- // This method supports the preview connection line function related to drag and drop
- //
- protected Point getConnectionPoint(GraphNodeEditPart parentEditPart, GraphNodeEditPart childRefEditPart, int[] data)
- {
- Point point = null;
- List childList = parentEditPart.getChildren();
-
- //TreeNodeIconFigure icon = ((TreeNodeFigure)parent.getFigure()).treeNodeIconFigure;
-
- if (childList.size() > 0)
- {
- point = new Point();
-
- GraphNodeEditPart prev = null;
- GraphNodeEditPart next = null;
-
- for (Iterator i = childList.iterator(); i.hasNext(); )
- {
- Object o = i.next();
- if (o instanceof GraphNodeEditPart)
- {
- GraphNodeEditPart childEditPart = (GraphNodeEditPart)o;
- if (childEditPart == childRefEditPart)
- {
- next = childEditPart;
- break;
- }
- prev = childEditPart;
- }
- }
-
- if (next != null && prev != null)
- {
- int ya = prev.getConnectionRectangle().getCenter().y;
- int yb = next.getConnectionRectangle().getCenter().y;
- point.y = ya + (yb - ya)/2;
- data[0] = 0;
- }
- else if (prev != null) // add it last
- {
- point.y = prev.getConnectionRectangle().getCenter().y;
- data[0] = 1;
- }
- else if (next != null) // add it first!
- {
- point.y = next.getConnectionRectangle().getCenter().y;
- data[0] = -1;
- }
-
- if (next != null || prev != null)
- {
- GraphNodeEditPart child = prev != null ? prev : next;
- int startOfChildBox = child.getConnectionRectangle().x;
- Rectangle r = parentEditPart.getConnectionRectangle();
- int x1 = r.x + r.width;
- point.x = x1 + (startOfChildBox - x1) / 3;
- }
- }
- return point;
- }
-
-
- protected void outlineShape(Graphics graphics)
- {
- if (isOutlined)
- {
- super.outlineShape(graphics);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerFigure.java
deleted file mode 100644
index 8594005a03..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerFigure.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.LayoutManager;
-import org.eclipse.draw2d.RectangleFigure;
-
-public class ContainerFigure extends RectangleFigure
-{
- protected boolean isOutlined = false;
-
- public ContainerFigure()
- {
- setLayoutManager(new ContainerLayout());
- setFill(false);
- }
-
- public void doLayout()
- {
- layout();
- setValid(true);
- }
-
- public ContainerLayout getContainerLayout()
- {
- return (ContainerLayout)getLayoutManager();
- }
-
- public void setOutlined(boolean isOutlined)
- {
- this.isOutlined = isOutlined;
- }
-
- protected void outlineShape(Graphics graphics)
- {
- if (isOutlined)
- {
- super.outlineShape(graphics);
- }
- }
-
-
- public void validate()
- {
- if (isValid())
- {
- return;
- }
- super.validate();
- postLayout();
- }
-
-
- protected void postLayout()
- {
- LayoutManager layoutManager = getLayoutManager();
- if (layoutManager instanceof PostLayoutManager)
- {
- ((PostLayoutManager)layoutManager).postLayout(this);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerLayout.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerLayout.java
deleted file mode 100644
index a30b6b89f9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ContainerLayout.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.AbstractLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.wst.xsd.ui.internal.gef.util.figures.SpacingFigure;
-
-public class ContainerLayout extends AbstractLayout implements PostLayoutManager
-{
- protected boolean isHorizontal;
- protected int spacing = 0;
- protected int border = 0;
-
- public ContainerLayout()
- {
- this(true, 0);
- }
-
- public ContainerLayout(boolean isHorizontal, int spacing)
- {
- this.isHorizontal = isHorizontal;
- this.spacing = spacing;
- }
-
- public void setHorizontal(boolean isHorizontal)
- {
- this.isHorizontal = isHorizontal;
- }
-
- public void setSpacing(int spacing)
- {
- this.spacing = spacing;
- }
-
- public void setBorder(int border)
- {
- this.border = border;
- }
-
- /**
- * Calculates and returns the preferred size of the container
- * given as input.
- *
- * @param figure Figure whose preferred size is required.
- * @return The preferred size of the passed Figure.
- */
- protected Dimension calculatePreferredSize(IFigure parent, int w, int h)
- {
- Dimension preferred = null;
-
- // Here we ensure that an unexpanded container is given a size of (0,0)
- //
- if (parent instanceof GraphNodeContainerFigure)
- {
- GraphNodeContainerFigure graphNodeContainerFigure = (GraphNodeContainerFigure)parent;
- if (!graphNodeContainerFigure.isExpanded())
- {
- preferred = new Dimension();
- }
- }
-
- if (preferred == null)
- {
- preferred = new Dimension();
- List children = parent.getChildren();
-
- for (int i=0; i < children.size(); i++)
- {
- IFigure child = (IFigure)children.get(i);
-
- Dimension childSize = child.getPreferredSize();
- /*
- if (child instanceof Interactor)
- {
- childSize.width = 9;
- childSize.height = 9;
- }*/
-
- if (isHorizontal)
- {
- preferred.width += childSize.width;
- preferred.height = Math.max(preferred.height, childSize.height);
- }
- else
- {
- preferred.height += childSize.height;
- preferred.width = Math.max(preferred.width, childSize.width);
- }
- }
-
- int childrenSize = children.size();
- if (childrenSize > 1)
- {
- if (isHorizontal)
- {
- preferred.width += spacing * (childrenSize - 1);
- }
- else
- {
- preferred.height += spacing * (childrenSize - 1);
- }
- }
-
- preferred.width += border * 2;
- preferred.height += border * 2;
- preferred.width += parent.getInsets().getWidth();
- preferred.height += parent.getInsets().getHeight();
- }
- return preferred;
- }
-
-
- protected int alignFigure(IFigure parent, IFigure child)
- {
- int y = -1;
- return y;
- }
-
- public void layout(IFigure parent)
- {
- List children = parent.getChildren();
- Dimension preferred = new Dimension();
-
- int rx = 0;
- for (int i=0; i < children.size(); i++)
- {
- IFigure child = (IFigure)children.get(i);
- Dimension childSize = child.getPreferredSize();
- if (isHorizontal)
- {
- preferred.height = Math.max(preferred.height, childSize.height);
- rx += childSize.width;
- }
- else
- {
- preferred.width = Math.max(preferred.width, childSize.width);
- }
- }
-
- if (isHorizontal)
- {
- preferred.height += border*2;
- preferred.width += border;
- }
- else
- {
- preferred.width += border*2;
- preferred.height += border;
- }
-
- int childrenSize = children.size();
- for (int i=0; i < childrenSize; i++)
- {
- IFigure child = (IFigure)children.get(i);
- Dimension childSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- int y = alignFigure(parent, child);
-
-
- if (y == -1)
- {
- y = (preferred.height - childSize.height) / 2;
- }
-
- Rectangle rectangle = new Rectangle(preferred.width, y, childSize.width, childSize.height);
- rectangle.translate(parent.getClientArea().getLocation());
-
- child.setBounds(rectangle);
- preferred.width += childSize.width;
- preferred.width += spacing;
-
- if (child instanceof SpacingFigure)
- {
- int availableHorizontalSpace = parent.getClientArea().width - rx;
- preferred.width += availableHorizontalSpace;
- }
- }
- else
- {
- Rectangle rectangle = new Rectangle(0, preferred.height, childSize.width, childSize.height);
- rectangle.translate(parent.getClientArea().getLocation());
- child.setBounds(rectangle);
- preferred.height += childSize.height;
- preferred.height += spacing;
- }
- }
- }
-
- public void postLayout(IFigure figure)
- {
- // This method attempts to align a 'FloatableFigure' (e.g. an Element node)
- // with any content that it is connected to. This way a chain of connected figures
- // will be vertically aligned (e.g. element -> modelgroup -> element). Any visible clipping of the
- // figures in the graph is probably a result of a bug in this code that results in a 'FloatableFigure' being
- // repositioned beyond the bounds of its parent.
- //
- for (Iterator i = figure.getChildren().iterator(); i.hasNext();)
- {
- IFigure child = (IFigure)i.next();
- if (child instanceof FloatableFigure)
- {
- FloatableFigure floatableFigure = (FloatableFigure)child;
- GraphNodeFigure graphNodeFigure = floatableFigure.getGraphNodeFigure();
- if (graphNodeFigure.isExpanded() && graphNodeFigure.getChildGraphNodeFigures().size() == 1)
- {
- GraphNodeFigure alignedChild = (GraphNodeFigure)graphNodeFigure.getChildGraphNodeFigures().get(0);
- Rectangle alignedChildBounds = alignedChild.getConnectionRectangle();
- Rectangle childBounds = child.getBounds();
-
- int l = childBounds.y + childBounds.height/2;
- int r = alignedChildBounds.y + alignedChildBounds.height/2;
- int delta = r - l;
-
- fixUp(child, delta);
- }
- }
- }
- }
-
- protected void fixUp(IFigure figure, int delta)
- {
- Rectangle bounds = figure.getBounds();
- bounds.y += delta;
- figure.setBounds(bounds);
-
- for (Iterator i = figure.getChildren().iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- fixUp(child, delta);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ExpandableGraphNodeFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ExpandableGraphNodeFigure.java
deleted file mode 100644
index e3391037ba..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/ExpandableGraphNodeFigure.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-// ------------------------------------------------------------
-// | ExpandableGraphNodeFigure |
-// | |
-// | ---------------------------------- --------------- |
-// | | verticalGroup | | | |
-// | | | | | |
-// | | ----------------------------- | | | |
-// | | | horizontalGroup | | | | |
-// | | | | | | | |
-// | | | --------------------- | | | | |
-// | | | | outlinedArea | | | | | |
-// | | | | ----------------- | | | | outer | |
-// | | | | | iconArea | | | | | Content | |
-// | | | | ----------------- | [+] | | | Area | |
-// | | | | ----------------- | | | | | |
-// | | | | | innerContent | | | | | | |
-// | | | | ----------------- | | | | | |
-// | | | --------------------- | | | | |
-// | | ----------------------------- | | | |
-// | | | | | |
-// | | ------------------ | | | |
-// | | | occurenceArea | | | | |
-// | | ------------------ | | | |
-// | ---------------------------------- --------------- |
-// ------------------------------------------------------------
-
-public class ExpandableGraphNodeFigure extends RepeatableGraphNodeFigure
-{
- protected ContainerFigure horizontalGroup;
- protected Interactor interactor;
- protected ContainerFigure outerContentArea;
-
- public boolean isExpanded()
- {
- return interactor.isExpanded();
- }
-
- public void setExpanded(boolean isExpanded)
- {
- interactor.setExpanded(isExpanded);
- }
-
- public ExpandableGraphNodeFigure()
- {
- super();
- isConnected = true;
- }
-
- protected void createFigure()
- {
- createPreceedingSpace(this);
- createVerticalGroup(this);
- createHorizontalGroup(verticalGroup);
- createOutlinedArea(horizontalGroup);
- createInteractor(horizontalGroup);
- createOccurenceArea(verticalGroup);
- createOuterContentArea(this);
- }
-
- protected void createVerticalGroup(IFigure parent)
- {
- verticalGroup = new FloatableFigure(this);
- verticalGroup.getContainerLayout().setHorizontal(false);
- parent.add(verticalGroup);
- }
-
- protected void createHorizontalGroup(IFigure parent)
- {
- horizontalGroup = new ContainerFigure();
- parent.add(horizontalGroup);
- }
-
- protected void createInteractor(IFigure parent)
- {
- interactor = new Interactor();
- interactor.setForegroundColor(ColorConstants.black);
- interactor.setBackgroundColor(ColorConstants.white);
- parent.add(interactor);
- }
-
- protected void createOuterContentArea(IFigure parent)
- {
- // create a small space between the interactor and the contentArea
- //
- RectangleFigure space = new RectangleFigure();
- space.setVisible(false);
- space.setPreferredSize(new Dimension(5, 10));
- parent.add(space);
-
- outerContentArea = new GraphNodeContainerFigure(this);
- outerContentArea.getContainerLayout().setHorizontal(false);
- parent.add(outerContentArea);
- }
-
- public Interactor getInteractor()
- {
- return interactor;
- }
-
- public ContainerFigure getOuterContentArea()
- {
- return outerContentArea;
- }
-
- public IFigure getConnectionFigure()
- {
- return horizontalGroup;
- }
-
- public Rectangle getConnectionRectangle()
- {
- return horizontalGroup.getBounds();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FillLayout.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FillLayout.java
deleted file mode 100644
index 221c147b24..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FillLayout.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.draw2d.AbstractLayout;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-/**
- * Figures using the StackLayout as their layout manager have
- * their children placed on top of one another. Order of
- * placement is determined by the order in which the children
- * were added, first child added placed on the bottom.
- */
-public class FillLayout extends AbstractLayout
-{
-
-protected boolean isHorizontal = false;
-protected int spacing = 0;
-public Dimension min;
-
-public FillLayout(){}
-public FillLayout(boolean dummy){}
-
-public FillLayout(int spacing)
-{
- this.spacing = spacing;
-}
-
-public void setHorizontal(boolean isHorizontal)
-{
- this.isHorizontal = isHorizontal;
-}
-
-/**
- * Calculates and returns the preferred size of the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- *
- * @param figure Container figure for which preferred size is required.
- * @return The preferred size of the input figure.
- */
-protected Dimension calculatePreferredSize(IFigure figure, int w, int h)
-{
- Dimension d = calculatePreferredClientAreaSize(figure);
- d.expand(figure.getInsets().getWidth(),
- figure.getInsets().getHeight());
- //d.union(getBorderPreferredSize(figure));
- return d;
-}
-
-protected Dimension calculatePreferredClientAreaSize(IFigure figure)
-{
- Dimension d = new Dimension();
- List children = figure.getChildren();
-
-
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- Dimension childSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- d.width += childSize.width;
- d.height = Math.max(childSize.height, d.height);
- }
- else
- {
- d.height += childSize.height;
- d.width = Math.max(childSize.width, d.width);
- }
- }
-
-
- int childrenSize = children.size();
- if (childrenSize > 0)
- {
- if (isHorizontal)
- d.width += spacing * (childrenSize - 1);
- else
- d.height += spacing * (childrenSize - 1);
- }
-
- if (min != null)
- {
- d.width = Math.max(d.width, min.width);
- d.height = Math.max(d.height, min.height);
- }
- return d;
-}
-
-/*
- * Returns the minimum size required by the input container.
- * This is the size of the largest child of the container, as all
- * other children fit into this size.
- */
-public Dimension getMinimumSize(IFigure figure, int w, int h)
-{
- Dimension d = new Dimension();
- List children = figure.getChildren();
- IFigure child;
- for (int i=0; i < children.size(); i++){
- child = (IFigure)children.get(i);
- d.union(child.getMinimumSize());
- }
- d.expand(figure.getInsets().getWidth(),
- figure.getInsets().getHeight());
- return d;
-}
-
-public Dimension getPreferredSize(IFigure figure, int w, int h)
-{
- return calculatePreferredSize(figure, w, h);
-}
-
-/*
- * Lays out the children on top of each other with
- * their sizes equal to that of the available
- * paintable area of the input container figure.
- */
-public void layout(IFigure figure){
-
- Dimension preferredSize = calculatePreferredClientAreaSize(figure);
- Rectangle r = figure.getClientArea().getCopy();
-
- List children = figure.getChildren();
-
- for (Iterator i = children.iterator(); i.hasNext(); )
- {
- IFigure child = (IFigure)i.next();
- Dimension childSize = child.getPreferredSize();
-
- if (isHorizontal)
- {
- child.setBounds(new Rectangle(r.x, r.y, childSize.width, Math.max(preferredSize.height, r.height)));
- r.x += childSize.width + spacing;
- }
- else
- {
- child.setBounds(new Rectangle(r.x, r.y, Math.max(preferredSize.width, r.width), childSize.height));
- r.y += childSize.height + spacing;
- }
- }
-}
-}
- \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FloatableFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FloatableFigure.java
deleted file mode 100644
index c224145ee0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/FloatableFigure.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-
-
-public class FloatableFigure extends ContainerFigure
-{
- public GraphNodeFigure graphNodeFigure;
-
- public FloatableFigure(GraphNodeFigure graphNodeFigure)
- {
- super();
- this.graphNodeFigure = graphNodeFigure;
- }
-
- public GraphNodeFigure getGraphNodeFigure()
- {
- return graphNodeFigure;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeContainerFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeContainerFigure.java
deleted file mode 100644
index c06a6556d3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeContainerFigure.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-
-
-public class GraphNodeContainerFigure extends ContainerFigure
-{
- public ExpandableGraphNodeFigure expandableGraphNodeFigure;
-
- public GraphNodeContainerFigure(ExpandableGraphNodeFigure expandableGraphNodeFigure)
- {
- super();
- this.expandableGraphNodeFigure = expandableGraphNodeFigure;
- }
-
- public boolean isExpanded()
- {
- return expandableGraphNodeFigure.isExpanded();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeFigure.java
deleted file mode 100644
index 3d9706d5a4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/GraphNodeFigure.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-// ------------------------------
-// | GraphNodeFigure |
-// | |
-// | ------------------------- |
-// | | vertical group | |
-// | | --------------------- | |
-// | | | outlined area | | |
-// | | | ----------------- | | |
-// | | | | icon area | | | |
-// | | | ----------------- | | |
-// | | | ----------------- | | |
-// | | | | inner content | | | |
-// | | | ----------------- | | |
-// | | --------------------- | |
-// | ------------------------- |
-// ------------------------------
-
-public class GraphNodeFigure extends ContainerFigure
-{
- protected ContainerFigure verticalGroup;
- protected ContainerFigure outlinedArea;
- protected ContainerFigure iconArea;
- protected ContainerFigure innerContentArea;
-
- protected boolean isConnected;
- protected boolean isIsolated;
-
- protected List childGraphNodeFigures = new ArrayList();
- protected GraphNodeFigure parentGraphNodeFigure;
-
- public GraphNodeFigure()
- {
- isIsolated = false;
- createFigure();
- }
-
- public boolean isExpanded()
- {
- return true;
- }
-
- public boolean isConnected()
- {
- return isConnected;
- }
-
- public void setConnected(boolean isConnected)
- {
- this.isConnected = isConnected;
- }
-
- public void setIsIsolated(boolean isIsolated)
- {
- this.isIsolated = isIsolated;
- }
-
- public boolean getIsIsolated()
- {
- return isIsolated;
- }
-
- protected void createFigure()
- {
- createVerticalGroup(this);
- createOutlinedArea(verticalGroup);
- }
-
- protected void createVerticalGroup(IFigure parent)
- {
- verticalGroup = new ContainerFigure();
- verticalGroup.getContainerLayout().setHorizontal(false);
- parent.add(verticalGroup);
- }
-
- protected void createOutlinedArea(IFigure parent)
- {
- outlinedArea = new ContainerFigure();
- outlinedArea.getContainerLayout().setHorizontal(false);
- parent.add(outlinedArea);
-
- iconArea = new ContainerFigure();
- outlinedArea.add(iconArea);
-
- innerContentArea = new ContainerFigure();
- innerContentArea.getContainerLayout().setHorizontal(false);
- outlinedArea.add(innerContentArea);
- }
-
- public ContainerFigure getIconArea()
- {
- return iconArea;
- }
-
- public ContainerFigure getOutlinedArea()
- {
- return outlinedArea;
- }
-
- public ContainerFigure getInnerContentArea()
- {
- return innerContentArea;
- }
-
- public IFigure getConnectionFigure()
- {
- return outlinedArea;
- }
-
- public Rectangle getConnectionRectangle()
- {
- return outlinedArea.getBounds();
- }
-
- public List getChildGraphNodeFigures()
- {
- return childGraphNodeFigures;
- }
-
- public void addNotify()
- {
- super.addNotify();
- if (isConnected())
- {
- parentGraphNodeFigure = computeParentGraphNodeFigure(this);
- if (parentGraphNodeFigure != null)
- {
- parentGraphNodeFigure.getChildGraphNodeFigures().add(this);
- }
- }
- }
-
- public void removeNotify()
- {
- super.removeNotify();
- if (parentGraphNodeFigure != null)
- {
- parentGraphNodeFigure.getChildGraphNodeFigures().remove(this);
- }
- }
-
- public GraphNodeFigure getParentGraphNodeFigure()
- {
- return parentGraphNodeFigure;
- }
-
- public GraphNodeFigure computeParentGraphNodeFigure(IFigure figure)
- {
- GraphNodeFigure result = null;
- IFigure parent = figure != null ? figure.getParent() : null;
- while (parent != null)
- {
- if (parent instanceof GraphNodeFigure)
- {
- GraphNodeFigure parentGraphNodeFigure = (GraphNodeFigure)parent;
- if (parentGraphNodeFigure.isConnected())
- {
- result = (GraphNodeFigure)parent;
- break;
- }
- }
- parent = parent.getParent();
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/Interactor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/Interactor.java
deleted file mode 100644
index 7a64b8fbac..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/Interactor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-/**
- * Interactor the +/- control commonly found in trees
- */
-public class Interactor extends RectangleFigure
-{
- protected boolean isExpanded;
-
- public Interactor()
- {
- super();
- setPreferredSize(new Dimension(9, 9));
- }
-
- public void setExpanded(boolean isExpanded)
- {
- this.isExpanded = isExpanded;
- }
-
- public boolean isExpanded()
- {
- return isExpanded;
- }
-
- protected void fillShape(Graphics g)
- {
- super.fillShape(g);
- Rectangle r = getBounds();
- int mx = r.x + r.width / 2;
- int my = r.y + r.height / 2;
- int s = 2;
- g.drawLine(r.x + s, my, r.x + r.width - s - 1, my);
- if (!isExpanded)
- {
- g.drawLine(mx, r.y + s, mx, r.y + r.height - s -1);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/LabelFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/LabelFigure.java
deleted file mode 100644
index 04c82b8430..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/LabelFigure.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.Figure;
-import org.eclipse.draw2d.FigureUtilities;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-
-
-public class LabelFigure extends Figure
-{
- protected String text = "";
- protected boolean isShowEmptyLabel = true;
- protected int left = 4;
- protected int right = 4;
- protected int textHeight;
- protected int textWidth;
-
- public LabelFigure()
- {
- setPreferredSize(new Dimension());
- }
-
- protected void setLeft(int left)
- {
- this.left = left;
- }
-
- protected void setRight(int right)
- {
- this.right = right;
- }
-
- public void setShowEmptyLabel(boolean isShowEmptyLabel)
- {
- this.isShowEmptyLabel = isShowEmptyLabel;
- }
-
-
- public void setText(String s)
- {
- if (s == null)
- s = "";
-
- if (!text.equals(s))
- {
- text = s;
- if (text.length() > 0 || isShowEmptyLabel)
- {
- textHeight = FigureUtilities.getFontMetrics(getFont()).getHeight();
- textWidth = FigureUtilities.getTextWidth(text, getFont());
- textWidth = Math.max(textWidth, FigureUtilities.getTextWidth("abcdefg", getFont()));
- setPreferredSize(new Dimension(textWidth + left + right, textHeight));
- }
- else
- {
- setPreferredSize(new Dimension());
- }
- }
- //revalidate();
- //repaint();
- }
-
-
-
- protected void paintFigure(Graphics graphics)
- //protected void fillShape(Graphics graphics)
- {
- super.paintFigure(graphics);
- //super.fillShape(graphics);
- if (text.length() > 0)
- {
- Rectangle r = getBounds();
- graphics.setForegroundColor(getForegroundColor());
- graphics.drawString(text, left + r.x, r.y);// + (r.width - textWidth)/2, r.y + (r.height - textHeight)/2);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/PostLayoutManager.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/PostLayoutManager.java
deleted file mode 100644
index 21a1f54274..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/PostLayoutManager.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.IFigure;
-
-
-public interface PostLayoutManager
-{
- public void postLayout(IFigure figure);
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RepeatableGraphNodeFigure.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RepeatableGraphNodeFigure.java
deleted file mode 100644
index fd8d2496c3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RepeatableGraphNodeFigure.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
-
-
-
-
-// ------------------------------
-// | RepeatableGraphNodeFigure |
-// | |
-// | ------------------------- |
-// | | vertical group | |
-// | | --------------------- | |
-// | | | outlined area | | |
-// | | | ----------------- | | |
-// | | | | icon area | | | |
-// | | | ----------------- | | |
-// | | | ----------------- | | |
-// | | | | inner content | | | |
-// | | | ----------------- | | |
-// | | --------------------- | |
-// | | | |
-// | | ------------------ | |
-// | | | occurence area | | |
-// | | ------------------ | |
-// | ------------------------- |
-// ------------------------------
-
-public class RepeatableGraphNodeFigure extends GraphNodeFigure
-{
- protected ContainerFigure occurenceArea;
- protected LabelFigure occurenceLabel;
-
- public RepeatableGraphNodeFigure()
- {
- super();
- }
-
- protected void createFigure()
- {
- createPreceedingSpace(this);
- createVerticalGroup(this);
- createOutlinedArea(verticalGroup);
- createOccurenceArea(verticalGroup);
- }
-
- protected void createOccurenceArea(IFigure parent)
- {
- occurenceArea = new ContainerFigure();
- occurenceLabel = new LabelFigure();
- occurenceLabel.setForegroundColor(ColorConstants.black);
- occurenceLabel.setShowEmptyLabel(false);
- occurenceLabel.setFont(GraphicsConstants.medium);
- occurenceArea.add(occurenceLabel);
- parent.add(occurenceArea);
- }
-
- protected void createPreceedingSpace(IFigure parent)
- {
- // create a small space
- RectangleFigure space = new RectangleFigure();
- space.setVisible(false);
- space.setPreferredSize(new Dimension(10, 10));
- parent.add(space);
- }
-
- public LabelFigure getOccurenceLabel()
- {
- return occurenceLabel;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RoundedLineBorder.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RoundedLineBorder.java
deleted file mode 100644
index 75dbff750c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/figures/RoundedLineBorder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.figures;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.draw2d.geometry.Insets;
-import org.eclipse.swt.graphics.Color;
-
-
-public class RoundedLineBorder extends LineBorder
-{
- protected int arcLength;
- protected int lineStyle = Graphics.LINE_SOLID;
-
- public RoundedLineBorder(Color c, int width, int arcLength)
- {
- super(c, width);
- this.arcLength = arcLength;
- }
-
- public RoundedLineBorder(int width, int arcLength)
- {
- super(width);
- this.arcLength = arcLength;
- }
-
- public RoundedLineBorder(Color c, int width, int arcLength, int lineStyle)
- {
- super(c, width);
- this.arcLength = arcLength;
- this.lineStyle = lineStyle;
- }
-
- public RoundedLineBorder(int width, int arcLength, int lineStyle)
- {
- super(width);
- this.arcLength = arcLength;
- this.lineStyle = lineStyle;
- }
-
- public void paint(IFigure figure, Graphics graphics, Insets insets)
- {
- int rlbWidth = getWidth();
- tempRect.setBounds(getPaintRectangle(figure, insets));
- if (rlbWidth%2 == 1)
- {
- tempRect.width--;
- tempRect.height--;
- }
- tempRect.shrink(rlbWidth/2,rlbWidth/2);
- graphics.setLineWidth(rlbWidth);
- graphics.setLineStyle(lineStyle);
- if (getColor() != null)
- graphics.setForegroundColor(getColor());
- graphics.drawRoundRectangle(tempRect, arcLength, arcLength);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/Category.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/Category.java
deleted file mode 100644
index 31aa07b526..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/Category.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNotationDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-public class Category implements ModelAdapter
-{
- public final static int ATTRIBUTES = 1;
- public final static int ELEMENTS = 2;
- public final static int TYPES = 3;
- public final static int GROUPS = 5;
- public final static int DIRECTIVES = 6;
- public final static int NOTATIONS = 7;
- public final static int ATTRIBUTE_GROUPS = 8;
- public final static int IDENTITY_CONSTRAINTS = 9;
- public final static int ANNOTATIONS = 10;
-
-
- protected XSDSchema schema;
- protected int groupType;
-
- //public void modelNameChanged();
- public Category(XSDSchema schema, int groupType)
- {
- this.schema = schema;
- this.groupType = groupType;
- }
-
- public int getGroupType()
- {
- return groupType;
- }
-
- public XSDSchema getXSDSchema()
- {
- return schema;
- }
-
- public String getName()
- {
- String name = "";
- switch (groupType)
- {
- case ATTRIBUTES : { name = XSDEditorPlugin.getXSDString("_UI_GRAPH_ATTRIBUTES"); break; }
- case NOTATIONS : { name = XSDEditorPlugin.getXSDString("_UI_GRAPH_NOTATIONS"); break; }
- case ELEMENTS : { name = XSDEditorPlugin.getXSDString("_UI_GRAPH_ELEMENTS"); break; }
- case TYPES : { name = XSDEditorPlugin.getXSDString("_UI_GRAPH_TYPES"); break; }
- case GROUPS : { name = XSDEditorPlugin.getXSDString("_UI_GRAPH_GROUPS"); break; }
- case DIRECTIVES : { name = XSDEditorPlugin.getXSDString("_UI_GRAPH_DIRECTIVES"); break; }
- }
- return name;
- }
-
- public List getChildren()
- {
- List list = Collections.EMPTY_LIST;
- switch (groupType)
- {
- case ATTRIBUTES : { list = getAttributeList(); break; }
- case NOTATIONS : { list = getNotations(); break; }
- case ELEMENTS : { list = getGlobalElements(); break; }
- case TYPES : { list = getTypes(); break; }
- case GROUPS : { list = getGroups(); break; }
- case DIRECTIVES : { list = getDirectives(); break; }
- }
- return list;
- }
-
- private boolean isSameNamespace(String ns1, String ns2)
- {
- if (ns1 == null) ns1 = "";
- if (ns2 == null) ns2 = "";
-
- if (ns1.equals(ns2))
- {
- return true;
- }
- return false;
- }
-
- protected List getGlobalElements()
- {
- List elements = schema.getElementDeclarations();
- List list = new ArrayList();
- for (Iterator i = elements.iterator(); i.hasNext(); )
- {
- XSDElementDeclaration elem = (XSDElementDeclaration)i.next();
- if (isSameNamespace(elem.getTargetNamespace(),schema.getTargetNamespace()))
- {
- list.add(elem);
- }
- }
- return list;
- }
-
- protected List getTypes()
- {
- List allTypes = schema.getTypeDefinitions();
- List list = new ArrayList();
- for (Iterator i = allTypes.iterator(); i.hasNext(); )
- {
- XSDTypeDefinition td = (XSDTypeDefinition)i.next();
- if (td instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)td;
- if (isSameNamespace(ct.getTargetNamespace(),schema.getTargetNamespace()))
- {
- list.add(ct);
- }
- }
- }
-
-// List simpleTypes = schema.getTypeDefinitions();
- for (Iterator i = allTypes.iterator(); i.hasNext(); )
- {
- XSDTypeDefinition td = (XSDTypeDefinition)i.next();
- if (td instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)td;
- if (isSameNamespace(st.getTargetNamespace(),schema.getTargetNamespace()))
- {
- list.add(st);
- }
- }
- }
- return list;
- }
-
- protected List getGroups()
- {
- List groups = schema.getModelGroupDefinitions();
- List list = new ArrayList();
- for (Iterator i = groups.iterator(); i.hasNext(); )
- {
- XSDModelGroupDefinition group = (XSDModelGroupDefinition)i.next();
- if (isSameNamespace(group.getTargetNamespace(),schema.getTargetNamespace()))
- {
- list.add(group);
- }
- }
- return list;
- }
-
- protected List getDirectives()
- {
- List list = new ArrayList();
- for (Iterator i = schema.getContents().iterator(); i.hasNext(); )
- {
- Object o = i.next();
- if (o instanceof XSDSchemaDirective)
- {
- list.add(o);
- }
- }
- return list;
- }
-
- protected List getAttributeList()
- {
- List attributesList = new ArrayList();
- for (Iterator iter = schema.getAttributeDeclarations().iterator(); iter.hasNext(); )
- {
- Object o = iter.next();
- if (o instanceof XSDAttributeDeclaration)
- {
- XSDAttributeDeclaration attr = (XSDAttributeDeclaration)o;
- if (attr != null)
- {
- if (attr.getTargetNamespace() != null)
- {
- if (!(attr.getTargetNamespace().equals("http://www.w3.org/2001/XMLSchema-instance")))
- {
- if (isSameNamespace(attr.getTargetNamespace(), schema.getTargetNamespace()))
- {
- attributesList.add(attr);
- }
- }
- }
- else
- {
- if (isSameNamespace(attr.getTargetNamespace(),schema.getTargetNamespace()))
- {
- attributesList.add(attr);
- }
- }
- }
- }
- }
- return attributesList;
- }
-
- protected List getNotations()
- {
- List notations = schema.getNotationDeclarations();
- List list = new ArrayList();
- for (Iterator i = notations.iterator(); i.hasNext(); )
- {
- XSDNotationDeclaration notation = (XSDNotationDeclaration)i.next();
- if (isSameNamespace(notation.getTargetNamespace(),schema.getTargetNamespace()))
- {
- list.add(notation);
- }
- }
- return list;
- }
-
- //
- protected List listenerList = new ArrayList();
-
- public void addListener(ModelAdapterListener l)
- {
- listenerList.add(l);
- }
-
- public void removeListener(ModelAdapterListener l)
- {
- listenerList.remove(l);
- }
-
- public Object getProperty(Object modelObject, String propertyName)
- {
- return null;
- }
-
- public void firePropertyChanged(Object modelObject, String propertyName)
- {
- List newList = new ArrayList();
- newList.addAll(listenerList);
- for (Iterator i = newList.iterator(); i.hasNext(); )
- {
- ModelAdapterListener l = (ModelAdapterListener)i.next();
- try
- {
- l.propertyChanged(modelObject, propertyName);
- }
- catch (Exception e)
- {
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapter.java
deleted file mode 100644
index 30669878a2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.model;
-
-
-
-public interface ModelAdapter
-{
- public static final String CHILDREN_PROPERTY = "CHILDREN_PROPERTY";
- public static final String LABEL_PROPERTY = "LABEL_PROPERTY";
- public static final String IMAGE_PROPERTY = "IMAGE_PROPERTY";
- public static final String DETAIL_PROPERTY = "DETAIL_PROPERTY";
-
- public void addListener(ModelAdapterListener l);
- public void removeListener(ModelAdapterListener l);
- public Object getProperty(Object modelObject, String propertyName);
- public void firePropertyChanged(Object modelObject, String propertyName);
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapterListener.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapterListener.java
deleted file mode 100644
index ff6e4db5f6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/ModelAdapterListener.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.model;
-
-
-
-public interface ModelAdapterListener
-{
- public void propertyChanged(Object object, String property);
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/XSDModelAdapterFactory.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/XSDModelAdapterFactory.java
deleted file mode 100644
index 98f051ade9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/model/XSDModelAdapterFactory.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.graph.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDAbstractAdapter;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDParticleContent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.util.XSDSwitch;
-
-
-
-
-public class XSDModelAdapterFactory
-{
- protected static XSDModelAdapterFactory instance;
- protected static XSDAdapterFactoryImpl xsdAdapterFactoryImpl = new XSDAdapterFactoryImpl();
-
- public static XSDModelAdapterFactory getInstance()
- {
- if (instance == null)
- {
- instance = new XSDModelAdapterFactory();
- }
- return instance;
- }
-
-
- public static ModelAdapter getAdapter(Object o)
- {
- ModelAdapter result = null;
- if (o instanceof Notifier)
- {
- Notifier target = (Notifier)o;
- Adapter adapter = xsdAdapterFactoryImpl.adapt(target);
- if (adapter instanceof XSDObjectAdapter)
- {
- result = (XSDObjectAdapter)adapter;
- }
- }
- else if (o instanceof ModelAdapter)
- {
- result = (ModelAdapter)o;
- }
- return result;
- }
-
-
- public static XSDObjectAdapter getExisitingAdapter(Object xsdObject)
- {
- XSDObjectAdapter result = null;
- if (xsdObject instanceof Notifier)
- {
- Notifier target = (Notifier)xsdObject;
- Adapter adapter = EcoreUtil.getExistingAdapter(target,xsdAdapterFactoryImpl);
- if (adapter instanceof XSDObjectAdapter)
- {
- result = (XSDObjectAdapter)adapter;
- }
- }
- return result;
- }
-
- //
- //
- //
- public static class XSDAdapterFactoryImpl extends AdapterFactoryImpl
- {
- public Adapter createAdapter(Notifier target)
- {
- XSDSwitch xsdSwitch = new XSDSwitch()
- {
- public Object caseXSDElementDeclaration(XSDElementDeclaration object)
- {
- return new XSDElementDeclarationAdapter(object);
- }
-
- public Object caseXSDParticle(XSDParticle object)
- {
- return new XSDParticleAdapter(object);
- }
-
- public Object caseXSDSchema(XSDSchema object)
- {
- return new XSDSchemaAdapter(object);
- }
-
- public Object defaultCase(EObject object)
- {
- return new XSDObjectAdapter();
- }
- };
- Object o = xsdSwitch.doSwitch((EObject)target);
-
- Adapter result = null;
- if (o instanceof Adapter)
- {
- result = (Adapter)o;
- }
- else
- {
-// System.out.println("did not create adapter for target : " + target);
-// Thread.dumpStack();
- }
- return result;
- }
-
-
- public Adapter adapt(Notifier target)
- {
- return adapt(target, this);
- }
- }
-
-
-
- //
- //
- //
- protected static class XSDObjectAdapter extends AdapterImpl implements ModelAdapter
- {
- protected List listenerList = new ArrayList();
- protected boolean isUpdating = false;
-
- public boolean isAdapterForType(Object type)
- {
- return type == xsdAdapterFactoryImpl;
- }
-
- public void addListener(ModelAdapterListener l)
- {
- listenerList.add(l);
- }
-
- public void removeListener(ModelAdapterListener l)
- {
- listenerList.remove(l);
- }
-
- public Object getProperty(Object modelObject, String propertyName)
- {
- Object result = null;
- if (ModelAdapter.LABEL_PROPERTY.equals(propertyName))
- {
- result = "";
- // TODO... move this logic into each adapter
- //
- if (modelObject instanceof XSDNamedComponent)
- {
- result = ((XSDNamedComponent)modelObject).getName();
- }
- else if (modelObject instanceof XSDSchemaDirective)
- {
- result = ((XSDSchemaDirective)modelObject).getSchemaLocation();
- if (result == null) result = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- if (result.equals("")) result = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- return result;
- }
- }
- else if ("drillDown".equals(propertyName))
- {
- // TODO... move this logic into each adapter
- //
- List list = XSDChildUtility.getModelChildren(modelObject);
- result = list.size() > 0 ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (ModelAdapter.IMAGE_PROPERTY.equals(propertyName))
- {
- // result = XSDEditorPlugin.getDefault().getImage("icons/XSDElement.gif");
- XSDModelAdapterFactoryImpl factory = XSDModelAdapterFactoryImpl.getInstance();
- Adapter adapter = factory.createAdapter((Notifier)modelObject);
- result = ((XSDAbstractAdapter)adapter).getImage(modelObject);
- }
- return result;
- }
-
- public void firePropertyChanged(Object modelObject, String propertyName)
- {
- List newList = new ArrayList();
- newList.addAll(listenerList);
- for (Iterator i = newList.iterator(); i.hasNext(); )
- {
- ModelAdapterListener l = (ModelAdapterListener)i.next();
- try
- {
- l.propertyChanged(modelObject, propertyName);
- }
- catch (Exception e)
- {
- }
- }
- }
-
- public void notifyChanged(Notification msg)
- {
- firePropertyChanged(msg.getNotifier(), null);
- }
- }
-
- protected static class XSDParticleAdapter extends XSDObjectAdapter implements ModelAdapterListener
- {
- protected XSDParticle particle;
-
- public XSDParticleAdapter(XSDParticle particle)
- {
- this.particle = particle;
- }
-
- public void notifyChanged(Notification msg)
- {
- XSDParticle xsdParticle = (XSDParticle)msg.getNotifier();
- XSDParticleContent xsdParticleContent = xsdParticle.getContent();
- XSDModelAdapterFactoryImpl factory = XSDModelAdapterFactoryImpl.getInstance();
- if (xsdParticleContent != null)
- {
- if (xsdParticleContent instanceof XSDElementDeclaration)
- {
- firePropertyChanged((XSDElementDeclaration)xsdParticleContent, null);
- factory.fireNotifyChanged(msg);
- }
- else if (xsdParticleContent instanceof XSDModelGroup)
- {
- firePropertyChanged((XSDModelGroup)xsdParticleContent, null);
- factory.fireNotifyChanged(msg);
- }
- else if (xsdParticleContent instanceof XSDWildcard)
- {
- firePropertyChanged((XSDWildcard)xsdParticleContent, null);
- factory.fireNotifyChanged(msg);
- }
- }
- }
-
-
- public void propertyChanged(Object object, String property)
- {
- firePropertyChanged(object, property);
- }
- }
-
- //
- //
- //
- protected static class XSDElementDeclarationAdapter extends XSDObjectAdapter implements ModelAdapterListener
- {
- protected XSDElementDeclaration ed;
- protected XSDTypeDefinition typeDefinition;
-
- public XSDElementDeclarationAdapter(XSDElementDeclaration ed)
- {
- this.ed = ed;
- updateTypeDefinition();
- }
-
- protected void updateTypeDefinition()
- {
- XSDTypeDefinition td = ed.getTypeDefinition();
- td = (td instanceof XSDComplexTypeDefinition) ? td : null;
- if (td != typeDefinition)
- {
- if (typeDefinition != null)
- {
- XSDObjectAdapter adapter = (XSDObjectAdapter)xsdAdapterFactoryImpl.adapt(typeDefinition);
- adapter.removeListener(this);
- }
- typeDefinition = td;
- if (typeDefinition != null)
- {
- XSDObjectAdapter adapter = (XSDObjectAdapter)xsdAdapterFactoryImpl.adapt(typeDefinition);
- adapter.addListener(this);
- }
- }
- }
-
-
- public void notifyChanged(Notification msg)
- {
- updateTypeDefinition();
- firePropertyChanged(msg.getNotifier(), null);
- }
-
-
- public void propertyChanged(Object object, String property)
- {
- // here we propagate typeDefinition changes to our listeners
- firePropertyChanged(object, property);
- }
- }
-
-
- //
- //
- protected static class XSDSchemaAdapter extends XSDObjectAdapter
- {
- protected XSDSchema schema;
- protected List groups;
-
- public XSDSchemaAdapter(XSDSchema schema)
- {
- this.schema = schema;
- groups = new ArrayList();
- groups.add(new Category(schema, Category.DIRECTIVES));
- groups.add(new Category(schema, Category.ATTRIBUTES));
- //groups.add(new Category(schema, Category.ATTRIBUTE_GROUPS));
- groups.add(new Category(schema, Category.ELEMENTS));
- groups.add(new Category(schema, Category.TYPES));
- //groups.add(new Category(schema, Category.SIMPLE_TYPES));
- groups.add(new Category(schema, Category.GROUPS));
- }
-
- public void notifyChanged(Notification msg)
- {
- super.notifyChanged(msg);
- for (Iterator i = groups.iterator(); i.hasNext(); )
- {
- ModelAdapter group = (ModelAdapter)i.next();
- group.firePropertyChanged(group, null);
- }
- }
-
- public Object getProperty(Object modelObject, String propertyName)
- {
- Object result = null;
- if ("groups".equals(propertyName))
- {
- /*
- List list = new ArrayList();
- for (Iterator i = groups.iterator(); i.hasNext(); )
- {
- Category group = (Category)i.next();
- if (group.getChildren().size() > 0)
- {
- list.add(group);
- }
- }
- result = list;*/
- result = groups;
- }
- if (result == null)
- {
- result = super.getProperty(modelObject, propertyName);
- }
- return result;
- }
- }
-
-
- public static void addModelAdapterListener(Object modelObject, ModelAdapterListener listener)
- {
- ModelAdapter modelAdapter = getModelAdapter(modelObject);
- if (modelAdapter != null)
- {
- modelAdapter.addListener(listener);
- }
- }
-
-
- public static void removeModelAdapterListener(Object modelObject, ModelAdapterListener listener)
- {
- ModelAdapter modelAdapter = getModelAdapter(modelObject);
- if (modelAdapter != null)
- {
- modelAdapter.removeListener(listener);
- }
- }
-
- protected static ModelAdapter getModelAdapter(Object modelObject)
- {
- ModelAdapter modelAdapter = null;
- if (modelObject instanceof Notifier)
- {
- modelAdapter = (ModelAdapter)xsdAdapterFactoryImpl.adapt((Notifier)modelObject);
- }
- else if (modelObject instanceof ModelAdapter)
- {
- modelAdapter = (ModelAdapter)modelObject;
- }
- return modelAdapter;
- }
-}
-
-
-
-// --------------------------------------------------------------------------------------------
-// todo... revist this stuff
-// --------------------------------------------------------------------------------------------
-
- /*
- public static void handleTypeChange(XSDTypeDefinition td, XSDSchema schema, int change)
- {
- try
- {
- TypeFindingSchemaVisitor visitor = new TypeFindingSchemaVisitor(schema, td, change == Notification.ADD);
- List list = visitor.findElementsUsingType(schema);
-
- if (change == Notification.REMOVE)
- {
- visitor.removeMatchingReferences();
- }
- else if (change == Notification.ADD)
- {
- visitor.setMatchingReferences();
- }
- else
- {
- visitor.cleanUpTypeMismatches();
- }
-
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- Object o = i.next();
- XSDObjectAdapter adapter = getExisitingAdapter(o);
- if (adapter != null)
- {
- adapter.fireChildrenChangedNotification();
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-
- protected static class TypeFindingSchemaVisitor extends org.eclipse.wst.xsd.utility.XSDVisitor
- {
- protected XSDTypeDefinition td;
- protected List list = new ArrayList();
- protected XSDSchema schema;
- protected boolean matchByName;
-
- public TypeFindingSchemaVisitor(XSDSchema schema, XSDTypeDefinition td, boolean matchByName)
- {
- this.td = td;
- this.schema = schema;
- this.matchByName = matchByName;
- }
-
- public void visitElementDeclaration(XSDElementDeclaration ed)
- {
- if (ed.getTypeDefinition() == td)
- {
- list.add(ed);
- }
- else if (matchByName)
- {
- String[] name = getDOMName(ed);
- if (name[0].equals(td.getTargetNamespace()) && name[1].equals(td.getName()))
- {
- list.add(ed);
- }
- }
- }
-
- public List findElementsUsingType(XSDSchema schema)
- {
- if (td != null)
- {
- visitSchema(schema);
- }
- return list;
- }
-
- public List getMatchingTypeList()
- {
- return list;
- }
-
- public String[] getDOMName(XSDElementDeclaration ed)
- {
- String[] result = new String[2];
- org.w3c.dom.Element domElement = ed.getElement();
- String typeName = domElement.getAttribute("type");
- if (typeName != null && !typeName.endsWith(td.getName()))
- {
- int index = typeName.indexOf(":");
- String prefix = index == -1 ? "" : typeName.substring(0, index);
- result[0] = (String)schema.getQNamePrefixToNamespaceMap().get(prefix);
- if (result[0] == null) result[0] = "";
- if (result[1] == null) result[1] = "";
- result[1] = index == -1 ? typeName : typeName.substring(index + 1);
- }
- else
- {
- result[0] = "";
- result[1] = "";
- }
- return result;
- }
-
-
- public void cleanUpTypeMismatches()
- {
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- XSDElementDeclaration ed = (XSDElementDeclaration)i.next();
- XSDTypeDefinition candidateTd = ed.getTypeDefinition();
- if (candidateTd != null && candidateTd.getName() != null)
- {
- String[] result = getDOMName(ed);
- ed.setTypeDefinition((XSDTypeDefinition)schema.resolveComplexTypeDefinition(result[0], result[1]));
- }
- }
- }
-
- public void removeMatchingReferences()
- {
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- XSDElementDeclaration ed = (XSDElementDeclaration)i.next();
- String[] result = getDOMName(ed);
- if (ed.getElement() != null)
- {
- // NOTE ... this forces the model to reset the ed's XSDTypeDefinition without causing the
- // DOM element's 'type' attribute to be set to null
- ed.elementAttributesChanged(ed.getElement());
- }
- }
- }
-
- public void setMatchingReferences()
- {
- for (Iterator i = list.iterator(); i.hasNext(); )
- {
- XSDElementDeclaration ed = (XSDElementDeclaration)i.next();
- ed.setTypeDefinition(td);
- }
- }
- } */
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateDtd.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateDtd.gif
deleted file mode 100644
index ac58c1e8ab..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateDtd.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateJava.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateJava.gif
deleted file mode 100644
index 2375c655d8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GenerateJava.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GraphViewElementRef.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GraphViewElementRef.gif
deleted file mode 100644
index d535dac36d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/GraphViewElementRef.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/NewXSD.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/NewXSD.gif
deleted file mode 100644
index 47f6730398..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/NewXSD.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/RegexWizardArrow.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/RegexWizardArrow.gif
deleted file mode 100644
index 3d550a30e8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/RegexWizardArrow.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/ValidateXSD.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/ValidateXSD.gif
deleted file mode 100644
index 2b347ac458..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/ValidateXSD.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAll.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAll.gif
deleted file mode 100644
index 6d74e802b5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAll.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnnotate.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnnotate.gif
deleted file mode 100644
index d2108c0368..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnnotate.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAny.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAny.gif
deleted file mode 100644
index a39f93cdce..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAny.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnyAttribute.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnyAttribute.gif
deleted file mode 100644
index 5280cc2904..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAnyAttribute.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAppInfo.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAppInfo.gif
deleted file mode 100644
index 2da001e3e9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAppInfo.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttribute.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttribute.gif
deleted file mode 100644
index 79d49d037b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttribute.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroup.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroup.gif
deleted file mode 100644
index 648462ff67..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroup.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroupRef.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroupRef.gif
deleted file mode 100644
index a89fa8f187..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeGroupRef.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeRef.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeRef.gif
deleted file mode 100644
index 8365af2f3c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDAttributeRef.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDChoice.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDChoice.gif
deleted file mode 100644
index 89ba825253..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDChoice.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexContent.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexContent.gif
deleted file mode 100644
index 41c68dda8c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexContent.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexType.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexType.gif
deleted file mode 100644
index 007f8522af..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDComplexType.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDDoc.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDDoc.gif
deleted file mode 100644
index d349a05f2b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDDoc.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElement.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElement.gif
deleted file mode 100644
index dd45f08fb1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElement.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElementRef.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElementRef.gif
deleted file mode 100644
index 749acfc9c9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDElementRef.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDExtension.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDExtension.gif
deleted file mode 100644
index 0cfb8076dd..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDExtension.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDField.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDField.gif
deleted file mode 100644
index 378e43e14d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDField.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDFile.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDFile.gif
deleted file mode 100644
index 3900f1b55d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDFile.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalAttribute.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalAttribute.gif
deleted file mode 100644
index 79d49d037b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalAttribute.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalElement.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalElement.gif
deleted file mode 100644
index dd45f08fb1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGlobalElement.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroup.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroup.gif
deleted file mode 100644
index 555ef53306..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroup.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroupRef.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroupRef.gif
deleted file mode 100644
index 36213426cf..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDGroupRef.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDImport.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDImport.gif
deleted file mode 100644
index 9e44ce52a9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDImport.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDInclude.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDInclude.gif
deleted file mode 100644
index b26c527f5e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDInclude.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKey.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKey.gif
deleted file mode 100644
index 04032a915a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKey.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKeyRef.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKeyRef.gif
deleted file mode 100644
index ee5829d693..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDKeyRef.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDNotation.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDNotation.gif
deleted file mode 100644
index ce9df985b8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDNotation.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDRedefine.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDRedefine.gif
deleted file mode 100644
index 56964c13a5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDRedefine.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSelector.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSelector.gif
deleted file mode 100644
index 2399a58204..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSelector.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSequence.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSequence.gif
deleted file mode 100644
index 8bf3f972d2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSequence.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleContent.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleContent.gif
deleted file mode 100644
index 7ef38df720..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleContent.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleEnum.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleEnum.gif
deleted file mode 100644
index 11d7958525..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleEnum.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleList.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleList.gif
deleted file mode 100644
index d08e78f891..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleList.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimplePattern.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimplePattern.gif
deleted file mode 100644
index a113cf45a0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimplePattern.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleRestrict.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleRestrict.gif
deleted file mode 100644
index 38bc12e32f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleRestrict.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleType.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleType.gif
deleted file mode 100644
index 75f33c24fa..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleType.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleTypeForEditPart.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleTypeForEditPart.gif
deleted file mode 100644
index 9aefeb27b6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleTypeForEditPart.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleUnion.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleUnion.gif
deleted file mode 100644
index 292adafc8e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDSimpleUnion.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDUnique.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDUnique.gif
deleted file mode 100644
index 5a8a650f3d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/XSDUnique.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/back.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/back.gif
deleted file mode 100644
index 24d1a279e5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/back.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/browsebutton.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/browsebutton.gif
deleted file mode 100644
index 13dae59bea..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/browsebutton.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/forward.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/forward.gif
deleted file mode 100644
index eab699e385..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/forward.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/generate_xml.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/generate_xml.gif
deleted file mode 100644
index f2e363564f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/generate_xml.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/regx_wiz.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/regx_wiz.gif
deleted file mode 100644
index 789d137394..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/regx_wiz.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/reloadgrammar.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/reloadgrammar.gif
deleted file mode 100644
index c705db0c1e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/reloadgrammar.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/sort.gif b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/sort.gif
deleted file mode 100644
index 3c65dc4ba1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/icons/sort.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/preferences/XSDPreferencePage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/preferences/XSDPreferencePage.java
deleted file mode 100644
index 5f31f56e75..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/preferences/XSDPreferencePage.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-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.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-
-public class XSDPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Listener
-{
- Text indentTextField;
- String indentString;
- Text schemaNsPrefixField;
- Text defaultTargetNamespaceText;
- Button qualifyXSDLanguage;
-
- /**
- * Creates preference page controls on demand.
- * @param parent the parent for the preference page
- */
- protected Control createContents(Composite parent)
- {
- WorkbenchHelp.setHelp(parent, XSDEditorContextIds.XSDP_PREFERENCE_PAGE);
-
- Group group = createGroup(parent, 2);
- group.setText(XSDEditorPlugin.getXSDString("_UI_TEXT_XSD_NAMESPACE_PREFIX"));
-
- qualifyXSDLanguage = ViewUtility.createCheckBox(group, XSDEditorPlugin.getXSDString("_UI_QUALIFY_XSD"));
- ViewUtility.createLabel(group, " ");
-
- createLabel(group, XSDEditorPlugin.getXSDString("_UI_TEXT_XSD_DEFAULT_PREFIX"));
- schemaNsPrefixField = createTextField(group);
- schemaNsPrefixField.addKeyListener(new KeyAdapter()
- {
- public void keyPressed(KeyEvent e)
- {
- setValid(true);
- }
- });
-
- createLabel(group, XSDEditorPlugin.getXSDString("_UI_TEXT_XSD_DEFAULT_TARGET_NAMESPACE"));
- defaultTargetNamespaceText = createTextField(group);
-
- initializeValues();
-
- return new Composite(parent, SWT.NULL);
- }
-
- private Group createGroup(Composite parent, int numColumns)
- {
- Group group = new Group(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- group.setLayoutData(data);
-
- return group;
- }
-
- private Text createTextField(Composite parent)
- {
- Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- text.setLayoutData(data);
-
- return text;
- }
-
- private Label createLabel(Composite parent, String text)
- {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
-
- return label;
- }
-
- /**
- * Does anything necessary because the default button has been pressed.
- */
- protected void performDefaults()
- {
- super.performDefaults();
- initializeDefaults();
- checkValues();
- }
-
- /**
- * Do anything necessary because the OK button has been pressed.
- * @return whether it is okay to close the preference page
- */
- public boolean performOk()
- {
- if (checkValues())
- {
- storeValues();
- return true;
- }
- return false;
- }
-
- protected void performApply()
- {
- if (checkValues())
- {
- storeValues();
- }
- }
-
- /**
- * Handles events generated by controls on this page.
- * @param e the event to handle
- */
- public void handleEvent(Event e)
- {
- }
-
- /**
- * @see IWorkbenchPreferencePage
- */
- public void init(IWorkbench workbench)
- {
- }
-
- /**
- * The indent is stored in the preference store associated with the XML Schema Model
- */
- public IPreferenceStore getPreferenceStore()
- {
- return XSDEditorPlugin.getPlugin().getPreferenceStore();
- }
-
- /**
- * Initializes states of the controls using default values
- * in the preference store.
- */
- private void initializeDefaults()
- {
- schemaNsPrefixField.setText(getPreferenceStore().getDefaultString(XSDEditorPlugin.CONST_XSD_DEFAULT_PREFIX_TEXT));
- qualifyXSDLanguage.setSelection(getPreferenceStore().getDefaultBoolean(XSDEditorPlugin.CONST_XSD_LANGUAGE_QUALIFY));
- defaultTargetNamespaceText.setText(getPreferenceStore().getString(XSDEditorPlugin.CONST_DEFAULT_TARGET_NAMESPACE));
- }
-
- /**
- * Initializes states of the controls from the preference store.
- */
- private void initializeValues()
- {
- IPreferenceStore store = getPreferenceStore();
- schemaNsPrefixField.setText(store.getString(XSDEditorPlugin.CONST_XSD_DEFAULT_PREFIX_TEXT));
- qualifyXSDLanguage.setSelection(store.getBoolean(XSDEditorPlugin.CONST_XSD_LANGUAGE_QUALIFY));
- defaultTargetNamespaceText.setText(store.getString(XSDEditorPlugin.CONST_DEFAULT_TARGET_NAMESPACE));
- }
-
- /**
- * Stores the values of the controls back to the preference store.
- */
- private void storeValues()
- {
- IPreferenceStore store = getPreferenceStore();
-
- store.setValue(XSDEditorPlugin.CONST_XSD_DEFAULT_PREFIX_TEXT, getXMLSchemaPrefix());
- store.setValue(XSDEditorPlugin.CONST_XSD_LANGUAGE_QUALIFY, getQualify());
- store.setValue(XSDEditorPlugin.CONST_DEFAULT_TARGET_NAMESPACE, getXMLSchemaTargetNamespace());
-
- XSDEditorPlugin.getPlugin().savePluginPreferences();
- }
-
- public String getXMLSchemaPrefix()
- {
- String prefix = schemaNsPrefixField.getText();
- if (prefix == null || prefix.equals(""))
- {
- return "xsd";
- }
- return prefix;
- }
-
- public boolean getQualify()
- {
- return qualifyXSDLanguage.getSelection();
- }
-
- /**
- * Get the xml schema default target namespace
- */
- public String getXMLSchemaTargetNamespace()
- {
- String targetNamespace = defaultTargetNamespaceText.getText();
- if (targetNamespace == null || targetNamespace.equals(""))
- {
- return XSDEditorPlugin.DEFAULT_TARGET_NAMESPACE;
- }
- return targetNamespace;
- }
-
- public boolean checkValues()
- {
-// KCPort TODO String errorMessage = ValidateHelper.checkXMLName(schemaNsPrefixField.getText());
- String errorMessage = null;
-
- if (errorMessage == null || errorMessage.length() == 0)
- {
- setErrorMessage(null);
- setValid(true);
- return true;
- }
- else
- {
- setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_LABEL_INVALID_PREFIX"));
- setValid(false);
- return false;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyAttributePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyAttributePropertySource.java
deleted file mode 100644
index 0f4e7e707a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyAttributePropertySource.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-public class AnyAttributePropertySource extends BasePropertySource implements IPropertySource
-{
- private String[] namespaceComboValues = {
- "",
- "##any",
- "##other",
- "##targetNamespace",
- "##local"
- };
-
- private String[] processContentsComboValues = {
- "",
- XSDEditorPlugin.getXSDString("_UI_COMBO_LAX"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_SKIP"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_STRICT")
- };
- public AnyAttributePropertySource()
- {
- }
-
- public AnyAttributePropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
-
- public AnyAttributePropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
-
- XSDComboBoxPropertyDescriptor namespaceDescriptor = new XSDComboBoxPropertyDescriptor(
- XSDConstants.NAMESPACE_ATTRIBUTE,
- XSDConstants.NAMESPACE_ATTRIBUTE,
- namespaceComboValues);
- list.add(namespaceDescriptor);
-
- XSDComboBoxPropertyDescriptor processContentsDescriptor = new XSDComboBoxPropertyDescriptor(
- XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
- XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
- processContentsComboValues);
- list.add(processContentsDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- return "";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.NAMESPACE_ATTRIBUTE))
- {
- String namespace = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_NAMESPACE_CHANGE"), element);
- if (namespace != null && namespace.length() > 0)
- {
- element.setAttribute(XSDConstants.NAMESPACE_ATTRIBUTE, namespace);
- }
- else
- {
- element.removeAttribute(XSDConstants.NAMESPACE_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.PROCESSCONTENTS_ATTRIBUTE))
- {
- String processContents = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PROCESSCONTENTS_CHANGE"), element);
- if (processContents != null && processContents.length() > 0)
- {
- element.setAttribute(XSDConstants.PROCESSCONTENTS_ATTRIBUTE, processContents);
- }
- else
- {
- element.removeAttribute(XSDConstants.PROCESSCONTENTS_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyContentPropertyDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyContentPropertyDescriptor.java
deleted file mode 100644
index 7904053744..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyContentPropertyDescriptor.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.window.Window;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class AnyContentPropertyDescriptor extends PropertyDescriptor
-{
- Element element;
- /**
- * @param id
- * @param displayName
- */
- public AnyContentPropertyDescriptor(Object id, String displayName, Element element)
- {
- super(id, displayName);
- this.element = element;
- }
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- CellEditor editor = new AnyContentDialogCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
-
- public class AnyContentDialogCellEditor extends DialogCellEditor {
-
- /**
- * Creates a new Font dialog cell editor parented under the given control.
- * The cell editor value is <code>null</code> initially, and has no
- * validator.
- *
- * @param parent the parent control
- */
- protected AnyContentDialogCellEditor(Composite parent) {
- super(parent);
- }
-
- /**
- * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control)
- */
- protected Object openDialogBox(Control cellEditorWindow)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- AnyContentDialog dialog = new AnyContentDialog(shell);
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- String value = (String)getValue();
-
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- return dialog.getComment();
- }
- return value;
- }
-
- }
-
- public class AnyContentDialog extends org.eclipse.jface.dialogs.Dialog
- {
- protected Text commentField;
- protected Button okButton, cancelButton;
- private String comment;
-
- public AnyContentDialog(Shell shell)
- {
- super(shell);
- }
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.OK)
- {
- comment = commentField.getText();
- }
- super.buttonPressed(buttonId);
- }
-
- public String getComment() { return comment; }
-
- //
- // Create the controls
- //
- public Control createDialogArea(Composite parent)
- {
- Composite client = (Composite)super.createDialogArea(parent);
- getShell().setText(element.getLocalName());
-
- commentField = ViewUtility.createMultiTextField(client, 400, 200, true);
-
- WorkbenchHelp.setHelp(commentField, XSDEditorContextIds.XSDE_ANNOTATION_COMMENT);
- commentField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_COMMENT")); //$NON-NLS-1$
-
- String initialString = (String)getInitialContent();
- commentField.setText(initialString);
- return client;
- }
-
- private Object getInitialContent()
- {
- Object result = null;
- if (element.hasChildNodes())
- {
- // if the element is Text
- Node node = element.getFirstChild();
- if (node instanceof CharacterData)
- {
- result = ((CharacterData)node).getData();
- }
- }
- else
- {
- result = ""; //$NON-NLS-1$
- }
- return result;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyElementPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyElementPropertySource.java
deleted file mode 100644
index 1b2e12b71d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AnyElementPropertySource.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-public class AnyElementPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
-
- private String[] namespaceComboValues = {
- "",
- "##any",
- "##other",
- "##targetNamespace",
- "##local"
- };
-
- private String[] processContentsComboValues = {
- "",
- XSDEditorPlugin.getXSDString("_UI_COMBO_LAX"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_SKIP"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_STRICT")
- };
-
- /**
- *
- */
- public AnyElementPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public AnyElementPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public AnyElementPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
-
- XSDComboBoxPropertyDescriptor namespaceDescriptor = new XSDComboBoxPropertyDescriptor(
- XSDConstants.NAMESPACE_ATTRIBUTE,
- XSDConstants.NAMESPACE_ATTRIBUTE,
- namespaceComboValues);
- list.add(namespaceDescriptor);
-
- XSDComboBoxPropertyDescriptor processContentsDescriptor = new XSDComboBoxPropertyDescriptor(
- XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
- XSDConstants.PROCESSCONTENTS_ATTRIBUTE,
- processContentsComboValues);
- list.add(processContentsDescriptor);
-
-// These are moved to the tabbed properties general section
-// PropertyDescriptor minOccursDescriptor =
-// new TextPropertyDescriptor(
-// XSDConstants.MINOCCURS_ATTRIBUTE,
-// XSDConstants.MINOCCURS_ATTRIBUTE);
-// list.add(minOccursDescriptor);
-// PropertyDescriptor maxOccursDescriptor =
-// new TextPropertyDescriptor(
-// XSDConstants.MAXOCCURS_ATTRIBUTE,
-// XSDConstants.MAXOCCURS_ATTRIBUTE);
-// list.add(maxOccursDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "";
- }
- return result;
-
-// if (((String) id).equals(XSDConstants.NAMESPACE_ATTRIBUTE))
-// {
-// }
-// else if (((String) id).equals(XSDConstants.PROCESSCONTENTS_ATTRIBUTE))
-// {
-// }
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.MAXOCCURS_ATTRIBUTE))
- {
- String max = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MAXOCCURS_CHANGE"), element);
- if (max.length() > 0)
- {
- element.setAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE, max);
- }
- else
- {
- element.removeAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.MINOCCURS_ATTRIBUTE))
- {
- String min = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MINOCCURS_CHANGE"), element);
- if (min.length() > 0)
- {
- element.setAttribute(XSDConstants.MINOCCURS_ATTRIBUTE, min);
- }
- else
- {
- element.removeAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.NAMESPACE_ATTRIBUTE))
- {
- String namespace = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_NAMESPACE_CHANGE"), element);
- if (namespace.length() > 0)
- {
- element.setAttribute(XSDConstants.NAMESPACE_ATTRIBUTE, namespace);
- }
- else
- {
- element.removeAttribute(XSDConstants.NAMESPACE_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.PROCESSCONTENTS_ATTRIBUTE))
- {
- String processContents = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PROCESSCONTENTS_CHANGE"), element);
- if (processContents.length() > 0)
- {
- element.setAttribute(XSDConstants.PROCESSCONTENTS_ATTRIBUTE, processContents);
- }
- else
- {
- element.removeAttribute(XSDConstants.PROCESSCONTENTS_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AppInfoPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AppInfoPropertySource.java
deleted file mode 100644
index b99c76815a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AppInfoPropertySource.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Node;
-
-public class AppInfoPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- public static String CONTENT = "Content";
-
- /**
- *
- */
- public AppInfoPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public AppInfoPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public AppInfoPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- PropertyDescriptor sourceDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.SOURCE_ATTRIBUTE,
- XSDConstants.SOURCE_ATTRIBUTE);
- list.add(sourceDescriptor);
- AnyContentPropertyDescriptor contentDescriptor =
- new AnyContentPropertyDescriptor(
- CONTENT,
- CONTENT,
- element);
- list.add(contentDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- if (((String) id).equals(CONTENT))
- {
- try
- {
- if (element.hasChildNodes())
- {
- // if the element is Text
- Node node = element.getFirstChild();
- if (node instanceof CharacterData)
- {
- return ((CharacterData)node).getData();
- }
- }
- else
- {
- return "";
- }
- }
- catch (Exception e)
- {
-
- }
-
- }
- else
- {
- result = element.getAttribute((String) id);
- }
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- if (((String)id).equals(XSDConstants.SOURCE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SOURCE_ATTRIBUTE_CHANGE"), element);
- if (((String)value).length() > 0)
- {
- element.setAttribute(XSDConstants.SOURCE_ATTRIBUTE, (String)value);
- }
- else
- {
- element.removeAttribute(XSDConstants.SOURCE_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String)id).equals(CONTENT))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMMENT_CHANGE"), element);
- try
- {
- if (element.hasChildNodes())
- {
- // if the element is Text
- Node node = element.getFirstChild();
- if (node instanceof CharacterData)
- {
- ((CharacterData)node).setData((String)value);
- }
- }
- else
- {
- if (((String)value).length() > 0)
- {
- Node childNode = element.getOwnerDocument().createTextNode((String)value);
- element.appendChild(childNode);
- }
- }
- endRecording(element);
- }
- catch (Exception e)
- {
-
- }
- }
- else // shouldn't be here
- {
- element.setAttribute((String) id, (String) value);
- }
- }
- else if (value instanceof Integer)
- {
- }
- }
- else
- {
- element.removeAttribute((String) id);
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributeGroupRefPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributeGroupRefPropertySource.java
deleted file mode 100644
index 74ca7021ec..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributeGroupRefPropertySource.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class AttributeGroupRefPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String[] refComboValues = { "" };
- /**
- *
- */
- public AttributeGroupRefPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public AttributeGroupRefPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public AttributeGroupRefPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
-
- public void setInput(Element element)
- {
- this.element = element;
- TypesHelper helper = new TypesHelper(xsdSchema);
- java.util.List items = helper.getGlobalAttributes();
-
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- items = helper.getGlobalAttributes();
-// WorkbenchHelp.setHelp(client, XSDEditorContextIds.XSDE_ATTRIBUTE_REF_DESIGN_VIEW);
-// WorkbenchHelp.setHelp(refCombo, XSDEditorContextIds.XSDE_ATTRIBUTE_REF_NAME);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true))
- {
- items = helper.getGlobalAttributeGroups();
-// WorkbenchHelp.setHelp(client, XSDEditorContextIds.XSDE_ATTRIBUTE_GROUP_REF_DESIGN_VIEW);
-// WorkbenchHelp.setHelp(refCombo, XSDEditorContextIds.XSDE_ATTRIBUTE_GROUP_REF_NAME);
- }
- int size = items.size() + 1;
- refComboValues = new String[size];
- refComboValues[0] = "";
- if (items != null)
- {
- for (int i = 0; i < items.size(); i++)
- {
- refComboValues[i + 1] = (String) items.get(i);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- XSDComboBoxPropertyDescriptor refDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.REF_ATTRIBUTE,
- XSDConstants.REF_ATTRIBUTE,
- refComboValues);
- list.add(refDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "";
- }
-// if (((String) id).equals(XSDConstants.REF_ATTRIBUTE))
-// {
-// }
- return result;
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.REF_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTEGROUP_REF_CHANGE"), element);
- element.setAttribute(XSDConstants.REF_ATTRIBUTE, (String) value);
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributePropertySource.java
deleted file mode 100644
index 0365346edb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributePropertySource.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalAttributeRenamer;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-public class AttributePropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String[] useComboValues =
- {
- "", //$NON-NLS-1$
- "prohibited", // XSDEditorPlugin.getXSDString("_UI_COMBO_BOX_PROHIBITED"), //$NON-NLS-1$
- "optional", // XSDEditorPlugin.getXSDString("_UI_COMBO_BOX_OPTIONAL"), //$NON-NLS-1$
- "required" // XSDEditorPlugin.getXSDString("_UI_COMBO_BOX_REQUIRED") //$NON-NLS-1$
- };
-
- protected String formComboValues[] =
- {
- "", //$NON-NLS-1$
- XSDEditorPlugin.getXSDString("_UI_COMBO_UNQUALIFIED"), //$NON-NLS-1$
- XSDEditorPlugin.getXSDString("_UI_COMBO_QUALIFIED") //$NON-NLS-1$
- };
-
-
- /**
- *
- */
- public AttributePropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public AttributePropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public AttributePropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- PropertyDescriptor nameDescriptor = new TextPropertyDescriptor(XSDConstants.NAME_ATTRIBUTE, XSDConstants.NAME_ATTRIBUTE);
- list.add(nameDescriptor);
-// nameDescriptor.setCategory(XSDEditorPlugin.getXSDString("_UI_LABEL_GENERAL"));
- TypesPropertyDescriptor typeDescriptor = new TypesPropertyDescriptor(
- XSDConstants.TYPE_ATTRIBUTE,
- XSDConstants.TYPE_ATTRIBUTE,
- element, xsdSchema);
- list.add(typeDescriptor);
-// typeDescriptor.setCategory(XSDEditorPlugin.getXSDString("_UI_LABEL_GENERAL"));
-
- Attr fixedAttr = element.getAttributeNode(XSDConstants.FIXED_ATTRIBUTE);
- Attr defaultAttr = element.getAttributeNode(XSDConstants.DEFAULT_ATTRIBUTE);
- String str;
- if (fixedAttr != null)
- {
- str = XSDConstants.FIXED_ATTRIBUTE;
- }
- else if (defaultAttr != null)
- {
- str = XSDConstants.DEFAULT_ATTRIBUTE;
- }
- else
- {
- str = XSDConstants.FIXED_ATTRIBUTE + "/" + XSDConstants.DEFAULT_ATTRIBUTE; //$NON-NLS-1$
- }
-
- FixedOrDefaultTextPropertyDescriptor fixedOrDefaultDescriptor =
- new FixedOrDefaultTextPropertyDescriptor(
- str,
- str,
- element);
- list.add(fixedOrDefaultDescriptor);
-// fixedOrDefaultDescriptor.setCategory(XSDEditorPlugin.getXSDString("_UI_LABEL_OTHER"));
-
- Object parentNode = element.getParentNode();
- if (XSDDOMHelper.inputEquals(parentNode, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- }
- else
- {
- XSDComboBoxPropertyDescriptor useDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.USE_ATTRIBUTE,
- XSDConstants.USE_ATTRIBUTE,
- useComboValues);
- list.add(useDescriptor);
-// useDescriptor.setCategory(XSDEditorPlugin.getXSDString("_UI_LABEL_OTHER"));
- XSDComboBoxPropertyDescriptor formDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.FORM_ATTRIBUTE,
- XSDConstants.FORM_ATTRIBUTE,
- formComboValues);
- list.add(formDescriptor);
-// formDescriptor.setCategory(XSDEditorPlugin.getXSDString("_UI_LABEL_OTHER"));
- }
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = ""; //$NON-NLS-1$
- }
- if (((String) id).equals(XSDConstants.TYPE_ATTRIBUTE))
- {
- if (result.equals("")) //$NON-NLS-1$
- {
- if (checkForAnonymousType(element))
- {
- return "**anonymous**"; //$NON-NLS-1$
- }
- else
- {
- return XSDEditorPlugin.getXSDString("_UI_NO_TYPE"); //$NON-NLS-1$
- }
- }
- else
- {
- return result;
- }
- }
- return result;
- }
- return ""; //$NON-NLS-1$
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = ""; //$NON-NLS-1$
- }
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.TYPE_ATTRIBUTE))
- {
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), element);
-// element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, (String)value);
-// updateElementToNotAnonymous(element);
-// endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.NAME_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTE_NAME_CHANGE"), element); //$NON-NLS-1$
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDAttributeDeclaration && comp.getRootContainer().equals(xsdSchema))
- {
- XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)comp;
- xsdAttributeDeclaration.setName((String)value);
- GlobalAttributeRenamer renamer = new GlobalAttributeRenamer(xsdAttributeDeclaration, (String)value);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, (String)value);
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.FIXED_ATTRIBUTE) || ((String) id).equals(XSDConstants.DEFAULT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTE_VALUE_CHANGE"), element); //$NON-NLS-1$
- if (((String)value).equals("")) //$NON-NLS-1$
- {
- element.removeAttribute((String)id);
- }
- else
- {
- element.setAttribute((String) id, (String) value);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.USE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTE_USE_CHANGE"), element); //$NON-NLS-1$
- if (((String)value).equals("")) //$NON-NLS-1$
- {
- element.removeAttribute(XSDConstants.USE_ATTRIBUTE);
- }
- else
- {
- element.setAttribute((String) id, (String)value);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.FORM_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTE_FORM_CHANGE"), element); //$NON-NLS-1$
- if (((String)value).equals("")) //$NON-NLS-1$
- {
- element.removeAttribute(XSDConstants.FORM_ATTRIBUTE);
- }
- else
- {
- element.setAttribute(XSDConstants.FORM_ATTRIBUTE, (String)value);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- boolean checkForAnonymousType(Element element)
- {
- NodeList list = element.getElementsByTagNameNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (list.getLength() > 0)
- {
- return true;
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributesTable.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributesTable.java
deleted file mode 100644
index f80e72eb90..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/AttributesTable.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-//import java.text.Collator;
-//import java.util.Comparator;
-//import java.util.List;
-//
-//import org.eclipse.jface.viewers.CellEditor;
-//import org.eclipse.jface.viewers.ColumnPixelData;
-//import org.eclipse.jface.viewers.ICellModifier;
-//import org.eclipse.jface.viewers.ILabelProvider;
-//import org.eclipse.jface.viewers.IStructuredContentProvider;
-//import org.eclipse.jface.viewers.ITableLabelProvider;
-//import org.eclipse.jface.viewers.LabelProvider;
-//import org.eclipse.jface.viewers.TableLayout;
-//import org.eclipse.jface.viewers.TableViewer;
-//import org.eclipse.jface.viewers.TextCellEditor;
-//import org.eclipse.jface.viewers.Viewer;
-//import org.eclipse.swt.SWT;
-//import org.eclipse.swt.events.MouseAdapter;
-//import org.eclipse.swt.events.MouseEvent;
-//import org.eclipse.swt.graphics.Image;
-//import org.eclipse.swt.widgets.Composite;
-//import org.eclipse.swt.widgets.Control;
-//import org.eclipse.swt.widgets.Table;
-//import org.eclipse.swt.widgets.TableColumn;
-//import org.eclipse.swt.widgets.TableItem;
-//import org.eclipse.ui.IEditorPart;
-//import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
-//import org.eclipse.ui.views.properties.IPropertyDescriptor;
-//import org.eclipse.ui.views.properties.IPropertySource;
-//import org.w3c.dom.Element;
-
-public class AttributesTable // extends TableViewer implements ICellModifier
-{
-// protected static final String PROPERTY = "property"; //$NON-NLS-1$
-// protected static final String VALUE = "value"; //$NON-NLS-1$
-//
-// protected IEditorPart editorPart;
-// protected String[] columnProperties = {PROPERTY, VALUE};
-// protected PropertyTableProvider tableProvider = new PropertyTableProvider(this);
-// protected CellEditor cellEditor;
-// //protected StringComboBoxCellEditor comboCellEditor;
-// protected IPropertySource propertySource;
-//
-// public AttributesTable(IEditorPart editorPart, Composite parent)
-// {
-// super(new Table(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.FLAT | SWT.H_SCROLL | SWT.V_SCROLL));
-// this.editorPart = editorPart;
-// getTable().setLinesVisible(true);
-// getTable().setHeaderVisible(true);
-//
-// setContentProvider(tableProvider);
-// setLabelProvider(tableProvider);
-// setColumnProperties(columnProperties);
-//
-// for (int i = 0; i < columnProperties.length; i++)
-// {
-// TableColumn column = new TableColumn(getTable(), SWT.NONE, i);
-// column.setText(columnProperties[i]);
-// column.setAlignment(SWT.LEFT);
-// }
-//
-//// TableLayout layout = new TableLayout();
-//// ColumnWeightData data = new ColumnWeightData(40, 40, true);
-//// layout.addColumnData(data);
-////
-//// ColumnWeightData data2 = new ColumnWeightData(80, 80, true);
-//// layout.addColumnData(data2);
-//
-// TableLayout layout = new TableLayout();
-// layout.addColumnData(new ColumnPixelData(130,true));
-// layout.addColumnData(new ColumnPixelData(130,true));
-// getTable().setLayout(layout);
-//
-//
-// cellEditor = new TextCellEditor(getTable());
-// resetCellEditors();
-//
-// setCellModifier(this);
-// }
-//
-// public void setPropertySource(IPropertySource propertySource)
-// {
-// this.propertySource = propertySource;
-// }
-//
-// /* (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(VALUE);
-// }
-//
-// /* (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;
-// }
-// return tableProvider.getColumnValue(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)
-// {
-// TableItem item = (TableItem)element;
-// IPropertyDescriptor propertyDescriptor = (IPropertyDescriptor)item.getData();
-//
-// // if the new value is the same as the old value, the user has only clicked
-// // on the cell in the course of 'browsing' ... so don't edit the value
-// Object oldValue = getValue(propertyDescriptor, property);
-// if (value != null && !value.equals(oldValue))
-// {
-// // we assume the value is empty that the attribute should be removed
-// // todo... we probably need to look at this in more detail
-// if (value instanceof String && ((String)value).length() == 0)
-// {
-// value = null;
-// }
-// propertySource.setPropertyValue(propertyDescriptor.getId(), value);
-// }
-// }
-//
-//
-// protected void hookControl(Control control) {
-// // we need to hook up our own mouse listener first
-// // so that we can update the cellEditors before
-// // the 'internal' listener tries to get hold of them
-// Table tableControl = (Table)control;
-// tableControl.addMouseListener(new MouseAdapter() {
-// public void mouseDown(MouseEvent e) {
-// System.out.println("Mouse down");
-// updateCellEditors();
-// }
-// });
-// super.hookControl(control);
-// }
-//
-// protected void updateCellEditors()
-// {
-// CellEditor[] cellEditors = new CellEditor[2];
-// cellEditors[0] = cellEditor;
-// cellEditors[1] = cellEditor;
-//
-// Element element = (Element)getInput();
-//
-// IPropertyDescriptor[] propertyDescriptors = propertySource.getPropertyDescriptors();
-// int index = getTable().getSelectionIndex();
-// if (index >= 0 && index < propertyDescriptors.length)
-// {
-// CellEditor[] oldCellEditors = getCellEditors();
-// CellEditor oldCellEditor = (oldCellEditors.length > 1) ? oldCellEditors[1] : null;
-// if (oldCellEditor != null && oldCellEditor != cellEditor)
-// {
-// oldCellEditor.deactivate();
-// oldCellEditor.dispose();
-// }
-// cellEditors[1] = propertyDescriptors[index].createPropertyEditor(getTable());
-// }
-// setCellEditors(cellEditors);
-//
-//// IPropertyDescriptor[] propertyDescriptors = propertySource.getPropertyDescriptors();
-////
-//// int index = getTable().getSelectionIndex();
-//// //cellEditor.dispose();
-////
-//// if (index >= 0 && index < propertyDescriptors.length)
-//// {
-//// cellEditor = propertyDescriptors[index].createPropertyEditor(getTable());
-//// Control control = cellEditor.getControl();
-//// if (control == null) {
-//// cellEditor.deactivate();
-//// cellEditor = null;
-//// return;
-//// }
-//// setCellEditors(new CellEditor[] {null, cellEditor});
-//// cellEditor.activate();
-//// cellEditor.setFocus();
-//// }
-// }
-//
-//
-// public String[] getStringArray(List list)
-// {
-// String[] result = new String[list.size()];
-// for (int i = 0; i < result.length; i++)
-// {
-// result[i] = (String)list.get(i);
-// }
-// return result;
-// }
-//
-// protected void resetCellEditors()
-// {
-// CellEditor[] cellEditors = new CellEditor[2];
-// cellEditors[0] = null;
-// cellEditors[1] = cellEditor;
-// setCellEditors(cellEditors);
-// }
-//
-//
-// class PropertyTableProvider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider
-// {
-// protected TableViewer viewer;
-//
-// PropertyTableProvider(TableViewer viewer)
-// {
-// this.viewer = viewer;
-// }
-//
-// public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
-// {
-//// resetCellEditors();
-//// if (newInput instanceof XMLElement)
-//// {
-//// propertySource = new ExtensiblePropertySource(editorPart, (XMLElement)newInput);
-//// }
-//// if (newInput instanceof Element)
-//// {
-//// if (XSDDOMHelper.inputEquals(newInput, XSDConstants.ELEMENT_ELEMENT_TAG, false))
-//// {
-//// propertySource = new ElementPropertySource((Element)newInput, viewer);
-//// }
-//// else
-//// {
-//// propertySource = new ReadOnlyPropertySource(editorPart, (Element)newInput);
-//// }
-//// }
-//// else
-//// {
-//// propertySource = null;
-//// }
-// }
-//
-// public Image getColumnImage(Object element, int columnIndex)
-// {
-// return null;
-// }
-//
-// public Object getColumnValue(Object o, int columnIndex)
-// {
-// IPropertyDescriptor propertyDescriptor = (IPropertyDescriptor)o;
-// if (columnIndex == 0)
-// {
-// return propertyDescriptor.getId();
-// }
-// else
-// {
-// return propertySource.getPropertyValue(propertyDescriptor.getId());
-// }
-// }
-//
-// public String getColumnText(Object o, int columnIndex)
-// {
-// IPropertyDescriptor propertyDescriptor = (IPropertyDescriptor)o;
-// // (columnIndex == 1 && propertyDescriptor instanceof XSDComboBoxPropertyDescriptor)
-// if ((columnIndex == 1 && propertyDescriptor instanceof OptionsComboBoxPropertyDescriptor) ||
-// (columnIndex == 1 && propertyDescriptor instanceof ComboBoxPropertyDescriptor))
-// {
-// ILabelProvider lp = propertyDescriptor.getLabelProvider();
-// if (lp != null)
-// {
-// return lp.getText(propertyDescriptor.getId());
-// }
-// }
-//
-// Object id = propertyDescriptor.getId();
-// String attribute = "";
-// if (id != null && attribute instanceof String)
-// {
-// attribute = (String)id;
-// }
-// Object value = propertySource.getPropertyValue(attribute);
-// String attributeValue = "";
-// if (value != null)
-// {
-// attributeValue = (String)value;
-// }
-//
-// return (columnIndex == 0) ? attribute : attributeValue;
-//
-//// return (columnIndex == 0) ? propertyDescriptor.getId().toString() : propertySource.getPropertyValue(propertyDescriptor.getId()).toString();
-// }
-//
-// public Object[] getElements(Object o)
-// {
-// Object[] result = propertySource.getPropertyDescriptors();
-// // For some strange reson the ViewerSorter doesn't seem to be working for this table
-// // As a workaround we sort them in this method before returning them to the viewer
-//// if (result.length > 0)
-//// {
-//// Arrays.sort(result, new InternalComparator());
-//// }
-// return result;
-// }
-// }
-//
-// class InternalComparator implements Comparator
-// {
-// public int compare(Object e1, Object e2)
-// {
-// IPropertyDescriptor p1 = (IPropertyDescriptor)e1;
-// IPropertyDescriptor p2 = (IPropertyDescriptor)e2;
-// String p1Name = p1.getDisplayName();
-// String p2Name = p2.getDisplayName();
-// return Collator.getInstance().compare(p1.getDisplayName(), p2.getDisplayName());
-// }
-// }
-//
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/BasePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/BasePropertySource.java
deleted file mode 100644
index dbea691adb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/BasePropertySource.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public abstract class BasePropertySource implements IPropertySource
-{
- protected Element element;
- protected Viewer viewer;
- protected IPropertyDescriptor[] propertyDescriptors;
- protected XSDSchema xsdSchema;
- protected String [] trueFalseComboValues = {
- "",
- "false",
- "true"
- };
-
- public BasePropertySource()
- {
-
- }
-
- public DocumentImpl getDocument(Element element)
- {
- return (DocumentImpl) element.getOwnerDocument();
- }
-
- public void beginRecording(String description, Element element)
- {
- getDocument(element).getModel().beginRecording(this, description);
- }
-
- public void endRecording(Element element)
- {
- DocumentImpl doc = (DocumentImpl) getDocument(element);
-
- doc.getModel().endRecording(this);
- }
-
-
- public BasePropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- this.viewer = viewer;
- this.xsdSchema = xsdSchema;
- }
-
- public BasePropertySource(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- public void setViewer(Viewer viewer)
- {
- this.viewer = viewer;
- }
-
- public void setInput(Element element)
- {
- this.element = element;
- }
-
- protected XSDDOMHelper domHelper = new XSDDOMHelper();
- /**
- * Gets the domHelper.
- * @return Returns a XSDDomHelper
- */
- public XSDDOMHelper getDomHelper()
- {
- return domHelper;
- }
-
- protected boolean hasElementChildren(Node parentNode)
- {
- boolean hasChildrenElements = false;
- if (parentNode != null && parentNode.hasChildNodes())
- {
- NodeList nodes = parentNode.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- if (nodes.item(i) instanceof Element)
- {
- hasChildrenElements = true;
- break;
- }
- }
- }
- return hasChildrenElements;
- }
-
- protected boolean validateName(String name)
- {
- return NameValidator.isValid(name);
- }
-
- // TODO
- protected boolean validateLanguage(String lang)
- {
- return true;
- }
-
- // TODO
- protected boolean validatePrefix(String prefix)
- {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ComplexTypePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ComplexTypePropertySource.java
deleted file mode 100644
index 0e759c173e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ComplexTypePropertySource.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.SetBaseTypeAction;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalSimpleOrComplexTypeRenamer;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class ComplexTypePropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String DERIVED_BY_ID = "derived by"; // XSDEditorPlugin.getXSDString("_UI_LABEL_DERIVED_BY"); //$NON-NLS-1$
- private String BASE_TYPE_ID = "base type"; // XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE"); //$NON-NLS-1$
-
- private String[] blockOrFinalComboValues =
- {
- "", //$NON-NLS-1$
- "#all", //$NON-NLS-1$
- "extension", //$NON-NLS-1$
- "restriction" //$NON-NLS-1$
- };
-
- /**
- *
- */
- public ComplexTypePropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public ComplexTypePropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public ComplexTypePropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-
- XSDComboBoxPropertyDescriptor abstractDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.ABSTRACT_ATTRIBUTE,
- XSDConstants.ABSTRACT_ATTRIBUTE,
- trueFalseComboValues);
- list.add(abstractDescriptor);
-
- XSDComboBoxPropertyDescriptor mixedDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.MIXED_ATTRIBUTE,
- XSDConstants.MIXED_ATTRIBUTE,
- trueFalseComboValues);
- list.add(mixedDescriptor);
-
- XSDComboBoxPropertyDescriptor blockDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.BLOCK_ATTRIBUTE,
- XSDConstants.BLOCK_ATTRIBUTE,
- blockOrFinalComboValues);
- list.add(blockDescriptor);
- XSDComboBoxPropertyDescriptor finalDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.FINAL_ATTRIBUTE,
- XSDConstants.FINAL_ATTRIBUTE,
- blockOrFinalComboValues);
- list.add(finalDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
-
- public void setInput(Element element)
- {
- this.element = element;
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- String attributeName = (String)id;
- result = element.getAttribute((String) id);
- Element contentModelElement = getDomHelper().getContentModelFromParent(element);
- String baseType = getDomHelper().getBaseType(contentModelElement);
-
- if (result == null)
- {
- result = ""; //$NON-NLS-1$
- }
-
- if (attributeName.equals(DERIVED_BY_ID))
- {
- return getDomHelper().getDerivedByName(contentModelElement);
- }
- else if (attributeName.equals(BASE_TYPE_ID))
- {
- if (baseType != null)
- {
- return baseType;
- }
- else
- {
- return ""; //$NON-NLS-1$
- }
- }
- else if (attributeName.equals(XSDConstants.NAME_ATTRIBUTE))
- {
- String name = element.getAttribute(XSDConstants.NAME_ATTRIBUTE);
-
- boolean isAnonymousType = checkForAnonymousType(element);
- if (isAnonymousType)
- {
- return "**anonymous**"; //$NON-NLS-1$
- }
- else
- {
- return name;
- }
- }
-
- return result;
-// if (((String) id).equals(XSDConstants.ABSTRACT_ATTRIBUTE)
-// || ((String) id).equals(XSDConstants.MIXED_ATTRIBUTE))
-// {
-// }
-// else if (((String) id).equals(XSDConstants.BLOCK_ATTRIBUTE))
-// {
-// }
-// else if (((String) id).equals(XSDConstants.FINAL_ATTRIBUTE))
-// {
-// }
- }
- return ""; //$NON-NLS-1$
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = ""; //$NON-NLS-1$
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- String attributeName = (String)id;
-
- if (attributeName.equals(XSDConstants.NAME_ATTRIBUTE))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMPLEXTYPE_NAME_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length() > 0)
- {
- // now rename any references to this type
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDComplexTypeDefinition && comp.getContainer().equals(xsdSchema))
- {
-// XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)comp;
-// ct.setName(newValue);
- GlobalSimpleOrComplexTypeRenamer renamer = new GlobalSimpleOrComplexTypeRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.removeAttribute(XSDConstants.NAME_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
- else if (attributeName.equals(DERIVED_BY_ID))
- {
- Element contentModelElement = getDomHelper().getContentModelFromParent(element);
- String baseType = getDomHelper().getBaseType(contentModelElement);
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DERIVEDBY_CHANGE"), element); //$NON-NLS-1$
- getDomHelper().changeDerivedByType(contentModelElement, newValue, baseType);
- endRecording(element);
- }
- else if (attributeName.equals(BASE_TYPE_ID))
- {
- String derivedBy = getDomHelper().getDerivedByName(element);
-
- SetBaseTypeAction setBaseTypeAction = new SetBaseTypeAction(XSDEditorPlugin.getXSDString("_UI_LABEL_SET_BASE_TYPE")); //$NON-NLS-1$
- setBaseTypeAction.setXSDSchema(xsdSchema);
- setBaseTypeAction.setComplexTypeElement(element);
- setBaseTypeAction.setType(newValue);
- setBaseTypeAction.setDerivedBy(derivedBy);
- setBaseTypeAction.performAction();
-
-// handleBaseTypeComboChange(newValue);
-
- }
- else
- {
- if (attributeName.equals(XSDConstants.ABSTRACT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMPLEXTYPE_ABSTRACT_CHANGE"), element); //$NON-NLS-1$
- }
- else if (attributeName.equals(XSDConstants.MIXED_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMPLEXTYPE_MIXED_CHANGE"), element); //$NON-NLS-1$
- }
- else if (attributeName.equals(XSDConstants.BLOCK_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMPLEXTYPE_BLOCK_CHANGE"), element); //$NON-NLS-1$
- }
- else if (attributeName.equals(XSDConstants.FINAL_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMPLEXTYPE_FINAL_CHANGE"), element); //$NON-NLS-1$
- }
-
- if (newValue.length() > 0)
- {
- element.setAttribute((String) id, (String)value);
- }
- else
- {
- element.removeAttribute((String) id);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- boolean checkForAnonymousType(Element element)
- {
- Object parentElement = (Object)element.getParentNode();
- boolean isAnonymous = false;
- if (parentElement != null)
- {
- if (XSDDOMHelper.inputEquals(parentElement, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- isAnonymous = true;
- }
- }
- return isAnonymous;
- }
-
-
-// private void handleBaseTypeComboChange(String newType)
-// {
-// String tempChoice = newType;
-// TypesHelper helper = new TypesHelper(xsdSchema);
-// if (helper.getBuiltInTypeNamesList().contains(tempChoice) ||
-// helper.getUserSimpleTypeNamesList().contains(tempChoice))
-// {
-// derivedByCombo.setText(XSDConstants.EXTENSION_ELEMENT_TAG);
-// derivedByCombo.setEnabled(false);
-// }
-// else if (helper.getUserComplexTypeNamesList().contains(tempChoice))
-// {
-// Element contentModelElement = getDomHelper().getContentModelFromParent(element);
-// String derivedByString = getDomHelper().getDerivedByName(contentModelElement);
-// derivedByCombo.setText(derivedByString);
-// derivedByCombo.setEnabled(true);
-// }
-// else
-// {
-// derivedByCombo.setText("");
-// derivedByCombo.setEnabled(false);
-// }
-// }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DocumentationPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DocumentationPropertySource.java
deleted file mode 100644
index 06e9ef793b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DocumentationPropertySource.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Node;
-
-
-public class DocumentationPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- public static String CONTENT = "Content";
-
- /**
- *
- */
- public DocumentationPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public DocumentationPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
-
- }
- /**
- * @param xsdSchema
- */
- public DocumentationPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- PropertyDescriptor languageDescriptor =
- new TextPropertyDescriptor(
- "xml:lang",
- "xml:lang"
- );
- list.add(languageDescriptor);
- PropertyDescriptor sourceDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.SOURCE_ATTRIBUTE,
- XSDConstants.SOURCE_ATTRIBUTE);
- list.add(sourceDescriptor);
- AnyContentPropertyDescriptor contentDescriptor =
- new AnyContentPropertyDescriptor(
- CONTENT,
- CONTENT,
- element);
- list.add(contentDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- if (((String) id).equals(CONTENT))
- {
- try
- {
- if (element.hasChildNodes())
- {
- // if the element is Text
- Node node = element.getFirstChild();
- if (node instanceof CharacterData)
- {
- return ((CharacterData)node).getData();
- }
- }
- else
- {
- return "";
- }
- }
- catch (Exception e)
- {
-
- }
-
- }
- else
- {
- result = element.getAttribute((String) id);
- }
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (((String)id).equals("xml:lang"))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DOCUMENTATION_LANG_CHANGE"), element);
- if (newValue.length() > 0)
- {
- if (validateLanguage(newValue))
- {
- element.setAttribute("xml:lang", newValue);
- }
- }
- else
- {
- // clearErrorMessage();
- element.removeAttribute("xml:lang");
- }
- endRecording(element);
- }
- else if (((String)id).equals(XSDConstants.SOURCE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DOCUMENTATION_SOURCE_CHANGE"), element);
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.SOURCE_ATTRIBUTE, newValue);
- }
- else
- {
- element.removeAttribute(XSDConstants.SOURCE_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String)id).equals(CONTENT))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DOCUMENTATION_COMMENT_CHANGE"), element);
- try
- {
- if (element.hasChildNodes())
- {
- // if the element is Text
- Node node = element.getFirstChild();
- if (node instanceof CharacterData)
- {
- ((CharacterData)node).setData(newValue);
- }
- }
- else
- {
- if (newValue.length() > 0)
- {
- Node childNode = element.getOwnerDocument().createTextNode(newValue);
- element.appendChild(childNode);
- }
- }
- endRecording(element);
- }
- catch (Exception e)
- {
-
- }
- }
- else // shouldn't be here
- {
- element.setAttribute((String) id, newValue);
- }
- }
- else if (value instanceof Integer)
- {
- }
- }
- else
- {
- element.removeAttribute((String) id);
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DynamicCellEditor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DynamicCellEditor.java
deleted file mode 100644
index b09526a9d9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/DynamicCellEditor.java
+++ /dev/null
@@ -1,1174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlEvent;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.accessibility.AccessibleTextAdapter;
-import org.eclipse.swt.accessibility.AccessibleTextEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TypedListener;
-
-public class DynamicCellEditor extends Composite
-{
- Text text;
- List list;
- int maxItemCount = 5;
- Shell popup;
- Button arrow;
- boolean hasFocus;
-
- public DynamicCellEditor(Composite parent, int style) {
- super (parent, checkStyle (style));
-
- style = getStyle();
-
- int textStyle = SWT.SINGLE;
- if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
- if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
- text = new Text (this, textStyle);
-
- popup = new Shell (getShell (), SWT.NO_TRIM);
-
- int listStyle = SWT.SINGLE | SWT.V_SCROLL;
- if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
- if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
- list = new List (popup, listStyle);
-
- int arrowStyle = SWT.ARROW | SWT.DOWN;
- if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
- arrow = new Button (this, arrowStyle);
-
- Listener listener = new Listener () {
- public void handleEvent (Event event) {
- if (popup == event.widget) {
- popupEvent (event);
- return;
- }
- if (text == event.widget) {
- textEvent (event);
- return;
- }
- if (list == event.widget) {
- listEvent (event);
- return;
- }
- if (arrow == event.widget) {
- arrowEvent (event);
- return;
- }
- if (DynamicCellEditor.this == event.widget) {
- comboEvent (event);
- return;
- }
-
- }
- };
-
- int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
- for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
-
- int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
- for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
-
- int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut};
- for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
-
- int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut};
- for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
-
- int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut};
- for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
-
- initAccessible();
-}
-static int checkStyle (int style) {
- int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- return style & mask;
-}
-/**
-* Adds an item.
-* <p>
-* The item is placed at the end of the list.
-* Indexing is zero based.
-*
-* @param string the new item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when the string is null
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_ADDED)
-* when the item cannot be added
-*/
-public void add (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- list.add (string);
-}
-/**
-* Adds an item at an index.
-* <p>
-* The item is placed at an index in the list.
-* Indexing is zero based.
-*
-* This operation will fail when the index is
-* out of range.
-*
-* @param string the new item
-* @param index the index for the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when the string is null
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_ADDED)
-* when the item cannot be added
-*/
-public void add (String string, int index) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- list.add (string, index);
-}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the listener
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when listener is null
-*/
-public void addModifyListener (ModifyListener listener) {;
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Modify, typedListener);
-}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the listener
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when listener is null
-*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-void arrowEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- event.display.asyncExec(new Runnable() {
- public void run() {
- if (DynamicCellEditor.this.isDisposed()) return;
- Control focusControl = getDisplay().getFocusControl();
- if (focusControl == list || focusControl == text) return;
- hasFocus = false;
- Event e = new Event();
- notifyListeners(SWT.FocusOut, e);
- }
- });
- break;
- }
- case SWT.Selection: {
- dropDown (!isDropped ());
- break;
- }
- }
-}
-/**
-* Clears the current selection.
-* <p>
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public void clearSelection () {
- checkWidget();
- text.clearSelection ();
- list.deselectAll ();
-}
-void comboEvent (Event event) {
- switch (event.type) {
- case SWT.Dispose:
- if (popup != null && !popup.isDisposed ()) popup.dispose ();
- popup = null;
- text = null;
- list = null;
- arrow = null;
- break;
- case SWT.Move:
- dropDown(false);
- break;
- case SWT.Resize:
- internalLayout();
- break;
- }
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- int width = 0, height = 0;
- Point textSize = text.computeSize (wHint, SWT.DEFAULT, changed);
- Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
- Point listSize = list.computeSize (wHint, SWT.DEFAULT, changed);
- int borderWidth = getBorderWidth();
-
- height = Math.max (hHint, Math.max(textSize.y, arrowSize.y) + 2*borderWidth);
- width = Math.max (wHint, Math.max(textSize.x + arrowSize.x + 2*borderWidth, listSize.x + 2) );
- return new Point (width, height);
-}
-/**
-* Deselects an item.
-* <p>
-* If the item at an index is selected, it is
-* deselected. If the item at an index is not
-* selected, it remains deselected. Indices
-* that are out of range are ignored. Indexing
-* is zero based.
-*
-* @param index the index of the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public void deselect (int index) {
- checkWidget();
- list.deselect (index);
-}
-/**
-* Deselects all items.
-* <p>
-*
-* If an item is selected, it is deselected.
-* If an item is not selected, it remains unselected.
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public void deselectAll () {
- checkWidget();
- list.deselectAll ();
-}
-void dropDown (boolean drop) {
- if (drop == isDropped ()) return;
- if (!drop) {
- popup.setVisible (false);
- text.setFocus();
- return;
- }
-
- int index = list.getSelectionIndex ();
- if (index != -1) list.setTopIndex (index);
- Display display = getDisplay ();
- Rectangle listRect = list.getBounds ();
- Rectangle parentRect = display.map (getParent (), null, getBounds());
- Point comboSize = getSize ();
- Rectangle displayRect = getMonitor().getClientArea();
- int width = Math.max (comboSize.x, listRect.width + 2);
- int height = listRect.height + 2;
- int x = parentRect.x;
- int y = parentRect.y + comboSize.y;
- if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
- popup.setBounds (x, y, width, height);
- popup.setVisible (true);
- list.setFocus();
-}
-public Control [] getChildren () {
- checkWidget();
- return new Control [0];
-}
-boolean getEditable () {
- return text.getEditable ();
-}
-/**
-* Gets an item at an index.
-* <p>
-* Indexing is zero based.
-*
-* This operation will fail when the index is out
-* of range or an item could not be queried from
-* the OS.
-*
-* @param index the index of the item
-* @return the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_CANNOT_GET_ITEM)
-* when the operation fails
-*/
-public String getItem (int index) {
- checkWidget();
- return list.getItem (index);
-}
-/**
-* Gets the number of items.
-* <p>
-* This operation will fail if the number of
-* items could not be queried from the OS.
-*
-* @return the number of items in the widget
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_CANNOT_GET_COUNT)
-* when the operation fails
-*/
-public int getItemCount () {
- checkWidget();
- return list.getItemCount ();
-}
-/**
-* Gets the height of one item.
-* <p>
-* This operation will fail if the height of
-* one item could not be queried from the OS.
-*
-* @return the height of one item in the widget
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_CANNOT_GET_ITEM_HEIGHT)
-* when the operation fails
-*/
-public int getItemHeight () {
- checkWidget();
- return list.getItemHeight ();
-}
-/**
-* Gets the items.
-* <p>
-* This operation will fail if the items cannot
-* be queried from the OS.
-*
-* @return the items in the widget
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_CANNOT_GET_ITEM)
-* when the operation fails
-*/
-public String [] getItems () {
- checkWidget();
- return list.getItems ();
-}
-/**
-* Gets the selection.
-* <p>
-* @return a point representing the selection start and end
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public Point getSelection () {
- checkWidget();
- return text.getSelection ();
-}
-/**
-* Gets the index of the selected item.
-* <p>
-* Indexing is zero based.
-* If no item is selected -1 is returned.
-*
-* @return the index of the selected item.
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public int getSelectionIndex () {
- checkWidget();
- return list.getSelectionIndex ();
-}
-/**
-* Gets the widget text.
-* <p>
-* If the widget has no text, an empty string is returned.
-*
-* @return the widget text
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public String getText () {
- checkWidget();
- return text.getText ();
-}
-/**
-* Gets the height of the combo's text field.
-* <p>
-* The operation will fail if the height cannot
-* be queried from the OS.
-
-* @return the height of the combo's text field.
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_ERROR_CANNOT_GET_ITEM_HEIGHT)
-* when the operation fails
-*/
-public int getTextHeight () {
- checkWidget();
- return text.getLineHeight();
-}
-/**
-* Gets the text limit.
-* <p>
-* @return the text limit
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public int getTextLimit () {
- checkWidget();
- return text.getTextLimit ();
-}
-/**
-* Gets the index of an item.
-* <p>
-* The list is searched starting at 0 until an
-* item is found that is equal to the search item.
-* If no item is found, -1 is returned. Indexing
-* is zero based.
-*
-* @param string the search item
-* @return the index of the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when string is null
-*/
-public int indexOf (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return list.indexOf (string);
-}
-/**
-* Gets the index of an item.
-* <p>
-* The widget is searched starting at start including
-* the end position until an item is found that
-* is equal to the search itenm. If no item is
-* found, -1 is returned. Indexing is zero based.
-*
-* @param string the search item
-* @param index the starting position
-* @return the index of the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when string is null
-*/
-public int indexOf (String string, int start) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return list.indexOf (string, start);
-}
-
-void initAccessible() {
- getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getHelp(AccessibleEvent e) {
- e.result = getToolTipText();
- }
- });
-
- getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {
- public void getCaretOffset(AccessibleTextEvent e) {
- e.offset = text.getCaretPosition();
- }
- });
-
- getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
- public void getChildAtPoint(AccessibleControlEvent e) {
- Point testPoint = toControl(new Point(e.x, e.y));
- if (getBounds().contains(testPoint)) {
- e.childID = ACC.CHILDID_SELF;
- }
- }
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_COMBOBOX;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail = ACC.STATE_NORMAL;
- }
-
- public void getValue(AccessibleControlEvent e) {
- e.result = getText();
- }
- });
-}
-boolean isDropped () {
- return popup.getVisible ();
-}
-public boolean isFocusControl () {
- checkWidget();
- if (text.isFocusControl() || arrow.isFocusControl() || list.isFocusControl() || popup.isFocusControl()) {
- return true;
- } else {
- return super.isFocusControl();
- }
-}
-
-//public boolean isListVisible()
-//{
-// checkWidget();
-// return list.isVisible();
-//}
-
-void internalLayout () {
- if (isDropped ()) dropDown (false);
-
- Rectangle rect = getClientArea();
- int width = rect.width;
- int height = rect.height;
- Point arrowSize = arrow.computeSize(SWT.DEFAULT, height);
- text.setBounds (0, 0, width - arrowSize.x, height);
- arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
-
- Point size = getSize();
- int itemCount = list.getItemCount();
- itemCount = (itemCount == 0) ? maxItemCount : Math.min(maxItemCount, itemCount);
- int itemHeight = list.getItemHeight () * itemCount;
- Point listSize = list.computeSize (SWT.DEFAULT, itemHeight);
- list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
-}
-void listEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- event.display.asyncExec(new Runnable() {
- public void run() {
- if (DynamicCellEditor.this.isDisposed()) return;
- Control focusControl = getDisplay().getFocusControl();
- if (focusControl == text || focusControl == arrow || focusControl == list) return;
- hasFocus = false;
- Event e = new Event();
- notifyListeners(SWT.FocusOut, e);
- }
- });
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- dropDown (false);
- break;
- }
- case SWT.Selection: {
- int index = list.getSelectionIndex ();
- if (index == -1) return;
- text.setText (list.getItem (index));
- text.selectAll ();
- list.setSelection(index);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- e.doit = event.doit;
- notifyListeners(SWT.Selection, e);
- event.doit = e.doit;
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_TAB_NEXT:
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ESCAPE:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- event.doit = false;
- break;
- }
- Event e = new Event();
- e.time = event.time;
- e.detail = event.detail;
- e.doit = event.doit;
- e.keyCode = event.keyCode;
- notifyListeners(SWT.Traverse, e);
- event.doit = e.doit;
- break;
- }
- case SWT.KeyUp: {
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyUp, e);
- break;
- }
- case SWT.KeyDown: {
- if (event.character == SWT.ESC) {
- // escape key cancels popup list
- dropDown (false);
- }
- if (event.character == SWT.CR || event.character == '\t') {
- // Enter and Tab cause default selection
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.DefaultSelection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed()) break;
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyDown, e);
- break;
-
- }
- }
-}
-void popupEvent(Event event) {
- switch (event.type) {
- case SWT.Paint:
- // draw black rectangle around list
- Rectangle listRect = list.getBounds();
- Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
- event.gc.setForeground(black);
- event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
- break;
- case SWT.Close:
- event.doit = false;
- dropDown (false);
- break;
- case SWT.Deactivate:
- dropDown (false);
- break;
- }
-}
-public void redraw () {
- super.redraw();
- text.redraw();
- arrow.redraw();
- if (popup.isVisible()) list.redraw();
-}
-public void redraw (int x, int y, int width, int height, boolean all) {
- super.redraw(x, y, width, height, true);
-}
-
-/**
-* Removes an item at an index.
-* <p>
-* Indexing is zero based.
-*
-* This operation will fail when the index is out
-* of range or an item could not be removed from
-* the OS.
-*
-* @param index the index of the item
-* @return the selection state
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_REMOVED)
-* when the operation fails
-*/
-public void remove (int index) {
- checkWidget();
- list.remove (index);
-}
-/**
-* Removes a range of items.
-* <p>
-* Indexing is zero based. The range of items
-* is from the start index up to and including
-* the end index.
-*
-* This operation will fail when the index is out
-* of range or an item could not be removed from
-* the OS.
-*
-* @param start the start of the range
-* @param end the end of the range
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_REMOVED)
-* when the operation fails
-*/
-public void remove (int start, int end) {
- checkWidget();
- list.remove (start, end);
-}
-/**
-* Removes an item.
-* <p>
-* This operation will fail when the item
-* could not be removed from the OS.
-*
-* @param string the search item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when string is null
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_REMOVED)
-* when the operation fails
-*/
-public void remove (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- list.remove (string);
-}
-/**
-* Removes all items.
-* <p>
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public void removeAll () {
- checkWidget();
- text.setText (""); //$NON-NLS-1$
- list.removeAll ();
-}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the listener
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when listener is null
-*/
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener(SWT.Modify, listener);
-}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the listener
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when listener is null
-*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- removeListener(SWT.Selection, listener);
- removeListener(SWT.DefaultSelection,listener);
-}
-/**
-* Selects an item.
-* <p>
-* If the item at an index is not selected, it is
-* selected. Indices that are out of
-* range are ignored. Indexing is zero based.
-*
-* @param index the index of the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
-public void select (int index) {
- checkWidget();
- if (index == -1) {
- list.deselectAll ();
- text.setText (""); //$NON-NLS-1$
- return;
- }
- if (0 <= index && index < list.getItemCount()) {
- if (index != getSelectionIndex()) {
- text.setText (list.getItem (index));
- text.selectAll ();
- list.select (index);
- list.showSelection ();
- }
- }
-}
-public void setBackground (Color color) {
- super.setBackground(color);
- if (text != null) text.setBackground(color);
- if (list != null) list.setBackground(color);
- if (arrow != null) arrow.setBackground(color);
-}
-public boolean setFocus () {
- checkWidget();
- return text.setFocus ();
-}
-public void setFont (Font font) {
- super.setFont (font);
- text.setFont (font);
- list.setFont (font);
- internalLayout ();
-}
-public void setForeground (Color color) {
- super.setForeground(color);
- if (text != null) text.setForeground(color);
- if (list != null) list.setForeground(color);
- if (arrow != null) arrow.setForeground(color);
-}
-/**
-* Sets the text of an item; indexing is zero based.
-*
-* This operation will fail when the index is out
-* of range or an item could not be changed in
-* the OS.
-*
-* @param index the index for the item
-* @param string the item
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when items is null
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_MODIFIED)
-* when the operation fails
-*/
-public void setItem (int index, String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- list.setItem (index, string);
-}
-/**
-* Sets all items.
-*
-* @param items the array of items
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when items is null
-* @exception org.eclipse.swt.SWTError(ERROR_ITEM_NOT_ADDED)
-* when the operation fails
-*/
-public void setItems (String [] items) {
- checkWidget();
- if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int style = getStyle();
- if ((style & SWT.READ_ONLY) != 0) text.setText (""); //$NON-NLS-1$
- list.setItems (items);
-}
-/**
-* Sets the new selection.
-*
-* @param selection point representing the start and the end of the new selection
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when selection is null
-*/
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- text.setSelection (selection.x, selection.y);
-}
-
-/**
-* Sets the widget text.
-*
-* @param string the widget text
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_NULL_ARGUMENT)
-* when string is null
-*/
-public void setText (String string) {
- checkWidget();
- if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int index = list.indexOf (string);
- if (index == -1) {
- list.deselectAll ();
- text.setText (string);
- return;
- }
- text.setText (string);
- text.selectAll ();
- list.setSelection (index);
- list.showSelection ();
-}
-/**
-* Sets the text limit.
-*
-* @param limit new text limit
-*
-* @exception org.eclipse.swt.SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception org.eclipse.swt.SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception org.eclipse.swt.SWTError(ERROR_CANNOT_BE_ZERO)
-* when limit is 0
-*/
-public void setTextLimit (int limit) {
- checkWidget();
- text.setTextLimit (limit);
-}
-
-public void setToolTipText (String string) {
- checkWidget();
- super.setToolTipText(string);
- arrow.setToolTipText (string);
- text.setToolTipText (string);
-}
-
-public void setVisible (boolean visible) {
- super.setVisible(visible);
- if (!visible) popup.setVisible(false);
-}
-
-void textEvent (Event event) {
- switch (event.type) {
- case SWT.FocusIn: {
- if (hasFocus) return;
- hasFocus = true;
- if (getEditable ()) text.selectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.FocusIn, e);
- break;
- }
- case SWT.FocusOut: {
- event.display.asyncExec(new Runnable() {
- public void run() {
- if (DynamicCellEditor.this.isDisposed()) return;
- Control focusControl = getDisplay().getFocusControl();
- if (focusControl == list || focusControl == arrow) return;
- hasFocus = false;
- Event e = new Event();
- notifyListeners(SWT.FocusOut, e);
- }
- });
- break;
- }
- case SWT.KeyDown: {
-
- if (event.character == SWT.ESC) { // escape key cancels popup list
- dropDown (false);
- }
- if (event.character == SWT.CR) {
- dropDown (false);
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.DefaultSelection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed()) break;
-
- if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
- int oldIndex = getSelectionIndex ();
- if (event.keyCode == SWT.ARROW_UP) {
- select (Math.max (oldIndex - 1, 0));
- } else {
- select (Math.min (oldIndex + 1, getItemCount () - 1));
- }
-
- if (oldIndex != getSelectionIndex ()) {
- Event e = new Event();
- e.time = event.time;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.Selection, e);
- }
- //At this point the widget may have been disposed.
- // If so, do not continue.
- if (isDisposed()) break;
- }
-
- // Further work : Need to add support for incremental search in
- // pop up list as characters typed in text widget
-
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyDown, e);
- break;
- }
- case SWT.KeyUp: {
- Event e = new Event();
- e.time = event.time;
- e.character = event.character;
- e.keyCode = event.keyCode;
- e.stateMask = event.stateMask;
- notifyListeners(SWT.KeyUp, e);
- break;
- }
- case SWT.Modify: {
- list.deselectAll ();
- Event e = new Event();
- e.time = event.time;
- notifyListeners(SWT.Modify, e);
- break;
- }
- case SWT.MouseDown: {
- if (event.button != 1) return;
- if (text.getEditable ()) return;
- boolean dropped = isDropped ();
- text.selectAll ();
- if (!dropped) setFocus ();
- dropDown (!dropped);
- break;
- }
- case SWT.MouseUp: {
- if (event.button != 1) return;
- if (text.getEditable ()) return;
- text.selectAll ();
- break;
- }
- case SWT.Traverse: {
- switch (event.detail) {
- case SWT.TRAVERSE_RETURN:
- case SWT.TRAVERSE_ARROW_PREVIOUS:
- case SWT.TRAVERSE_ARROW_NEXT:
- // The enter causes default selection and
- // the arrow keys are used to manipulate the list contents so
- // do not use them for traversal.
- event.doit = false;
- break;
- }
-
- Event e = new Event();
- e.time = event.time;
- e.detail = event.detail;
- e.doit = event.doit;
- e.keyCode = event.keyCode;
- notifyListeners(SWT.Traverse, e);
- event.doit = e.doit;
- break;
- }
- }
-}
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ElementPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ElementPropertySource.java
deleted file mode 100644
index 65416acd3b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ElementPropertySource.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalElementRenamer;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class ElementPropertySource extends BasePropertySource implements IPropertySource
-{
- private String[] blockComboValues =
- { "", "#all", "extension", "restriction", "substitution" };
- private String[] finalComboValues =
- { "", "#all", "extension", "restriction" };
- private String[] substitutionGroupComboValues = { "" };
- private String[] formComboValues =
- {
- "",
- XSDEditorPlugin.getXSDString("_UI_COMBO_UNQUALIFIED"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_QUALIFIED")
- };
-
- public ElementPropertySource()
- {
- super();
- }
-
- public ElementPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
-
- public ElementPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
-
- public void setInput(Element element)
- {
- this.element = element;
- TypesHelper helper = new TypesHelper(xsdSchema);
- List globals = helper.getGlobalElements();
- int size = globals.size() + 1;
- substitutionGroupComboValues = new String[size];
- substitutionGroupComboValues[0] = "";
- if (globals != null)
- {
- for (int k = 0; k < globals.size(); k++)
- {
- substitutionGroupComboValues[k + 1] = (String) globals.get(k);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
-// return element.getNodeName();
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- Object parentNode = element.getParentNode();
- boolean isGlobalElement = XSDDOMHelper.inputEquals(parentNode, XSDConstants.SCHEMA_ELEMENT_TAG, false);
-
- List list = new ArrayList();
- // Create a descriptor and set a category
-// These have been moved to the general tab
-// PropertyDescriptor nameDescriptor =
-// new TextPropertyDescriptor(
-// XSDConstants.NAME_ATTRIBUTE,
-// XSDConstants.NAME_ATTRIBUTE);
-// list.add(nameDescriptor);
-// TypesPropertyDescriptor typeDescriptor = new TypesPropertyDescriptor(
-// XSDConstants.TYPE_ATTRIBUTE,
-// XSDConstants.TYPE_ATTRIBUTE,
-// element, xsdSchema);
-// list.add(typeDescriptor);
- if (isGlobalElement)
- {
- XSDComboBoxPropertyDescriptor abstractDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.ABSTRACT_ATTRIBUTE,
- XSDConstants.ABSTRACT_ATTRIBUTE,
- trueFalseComboValues);
- list.add(abstractDescriptor);
- }
- if (!isGlobalElement)
- {
- PropertyDescriptor minOccursDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.MINOCCURS_ATTRIBUTE,
- XSDConstants.MINOCCURS_ATTRIBUTE);
- list.add(minOccursDescriptor);
-
- PropertyDescriptor maxOccursDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.MAXOCCURS_ATTRIBUTE,
- XSDConstants.MAXOCCURS_ATTRIBUTE);
- list.add(maxOccursDescriptor);
- }
- XSDComboBoxPropertyDescriptor nillableDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.NILLABLE_ATTRIBUTE,
- XSDConstants.NILLABLE_ATTRIBUTE,
- trueFalseComboValues);
- list.add(nillableDescriptor);
- XSDComboBoxPropertyDescriptor blockDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.BLOCK_ATTRIBUTE,
- XSDConstants.BLOCK_ATTRIBUTE,
- blockComboValues);
- list.add(blockDescriptor);
- if (isGlobalElement)
- {
- XSDComboBoxPropertyDescriptor finalDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.FINAL_ATTRIBUTE,
- XSDConstants.FINAL_ATTRIBUTE,
- finalComboValues);
- list.add(finalDescriptor);
- XSDComboBoxPropertyDescriptor substitutionGroupDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE,
- XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE,
- substitutionGroupComboValues);
- list.add(substitutionGroupDescriptor);
- }
- if (!isGlobalElement)
- {
- XSDComboBoxPropertyDescriptor formDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.FORM_ATTRIBUTE,
- XSDConstants.FORM_ATTRIBUTE,
- formComboValues);
- list.add(formDescriptor);
- }
-
- Attr fixedAttr = element.getAttributeNode(XSDConstants.FIXED_ATTRIBUTE);
- Attr defaultAttr = element.getAttributeNode(XSDConstants.DEFAULT_ATTRIBUTE);
- String str;
- if (fixedAttr != null)
- {
- str = XSDConstants.FIXED_ATTRIBUTE;
- }
- else if (defaultAttr != null)
- {
- str = XSDConstants.DEFAULT_ATTRIBUTE;
- }
- else
- {
- str = XSDConstants.FIXED_ATTRIBUTE + "/" + XSDConstants.DEFAULT_ATTRIBUTE;
- }
-
- FixedOrDefaultTextPropertyDescriptor fixedOrDefaultDescriptor =
- new FixedOrDefaultTextPropertyDescriptor(
- str,
- str,
- element);
- list.add(fixedOrDefaultDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- // return propertyDescriptors;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- String attributeName = (String)id;
- result = element.getAttribute(attributeName);
- if (result == null)
- {
- result = "";
- }
- if (attributeName.equals(XSDConstants.TYPE_ATTRIBUTE))
- {
- boolean isAnonymous = checkForAnonymousType(element);
- if (isAnonymous)
- {
- return "**anonymous**";
- }
- if (result.equals(""))
- {
- result = XSDEditorPlugin.getXSDString("_UI_NO_TYPE");
- }
- return result;
- }
- else if (attributeName.equals(XSDConstants.MAXOCCURS_ATTRIBUTE)
- || attributeName.equals(XSDConstants.MINOCCURS_ATTRIBUTE)
- || attributeName.equals(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE)
- || attributeName.equals(XSDConstants.FORM_ATTRIBUTE)
- || attributeName.equals(XSDConstants.ABSTRACT_ATTRIBUTE)
- || attributeName.equals(XSDConstants.NILLABLE_ATTRIBUTE)
- || attributeName.equals(XSDConstants.BLOCK_ATTRIBUTE)
- || attributeName.equals(XSDConstants.FINAL_ATTRIBUTE)
- || attributeName.equals(XSDConstants.FIXED_ATTRIBUTE)
- || attributeName.equals(XSDConstants.DEFAULT_ATTRIBUTE)
- || attributeName.equals(XSDConstants.NAME_ATTRIBUTE))
- {
- return result;
- }
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object,
- * java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- String attributeName = (String)id;
-
- if (attributeName.equals(XSDConstants.MAXOCCURS_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MAXOCCURS_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.MINOCCURS_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MINOCCURS_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_SUBSTITUTIONGROUP_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.FORM_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_FORM_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.ABSTRACT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_ABSTRACT_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.NILLABLE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_NILLABLE_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.BLOCK_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_BLOCK_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.FINAL_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_FINAL_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.FIXED_ATTRIBUTE) || attributeName.equals(XSDConstants.DEFAULT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_VALUE_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.NAME_ATTRIBUTE))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_NAME_CHANGE"), element);
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDElementDeclaration && comp.getContainer().equals(xsdSchema))
- {
- GlobalElementRenamer renamer = new GlobalElementRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- }
- }
- else if (attributeName.equals(XSDConstants.TYPE_ATTRIBUTE))
- {
- // put logic in descriptor/cell editor
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_TYPE_CHANGE"), element);
- }
-
- if (newValue.length() > 0)
- {
- element.setAttribute((String) id, (String) value);
- }
- else
- {
- if (!attributeName.equals(XSDConstants.NAME_ATTRIBUTE))
- {
- element.removeAttribute((String) id);
- }
- }
- endRecording(element);
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- boolean checkForAnonymousType(Element element)
- {
- /* Using Ed's model to check
- boolean isAnonymous = false;
-
- XSDConcreteComponent component = getXSDSchema().getCorrespondingComponent(element);
- if (component instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElem = (XSDElementDeclaration)component;
- isAnonymous = xsdElem.isSetAnonymousTypeDefinition();
- }
- return isAnonymous;
- */
-
- boolean isAnonymous = false;
-
- Node aNode = getDomHelper().getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- aNode = getDomHelper().getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- isAnonymous = true;
- }
- return isAnonymous;
- }
-
-
-// void updateElementToAnonymous(Element element, String xsdType)
-// {
-// String prefix = element.getPrefix();
-// prefix = (prefix == null) ? "" : (prefix + ":");
-//
-// updateElementToNotAnonymous(element);
-// boolean hasChildrenElements = hasElementChildren(element);
-//
-// Element childNode = null;
-// if (xsdType.equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
-// {
-// childNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
-// }
-// else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG))
-// {
-// childNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SIMPLETYPE_ELEMENT_TAG);
-// }
-//
-// element.appendChild(childNode);
-// formatChild(childNode, hasChildrenElements);
-//
-//
-// /* Using Ed's model to do the above
-// XSDConcreteComponent component = getXSDSchema().getCorrespondingComponent(element);
-// if (component instanceof XSDElementDeclaration)
-// {
-// XSDElementDeclaration xsdElem = (XSDElementDeclaration)component;
-// XSDFactoryImpl factory = new XSDFactoryImpl();
-// XSDComplexTypeDefinition complex = factory.createXSDComplexTypeDefinition();
-// XSDSimpleTypeDefinition simple = factory.createXSDSimpleTypeDefinition();
-//
-// Node child = element.getFirstChild();
-// if (XSDDOMHelper.inputEquals(child, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false) ||
-// XSDDOMHelper.inputEquals(child, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
-// {
-// element.removeChild(child);
-// }
-//
-// FormatProcessor formatProcessor = new FormatProcessor();
-// if (xsdType.equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
-// {
-// xsdElem.setAnonymousTypeDefinition(complex);
-// Element elem = complex.getElement();
-// formatProcessor.formatWithSiblingIndent((XMLNode)elem);
-// }
-// else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG))
-// {
-// xsdElem.setAnonymousTypeDefinition(simple);
-// Element elem = simple.getElement();
-// formatProcessor.formatWithSiblingIndent((XMLNode)elem);
-// }
-// }
-// component.updateElement();
-// */
-// }
-//
-// boolean isSTAnonymous(Element element)
-// {
-// Node aNode = getDomHelper().getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
-// if (aNode != null)
-// {
-// if (XSDDOMHelper.inputEquals(aNode, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
-// {
-// return true;
-// }
-// }
-// return false;
-// }
-//
-// boolean isCTAnonymous(Element element)
-// {
-// Node aNode = getDomHelper().getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
-// if (aNode != null)
-// {
-// if (XSDDOMHelper.inputEquals(aNode, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
-// {
-// return true;
-// }
-// }
-// return false;
-// }
-//
-// XSDTypeDefinition getAnonymousTypeDefinition(Element element)
-// {
-// Node typeDefinitionNode = getDomHelper().getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
-// if (typeDefinitionNode == null)
-// {
-// typeDefinitionNode = getDomHelper().getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
-// }
-// if (typeDefinitionNode != null)
-// {
-// XSDConcreteComponent component = getXSDSchema().getCorrespondingComponent(typeDefinitionNode);
-// if (component instanceof XSDTypeDefinition)
-// {
-// return (XSDTypeDefinition)component;
-// }
-// }
-// return null;
-//
-// /* XSDConcreteComponent component = getXSDSchema().getCorrespondingComponent(element);
-// if (component instanceof XSDElementDeclaration)
-// {
-// XSDElementDeclaration xsdElem = (XSDElementDeclaration)component;
-//
-// return xsdElem.getAnonymousTypeDefinition();
-// }
-// return null;
-// */
-// }
-//
-// void updateElementToNotAnonymous(Element element)
-// {
-// NodeList children = element.getChildNodes();
-// if (children != null)
-// {
-// for (int i = 0; i < children.getLength(); i++)
-// {
-// Node node = (Node)children.item(i);
-// if (node instanceof Element)
-// {
-// if (node.getLocalName().equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG) ||
-// node.getLocalName().equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
-// {
-// XSDDOMHelper.removeNodeAndWhitespace(node);
-// i=0;
-// }
-// }
-// }
-// }
-// /* XSDConcreteComponent component = getXSDSchema().getCorrespondingComponent(element);
-// if (component instanceof XSDElementDeclaration)
-// {
-// XSDElementDeclaration xsdElem = (XSDElementDeclaration)component;
-// if (xsdElem.isSetAnonymousTypeDefinition())
-// {
-// xsdElem.unsetAnonymousTypeDefinition();
-// xsdElem.setAnonymousTypeDefinition(null);
-// }
-// }
-// component.updateElement();
-// */
-// }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/EnumerationPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/EnumerationPropertySource.java
deleted file mode 100644
index 65124f7015..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/EnumerationPropertySource.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-public class EnumerationPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public EnumerationPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public EnumerationPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public EnumerationPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- PropertyDescriptor nameDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.VALUE_ATTRIBUTE,
- XSDConstants.VALUE_ATTRIBUTE);
- list.add(nameDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ENUM_VALUE_CHANGE"), element);
- element.setAttribute(XSDConstants.VALUE_ATTRIBUTE, (String)value);
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/FixedOrDefaultTextPropertyDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/FixedOrDefaultTextPropertyDescriptor.java
deleted file mode 100644
index 1cdced0c80..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/FixedOrDefaultTextPropertyDescriptor.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.window.Window;
-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.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-
-public class FixedOrDefaultTextPropertyDescriptor extends PropertyDescriptor
-{
- protected static String choice = "";
- Element element;
- /**
- * @param id
- * @param displayName
- */
- public FixedOrDefaultTextPropertyDescriptor(Object id, String displayName, Element element)
- {
- super(id, displayName);
- this.element = element;
- }
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- CellEditor editor = new FixedOrDefaultTextCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
-
-// public void setChoice(String newChoice)
-// {
-// choice = newChoice;
-// }
-
- public Object getId()
- {
- Attr fixedAttr = element.getAttributeNode(XSDConstants.FIXED_ATTRIBUTE);
- Attr defaultAttr = element.getAttributeNode(XSDConstants.DEFAULT_ATTRIBUTE);
- if (fixedAttr != null)
- {
- choice = "fixed";
- }
- else if (defaultAttr != null) // what if both attributes were specified? Use default...
- {
- choice = "default";
- }
- else
- {
- choice = "";
- }
-
- if (choice.equals("fixed"))
- {
- return "fixed";
- }
- else if (choice.equals("default"))
- {
- return "default";
- }
- else
- {
- return super.getId();
- }
- }
-
- public String getDisplayName()
- {
- Attr fixedAttr = element.getAttributeNode(XSDConstants.FIXED_ATTRIBUTE);
- Attr defaultAttr = element.getAttributeNode(XSDConstants.DEFAULT_ATTRIBUTE);
- if (fixedAttr != null)
- {
- choice = "fixed";
- }
- else if (defaultAttr != null) // what if both attributes were specified? Use default...
- {
- choice = "default";
- }
- else
- {
- choice = "fixed/default";
- }
-
- if (choice.equals("fixed"))
- {
- return "fixed";
- }
- else if (choice.equals("default"))
- {
- return "default";
- }
- else
- {
- return super.getDisplayName();
- }
- }
-
- class FixedOrDefaultTextCellEditor extends DialogCellEditor
- {
- public FixedOrDefaultTextCellEditor(Composite parent)
- {
- super(parent);
- }
-
- protected Object openDialogBox(Control cellEditorWindow)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- FixedOrDefaultDialog dialog = new FixedOrDefaultDialog(shell);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- dialog.getValue();
- fireApplyEditorValue();
- }
- deactivate();
- return null;
- }
- }
-
- class FixedOrDefaultDialog extends Dialog implements SelectionListener
- {
- private int FIXED = 0;
- private int DEFAULT = 1;
- private int type;
- protected Button fixedButton, defaultButton;
- protected Text valueField;
- protected String valueString = "";
-
- public FixedOrDefaultDialog(Shell shell)
- {
- super(shell);
- }
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.OK)
- {
- valueString = valueField.getText();
- applyEditorValueAndDeactivate();
- }
- super.buttonPressed(buttonId);
- }
-
- public String getValue() { return valueString; }
- public String getType() { return type == FIXED? "fixed" : "default"; }
-
- //
- // Create the controls
- //
- public Control createDialogArea(Composite parent)
- {
- Composite client = (Composite)super.createDialogArea(parent);
- getShell().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_FIXEDORDEFAULT_VALUE"));
-
- GridLayout gl = new GridLayout(1, true);
-// gl.marginHeight = 0;
-// gl.marginWidth = 0;
-// gl.horizontalSpacing = 0;
-// gl.verticalSpacing = 0;
- client.setLayout(gl);
-
- GridData gd = new GridData();
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.FILL;
- gd.horizontalIndent = 0;
- client.setLayoutData(gd);
-
-// isTextReadOnly = false;
-
- fixedButton = ViewUtility.createRadioButton(client, XSDEditorPlugin.getXSDString("_UI_FIXED"));
-// WorkbenchHelp.setHelp(fixedButton, XSDEditorContextIds.XSDE_ELEMENT_FIXED);
-
- defaultButton = ViewUtility.createRadioButton(client, XSDEditorPlugin.getXSDString("_UI_DEFAULT"));
-// WorkbenchHelp.setHelp(defaultButton, XSDEditorContextIds.XSDE_ELEMENT_DEFAULT);
-
- valueField = ViewUtility.createTextField(client, 30);
-
-// WorkbenchHelp.setHelp(valueField, XSDEditorContextIds.XSDE_ELEMENT_VALUE);
-// valueField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_VALUE"));
-
- WorkbenchHelp.setHelp(fixedButton, XSDEditorContextIds.XSDE_ATTRIBUTE_FIXED);
- WorkbenchHelp.setHelp(defaultButton, XSDEditorContextIds.XSDE_ATTRIBUTE_DEFAULT);
- // WorkbenchHelp.setHelp(valueField, XSDEditorContextIds.XSDE_ATTRIBUTE_VALUE);
-
- Attr fixedAttr = element.getAttributeNode(XSDConstants.FIXED_ATTRIBUTE);
- Attr defaultAttr = element.getAttributeNode(XSDConstants.DEFAULT_ATTRIBUTE);
-
- if (fixedAttr != null)
- {
- fixedButton.setSelection(true);
- defaultButton.setSelection(false);
- choice = "fixed";
- type = FIXED;
- valueField.setText(element.getAttribute("fixed"));
- valueField.setFocus();
- valueField.selectAll();
- }
- if (defaultAttr != null) // what if both attributes were specified? Use default...
- {
- fixedButton.setSelection(false);
- defaultButton.setSelection(true);
- choice = "default";
- type = DEFAULT;
- valueField.setText(element.getAttribute("default"));
- valueField.setFocus();
- valueField.selectAll();
- }
-
- fixedButton.addSelectionListener(this);
- defaultButton.addSelectionListener(this);
- return client;
- }
-
- void applyEditorValueAndDeactivate()
- {
- String value = valueField.getText();
- if (value != null && value.length() > 0)
- {
- choice = type == FIXED? "fixed" : "default";
- }
- if (value != null && value.length() > 0)
- {
- if (choice.equals("fixed"))
- {
- element.removeAttribute(XSDConstants.DEFAULT_ATTRIBUTE);
- element.setAttribute(XSDConstants.FIXED_ATTRIBUTE, value);
- }
- else if (choice.equals("default"))
- {
- element.removeAttribute(XSDConstants.FIXED_ATTRIBUTE);
- element.setAttribute(XSDConstants.DEFAULT_ATTRIBUTE, value);
- }
- }
- if (value.equals(""))
- {
- choice = "";
- element.removeAttribute(XSDConstants.DEFAULT_ATTRIBUTE);
- element.removeAttribute(XSDConstants.FIXED_ATTRIBUTE);
- }
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == fixedButton && fixedButton.getSelection())
- {
- type = FIXED;
- choice = "fixed";
- }
- else if (e.widget == defaultButton && defaultButton.getSelection())
- {
- type = DEFAULT;
- choice = "default";
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/GroupRefPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/GroupRefPropertySource.java
deleted file mode 100644
index 0067c4813d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/GroupRefPropertySource.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class GroupRefPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String[] refComboValues = { "" };
- /**
- *
- */
- public GroupRefPropertySource()
- {
- super();
- }
-
-// public void setReferenceComboContextHelp(String contextId)
-// {
-// WorkbenchHelp.setHelp(refCombo, contextId);
-// }
-
- /**
- * @param viewer
- * @param xsdSchema
- */
- public GroupRefPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public GroupRefPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
-
- public void setInput(Element element)
- {
- this.element = element;
- TypesHelper helper = new TypesHelper(xsdSchema);
- java.util.List items = helper.getGlobalElements();
- if (XSDDOMHelper.inputEquals(element, XSDConstants.GROUP_ELEMENT_TAG, true))
- {
- items = helper.getModelGroups();
- // Need tooltip for Group Ref
-// minimumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MINIMUM"));
-// WorkbenchHelp.setHelp(minimumField, XSDEditorContextIds.XSDE_GROUP_REF_MINIMUM);
-// maximumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MAXIMUM"));
-// WorkbenchHelp.setHelp(maximumField, XSDEditorContextIds.XSDE_GROUP_REF_MAXIMUM);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, true))
- {
- items = helper.getGlobalElements();
-// minimumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MINIMUM"));
-// WorkbenchHelp.setHelp(minimumField, XSDEditorContextIds.XSDE_ELEMENT_REF_MINIMUM);
-// maximumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MAXIMUM"));
-// WorkbenchHelp.setHelp(maximumField, XSDEditorContextIds.XSDE_ELEMENT_REF_MAXIMUM);
- }
-
- int size = items.size() + 1;
- refComboValues = new String[size];
- refComboValues[0] = "";
- if (items != null)
- {
- for (int i = 0; i < items.size(); i++)
- {
- refComboValues[i + 1] = (String) items.get(i);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- XSDComboBoxPropertyDescriptor refDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.REF_ATTRIBUTE,
- XSDConstants.REF_ATTRIBUTE,
- refComboValues);
- list.add(refDescriptor);
-
- PropertyDescriptor minOccursDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.MINOCCURS_ATTRIBUTE,
- XSDConstants.MINOCCURS_ATTRIBUTE);
- list.add(minOccursDescriptor);
- PropertyDescriptor maxOccursDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.MAXOCCURS_ATTRIBUTE,
- XSDConstants.MAXOCCURS_ATTRIBUTE);
- list.add(maxOccursDescriptor);
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "";
- }
- return result;
-
-// if (((String) id).equals(XSDConstants.REF_ATTRIBUTE))
-// {
-// return result;
-// }
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (((String) id).equals(XSDConstants.MAXOCCURS_ATTRIBUTE))
- {
- String max = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MAXOCCURS_CHANGE"), element);
- if (max.length() > 0)
- {
- element.setAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE, max);
- }
- else
- {
- element.removeAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.MINOCCURS_ATTRIBUTE))
- {
- String min = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MINOCCURS_CHANGE"), element);
- if (min.length() > 0)
- {
- element.setAttribute(XSDConstants.MINOCCURS_ATTRIBUTE, min);
- }
- else
- {
- element.removeAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.REF_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_REF_CHANGE"), element);
- element.setAttribute((String) id, newValue);
- endRecording(element);
- }
- }
-// Runnable delayedUpdate = new Runnable()
-// {
-// public void run()
-// {
- if (viewer != null)
- viewer.refresh();
-// }
-// };
-// Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ImportPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ImportPropertySource.java
deleted file mode 100644
index cadd6114a5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ImportPropertySource.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.XSDExternalFileCleanup;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class ImportPropertySource
- extends SchemaDirectiveHelperPropertySource
- implements IPropertySource
-{
- boolean isSetNamespace = false;
- /**
- * @param viewer
- * @param xsdSchema
- */
- public ImportPropertySource(Viewer viewer, XSDSchema xsdSchema, IFile currentIFile)
- {
- super(viewer, xsdSchema, false);
- this.currentIFile = currentIFile;
-// WorkbenchHelp.setHelp(controlsContainer, XSDEditorContextIds.XSDE_IMPORT_DESIGN_VIEW);
-//WorkbenchHelp.setHelp(selectButton, XSDEditorContextIds.XSDE_INCLUDE_HELPER_SELECT);
-//WorkbenchHelp.setHelp(prefixField, XSDEditorContextIds.XSDE_IMPORT_PREFIX);
- }
- /**
- * @param xsdSchema
- */
- public ImportPropertySource(XSDSchema xsdSchema, IFile currentIFile)
- {
- super(xsdSchema, false);
- this.currentIFile = currentIFile;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-
- SchemaLocationPropertyDescriptor schemaLocationDescriptor =
- new SchemaLocationPropertyDescriptor(
- XSDConstants.SCHEMALOCATION_ATTRIBUTE,
- XSDConstants.SCHEMALOCATION_ATTRIBUTE
- );
- schemaLocationDescriptor.setHelpContextIds(XSDEditorContextIds.XSDE_INCLUDE_HELPER_SELECT);
- list.add(schemaLocationDescriptor);
-
- if (isSetNamespace)
- {
- PropertyDescriptor prefixDescriptor =
- new TextPropertyDescriptor(
- "Prefix",
- "Prefix");
- prefixDescriptor.setHelpContextIds(XSDEditorContextIds.XSDE_IMPORT_PREFIX);
- list.add(prefixDescriptor);
- }
- else
- {
- PropertyDescriptor prefixDescriptor =
- new PropertyDescriptor(
- "Prefix",
- "Prefix");
- prefixDescriptor.setHelpContextIds(XSDEditorContextIds.XSDE_IMPORT_PREFIX);
- list.add(prefixDescriptor);
- }
-
- PropertyDescriptor namespaceDescriptor =
- new PropertyDescriptor(
- XSDConstants.NAMESPACE_ATTRIBUTE,
- XSDConstants.NAMESPACE_ATTRIBUTE);
- list.add(namespaceDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- String attributeName = (String)id;
- if (result == null)
- {
- result = "";
- }
-
- if (attributeName.equals("Prefix"))
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- String aPrefix = helper.getPrefix(element.getAttribute(XSDConstants.NAMESPACE_ATTRIBUTE), false);
- if (aPrefix != null && aPrefix.length() > 0)
- {
- return aPrefix;
- }
- return "";
- }
- else
- {
- return result;
- }
- }
- return "";
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- TypesHelper typesHelper = new TypesHelper(xsdSchema);
- String namespace = element.getAttribute(XSDConstants.NAMESPACE_ATTRIBUTE);
- String oldPrefixValue = typesHelper.getPrefix(namespace, false);
-
- String schemaLocation = element.getAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE);
- if (((String) id).equals("Prefix"))
- {
- if (validatePrefix(newValue) && schemaLocation.length() > 0)
- {
- Map map = xsdSchema.getQNamePrefixToNamespaceMap();
-
- if (map.containsKey(newValue))
- {
-// setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_LABEL_PREFIX_EXISTS"));
- }
- else
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PREFIX_CHANGE"), element);
- map.remove(oldPrefixValue);
- map.put(newValue, namespace);
- XSDSchemaHelper.updateElement(xsdSchema);
-
- endRecording(element);
- }
- }
- }
- else if (((String) id).equals(XSDConstants.SCHEMALOCATION_ATTRIBUTE))
- {
- updateExternalModel((String)value, selectedIFile, selectedNamespace, selectedXSDSchema);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- public void setInput(Element element)
- {
- this.element = element;
- String namespace = element.getAttribute(XSDConstants.NAMESPACE_ATTRIBUTE);
- if (namespace != null && namespace.trim().length() > 0)
- {
- isSetNamespace = true;
- }
-
- }
-
- protected void updateExternalModel(String newLocation, IFile newFile, String namespace, XSDSchema externalSchema)
- {
- if (xsdSchema == null) // in case we have a bad schema
- {
- return;
- }
- Element importElement = element;
- if (namespace == null)
- {
- namespace = "";
- }
-
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp instanceof XSDImport)
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_IMPORT_CHANGE"), importElement);
- 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 = ((XSDSchemaDirective)comp).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);
-
- boolean prefixAlreadyExists = false;
- if (map.containsKey(prefix))
- {
- prefixAlreadyExists = true;
- }
-
- if (prefix == null || (prefix !=null && prefix.length() == 0) || prefixAlreadyExists)
- {
- prefix = "pref";
-
- int prefixExtension = 1;
- while (map.containsKey(prefix) && prefixExtension < 100)
- {
- prefix = prefix + String.valueOf(prefixExtension);
- prefixExtension++;
- }
- }
-
- 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);
- }
- }
-
- // Now update the import element's attributes
- importElement.setAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, newLocation);
-
- if (!namespace.equals(""))
- {
- importElement.setAttribute(XSDConstants.NAMESPACE_ATTRIBUTE, namespace);
- }
- else
- {
- importElement.removeAttribute(XSDConstants.NAMESPACE_ATTRIBUTE);
- }
-
- endRecording(importElement);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/IncludePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/IncludePropertySource.java
deleted file mode 100644
index b5054acfe3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/IncludePropertySource.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.XSDExternalFileCleanup;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class IncludePropertySource
- extends SchemaDirectiveHelperPropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public IncludePropertySource(IFile currentIFile)
- {
- super(true);
- this.currentIFile = currentIFile;
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public IncludePropertySource(Viewer viewer, XSDSchema xsdSchema, IFile currentIFile)
- {
- super(viewer, xsdSchema, true);
- this.currentIFile = currentIFile;
- }
- /**
- * @param xsdSchema
- */
- public IncludePropertySource(XSDSchema xsdSchema, IFile currentIFile)
- {
- super(xsdSchema, true);
- this.currentIFile = currentIFile;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-
- SchemaLocationPropertyDescriptor schemaLocationDescriptor =
- new SchemaLocationPropertyDescriptor(
- XSDConstants.SCHEMALOCATION_ATTRIBUTE,
- XSDConstants.SCHEMALOCATION_ATTRIBUTE);
-
- list.add(schemaLocationDescriptor);
-
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.SCHEMALOCATION_ATTRIBUTE))
- {
- //element.setAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, (String)value);
- updateExternalModel((String)value, selectedIFile, selectedNamespace, selectedXSDSchema);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
- }
-
- protected void updateExternalModel(String newLocation, IFile newFile, String namespace, XSDSchema externalSchema)
- {
- Element includeElement = element;
-
- String existingSchemaLocation = includeElement.getAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE);
-
- beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_INCLUDE_CHANGE"), includeElement);
- includeElement.setAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, newLocation);
-
- // If there is no existing schemaLocation, then just set it
- if (existingSchemaLocation == null)
- {
- return;
- }
-
- XSDConcreteComponent includeComponent = xsdSchema.getCorrespondingComponent(includeElement);
- if (includeComponent instanceof XSDInclude)
- {
- XSDInclude include = (XSDInclude) includeComponent;
-
- XSDSchema referencedSchema = include.getResolvedSchema();
- if (referencedSchema != null)
- {
- XSDExternalFileCleanup cleanHelper = new XSDExternalFileCleanup(referencedSchema);
- cleanHelper.visitSchema(xsdSchema);
-
- xsdSchema.update();
- include.updateElement();
- }
-
- }
- endRecording(includeElement);
- }
-
-
-// Redefine's version
-// protected void updateExternalModel(IFile newFile, String namespace, XSDSchema externalSchema)
-// {
-// Element redefineElement = (Element) getNode();
-//
-// redefineElement.setAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, locationField.getText());
-//
-// String existingSchemaLocation = redefineElement.getAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE);
-//
-// // If there is no existing schemaLocation, then just set it and return
-// if (existingSchemaLocation == null)
-// {
-// return;
-// }
-//
-// XSDConcreteComponent redefineComponent = getXSDSchema().getCorrespondingComponent(redefineElement);
-// if (redefineComponent instanceof XSDRedefine)
-// {
-// XSDRedefine redefine = (XSDRedefine) redefineComponent;
-// XSDExternalFileCleanup cleanup = new XSDExternalFileCleanup(redefine.getIncorporatedSchema());
-//
-// cleanup.visitSchema(getXSDSchema());
-// if (getEditor() != null)
-// {
-//// DisplayErrorInTaskList task = new DisplayErrorInTaskList(getEditor().getEditorIDocument(), getEditor().getFileResource(), cleanup.getMessages());
-//// task.run();
-//
-// // Workaround to reset included elements in XSD model
-// getEditor().reparseSchema();
-// getEditor().getGraphViewer().setSchema(getXSDSchema());
-// }
-// }
-//
-// /* since we are reparsing, we don't need this
-//
-// Iterator contents = getXSDSchema().getContents().iterator();
-// while (contents.hasNext())
-// {
-// XSDSchemaContent content = (XSDSchemaContent)contents.next();
-// if (content instanceof XSDSchemaDirective)
-// {
-// XSDSchemaDirective directive = (XSDSchemaDirective)content;
-//
-// if (directive.getSchemaLocation().equals(oldSchemaLocation) && directive instanceof XSDRedefine)
-// {
-// directive.unsetSchemaLocation();
-// directive.setSchemaLocation(locationField.getText());
-// directive.unsetResolvedSchema();
-// redefineElement.setAttribute(XSDConstants.SCHEMALOCATION_ATTRIBUTE, locationField.getText());
-// getXSDSchema().updateDocument();
-// XSDSchemaHelper.updateElement(directive);
-//// directive.updateElement();
-// break;
-// }
-// }
-// }
-// */
-// }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/KeyrefPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/KeyrefPropertySource.java
deleted file mode 100644
index 19e95ce78b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/KeyrefPropertySource.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class KeyrefPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String[] refComboValues = { "" };
- /**
- *
- */
- public KeyrefPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public KeyrefPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public KeyrefPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
-
- public void setInput(Element element)
- {
- this.element = element;
- java.util.List items = new ArrayList();
-
-
- if (xsdSchema != null)
- {
- Iterator iter = xsdSchema.getIdentityConstraintDefinitions().iterator();
- String name = element.getAttribute(XSDConstants.NAME_ATTRIBUTE);
- while (iter.hasNext())
- {
- XSDIdentityConstraintDefinition constraint = (XSDIdentityConstraintDefinition)iter.next();
- if (name != null && !name.equals(""))
- {
- if (constraint.getName() != null)
- {
- if (!name.equals(constraint.getQName(xsdSchema)))
- {
- items.add(constraint.getQName(xsdSchema));
- }
- }
- }
- else
- {
- if (constraint.getName() != null)
- {
- items.add(constraint.getQName(xsdSchema));
- }
- }
- }
- }
-
- int size = items.size() + 1;
- refComboValues = new String[size];
- refComboValues[0] = "";
- if (items != null)
- {
- for (int i = 0; i < items.size(); i++)
- {
- refComboValues[i + 1] = (String) items.get(i);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-// This property is moved to the General Tab
-// PropertyDescriptor nameDescriptor =
-// new TextPropertyDescriptor(
-// XSDConstants.NAME_ATTRIBUTE,
-// XSDConstants.NAME_ATTRIBUTE);
-// list.add(nameDescriptor);
-
- XSDComboBoxPropertyDescriptor refDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.REFER_ATTRIBUTE,
- XSDConstants.REFER_ATTRIBUTE,
- refComboValues);
- list.add(refDescriptor);
-
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
-
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "";
- }
- return result;
-// if (((String) id).equals(XSDConstants.REFER_ATTRIBUTE))
-// {
-// return result;
-// }
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (((String) id).equals(XSDConstants.NAME_ATTRIBUTE))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_KEYREF_NAME_CHANGE"), element);
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- endRecording(element);
- }
- }
- else if (((String) id).equals(XSDConstants.REFER_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_KEYREF_REFER_CHANGE"), element);
- element.setAttribute((String) id, newValue);
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ModelGroupPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ModelGroupPropertySource.java
deleted file mode 100644
index 228860c1a8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ModelGroupPropertySource.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-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.NodeList;
-
-
-public class ModelGroupPropertySource // all or sequence or choice
- extends BasePropertySource
- implements IPropertySource
-{
- private String[] modelGroupComboValues = { "sequence", "choice", "all" };
- /**
- *
- */
- public ModelGroupPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public ModelGroupPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public ModelGroupPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
-
- XSDComboBoxPropertyDescriptor modelGroupDescriptor =
- new XSDComboBoxPropertyDescriptor(
- "model group",
- "model group",
- modelGroupComboValues);
- list.add(modelGroupDescriptor);
-
- PropertyDescriptor minOccursDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.MINOCCURS_ATTRIBUTE,
- XSDConstants.MINOCCURS_ATTRIBUTE);
- list.add(minOccursDescriptor);
- PropertyDescriptor maxOccursDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.MAXOCCURS_ATTRIBUTE,
- XSDConstants.MAXOCCURS_ATTRIBUTE);
- list.add(maxOccursDescriptor);
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- String attributeName = (String)id;
- if (result == null)
- {
- result = "";
- }
- if (attributeName.equals("model group"))
- {
- result = element.getLocalName();
- return result;
- }
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- String property = (String)id;
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (property.equals("model group"))
- {
- Element parent = (Element)element.getParentNode();
- String prefix = element.getPrefix();
- prefix = prefix == null ? "" : prefix + ":";
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_SCOPE_CHANGE"), parent);
- changeContentModel(parent, newValue);
- endRecording(parent);
- XSDDOMHelper domHelper = new XSDDOMHelper();
- setInput(domHelper.getContentModelFromParent(parent));
- }
- else if (property.equals(XSDConstants.MAXOCCURS_ATTRIBUTE))
- {
- String max = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MAXOCCURS_CHANGE"), element);
- if (max.length() > 0)
- {
- element.setAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE, max);
- }
- else
- {
- element.removeAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
- }
- endRecording(element);
- }
- else if (((String) id).equals(XSDConstants.MINOCCURS_ATTRIBUTE))
- {
- String min = (String)value;
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MINOCCURS_CHANGE"), element);
- if (min.length() > 0)
- {
- element.setAttribute(XSDConstants.MINOCCURS_ATTRIBUTE, min);
- }
- else
- {
- element.removeAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
-
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- public void setInput(Element element)
- {
- super.setInput(element);
-
- if (element != null)
- {
- boolean parentIsSequence = false;
- boolean parentIsChoice = false;
-
- Object parent = element.getParentNode();
-
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SEQUENCE_ELEMENT_TAG, false))
- {
- parentIsSequence = true;
- }
- else if (XSDDOMHelper.inputEquals(parent, XSDConstants.CHOICE_ELEMENT_TAG, false))
- {
- parentIsChoice = true;
- }
-
- if (parentIsChoice || parentIsSequence)
- {
- modelGroupComboValues = new String[2];
- modelGroupComboValues[0] = XSDConstants.SEQUENCE_ELEMENT_TAG;
- modelGroupComboValues[1] = XSDConstants.CHOICE_ELEMENT_TAG;
- }
- else
- {
- modelGroupComboValues = new String[3];
- modelGroupComboValues[0] = XSDConstants.SEQUENCE_ELEMENT_TAG;
- modelGroupComboValues[1] = XSDConstants.CHOICE_ELEMENT_TAG;
- modelGroupComboValues[2] = XSDConstants.ALL_ELEMENT_TAG;
- }
- }
- }
-
- private void changeContentModel(Element parent, String contentModel)
- {
- Document doc = parent.getOwnerDocument();
- XSDDOMHelper domHelper = new XSDDOMHelper();
-
- String prefix = parent.getPrefix();
- prefix = prefix == null ? "" : prefix + ":";
-
- Element contentModelElement = domHelper.getContentModelFromParent(parent);
-
- if (contentModelElement.getLocalName().equals(contentModel))
- {
- return; // it's already the content model
- }
-
- Element newNode = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + contentModel);
-
- if (contentModelElement.hasChildNodes())
- {
- NodeList nodes = contentModelElement.getChildNodes();
- // use clones so we don't have a refresh problem
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- newNode.appendChild(node.cloneNode(true));
- }
- }
- parent.replaceChild(newNode, contentModelElement);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NamePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NamePropertySource.java
deleted file mode 100644
index bbfb786416..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NamePropertySource.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalAttributeGroupRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalGroupRenamer;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class NamePropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public NamePropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public NamePropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public NamePropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
-
-// From attribute group
-// WorkbenchHelp.setHelp(client, XSDEditorContextIds.XSDE_ATTRIBUTE_GROUP_DESIGN_VIEW);
-// WorkbenchHelp.setHelp(nameField, XSDEditorContextIds.XSDE_ATTRIBUTE_GROUP_NAME);
-
-// From unique
-// WorkbenchHelp.setHelp(nameField, XSDEditorContextIds.XSDE_UNIQUE_BASE_NAME);
-
-// From key
-// WorkbenchHelp.setHelp(nameField, XSDEditorContextIds.XSDE_UNIQUE_BASE_NAME);
-
-// From group
-// WorkbenchHelp.setHelp(controlsContainer, XSDEditorContextIds.XSDE_GROUP_DESIGN_VIEW);
-// WorkbenchHelp.setHelp(nameField, XSDEditorContextIds.XSDE_GROUP_NAME);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- PropertyDescriptor nameDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.NAME_ATTRIBUTE,
- XSDConstants.NAME_ATTRIBUTE);
- list.add(nameDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTEGROUP_NAME_CHANGE"), element);
-
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDAttributeGroupDefinition && comp.getContainer().equals(xsdSchema))
- {
- GlobalAttributeGroupRenamer renamer = new GlobalAttributeGroupRenamer((XSDNamedComponent)comp, (String)value);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, (String)value);
- endRecording(element);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.UNIQUE_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_UNIQUE_NAME_CHANGE"), element);
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, "");
- }
- endRecording(element);
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.KEY_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_KEY_NAME_CHANGE"), element);
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, "");
- }
- endRecording(element);
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.GROUP_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_NAME_CHANGE"), element);
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDModelGroupDefinition && comp.getContainer().equals(xsdSchema))
- {
- GlobalGroupRenamer renamer = new GlobalGroupRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- endRecording(element);
- }
-
- }
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NotationPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NotationPropertySource.java
deleted file mode 100644
index 573d83dd32..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/NotationPropertySource.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-public class NotationPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public NotationPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public NotationPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public NotationPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-// Removed for tabbed properties
-// PropertyDescriptor nameDescriptor =
-// new TextPropertyDescriptor(
-// XSDConstants.NAME_ATTRIBUTE,
-// XSDConstants.NAME_ATTRIBUTE);
-// list.add(nameDescriptor);
-
- PropertyDescriptor publicDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.PUBLIC_ATTRIBUTE,
- XSDConstants.PUBLIC_ATTRIBUTE);
- list.add(publicDescriptor);
-
- PropertyDescriptor systemDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.SYSTEM_ATTRIBUTE,
- XSDConstants.SYSTEM_ATTRIBUTE);
- list.add(systemDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (((String)id).equals(XSDConstants.NAME_ATTRIBUTE))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_NOTATION_NAME_CHANGE"), element);
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, "");
- }
- endRecording(element);
- }
- }
- else if (((String)id).equals(XSDConstants.PUBLIC_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_NOTATION_PUBLIC_CHANGE"), element);
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.PUBLIC_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.PUBLIC_ATTRIBUTE, "");
- }
- endRecording(element);
- }
- else if (((String)id).equals(XSDConstants.SYSTEM_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_NOTATION_SYSTEM_CHANGE"), element);
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.SYSTEM_ATTRIBUTE, newValue);
- }
- else
- {
- element.removeAttribute(XSDConstants.SYSTEM_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/OptionsTextCellEditor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/OptionsTextCellEditor.java
deleted file mode 100644
index d61142eafc..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/OptionsTextCellEditor.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-
-
-public abstract class OptionsTextCellEditor extends CellEditor implements SelectionListener, KeyListener
-{
- private Composite fEditor;
- protected Text fText;
- protected boolean isTextReadOnly;
- Button moreButton;
- Shell dialog;
-
- protected Object fValue;
- int selection;
- Object typeObject;
-
- private class ComboCellLayout extends Layout
- {
- public void layout(Composite editor, boolean force)
- {
- Rectangle bounds= editor.getClientArea();
- Point size= moreButton.computeSize(SWT.DEFAULT, bounds.height, force);
- fText.setBounds(0, 0, bounds.width - size.x, bounds.height);
- moreButton.setBounds(bounds.width - size.x, 0, size.x, size.y);
- }
-
- public Point computeSize(Composite editor, int wHint, int hHint, boolean force)
- {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- {
- return new Point(wHint, hHint);
- }
- Point size= fText.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
-// size.x += moreButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, force).x;
- return size;
- }
- }
-
-/**
- * Creates a new combo box cell editor with the given choices.
- */
- public OptionsTextCellEditor(Composite parent)
- {
- super(parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellEditor#createControl(org.eclipse.swt.widgets.Composite)
- */
- protected Control createControl(Composite parent)
- {
- fEditor = ViewUtility.createComposite(parent, 2);
- fEditor.setLayout(new ComboCellLayout());
-
- if (isTextReadOnly)
- {
- fText = new Text(fEditor, SWT.LEFT | SWT.READ_ONLY);
- }
- else
- {
- fText = new Text(fEditor, SWT.LEFT);
- }
-// fText.setEnabled(false);
-
- fText.setBackground(parent.getBackground());
- fText.setText("");
- fText.addKeyListener(this);
- fText.addFocusListener(new FocusAdapter()
- {
- public void focusLost(FocusEvent e)
- {
- if (!moreButton.isFocusControl())
- {
- OptionsTextCellEditor.this.focusLost();
- }
- }
- });
-
- moreButton = ViewUtility.createPushButton(fEditor, "...");
- moreButton.addSelectionListener(new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent e)
- {
- // System.out.println("More Button Clicked");
- openDialog();
- }
- });
- moreButton.addKeyListener(this);
- moreButton.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent e) {
- if (!fText.isFocusControl() && (dialog==null ||
- dialog.isDisposed() ||
- (dialog!=null && !dialog.isFocusControl())))
- {
- // System.out.println("MoreButton focusLost");
- OptionsTextCellEditor.this.focusLost();
- }
- }
- });
-
-
- setValueValid(true);
-
- return fEditor;
- }
-
- public void activate()
- {
- // System.out.println("Cell editor activated");
- fText.setText(fValue == null ? "" : fValue.toString());
- }
-
- protected void focusLost() {
- // System.out.println("CELLEDITOR FOCUS LOST");
- if (isActivated()) {
- applyEditorValueAndDeactivate();
- }
- }
-
- void applyEditorValueAndDeactivate() {
- // must set the selection before getting value
-// if (dialog != null && !dialog.isDisposed())
-// {
-// dialog.close();
-// dialog.dispose();
-// }
- fireApplyEditorValue();
- deactivate();
- }
-
- public void keyPressed(KeyEvent e)
- {
- if (e.character == SWT.ESC)
- { // Escape character
- fireCancelEditor();
- }
- else if ((e.character == SWT.CR) || (e.character == SWT.LF))
- { // Return key
- applyEditorValueAndDeactivate();
- }
- }
-
- public void keyReleased(KeyEvent e)
- {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellEditor#doGetValue()
- * Returns the cell editor's value.
- */
- protected Object doGetValue()
- {
- return fValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellEditor#doSetFocus()
- * Set the focus to the cell editor's UI representation.
- */
- protected void doSetFocus()
- {
-// fButton.setFocus();
-// System.out.println("doSetFocus() " + moreButton.setFocus());
- fText.setFocus();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellEditor#doSetValue(java.lang.Object)
- * Sets the value of the cell editor to the given value.
- */
- protected void doSetValue(Object value)
- {
- fValue = value;
- }
-
- protected Point getButtonAbsoluteLocation()
- {
- Rectangle buttonBounds = moreButton.getBounds();
- int x = buttonBounds.x;
- int y = buttonBounds.y;
- Control c = moreButton;
- while (c != null)
- {
- c = c.getParent();
- if (c == null)
- break;
- x += c.getBounds().x;
- y += c.getBounds().y;
- }
- x += buttonBounds.width + 5;
- y += buttonBounds.height;
- Point p = new Point(x,y);
- return p;
- }
-
- protected void cancel()
- {
- dialog.close();
- dialog.dispose();
- }
-
- protected abstract void openDialog();
-
- public void widgetSelected(SelectionEvent e)
- {
- }
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/PatternPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/PatternPropertySource.java
deleted file mode 100644
index 38f166ab5d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/PatternPropertySource.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.wizards.RegexWizard;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-public class PatternPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public PatternPropertySource()
- {
- super();
-// expressionField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_PATTERN"));
-// WorkbenchHelp.setHelp(expressionField, XSDEditorContextIds.XSDE_PATTERN_VALUE);
-// WorkbenchHelp.setHelp(activateWizardButton, XSDEditorContextIds.XSDE_PATTERN_REGULAR);
-// activateWizardButton.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_BUTTON"));
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public PatternPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public PatternPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-
- PatternTextPropertyDescriptor patternDescriptor =
- new PatternTextPropertyDescriptor(
- XSDConstants.VALUE_ATTRIBUTE,
- XSDConstants.VALUE_ATTRIBUTE);
- list.add(patternDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.VALUE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PATTERN_VALUE_CHANGE"), element);
- element.setAttribute(XSDConstants.VALUE_ATTRIBUTE, (String)value);
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- public class PatternTextPropertyDescriptor extends PropertyDescriptor
- {
- /**
- * @param id
- * @param displayName
- */
- public PatternTextPropertyDescriptor(Object id, String displayName)
- {
- super(id, displayName);
- }
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- // CellEditor editor = new PatternTextCellEditor(parent);
- CellEditor editor = new PatternDialogCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
- }
-
- public class PatternDialogCellEditor extends DialogCellEditor {
-
- /**
- * Creates a new Font dialog cell editor parented under the given control.
- * The cell editor value is <code>null</code> initially, and has no
- * validator.
- *
- * @param parent the parent control
- */
- protected PatternDialogCellEditor(Composite parent) {
- super(parent);
- }
-
- /**
- * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control)
- */
- protected Object openDialogBox(Control cellEditorWindow)
- {
- String initialValue = element.getAttribute(XSDConstants.VALUE_ATTRIBUTE);
- if (initialValue == null)
- {
- initialValue = "";
- }
- RegexWizard wizard = new RegexWizard(initialValue);
- Shell shell = Display.getCurrent().getActiveShell();
- WizardDialog wizardDialog = new WizardDialog(shell, wizard);
- wizardDialog.create();
-
- String value = (String)getValue();
-
- int result = wizardDialog.open();
-
- if (result == Window.OK)
- {
- return wizard.getPattern();
- }
- return value;
- }
-
- }
-
-// class PatternTextCellEditor extends OptionsTextCellEditor
-// {
-// protected Button fixedButton, defaultButton;
-//
-// public PatternTextCellEditor(Composite parent)
-// {
-// super(parent);
-// }
-//
-// protected Control createControl(Composite parent)
-// {
-// isTextReadOnly = false;
-// return super.createControl(parent);
-// }
-//
-// protected void openDialog()
-// {
-// RegexWizard wizard = new RegexWizard(element.getAttribute(XSDConstants.VALUE_ATTRIBUTE));
-// Shell shell = Display.getCurrent().getActiveShell();
-// WizardDialog wizardDialog = new WizardDialog(shell, wizard);
-// wizardDialog.create();
-//
-// dialog = wizardDialog.getShell();
-// Display display = dialog.getDisplay();
-// dialog.addShellListener(new ShellAdapter()
-// {
-// public void shellDeactivated(ShellEvent e)
-// {
-// cancel();
-// }
-// });
-//
-// int result = wizardDialog.open();
-//
-// if (result == Window.OK)
-// {
-// fText.setText(wizard.getPattern());
-// applyEditorValueAndDeactivate();
-// }
-//
-// }
-//
-// protected void cancel()
-// {
-// super.cancel();
-// }
-//
-// void applyEditorValueAndDeactivate()
-// {
-// String value = fText.getText();
-// doSetValue(value);
-// fireApplyEditorValue();
-// deactivate();
-// }
-//
-// protected Object doGetValue()
-// {
-// fValue = fText.getText();
-// return fText.getText();
-// }
-//
-// }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ReadOnlyPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ReadOnlyPropertySource.java
deleted file mode 100644
index 0f5cb7f09b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/ReadOnlyPropertySource.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-public class ReadOnlyPropertySource implements IPropertySource
-{
- protected Element element;
-
- public ReadOnlyPropertySource(IEditorPart editPart, Element element)
- {
- this.element = element;
- }
-
- public Object getEditableValue()
- {
- return null;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- NamedNodeMap map = element.getAttributes();
- int mapLength = map.getLength();
- for (int i = 0; i < mapLength; i++)
- {
- Attr attr = (Attr) map.item(i);
- list.add(new PropertyDescriptor(attr.getName(), attr.getName()));
- }
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
-
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- }
- return result != null ? result : "";
- }
-
- public boolean isPropertySet(Object id)
- {
- return false;
- }
-
- public void resetPropertyValue(Object id)
- {
- }
-
- public void setPropertyValue(Object id, Object value)
- {
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaDirectiveHelperPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaDirectiveHelperPropertySource.java
deleted file mode 100644
index 43780f84ba..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaDirectiveHelperPropertySource.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.navigator.ResourceNavigator;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-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.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.wizards.XSDSelectIncludeFileWizard;
-import org.eclipse.xsd.XSDSchema;
-
-public abstract class SchemaDirectiveHelperPropertySource
- extends BasePropertySource
-{
- protected IFile currentIFile;
-
- IFile selectedIFile;
- String selectedNamespace;
- XSDSchema selectedXSDSchema;
- boolean isInclude;
- /**
- *
- */
- public SchemaDirectiveHelperPropertySource(boolean isInclude)
- {
- super();
- this.isInclude = isInclude;
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SchemaDirectiveHelperPropertySource(
- Viewer viewer,
- XSDSchema xsdSchema,
- boolean isInclude)
- {
- super(viewer, xsdSchema);
- this.isInclude = isInclude;
- }
- /**
- * @param xsdSchema
- */
- public SchemaDirectiveHelperPropertySource(XSDSchema xsdSchema, boolean isInclude)
- {
- super(xsdSchema);
- this.isInclude = isInclude;
- }
-
-
- public class SchemaLocationPropertyDescriptor extends PropertyDescriptor
- {
- /**
- * @param id
- * @param displayName
- */
- public SchemaLocationPropertyDescriptor(Object id, String displayName)
- {
- super(id, displayName);
- }
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- CellEditor editor = new SchemaLocationDialogCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
- }
-
- public class SchemaLocationDialogCellEditor extends DialogCellEditor {
-
- /**
- * Creates a new Font dialog cell editor parented under the given control.
- * The cell editor value is <code>null</code> initially, and has no
- * validator.
- *
- * @param parent the parent control
- */
- protected SchemaLocationDialogCellEditor(Composite parent) {
- super(parent);
- }
-
- /**
- * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control)
- */
- protected Object openDialogBox(Control cellEditorWindow)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
-// oldSchemaLocation = locationField.getText().trim();
-// IFile currentIFile = ((IFileEditorInput)getIEditorPart().getEditorInput()).getFile();
- ViewerFilter filter = new ResourceFilter(new String[] { ".xsd" },
- new IFile[] { currentIFile },
- null);
-//
-
- IViewPart viewParts[] = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViews();
- ResourceNavigator resourceNav = null;
- for (int i = 0; i < viewParts.length; i++)
- {
- if (viewParts[i] instanceof ResourceNavigator)
- {
- resourceNav = (ResourceNavigator) viewParts[i];
- break;
- }
- }
- IStructuredSelection selection = StructuredSelection.EMPTY;
- if (resourceNav != null)
- {
- selection = (IStructuredSelection)resourceNav.getViewSite().getSelectionProvider().getSelection();
- }
-
- XSDSelectIncludeFileWizard fileSelectWizard =
- new XSDSelectIncludeFileWizard(xsdSchema, isInclude,
- XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_SCHEMA"),
- XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_DESC"),
- filter,
- selection);
-
- WizardDialog wizardDialog = new WizardDialog(shell, fileSelectWizard);
- wizardDialog.create();
- wizardDialog.setBlockOnOpen(true);
- int result = wizardDialog.open();
-
-
- String value = (String)getValue();
- // System.out.println("VALUE IS *** = " + value);
- if (result == Window.OK)
- {
- selectedIFile = fileSelectWizard.getResultFile();
- String schemaFileString = value;
- if (selectedIFile != null)
- {
- schemaFileString = URIHelper.getRelativeURI(selectedIFile.getLocation(), currentIFile.getLocation());
- }
- else
- {
- schemaFileString = fileSelectWizard.getURL();
- }
-
-// updateExternalModel(selectedIFile, fileSelectWizard.getNamespace(), fileSelectWizard.getExternalSchema());
- selectedNamespace = fileSelectWizard.getNamespace();
- selectedXSDSchema = fileSelectWizard.getExternalSchema();
-
- return schemaFileString;
- }
- return value;
- }
- }
-
- public IFile getSelectedIFile()
- {
- return selectedIFile;
- }
-
- public String getSelectedNamespace()
- {
- return selectedNamespace;
- }
-
- public XSDSchema getSelectedXSDSchema()
- {
- return selectedXSDSchema;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaPropertySource.java
deleted file mode 100644
index 2d8b4022c5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SchemaPropertySource.java
+++ /dev/null
@@ -1,520 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.TargetNamespaceChangeHandler;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaHelper;
-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 SchemaPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String oldPrefix = "";
- private String oldNamespace = "";
-
- private String[] attributeFormDefaultComboValues =
- {
- "",
- XSDEditorPlugin.getXSDString("_UI_COMBO_UNQUALIFIED"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_QUALIFIED")
- };
-
- private String[] elementFormDefaultComboValues =
- {
- "",
- XSDEditorPlugin.getXSDString("_UI_COMBO_UNQUALIFIED"),
- XSDEditorPlugin.getXSDString("_UI_COMBO_QUALIFIED")
- };
-
- private String[] blockDefaultComboValues =
- {
- "",
- "#all",
- "extension",
- "restriction",
- "substitution"
- };
-
- private String[] finalDefaultComboValues =
- {
- "",
- "#all",
- "extension",
- "restriction"
- };
-
- /**
- *
- */
- public SchemaPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SchemaPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public SchemaPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-// These have been moved to the General tab
-// PropertyDescriptor prefixDescriptor =
-// new TextPropertyDescriptor(
-// "prefix",
-// "prefix");
-// list.add(prefixDescriptor);
-// prefixDescriptor.setCategory("Namespace");
-//
-// PropertyDescriptor targetNamespaceDescriptor =
-// new TextPropertyDescriptor(
-// XSDConstants.TARGETNAMESPACE_ATTRIBUTE,
-// XSDConstants.TARGETNAMESPACE_ATTRIBUTE);
-// list.add(targetNamespaceDescriptor);
-// targetNamespaceDescriptor.setCategory("Namespace");
-
- PropertyDescriptor versionDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.VERSION_ATTRIBUTE,
- XSDConstants.VERSION_ATTRIBUTE);
-// versionDescriptor.setDescription("Version attribute"); // XSDEditorPlugin.getXSDString("_UI_TOOLTIP_VERSION"));
- list.add(versionDescriptor);
- PropertyDescriptor xmlLangDescriptor =
- new TextPropertyDescriptor(
- "xml:lang",
- "xml:lang");
- list.add(xmlLangDescriptor);
-
- XSDComboBoxPropertyDescriptor attributeFormDefaultDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE,
- XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE,
- attributeFormDefaultComboValues);
- list.add(attributeFormDefaultDescriptor);
-
-
- XSDComboBoxPropertyDescriptor elementFormDefaultDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE,
- XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE,
- elementFormDefaultComboValues);
- list.add(elementFormDefaultDescriptor);
-
- XSDComboBoxPropertyDescriptor blockDefaultDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.BLOCKDEFAULT_ATTRIBUTE,
- XSDConstants.BLOCKDEFAULT_ATTRIBUTE,
- blockDefaultComboValues);
- list.add(blockDefaultDescriptor);
- XSDComboBoxPropertyDescriptor finalDefaultDescriptor =
- new XSDComboBoxPropertyDescriptor(
- XSDConstants.FINALDEFAULT_ATTRIBUTE,
- XSDConstants.FINALDEFAULT_ATTRIBUTE,
- finalDefaultComboValues);
- list.add(finalDefaultDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- // return propertyDescriptors;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- String attributeName = (String)id;
- if (result == null)
- {
- result = "";
- }
-
- if (attributeName.equals("prefix"))
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- String aPrefix = helper.getPrefix(element.getAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE), false);
- // System.out.println("schema targetNS is " + xsdSchema.getTargetNamespace());
- if (aPrefix != null && aPrefix.length() > 0)
- {
- return aPrefix;
- }
- return "";
- }
- else
- {
- return result;
- }
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String newValue = (String)value;
- String attributeName = (String)id;
- if (attributeName.equals("prefix"))
- {
- updatePrefix(newValue);
- }
- else if (attributeName.equals(XSDConstants.TARGETNAMESPACE_ATTRIBUTE))
- {
- updateTargetNamespace(newValue);
- }
- else if (attributeName.equals("xml:lang"))
- {
- validateLanguage(newValue);
- // return; // we will accept the value even though it does not conform
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SCHEMA_LANG_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.VERSION_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SCHEMA_VERSION_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.ATTRIBUTEFORMDEFAULT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SCHEMA_ATTRIBUTEFORMDEFAULT_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.ELEMENTFORMDEFAULT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SCHEMA_ELEMENTFORMDEFAULT_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.BLOCKDEFAULT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SCHEMA_BLOCKDEFAULT_CHANGE"), element);
- }
- else if (attributeName.equals(XSDConstants.FINALDEFAULT_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SCHEMA_FINALDEFAULT_CHANGE"), element);
- }
-
- if (!attributeName.equals("prefix") && !attributeName.equals(XSDConstants.TARGETNAMESPACE_ATTRIBUTE))
- {
- if (newValue.equals(""))
- {
- element.removeAttribute(attributeName);
- }
- else
- {
- element.setAttribute(attributeName, newValue);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- public void setInput(Element element)
- {
- super.setInput(element);
-
- oldNamespace = "";
- oldPrefix = "";
-
- if (element!= null)
- {
- String targetNamespace = element.getAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE);
- oldNamespace = targetNamespace;
-
- TypesHelper helper = new TypesHelper(xsdSchema);
- String aPrefix = helper.getPrefix(targetNamespace, false);
- if (aPrefix != null && aPrefix.length() > 0)
- {
- oldPrefix = aPrefix;
- }
- }
- }
-
-
- private void updatePrefix(String newPrefix)
- {
- updateNamespaceInfo(newPrefix, oldNamespace);
- }
-
- private void updateTargetNamespace(String newTargetNamespace)
- {
- updateNamespaceInfo(oldPrefix, newTargetNamespace);
- }
-
- private void updateNamespaceInfo(String newPrefix, String newTargetNamespace)
- {
-// System.out.println("\nold Prefix is " + oldPrefix);
-// System.out.println("old NS is " + oldNamespace);
-// System.out.println("new Prefix is " + newPrefix);
-// System.out.println("new NS is " + newTargetNamespace);
-
- DocumentImpl doc = (DocumentImpl)element.getOwnerDocument();
-
- String modelTargetNamespace = xsdSchema.getTargetNamespace();
-// System.out.println("Model TargetNS is " + modelTargetNamespace);
- if (modelTargetNamespace == null)
- {
- modelTargetNamespace = "";
- }
-
- 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_LABEL_TARGETNAMESPACE_CHANGE"));
- String xsdForXSDPrefix = xsdSchema.getSchemaForSchemaQNamePrefix();
- Map map = xsdSchema.getQNamePrefixToNamespaceMap();
-
-// For debugging
-// System.out.println("1. SW Map is " + map.values());
-// System.out.println("1. SW Map keys are " + map.keySet());
-
- // 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);
-
- updateAllNodes(element, xsdForXSDPrefix);
-
- // remove the old xmlns attribute for the schema for schema
- if (element.getAttribute("xmlns") != null &&
- element.getAttribute("xmlns").equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- element.removeAttribute("xmlns");
- }
- }
- }
-
- 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);
-// element.setAttribute("xmlns:" + prefix, targetNamespace);
-// java.util.Map prefixToNameSpaceMap = xsdSchema.getQNamePrefixToNamespaceMap();
-// prefixToNameSpaceMap.remove(oldPrefix);
- }
- else // if no prefix
- {
- if (element.getAttribute("xmlns") != null)
- {
- if (!element.getAttribute("xmlns").equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- element.removeAttribute("xmlns");
- }
- }
- }
- }
-
- 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);
- }
- else
- {
- element.setAttribute("xmlns", targetNamespace);
- }
- // set the targetNamespace attribute
- }
- else // else targetNamespace is blank
- {
- if (prefix.length() == 0)
- {
- element.removeAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE);
- }
- }
-
-// System.out.println("1.5 SW Map is " + map.values());
-// System.out.println("1.5 SW Map keys are " + map.keySet());
-
- // do our own referential integrity
- TargetNamespaceChangeHandler targetNamespaceChangeHandler = new TargetNamespaceChangeHandler(xsdSchema, oldNamespace, targetNamespace);
- targetNamespaceChangeHandler.resolve();
-
- oldPrefix = prefix;
- oldNamespace = targetNamespace;
-
- XSDSchemaHelper.updateElement(xsdSchema);
-
- doc.getModel().endRecording(this);
-
-// For debugging
- map = xsdSchema.getQNamePrefixToNamespaceMap();
-// System.out.println("2. SW Map is " + map.values());
-// System.out.println("2. SW Map keys are " + map.keySet());
- }
-
-
- private String getUniqueSchemaForSchemaPrefix(String xsdForXSDPrefix, Map map)
- {
- if (xsdForXSDPrefix == null || (xsdForXSDPrefix != null && xsdForXSDPrefix.trim().length() == 0))
- {
- xsdForXSDPrefix = "xsd";
- }
- // 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);
- }
- }
- }
- }
- }
-
- protected boolean validateTargetNamespace(String ns)
- {
- // will allow blank namespace !!
- if (ns.equals(""))
- {
- return true;
- }
-
- String errorMessage = null;
- try
- {
- URI testURI = new URI(ns);
- testURI.isAbsolute();
- }
- catch (URISyntaxException e)
- {
- errorMessage = XSDEditorPlugin.getXSDString("_WARN_INVALID_TARGET_NAMESPACE");
- }
-
- if (errorMessage == null || errorMessage.length() == 0)
- {
- return true;
- }
- return false;
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertyDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertyDescriptor.java
deleted file mode 100644
index 1948146370..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertyDescriptor.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xsd.ui.internal.properties.section.SimpleContentBaseTypeOptionsDialog;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-
-public class SimpleContentPropertyDescriptor extends TypesPropertyDescriptor
-{
- public SimpleContentPropertyDescriptor(Object id, String displayName, Element element, XSDSchema xsdSchema)
- {
- super(id, displayName, element, xsdSchema);
- }
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- // CellEditor editor = new SimpleContentBaseTypeOptionsTextCellEditor(parent);
- CellEditor editor = new SimpleContentBaseTypeDialogCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
-
- public class SimpleContentBaseTypeDialogCellEditor extends TypesDialogCellEditor
- {
-
- /**
- * Creates a new Font dialog cell editor parented under the given control.
- * The cell editor value is <code>null</code> initially, and has no
- * validator.
- *
- * @param parent the parent control
- */
- protected SimpleContentBaseTypeDialogCellEditor(Composite parent)
- {
- super(parent);
- }
-
- protected Object openDialogBox(Control cellEditorWindow)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- // SimpleContentBaseTypeOptionsDialog dialog = new SimpleContentBaseTypeOptionsDialog(shell);
- SimpleContentBaseTypeOptionsDialog dialog = new SimpleContentBaseTypeOptionsDialog(shell, element, property, xsdSchema);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- String value = (String)getValue();
-
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- value = dialog.getType();
- return value;
- }
- deactivate();
- return value;
- }
- }
-
-// class SimpleContentBaseTypeOptionsDialog extends TypesDialog
-// {
-// public SimpleContentBaseTypeOptionsDialog(Shell shell)
-// {
-// super(shell);
-// showAnonymous = false;
-// }
-//
-//// protected void ok()
-//// {
-//// TableItem[] items = table.getItems();
-//// selection = table.getSelectionIndex();
-//// if (items != null && items.length > 0 && selection >= 0)
-//// {
-//// typeObject = items[selection].getData();
-//// }
-//// System.out.println("typeObject is " + typeObject);
-////
-//// doSetValue(typeObject);
-//// applyEditorValueAndDeactivate();
-//// dialog.close();
-//// }
-//
-// public void handleSetInput()
-// {
-// XSDDOMHelper domHelper = new XSDDOMHelper();
-// typeSection.getSimpleType().setSelection(false);
-// typeSection.getUserSimpleType().setSelection(false);
-// typeSection.getUserComplexType().setSelection(false);
-// showAnonymous = false;
-// if (element != null)
-// {
-// String derivedBy = domHelper.getDerivedByName(element);
-// String baseType = domHelper.getBaseType(element);
-// boolean derivedByRestriction = true;
-//
-// if (XSDDOMHelper.inputEquals(element, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
-// {
-// typeSection.getSimpleType().setEnabled(false);
-// typeSection.getUserSimpleType().setEnabled(false);
-// typeSection.getUserComplexType().setSelection(true);
-//
-// previousType = 3;
-// }
-// else if (XSDDOMHelper.inputEquals(element, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
-// {
-// typeSection.getSimpleType().setEnabled(false);
-// typeSection.getUserSimpleType().setEnabled(false);
-//
-// if (derivedBy.equals("restriction"))
-// {
-// typeSection.getSimpleType().setEnabled(false);
-// typeSection.getUserSimpleType().setEnabled(false);
-// typeSection.getUserComplexType().setEnabled(true);
-// }
-// else if (derivedBy.equals("extension"))
-// {
-// derivedByRestriction = false;
-// typeSection.getSimpleType().setEnabled(true);
-// typeSection.getUserSimpleType().setEnabled(true);
-// typeSection.getUserComplexType().setEnabled(true);
-// }
-// }
-//
-// if (derivedBy != null)
-// {
-// if (baseType != null && !baseType.equals(""))
-// {
-// Element parent = (Element)element.getParentNode();
-// XSDConcreteComponent component = null;
-// if (parent != null)
-// {
-// component = xsdSchema.getCorrespondingComponent(parent);
-// }
-// XSDTypeDefinition baseTypeDefinition = null;
-// if (component instanceof XSDComplexTypeDefinition)
-// {
-// XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)component;
-// baseTypeDefinition = complexType.getBaseTypeDefinition();
-// }
-//
-// if (typeSection.getBuiltInTypeNamesList(xsdSchema).contains(baseType) && !derivedByRestriction)
-// {
-// typeSection.getSimpleType().setSelection(true);
-// populateBuiltInType();
-// int i = typeSection.getBuiltInTypeNamesList(xsdSchema).indexOf(baseType);
-// table.setSelection(i);
-// previousType = 1;
-// }
-// else if (baseTypeDefinition instanceof XSDSimpleTypeDefinition && !derivedByRestriction)
-// {
-// typeSection.getUserSimpleType().setSelection(true);
-// populateUserSimpleType();
-// int i = typeSection.getUserSimpleTypeNamesList(xsdSchema).indexOf(baseType);
-// if (showAnonymous)
-// {
-// table.setSelection(i + 1);
-// }
-// else
-// {
-// table.setSelection(i);
-// }
-// previousType = 2;
-// }
-// else if (baseTypeDefinition instanceof XSDComplexTypeDefinition)
-// {
-// typeSection.getUserComplexType().setSelection(true);
-// populateUserComplexType();
-// int i = typeSection.getUserComplexTypeNamesList(xsdSchema).indexOf(baseType);
-// if (showAnonymous)
-// {
-// table.setSelection(i + 1);
-// }
-// else
-// {
-// table.setSelection(i);
-// }
-// previousType = 3;
-// }
-// }
-// else
-// {
-// typeSection.getUserComplexType().setSelection(true);
-// populateUserComplexType();
-// table.setSelection(0);
-// }
-// }
-//
-// }
-// }
-// }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertySource.java
deleted file mode 100644
index 6b33262083..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleContentPropertySource.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class SimpleContentPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String DERIVED_BY_ID = "derived by"; // XSDEditorPlugin.getXSDString("_UI_LABEL_DERIVED_BY"); //$NON-NLS-1$
- private String BASE_TYPE_ID = "base"; // XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE"); //$NON-NLS-1$
-
- private String derivedByChoicesComboValues[] =
- {
- "", //$NON-NLS-1$
- XSDConstants.RESTRICTION_ELEMENT_TAG,
- XSDConstants.EXTENSION_ELEMENT_TAG
- };
-
- /**
- *
- */
- public SimpleContentPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SimpleContentPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public SimpleContentPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-
- SimpleContentPropertyDescriptor typeDescriptor = new SimpleContentPropertyDescriptor(
- BASE_TYPE_ID,
- BASE_TYPE_ID,
- element, xsdSchema);
- list.add(typeDescriptor);
- XSDComboBoxPropertyDescriptor derivedByDescriptor =
- new XSDComboBoxPropertyDescriptor(
- DERIVED_BY_ID,
- DERIVED_BY_ID,
- derivedByChoicesComboValues);
- list.add(derivedByDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- if (id instanceof String)
- {
- if (((String) id).equals(DERIVED_BY_ID))
- {
- String derivedBy = getDomHelper().getDerivedByName(element);
- if (derivedBy == null)
- {
- derivedBy = ""; //$NON-NLS-1$
- }
- return derivedBy;
- }
- else if (((String) id).equals(BASE_TYPE_ID))
- {
- String baseType = getDomHelper().getBaseType(element);
- if (baseType == null)
- {
- baseType = ""; //$NON-NLS-1$
- }
- return baseType;
- }
- }
- return ""; //$NON-NLS-1$
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- String origBaseType = getDomHelper().getBaseType(element);
- String derivedBy = getDomHelper().getDerivedByName(element);
-
- if (((String) id).equals(BASE_TYPE_ID))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), element); //$NON-NLS-1$
- getDomHelper().setDerivedByBaseType(element, derivedBy, (String)value);
- endRecording(element);
- }
- else if (((String) id).equals(DERIVED_BY_ID))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DERIVEDBY_CHANGE"), element); //$NON-NLS-1$
- String newDerivedBy = (String)value;
- if (newDerivedBy.equals(XSDConstants.RESTRICTION_ELEMENT_TAG))
- {
- String prefix = element.getPrefix();
- String anyType = prefix == null? "anyType" : prefix + ":anyType"; //$NON-NLS-1$ $NON-NLS-2$
- getDomHelper().changeDerivedByType(element, (String)value, anyType);
- }
- else
- {
- Element derivedByElem = getDomHelper().getDerivedByElement(element);
- if (checkForAnonymousType(derivedByElem))
- {
-// KCPort
-// ArrayList message = new ArrayList();
-// ErrorMessage aTask = new ErrorMessage();
-// Node aNode = getDomHelper().getChildNode(derivedByElem, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
-////////////// shall we remove the node and its children??
-//// getDomHelper().removeNodeAndWhitespace(aNode);
-//////////////
-//// if (aNode instanceof Element)
-//// {
-//// Element st = (Element)aNode;
-//// if (st instanceof NodeImpl)
-//// {
-//// aTask.setNode((NodeImpl)st);
-//// }
-//// }
-// if (derivedByElem instanceof NodeImpl)
-// {
-// aTask.setModelObject(derivedByElem);
-// }
-// aTask.setLocalizedMessage(XSDEditorPlugin.getXSDString("_ERROR_REMOVE_LOCAL_SIMPLETYPE"));
-// message.add(aTask);
-// if (getEditor() != null)
-// {
-// getEditor().createTasksInTaskList(message);
-// }
- }
- getDomHelper().changeDerivedByType(element, (String)value, origBaseType);
- }
-
-
- endRecording(element);
-// setInput(element);
- }
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
- }
-
- boolean checkForAnonymousType(Element element)
- {
- boolean isAnonymous = false;
-
- Node aNode = getDomHelper().getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- return isAnonymous;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleRestrictPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleRestrictPropertySource.java
deleted file mode 100644
index 4d07c0b9c0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleRestrictPropertySource.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDFacet;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.impl.XSDFactoryImpl;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class SimpleRestrictPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private String [] whiteSpaceComboChoices = { "", "preserve", "replace", "collapse" };
- /**
- *
- */
- public SimpleRestrictPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SimpleRestrictPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public SimpleRestrictPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
-
- SimpleContentPropertyDescriptor typeDescriptor = new SimpleContentPropertyDescriptor(
- XSDConstants.BASE_ATTRIBUTE,
- XSDConstants.BASE_ATTRIBUTE,
- (Element)element.getParentNode(), xsdSchema); // get the parent node!
- list.add(typeDescriptor);
-
- Iterator facets = xsdSimpleType.getValidFacets().iterator();
-
- while(facets.hasNext())
- {
- String aValidFacet = (String)facets.next();
- if (!(aValidFacet.equals(XSDConstants.PATTERN_ELEMENT_TAG) || aValidFacet.equals(XSDConstants.ENUMERATION_ELEMENT_TAG)))
- {
- if (aValidFacet.equals(XSDConstants.WHITESPACE_ELEMENT_TAG))
- {
- XSDComboBoxPropertyDescriptor whitespaceDescriptor = new XSDComboBoxPropertyDescriptor(
- aValidFacet, aValidFacet, whiteSpaceComboChoices);
- list.add(whitespaceDescriptor);
- }
- else
- {
- list.add(new TextPropertyDescriptor(aValidFacet, aValidFacet));
- }
- }
- }
-
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- if (((String) id).equals(XSDConstants.BASE_ATTRIBUTE))
- {
- String baseType = element.getAttribute(XSDConstants.BASE_ATTRIBUTE);
- if (baseType == null)
- {
- baseType = "";
- }
- return baseType;
- }
- else
- {
- String aFacet = (String)id;
- Iterator facets = xsdSimpleType.getFacets().iterator();
-
- while(facets.hasNext())
- {
- XSDFacet aValidFacet = (XSDFacet)facets.next();
- if (aValidFacet.getFacetName().equals(aFacet))
- {
- result = aValidFacet.getLexicalValue();
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- }
- }
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- String newValue = (String)value;
-
- if (((String) id).equals(XSDConstants.BASE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), element);
-
- Element parent = (Element)element.getParentNode();
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
-// updateElementToNotAnonymous(element);
- }
- getDomHelper().setSimpleContentType(element, newValue);
- endRecording(element);
- }
- else
- {
- Element simpleTypeElement = xsdSimpleType.getElement();
- XSDDOMHelper xsdDOMHelper = new XSDDOMHelper();
- Element derivedByElement = xsdDOMHelper.getDerivedByElement(simpleTypeElement);
- beginRecording(XSDEditorPlugin.getXSDString("_UI_FACET_CHANGE"), simpleTypeElement);
- String prefix = simpleTypeElement.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
-
- String aFacet = (String)id;
- XSDFactoryImpl factory = new XSDFactoryImpl();
-
- Element childNodeElement = null;
- DOMAttribute valueAttr = null;
- XSDFacet facet = null;
- if (aFacet.equals(XSDConstants.TOTALDIGITS_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getTotalDigitsFacet();
- }
- else if (aFacet.equals(XSDConstants.FRACTIONDIGITS_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getFractionDigitsFacet();
- }
- else if (aFacet.equals(XSDConstants.WHITESPACE_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getWhiteSpaceFacet();
- }
- else if (aFacet.equals(XSDConstants.MAXEXCLUSIVE_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getMaxExclusiveFacet();
- }
- else if (aFacet.equals(XSDConstants.MAXINCLUSIVE_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getMaxInclusiveFacet();
- }
- else if (aFacet.equals(XSDConstants.MINEXCLUSIVE_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getMinExclusiveFacet();
- }
- else if (aFacet.equals(XSDConstants.MININCLUSIVE_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getMinInclusiveFacet();
- }
- else if (aFacet.equals(XSDConstants.LENGTH_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getLengthFacet();
- }
- else if (aFacet.equals(XSDConstants.MAXLENGTH_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getMaxLengthFacet();
- }
- else if (aFacet.equals(XSDConstants.MINLENGTH_ELEMENT_TAG))
- {
- facet = xsdSimpleType.getMinLengthFacet();
- }
-
- if (facet != null)
- {
- facet.setLexicalValue(newValue);
- }
- else
- {
- facet = (XSDFacet)factory.createXSDTotalDigitsFacet();
- childNodeElement = (derivedByElement.getOwnerDocument()).createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + aFacet);
- valueAttr = new DOMAttribute(XSDConstants.VALUE_ATTRIBUTE, "");
- childNodeElement.setAttribute(valueAttr.getName(), valueAttr.getValue());
- valueAttr.setValue(newValue);
- childNodeElement.setAttribute(valueAttr.getName(), valueAttr.getValue());
- element.appendChild(childNodeElement);
- //formatChild(childNodeElement, hasChildrenElements);
- }
- XSDSchemaHelper.updateElement(xsdSimpleType);
- if (facet != null)
- {
- XSDSchemaHelper.updateElement(facet);
- }
- }
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
- protected boolean isAnonymous;
- protected XSDSimpleTypeDefinition xsdSimpleType;
-
- public void setInput(Element element)
- {
- this.element = element;
- if (xsdSchema == null)
- {
- return;
- }
-
- isAnonymous = checkForAnonymousType(element);
-
- if (XSDDOMHelper.inputEquals(element, XSDConstants.RESTRICTION_ELEMENT_TAG, false))
- {
- Element parent = (Element)element.getParentNode();
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- XSDConcreteComponent component = null;
- if (parent != null)
- {
- component = xsdSchema.getCorrespondingComponent(parent);
- }
- if (component instanceof XSDSimpleTypeDefinition)
- {
- xsdSimpleType = (XSDSimpleTypeDefinition)component;
- }
- }
-
- XSDConcreteComponent xsdConcreteComponent = null;
- if (element.getParentNode() != null)
- {
- xsdConcreteComponent = xsdSchema.getCorrespondingComponent(element.getParentNode());
- }
-
- if (xsdConcreteComponent instanceof XSDSimpleTypeDefinition)
- {
- xsdSimpleType = (XSDSimpleTypeDefinition)xsdConcreteComponent;
- }
- }
- }
-
- boolean checkForAnonymousType(Element element)
- {
- boolean isAnonymous = false;
-
- Node aNode = getDomHelper().getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- return isAnonymous;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeListPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeListPropertySource.java
deleted file mode 100644
index b49ceb1de3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeListPropertySource.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class SimpleTypeListPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public SimpleTypeListPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SimpleTypeListPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public SimpleTypeListPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- TypesPropertyDescriptor typeDescriptor = new TypesPropertyDescriptor(
- XSDConstants.ITEMTYPE_ATTRIBUTE,
- XSDConstants.ITEMTYPE_ATTRIBUTE,
- element, xsdSchema);
-
- typeDescriptor.setLabelProvider(new LabelProvider()
- {
- public String getText(Object element)
- {
- return (String) element;
- }
- });
- list.add(typeDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- if (((String) id).equals(XSDConstants.ITEMTYPE_ATTRIBUTE))
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = "**anonymous**"; //$NON-NLS-1$
- }
- return result;
- }
- }
- return ""; //$NON-NLS-1$
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- if (((String) id).equals(XSDConstants.ITEMTYPE_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE, (String)value);
- endRecording(element);
- }
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypePropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypePropertySource.java
deleted file mode 100644
index 99885fad54..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypePropertySource.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalSimpleOrComplexTypeRenamer;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Node;
-
-public class SimpleTypePropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- private boolean isAnonymous = false;
- /**
- *
- */
- public SimpleTypePropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SimpleTypePropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public SimpleTypePropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- Node parent = element.getParentNode();
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.RESTRICTION_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parent, XSDConstants.ELEMENT_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parent, XSDConstants.UNION_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parent, XSDConstants.LIST_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- isAnonymous = true;
- }
-
- List list = new ArrayList();
- if (!isAnonymous)
- {
- // Create a descriptor and set a category
- PropertyDescriptor nameDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.NAME_ATTRIBUTE,
- XSDConstants.NAME_ATTRIBUTE);
- list.add(nameDescriptor);
- }
- else
- {
- PropertyDescriptor readOnly = new PropertyDescriptor(XSDConstants.NAME_ATTRIBUTE, XSDConstants.NAME_ATTRIBUTE);
- list.add(readOnly);
- }
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- if (isAnonymous)
- {
- result = "**anonymous**";
- }
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = "";
- }
- if (value instanceof String)
- {
- String name = (String)value;
- if (validateName(name))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SIMPLETYPE_NAME_CHANGE"), element);
- if (name != null && name.length() > 0)
- {
- // now rename any references to this type
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDSimpleTypeDefinition && comp.getContainer().equals(xsdSchema))
- {
-// ((XSDNamedComponent)comp).setName(name);
- GlobalSimpleOrComplexTypeRenamer renamer = new GlobalSimpleOrComplexTypeRenamer((XSDNamedComponent)comp, name);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, name);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, "");
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeUnionPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeUnionPropertySource.java
deleted file mode 100644
index 68584b4856..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/SimpleTypeUnionPropertySource.java
+++ /dev/null
@@ -1,493 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.viewers.LabelProvider;
-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.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.Display;
-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.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.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.util.XSDConstants;
-
-
-public class SimpleTypeUnionPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public SimpleTypeUnionPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public SimpleTypeUnionPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
- }
- /**
- * @param xsdSchema
- */
- public SimpleTypeUnionPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- SimpleUnionMemberTypesPropertyDescriptor typeDescriptor = new SimpleUnionMemberTypesPropertyDescriptor(
- XSDConstants.MEMBERTYPES_ATTRIBUTE,
- XSDConstants.MEMBERTYPES_ATTRIBUTE);
-
- typeDescriptor.setLabelProvider(new LabelProvider()
- {
- public String getText(Object element)
- {
- return (String) element;
- }
- });
- list.add(typeDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- if (((String) id).equals(XSDConstants.MEMBERTYPES_ATTRIBUTE))
- {
- result = element.getAttribute((String) id);
- if (result == null)
- {
- result = ""; //$NON-NLS-1$
- }
- return result;
- }
- }
- return ""; //$NON-NLS-1$
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value == null)
- {
- value = ""; //$NON-NLS-1$
- }
-
- if (value instanceof String)
- {
- String newValue = (String)value;
- if (((String) id).equals(XSDConstants.MEMBERTYPES_ATTRIBUTE))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, (String)value);
- }
- else
- {
- element.removeAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-
-
- public class SimpleUnionMemberTypesPropertyDescriptor extends PropertyDescriptor
- {
- /**
- * @param id
- * @param displayName
- */
- public SimpleUnionMemberTypesPropertyDescriptor(Object id, String displayName)
- {
- super(id, displayName);
- }
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- CellEditor editor = new SimpleTypeUnionMemberTypesDialogCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
- }
-
- public class SimpleTypeUnionMemberTypesDialogCellEditor extends DialogCellEditor {
-
- /**
- * Creates a new Font dialog cell editor parented under the given control.
- * The cell editor value is <code>null</code> initially, and has no
- * validator.
- *
- * @param parent the parent control
- */
- protected SimpleTypeUnionMemberTypesDialogCellEditor(Composite parent) {
- super(parent);
- }
-
- /**
- * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(Control)
- */
- protected Object openDialogBox(Control cellEditorWindow)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- SimpleContentUniontMemberTypesDialog dialog = new SimpleContentUniontMemberTypesDialog(shell);
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- String value = (String)getValue();
-
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- return dialog.getResult();
- }
- return value;
- }
-
- }
-
- public class SimpleContentUniontMemberTypesDialog extends org.eclipse.jface.dialogs.Dialog implements SelectionListener
- {
- Table table;
- TypeSection typeSection;
- Button addButton, removeButton;
- org.eclipse.swt.widgets.List memberTypesList;
-
- private String result;
-
- public SimpleContentUniontMemberTypesDialog(Shell shell)
- {
- super(shell);
- }
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.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.setImage(XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"));
- //tc.setText("Available types:");
- 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());
- }
- }
-
- 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]);
- }
- }
- }
-
- 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(xsdSchema);
- return helper.getBuiltInTypeNamesList();
- }
-
- public java.util.List getUserSimpleTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserSimpleTypeNamesList();
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/TypesPropertyDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/TypesPropertyDescriptor.java
deleted file mode 100644
index 60e238a578..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/TypesPropertyDescriptor.java
+++ /dev/null
@@ -1,1145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.DialogCellEditor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-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.PropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.wst.xsd.ui.internal.widgets.TypeSection;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public class TypesPropertyDescriptor extends PropertyDescriptor
-{
- Element element;
- XSDSchema xsdSchema;
- String property;
- /**
- * @param id
- * @param displayName
- */
- public TypesPropertyDescriptor(Object id, String displayName, Element element, XSDSchema xsdSchema)
- {
- super(id, displayName);
- this.property = (String)id;
- this.element = element;
- this.xsdSchema = xsdSchema;
- }
-
- boolean showComplexTypes = true;
-
- public CellEditor createPropertyEditor(Composite parent)
- {
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- showComplexTypes = true;
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(element, XSDConstants.LIST_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- showComplexTypes = false;
- }
- // CellEditor editor = new TypesOptionsTextCellEditor(parent);
- CellEditor editor = new TypesDialogCellEditor(parent);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
-
-
- public class TypesDialogCellEditor extends DialogCellEditor
- {
-
- /**
- * Creates a new Font dialog cell editor parented under the given control.
- * The cell editor value is <code>null</code> initially, and has no
- * validator.
- *
- * @param parent the parent control
- */
- protected TypesDialogCellEditor(Composite parent)
- {
- super(parent);
- }
-
- protected Object openDialogBox(Control cellEditorWindow)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- TypesDialog dialog = new TypesDialog(shell);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- String value = (String)getValue();
-
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- value = dialog.getType();
- doSetValue(value);
- fireApplyEditorValue();
- }
- deactivate();
- return null;
- }
- }
-
- public class TypesDialog extends org.eclipse.jface.dialogs.Dialog implements SelectionListener
- {
- String type;
- Object typeObject;
- Table table;
-
- TypeSection typeSection;
- boolean showAnonymous = true;
- String previousStringType = "";
- boolean isAnonymous;
- int previousType;
-
-
- public TypesDialog(Shell shell)
- {
- super(shell);
- }
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.OK)
- {
- type = table.getItem(table.getSelectionIndex()).getText();
- ok();
- }
- super.buttonPressed(buttonId);
- }
-
- public Object getTypeObject() { return typeObject; }
- public String getType() { return type; }
-
- //
- // Create the controls
- //
- public Control createDialogArea(Composite parent)
- {
- Composite client = (Composite)super.createDialogArea(parent);
- getShell().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_AVAILABLE_TYPES"));
-
- typeObject = null;
-
- GridLayout gl = new GridLayout(1, true);
- client.setLayout(gl);
-
- GridData gd = new GridData();
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.FILL;
- gd.horizontalIndent = 0;
- client.setLayoutData(gd);
-
- typeSection = new TypeSection(client);
- typeSection.setShowUserComplexType(showComplexTypes);
-
- typeSection.createClient(client);
- typeSection.getSimpleType().setSelection(false);
- typeSection.getSimpleType().addSelectionListener(this);
- typeSection.getUserSimpleType().addSelectionListener(this);
- if (showComplexTypes)
- {
- typeSection.getUserComplexType().addSelectionListener(this);
- }
-
- table = new Table(client,
- SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- table.setHeaderVisible(false);
- table.setLinesVisible(true);
-
- GridData gd2 = new GridData();
- gd2.grabExcessHorizontalSpace = true;
- gd2.grabExcessVerticalSpace = true;
- gd2.horizontalAlignment = GridData.FILL;
- gd2.heightHint = 200;
- table.setLayoutData(gd2);
-
- TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
-// tableColumn.setImage(XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"));
- tableColumn.setResizable(true);
- tableColumn.setWidth(200);
-
-
- // Fill table and select input type
- handleSetInput();
-
- return client;
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == typeSection.getSimpleType() && typeSection.getSimpleType().getSelection())
- {
- populateBuiltInType();
- }
- else if (e.widget == typeSection.getUserComplexType() && typeSection.getUserComplexType().getSelection())
- {
- populateUserComplexType();
- }
- else if (e.widget == typeSection.getUserSimpleType() && typeSection.getUserSimpleType().getSelection())
- {
- populateUserSimpleType();
- }
-
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- protected void ok()
- {
- TableItem[] items = table.getItems();
- int selection = table.getSelectionIndex();
- if (items != null && items.length > 0 && selection >= 0)
- {
- typeObject = items[selection].getData();
- }
-// System.out.println("typeObject is " + typeObject);
-
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_TYPE_CHANGE"), element);
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), element);
-// doSetValue(typeObject);
-// applyEditorValueAndDeactivate();
-// dialog.close();
-
- if (!XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- if (typeObject.equals("**anonymous**"))
- {
- if (typeSection.getUserSimpleType().getSelection())
- {
- if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(
- element,
- XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- }
- else
- {
- if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- }
- // element.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- element.removeAttribute(property);
- }
- else
- {
- updateElementToNotAnonymous(element);
- //element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, typeObject.toString());
- element.setAttribute(property, typeObject.toString());
- }
- }
-// endRecording(element);
-
- //implement dispose();
-// table.removeAll();
-// table.dispose();
- }
-
-
- public void handleSetInput()
- {
- table.removeAll();
- isAnonymous = checkForAnonymousType(element);
- // Attr attr = element.getAttributeNode(XSDConstants.TYPE_ATTRIBUTE);
- Attr attr = element.getAttributeNode(property);
- if (attr != null)
- {
- String value = attr.getValue();
- if (typeSection.getBuiltInTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- int i = typeSection.getBuiltInTypeNamesList(xsdSchema).indexOf(value);
- table.setSelection(i);
- previousType = 1;
- }
- else if (typeSection.getUserSimpleTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- int i = typeSection.getUserSimpleTypeNamesList(xsdSchema).indexOf(value);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 2;
- }
- else if (typeSection.getUserComplexTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- int i = typeSection.getUserComplexTypeNamesList(xsdSchema).indexOf(value);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 3;
- }
- else // if it is type="" for an empty list of simple types
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- previousType = 2;
- }
- }
- else
- {
- if (isAnonymous)
- {
- if (isSTAnonymous(element))
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- previousType = 2;
- }
- else
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- previousType = 3;
- }
- table.setSelection(0); // anonymous
- // typeSection.getTypeList().setText("**anonymous**");
- }
- else
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- table.setSelection(0);
-
- // typeSection.getTypeList().setEnabled(true);
- // typeSection.getSimpleType().setSelection(true);
- // typeSection.populateBuiltInType(xsdSchema);
- // typeSection.getTypeList().setText(XSDEditorPlugin.getXSDString("_UI_NO_TYPE"));
- previousType = 1;
- }
- }
- if (table.getSelection() != null && table.getSelection().length > 0)
- {
- previousStringType = (table.getSelection()[0]).getText();
- }
- }
-
- 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"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserComplexType()
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- List items = getUserComplexTypeNamesList();
- for (int i = 0; i < items.size(); i++)
- {
- TableItem item = new TableItem(table, SWT.NONE);
-// System.out.println("item " + i + " is " + item);
- item.setText(items.get(i).toString());
- item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserSimpleType()
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- 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"));
- item.setData(items.get(i));
- }
- }
-
- boolean checkForAnonymousType(Element element)
- {
- /*
- * Using Ed's model to check boolean isAnonymous = false;
- *
- * XSDConcreteComponent component =
- * getXSDSchema().getCorrespondingComponent(element); if (component
- * instanceof XSDElementDeclaration) { XSDElementDeclaration xsdElem =
- * (XSDElementDeclaration)component; isAnonymous =
- * xsdElem.isSetAnonymousTypeDefinition(); } return isAnonymous;
- */
- XSDDOMHelper helper = new XSDDOMHelper();
- boolean isAnonymous = false;
- Node aNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- aNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- isAnonymous = true;
- }
- return isAnonymous;
- }
-
- void updateElementToAnonymous(Element element, String xsdType)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- updateElementToNotAnonymous(element);
- Element childNode = null;
- if (xsdType.equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
- {
- childNode = element.getOwnerDocument().createElementNS(
- XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001,
- prefix + XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG))
- {
- childNode =
- element.getOwnerDocument().createElementNS(
- XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001,
- prefix + XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- element.appendChild(childNode);
- }
-
- boolean isSTAnonymous(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node aNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- if (XSDDOMHelper
- .inputEquals(aNode, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- return true;
- }
- }
- return false;
- }
-
- boolean isCTAnonymous(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node aNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- if (XSDDOMHelper.inputEquals(aNode, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- return true;
- }
- }
- return false;
- }
-
- XSDTypeDefinition getAnonymousTypeDefinition(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node typeDefinitionNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (typeDefinitionNode == null)
- {
- typeDefinitionNode =
- helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- if (typeDefinitionNode != null)
- {
- XSDConcreteComponent component =
- xsdSchema.getCorrespondingComponent(typeDefinitionNode);
- if (component instanceof XSDTypeDefinition)
- {
- return (XSDTypeDefinition) component;
- }
- }
- return null;
- }
-
- void updateElementToNotAnonymous(Element element)
- {
- if (element != null)
- {
- NodeList children = element.getChildNodes();
- if (children != null)
- {
- for (int i = 0; i < children.getLength(); i++)
- {
- Node node = (Node) children.item(i);
- if (node instanceof Element)
- {
- if (node.getLocalName().equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG)
- || node.getLocalName().equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
- {
- XSDDOMHelper.removeNodeAndWhitespace(node);
- i = 0;
- }
- }
- }
- }
- }
- }
-
- public java.util.List getBuiltInTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getBuiltInTypeNamesList();
- }
-
- public java.util.List getUserSimpleTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserSimpleTypeNamesList();
- }
-
- public java.util.List getUserComplexTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserComplexTypeNamesList();
- }
-
- protected boolean hasElementChildren(Node parentNode)
- {
- boolean hasChildrenElements = false;
- if (parentNode != null && parentNode.hasChildNodes())
- {
- NodeList nodes = parentNode.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- if (nodes.item(i) instanceof Element)
- {
- hasChildrenElements = true;
- break;
- }
- }
- }
- return hasChildrenElements;
- }
-
- }
-
-
-
-
-
-
-
-
- class TypesOptionsTextCellEditor extends OptionsTextCellEditor
- {
- boolean showAnonymous = true;
-
- public TypesOptionsTextCellEditor(Composite parent)
- {
- super(parent);
- }
-
- protected Control createControl(Composite parent)
- {
- isTextReadOnly = true;
- return super.createControl(parent);
- }
-
- Table table;
- TypeSection typeSection;
-
- protected void openDialog()
- {
- typeObject = null;
- dialog = new Shell(XSDEditorPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.MODELESS);
- Display display = dialog.getDisplay();
- GridLayout gl = new GridLayout(1, true);
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- gl.horizontalSpacing = 0;
- gl.verticalSpacing = 0;
- dialog.setLayout(gl);
- GridData gd = new GridData();
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.FILL;
- gd.horizontalIndent = 0;
- dialog.setLayoutData(gd);
-
-
-
- typeSection = new TypeSection(dialog);
- typeSection.setShowUserComplexType(showComplexTypes);
-
- typeSection.createClient(dialog);
- typeSection.getSimpleType().setSelection(false);
- typeSection.getSimpleType().addSelectionListener(this);
- typeSection.getUserSimpleType().addSelectionListener(this);
- if (showComplexTypes)
- {
- typeSection.getUserComplexType().addSelectionListener(this);
- }
-
- table = new Table(dialog,
- SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- table.setHeaderVisible(false);
- table.setLinesVisible(true);
- GridData gd2 = new GridData();
- gd2.grabExcessHorizontalSpace = true;
- gd2.grabExcessVerticalSpace = true;
- gd2.horizontalAlignment = GridData.FILL;
- gd2.verticalAlignment = GridData.FILL;
- table.setLayoutData(gd2);
-
- // Fill table and select input type
- handleSetInput();
-
- TableColumn tc = new TableColumn(table, SWT.LEFT);
- tc.setImage(XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"));
- tc.setResizable(false);
-
- int MAX_ITEMS = 23;
- Rectangle tableBounds = table.getBounds();
- tableBounds.height = Math.min(tableBounds.height, table.getItemHeight()*MAX_ITEMS);
- table.setBounds(tableBounds);
- dialog.pack();
-
- dialog.addShellListener(new ShellAdapter()
- {
- public void shellDeactivated(ShellEvent e)
- {
- cancel();
- }
- });
-
- Rectangle dialogBounds = dialog.getBounds();
- Point buttonLocation = getButtonAbsoluteLocation();
- dialogBounds.x = buttonLocation.x;
- dialogBounds.y = buttonLocation.y;
-
- if (dialogBounds.height > 200)
- {
- dialogBounds.height = 200;
- }
- if (dialogBounds.height < 100)
- {
- dialogBounds.height = 200;
- }
- if (dialogBounds.width > 200)
- {
- dialogBounds.width = typeSection.getUserComplexType().getBounds().width + 30;
- }
- dialog.setBounds(dialogBounds);
- tc.setWidth(dialogBounds.width);
-
- table.addKeyListener(new KeyAdapter()
- {
- public void keyPressed(KeyEvent e)
- {
- char character = e.character;
- if (character == SWT.CR || character == SWT.LF)
- ok();
- else if (character == SWT.ESC)
- cancel();
- }
- });
-
- table.addMouseListener(new MouseAdapter()
- {
- public void mouseDoubleClick(MouseEvent e)
- {
- ok();
- }
- public void mouseDown(MouseEvent e)
- {
- ok();
- }
- });
-
- try
- {
- dialog.open();
- table.setFocus();
- table.showSelection();
-
- while (!dialog.isDisposed())
- {
- if (!display.readAndDispatch())
- {
- display.sleep();
- }
- }
- }
- finally
- {
- if (!dialog.isDisposed())
- cancel();
- }
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == typeSection.getSimpleType() && typeSection.getSimpleType().getSelection())
- {
- populateBuiltInType();
- }
- else if (e.widget == typeSection.getUserComplexType() && typeSection.getUserComplexType().getSelection())
- {
- populateUserComplexType();
- }
- else if (e.widget == typeSection.getUserSimpleType() && typeSection.getUserSimpleType().getSelection())
- {
- populateUserSimpleType();
- }
- }
-
- protected void cancel()
- {
- super.cancel();
- table.dispose();
- }
-
- protected void ok()
- {
- TableItem[] items = table.getItems();
- selection = table.getSelectionIndex();
- if (items != null && items.length > 0 && selection >= 0)
- {
- typeObject = items[selection].getData();
- }
-// System.out.println("typeObject is " + typeObject);
-
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_TYPE_CHANGE"), element);
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), element);
- doSetValue(typeObject);
- applyEditorValueAndDeactivate();
- dialog.close();
-
- if (!XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- if (typeObject.equals("**anonymous**"))
- {
- if (typeSection.getUserSimpleType().getSelection())
- {
- if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(
- element,
- XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- }
- else
- {
- if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- }
- // element.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- element.removeAttribute(property);
- }
- else
- {
- updateElementToNotAnonymous(element);
- //element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, typeObject.toString());
- element.setAttribute(property, typeObject.toString());
- }
- }
-// endRecording(element);
-
- //implement dispose();
- table.removeAll();
- table.dispose();
- }
-
- String previousStringType = "";
- boolean isAnonymous;
- int previousType;
-
- public void handleSetInput()
- {
- table.removeAll();
- isAnonymous = checkForAnonymousType(element);
- // Attr attr = element.getAttributeNode(XSDConstants.TYPE_ATTRIBUTE);
- Attr attr = element.getAttributeNode(property);
- if (attr != null)
- {
- String value = attr.getValue();
- if (typeSection.getBuiltInTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- int i = typeSection.getBuiltInTypeNamesList(xsdSchema).indexOf(value);
- table.setSelection(i);
- previousType = 1;
- }
- else if (typeSection.getUserSimpleTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- int i = typeSection.getUserSimpleTypeNamesList(xsdSchema).indexOf(value);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 2;
- }
- else if (typeSection.getUserComplexTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- int i = typeSection.getUserComplexTypeNamesList(xsdSchema).indexOf(value);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 3;
- }
- else // if it is type="" for an empty list of simple types
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- previousType = 2;
- }
- }
- else
- {
- if (isAnonymous)
- {
- if (isSTAnonymous(element))
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- previousType = 2;
- }
- else
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- previousType = 3;
- }
- table.setSelection(0); // anonymous
- // typeSection.getTypeList().setText("**anonymous**");
- }
- else
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- table.setSelection(0);
-
- // typeSection.getTypeList().setEnabled(true);
- // typeSection.getSimpleType().setSelection(true);
- // typeSection.populateBuiltInType(xsdSchema);
- // typeSection.getTypeList().setText(XSDEditorPlugin.getXSDString("_UI_NO_TYPE"));
- previousType = 1;
- }
- }
- if (table.getSelection() != null && table.getSelection().length > 0)
- {
- previousStringType = (table.getSelection()[0]).getText();
- }
- }
-
- 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"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserComplexType()
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- List items = getUserComplexTypeNamesList();
- for (int i = 0; i < items.size(); i++)
- {
- TableItem item = new TableItem(table, SWT.NONE);
-// System.out.println("item " + i + " is " + item);
- item.setText(items.get(i).toString());
- item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserSimpleType()
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- 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"));
- item.setData(items.get(i));
- }
- }
-
- boolean checkForAnonymousType(Element element)
- {
- /*
- * Using Ed's model to check boolean isAnonymous = false;
- *
- * XSDConcreteComponent component =
- * getXSDSchema().getCorrespondingComponent(element); if (component
- * instanceof XSDElementDeclaration) { XSDElementDeclaration xsdElem =
- * (XSDElementDeclaration)component; isAnonymous =
- * xsdElem.isSetAnonymousTypeDefinition(); } return isAnonymous;
- */
- XSDDOMHelper helper = new XSDDOMHelper();
- boolean isAnonymous = false;
- Node aNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- aNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- isAnonymous = true;
- }
- return isAnonymous;
- }
-
- void updateElementToAnonymous(Element element, String xsdType)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- updateElementToNotAnonymous(element);
- Element childNode = null;
- if (xsdType.equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
- {
- childNode = element.getOwnerDocument().createElementNS(
- XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001,
- prefix + XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG))
- {
- childNode =
- element.getOwnerDocument().createElementNS(
- XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001,
- prefix + XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- element.appendChild(childNode);
- }
-
- boolean isSTAnonymous(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node aNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- if (XSDDOMHelper
- .inputEquals(aNode, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- return true;
- }
- }
- return false;
- }
-
- boolean isCTAnonymous(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node aNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- if (XSDDOMHelper.inputEquals(aNode, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- return true;
- }
- }
- return false;
- }
-
- XSDTypeDefinition getAnonymousTypeDefinition(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node typeDefinitionNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (typeDefinitionNode == null)
- {
- typeDefinitionNode =
- helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- if (typeDefinitionNode != null)
- {
- XSDConcreteComponent component =
- xsdSchema.getCorrespondingComponent(typeDefinitionNode);
- if (component instanceof XSDTypeDefinition)
- {
- return (XSDTypeDefinition) component;
- }
- }
- return null;
- }
-
- void updateElementToNotAnonymous(Element element)
- {
- NodeList children = element.getChildNodes();
- if (children != null)
- {
- for (int i = 0; i < children.getLength(); i++)
- {
- Node node = (Node) children.item(i);
- if (node instanceof Element)
- {
- if (node.getLocalName().equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG)
- || node.getLocalName().equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
- {
- XSDDOMHelper.removeNodeAndWhitespace(node);
- i = 0;
- }
- }
- }
- }
- }
-
- public java.util.List getBuiltInTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getBuiltInTypeNamesList();
- }
-
- public java.util.List getUserSimpleTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserSimpleTypeNamesList();
- }
-
- public java.util.List getUserComplexTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserComplexTypeNamesList();
- }
-
- protected boolean hasElementChildren(Node parentNode)
- {
- boolean hasChildrenElements = false;
- if (parentNode != null && parentNode.hasChildNodes())
- {
- NodeList nodes = parentNode.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- if (nodes.item(i) instanceof Element)
- {
- hasChildrenElements = true;
- break;
- }
- }
- }
- return hasChildrenElements;
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XPathPropertySource.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XPathPropertySource.java
deleted file mode 100644
index 9a5d893cca..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XPathPropertySource.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-public class XPathPropertySource
- extends BasePropertySource
- implements IPropertySource
-{
- /**
- *
- */
- public XPathPropertySource()
- {
- super();
- }
- /**
- * @param viewer
- * @param xsdSchema
- */
- public XPathPropertySource(Viewer viewer, XSDSchema xsdSchema)
- {
- super(viewer, xsdSchema);
-// From Field
-// WorkbenchHelp.setHelp(comp, XSDEditorContextIds.XSDE_UNIQUE_BASE_FIELDS_GROUP);
-// fieldField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_FIELD_TEXT"));
-// WorkbenchHelp.setHelp(fieldField, XSDEditorContextIds.XSDE_UNIQUE_BASE_SOURCE);
-
-// From Selector
-// WorkbenchHelp.setHelp(comp, XSDEditorContextIds.XSDE_UNIQUE_BASE_SELECTOR_GROUP);
-// WorkbenchHelp.setHelp(selectorField, XSDEditorContextIds.XSDE_UNIQUE_BASE_SELECTOR);
-// selectorField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_SELECTOR_TEXT"));
-
- }
- /**
- * @param xsdSchema
- */
- public XPathPropertySource(XSDSchema xsdSchema)
- {
- super(xsdSchema);
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue()
- {
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- List list = new ArrayList();
- // Create a descriptor and set a category
- PropertyDescriptor xpathDescriptor =
- new TextPropertyDescriptor(
- XSDConstants.XPATH_ATTRIBUTE,
- XSDConstants.XPATH_ATTRIBUTE);
- list.add(xpathDescriptor);
-
- IPropertyDescriptor[] result = new IPropertyDescriptor[list.size()];
- list.toArray(result);
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id)
- {
- Object result = null;
- if (id instanceof String)
- {
- result = element.getAttribute((String) id);
- }
- if (result == null)
- {
- result = "";
- }
- return result;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value)
- {
- if (value != null)
- {
- if (value instanceof String)
- {
- if (XSDDOMHelper.inputEquals(element, XSDConstants.FIELD_ELEMENT_TAG, false))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_FIELD_XPATH_CHANGE"), element);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.SELECTOR_ELEMENT_TAG, false))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SELECTOR_XPATH_CHANGE"), element);
- }
-
- element.setAttribute(XSDConstants.XPATH_ATTRIBUTE, (String)value);
- endRecording(element);
- }
- }
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (viewer != null)
- viewer.refresh();
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDComboBoxPropertyDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDComboBoxPropertyDescriptor.java
deleted file mode 100644
index b4d9cc2531..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDComboBoxPropertyDescriptor.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.PopupList;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-public class XSDComboBoxPropertyDescriptor extends PropertyDescriptor
-{
- private String[] values;
-
- public XSDComboBoxPropertyDescriptor(Object id, String displayName, String[] valuesArray) {
- super(id, displayName);
- values = valuesArray;
- }
- /**
- * The <code>ComboBoxPropertyDescriptor</code> implementation of this
- * <code>IPropertyDescriptor</code> method creates and returns a new
- * <code>ComboBoxCellEditor</code>.
- * <p>
- * The editor is configured with the current validator if there is one.
- * </p>
- */
- public CellEditor createPropertyEditor(Composite parent) {
- CellEditor editor = new XSDComboBoxCellEditor(parent, values);
- //CellEditor editor = new StringComboBoxCellEditor(parent, values);
- if (getValidator() != null)
- editor.setValidator(getValidator());
- return editor;
- }
-
- public class XSDComboBoxCellEditor extends CellEditor
- {
- DynamicCellEditor comboBox;
-
- private String fSelection;
- protected String[] fItems;
- protected Object fValue;
- int selection;
- Object typeObject;
-
- public void createItems(String[] items)
- {
- fItems = items;
- }
-
- public String[] getComboBoxItems()
- {
- return fItems;
- }
-
- /**
- * Creates a new combo box cell editor with the given choices.
- */
- public XSDComboBoxCellEditor(Composite parent, String[] items)
- {
- super(parent);
- fSelection = "";
- setItems(items);
-// fText.setText("");
- }
-
- public void activate() {
- if (doGetValue() != null)
- {
-// int i = ((Integer)doGetValue()).intValue();
-// if (i >= 0)
-// {
-// comboBox.setText(fItems[i]);
-// }
- comboBox.setText((String)fValue);
- }
- }
-
- public void deactivate() {
- super.deactivate();
- }
-
- public void setItems(String[] items) {
- Assert.isNotNull(items);
- this.fItems = items;
- populateComboBoxItems();
- }
-
- private void populateComboBoxItems() {
- if (comboBox != null && fItems != null) {
- comboBox.removeAll();
- for (int i = 0; i < fItems.length; i++)
- comboBox.add(fItems[i], i);
-
- setValueValid(true);
- selection = 0;
- }
- }
-
- /**
- * Creates the actual UI representation.
- */
-
- protected Control createControl(Composite parent)
- {
- comboBox = new DynamicCellEditor(parent, SWT.READ_ONLY |SWT.NONE | SWT.NO_TRIM);
- comboBox.addKeyListener(new KeyAdapter() {
- // hook key pressed - see PR 14201
- public void keyPressed(KeyEvent e) {
-// System.out.println("Key e " + e);
- keyReleaseOccured(e);
- }
- });
-
- comboBox.addSelectionListener(new SelectionAdapter() {
- public void widgetDefaultSelected(SelectionEvent event) {
- }
-
- public void widgetSelected(SelectionEvent event) {
-// System.out.println("combo selected");
- selection = comboBox.getSelectionIndex();
- if (!comboBox.isDropped()) // allows user to traverse list using keyboard without applying value
- applyEditorValueAndDeactivate();
- }
- });
-
- comboBox.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
-// System.out.println("TRAVERSE e " + e);
- if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
- }
- });
-
-
- comboBox.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent e) {
- XSDComboBoxCellEditor.this.focusLost();
- }
- public void focusGained(FocusEvent e) {
-// System.out.println("focusGained");
- }
- });
- setValueValid(true);
- return comboBox;
- }
-
- protected void focusLost() {
-// System.out.println("CELLEDITOR FOCUS LOST");
- if (isActivated()) {
- applyEditorValueAndDeactivate();
- }
- }
-
- protected void keyReleaseOccured(KeyEvent keyEvent) {
- if (keyEvent.character == '\u001b') { // Escape character
- comboBox.setText(""); // clear text
- fireCancelEditor();
- } else if (keyEvent.character == '\r') { // Return key
- //fireApplyEditorValue();
- applyEditorValueAndDeactivate();
- deactivate();
- }
- }
-
- void applyEditorValueAndDeactivate() {
- // must set the selection before getting value
- selection = comboBox.getSelectionIndex();
- if (selection < 0)
- {
- deactivate();
- return;
- }
- // Object newValue = new Integer(selection);
- Object newValue = fItems[selection];
- markDirty();
- boolean isValid = isCorrect(newValue);
- setValueValid(isValid);
- if (!isValid) {
- // try to insert the current value into the error message.
- setErrorMessage(
- MessageFormat.format(getErrorMessage(), new Object[] {fItems[selection]}));
- }
- doSetValue(newValue);
- fireApplyEditorValue();
- deactivate();
- }
-
- protected Object doGetValue() {
- return fValue;
- // otherwise limits to set of valid values
-// Object index = super.doGetValue();
-// int selection = -1;
-// if (index instanceof Integer)
-// selection = ((Integer) index).intValue();
-// if (selection >= 0)
-// return fItems[selection];
-// else if (getControl() instanceof CCombo) {
-// // retrieve the actual text as the list of valid items doesn't contain the value
-// return ((CCombo) getControl()).getText();
-// }
-// return null;
- }
- private boolean fSettingValue = false;
- protected void doSetValue(Object value) {
- if (fSettingValue)
- return;
- fSettingValue = true;
- if (value instanceof Integer) {
- //super.doSetValue(value);
- fValue = value;
- }
- else {
- String stringValue = value.toString();
- int selection = -1;
- for (int i = 0; i < fItems.length; i++)
- if (fItems[i].equals(stringValue))
- selection = i;
- if (selection >= 0)
- //super.doSetValue(new Integer(selection));
- fValue = stringValue;
- else {
- // super.doSetValue(new Integer(-1));
- // fValue = new Integer(-1);
- fValue = stringValue;
- if (getControl() instanceof CCombo && !stringValue.equals(((CCombo) getControl()).getText())) {
- // update the Text widget
- ((CCombo) getControl()).setText(stringValue);
- }
- }
- }
- fSettingValue = false;
- }
-
- /**
- * Returns the cell editor's value.
- */
-// protected Object doGetValue()
-// {
-// return fValue;
-// }
-
- /**
- * Set the focus to the cell editor's UI representation.
- */
- protected void doSetFocus()
- {
-// fButton.setFocus();
-// System.out.println("doSetFocus() " + moreButton.setFocus());
- comboBox.setFocus();
- }
-
- /**
- * Sets the value of the cell editor to the given value.
- */
-// protected void doSetValue(Object value)
-// {
-// fValue = value;
-// }
-
- protected void fillPopupList(PopupList list)
- {
- String[] labels= new String[fItems.length];
- for (int i= 0; i < labels.length; i++)
- {
- String item= fItems[i];
- labels[i]= item;
-// System.out.println(fItems[i]);
- if (fSelection == null && fValue != null && fValue.equals(item))
- {
- fSelection = item;
- }
- }
-
- list.setItems(labels);
- if (fSelection != null)
- {
-// fText.setText(fSelection);
- list.select(fSelection);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDPropertySourceProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDPropertySourceProvider.java
deleted file mode 100644
index 78e790b1ef..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/XSDPropertySourceProvider.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties;
-
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-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.Element;
-import org.w3c.dom.Node;
-
-
-public class XSDPropertySourceProvider implements IPropertySourceProvider
-{
- XSDSchema xsdSchema;
- /**
- *
- * @todo Generated comment
- */
- public XSDPropertySourceProvider()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySourceProvider#getPropertySource(java.lang.Object)
- */
- public IPropertySource getPropertySource(Object object)
- {
- if (object == null) return null;
-
- if (object instanceof XSDConcreteComponent)
- {
- XSDConcreteComponent component = (XSDConcreteComponent)object;
-
- xsdSchema = component.getSchema();
-
- if (component instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)component;
- if (elementDeclaration.isElementDeclarationReference())
- {
- component = elementDeclaration.getResolvedElementDeclaration();
- }
- }
-
- Element input = component.getElement();
-
- BasePropertySource bps = (BasePropertySource)getXSDPropertySource(input);
- if (bps == null) return null;
-
- bps.setInput(input);
- return bps;
- }
- return null;
- }
-
- boolean showParent = false;
-
- public IPropertySource getXSDPropertySource(Object object)
- {
- Element input = (Element)object;
-
- showParent = false;
-
- if (inputEquals(input, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- return new ElementPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ELEMENT_ELEMENT_TAG, true))
- {
- return new GroupRefPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.SEQUENCE_ELEMENT_TAG, false) ||
- inputEquals(input, XSDConstants.CHOICE_ELEMENT_TAG, false) ||
- inputEquals(input, XSDConstants.ALL_ELEMENT_TAG, false))
- {
- return new ModelGroupPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- return new AttributePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- return new AttributeGroupRefPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false))
- {
- return new NamePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true))
- {
- return new AttributeGroupRefPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.NOTATION_ELEMENT_TAG, false))
- {
- return new NotationPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- return new SimpleTypePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.GROUP_ELEMENT_TAG, false))
- {
- return new NamePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.GROUP_ELEMENT_TAG, true))
- {
- return new GroupRefPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.SCHEMA_ELEMENT_TAG, false))
- {
- return new SchemaPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- return new ComplexTypePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.DOCUMENTATION_ELEMENT_TAG, false))
- {
- return new DocumentationPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.APPINFO_ELEMENT_TAG, false))
- {
- return new AppInfoPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- if (input != null && input instanceof Element)
- {
- Element parent = (Element)input;
- XSDDOMHelper xsdDOMHelper = new XSDDOMHelper();
- Element derivedByNode = xsdDOMHelper.getDerivedByElement(parent);
- if (derivedByNode != null)
- {
- if (inputEquals(derivedByNode, XSDConstants.RESTRICTION_ELEMENT_TAG, false) ||
- inputEquals(derivedByNode, XSDConstants.EXTENSION_ELEMENT_TAG, false))
- {
- return new SimpleContentPropertySource(xsdSchema);
- }
- }
- else
- {
- return null;
- }
- }
- }
- else if (inputEquals(input, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- if (input != null && input instanceof Element)
- {
- Element parent = (Element)input;
- XSDDOMHelper xsdDOMHelper = new XSDDOMHelper();
- Element derivedByNode = xsdDOMHelper.getDerivedByElement(parent);
- if (derivedByNode != null)
- {
- return new SimpleContentPropertySource(xsdSchema);
- }
- else
- {
- return null;
- }
- }
- }
- else if (inputEquals(input, XSDConstants.LIST_ELEMENT_TAG, false))
- {
- return new SimpleTypeListPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- return new SimpleTypeUnionPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.RESTRICTION_ELEMENT_TAG, false))
- {
- return createRestrictWindow(input, xsdSchema);
- }
- else if (XSDDOMHelper.isFacet(input))
- {
- if (input != null && input instanceof Element)
- {
- Node parent = ((Element)input).getParentNode();
- if (inputEquals(parent, XSDConstants.RESTRICTION_ELEMENT_TAG, false))
- {
- return createRestrictWindow(input, xsdSchema);
- }
- }
- }
- else if (inputEquals(input, XSDConstants.EXTENSION_ELEMENT_TAG, false))
- {
- if (input != null && input instanceof Element)
- {
- Node parent = ((Element)input).getParentNode();
- if (inputEquals(parent, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false)
- || inputEquals(parent, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- showParent = true;
- return new SimpleContentPropertySource(xsdSchema);
- }
- }
- }
- else if (inputEquals(input, XSDConstants.PATTERN_ELEMENT_TAG, false))
- {
- return new PatternPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ENUMERATION_ELEMENT_TAG, false))
- {
- return new EnumerationPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ANY_ELEMENT_TAG, false))
- {
- return new AnyElementPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false))
- {
- return new AnyAttributePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.UNIQUE_ELEMENT_TAG, false))
- {
- return new NamePropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.KEYREF_ELEMENT_TAG, false))
- {
- return new KeyrefPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.SELECTOR_ELEMENT_TAG, false))
- {
- return new XPathPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.FIELD_ELEMENT_TAG, false))
- {
- return new XPathPropertySource(xsdSchema);
- }
- else if (inputEquals(input, XSDConstants.KEY_ELEMENT_TAG, false))
- {
- return new NamePropertySource(xsdSchema);
- }
- else
- {
- return null;
- }
- return null;
- }
-
- protected IPropertySource createRestrictWindow(Object input, XSDSchema xsdSchema)
- {
- // special case where SimpleType restriction is different than SimpleContent restriction
-
- if (input != null && input instanceof Element)
- {
- Node parent = ((Element)input).getParentNode();
- if (inputEquals(parent, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- return new SimpleRestrictPropertySource(xsdSchema);
- }
- else if (inputEquals(parent, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- return new SimpleRestrictPropertySource(xsdSchema);
- }
- else if (inputEquals(parent, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- showParent = true;
- return new SimpleContentPropertySource(xsdSchema);
- }
- }
- return null;
- }
-
-
- protected boolean inputEquals(Object input, String tagname, boolean isRef)
- {
- return XSDDOMHelper.inputEquals(input, tagname, isRef);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java
deleted file mode 100644
index 9f4bd90e3b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSection.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.part.EditorActionBarContributor;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateElementAction;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class AbstractSection implements ISection, IPropertyChangeListener, Listener, SelectionListener
-{
- private TabbedPropertySheetWidgetFactory factory;
- protected IWorkbenchPart part;
- protected ISelection selection;
- protected Object input;
- protected boolean doRefresh = true;
- XSDSchema xsdSchema;
- protected boolean isReadOnly = false;
- private IStatusLineManager statusLine;
- protected Composite composite;
- protected int rightMarginSpace;
- protected int tableMinimumWidth = 50;
-
- /**
- *
- */
- public AbstractSection()
- {
- super();
- }
-
- public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage)
- {
- createControls(parent, tabbedPropertySheetPage.getWidgetFactory());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory)
- */
- public void createControls(Composite parent, TabbedPropertySheetWidgetFactory aFactory)
- {
- this.factory = aFactory;
- GC gc = new GC(parent);
- Point extent = gc.textExtent(" ... ");
- rightMarginSpace = extent.x;
- gc.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- */
- public void setInput(IWorkbenchPart part, ISelection selection)
- {
- Assert.isTrue(selection instanceof IStructuredSelection);
- this.part = part;
- this.selection = selection;
- Object input = ((IStructuredSelection)selection).getFirstElement();
- this.input = input;
-
- if (input instanceof XSDConcreteComponent)
- {
- xsdSchema = ((XSDConcreteComponent)input).getSchema();
-
- Element element = ((XSDConcreteComponent)input).getElement();
- if (element instanceof IDOMNode)
- {
- isReadOnly = false;
- }
- else
- {
- isReadOnly = true;
- }
- }
- statusLine = getStatusLine();
- clearErrorMessage();
-
-// refresh();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#aboutToBeShown()
- */
- public void aboutToBeShown()
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#aboutToBeHidden()
- */
- public void aboutToBeHidden()
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#dispose()
- */
- public void dispose()
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#getMinimumHeight()
- */
- public int getMinimumHeight()
- {
- return SWT.DEFAULT;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#refresh()
- */
- public void refresh()
- {
- }
-
- public Object getInput()
- {
- if (input instanceof Element)
- {
- input = xsdSchema.getCorrespondingComponent((Element)input);
- }
- return input;
- }
-
- public XSDSchema getSchema()
- {
- return xsdSchema;
- }
-
- /**
- * Get the widget factory.
- * @return the widget factory.
- */
- public TabbedPropertySheetWidgetFactory getWidgetFactory() {
- return factory;
- }
-
- public void propertyChange(PropertyChangeEvent event)
- {
- refresh();
- }
-
-
- public void doWidgetDefaultSelected(SelectionEvent e)
- {}
-
- public void doWidgetSelected(SelectionEvent e)
- {}
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e)
- {
- if (isListenerEnabled() &&
- getInput() != null &&
- !isInDoHandle &&
- !isReadOnly)
- {
- isInDoHandle = true;
- doWidgetDefaultSelected(e);
- isInDoHandle = false;
- }
-
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e)
- {
- if (isListenerEnabled() &&
- getInput() != null &&
- !isInDoHandle &&
- !isReadOnly)
- {
- isInDoHandle = true;
- doWidgetSelected(e);
- isInDoHandle = false;
- }
-
- }
-
- boolean listenerEnabled = true;
- /**
- * 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;
- }
-
- public void handleEvent(Event event)
- {
- if (isListenerEnabled() && !isInDoHandle && !isReadOnly)
- {
- isInDoHandle = true;
- startDelayedEvent(event);
- isInDoHandle = false;
- } // end of if ()
- }
-
- public void doHandleEvent(Event event)
- {
-
- }
-
- protected DelayedEvent delayedTask;
-
- protected void startDelayedEvent(Event e)
- {
- if (delayedTask == null ||
- delayedTask.getEvent() == null)
- {
- delayedTask = new DelayedEvent();
- delayedTask.setEvent(e);
- Display.getDefault().timerExec(500,delayedTask);
- }
- else
- {
- Event delayedEvent = delayedTask.getEvent();
-
- if (e.widget == delayedEvent.widget &&
- e.type == delayedEvent.type)
- {
- // same event, just different data, delay new event
- delayedTask.setEvent(null);
- }
- delayedTask = new DelayedEvent();
- delayedTask.setEvent(e);
- Display.getDefault().timerExec(500,delayedTask);
- }
- }
-
- class DelayedEvent implements Runnable
- {
- protected Event event;
-
- /*
- * @see Runnable#run()
- */
- public void run()
- {
- if (event != null)
- {
- isInDoHandle = true;
- doHandleEvent(event);
- isInDoHandle = false;
- event = null;
- }
- }
-
- /**
- * Gets the event.
- * @return Returns a Event
- */
- public Event getEvent()
- {
- return event;
- }
-
- /**
- * Sets the event.
- * @param event The event to set
- */
- public void setEvent(Event event)
- {
- this.event = event;
- }
-
- }
-
- boolean isInDoHandle;
- /**
- * Get the value of isInDoHandle.
- * @return value of isInDoHandle.
- */
- public boolean isInDoHandle()
- {
- return isInDoHandle;
- }
-
-
- protected IEditorPart getActiveEditor()
- {
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
-// IEditorPart editorPart = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
-
- return editorPart;
- }
-
- static protected IStatusLineManager getStatusLineManager(IEditorPart editorPart)
- {
- IStatusLineManager result = null;
- try
- {
- EditorActionBarContributor contributor = (EditorActionBarContributor)editorPart.getEditorSite().getActionBarContributor();
- result = contributor.getActionBars().getStatusLineManager();
- }
- catch (Exception e)
- {
- }
- return result;
- }
-
- protected XSDDOMHelper domHelper = new XSDDOMHelper();
- /**
- * Gets the domHelper.
- * @return Returns a XSDDomHelper
- */
- public XSDDOMHelper getDomHelper()
- {
- return domHelper;
- }
-
- public DocumentImpl getDocument(Element element)
- {
- return (DocumentImpl) element.getOwnerDocument();
- }
-
- public void beginRecording(String description, Element element)
- {
- getDocument(element).getModel().beginRecording(this, description);
- }
-
- public void endRecording(Element element)
- {
- DocumentImpl doc = (DocumentImpl) getDocument(element);
-
- doc.getModel().endRecording(this);
- }
-
- protected boolean validateName(String name)
- {
- try
- {
- return NameValidator.isValid(name);
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- // TODO
- protected boolean validateLanguage(String lang)
- {
- return true;
- }
-
- // TODO
- protected boolean validatePrefix(String prefix)
- {
- return true;
- }
-
-
- protected Action getNewElementAction(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);
- action.setXSDSchema(getSchema());
- action.setSelectionProvider(null);
- return action;
- }
-
- public void setErrorMessage(String message)
- {
- if (statusLine != null)
- {
- statusLine.setErrorMessage(message);
- statusLine.update(true);
- }
- }
-
- public void clearErrorMessage()
- {
- if (statusLine != null)
- {
- statusLine.setErrorMessage(null);
- statusLine.update(false);
- }
- }
-
- EditorActionBarContributor contributor;
- protected IStatusLineManager getStatusLine()
- {
-// IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
-// IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
-
- if (statusLine == null)
- {
- try
- {
- contributor = (EditorActionBarContributor)editorPart.getEditorSite().getActionBarContributor();
- statusLine = contributor.getActionBars().getStatusLineManager();
- }
- catch (Exception e)
- {
- }
- }
- return statusLine;
- }
-
- /**
- * Get the standard label width when labels for sections line up on the left
- * hand side of the composite. We line up to a fixed position, but if a
- * string is wider than the fixed position, then we use that widest string.
- *
- * @param parent
- * The parent composite used to create a GC.
- * @param labels
- * The list of labels.
- * @return the standard label width.
- */
- protected int getStandardLabelWidth(Composite parent, String[] labels) {
- int standardLabelWidth = 100; // STANDARD_LABEL_WIDTH;
- GC gc = new GC(parent);
- int indent = gc.textExtent("XXX").x; //$NON-NLS-1$
- for (int i = 0; i < labels.length; i++) {
- int width = gc.textExtent(labels[i]).x;
- if (width + indent > standardLabelWidth) {
- standardLabelWidth = width + indent;
- }
- }
- gc.dispose();
- return standardLabelWidth;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSectionDescriptor.java
deleted file mode 100644
index 1cbcf1072e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AbstractSectionDescriptor.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-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-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getFilter()
- */
- public ITypeMapper 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 "";
- }
-
- protected boolean inputEquals(Object input, String tagname, boolean isRef)
- {
- return XSDDOMHelper.inputEquals(input, tagname, isRef);
- }
-
- public int getEnablesFor()
- {
- return ENABLES_FOR_ANY;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSection.java
deleted file mode 100644
index e756ea77f9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSection.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-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.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAnnotation;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFacet;
-import org.eclipse.xsd.XSDFactory;
-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.XSDNotationDeclaration;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.XSDXPathDefinition;
-import org.eclipse.xsd.impl.XSDFactoryImpl;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class AnnotationSection extends AbstractSection
-{
- DocumentationWorkbookPage documentationPage;
- AppInfoWorkbookPage appInfoPage;
- XSDWorkbook workbook;
- XSDFactory factory;
-
- /**
- *
- */
- public AnnotationSection()
- {
- super();
- factory = new XSDFactoryImpl();
- }
-
- /**
- * @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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
-
- workbook = new XSDWorkbook(parent, SWT.BOTTOM | SWT.FLAT);
-
- documentationPage = new DocumentationWorkbookPage(workbook);
- appInfoPage = new AppInfoWorkbookPage(workbook);
-
- documentationPage.activate();
- appInfoPage.activate();
- workbook.setSelectedPage(documentationPage);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (doRefresh)
- {
- if (documentationPage.getDocumentationText().isFocusControl() || appInfoPage.getAppInfoText().isFocusControl())
- {
- return;
- }
-
- if (isReadOnly)
- {
- documentationPage.setEnabled(false);
- appInfoPage.setEnabled(false);
- }
- else
- {
- documentationPage.setEnabled(true);
- appInfoPage.setEnabled(true);
- }
- setListenerEnabled(false);
- Object input = getInput();
- if (input != null)
- {
- XSDAnnotation xsdAnnotation = getInputXSDAnnotation(false);
- setInitialText(xsdAnnotation);
- }
- setListenerEnabled(true);
- }
- }
-
-
- public void doHandleEvent(Event event)
- {
- Object input = getInput();
- if (input != null)
- {
- XSDAnnotation xsdAnnotation = getInputXSDAnnotation(true);
-
- if (event.widget == documentationPage.getDocumentationText())
- {
- documentationPage.doHandleEvent(xsdAnnotation);
- }
- else if (event.widget == appInfoPage.getAppInfoText())
- {
- appInfoPage.doHandleEvent(xsdAnnotation);
- }
- }
-
- }
-
- protected XSDAnnotation getInputXSDAnnotation(boolean createIfNotExist)
- {
- XSDAnnotation xsdAnnotation = null;
-
- 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 void formatAnnotation(XSDAnnotation annotation)
- {
- Element element = annotation.getElement();
- XSDDOMHelper.formatChild(element);
- }
-
-
- public boolean shouldUseExtraSpace()
- {
- return true;
- }
-
- public void dispose()
- {
- factory = null;
- }
-
- private void setInitialText(XSDAnnotation an)
- {
- if (documentationPage != null)
- {
- documentationPage.setText(""); //$NON-NLS-1$
- }
- if (appInfoPage != null)
- {
- appInfoPage.setText(""); //$NON-NLS-1$
- }
-
- if (an != null)
- {
- Element element = an.getElement();
- try
- {
- if (element.hasChildNodes())
- {
- // if the element is Text
- Element docElement = (Element)domHelper.getChildNode(element, XSDConstants.DOCUMENTATION_ELEMENT_TAG);
- if (docElement != null)
- {
- Node node = docElement.getFirstChild();
- if (node instanceof CharacterData)
- {
- documentationPage.setText( ((CharacterData)node).getData());
- }
- }
-
- Element appInfoElement = (Element)domHelper.getChildNode(element, XSDConstants.APPINFO_ELEMENT_TAG);
- if (appInfoElement != null)
- {
- Node node = appInfoElement.getFirstChild();
- if (node instanceof CharacterData)
- {
- appInfoPage.setText( ((CharacterData)node).getData());
- }
- }
-
- }
- }
- catch (Exception e)
- {
-
- }
- }
- }
-
-
- class DocumentationWorkbookPage extends XSDWorkbookPage
- {
- Text documentationText;
- Composite page1;
-
- public DocumentationWorkbookPage(XSDWorkbook workbook)
- {
- super(workbook);
- this.getTabItem().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_DOCUMENTATION"));
- }
-
- public void setText(String value)
- {
- documentationText.setText(value);
- }
-
- public void setEnabled(boolean state)
- {
- page1.setEnabled(state);
- }
-
- public String getText()
- {
- return documentationText.getText();
- }
-
- public Text getDocumentationText()
- {
- return documentationText;
- }
-
- public Control createControl (Composite parent)
- {
- page1 = getWidgetFactory().createFlatFormComposite(parent);
- documentationText = getWidgetFactory().createText(page1, "", SWT.V_SCROLL | SWT.H_SCROLL); //$NON-NLS-1$
- documentationText.addListener(SWT.Modify, AnnotationSection.this);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- documentationText.setLayoutData(data);
-
- return page1;
- }
-
- public void doHandleEvent(XSDAnnotation xsdAnnotation)
- {
- if (xsdAnnotation != null)
- {
- Element element = xsdAnnotation.getElement();
- List documentationList = xsdAnnotation.getUserInformation();
- Element documentationElement = null;
- if (documentationList.size() > 0)
- {
- documentationElement = (Element)documentationList.get(0);
- }
-
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DOCUMENTATION_COMMENT_CHANGE"), element); //$NON-NLS-1$
-
- if (documentationElement == null)
- {
- documentationElement = xsdAnnotation.createUserInformation(null);
- element.appendChild(documentationElement);
- XSDDOMHelper.formatChild(documentationElement);
- // Defect in model....I create it but the model object doesn't appear to be updated
- // Notice that it is fine for appinfo
- xsdAnnotation.updateElement();
- xsdAnnotation.setElement(element);
- }
-
- String newValue = documentationText.getText();
- if (documentationElement != null)
- {
- try
- {
- if (documentationElement.hasChildNodes())
- {
- // if the element is Text
- Node node = documentationElement.getFirstChild();
- if (node instanceof CharacterData)
- {
- ((CharacterData)node).setData(newValue);
- }
- }
- else
- {
- if (newValue.length() > 0)
- {
- Node childNode = documentationElement.getOwnerDocument().createTextNode(newValue);
- documentationElement.appendChild(childNode);
- }
- }
- }
- catch (Exception e)
- {
-
- }
- }
- endRecording(element);
- }
- }
- }
-
- class AppInfoWorkbookPage extends XSDWorkbookPage
- {
- Text appInfoText;
- Composite page2;
-
- public AppInfoWorkbookPage(XSDWorkbook workbook)
- {
- super(workbook);
- this.getTabItem().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_APP_INFO"));
- }
-
- public void setText(String value)
- {
- appInfoText.setText(value);
- }
-
- public String getText()
- {
- return appInfoText.getText();
- }
-
- public Text getAppInfoText()
- {
- return appInfoText;
- }
-
- public void setEnabled(boolean state)
- {
- page2.setEnabled(state);
- }
-
- public Control createControl (Composite parent)
- {
- page2 = getWidgetFactory().createFlatFormComposite(parent);
- appInfoText = getWidgetFactory().createText(page2, "", SWT.V_SCROLL | SWT.H_SCROLL); //$NON-NLS-1$
- appInfoText.addListener(SWT.Modify, AnnotationSection.this);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- //data.top = new FormAttachment(documentationText, +ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- appInfoText.setLayoutData(data);
-
- return page2;
- }
-
- public void doHandleEvent(XSDAnnotation xsdAnnotation)
- {
- if (xsdAnnotation != null)
- {
- Element element = xsdAnnotation.getElement();
- List appInfoList = xsdAnnotation.getApplicationInformation();
-
- Element appInfoElement = null;
- if (appInfoList.size() > 0)
- {
- appInfoElement = (Element)appInfoList.get(0);
- }
-
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMMENT_CHANGE"), element); //$NON-NLS-1$
- if (appInfoElement == null)
- {
- appInfoElement = xsdAnnotation.createApplicationInformation(null);
- element.appendChild(appInfoElement);
- XSDDOMHelper.formatChild(appInfoElement);
- }
-
- String newValue = appInfoText.getText();
- if (appInfoElement != null)
- {
- try
- {
- if (appInfoElement.hasChildNodes())
- {
- // if the element is Text
- Node node = appInfoElement.getFirstChild();
- if (node instanceof CharacterData)
- {
- ((CharacterData)node).setData(newValue);
- }
- }
- else
- {
- if (newValue.length() > 0)
- {
- Node childNode = appInfoElement.getOwnerDocument().createTextNode(newValue);
- appInfoElement.appendChild(childNode);
- }
- }
- }
- catch (Exception e)
- {
-
- }
- endRecording(element);
- }
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSectionDescriptor.java
deleted file mode 100644
index 93bd523e60..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AnnotationSectionDescriptor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDAnnotation;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFacet;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNotationDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.XSDXPathDefinition;
-
-public class AnnotationSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public AnnotationSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.annotation";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDAnnotation.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new AnnotationSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.documentation";
- }
-
- /* (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 XSDAttributeDeclaration ||
- object instanceof XSDAttributeGroupDefinition ||
- object instanceof XSDElementDeclaration ||
- object instanceof XSDNotationDeclaration ||
- object instanceof XSDXPathDefinition ||
- object instanceof XSDModelGroup ||
- object instanceof XSDModelGroupDefinition ||
- object instanceof XSDIdentityConstraintDefinition ||
- object instanceof XSDWildcard ||
- object instanceof XSDSchema ||
- object instanceof XSDFacet ||
- object instanceof XSDTypeDefinition ||
- object instanceof XSDAnnotation ||
- object instanceof XSDSchemaDirective)
- {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewContentProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewContentProvider.java
deleted file mode 100644
index b5ffe415e0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewContentProvider.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDAbstractAdapter;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDAdapterFactoryLabelProvider;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-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.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-
-
-public class AttributesViewContentProvider implements ITreeContentProvider, ITableLabelProvider, ILabelProvider, INotifyChangedListener
-{
- IEditorPart editorPart;
-
- static XSDModelAdapterFactoryImpl xsdModelAdapterFactory = XSDModelAdapterFactoryImpl.getInstance();
- static XSDAdapterFactoryLabelProvider adapterFactoryLabelProvider = new XSDAdapterFactoryLabelProvider(xsdModelAdapterFactory); // XSDTextEditor.getLabelProvider();
-
- XSDAbstractAdapter elementAdapter;
- XSDAbstractAdapter ctAdapter;
- XSDComplexTypeDefinition ct;
-
- /**
- *
- */
- public AttributesViewContentProvider()
- {
- super();
-// if (xsdModelAdapterFactory instanceof IChangeNotifier)
-// {
-// ((IChangeNotifier)xsdModelAdapterFactory).addListener(this);
-// }
-
- }
-
- Viewer attributesViewer;
- public AttributesViewContentProvider(IEditorPart editorPart, Viewer viewer)
- {
- super();
- this.editorPart = editorPart;
- this.attributesViewer = viewer;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object inputElement)
- {
- List list = new ArrayList();
- ct = null;
- if (inputElement instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElement = (XSDElementDeclaration)inputElement;
-
- if (elementAdapter != null)
- {
- elementAdapter.removeListener((INotifyChangedListener)this);
- }
- elementAdapter = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt(xsdElement, xsdModelAdapterFactory);
- elementAdapter.addListener((INotifyChangedListener)this);
-
- if (xsdElement.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition)
- {
- ct = (XSDComplexTypeDefinition)xsdElement.getAnonymousTypeDefinition();
- }
- else
- {
- XSDTypeDefinition xsdType = xsdElement.getTypeDefinition();
- if (xsdType instanceof XSDComplexTypeDefinition)
- {
- ct = (XSDComplexTypeDefinition)xsdType;
- }
- }
- }
- else if (inputElement instanceof XSDComplexTypeDefinition)
- {
- ct = (XSDComplexTypeDefinition)inputElement;
- }
-
- if (ct != null)
- {
- if (ctAdapter != null)
- {
- ctAdapter.removeListener((INotifyChangedListener)this);
- }
- ctAdapter = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt(ct, xsdModelAdapterFactory);
- ctAdapter.addListener((INotifyChangedListener)this);
-
- XSDWildcard wildcard = ct.getAttributeWildcardContent();
- if (wildcard != null)
- {
- list.add(wildcard);
- }
-
- Iterator i = ct.getAttributeContents().iterator();
- while (i.hasNext())
- {
- XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent)i.next();
- if (attributeGroupContent instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition)attributeGroupContent;
- XSDAbstractAdapter a = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt(attributeGroupDefinition, xsdModelAdapterFactory);
- a.removeListener((INotifyChangedListener)this);
- a.addListener((INotifyChangedListener)this);
- list.add(attributeGroupDefinition);
- }
- else if (attributeGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)attributeGroupContent;
-
- XSDAttributeDeclaration attribute = attributeUse.getAttributeDeclaration();
-
- boolean isRef = XSDDOMHelper.isAttributeRef(ct.getElement(), attribute.getQName(), attribute.getTargetNamespace());
-
- if (isRef)
- {
- XSDAbstractAdapter a = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt(attributeUse, xsdModelAdapterFactory);
- a.removeListener((INotifyChangedListener)this);
- a.addListener((INotifyChangedListener)this);
- list.add(attributeUse);
- }
- else
- {
- XSDAbstractAdapter a = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt(attribute, xsdModelAdapterFactory);
- a.removeListener((INotifyChangedListener)this);
- a.addListener((INotifyChangedListener)this);
- list.add(attribute);
- }
- }
- }
- }
- return list.toArray();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element)
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex)
- {
- if (element instanceof XSDConcreteComponent)
- {
- return adapterFactoryLabelProvider.getImage((XSDConcreteComponent)element);
- }
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex)
- {
- if (element instanceof XSDConcreteComponent)
- {
- XSDAbstractAdapter a = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt((XSDConcreteComponent)element, xsdModelAdapterFactory);
- return a.getText((XSDConcreteComponent)element);
- }
- return "";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element)
- {
- if (element instanceof XSDConcreteComponent)
- {
- return adapterFactoryLabelProvider.getImage((XSDConcreteComponent)element);
- }
- return null;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element)
- {
- if (element instanceof XSDConcreteComponent)
- {
- XSDAbstractAdapter a = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt((XSDConcreteComponent)element, xsdModelAdapterFactory);
- return a.getText((XSDConcreteComponent)element);
- }
- return "";
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement)
- {
- return getChildren(inputElement);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- public void dispose()
- {
- if (elementAdapter != null)
- {
- elementAdapter.removeListener(this);
- }
- if (ctAdapter != null)
- {
- ctAdapter.removeListener((INotifyChangedListener)this);
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- Viewer viewer;
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
-// System.out.println("input changed " + oldInput + "\n" + newInput);
- this.viewer = viewer;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
- public void addListener(ILabelProviderListener listener)
- {
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- */
- public boolean isLabelProperty(Object element, String property)
- {
- return false;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
- public void removeListener(ILabelProviderListener listener)
- {
- }
-
- public void notifyChanged(Notification notification)
- {
- if (attributesViewer != null && !attributesViewer.getControl().isDisposed())
- {
- if (attributesViewer instanceof StructuredViewer)
- {
- attributesViewer.refresh();
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSection.java
deleted file mode 100644
index 0c830fff9a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSection.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.XSDMenuListener;
-import org.eclipse.wst.xsd.ui.internal.actions.AddAttributeAction;
-import org.eclipse.wst.xsd.ui.internal.actions.CreateAttributeAndRequired;
-import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute;
-import org.eclipse.wst.xsd.ui.internal.actions.DeleteAction;
-import org.eclipse.wst.xsd.ui.internal.properties.XSDPropertySourceProvider;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class AttributesViewSection extends AbstractSection implements ISelectionChangedListener
-{
- AttributeTableTreeViewer viewer;
- AttributesPropertySheetPage propertySheetPage;
-
- /**
- *
- */
- public AttributesViewSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory) {
- super.createControls(parent, factory);
-
- composite = getWidgetFactory().createFlatFormComposite(parent);
- SashForm sashForm = new SashForm(composite, SWT.HORIZONTAL);
-
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.bottom = new FormAttachment(100, 0);
- sashForm.setLayoutData(data);
-
- viewer = new AttributeTableTreeViewer(sashForm);
- propertySheetPage = new AttributesPropertySheetPage();
- propertySheetPage.createControl(sashForm);
-
- AttributesViewContentProvider provider = new AttributesViewContentProvider(getActiveEditor(), viewer);
- viewer.setContentProvider(provider);
-
- viewer.setLabelProvider(provider);
- viewer.addSelectionChangedListener(this);
-
- propertySheetPage.setPropertySourceProvider(new XSDPropertySourceProvider());
- }
-
- public void setInput(IWorkbenchPart part, ISelection selection)
- {
- super.setInput(part, selection);
- if (input instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)input;
- if (elementDeclaration.isElementDeclarationReference())
- {
- input = elementDeclaration.getResolvedElementDeclaration();
-
- isReadOnly = (!(elementDeclaration.getResolvedElementDeclaration().getRootContainer() == xsdSchema));
- }
- }
- }
-
- public void selectionChanged(SelectionChangedEvent event)
- {
- propertySheetPage.selectionChanged(part, event.getSelection());
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection)
- {
- }
-
- public void aboutToBeShown()
- {
- refresh();
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- setListenerEnabled(false);
- if (viewer != null)
- {
- viewer.setInput(getInput());
- viewer.refresh();
- }
- setListenerEnabled(true);
- }
-
- public void dispose()
- {
-// if (propertySheetPage != null)
-// {
-// propertySheetPage.dispose();
-// propertySheetPage = null;
-// }
-// if (viewer != null)
-// {
-// viewer = null;
-// }
- }
-
- public boolean shouldUseExtraSpace()
- {
- return true;
- }
-
-
- class AttributeTableTreeViewer extends TreeViewer // ExtendedTableTreeViewer
- {
- public AttributeTableTreeViewer(Composite c)
- {
- super(c);
-
- MenuManager menuManager = new MenuManager("#popup");//$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- Menu menu = menuManager.createContextMenu(getTree());
- getTree().setMenu(menu);
-
- XSDAttributeMenuListener menuListener = new XSDAttributeMenuListener(this);
- menuManager.addMenuListener(menuListener);
-
- }
-
- public class XSDAttributeMenuListener extends XSDMenuListener
- {
- public XSDAttributeMenuListener(TreeViewer viewer)
- {
- super(viewer);
- selectionProvider = viewer;
-
- deleteAction = new DeleteAction(XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE"), AttributesViewSection.this.getActiveEditor(), getXSDSchema());
- deleteAction.setSelectionProvider(selectionProvider);
- selectionProvider.addSelectionChangedListener(deleteAction);
- }
-
- protected XSDSchema getXSDSchema()
- {
- return xsdSchema;
-// return getSchema();
-// XSDConcreteComponent xsdInput = (XSDConcreteComponent)AttributesViewSection.this.getInput();
-// return xsdInput.getSchema();
- }
-
- protected Object getSelectedElement()
- {
- XSDComponent xsdInput = (XSDComponent)AttributesViewSection.this.getInput();
-
- if (xsdInput instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElement = (XSDElementDeclaration)xsdInput;
- XSDTypeDefinition xsdType = xsdElement.getType();
- if (xsdType instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)xsdType;
- return ct;
- }
- return xsdElement;
- }
- else if (xsdInput instanceof XSDComplexTypeDefinition)
- {
- return xsdInput;
- }
-
- return null;
- }
-
- public void menuAboutToShow(IMenuManager manager)
- {
- updateXSDSchema();
- if (xsdSchema == null)
- {
- return;
- }
-
- Object selectedElementObj = getSelectedElement();
-
- Element selectedElement = null;
-
- if (selectedElementObj instanceof XSDComplexTypeDefinition)
- {
- selectedElement = ((XSDComplexTypeDefinition)selectedElementObj).getElement();
- }
-
- addContextItems(manager, selectedElement, null);
-
- if (!selectionProvider.getSelection().isEmpty())
- {
- // Add context menu items for selected element
-// addContextItems(manager, selectedElement, null);
-
- manager.add(new Separator());
- if (deleteAction != null)
- {
- deleteAction.setXSDSchema(getXSDSchema());
- manager.add(deleteAction);
- }
- }
- }
-
- protected void addContextItems(IMenuManager manager, Element parent, Node relativeNode)
- {
- ArrayList attributes = null;
- if (XSDDOMHelper.inputEquals(parent, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- { //
- boolean complexOrSimpleContentExists = false;
- boolean anyAttributeExists = false;
- Element contentNode = null;
- Node anyAttributeNode = null;
- NodeList children = parent.getChildNodes();
-
- for (int i=0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
- if (child != null && child instanceof Element)
- {
- if (XSDDOMHelper.inputEquals((Element)child, XSDConstants.SEQUENCE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals((Element)child, XSDConstants.ALL_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals((Element)child, XSDConstants.CHOICE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals((Element)child, XSDConstants.GROUP_ELEMENT_TAG, true) ||
- XSDDOMHelper.inputEquals((Element)child, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals((Element)child, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- contentNode = (Element)child;
-
- if (XSDDOMHelper.inputEquals((Element)child, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals((Element)child, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- complexOrSimpleContentExists = true;
- }
- }
- else if (XSDDOMHelper.inputEquals((Element)child, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false))
- {
- anyAttributeExists = true;
- anyAttributeNode = child;
- }
- }
- }
-
- if (anyAttributeExists)
- {
- if (!complexOrSimpleContentExists)
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE,
- getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, anyAttributeNode);
- attributes = null;
-// ARE ATTRIBUTE GROUPS ALLOWED ?
-// addCreateElementAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, "_UI_ACTION_ADD_ATTRIBUTE_GROUP", attributes, parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, anyAttributeNode);
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, anyAttributeNode);
- }
- }
- else
- {
- if (!complexOrSimpleContentExists)
- {
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE,
- getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- addCreateElementAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), parent, parent.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), parent, parent.getLastChild());
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, parent, parent.getLastChild());
- }
- else
- {
- // new model based add attribute action
- XSDComplexTypeDefinition xsdCT = (XSDComplexTypeDefinition)getXSDSchema().getCorrespondingComponent(parent);
- manager.add(new AddAttributeAction(XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"), xsdCT));
-
- Element derivedByElement = domHelper.getDerivedByElement(contentNode);
- if (derivedByElement != null)
- {
- attributes = null;
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"), derivedByElement, derivedByElement.getLastChild());
- addCreateElementRefAction(manager, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"), derivedByElement, derivedByElement.getLastChild());
- attributes = null;
- addCreateElementActionIfNotExist(manager, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"), attributes, derivedByElement, derivedByElement.getLastChild());
- }
- }
- }
- }
- else if (parent == null) {
- XSDElementDeclaration ed = (XSDElementDeclaration)input;
-
- // Add Attribute
- attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.NAME_ATTRIBUTE,
- getNewName(parent, XSDConstants.ATTRIBUTE_ELEMENT_TAG, "Attribute", false)));
- attributes.add(new DOMAttribute(XSDConstants.TYPE_ATTRIBUTE, getBuiltInStringQName()));
- manager.add(new CreateAttributeAndRequired(XSDConstants.ATTRIBUTE_ELEMENT_TAG,
- XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE"),
- attributes,
- getXSDSchema(),
- selectionProvider,
- ed));
-
- // Add Attribute Reference
- attributes = null;
- attributes = new ArrayList();
- String ref = getFirstGlobalElementTagName(XSDConstants.ATTRIBUTE_ELEMENT_TAG);
- attributes.add(new DOMAttribute(XSDConstants.REF_ATTRIBUTE, ref));
-
- Action action = new CreateAttributeAndRequired(XSDConstants.ATTRIBUTE_ELEMENT_TAG,
- XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_REFERENCE"),
- attributes,
- getXSDSchema(),
- selectionProvider,
- ed);
- manager.add(action);
- action.setEnabled(ref != null);
-
- // Add Attribute Group Reference
- attributes = null;
- attributes = new ArrayList();
- ref = getFirstGlobalElementTagName(XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG);
- attributes.add(new DOMAttribute(XSDConstants.REF_ATTRIBUTE, ref));
-
- action = new CreateAttributeAndRequired(XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG,
- XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF"),
- attributes,
- getXSDSchema(),
- selectionProvider,
- ed);
-
- manager.add(action);
- action.setEnabled(ref != null);
-
- // Add Any Attribute
- attributes = null;
- if (getFirstChildNodeIfExists(parent, XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false) == null)
- {
- action = new CreateAttributeAndRequired(XSDConstants.ANYATTRIBUTE_ELEMENT_TAG,
- XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ANY_ATTRIBUTE"),
- attributes,
- getXSDSchema(),
- selectionProvider,
- ed);
- manager.add(action);
- }
- }
- }
- }
- }
-
- class AttributesPropertySheetPage extends PropertySheetPage implements INotifyChangedListener
- {
- public AttributesPropertySheetPage()
- {
- super();
- }
-
- public void notifyChanged(Notification notification)
- {
- System.out.println("Notification");
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSectionDescriptor.java
deleted file mode 100644
index 2156ff92b9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/AttributesViewSectionDescriptor.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-
-public class AttributesViewSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public AttributesViewSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.attributes";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDElementDeclaration.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new AttributesViewSection();
- }
-
- public boolean appliesTo(IWorkbenchPart part, ISelection selection)
- {
- Object object = null;
- if (selection instanceof StructuredSelection)
- {
- StructuredSelection structuredSelection = (StructuredSelection)selection;
- object = structuredSelection.getFirstElement();
- if (object instanceof XSDElementDeclaration)
- {
-// Remove this to fix bug 3870 Element references should have the same properties as elements
-// XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)object;
-// if (elementDeclaration.isElementDeclarationReference())
-// {
-// return false;
-// }
- return true;
- }
- else if (object instanceof XSDComplexTypeDefinition)
- {
- return true;
- }
- }
- return false;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.attributes";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection()
- */
- public String getAfterSection()
- {
- return "";
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/CommonDirectivesSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/CommonDirectivesSection.java
deleted file mode 100644
index 6a89da7f79..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/CommonDirectivesSection.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.swt.SWT;
-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.XSDEditorPlugin;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDParser;
-
-public class CommonDirectivesSection extends AbstractSection
-{
- Text schemaLocationText;
- Button wizardButton;
- StyledText errorText;
- Color red;
-
- // TODO: common up code with XSDSelectIncludeFileWizard
- public void doHandleEvent(Event event)
- {
- errorText.setText("");
- if (event.type == SWT.Modify)
- {
- if (event.widget == schemaLocationText)
- {
- String errorMessage = "";
- boolean isValidSchemaLocation = true;
- String xsdModelFile = schemaLocationText.getText();
- String namespace = "";
- XSDSchema externalSchema = null;
-
- if (xsdModelFile.length() == 0)
- {
- handleSchemaLocationChange(xsdModelFile, "", null);
- 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(), "");
-
- XSDParser parser = new XSDParser();
- parser.parse(normalizedXSDFile);
-
- externalSchema = parser.getSchema();
-
- if (externalSchema != null)
- {
- String extNamespace = externalSchema.getTargetNamespace();
- if (extNamespace == null) extNamespace = "";
- namespace = extNamespace;
-
- if (externalSchema.getDiagnostics() != null &&
- externalSchema.getDiagnostics().size() > 0)
- {
- isValidSchemaLocation = false;
- errorMessage = XSDEditorPlugin.getPlugin().getString("_UI_INCORRECT_XML_SCHEMA", xsdModelFile);
- }
- else
- {
- String currentNameSpace = getSchema().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.getPlugin().getString("_UI_DIFFERENT_NAME_SPACE", xsdModelFile);
- 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.getPlugin().getString("_UI_SAME_NAME_SPACE", xsdModelFile);
- isValidSchemaLocation = false;
- }
- }
- }
- }
- }
- else
- {
- errorMessage = "Invalid file";
- isValidSchemaLocation = false;
- }
- }
- catch(Exception e)
- {
- errorMessage = "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/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSection.java
deleted file mode 100644
index e5e9ca8228..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSection.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.core.resources.IFile;
-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.graphics.GC;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.SetBaseTypeAction;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xml.XMLComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDSetTypeHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class ComplexTypeSection extends AbstractSection
-{
- private String derivedByChoicesComboValues[] =
- {
- "",
- XSDConstants.RESTRICTION_ELEMENT_TAG,
- XSDConstants.EXTENSION_ELEMENT_TAG
- };
-
- /**
- *
- */
- public ComplexTypeSection()
- {
- super();
- }
-
- Text baseTypeCombo;
- CCombo derivedByCombo;
- Button button;
-
- /**
- * @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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- String textBaseType = XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON");
- String textDerivedType = XSDEditorPlugin.getXSDString("_UI_LABEL_DERIVED_BY");
- GC gc = new GC(parent);
- int xoffset = Math.max(100, gc.textExtent(textBaseType).x + 20); // adds 20 due to borders
- xoffset = Math.max(xoffset, gc.textExtent(textDerivedType).x + 20); // adds 20 due to borders
- gc.dispose();
-
- baseTypeCombo = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- CLabel baseTypeLabel = getWidgetFactory().createCLabel(composite, textBaseType); //$NON-NLS-1$
-
- button = getWidgetFactory().createButton(composite, "", SWT.PUSH);
- button.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$
- baseTypeCombo.setEditable(false);
- baseTypeCombo.addListener(SWT.Modify, this);
-
- data = new FormData();
- data.left = new FormAttachment(0, xoffset);
- data.right = new FormAttachment(button, 0);
- baseTypeCombo.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(baseTypeCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(button, 0, SWT.CENTER);
- baseTypeLabel.setLayoutData(data);
-
- button.addSelectionListener(this);
- data = new FormData();
- data.left = new FormAttachment(100, -rightMarginSpace + 2);
- data.right = new FormAttachment(100,0);
- data.top = new FormAttachment(baseTypeCombo, 0, SWT.CENTER);
- button.setLayoutData(data);
-
- derivedByCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- data = new FormData();
- data.left = new FormAttachment(0, xoffset);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(baseTypeCombo, +ITabbedPropertyConstants.VSPACE);
- derivedByCombo.setLayoutData(data);
- derivedByCombo.setItems(derivedByChoicesComboValues);
- derivedByCombo.addSelectionListener(this);
-
- CLabel derivedByLabel = getWidgetFactory().createCLabel(composite, textDerivedType); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(derivedByCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(derivedByCombo, 0, SWT.CENTER);
- derivedByLabel.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- setListenerEnabled(false);
-
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
-
- Object input = getInput();
- baseTypeCombo.setText(""); //$NON-NLS-1$
-
- if (input instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)input;
- Element element = complexType.getElement();
- Element contentModelElement = getDomHelper().getContentModelFromParent(element);
- String baseType = getDomHelper().getBaseType(contentModelElement);
-
- derivedByCombo.setText(getDomHelper().getDerivedByName(contentModelElement));
-
- if (baseType != null)
- {
- baseTypeCombo.setText(baseType);
- }
- }
-
- setListenerEnabled(true);
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e)
- {
- XSDComplexTypeDefinition xsdComplexType = (XSDComplexTypeDefinition)getInput();
- Element ctElement = xsdComplexType.getElement();
- if (e.widget == button)
- {
- Shell shell = Display.getCurrent().getActiveShell();
- Element element = null;
- if (xsdComplexType.getContent() != null)
- {
- element = ((XSDComplexTypeDefinition)getInput()).getContent().getElement();
- }
-
-// SimpleContentBaseTypeOptionsDialog dialog = new SimpleContentBaseTypeOptionsDialog(shell, element, BASE_TYPE_ID, ((XSDConcreteComponent)getInput()).getSchema());
-// dialog.setBlockOnOpen(true);
-// dialog.create();
-// int result = dialog.open();
-
- IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile();
-
- Object input = getInput();
- XSDSchema schema = null;
- if (input instanceof XSDConcreteComponent) {
- schema = ((XSDConcreteComponent) input).getSchema();
- }
-
- XSDComponentSelectionProvider provider = new XSDComponentSelectionProvider(currentIFile, schema);
- XSDComponentSelectionDialog dialog = new XSDComponentSelectionDialog(shell, XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"), provider);
- provider.setDialog(dialog);
- dialog.setBlockOnOpen(true);
- dialog.create();
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- XMLComponentSpecification spec = dialog.getSelection();
- XSDSetTypeHelper helper = new XSDSetTypeHelper(currentIFile, schema);
- helper.addImportIfNecessary(element, spec);
-
- String typeString = helper.getPrefixedTypeName(spec);
- String derivedBy = getDomHelper().getDerivedByName(element);
- SetBaseTypeAction setBaseTypeAction = new SetBaseTypeAction(XSDEditorPlugin.getXSDString("_UI_LABEL_SET_BASE_TYPE")); //$NON-NLS-1$
- setBaseTypeAction.setXSDSchema(xsdSchema);
- setBaseTypeAction.setComplexTypeElement(ctElement);
- setBaseTypeAction.setType(typeString);
- setBaseTypeAction.setDerivedBy(derivedBy);
- setBaseTypeAction.performAction();
-
- }
-
-// refresh();
- }
- else if (e.widget == derivedByCombo)
- {
- Element contentModelElement = getDomHelper().getContentModelFromParent(ctElement);
- String baseType = getDomHelper().getBaseType(contentModelElement);
- beginRecording(XSDEditorPlugin.getXSDString("_UI_DERIVEDBY_CHANGE"), ctElement); //$NON-NLS-1$
- if (contentModelElement != null)
- {
- getDomHelper().changeDerivedByType(contentModelElement, derivedByCombo.getText(), baseType);
- }
- endRecording(ctElement);
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSectionDescriptor.java
deleted file mode 100644
index 56979a7c5e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ComplexTypeSectionDescriptor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-
-public class ComplexTypeSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public ComplexTypeSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDComplexTypeDefinition.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new ComplexTypeSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDComplexTypeDefinition)
- {
- return true;
- }
- }
- return false;
- }
-
- public String getAfterSection()
- {
- return "org.eclipse.wst.xsdeditor.section.name";
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSection.java
deleted file mode 100644
index 266fb24dc8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSection.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-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.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.Event;
-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.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.AddEnumsAction;
-import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDEnumerationFacet;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDVariety;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-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)getInput();
- Element element = st.getElement();
- if (e.widget == addButton || e.widget == addManyButton)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
-
- int variety = st.getVariety().getValue();
- Node varietyElement = null;
- if (variety == XSDVariety.ATOMIC)
- {
- varietyElement = helper.getChildNode(element, XSDConstants.RESTRICTION_ELEMENT_TAG);
- }
- else if (variety == XSDVariety.UNION)
- {
- varietyElement = helper.getChildNode(element, XSDConstants.UNION_ELEMENT_TAG);
- }
- else if (variety == XSDVariety.LIST)
- {
- varietyElement = helper.getChildNode(element, XSDConstants.LIST_ELEMENT_TAG);
- }
-
- if (varietyElement != null)
- {
- if (e.widget == addButton)
- {
- java.util.List attributes = new ArrayList();
-
- 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$
- }
- }
- }
- attributes.add(new DOMAttribute(XSDConstants.VALUE_ATTRIBUTE, newName.toString()));
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ENUM"), element); //$NON-NLS-1$
- Action action = getNewElementAction(XSDConstants.ENUMERATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ENUM"), attributes, (Element)varietyElement, null);
- action.run();
- st.setElement(element);
-
- endRecording(element);
- enumerationsTable.refresh();
- int newItemIndex = enumerationsTable.getTable().getItemCount() - 1;
- enumerationsTable.editElement(enumerationsTable.getElementAt(newItemIndex), 0);
- attributes = null;
- }
- else if (e.widget == addManyButton)
- {
- AddEnumsAction action = new AddEnumsAction(XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ENUMS")); //$NON-NLS-1$
- action.setElementTag(XSDConstants.ENUMERATION_ELEMENT_TAG);
- action.setAttributes(null);
- action.setParentNode((Element)varietyElement);
- action.setRelativeNode(null);
- action.setDescription(XSDEditorPlugin.getXSDString("_UI_ENUMERATIONS_DIALOG_TITLE")); //$NON-NLS-1$
- action.run();
- st.setElement(element);
- enumerationsTable.refresh();
- }
- }
- }
- else if (e.widget == deleteButton)
- {
- StructuredSelection selection = (StructuredSelection)enumerationsTable.getSelection();
- if (selection != null)
- {
- Iterator i = selection.iterator();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE_ENUMERATION"), element); //$NON-NLS-1$
- while (i.hasNext())
- {
- Object obj = i.next();
- if (obj != null)
- {
- if (obj instanceof XSDEnumerationFacet)
- {
- XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)obj;
-
- // I have to update using DOM
- XSDDOMHelper.removeNodeAndWhitespace(enumFacet.getElement());
-
- }
- }
- }
- enumerationsTable.refresh();
- st.setElement(element);
- endRecording(element);
- }
- }
- 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)
- {
-
- }
-
- /**
- * @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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
-
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- enumerationsTable = new EnumerationsTableViewer(getWidgetFactory().createTable(composite, SWT.MULTI | SWT.FULL_SELECTION));
- enumerationsTable.setInput(getInput());
- 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$
- 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);
-
- 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 = tableMinimumWidth;
- table.setLayoutData(data);
- table.addListener(SWT.Resize, this);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- Object input = getInput();
- 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()
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- 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;
-
- Element simpleTypeElement = ((XSDSimpleTypeDefinition)getInput()).getElement();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ENUM_VALUE_CHANGE"), simpleTypeElement); //$NON-NLS-1$
-
- XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)item.getData();
- enumFacet.setLexicalValue((String)value);
- item.setData(enumFacet);
- item.setText((String)value);
- endRecording(simpleTypeElement);
- }
- }
-
- 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");
- }
-
- public String getColumnText(Object element, int columnIndex)
- {
- if (element instanceof XSDEnumerationFacet)
- {
- XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)element;
- String value = enumFacet.getLexicalValue();
- if (value == null) value = "";
- return value;
- }
- return "";
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSectionDescriptor.java
deleted file mode 100644
index 0af99b0050..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/EnumerationsSectionDescriptor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-
-
-public class EnumerationsSectionDescriptor extends AbstractSectionDescriptor
-{
-
- /**
- *
- */
- public EnumerationsSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.enumerations";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDSimpleTypeDefinition.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new EnumerationsSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.enumerations";
- }
-
- /* (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 XSDSimpleTypeDefinition)
- {
- return true;
- // return false; // turn off this tab
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetViewer.java
deleted file mode 100644
index 1c3faabb58..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetViewer.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-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.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.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.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.impl.XSDFactoryImpl;
-import org.eclipse.xsd.util.XSDConstants;
-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" };
- protected FacetsSection facetsSection;
- /**
- * @param parent
- */
- public FacetViewer(Composite parent, FacetsSection facetsSection)
- {
- super(new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE));
- this.facetsSection = facetsSection;
-
- 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, 120, true);
- layout.addColumnData(data);
- cellEditors[0] = null;
-
- ColumnWeightData data2 = new ColumnWeightData(120, 100, 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, 80, 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);
-
- facetsSection.beginRecording(XSDEditorPlugin.getXSDString("_UI_FACET_CHANGE"), 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)
- {
- facetsSection.endRecording(simpleTypeElement);
- 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();
- facetsSection.endRecording(simpleTypeElement);
- 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)
- {
- XSDFactoryImpl factory = new XSDFactoryImpl();
- 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 o = WindowUtility.getSelection(event.getSelection());
- 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)
- {
- Vector v = new Vector();
- XSDSimpleTypeDefinition inputXSDSimpleType = (XSDSimpleTypeDefinition)inputElement;
- XSDSimpleTypeDefinition base = inputXSDSimpleType.getBaseTypeDefinition();
-
- if (base != null)
- {
- Iterator validFacets = base.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/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSection.java
deleted file mode 100644
index 55d9587965..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSection.java
+++ /dev/null
@@ -1,802 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.jface.viewers.ISelection;
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-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.IWorkbenchPart;
-import org.eclipse.wst.common.ui.internal.viewers.NavigableTableViewer;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.wst.xsd.ui.internal.wizards.RegexWizard;
-import org.eclipse.xsd.XSDPatternFacet;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDVariety;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class FacetsSection extends AbstractSection
-{
- IWorkbenchPart part;
- ISelection selection;
- FacetViewer facetViewer;
-
- XSDWorkbook workbook;
- FacetsWorkbookPage facetsWorkbookPage;
-// If you want to add the enumerations tab to this facets tab
-// EnumsWorkbookPage enumsWorkbookPage;
- PatternsWorkbookPage patternsWorkbookPage;
-
- /**
- *
- */
- public FacetsSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
-
- workbook = new XSDWorkbook(parent, SWT.BOTTOM | SWT.FLAT);
-
- facetsWorkbookPage = new FacetsWorkbookPage(workbook, this);
-// enumsWorkbookPage = new EnumsWorkbookPage(workbook);
- patternsWorkbookPage = new PatternsWorkbookPage(workbook);
- facetsWorkbookPage.activate();
-// enumsWorkbookPage.activate();
- patternsWorkbookPage.activate();
- workbook.setSelectedPage(facetsWorkbookPage);
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection)
- {
- this.part = part;
- this.selection = selection;
- }
-
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- Object input = getInput();
-
- if (isReadOnly)
- {
- facetViewer.getControl().getParent().setEnabled(false);
- }
- else
- {
- facetViewer.getControl().getParent().setEnabled(true);
- }
-
- if (facetViewer != null)
- {
- facetViewer.setInput(input);
- }
-
-// if (enumsWorkbookPage != null)
-// {
-// enumsWorkbookPage.setInput(input);
-// }
-
- if (patternsWorkbookPage != null)
- {
- patternsWorkbookPage.setInput(input);
- }
- }
-
- public void dispose()
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return true;
- }
-
-
- /* General Facets Page */
-
- class FacetsWorkbookPage extends XSDWorkbookPage
- {
- FacetsSection facetsSection;
- Composite page1;
-
- public FacetsWorkbookPage(XSDWorkbook workbook, FacetsSection facetsSection)
- {
- super(workbook);
- this.getTabItem().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_FACETS")); //$NON-NLS-1$
- this.facetsSection = facetsSection;
- }
-
- public Control createControl (Composite parent)
- {
- page1 = getWidgetFactory().createFlatFormComposite(parent);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
-
- facetViewer = new FacetViewer(page1, facetsSection);
- facetViewer.setInput(getInput());
- facetViewer.getControl().setLayoutData(data);
-
- return page1;
- }
- }
-
- /* Enumerations Page */
-
-// class EnumsWorkbookPage extends XSDWorkbookPage implements SelectionListener
-// {
-// EnumerationsTableViewer enumerationsTable;
-// Button addButton;
-// Button deleteButton;
-//
-// public EnumsWorkbookPage(XSDWorkbook workbook)
-// {
-// super(workbook);
-// this.getTabItem().setText("Enumerations");
-// }
-//
-// public Control createControl (Composite parent)
-// {
-// Composite composite = getWidgetFactory().createFlatFormComposite(parent);
-// FormData data;
-//
-// addButton = getWidgetFactory().createButton(composite, "Add", SWT.PUSH);
-// deleteButton = getWidgetFactory().createButton(composite, "Delete", SWT.PUSH);
-// enumerationsTable = new EnumerationsTableViewer(getWidgetFactory().createTable(composite, SWT.MULTI | SWT.FULL_SELECTION));
-//
-// enumerationsTable.setInput(getInput());
-// Table table = enumerationsTable.getTable();
-// table.addSelectionListener(this);
-//
-// data = new FormData();
-// data.left = new FormAttachment(deleteButton, 0, SWT.LEFT);
-// data.right = new FormAttachment(100, 0);
-// data.top = new FormAttachment(0, 0);
-// data.bottom = new FormAttachment(deleteButton, 0); //-ITabbedPropertyConstants.VSPACE);
-// addButton.setLayoutData(data);
-// addButton.addSelectionListener(this);
-//
-// data = new FormData();
-// data.left = new FormAttachment(table, +ITabbedPropertyConstants.HSPACE);
-// data.right = new FormAttachment(100, 0);
-// data.top = new FormAttachment(addButton, 0);
-//// data.bottom = new FormAttachment(deleteButton, +ITabbedPropertyConstants.VSPACE);
-// deleteButton.setLayoutData(data);
-// deleteButton.setEnabled(false);
-// deleteButton.addSelectionListener(this);
-//
-// data = new FormData();
-// data.left = new FormAttachment(0, 0);
-// data.right = new FormAttachment(85, 0);
-// data.top = new FormAttachment(0, 0);
-// data.bottom = new FormAttachment(100, 0);
-// table.setLayoutData(data);
-//
-// return composite;
-// }
-//
-// public void setInput(Object input)
-// {
-// enumerationsTable.setInput(input);
-// }
-//
-// public void widgetSelected(SelectionEvent e)
-// {
-// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)getInput();
-// Element element = st.getElement();
-// if (e.widget == addButton)
-// {
-// XSDDOMHelper helper = new XSDDOMHelper();
-//
-// int variety = st.getVariety().getValue();
-// Node varietyElement = null;
-// if (variety == XSDVariety.ATOMIC)
-// {
-// varietyElement = helper.getChildNode(element, XSDConstants.RESTRICTION_ELEMENT_TAG);
-// }
-// else if (variety == XSDVariety.UNION)
-// {
-// varietyElement = helper.getChildNode(element, XSDConstants.UNION_ELEMENT_TAG);
-// }
-// else if (variety == XSDVariety.LIST)
-// {
-// varietyElement = helper.getChildNode(element, XSDConstants.LIST_ELEMENT_TAG);
-// }
-//
-// if (varietyElement != null)
-// {
-// java.util.List attributes = new ArrayList();
-// attributes.add(new DOMAttribute(XSDConstants.VALUE_ATTRIBUTE, ""));
-// beginRecording("Add Enumeration", element);
-// Action action = getNewElementAction(XSDConstants.ENUMERATION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ENUM"), attributes, (Element)varietyElement, null);
-// action.run();
-// st.setElement(element);
-//
-// endRecording(element);
-// enumerationsTable.refresh();
-// attributes = null;
-// }
-// }
-// else if (e.widget == deleteButton)
-// {
-// StructuredSelection selection = (StructuredSelection)enumerationsTable.getSelection();
-// if (selection != null)
-// {
-// Iterator i = selection.iterator();
-// beginRecording("Delete Enumeration", element);
-// while (i.hasNext())
-// {
-// Object obj = i.next();
-// if (obj != null)
-// {
-// if (obj instanceof XSDEnumerationFacet)
-// {
-// XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)obj;
-//
-// // I have to update using DOM
-// XSDDOMHelper.removeNodeAndWhitespace(enumFacet.getElement());
-//
-// }
-// }
-// }
-// enumerationsTable.refresh();
-// st.setElement(element);
-// endRecording(element);
-// }
-// }
-// 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)
-// {
-//
-// }
-// }
-//
-// class EnumerationsTableViewer extends NavigableTableViewer implements ICellModifier
-// {
-// protected String[] columnProperties = {"Enumeration"};
-//
-// 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);
-//
-// 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;
-//
-// Element simpleTypeElement = ((XSDSimpleTypeDefinition)getInput()).getElement();
-// FacetsSection.this.beginRecording(XSDEditorPlugin.getXSDString("_UI_ENUM_VALUE_CHANGE"), simpleTypeElement);
-//
-// XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)item.getData();
-// enumFacet.setLexicalValue((String)value);
-// item.setData(enumFacet);
-// item.setText((String)value);
-// FacetsSection.this.endRecording(simpleTypeElement);
-// }
-// }
-//
-// public Object getValue(Object element, String property)
-// {
-// if (element instanceof XSDEnumerationFacet)
-// {
-// XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)element;
-// String value = enumFacet.getLexicalValue();
-// if (value == null) value = "";
-// return value;
-// }
-// return "";
-// }
-//
-// }
-//
-// 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");
-// }
-//
-// public String getColumnText(Object element, int columnIndex)
-// {
-// if (element instanceof XSDEnumerationFacet)
-// {
-// XSDEnumerationFacet enum = (XSDEnumerationFacet)element;
-// String value = enum.getLexicalValue();
-// if (value == null) value = "";
-// return value;
-// }
-// return "";
-// }
-//
-// }
-
- /* Patterns Page */
-
- class PatternsWorkbookPage extends XSDWorkbookPage implements SelectionListener, Listener
- {
- PatternsTableViewer patternsTable;
- Button addButton;
- Button deleteButton;
- Button editButton;
- Composite composite;
-
- public PatternsWorkbookPage(XSDWorkbook workbook)
- {
- super(workbook);
- this.getTabItem().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_PATTERNS")); //$NON-NLS-1$
- }
-
- public Control createControl (Composite parent)
- {
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- patternsTable = new PatternsTableViewer(getWidgetFactory().createTable(composite, SWT.MULTI | SWT.FULL_SELECTION));
- patternsTable.setInput(getInput());
- Table table = patternsTable.getTable();
- table.addSelectionListener(this);
-
- addButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_ADD"), SWT.PUSH); //$NON-NLS-1$
- editButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_EDIT"), SWT.PUSH); //$NON-NLS-1$
- deleteButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE_INCLUDE"), SWT.PUSH); //$NON-NLS-1$
-
- data = new FormData();
- data.left = new FormAttachment(100, -100);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- addButton.setLayoutData(data);
- addButton.addSelectionListener(this);
-
- data = new FormData();
- data.left = new FormAttachment(addButton, 0, SWT.LEFT);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(addButton, 0);
- editButton.setLayoutData(data);
- editButton.setEnabled(false);
- editButton.addSelectionListener(this);
-
- data = new FormData();
- data.left = new FormAttachment(addButton, 0, SWT.LEFT);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(editButton, 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 = tableMinimumWidth;
- table.setLayoutData(data);
- table.addListener(SWT.Resize, this);
-
- return composite;
- }
-
- public void handleEvent(Event event)
- {
- Table table = patternsTable.getTable();
- if (event.type == SWT.Resize && event.widget == table)
- {
- TableColumn tableColumn = table.getColumn(0);
- tableColumn.setWidth(table.getSize().x);
- }
- }
-
-
- public void setInput(Object input)
- {
- patternsTable.setInput(input);
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)getInput();
- Element element = st.getElement();
-
- if (e.widget == addButton)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
-
- int variety = st.getVariety().getValue();
- Node varietyElement = null;
- if (variety == XSDVariety.ATOMIC)
- {
- varietyElement = helper.getChildNode(element, XSDConstants.RESTRICTION_ELEMENT_TAG);
- }
- else if (variety == XSDVariety.UNION)
- {
- varietyElement = helper.getChildNode(element, XSDConstants.UNION_ELEMENT_TAG);
- }
- else if (variety == XSDVariety.LIST)
- {
- varietyElement = helper.getChildNode(element, XSDConstants.LIST_ELEMENT_TAG);
- }
-
- if (varietyElement != null)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- 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();
-
- java.util.List attributes = new ArrayList();
- attributes.add(new DOMAttribute(XSDConstants.VALUE_ATTRIBUTE, newPattern));
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_PATTERN"), element); //$NON-NLS-1$
- Action action = getNewElementAction(XSDConstants.PATTERN_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_PATTERN"), attributes, (Element)varietyElement, null); //$NON-NLS-1$
- action.run();
- st.setElement(element);
- endRecording(element);
- patternsTable.refresh();
- attributes = null;
- }
- }
- }
- else if (e.widget == deleteButton)
- {
- StructuredSelection selection = (StructuredSelection)patternsTable.getSelection();
- if (selection != null)
- {
- Iterator i = selection.iterator();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE_INCLUDE"), element); // Reword ?
- while (i.hasNext())
- {
- Object obj = i.next();
- if (obj != null)
- {
- if (obj instanceof XSDPatternFacet)
- {
- XSDPatternFacet patternFacet = (XSDPatternFacet)obj;
-
- // I have to update using DOM
- XSDDOMHelper.removeNodeAndWhitespace(patternFacet.getElement());
- }
- }
- }
- st.setElement(element);
- endRecording(element);
- patternsTable.refresh();
- if (patternsTable.getTable().getItemCount() == 0)
- {
- editButton.setEnabled(false);
- deleteButton.setEnabled(false);
- }
- }
- }
- else if (e.widget == editButton)
- {
- StructuredSelection selection = (StructuredSelection)patternsTable.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();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PATTERN_VALUE_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.VALUE_ATTRIBUTE, newPattern);
- pattern.setLexicalValue(newPattern);
- endRecording(element);
- patternsTable.refresh();
- }
- }
- }
- }
- else if (e.widget == patternsTable.getTable())
- {
- StructuredSelection selection = (StructuredSelection)patternsTable.getSelection();
- if (selection.getFirstElement() != null)
- {
- editButton.setEnabled(true);
- deleteButton.setEnabled(true);
- }
- else
- {
- editButton.setEnabled(false);
- deleteButton.setEnabled(false);
- }
- }
-
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
-
- }
- }
-
-
- class PatternsTableViewer extends NavigableTableViewer implements ICellModifier
- {
- protected String[] columnProperties = {"Pattern"};
-
- protected CellEditor[] cellEditors;
-
- Table table;
-
- public PatternsTableViewer(Table table)
- {
- super(table);
- table = getTable();
-
- table.setLinesVisible(true);
-
- setContentProvider(new PatternsTableContentProvider());
- setLabelProvider(new PatternsTableLabelProvider());
- 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;
-
- Element simpleTypeElement = ((XSDSimpleTypeDefinition)getInput()).getElement();
- FacetsSection.this.beginRecording(XSDEditorPlugin.getXSDString("_UI_PATTERN_VALUE_CHANGE"), simpleTypeElement); //$NON-NLS-1$
-
- XSDPatternFacet patternFacet = (XSDPatternFacet)item.getData();
- patternFacet.setLexicalValue((String)value);
-
- item.setData(patternFacet);
- item.setText((String)value);
- FacetsSection.this.endRecording(simpleTypeElement);
- }
- }
-
- public Object getValue(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;
- }
- return ""; //$NON-NLS-1$
- }
-
- }
-
- class PatternsTableContentProvider 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.getPatternFacets().toArray();
- }
- return list.toArray();
- }
-
- public void dispose()
- {
- }
- }
-
- class PatternsTableLabelProvider extends LabelProvider implements ITableLabelProvider
- {
- public PatternsTableLabelProvider()
- {
-
- }
-
- public Image getColumnImage(Object element, int columnIndex)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDSimplePattern.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;
- }
- return ""; //$NON-NLS-1$
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSectionDescriptor.java
deleted file mode 100644
index c188f7c93f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/FacetsSectionDescriptor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-
-
-public class FacetsSectionDescriptor extends AbstractSectionDescriptor
-{
-
- /**
- *
- */
- public FacetsSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.facets";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDSimpleTypeDefinition.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new FacetsSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.facets";
- }
-
- /* (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 XSDSimpleTypeDefinition)
- {
- return true;
- }
- }
- return false;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSection.java
deleted file mode 100644
index 36b591842c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSection.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-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 MinMaxSection extends AbstractSection
-{
- CCombo minCombo;
- CCombo maxCombo;
-
- /**
- *
- */
- public MinMaxSection()
- {
- super();
- }
-
-
- 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();
- }
- }
-
- private void updateMinAttribute()
- {
- XSDParticle particle = null;
- Object input = getInput();
-
- if (input instanceof XSDParticleContent)
- {
- particle = getAssociatedParticle((XSDParticleContent)input);
- }
- if (particle != null)
- {
- Element element = particle.getElement();
- String newValue = ""; //$NON-NLS-1$
-
- newValue = minCombo.getText();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MINOCCURS_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length()==0)
- {
- particle.unsetMinOccurs();
- }
- try
- {
- if (newValue.equals("unbounded") || newValue.equals("*")) //$NON-NLS-1$
- {
- particle.setMinOccurs(XSDParticle.UNBOUNDED);
- }
- else
- {
- int val = Integer.parseInt(newValue);
- particle.setMinOccurs(val);
- }
- }
- catch (NumberFormatException e)
- {
-
- }
- finally
- {
- endRecording(element);
- }
- }
- }
-
- private void updateMaxAttribute()
- {
- XSDParticle particle = null;
- Object input = getInput();
-
- if (input instanceof XSDParticleContent)
- {
- particle = getAssociatedParticle((XSDParticleContent)input);
- }
- if (particle != null)
- {
- Element element = particle.getElement();
- String newValue = "";
- newValue = maxCombo.getText();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_MAXOCCURS_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length()==0)
- {
- particle.unsetMaxOccurs();
- }
- try
- {
- if (newValue.equals("unbounded") || newValue.equals("*")) //$NON-NLS-1$
- {
- particle.setMaxOccurs(XSDParticle.UNBOUNDED);
- }
- else
- {
- int val = Integer.parseInt(newValue);
- particle.setMaxOccurs(val);
- }
- }
- catch (NumberFormatException e)
- {
-
- }
- finally
- {
- endRecording(element);
- }
- }
- }
-
- /**
- * @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 createControls(Composite parent,TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- minCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- minCombo.setLayoutData(data);
- minCombo.add("0"); //$NON-NLS-1$
- minCombo.add("1"); //$NON-NLS-1$
- minCombo.addListener(SWT.Modify, this);
- minCombo.addSelectionListener(this);
-
- CLabel minLabel = getWidgetFactory().createCLabel(composite, XSDConstants.MINOCCURS_ATTRIBUTE + ":");
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(minCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(minCombo, 0, SWT.CENTER);
- minLabel.setLayoutData(data);
-
- maxCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(minCombo, +ITabbedPropertyConstants.VSPACE);
- maxCombo.setLayoutData(data);
- maxCombo.add("0"); //$NON-NLS-1$
- maxCombo.add("1"); //$NON-NLS-1$
- maxCombo.add("unbounded"); //$NON-NLS-1$
- maxCombo.addListener(SWT.Modify, this);
- maxCombo.addSelectionListener(this);
-
- CLabel maxLabel = getWidgetFactory().createCLabel(composite, XSDConstants.MAXOCCURS_ATTRIBUTE + ":");
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(maxCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(maxCombo, 0, SWT.CENTER);
- maxLabel.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (doRefresh)
- {
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
-
- setListenerEnabled(false);
- 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$
- }
- Object input = getInput();
- 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);
- }
- }
- }
- }
- }
- setListenerEnabled(true);
- }
- }
-
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
- private XSDParticle getAssociatedParticle(XSDParticleContent particleContent)
- {
- XSDConcreteComponent xsdComp = particleContent.getContainer();
- if (xsdComp instanceof XSDParticle)
- {
- return (XSDParticle)xsdComp;
- }
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSectionDescriptor.java
deleted file mode 100644
index b82b234fa3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/MinMaxSectionDescriptor.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDWildcard;
-
-public class MinMaxSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public MinMaxSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.minmax";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDElementDeclaration.class);
- list.add(XSDModelGroup.class);
- list.add(XSDWildcard.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new MinMaxSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDElementDeclaration)
-// {
-// Element element = ((XSDElementDeclaration)object).getElement();
-// Object parentNode = element.getParentNode();
-// // minOccurs and maxOccurs apply to non-global elements
-// boolean isGlobalElement = XSDDOMHelper.inputEquals(parentNode, XSDConstants.SCHEMA_ELEMENT_TAG, false);
-// return !isGlobalElement;
-// }
-// if (object instanceof XSDParticle)
-// {
-// XSDParticle particle = (XSDParticle)object;
-// Element element = particle.getElement();
-// if (inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, false))
-// {
-// return true;
-// }
-// else if (inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, true))
-// {
-// return false;
-// }
-// else
-// {
-// return true;
-// }
-// }
- if (object instanceof XSDModelGroup)
- {
- return true;
- }
- else if (object instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)object;
- if (xsdElementDeclaration.isGlobal())
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- else if (object instanceof XSDWildcard)
- {
- XSDWildcard wildcard = (XSDWildcard)object;
- if (wildcard.getContainer() instanceof XSDComplexTypeDefinition ||
- wildcard.getContainer() instanceof XSDAttributeGroupDefinition)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- }
- return false;
- }
-
- public String getAfterSection()
- {
- return "org.eclipse.wst.wsdleditor.section.reference";
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSection.java
deleted file mode 100644
index bfc6f8a503..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSection.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDModelGroup;
-import org.w3c.dom.Element;
-
-public class ModelGroupSection extends AbstractSection
-{
- CCombo modelGroupCombo;
- private String[] modelGroupComboValues = { "sequence", "choice", "all" }; //$NON-NLS-1$
-
- /**
- *
- */
- public ModelGroupSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- modelGroupCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- modelGroupCombo.setLayoutData(data);
- modelGroupCombo.addSelectionListener(this);
- modelGroupCombo.setItems(modelGroupComboValues);
-
- CLabel cLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_KIND")); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(modelGroupCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(modelGroupCombo, 0, SWT.CENTER);
- cLabel.setLayoutData(data);
-
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- setListenerEnabled(false);
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- Object input = getInput();
- if (input != null)
- {
- if (input instanceof XSDModelGroup)
- {
- XSDModelGroup particle = (XSDModelGroup)input;
- String modelType = particle.getCompositor().getName();
- modelGroupCombo.setText(modelType);
- }
- }
- setListenerEnabled(true);
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == modelGroupCombo)
- {
- Object input = getInput();
- if (input instanceof XSDModelGroup)
- {
- XSDModelGroup particle = (XSDModelGroup)input;
-
- Element element = particle.getElement();
- Element parent = (Element)element.getParentNode();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_SCOPE_CHANGE"), parent); //$NON-NLS-1$
-// changeContentModel(parent, modelGroupCombo.getText());
- particle.setCompositor(XSDCompositor.get(modelGroupCombo.getText()));
- endRecording(parent);
- refresh();
- }
- }
- }
-
-// private void changeContentModel(Element parent, String contentModel)
-// {
-// Document doc = parent.getOwnerDocument();
-// XSDDOMHelper domHelper = getDomHelper();
-//
-// String prefix = parent.getPrefix();
-// prefix = prefix == null ? "" : prefix + ":";
-//
-// Element contentModelElement = domHelper.getContentModelFromParent(parent);
-//
-// if (contentModelElement.getLocalName().equals(contentModel))
-// {
-// return; // it's already the content model
-// }
-//
-// Element newNode = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + contentModel);
-//
-// if (contentModelElement.hasChildNodes())
-// {
-// NodeList nodes = contentModelElement.getChildNodes();
-// // use clones so we don't have a refresh problem
-// for (int i = 0; i < nodes.getLength(); i++)
-// {
-// Node node = nodes.item(i);
-// newNode.appendChild(node.cloneNode(true));
-// }
-// }
-// parent.replaceChild(newNode, contentModelElement);
-// }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSectionDescriptor.java
deleted file mode 100644
index 2f91552e00..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ModelGroupSectionDescriptor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDModelGroup;
-
-public class ModelGroupSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public ModelGroupSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.modelgroup";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDModelGroup.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new ModelGroupSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDModelGroup)
- {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSection.java
deleted file mode 100644
index 95ebbe322d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSection.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-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.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalAttributeGroupRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalAttributeRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalElementRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalGroupRenamer;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.GlobalSimpleOrComplexTypeRenamer;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDComponent;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class NameSection extends AbstractSection
-{
- /**
- *
- */
- public NameSection()
- {
- super();
- }
-
- Text nameText;
-
-
- public void doHandleEvent(Event event)
- {
- if (event.widget == nameText)
- {
- Object input = getInput();
- String newValue = nameText.getText();
- if (input instanceof XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)input;
- if (newValue.length() > 0)
- {
- namedComponent.setName(newValue);
- doReferentialIntegrityCheck(namedComponent, newValue);
- }
- else
- {
- // TODO: Show error message
- }
- }
-// else if (input instanceof XSDParticle)
-// {
-// XSDParticle xsdParticle = (XSDParticle)input;
-// if (newValue.length() > 0)
-// {
-// doReferentialIntegrityCheck(xsdParticle, newValue);
-// }
-// else
-// {
-// // TODO: Show error message
-// }
-// }
- else if (input instanceof XSDAttributeDeclaration)
- {
- XSDAttributeDeclaration attribute = (XSDAttributeDeclaration)input;
- if (newValue.length() > 0)
- {
- doReferentialIntegrityCheck(attribute, newValue);
- attribute.setName(newValue);
- }
- else
- {
- // TODO: Show error message
- }
- }
- else if (input instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)input;
- XSDAttributeDeclaration attribute = attributeUse.getAttributeDeclaration();
- if (newValue.length() > 0)
- {
- doReferentialIntegrityCheck(attribute, newValue);
- attribute.setName(newValue);
- attributeUse.setAttributeDeclaration(attribute);
- }
- else
- {
- // TODO: Show error message
- }
- }
- }
- }
-
- /**
- * @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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- // data.right = new FormAttachment(95, 0);
- data.right = new FormAttachment(100, -rightMarginSpace -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- nameText.setLayoutData(data);
- nameText.addListener(SWT.Modify, this);
-
- CLabel nameLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_NAME")); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(nameText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(nameText, 0, SWT.CENTER);
- nameLabel.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (nameText.isFocusControl())
- {
- return;
- }
- setListenerEnabled(false);
- nameText.setEditable(true);
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- Object input = getInput();
- nameText.setText(""); //$NON-NLS-1$
- if (input != null)
- {
- if (input instanceof XSDComplexTypeDefinition || input instanceof XSDSimpleTypeDefinition)
- {
- XSDTypeDefinition type = (XSDTypeDefinition)input;
-
- Element element = type.getElement();
- String name = element.getAttribute(XSDConstants.NAME_ATTRIBUTE);
- if (name == null) name = "";
-
- boolean isAnonymousType = checkForAnonymousType(element);
- if (isAnonymousType)
- {
- nameText.setText("**anonymous**"); //$NON-NLS-1$
- nameText.setEditable(false);
- }
- else
- {
- nameText.setText(name);
- nameText.setEditable(true);
- }
- }
- else if (input instanceof XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)input;
- String name = namedComponent.getName();
- if (name != null)
- {
- nameText.setText(name);
- }
- }
- else if (input instanceof XSDAttributeDeclaration)
- {
- XSDAttributeDeclaration attribute = (XSDAttributeDeclaration)input;
- //String name = attribute.getName();
- Element element = attribute.getElement();
- String name = element.getAttribute(XSDConstants.NAME_ATTRIBUTE);
- if (name != null)
- {
- nameText.setText(name);
- }
- }
- else if (input instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)input;
- XSDAttributeDeclaration attribute = attributeUse.getAttributeDeclaration();
- String name = attribute.getName();
- if (name != null)
- {
- nameText.setText(name);
- }
- }
-// else if (input instanceof Element)
-// {
-// String name = ((Element)input).getAttribute(XSDConstants.NAME_ATTRIBUTE);
-// if (name == null) name = "";
-// nameText.setText(name);
-// }
- }
- setListenerEnabled(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
- private void doReferentialIntegrityCheck(XSDComponent xsdComponent, String newValue)
- {
- Element element = xsdComponent.getElement();
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_NAME_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- if (xsdComponent instanceof XSDNamedComponent)
- {
- ((XSDNamedComponent)xsdComponent).setName(newValue);
- }
-
- // now rename any references to this element
-
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDElementDeclaration && comp.getContainer().equals(xsdSchema))
- {
- GlobalElementRenamer renamer = new GlobalElementRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- endRecording(element);
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_COMPLEXTYPE_NAME_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length() > 0)
- {
- // now rename any references to this type
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDComplexTypeDefinition && comp.getContainer().equals(xsdSchema))
- {
- GlobalSimpleOrComplexTypeRenamer renamer = new GlobalSimpleOrComplexTypeRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- ((XSDNamedComponent)xsdComponent).setName(newValue);
- }
- else
- {
- element.removeAttribute(XSDConstants.NAME_ATTRIBUTE);
- }
- endRecording(element);
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_SIMPLETYPE_NAME_CHANGE"), element);
- if (validateName(newValue))
- {
- // now rename any references to this type
- if (newValue.length() > 0)
- {
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDSimpleTypeDefinition && comp.getContainer().equals(xsdSchema))
- {
- GlobalSimpleOrComplexTypeRenamer renamer = new GlobalSimpleOrComplexTypeRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
-// element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, "");
- }
- }
- endRecording(element);
-
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTE_NAME_CHANGE"), element); //$NON-NLS-1$
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDAttributeDeclaration && comp.getContainer().equals(xsdSchema))
- {
- GlobalAttributeRenamer renamer = new GlobalAttributeRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- // element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- endRecording(element);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTEGROUP_NAME_CHANGE"), element); //$NON-NLS-1$
- ((XSDNamedComponent)xsdComponent).setName(newValue);
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDAttributeGroupDefinition && comp.getContainer().equals(xsdSchema))
- {
- GlobalAttributeGroupRenamer renamer = new GlobalAttributeGroupRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- endRecording(element);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.UNIQUE_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_UNIQUE_NAME_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, ""); //$NON-NLS-1$
- }
- endRecording(element);
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.KEY_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_KEY_NAME_CHANGE"), element); //$NON-NLS-1$
- if (newValue.length() > 0)
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- }
- else
- {
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, ""); //$NON-NLS-1$
- }
- endRecording(element);
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.GROUP_ELEMENT_TAG, false))
- {
- if (validateName(newValue))
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_NAME_CHANGE"), element); //$NON-NLS-1$
- // now rename any references to this element
- if (xsdSchema != null)
- {
- XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(element);
- if (comp != null && comp instanceof XSDModelGroupDefinition && comp.getContainer().equals(xsdSchema))
- {
- GlobalGroupRenamer renamer = new GlobalGroupRenamer((XSDNamedComponent)comp, newValue);
- renamer.visitSchema(xsdSchema);
- }
- }
- element.setAttribute(XSDConstants.NAME_ATTRIBUTE, newValue);
- endRecording(element);
- }
-
- }
-
-
-
- }
-
- boolean checkForAnonymousType(Element element)
- {
- Object parentElement = (Object)element.getParentNode();
- boolean isAnonymous = false;
- if (parentElement != null)
- {
- if (XSDDOMHelper.inputEquals(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parentElement, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- isAnonymous = true;
- }
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- if (XSDDOMHelper.inputEquals(parentElement, XSDConstants.RESTRICTION_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parentElement, XSDConstants.ELEMENT_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parentElement, XSDConstants.UNION_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parentElement, XSDConstants.LIST_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(parentElement, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- isAnonymous = true;
- }
- }
- }
- return isAnonymous;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSectionDescriptor.java
deleted file mode 100644
index e4349ea343..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NameSectionDescriptor.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class NameSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor
-{
- /**
- *
- */
- public NameSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.name";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDNamedComponent.class);
- list.add(XSDAttributeUse.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new NameSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)object;
- Element element = namedComponent.getElement();
-
- if (inputEquals(element, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false) ||
- inputEquals(element, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- return false;
- }
-
- // don't want to show editable name section for ref's
- // need to show ref section with a combobox
-
- if (namedComponent instanceof XSDElementDeclaration)
- {
- if (((XSDElementDeclaration)namedComponent).isElementDeclarationReference())
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- else if (namedComponent instanceof XSDAttributeDeclaration)
- {
- if (((XSDAttributeDeclaration)namedComponent).isAttributeDeclarationReference())
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- if (element != null)
- {
- if (inputEquals(element, element.getLocalName(), true))
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- }
-// else if (object instanceof XSDParticle)
-// {
-// XSDParticle particle = (XSDParticle)object;
-// Element element = particle.getElement();
-// if (inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, false))
-// {
-// return true;
-// }
-// else if (inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, true))
-// {
-// return false;
-// }
-// else
-// {
-// return false;
-// }
-// }
- else if (object instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)object;
- Element element = attributeUse.getElement();
- if (inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- }
-
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationDescriptor.java
deleted file mode 100644
index f86fe2dcae..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationDescriptor.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDImport;
-
-public class NamespaceAndSchemaLocationDescriptor extends AbstractSectionDescriptor
-{
- NamespaceAndSchemaLocationSection namespaceAndSchemaLocationSection;
- /**
- *
- */
- public NamespaceAndSchemaLocationDescriptor()
- {
- super();
- namespaceAndSchemaLocationSection = new NamespaceAndSchemaLocationSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.namespaceAndSchemaLocationSection";
- }
-
- /* (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 namespaceAndSchemaLocationSection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDImport) {
- return true;
- }
- }
-
- return false;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationSection.java
deleted file mode 100644
index 91a1924aa6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceAndSchemaLocationSection.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.Map;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-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.wst.common.ui.internal.viewers.ResourceFilter;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.delete.XSDExternalFileCleanup;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaHelper;
-import org.eclipse.wst.xsd.ui.internal.wizards.XSDSelectIncludeFileWizard;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.impl.XSDImportImpl;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class NamespaceAndSchemaLocationSection extends CommonDirectivesSection
-{
- Text namespaceText, prefixText;
- protected String oldPrefixValue;
-
- public NamespaceAndSchemaLocationSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
-
- CLabel namespaceLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_NAMESPACE")); //$NON-NLS-1$
- namespaceText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$
- namespaceText.setEditable(false);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(namespaceText, +ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(namespaceText, 0, SWT.CENTER);
- namespaceLabel.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 110);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- namespaceText.setLayoutData(data);
-
- CLabel prefixLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_PREFIX")); //$NON-NLS-1$
- prefixText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$
- prefixText.setEditable(true);
- prefixText.addListener(SWT.Modify, this);
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(prefixText, 0);
- data.top = new FormAttachment(prefixText, 0, SWT.CENTER);
- prefixLabel.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 110);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(namespaceText, +ITabbedPropertyConstants.VSPACE);
- prefixText.setLayoutData(data);
-
- // Create Schema Location Label
- CLabel schemaLocationLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_LOCATION")); //$NON-NLS-1$
- schemaLocationText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$
-
- // Create Wizard Button
- wizardButton = getWidgetFactory().createButton(composite, "", SWT.NONE); //$NON-NLS-1$
- wizardButton.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$
- FormData buttonFormData = new FormData();
- buttonFormData.left = new FormAttachment(100, -rightMarginSpace + 2);
- buttonFormData.right = new FormAttachment(100, 0);
- buttonFormData.top = new FormAttachment(schemaLocationText, 0, SWT.CENTER);
- wizardButton.setLayoutData(buttonFormData);
- wizardButton.addSelectionListener(this);
-
- // Create Schema Location Text
- schemaLocationText.setEditable(true);
- FormData schemaLocationData = new FormData();
- schemaLocationData.left = new FormAttachment(0, 110);
- schemaLocationData.right = new FormAttachment(wizardButton, 0);
- schemaLocationData.top = new FormAttachment(prefixText, +ITabbedPropertyConstants.VSPACE);
- schemaLocationText.setLayoutData(schemaLocationData);
- schemaLocationText.addListener(SWT.Modify, this);
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(schemaLocationText, 0);
- data.top = new FormAttachment(schemaLocationText, 0, SWT.CENTER);
- schemaLocationLabel.setLayoutData(data);
-
- // error text
- errorText = new StyledText(composite, SWT.FLAT);
- errorText.setEditable(false);
- errorText.setEnabled(false);
- errorText.setText("");
-
- data = new FormData();
- data.left = new FormAttachment(schemaLocationText, 0, SWT.LEFT);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(schemaLocationText, 0);
- errorText.setLayoutData(data);
- }
-
- 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) selection);
-
- 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)
- {
- XSDConcreteComponent comp = (XSDConcreteComponent)getInput();
- if (comp instanceof XSDImport)
- {
- XSDImport xsdImport = (XSDImport)comp;
- Element importElement = comp.getElement();
-
- beginRecording(XSDEditorPlugin.getXSDString("_UI_IMPORT_CHANGE"), importElement);
-
- xsdImport.setNamespace(namespace);
- xsdImport.setSchemaLocation(schemaFileString);
- xsdImport.setResolvedSchema(externalSchema);
-
- java.util.Map map = xsdSchema.getQNamePrefixToNamespaceMap();
-
-// System.out.println("changed Import Map is " + map.values());
-// System.out.println("changed import Map keys are " + map.keySet());
-
- // 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 = getSchema().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("");
- }
-
- endRecording(importElement);
-
-// System.out.println("changed Import Map is " + map.values());
-// System.out.println("changed import Map keys are " + map.keySet());
-
- }
- refresh();
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (doRefresh)
- {
- errorText.setText("");
- setListenerEnabled(false);
-
- Element element = null;
- if (input instanceof XSDImport) {
- element = ((XSDImportImpl) 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);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return true;
- }
-
- public void doHandleEvent(Event event)
- {
- super.doHandleEvent(event);
- if (event.type == SWT.Modify)
- {
- if (event.widget == prefixText)
- {
- if (validatePrefix(prefixText.getText()) && schemaLocationText.getText().trim().length() > 0)
- {
- Element element = ((XSDConcreteComponent)getInput()).getElement();
- Map map = getSchema().getQNamePrefixToNamespaceMap();
-
- if (map.containsKey(prefixText.getText()))
- {
- setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_LABEL_PREFIX_EXISTS"));
- }
- else
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PREFIX_CHANGE"), element);
-
- Element schemaElement = getSchema().getElement();
- schemaElement.removeAttribute("xmlns:"+oldPrefixValue);
- schemaElement.setAttribute("xmlns:" + prefixText.getText(), namespaceText.getText());
- XSDSchemaHelper.updateElement(getSchema());
-
- clearErrorMessage();
- oldPrefixValue = prefixText.getText();
- endRecording(element);
-
-// System.out.println("Map is " + map.values());
-// System.out.println("Map keys are " + map.keySet());
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSection.java
deleted file mode 100644
index f32b09c5b3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSection.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDProcessContents;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class NamespaceProcessContentsSection extends AbstractSection
-{
- 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 NamespaceProcessContentsSection()
- {
- 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 createControls(Composite parent,TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
-
- namespaceCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- namespaceCombo.setLayoutData(data);
-// Iterator list = XSDNamespaceConstraintCategory.VALUES.iterator();
-// while (list.hasNext())
-// {
-// namespaceCombo.add(((XSDNamespaceConstraintCategory)list.next()).getName());
-// }
- namespaceCombo.setItems(namespaceComboValues);
- namespaceCombo.addSelectionListener(this);
-
- CLabel namespaceLabel = getWidgetFactory().createCLabel(composite, XSDConstants.NAMESPACE_ATTRIBUTE);
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(namespaceCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(namespaceCombo, 0, SWT.CENTER);
- namespaceLabel.setLayoutData(data);
-
- processContentsCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(namespaceCombo, +ITabbedPropertyConstants.VSPACE);
- 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);
-
- CLabel processContentsLabel = getWidgetFactory().createCLabel(composite, XSDConstants.PROCESSCONTENTS_ATTRIBUTE);
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(processContentsCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(processContentsCombo, 0, SWT.CENTER);
- processContentsLabel.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
-// namespaceCombo.removeSelectionListener(this);
-// processContentsCombo.removeSelectionListener(this);
- namespaceCombo.setText(""); //$NON-NLS-1$
- processContentsCombo.setText(""); //$NON-NLS-1$
- Object input = getInput();
- 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());
- }
- }
- }
- }
-
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- XSDConcreteComponent concreteComponent = (XSDConcreteComponent)getInput();
- Element element = concreteComponent.getElement();
- 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;
- }
-
- 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);
- }
- }
- refresh();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSectionDescriptor.java
deleted file mode 100644
index 87608c9ba6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceProcessContentsSectionDescriptor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDWildcard;
-
-public class NamespaceProcessContentsSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public NamespaceProcessContentsSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.namespaceprocesscontents";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDWildcard.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new NamespaceProcessContentsSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDWildcard)
- {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSection.java
deleted file mode 100644
index 468106e341..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSection.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-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.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.actions.XSDEditNamespacesAction;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.TargetNamespaceChangeHandler;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaHelper;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class NamespaceSection extends AbstractSection
-{
- IWorkbenchPart part;
- Text prefixText;
- Text targetNamespaceText;
- Button editButton;
- StyledText errorText;
- Color red;
-
- /**
- *
- */
- public NamespaceSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
-
- // Create Prefix Label
- CLabel prefixLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_PREFIX")); //$NON-NLS-1$
-
- int leftCoordinate = getStandardLabelWidth(composite,
- new String[] {XSDEditorPlugin.getXSDString("_UI_LABEL_TARGET_NAME_SPACE"), XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_PREFIX")});
-
- // Create Prefix Text
- prefixText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$
- FormData prefixTextData = new FormData();
- // prefixTextData.left = new FormAttachment(0, 115);
- prefixTextData.left = new FormAttachment(0, leftCoordinate);
- prefixTextData.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- prefixText.setLayoutData(prefixTextData);
- prefixText.addListener(SWT.Modify, this);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(prefixText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(prefixText, 0, SWT.CENTER);
- prefixLabel.setLayoutData(data);
-
- // Create TargetNamespace Label
- CLabel targetNamespaceLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_TARGET_NAME_SPACE")); //$NON-NLS-1$
-
- // Create TargetNamespace Text
- targetNamespaceText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$
-
- FormData tnsLabelData = new FormData();
- tnsLabelData.left = new FormAttachment(0, 0);
- tnsLabelData.right = new FormAttachment(targetNamespaceText, -ITabbedPropertyConstants.HSPACE);
- tnsLabelData.top = new FormAttachment(targetNamespaceText, 0, SWT.CENTER);
- targetNamespaceLabel.setLayoutData(tnsLabelData);
-
- FormData tnsTextData = new FormData();
- // tnsTextData.left = new FormAttachment(0, 115);
- tnsTextData.left = new FormAttachment(0, leftCoordinate);
- tnsTextData.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- tnsTextData.top = new FormAttachment(prefixText, +ITabbedPropertyConstants.VSPACE);
- targetNamespaceText.setLayoutData(tnsTextData);
- targetNamespaceText.addListener(SWT.Modify, this);
-
- // Advanced Button
- editButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_SECTION_ADVANCED_ATTRIBUTES") + "...", SWT.PUSH);
-
- FormData buttonFormData = new FormData();
- buttonFormData.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- buttonFormData.top = new FormAttachment(targetNamespaceText, +ITabbedPropertyConstants.VSPACE);
- editButton.setLayoutData(buttonFormData);
- editButton.addSelectionListener(this);
-
- // error text
- errorText = new StyledText(composite, SWT.FLAT);
- errorText.setEditable(false);
- errorText.setEnabled(false);
- errorText.setText("");
-
- data = new FormData();
- data.left = new FormAttachment(targetNamespaceText, 0, SWT.LEFT);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(editButton, 0);
- errorText.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (doRefresh)
- {
- // hack...open bug against properties
- if (prefixText.isDisposed() || targetNamespaceText.isDisposed())
- {
- return;
- }
- if (prefixText.isFocusControl() || targetNamespaceText.isFocusControl())
- {
- return;
- }
-
- 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("");
- }
- setListenerEnabled(true);
- }
- }
-
- public void doHandleEvent(Event event)
- {
- errorText.setText("");
- String prefixValue = prefixText.getText();
- String tnsValue = targetNamespaceText.getText();
- if (tnsValue.trim().length() == 0)
- {
- if (prefixValue.trim().length() > 0)
- {
- errorText.setText(XSDEditorPlugin.getXSDString("_ERROR_TARGET_NAMESPACE_AND_PREFIX"));
- 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)
- {
- updateNamespaceInfo(prefixValue, tnsValue);
- }
- else if (event.widget == targetNamespaceText)
- {
- updateNamespaceInfo(prefixValue, tnsValue);
- }
- }
-
- 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)
- {
- Element element = xsdSchema.getElement();
- 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$
- String xsdForXSDPrefix = xsdSchema.getSchemaForSchemaQNamePrefix();
- Map map = xsdSchema.getQNamePrefixToNamespaceMap();
-
-// For debugging
-// System.out.println("1. SW Map is " + map.values());
-// System.out.println("1. SW Map keys are " + map.keySet());
-
- // 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);
- }
- }
-
-// System.out.println("1.5 SW Map is " + map.values());
-// System.out.println("1.5 SW Map keys are " + map.keySet());
-
- // do our own referential integrity
- TargetNamespaceChangeHandler targetNamespaceChangeHandler = new TargetNamespaceChangeHandler(xsdSchema, oldNamespace, targetNamespace);
- targetNamespaceChangeHandler.resolve();
-
- XSDSchemaHelper.updateElement(xsdSchema);
-
- doc.getModel().endRecording(this);
-
-// For debugging
-// map = xsdSchema.getQNamePrefixToNamespaceMap();
-// System.out.println("2. SW Map is " + map.values());
-// System.out.println("2. SW Map keys are " + map.keySet());
- }
-
- 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(""))
- {
- 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;
- }
-
- public void dispose()
- {
- super.dispose();
- if (red != null)
- {
- red.dispose();
- red = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSectionDescriptor.java
deleted file mode 100644
index 69f2d15b1c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/NamespaceSectionDescriptor.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.impl.XSDSchemaImpl;
-
-public class NamespaceSectionDescriptor extends AbstractSectionDescriptor
-{
- NamespaceSection namespaceSection;
- /**
- *
- */
- public NamespaceSectionDescriptor()
- {
- super();
- namespaceSection = new NamespaceSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.namespaceSection";
- }
-
- /* (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 namespaceSection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDSchemaImpl) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSection.java
deleted file mode 100644
index 2b934bcd60..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSection.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.properties.XSDPropertySourceProvider;
-import org.eclipse.xsd.XSDElementDeclaration;
-
-public class OtherAttributesSection extends AbstractSection
-{
- PropertySheetPage propertySheetPage;
-
- /**
- *
- */
- public OtherAttributesSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
-
- propertySheetPage = new PropertySheetPage();
- propertySheetPage.createControl(composite);
- propertySheetPage.setPropertySourceProvider(new XSDPropertySourceProvider());
- propertySheetPage.getControl().setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (doRefresh)
- {
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- }
- propertySheetPage.refresh();
- }
-
- public void dispose()
- {
- super.dispose();
- if (propertySheetPage != null)
- {
- propertySheetPage.dispose();
- propertySheetPage = null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return true;
- }
-
- public void setInput(IWorkbenchPart part, ISelection selection)
- {
- super.setInput(part, selection);
- if (input instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)input;
- if (elementDeclaration.isElementDeclarationReference())
- {
- input = elementDeclaration.getResolvedElementDeclaration();
-
- isReadOnly = (!(elementDeclaration.getResolvedElementDeclaration().getRootContainer() == xsdSchema));
- }
- }
- // update property sheet because of new input change
- propertySheetPage.selectionChanged(part, selection);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSectionDescriptor.java
deleted file mode 100644
index ce3808b026..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/OtherAttributesSectionDescriptor.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDAnnotation;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDEnumerationFacet;
-import org.eclipse.xsd.XSDIdentityConstraintCategory;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDPatternFacet;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-
-public class OtherAttributesSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public OtherAttributesSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.otherattributes";
- }
-
- /* (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 new OtherAttributesSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.other";
- }
-
- /* (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)
- {
- if (object instanceof XSDAttributeGroupDefinition ||
- object instanceof XSDAttributeUse ||
- object instanceof XSDAttributeDeclaration ||
- object instanceof XSDEnumerationFacet ||
- object instanceof XSDPatternFacet ||
- object instanceof XSDSimpleTypeDefinition ||
- object instanceof XSDAnnotation ||
- object instanceof XSDWildcard ||
- object instanceof XSDSchemaDirective)
- {
- return false;
- }
- else if (object instanceof XSDModelGroup)
- {
- return false;
- }
- else if (object instanceof XSDElementDeclaration)
- {
-// Remove this to fix bug 3870 Element references should have the same properties as elements
-// if (((XSDElementDeclaration)object).isElementDeclarationReference())
-// {
-// return false;
-// }
- return true;
- }
- else if (object instanceof XSDModelGroupDefinition)
- {
- if (((XSDModelGroupDefinition)object).isModelGroupDefinitionReference())
- {
- return false;
- }
- return false;
- }
- else if (object instanceof XSDIdentityConstraintDefinition)
- {
- XSDIdentityConstraintDefinition constraint = (XSDIdentityConstraintDefinition)object;
- XSDIdentityConstraintCategory category = constraint.getIdentityConstraintCategory();
- if (category.getValue() == XSDIdentityConstraintCategory.KEYREF)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- return true;
- }
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSection.java
deleted file mode 100644
index 9a0255c0eb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSection.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-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.events.SelectionEvent;
-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.Text;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.wizards.RegexWizard;
-import org.eclipse.xsd.XSDPatternFacet;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class PatternSection extends AbstractSection
-{
- /**
- *
- */
- public PatternSection()
- {
- super();
- }
-
- Text patternText;
- Button button;
-
- /**
- * @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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
-
- super.createControls(parent, factory);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- patternText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- CLabel nameLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_VALUE") + ":"); //$NON-NLS-1$
- button = getWidgetFactory().createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
- button.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$
-
- patternText.addListener(SWT.Modify, this);
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(patternText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(button, 0, SWT.CENTER);
- nameLabel.setLayoutData(data);
-
- button.addSelectionListener(this);
- data = new FormData();
- data.left = new FormAttachment(100, -rightMarginSpace + 2);
- data.right = new FormAttachment(100,0);
- data.top = new FormAttachment(patternText, 0, SWT.CENTER);
- button.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(button, 0);
- patternText.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- setListenerEnabled(false);
- Object input = getInput();
- patternText.setText(""); //$NON-NLS-1$
- if (input != null)
- {
- Element element = null;
- if (input instanceof XSDPatternFacet)
- {
- element = ((XSDPatternFacet)input).getElement();
- }
- if (element != null)
- {
- String result = element.getAttribute(XSDConstants.VALUE_ATTRIBUTE);
- if (result != null)
- {
- patternText.setText(result);
- }
- }
- }
- setListenerEnabled(true);
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == button)
- {
- Shell shell = Display.getCurrent().getActiveShell();
- Element element = ((XSDPatternFacet)getInput()).getElement();
-
- String initialValue = element.getAttribute(XSDConstants.VALUE_ATTRIBUTE);
- if (initialValue == null)
- {
- 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();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_PATTERN_VALUE_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.VALUE_ATTRIBUTE, newPattern);
- ((XSDPatternFacet)getInput()).setLexicalValue(newPattern);
- endRecording(element);
- }
-
- refresh();
- }
- }
-
- public void doHandleEvent(Event event)
- {
- if (event.widget == patternText)
- {
- XSDPatternFacet pattern = (XSDPatternFacet)getInput();
-
- String newValue = patternText.getText();
- if (newValue.length() > 0)
- {
- pattern.setLexicalValue(newValue);
- }
- }
-
- }
-
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSectionDescriptor.java
deleted file mode 100644
index 68219c711c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/PatternSectionDescriptor.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDPatternFacet;
-
-public class PatternSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public PatternSectionDescriptor()
- {
- super();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.pattern";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDPatternFacet.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new PatternSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDPatternFacet)
- {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSection.java
deleted file mode 100644
index 574d548978..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSection.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDParticleContent;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class ReferenceSection extends AbstractSection
-{
- protected CCombo componentNameCombo;
- Button button;
- IEditorPart editorPart;
- CLabel refLabel;
-
- /**
- * @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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- componentNameCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- componentNameCombo.addSelectionListener(this);
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 1);
- componentNameCombo.setLayoutData(data);
-
- refLabel = getWidgetFactory().createCLabel(composite, XSDConstants.REF_ATTRIBUTE + ":"); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(componentNameCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(componentNameCombo, 0, SWT.CENTER);
- refLabel.setLayoutData(data);
- }
-
- public void setInput(IWorkbenchPart part, ISelection selection)
- {
- super.setInput(part, selection);
-
- Object obj = getInput();
- TypesHelper helper = new TypesHelper(xsdSchema);
- List items = new ArrayList();
- if (obj instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)obj;
- if (elementDeclaration.isElementDeclarationReference())
- {
- items = helper.getGlobalElements();
-// minimumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MINIMUM"));
-// WorkbenchHelp.setHelp(minimumField, XSDEditorContextIds.XSDE_ELEMENT_REF_MINIMUM);
-// maximumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MAXIMUM"));
-// WorkbenchHelp.setHelp(maximumField, XSDEditorContextIds.XSDE_ELEMENT_REF_MAXIMUM);
- }
- }
- else if (obj instanceof XSDAttributeDeclaration)
- {
- items = helper.getGlobalAttributes();
- }
- else if (obj instanceof XSDModelGroupDefinition)
- {
- XSDModelGroupDefinition group = (XSDModelGroupDefinition)obj;
- if (group.isModelGroupDefinitionReference())
- {
- items = helper.getModelGroups();
- // Need tooltip for Group Ref
-// minimumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MINIMUM"));
-// WorkbenchHelp.setHelp(minimumField, XSDEditorContextIds.XSDE_GROUP_REF_MINIMUM);
-// maximumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MAXIMUM"));
-// WorkbenchHelp.setHelp(maximumField, XSDEditorContextIds.XSDE_GROUP_REF_MAXIMUM);
- }
- }
- else if (obj instanceof XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)obj;
- Element element = namedComponent.getElement();
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true))
- {
- items = helper.getGlobalAttributeGroups();
-// WorkbenchHelp.setHelp(client, XSDEditorContextIds.XSDE_ATTRIBUTE_GROUP_REF_DESIGN_VIEW);
-// WorkbenchHelp.setHelp(refCombo, XSDEditorContextIds.XSDE_ATTRIBUTE_GROUP_REF_NAME);
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, true))
- {
- items = helper.getGlobalElements();
-// minimumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MINIMUM"));
-// WorkbenchHelp.setHelp(minimumField, XSDEditorContextIds.XSDE_ELEMENT_REF_MINIMUM);
-// maximumField.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_ELEMENT_MAXIMUM"));
-// WorkbenchHelp.setHelp(maximumField, XSDEditorContextIds.XSDE_ELEMENT_REF_MAXIMUM);
- }
- }
- else if (obj instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)obj;
- Element element = attributeUse.getElement();
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- items = helper.getGlobalAttributes();
-// WorkbenchHelp.setHelp(client, XSDEditorContextIds.XSDE_ATTRIBUTE_REF_DESIGN_VIEW);
-// WorkbenchHelp.setHelp(refCombo, XSDEditorContextIds.XSDE_ATTRIBUTE_REF_NAME);
- }
- }
- items.add(0, "");
- int size = items.size();
- String [] st = new String[size];
- System.arraycopy(items.toArray(), 0, st, 0, size);
- componentNameCombo.setItems(st);
-
- st = null;
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- if (doRefresh)
- {
- setListenerEnabled(false);
- // componentNameCombo.removeListener(SWT.Modify, this);
- Object input = getInput();
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
-
- if (input instanceof XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)getInput();
- Element element = namedComponent.getElement();
- if (element != null)
- {
- String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE);
- if (attrValue == null)
- {
- attrValue = "";
- }
- componentNameCombo.setText(attrValue);
- }
- }
- else if (input instanceof XSDParticleContent)
- {
- XSDParticleContent particle = (XSDParticleContent)input;
- Element element = particle.getElement();
- String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE);
- if (attrValue == null)
- {
- attrValue = "";
- }
- componentNameCombo.setText(attrValue);
- }
- else if (input instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)getInput();
- Element element = attributeUse.getElement();
- String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE);
- if (attrValue == null)
- {
- attrValue = "";
- }
- componentNameCombo.setText(attrValue);
- }
-
- setListenerEnabled(true);
- // componentNameCombo.addListener(SWT.Modify, this);
- }
- }
-
-
- public void widgetSelected(SelectionEvent e)
- {
- Object input = getInput();
- if (e.widget == componentNameCombo)
- {
- String newValue = componentNameCombo.getText();
- if (input instanceof XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)getInput();
- Element element = namedComponent.getElement();
-
- if (namedComponent instanceof XSDElementDeclaration)
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_REF_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue);
- endRecording(element);
- }
- else if (namedComponent instanceof XSDAttributeDeclaration)
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTEGROUP_REF_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue);
- endRecording(element);
-
- }
- else if (namedComponent instanceof XSDAttributeGroupDefinition)
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTEGROUP_REF_CHANGE"), element); //$NON-NLS-1$
- // element.setAttribute(XSDConstants.REF_ATTRIBUTE, (String) value);
- XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition)namedComponent;
- Iterator iter = xsdSchema.getAttributeGroupDefinitions().iterator();
- while (iter.hasNext())
- {
- XSDAttributeGroupDefinition def = (XSDAttributeGroupDefinition)iter.next();
- if (def.getQName(xsdSchema).equals(componentNameCombo.getText()))
- {
- attrGroup.setResolvedAttributeGroupDefinition(def);
- attrGroup.setName(componentNameCombo.getText());
- break;
- }
- }
- endRecording(element);
- }
- else if (namedComponent instanceof XSDModelGroupDefinition)
- {
- beginRecording(XSDEditorPlugin.getXSDString("_UI_GROUP_REF_CHANGE"), element); //$NON-NLS-1$
- element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue);
- endRecording(element);
- }
- }
- else if (input instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)getInput();
- Element element = attributeUse.getElement();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ATTRIBUTE_USE_CHANGE"), element); //$NON-NLS-1$
- Iterator iter = xsdSchema.getAttributeDeclarations().iterator();
- while (iter.hasNext())
- {
- XSDAttributeDeclaration attr = (XSDAttributeDeclaration)iter.next();
- if (attr.getQName(xsdSchema).equals(newValue))
- {
- attributeUse.setAttributeDeclaration(attr);
- element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue);
- break;
- }
- }
-
- endRecording(element);
- }
- }
- }
-
- public void setEditorPart(IEditorPart editorPart)
- {
- this.editorPart = editorPart;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSectionDescriptor.java
deleted file mode 100644
index 8c11abbd14..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ReferenceSectionDescriptor.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class ReferenceSectionDescriptor extends AbstractSectionDescriptor implements ISectionDescriptor
-{
- ReferenceSection referenceSection;
-
- /**
- *
- */
- public ReferenceSectionDescriptor()
- {
- super();
- this.referenceSection = new ReferenceSection();
- }
-
-
- /**
- *
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.wsdleditor.section.reference";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDNamedComponent.class);
- list.add(XSDElementDeclaration.class);
- list.add(XSDModelGroupDefinition.class);
- list.add(XSDAttributeDeclaration.class);
- list.add(XSDAttributeUse.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return referenceSection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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)
- {
- if (part != null)
- {
- referenceSection.setEditorPart(part.getSite()
- .getWorkbenchWindow()
- .getActivePage()
- .getActiveEditor());
- }
- Object object = null;
- if (selection instanceof StructuredSelection)
- {
- StructuredSelection structuredSelection = (StructuredSelection)selection;
- object = structuredSelection.getFirstElement();
- if (object instanceof XSDNamedComponent)
- {
- XSDNamedComponent namedComponent = (XSDNamedComponent)object;
- Element element = namedComponent.getElement();
- if (element == null)
- {
- return false;
- }
- if (inputEquals(element, element.getLocalName(), true))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else if (object instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)object;
- if (elementDeclaration.isElementDeclarationReference())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else if (object instanceof XSDAttributeDeclaration)
- {
- XSDAttributeDeclaration attr = (XSDAttributeDeclaration)object;
- if (attr.isAttributeDeclarationReference())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else if (object instanceof XSDModelGroupDefinition)
- {
- XSDModelGroupDefinition group = (XSDModelGroupDefinition)object;
- if (group.isModelGroupDefinitionReference())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else if (object instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)object;
- Element element = attributeUse.getElement();
- if (inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationDescriptor.java
deleted file mode 100644
index ca2200d3d5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationDescriptor.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDRedefine;
-
-public class SchemaLocationDescriptor extends AbstractSectionDescriptor
-{
- SchemaLocationSection schemaLocationSection;
- /**
- *
- */
- public SchemaLocationDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.schemaLocationSection";
- }
-
- /* (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 schemaLocationSection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDInclude || object instanceof XSDRedefine) {
- schemaLocationSection = new SchemaLocationSection();
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationSection.java
deleted file mode 100644
index 6f2d1df4f8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SchemaLocationSection.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-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.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-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.wst.common.ui.internal.viewers.ResourceFilter;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xsd.ui.internal.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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
-
- int leftCoordinate = getStandardLabelWidth(composite,
- new String[] {XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_LOCATION")});
-
- // Create Schema Location Label
- CLabel schemaLocationLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_LOCATION")); //$NON-NLS-1$
-
- // Create Schema Location Text
- schemaLocationText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$
-
- // Create Wizard Button
- wizardButton = getWidgetFactory().createButton(composite, "", SWT.NONE); //$NON-NLS-1$
-
- wizardButton.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$
- FormData buttonFormData = new FormData();
- buttonFormData.left = new FormAttachment(100, -rightMarginSpace + 2);
- buttonFormData.right = new FormAttachment(100,0);
- buttonFormData.top = new FormAttachment(schemaLocationText, 0, SWT.CENTER);
- wizardButton.setLayoutData(buttonFormData);
- wizardButton.addSelectionListener(this);
-
- schemaLocationText.setEditable(true);
- FormData schemaLocationData = new FormData();
- schemaLocationData.left = new FormAttachment(0, leftCoordinate);
- schemaLocationData.right = new FormAttachment(wizardButton, 0);
- schemaLocationText.setLayoutData(schemaLocationData);
- schemaLocationText.addListener(SWT.Modify, this);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(schemaLocationText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(schemaLocationText, 0, SWT.CENTER);
- schemaLocationLabel.setLayoutData(data);
-
- // error text
- errorText = new StyledText(composite, SWT.FLAT);
- errorText.setEditable(false);
- errorText.setEnabled(false);
- errorText.setText("");
-
- data = new FormData();
- data.left = new FormAttachment(schemaLocationText, 0, SWT.LEFT);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(schemaLocationText, 0);
- errorText.setLayoutData(data);
- }
-
- public void widgetSelected(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) selection);
-
- 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("");
- 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()
- {
- if (doRefresh)
- {
- 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 = "";
- }
- 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/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentBaseTypeOptionsDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentBaseTypeOptionsDialog.java
deleted file mode 100644
index 2aa1a5094e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentBaseTypeOptionsDialog.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class SimpleContentBaseTypeOptionsDialog extends TypesDialog
-{
- /**
- * @param parentShell
- * @param element
- * @param id
- * @param xsdSchema
- */
- public SimpleContentBaseTypeOptionsDialog(Shell parentShell, Element element, Object id, XSDSchema xsdSchema)
- {
- super(parentShell, element, id, xsdSchema);
- showAnonymous = false;
- }
-
- protected void ok()
- {
- TableItem[] items = table.getItems();
- int selection = table.getSelectionIndex();
- if (items != null && items.length > 0 && selection >= 0)
- {
- typeObject = items[selection].getData();
- }
- }
-
-
- public void handleSetInput()
- {
- XSDDOMHelper domHelper = new XSDDOMHelper();
- typeSection.getSimpleType().setSelection(false);
- typeSection.getUserSimpleType().setSelection(false);
- typeSection.getUserComplexType().setSelection(false);
- showAnonymous = false;
- if (element != null)
- {
- String derivedBy = domHelper.getDerivedByName(element);
- String baseType = domHelper.getBaseType(element);
- boolean derivedByRestriction = true;
-
- if (XSDDOMHelper.inputEquals(element, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- typeSection.getSimpleType().setEnabled(false);
- typeSection.getUserSimpleType().setEnabled(false);
- typeSection.getUserComplexType().setSelection(true);
-
- previousType = 3;
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- typeSection.getSimpleType().setEnabled(false);
- typeSection.getUserSimpleType().setEnabled(false);
-
- if (derivedBy.equals("restriction"))
- {
- typeSection.getSimpleType().setEnabled(false);
- typeSection.getUserSimpleType().setEnabled(false);
- typeSection.getUserComplexType().setEnabled(true);
- }
- else if (derivedBy.equals("extension"))
- {
- derivedByRestriction = false;
- typeSection.getSimpleType().setEnabled(true);
- typeSection.getUserSimpleType().setEnabled(true);
- typeSection.getUserComplexType().setEnabled(true);
- }
- }
-
- if (derivedBy != null)
- {
- if (baseType != null && !baseType.equals(""))
- {
- Element parent = (Element)element.getParentNode();
- XSDConcreteComponent component = null;
- if (parent != null)
- {
- component = xsdSchema.getCorrespondingComponent(parent);
- }
- XSDTypeDefinition baseTypeDefinition = null;
- if (component instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)component;
- baseTypeDefinition = complexType.getBaseTypeDefinition();
- }
-
- if (typeSection.getBuiltInTypeNamesList(xsdSchema).contains(baseType) && !derivedByRestriction)
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- int i = typeSection.getBuiltInTypeNamesList(xsdSchema).indexOf(baseType);
- table.setSelection(i);
- previousType = 1;
- }
- else if (baseTypeDefinition instanceof XSDSimpleTypeDefinition && !derivedByRestriction)
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- int i = typeSection.getUserSimpleTypeNamesList(xsdSchema).indexOf(baseType);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 2;
- }
- else if (baseTypeDefinition instanceof XSDComplexTypeDefinition)
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- int i = typeSection.getUserComplexTypeNamesList(xsdSchema).indexOf(baseType);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 3;
- }
- }
- else
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- table.setSelection(0);
- }
- }
-
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentUnionMemberTypesDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentUnionMemberTypesDialog.java
deleted file mode 100644
index c58a7aa7c3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleContentUnionMemberTypesDialog.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.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.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 == Dialog.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(" ");
- }
- }
- 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);
-
- Label instructions = new Label(client, SWT.LEFT | SWT.WRAP);
- instructions.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_SELECT_MEMBERTYPES"));
-
- 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"));
-
- 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(">");
- addButton.addSelectionListener(this);
- removeButton = new Button(buttonComposite, SWT.PUSH);
- removeButton.setText("<");
- 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"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserSimpleType(boolean showAnonymous)
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- 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"));
- 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/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSection.java
deleted file mode 100644
index c69a73a21d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSection.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.Dialog;
-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.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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-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.dialogs.types.xsd.XSDComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDSetTypeHelper;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-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;
-
-
-public class SimpleTypeSection extends AbstractSection
-{
- CCombo varietyCombo;
- Text typesText;
- CLabel typesLabel;
- Button button;
-
- /**
- *
- */
- public SimpleTypeSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- varietyCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT);
- CLabel label = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_VARIETY")); //$NON-NLS-1$
-
- List list = XSDVariety.VALUES;
- Iterator iter = list.iterator();
- while (iter.hasNext())
- {
- varietyCombo.add(((XSDVariety)iter.next()).getName());
- }
- varietyCombo.addSelectionListener(this);
-
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, 0);
- varietyCombo.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(varietyCombo, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(varietyCombo, 0, SWT.CENTER);
- label.setLayoutData(data);
-
- typesText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- typesLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES")); //$NON-NLS-1$
- button = getWidgetFactory().createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
- button.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$
-
- typesText.addListener(SWT.Modify, this);
-
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, -rightMarginSpace - ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(button, 0, SWT.CENTER);
- typesText.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(typesText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(button, 0, SWT.CENTER);
- typesLabel.setLayoutData(data);
-
- button.addSelectionListener(this);
- data = new FormData();
- data.left = new FormAttachment(typesText, 0);
- data.right = new FormAttachment(100,0);
- data.top = new FormAttachment(varietyCombo, +ITabbedPropertyConstants.VSPACE);
- button.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- setListenerEnabled(false);
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- Object input = getInput();
- varietyCombo.setText(""); //$NON-NLS-1$
- typesText.setText(""); //$NON-NLS-1$
- typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON")); //$NON-NLS-1$
- if (input != null)
- {
- if (input instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)input;
-
- Element simpleTypeElement = st.getElement();
- Element element = null;
- String variety = st.getVariety().getName();
-
- int intVariety = st.getVariety().getValue();
-
- if (variety != null)
- {
- varietyCombo.setText(variety);
- if (intVariety == XSDVariety.ATOMIC)
- {
- element = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.RESTRICTION_ELEMENT_TAG);
-// if (element == null)
-// {
-// element = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.EXTENSION_ELEMENT_TAG);
-// if (element == null) return;
-// }
-
- if (element == null)
- {
- varietyCombo.setText(XSDEditorPlugin.getXSDString("_UI_NO_TYPE")); // "Select a simple type variety"); //$NON-NLS-1$
- }
- else
- {
- String result = element.getAttribute(XSDConstants.BASE_ATTRIBUTE);
- if (result == null)
- {
- typesText.setText("**anonymous**"); //$NON-NLS-1$
- }
- else
- {
- typesText.setText(result);
- }
- }
- typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON")); //$NON-NLS-1$
- }
- else if (intVariety == XSDVariety.LIST)
- {
- element = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.LIST_ELEMENT_TAG);
- if (element != null)
- {
- String result = element.getAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE);
- if (result == null)
- {
- typesText.setText("**anonymous**"); //$NON-NLS-1$
- }
- else
- {
- typesText.setText(result);
- }
- }
- typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE")); //$NON-NLS-1$
- }
- else if (intVariety == XSDVariety.UNION)
- {
- Element unionElement = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.UNION_ELEMENT_TAG);
- if (unionElement != null)
- {
- String memberTypes = unionElement.getAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE);
- if (memberTypes != null)
- {
- typesText.setText(memberTypes);
- }
- }
- typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES")); //$NON-NLS-1$
- }
- }
- }
- }
- setListenerEnabled(true);
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e)
- {
- Object input = getInput();
- 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();
-
- 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)domHelper.getChildNode(simpleTypeElement, XSDConstants.LIST_ELEMENT_TAG);
-// 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)domHelper.getChildNode(simpleTypeElement, XSDConstants.RESTRICTION_ELEMENT_TAG);
- if (derivedByElement == null)
- {
- derivedByElement = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.EXTENSION_ELEMENT_TAG);
- if (derivedByElement == null) return;
- }
- 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;
- }
- }
- else 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 = (Element)domHelper.getChildNode(element, XSDConstants.UNION_ELEMENT_TAG);
- unionElement.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, newValue);
-
- if (newValue.length() > 0)
- {
- unionElement.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, newValue);
- }
- else
- {
- unionElement.removeAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE);
- }
- endRecording(unionElement);
- if (doRefresh)
- {
- refresh();
- }
- }
- return;
- }
- else
- {
-// dialog = new TypesDialog(shell, element, "type", xsdSchema); //$NON-NLS-1$
- property = "type";
- }
- }
- else
- {
-// dialog = new TypesDialog(shell, element, "type", xsdSchema); //$NON-NLS-1$
- 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)getInput();
- st.setElement(element);
- updateSimpleTypeFacets();
- }
- endRecording(element);
- }
- if (doRefresh)
- {
- refresh();
- }
- }
-
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
-
- protected boolean addCreateElementActionIfNotExist(String elementTag, String label, Element parent, Node relativeNode)
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)getInput();
- 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((Element)child, elementTag, isRef))
- {
- targetNode = (Element)child;
- break;
- }
- }
- }
- return targetNode;
- }
-
- protected String getBuiltInStringQName()
- {
- String stringName = "string"; //$NON-NLS-1$
-
- if (getSchema() != null)
- {
- String schemaForSchemaPrefix = getSchema().getSchemaForSchemaQNamePrefix();
- if (schemaForSchemaPrefix != null && schemaForSchemaPrefix.length() > 0)
- {
- String prefix = getSchema().getSchemaForSchemaQNamePrefix();
- if (prefix != null && prefix.length() > 0)
- {
- stringName = prefix + ":" + stringName; //$NON-NLS-1$
- }
- }
- }
- return stringName;
- }
-
- private void updateSimpleTypeFacets()
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)getInput();
- Element simpleTypeElement = st.getElement();
- Element derivedByElement = getDomHelper().getDerivedByElement(simpleTypeElement);
- 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$
- 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);
- }
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSectionDescriptor.java
deleted file mode 100644
index bd02dee07f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeSectionDescriptor.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-
-
-public class SimpleTypeSectionDescriptor extends AbstractSectionDescriptor
-{
-
- /**
- *
- */
- public SimpleTypeSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.simpletype";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDSimpleTypeDefinition.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new SimpleTypeSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- public String getAfterSection()
- {
- return "org.eclipse.wst.xsdeditor.section.name";
- }
-
- /* (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 XSDSimpleTypeDefinition)
- {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSection.java
deleted file mode 100644
index a4496dce5e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSection.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.SelectionEvent;
-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.Text;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class SimpleTypeUnionSection extends AbstractSection
-{
- Text memberTypesText;
- Button button;
-
- /**
- *
- */
- public SimpleTypeUnionSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- memberTypesText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- CLabel label = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES")); //$NON-NLS-1$
- button = getWidgetFactory().createButton(composite, "...", SWT.PUSH); //$NON-NLS-1$
-
- memberTypesText.addListener(SWT.Modify, this);
-// memberTypesText.addSelectionListener(this);
-
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(95, 0);
- data.top = new FormAttachment(button, 0, SWT.CENTER);
- memberTypesText.setLayoutData(data);
-
-
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(memberTypesText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(button, 0, SWT.CENTER);
- label.setLayoutData(data);
-
- button.addSelectionListener(this);
- data = new FormData();
- data.left = new FormAttachment(memberTypesText, +ITabbedPropertyConstants.HSPACE);
- data.right = new FormAttachment(100,0);
- // data.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
- data.top = new FormAttachment(0,0);
- button.setLayoutData(data);
-
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- setListenerEnabled(false);
- Object input = getInput();
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- memberTypesText.setText(""); //$NON-NLS-1$
- if (input != null)
- {
- Element element = null;
- if (input instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)input;
- element = st.getElement();
- Element unionElement = (Element)domHelper.getChildNode(element, XSDConstants.UNION_ELEMENT_TAG);
- String memberTypes = unionElement.getAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE);
- if (memberTypes != null)
- {
- memberTypesText.setText(memberTypes);
- }
-
-// StringBuffer buf = new StringBuffer();
-// if (st.getMemberTypeDefinitions().size() > 0)
-// {
-// for (Iterator i = st.getMemberTypeDefinitions().iterator(); i.hasNext(); )
-// {
-// String name = ((XSDSimpleTypeDefinition)i.next()).getQName(getSchema());
-// if (name != null)
-// {
-// buf.append(name);
-// buf.append(" ");
-// }
-// }
-// }
-// memberTypesText.setText(buf.toString());
- }
- }
- setListenerEnabled(true);
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == button)
- {
- Shell shell = Display.getCurrent().getActiveShell();
-
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)getInput();
- Element element = st.getElement();
- SimpleContentUnionMemberTypesDialog dialog = new SimpleContentUnionMemberTypesDialog(shell, st);
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- int result = dialog.open();
- if (result == Window.OK)
- {
- String newValue = dialog.getResult();
- beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES_CHANGE"), element); //$NON-NLS-1$
- Element unionElement = (Element)domHelper.getChildNode(element, XSDConstants.UNION_ELEMENT_TAG);
- 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();
- }
- }
-
- public void doHandleEvent(Event event)
- {
- if (event.widget == memberTypesText)
- {
- }
-
- }
-
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSectionDescriptor.java
deleted file mode 100644
index b1338ae603..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/SimpleTypeUnionSectionDescriptor.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-
-public class SimpleTypeUnionSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public SimpleTypeUnionSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.simpletypeunion";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDSimpleTypeDefinition.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new SimpleTypeUnionSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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)
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TextChangeHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TextChangeHelper.java
deleted file mode 100644
index 0df6ffaef4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TextChangeHelper.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-public abstract class TextChangeHelper implements Listener
-{
- private boolean nonUserChange;
-
- /**
- * Marks the start of a programmatic change to the widget contents.
- * Clients must call startNonUserChange() before directly setting
- * the widget contents to avoid unwanted lifecycle events.
- * @throws IllegalArgumentException if a programmatic change is
- * already in progress.
- */
- public void startNonUserChange() {
- if (nonUserChange)
- throw new IllegalStateException("we already started a non user change");//$NON-NLS-1$
- nonUserChange = true;
- }
-
- /**
- * Clients who call startNonUserChange() should call
- * finishNonUserChange() as soon as possible after the change is done.
- * @throws IllegalArgumentException if no change is in progress.
- */
- public void finishNonUserChange() {
- if (!nonUserChange)
- throw new IllegalStateException("we are not in a non user change");//$NON-NLS-1$
- nonUserChange = false;
- }
-
- /**
- * Returns true if a programmatic change is in progress.
- */
- public boolean isNonUserChange() {
- return nonUserChange;
- }
-
- /**
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
- */
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.KeyDown :
- if (event.character == SWT.CR)
- textChanged((Control)event.widget);
- break;
- case SWT.FocusOut :
- textChanged((Control)event.widget);
- break;
- }
- }
-
- /**
- * Abstract method notified when a text field has been changed.
- * @param control
- */
- public abstract void textChanged(Control control);
-
- /**
- * Registers this helper with the given control to listen for events
- * which indicate that a change is in progress (or done).
- */
- public void startListeningTo(Control control) {
- control.addListener(SWT.FocusOut, this);
- control.addListener(SWT.Modify, this);
- }
-
- /**
- * Registers this helper with the given control to listen for the
- * Enter key. When Enter is pressed, the change is considered done
- * (this is only appropriate for single-line Text widgets).
- */
- public void startListeningForEnter(Control control) {
- // NOTE: KeyDown rather than KeyUp, because of similar usage in CCombo.
- control.addListener(SWT.KeyDown, this);
- }
-
- /**
- * Unregisters this helper from a control previously passed to
- * startListeningTo() and/or startListeningForEnter().
- */
- public void stopListeningTo(Control control) {
- control.removeListener(SWT.FocusOut, this);
- control.removeListener(SWT.Modify, this);
- control.removeListener(SWT.KeyDown, this);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java
deleted file mode 100644
index 1454b4d2eb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java
+++ /dev/null
@@ -1,721 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-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.swt.widgets.Text;
-import org.eclipse.wst.xsd.ui.internal.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.util.XSDDOMHelper;
-import org.eclipse.wst.xsd.ui.internal.widgets.TypeSection;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public class TypesDialog extends Dialog implements SelectionListener, Listener
-{
- XSDSchema xsdSchema;
- String property;
-
- /**
- * @param parentShell
- */
- public TypesDialog(Shell parentShell, Element element, Object id, XSDSchema xsdSchema)
- {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.element = element;
- this.property = (String)id;
- this.element = element;
- this.xsdSchema = xsdSchema;
-
- if (XSDDOMHelper.inputEquals(element, XSDConstants.ELEMENT_ELEMENT_TAG, false))
- {
- showComplexTypes = true;
- }
- else if (XSDDOMHelper.inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(element, XSDConstants.LIST_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- showComplexTypes = false;
- }
- }
-
- String type;
- Object typeObject;
- Text textField;
- Table table;
- TableColumn tableColumn;
- Element element;
-
- boolean showComplexTypes = true;
- TypeSection typeSection;
- boolean showAnonymous = true;
- String previousStringType = "";
- boolean isAnonymous;
- int previousType;
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.OK)
- {
- type = table.getItem(table.getSelectionIndex()).getText();
- ok();
- }
- super.buttonPressed(buttonId);
- }
-
- public Object getTypeObject() { return typeObject; }
- public String getType() { return type; }
-
- //
- // Create the controls
- //
- public Control createDialogArea(Composite parent)
- {
- Composite client = (Composite)super.createDialogArea(parent);
- getShell().setText(XSDEditorPlugin.getXSDString("_UI_LABEL_AVAILABLE_TYPES"));
-
- typeObject = null;
-
- GridLayout gl = new GridLayout(1, true);
-// gl.marginHeight = 0;
-// gl.marginWidth = 0;
-// gl.horizontalSpacing = 0;
-// gl.verticalSpacing = 0;
- client.setLayout(gl);
-
- GridData gd = new GridData();
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.FILL;
- gd.horizontalIndent = 0;
- client.setLayoutData(gd);
-
- typeSection = new TypeSection(client);
- typeSection.setShowUserComplexType(showComplexTypes);
-
- typeSection.createClient(client);
- typeSection.getSimpleType().setSelection(false);
- typeSection.getSimpleType().addSelectionListener(this);
- typeSection.getUserSimpleType().addSelectionListener(this);
- if (showComplexTypes)
- {
- typeSection.getUserComplexType().addSelectionListener(this);
- }
-
- textField = ViewUtility.createTextField(client, 50);
- textField.addListener(SWT.Modify, this);
- ViewUtility.createVerticalFiller(client, 0);
-
- table = new Table(client,
- SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- table.setHeaderVisible(false);
- table.setLinesVisible(true);
- table.addSelectionListener(this);
-
- GridData gd2 = new GridData();
- gd2.grabExcessHorizontalSpace = true;
- gd2.grabExcessVerticalSpace = true;
- gd2.horizontalAlignment = GridData.FILL;
- gd2.verticalAlignment = GridData.FILL;
- gd2.heightHint = 200;
- table.setLayoutData(gd2);
- table.addListener(SWT.Resize, this);
-
- tableColumn = new TableColumn(table, SWT.LEFT);
-// tableColumn.setImage(XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"));
- tableColumn.setResizable(true);
- tableColumn.setWidth(200);
-
- // Fill table and select input type
- handleSetInput();
-
- return client;
- }
-
- public void handleEvent(Event event)
- {
- if (event.type == SWT.Resize && event.widget == table) {
- tableColumn.setWidth(table.getSize().x);
- }
- else if (event.type == SWT.Modify && event.widget == textField) {
- boolean showAll = false;
- String inputString = textField.getText();
-
- if (inputString.equals("")) {
- showAll = true;
- }
- else {
- inputString = insertString("*", ".", inputString);
- inputString = insertString("?", ".", inputString);
- inputString = inputString + ".*";
- }
-
- try {
- if (typeSection.getSimpleType().getSelection())
- {
- if (showAll) {
- populateBuiltInType();
- }
- else {
- populateBuiltInType(inputString);
- }
- }
- else if (typeSection.getUserComplexType().getSelection())
- {
- if (showAll) {
- populateUserComplexType();
- }
- else {
- populateUserComplexType(inputString);
- }
- }
- else if (typeSection.getUserSimpleType().getSelection())
- {
- if (showAll) {
- populateUserSimpleType();
- }
- else {
- populateUserSimpleType(inputString);
- }
- }
- }
- catch (Exception e) {
- // Do nothing
- }
- }
-
- setEnabledState();
- }
-
- private void setEnabledState() {
- if (table.getSelectionIndex() != -1) {
- this.getButton(IDialogConstants.OK_ID).setEnabled(true);
- }
- else {
- this.getButton(IDialogConstants.OK_ID).setEnabled(false);
- }
- }
-
- private String insertString(String target, String newString, String string) {
- StringBuffer stringBuffer = new StringBuffer(string);
-
- int index = stringBuffer.indexOf(target);
- while (index != -1) {
- stringBuffer = stringBuffer.insert(index, newString);
- index = stringBuffer.indexOf(target, index + newString.length() + target.length());
- }
-
- return stringBuffer.toString();
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == typeSection.getSimpleType() && typeSection.getSimpleType().getSelection())
- {
- if (textField.getText().equals("")) {
- populateBuiltInType();
- }
- else {
- populateBuiltInType(textField.getText());
- }
- }
- else if (e.widget == typeSection.getUserComplexType() && typeSection.getUserComplexType().getSelection())
- {
- if (textField.getText().equals("")) {
- populateUserComplexType();
- }
- else {
- populateUserComplexType(textField.getText());
- }
- }
- else if (e.widget == typeSection.getUserSimpleType() && typeSection.getUserSimpleType().getSelection())
- {
- if (textField.getText().equals("")) {
- populateUserSimpleType();
- }
- else {
- populateUserSimpleType(textField.getText());
- }
- }
- setEnabledState();
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- protected void ok()
- {
- TableItem[] items = table.getItems();
- int selection = table.getSelectionIndex();
- if (items != null && items.length > 0 && selection >= 0)
- {
- typeObject = items[selection].getData();
- }
-// System.out.println("typeObject is " + typeObject);
-
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_ELEMENT_TYPE_CHANGE"), element);
-// beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), element);
-// doSetValue(typeObject);
-// applyEditorValueAndDeactivate();
-// dialog.close();
-
- if (!XSDDOMHelper.inputEquals(element, XSDConstants.UNION_ELEMENT_TAG, false))
- {
- if (typeObject.equals("**anonymous**"))
- {
- if (typeSection.getUserSimpleType().getSelection())
- {
-// if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- }
- }
- else
- {
-// if (!previousStringType.equals("**anonymous**"))
- {
- updateElementToAnonymous(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- }
- // element.removeAttribute(XSDConstants.TYPE_ATTRIBUTE);
- element.removeAttribute(property);
- }
- else
- {
- XSDDOMHelper.updateElementToNotAnonymous(element);
- //element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, typeObject.toString());
- element.setAttribute(property, typeObject.toString());
- }
- }
-// endRecording(element);
-
- //implement dispose();
-// table.removeAll();
-// table.dispose();
- }
-
-
- public void handleSetInput()
- {
- table.removeAll();
- isAnonymous = checkForAnonymousType(element);
- // Attr attr = element.getAttributeNode(XSDConstants.TYPE_ATTRIBUTE);
- Attr attr = element.getAttributeNode(property);
- if (attr != null)
- {
- String value = attr.getValue();
- if (typeSection.getBuiltInTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- int i = typeSection.getBuiltInTypeNamesList(xsdSchema).indexOf(value);
- table.setSelection(i);
- previousType = 1;
- }
- else if (typeSection.getUserSimpleTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- int i = typeSection.getUserSimpleTypeNamesList(xsdSchema).indexOf(value);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 2;
- }
- else if (typeSection.getUserComplexTypeNamesList(xsdSchema).contains(value))
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- int i = typeSection.getUserComplexTypeNamesList(xsdSchema).indexOf(value);
- if (showAnonymous)
- {
- table.setSelection(i + 1);
- }
- else
- {
- table.setSelection(i);
- }
- previousType = 3;
- }
- else // if it is type="" for an empty list of simple types
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- previousType = 2;
- }
- }
- else
- {
- if (isAnonymous)
- {
- if (isSTAnonymous(element))
- {
- typeSection.getUserSimpleType().setSelection(true);
- populateUserSimpleType();
- previousType = 2;
- }
- else
- {
- typeSection.getUserComplexType().setSelection(true);
- populateUserComplexType();
- previousType = 3;
- }
- table.setSelection(0); // anonymous
- // typeSection.getTypeList().setText("**anonymous**");
- }
- else
- {
- typeSection.getSimpleType().setSelection(true);
- populateBuiltInType();
- table.setSelection(0);
-
- // typeSection.getTypeList().setEnabled(true);
- // typeSection.getSimpleType().setSelection(true);
- // typeSection.populateBuiltInType(xsdSchema);
- // typeSection.getTypeList().setText(XSDEditorPlugin.getXSDString("_UI_NO_TYPE"));
- previousType = 1;
- }
- }
- if (table.getSelection() != null && table.getSelection().length > 0)
- {
- previousStringType = (table.getSelection()[0]).getText();
- }
- }
-
- 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"));
- item.setData(items.get(i));
- }
- }
-
- public void populateBuiltInType(String fragment)
- {
- table.removeAll();
- List items = getBuiltInTypeNamesList();
- fragment = fragment.toLowerCase();
- Pattern regex = Pattern.compile(fragment);
-
- for (int i = 0; i < items.size(); i++)
- {
- String itemString = items.get(i).toString().toLowerCase();
- Matcher m = regex.matcher(itemString);
-
- if (itemString.startsWith(fragment) || m.matches()) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText(items.get(i).toString());
- item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif"));
- item.setData(items.get(i));
- }
- }
-
- table.select(0);
- }
-
- public void populateUserComplexType()
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- List items = getUserComplexTypeNamesList();
- for (int i = 0; i < items.size(); i++)
- {
- TableItem item = new TableItem(table, SWT.NONE);
-// System.out.println("item " + i + " is " + item);
- item.setText(items.get(i).toString());
- item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserComplexType(String fragment)
- {
- table.removeAll();
- fragment = fragment.toLowerCase();
- Pattern regex = java.util.regex.Pattern.compile(fragment);
-
- if (showAnonymous)
- {
- Matcher m = regex.matcher("**anonymous**");
- if ("**anonymous**".startsWith(fragment) || m.matches()) {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- }
- List items = getUserComplexTypeNamesList();
- for (int i = 0; i < items.size(); i++)
- {
- String itemString = items.get(i).toString().toLowerCase();
- Matcher m = regex.matcher(itemString);
-
- if (itemString.startsWith(fragment) || m.matches()) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText(items.get(i).toString());
- item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif"));
- item.setData(items.get(i));
- }
- }
-
- table.select(0);
- }
-
- public void populateUserSimpleType()
- {
- table.removeAll();
- if (showAnonymous)
- {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- 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"));
- item.setData(items.get(i));
- }
- }
-
- public void populateUserSimpleType(String fragment)
- {
- table.removeAll();
- fragment = fragment.toLowerCase();
- Pattern regex = java.util.regex.Pattern.compile(fragment);
-
- if (showAnonymous)
- {
- Matcher m = regex.matcher("**anonymous**");
- if ("**anonymous**".startsWith(fragment) || m.matches()) {
- TableItem anonymousItem = new TableItem(table, SWT.NONE);
- anonymousItem.setText("**anonymous**");
- anonymousItem.setData("**anonymous**");
- }
- }
- List items = getUserSimpleTypeNamesList();
- for (int i = 0; i < items.size(); i++)
- {
- String itemString = items.get(i).toString().toLowerCase();
- Matcher m = regex.matcher(itemString);
-
- if (itemString.startsWith(fragment) || m.matches()) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText(items.get(i).toString());
- item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif"));
- item.setData(items.get(i));
- }
- }
-
- table.select(0);
- }
-
- boolean checkForAnonymousType(Element element)
- {
- /*
- * Using Ed's model to check boolean isAnonymous = false;
- *
- * XSDConcreteComponent component =
- * getXSDSchema().getCorrespondingComponent(element); if (component
- * instanceof XSDElementDeclaration) { XSDElementDeclaration xsdElem =
- * (XSDElementDeclaration)component; isAnonymous =
- * xsdElem.isSetAnonymousTypeDefinition(); } return isAnonymous;
- */
- XSDDOMHelper helper = new XSDDOMHelper();
- boolean isAnonymous = false;
- Node aNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- aNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- isAnonymous = true;
- }
- return isAnonymous;
- }
-
- void updateElementToAnonymous(Element element, String xsdType)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
- XSDDOMHelper.updateElementToNotAnonymous(element);
- Element childNode = null;
- if (xsdType.equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
- {
- childNode = element.getOwnerDocument().createElementNS(
- XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001,
- prefix + XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG))
- {
- childNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SIMPLETYPE_ELEMENT_TAG);
-
- Element restrictionNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.RESTRICTION_ELEMENT_TAG);
- restrictionNode.setAttribute(XSDConstants.BASE_ATTRIBUTE, prefix + "string");
- childNode.appendChild(restrictionNode);
- }
- if (childNode != null)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node annotationNode = helper.getChildNode(element, XSDConstants.ANNOTATION_ELEMENT_TAG);
- if (annotationNode == null)
- {
- Node firstChild = element.getFirstChild();
- element.insertBefore(childNode, firstChild);
- }
- else
- {
- Node nextSibling = annotationNode.getNextSibling();
- element.insertBefore(childNode, nextSibling);
- }
- XSDDOMHelper.formatChild(childNode);
- }
- }
-
- boolean isSTAnonymous(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node aNode = helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- if (XSDDOMHelper.inputEquals(aNode, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false))
- {
- return true;
- }
- }
- return false;
- }
-
- boolean isCTAnonymous(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node aNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- if (XSDDOMHelper.inputEquals(aNode, XSDConstants.COMPLEXTYPE_ELEMENT_TAG, false))
- {
- return true;
- }
- }
- return false;
- }
-
- XSDTypeDefinition getAnonymousTypeDefinition(Element element)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Node typeDefinitionNode =
- helper.getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (typeDefinitionNode == null)
- {
- typeDefinitionNode = helper.getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- }
- if (typeDefinitionNode != null)
- {
- XSDConcreteComponent component =
- xsdSchema.getCorrespondingComponent(typeDefinitionNode);
- if (component instanceof XSDTypeDefinition)
- {
- return (XSDTypeDefinition) component;
- }
- }
- return null;
- }
-
- public java.util.List getBuiltInTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getBuiltInTypeNamesList();
- }
-
- public java.util.List getUserSimpleTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserSimpleTypeNamesList();
- }
-
- public java.util.List getUserComplexTypeNamesList()
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserComplexTypeNamesList();
- }
-
- protected boolean hasElementChildren(Node parentNode)
- {
- boolean hasChildrenElements = false;
- if (parentNode != null && parentNode.hasChildNodes())
- {
- NodeList nodes = parentNode.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- if (nodes.item(i) instanceof Element)
- {
- hasChildrenElements = true;
- break;
- }
- }
- }
- return hasChildrenElements;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSection.java
deleted file mode 100644
index 3381d16c37..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSection.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.SelectionEvent;
-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.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionDialog;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDComponentSelectionProvider;
-import org.eclipse.wst.xsd.ui.internal.dialogs.types.xsd.XSDSetTypeHelper;
-import org.eclipse.wst.xsd.ui.internal.widgets.TypeSection;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class TypesSection extends AbstractSection
-{
- Text typeCombo;
- Button button;
-
- String type;
- Object typeObject;
- CLabel typeLabel;
- Table table;
- TypeSection typeSection;
- boolean showAnonymous = true;
- String previousStringType = "";
- boolean isAnonymous;
- int previousType;
- boolean showComplexTypes = true;
-
- /**
- *
- */
- public TypesSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- composite = getWidgetFactory().createFlatFormComposite(parent);
-
- FormData data;
-
- typeCombo = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- typeCombo.setEditable(false);
- typeCombo.addListener(SWT.Modify, this);
-
- button = getWidgetFactory().createButton(composite, "", SWT.PUSH); //$NON-NLS-1$
- button.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$
-
- typeLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_TYPE") + ":"); //$NON-NLS-1$
-
- button.addSelectionListener(this);
- FormData data2 = new FormData();
- data2.left = new FormAttachment(100, -rightMarginSpace + 2);
- data2.right = new FormAttachment(100,0);
- data2.top = new FormAttachment(typeCombo, 0, SWT.CENTER);
- button.setLayoutData(data2);
-
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(button, 0);
- typeCombo.setLayoutData(data);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- Object input = getInput();
- if (isReadOnly)
- {
- composite.setEnabled(false);
- }
- else
- {
- composite.setEnabled(true);
- }
- typeCombo.setText(""); //$NON-NLS-1$
- if (input != null)
- {
- Element element = null;
- if (input instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElem = (XSDElementDeclaration)input;
- element = xsdElem.getElement();
- XSDTypeDefinition typeDef = xsdElem.getTypeDefinition();
- boolean isAnonymous = xsdElem.isAbstract();
-
- if (isAnonymous)
- {
- typeCombo.setText("**anonymous**"); //$NON-NLS-1$
- }
- else
- {
- String typeName = ""; //$NON-NLS-1$
- if (typeDef != null)
- {
- typeName = typeDef.getQName(getSchema());
- if (typeName == null)
- {
- typeName = ""; //$NON-NLS-1$
- }
- typeCombo.setText(typeName);
- }
- else
- {
- typeCombo.setText(XSDEditorPlugin.getXSDString("_UI_NO_TYPE")); //$NON-NLS-1$
- }
- }
- }
- else if (input instanceof XSDAttributeDeclaration)
- {
- element = ((XSDAttributeDeclaration)input).getElement();
- }
- else if (input instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)input;
- XSDAttributeDeclaration attribute = attributeUse.getAttributeDeclaration();
- element = attribute.getElement();
- }
- else if (input instanceof Element)
- {
- element = (Element)input;
- }
-// else if (input instanceof XSDSimpleTypeDefinition)
-// {
-// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)input;
-// Element simpleTypeElement = st.getElement();
-// if (st.getVariety() == XSDVariety.LIST_LITERAL)
-// {
-// element = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.LIST_ELEMENT_TAG);
-// String result = element.getAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE);
-// if (result == null)
-// {
-// typeCombo.setText("**anonymous**");
-// }
-// else
-// {
-// typeCombo.setText(result);
-// }
-// typeLabel.setText("Item Type:");
-// }
-// else if (st.getVariety() == XSDVariety.ATOMIC_LITERAL)
-// {
-// typeLabel.setText("Base Type:");
-// element = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.RESTRICTION_ELEMENT_TAG);
-// if (element == null)
-// {
-// element = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.EXTENSION_ELEMENT_TAG);
-// if (element == null) return;
-// }
-//
-// String result = element.getAttribute(XSDConstants.BASE_ATTRIBUTE);
-// if (result == null)
-// {
-// typeCombo.setText("");
-// }
-// else
-// {
-// typeCombo.setText(result);
-// }
-// }
-// return;
-// }
-
- typeLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_TYPE") + ":"); //$NON-NLS-1$
- if (element != null)
- {
- boolean isAnonymous = checkForAnonymousType(element);
- String result = element.getAttribute(XSDConstants.TYPE_ATTRIBUTE);
- if (isAnonymous)
- {
- typeCombo.setText("**anonymous**"); //$NON-NLS-1$
- }
- if (result != null && result.equals("")) //$NON-NLS-1$
- {
- typeCombo.setText(XSDEditorPlugin.getXSDString("_UI_NO_TYPE")); //$NON-NLS-1$
- }
- else if (result != null)
- {
- typeCombo.setText(result);
- }
-
- }
- }
- }
-
- /**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == button)
- {
-/*
- Shell shell = Display.getCurrent().getActiveShell();
- Object input = getInput();
- Element element = ((XSDConcreteComponent)getInput()).getElement();
- TypesDialog dialog;
-
-// if (input instanceof XSDSimpleTypeDefinition)
-// {
-// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)input;
-// Element simpleTypeElement = st.getElement();
-// if (st.getVariety() == XSDVariety.LIST_LITERAL)
-// {
-// Element listElement = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.LIST_ELEMENT_TAG);
-// dialog = new TypesDialog(shell, listElement, XSDConstants.ITEMTYPE_ATTRIBUTE, xsdSchema);
-// dialog.showComplexTypes = false;
-// }
-// else if (st.getVariety() == XSDVariety.ATOMIC_LITERAL)
-// {
-// Element derivedByElement = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.RESTRICTION_ELEMENT_TAG);
-// if (derivedByElement == null)
-// {
-// derivedByElement = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.EXTENSION_ELEMENT_TAG);
-// if (derivedByElement == null) return;
-// }
-// if (derivedByElement != null)
-// {
-// dialog = new TypesDialog(shell, derivedByElement, XSDConstants.BASE_ATTRIBUTE, xsdSchema);
-// }
-// else
-// {
-// return;
-// }
-// }
-// else
-// {
-// dialog = new TypesDialog(shell, element, "type", xsdSchema);
-// }
-// }
-// else
-// {
- dialog = new TypesDialog(shell, element, "type", xsdSchema); //$NON-NLS-1$
-// }
-
- dialog.setBlockOnOpen(true);
- dialog.create();
- int result = dialog.open();
-
- if (result == Window.OK)
- {
- Object typeObject = dialog.getType();
-// if (input instanceof XSDSimpleTypeDefinition)
-// {
-// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)input;
-// Element simpleTypeElement = st.getElement();
-// Element listElement = (Element)domHelper.getChildNode(simpleTypeElement, XSDConstants.LIST_ELEMENT_TAG);
-//
-// beginRecording("ItemType Change", element);
-// listElement.setAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE, (String)typeObject);
-// endRecording(element);
-// }
- }
-*/
- Shell shell = Display.getCurrent().getActiveShell();
- IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile();
-
- Object input = getInput();
- XSDSchema schema = null;
- if (input instanceof XSDConcreteComponent) {
- schema = ((XSDConcreteComponent) input).getSchema();
- }
-
- XSDComponentSelectionProvider provider = new XSDComponentSelectionProvider(currentIFile, schema);
- XSDComponentSelectionDialog dialog = new XSDComponentSelectionDialog(shell, XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"), provider); // TODO: Externalize This
- if (input instanceof XSDAttributeDeclaration)
- {
- provider.showComplexTypes(false);
- }
- provider.setDialog(dialog);
-
- dialog.setBlockOnOpen(true);
- dialog.create();
-
- if (dialog.open() == Window.OK) {
- Element element = ((XSDConcreteComponent)getInput()).getElement();
- XSDSetTypeHelper helper = new XSDSetTypeHelper(currentIFile, schema);
- helper.setType(element, "type", dialog.getSelection());
- }
-
-// refresh();
- }
- }
-
-
-
- boolean checkForAnonymousType(Element element)
- {
- /* Using Ed's model to check
- boolean isAnonymous = false;
-
- XSDConcreteComponent component = getXSDSchema().getCorrespondingComponent(element);
- if (component instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration xsdElem = (XSDElementDeclaration)component;
- isAnonymous = xsdElem.isSetAnonymousTypeDefinition();
- }
- return isAnonymous;
- */
-
- boolean isAnonymous = false;
-
- Node aNode = getDomHelper().getChildNode(element, XSDConstants.SIMPLETYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- return true;
- }
- aNode = getDomHelper().getChildNode(element, XSDConstants.COMPLEXTYPE_ELEMENT_TAG);
- if (aNode != null)
- {
- isAnonymous = true;
- }
- return isAnonymous;
- }
-
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSectionDescriptor.java
deleted file mode 100644
index 3e9b8bfeb6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesSectionDescriptor.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class TypesSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public TypesSectionDescriptor()
- {
- super();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId()
- */
- public String getId()
- {
- return "org.eclipse.wst.xsdeditor.section.types";
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDElementDeclaration.class);
- list.add(XSDAttributeDeclaration.class);
- list.add(XSDAttributeUse.class);
- list.add(XSDSimpleTypeDefinition.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new TypesSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDElementDeclaration)
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration)object;
- if (elementDeclaration.isElementDeclarationReference())
- {
- return false;
- }
- return true;
- }
- else if (object instanceof XSDAttributeDeclaration)
- {
- XSDAttributeDeclaration attr = (XSDAttributeDeclaration)object;
- if (attr.isAttributeDeclarationReference())
- {
- return false;
- }
- return true;
- }
- else if (object instanceof XSDAttributeUse)
- {
- XSDAttributeUse attributeUse = (XSDAttributeUse)object;
- Element element = attributeUse.getElement();
- if (inputEquals(element, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSection.java
deleted file mode 100644
index d72ed50236..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSection.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-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.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDEnumerationFacet;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class ValueSection extends AbstractSection
-{
- Text valueText;
- /**
- *
- */
- public ValueSection()
- {
- 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 createControls(Composite parent, TabbedPropertySheetWidgetFactory factory)
- {
- super.createControls(parent, factory);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- valueText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 100);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- valueText.setLayoutData(data);
- valueText.addListener(SWT.Modify, this);
-
- CLabel valueLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_VALUE") + ":"); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(valueText, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(valueText, 0, SWT.CENTER);
- valueLabel.setLayoutData(data);
-
-// listener.startListeningForEnter(valueText);
-// listener.startListeningTo(valueText);
- }
-
- /*
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
- */
- public void refresh()
- {
- setListenerEnabled(false);
- Object input = getInput();
- valueText.setText(""); //$NON-NLS-1$
- if (input != null)
- {
- if (input instanceof XSDEnumerationFacet)
- {
- XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)input;
- Element element = enumFacet.getElement();
- String value = element.getAttribute(XSDConstants.VALUE_ATTRIBUTE);
-
- if (value != null)
- {
- valueText.setText(value);
- }
- }
- }
- setListenerEnabled(true);
- }
-
- public void doHandleEvent(Event event)
- {
- if (event.widget == valueText)
- {
- Object input = getInput();
- if (input instanceof XSDEnumerationFacet)
- {
- XSDEnumerationFacet enumFacet = (XSDEnumerationFacet)input;
- Element element = enumFacet.getElement();
-
- beginRecording(XSDEditorPlugin.getXSDString("_UI_ENUM_VALUE_CHANGE"), element); //$NON-NLS-1$
- String value = valueText.getText();
- element.setAttribute(XSDConstants.VALUE_ATTRIBUTE, value);
- endRecording(element);
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace()
- */
- public boolean shouldUseExtraSpace()
- {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSectionDescriptor.java
deleted file mode 100644
index e8f0b48253..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/ValueSectionDescriptor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISection;
-import org.eclipse.xsd.XSDEnumerationFacet;
-
-public class ValueSectionDescriptor extends AbstractSectionDescriptor
-{
- /**
- *
- */
- public ValueSectionDescriptor()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes()
- */
- public List getInputTypes()
- {
- List list = new ArrayList();
- list.add(XSDEnumerationFacet.class);
- return list;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass()
- */
- public ISection getSectionClass()
- {
- return new ValueSection();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab()
- */
- public String getTargetTab()
- {
- return "org.eclipse.wst.xmlwebservices.general";
- }
-
- /* (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 XSDEnumerationFacet)
- {
- return true;
- }
- }
- return false;
- }
-
- public String getAfterSection()
- {
- return "org.eclipse.wst.xsdeditor.section.name";
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/WindowUtility.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/WindowUtility.java
deleted file mode 100644
index 9cc0e4d439..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/WindowUtility.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2004, 2005 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Eclipse Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* IBM Corporation - Initial API and implementation
-*******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.properties.section;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-
-class WindowUtility
-{
- public static Object getSelection(ISelection selection)
- {
- if (selection == null)
- {
- return null;
- } // end of if ()
-
- Object result = null;
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection es= (IStructuredSelection)selection;
- Iterator i= es.iterator();
- if (i.hasNext())
- {
- result= i.next();
- }
- }
- return result;
- }
-
- public static List getSelectionList(ISelection selection)
- {
- List result = null;
- if (selection != null)
- {
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection es= (IStructuredSelection)selection;
- result = new Vector();
- for (Iterator i= es.iterator(); i.hasNext(); )
- {
- result.add(i.next());
- }
- }
- }
- return result;
- }
-
- public static void openErrorCreatingFile(Shell shell, IResource resource)
- {
- String title = null;
- String briefMessage = null;
- String reason = null;
- String details = null;
-
-// KCPort TODO
-// title = B2BGUIPlugin.getInstance().getString("_UI_ERROR_CREATING_FILE_TITLE");
-// briefMessage = B2BGUIPlugin.getInstance().getString("_UI_ERROR_CREATING_FILE_SHORT_DESC", resource.getName());
-// details = B2BGUIPlugin.getInstance().getString("_UI_ERROR_CREATING_FILE_LONG_DESC", resource.getLocation().toOSString());
-//
-// IResource parent = resource.getParent();
-// if (parent != null)
-// {
-// if (parent.isReadOnly())
-// {
-// reason = B2BGUIPlugin.getInstance().getString("_UI_PARENT_FOLDER_IS_READ_ONLY", parent.getName());
-// }
-// else
-// {
-// // on windows the isReadOnly() = false for read only shared directory... so we give a hint
-// reason = B2BGUIPlugin.getInstance().getString("_UI_UNKNOWN_ERROR_WITH_HINT", parent.getName());
-// }
-// }
-//
-// if (reason == null)
-// {
-// reason = B2BGUIPlugin.getInstance().getString("_UI_UNKNOWN_ERROR");
-// }
-
- openError(shell, title, briefMessage, reason, details);
- }
-
- public static void openError(Shell shell, String title, String briefMessage, String reason, String detailedMessage)
- {
- ErrorDialog.openError(shell, title, briefMessage, createStatus(reason, detailedMessage));
- }
-
- private static IStatus createStatus(String reason, String msg)
- {
-// KCPort TODO
-// String pluginId = B2BGUIPlugin.getInstance().getDescriptor().getUniqueIdentifier();
- String pluginId = "";
- MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null);
- Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null);
- multiStatus.add(status);
- return multiStatus;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionDescriptorProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionDescriptorProvider.java
deleted file mode 100644
index 54acd8cf6e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionDescriptorProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider;
-
-
-public class XSDSectionDescriptorProvider implements ISectionDescriptorProvider
-{
- /**
- *
- */
- public XSDSectionDescriptorProvider()
- {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider#getSectionDescriptors()
- */
- public ISectionDescriptor[] getSectionDescriptors()
- {
- ISectionDescriptor[] descriptors = new ISectionDescriptor[18];
- descriptors[0] = new NameSectionDescriptor();
- descriptors[1] = new TypesSectionDescriptor();
- descriptors[2] = new OtherAttributesSectionDescriptor();
- descriptors[3] = new AttributesViewSectionDescriptor();
- descriptors[4] = new ModelGroupSectionDescriptor();
- descriptors[5] = new NamespaceProcessContentsSectionDescriptor();
- descriptors[6] = new ReferenceSectionDescriptor();
- descriptors[7] = new ComplexTypeSectionDescriptor();
- descriptors[8] = new ValueSectionDescriptor();
- descriptors[9] = new PatternSectionDescriptor();
- descriptors[10] = new AnnotationSectionDescriptor();
- descriptors[11] = new SimpleTypeSectionDescriptor();
- descriptors[12] = new FacetsSectionDescriptor();
- descriptors[13] = new EnumerationsSectionDescriptor();
- descriptors[14] = new NamespaceSectionDescriptor();
- descriptors[15] = new SchemaLocationDescriptor();
- descriptors[16] = new NamespaceAndSchemaLocationDescriptor();
- descriptors[17] = new MinMaxSectionDescriptor();
-
-// descriptors[18] = new SimpleTypeUnionSectionDescriptor();
-// descriptors[19] = new FixedDefaultSectionDescriptor();
- return descriptors;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionLabelProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionLabelProvider.java
deleted file mode 100644
index 77bebed075..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDSectionLabelProvider.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.util.Assert;
-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.IWorkbenchWindow;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-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)
- {
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
- if (editorPart instanceof XSDEditor)
- {
- return ((XSDEditor)editorPart).getLabelProvider().getImage((XSDConcreteComponent)selected);
- }
- }
-
-// selected = typeMapper.remapObject(selected);
-// ModelAdapter modelAdapter = adapterFactory.getAdapter(selected);
-// if (modelAdapter != null)
-// {
-// result = (Image)modelAdapter.getProperty(selected, ModelAdapter.IMAGE_PROPERTY);
-// }
- }
- 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 "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(" ");
- sb.append(XSDEditorPlugin.getXSDString("_UI_PAGE_HEADING_REFERENCE"));
- }
-
- if (!(element instanceof IDOMNode))
- {
- sb.append(" (" + XSDEditorPlugin.getXSDString("_UI_LABEL_READ_ONLY") + ")"); //$NON-NLS-1$
- }
- return sb.toString();
- }
- else
- {
- return "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_READ_ONLY") + ")"; //$NON-NLS-1$
- }
- }
-
-// selected = typeMapper.remapObject(selected);
-//
-// ModelAdapter modelAdapter = adapterFactory.getAdapter(selected);
-// if (modelAdapter != null)
-// {
-// // result = (String)modelAdapter.getProperty(selected, ModelAdapter.LABEL_PROPERTY);
-// result = ((WSDLElement)selected).getElement().getLocalName();
-// }
- if (object instanceof Element)
- {
- return ((Element)object).getLocalName();
- }
- }
- else if (object instanceof TextSelection)
- {
- }
-
-
- return result;
- }
-
- /**
- * Determine if a multiple object selection has been passed to the
- * label provider. If the objects is a IStructuredSelection, see if
- * all the objects in the selection are the same and if so, we want
- * to provide labels for the common selected element.
- * @param objects a single object or a IStructuredSelection.
- * @param multiple first element in the array is true if there is multiple
- * unequal selected elements in a IStructuredSelection.
- * @return the object to get labels for.
- */
- private Object getObject(Object objects, boolean multiple[]) {
- Assert.isNotNull(objects);
- Object object = null;
- return object;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDTabbedPropertySheetPage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDTabbedPropertySheetPage.java
deleted file mode 100644
index 97810d0c91..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDTabbedPropertySheetPage.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.text.TextSelection;
-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.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor;
-import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage;
-import org.eclipse.wst.xsd.ui.internal.XSDSelectionManager;
-import org.eclipse.wst.xsd.ui.internal.graph.model.Category;
-import org.eclipse.wst.xsd.ui.internal.provider.CategoryAdapter;
-import org.eclipse.wst.xsd.ui.internal.provider.XSDModelAdapterFactoryImpl;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-public class XSDTabbedPropertySheetPage extends TabbedPropertySheetPage
- implements ISelectionChangedListener, INotifyChangedListener
-{
- XSDSchema xsdSchema;
- private XSDSelectionManager selectionManager;
- private XSDModelAdapterFactoryImpl adapterFactory;
- /**
- * @param tabbedPropertySheetPageContributor
- */
- public XSDTabbedPropertySheetPage(ITabbedPropertySheetPageContributor tabbedPropertySheetPageContributor)
- {
- super(tabbedPropertySheetPageContributor);
- }
-
- public void init(IPageSite pageSite)
- {
- super.init(pageSite);
- getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
- }
-
- public void setXSDSchema(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- public void setXSDModelAdapterFactory(XSDModelAdapterFactoryImpl adapterFactory) {
- // disconnect from old one
- if (adapterFactory != null) {
- adapterFactory.removeListener(this);
- }
-
- this.adapterFactory = adapterFactory;
-
- // connect to new one
- if (adapterFactory != null) {
- adapterFactory.addListener(this);
- }
- }
-
- public void setSelectionManager(XSDSelectionManager newSelectionManager)
- {
- // disconnect from old one
- if (selectionManager != null)
- {
- selectionManager.removeSelectionChangedListener(this);
- }
-
- selectionManager = newSelectionManager;
-
- // connect to new one
- if (selectionManager != null)
- {
- selectionManager.addSelectionChangedListener(this);
- }
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection)
- {
- // override for category
- if (selection != null)
- {
- if (selection instanceof IStructuredSelection)
- {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- if (structuredSelection.isEmpty())
- {
- return;
- }
- Object obj = structuredSelection.getFirstElement();
- if (obj instanceof Element)
- {
- try
- {
- Object modelObject = xsdSchema.getCorrespondingComponent((Element) obj);
- if (modelObject != null)
- {
- obj = modelObject;
- selection = new StructuredSelection(obj);
- }
- }
- catch (Exception e)
- {
- }
- }
- else if (obj instanceof Text)
- {
- Node parent = ((Text)obj).getParentNode();
- Object modelObject = xsdSchema.getCorrespondingComponent(parent);
- if (modelObject != null)
- {
- obj = modelObject;
- selection = new StructuredSelection(obj);
- }
- }
- else if (obj instanceof CategoryAdapter)
- {
- selection = new StructuredSelection(((CategoryAdapter)obj).getXSDSchema());
- }
- else if (obj instanceof Category)
- {
- selection = new StructuredSelection(((Category)obj).getXSDSchema());
- }
- else if (obj instanceof ProcessingInstruction)
- {
- selection = new StructuredSelection(xsdSchema);
- }
- }
- else if (selection instanceof TextSelection)
- {
- return;
- }
- }
- super.selectionChanged(part, selection);
- }
-
- public void selectionChanged(SelectionChangedEvent event)
- {
- if (!event.getSelection().isEmpty())
- {
- selectionChanged(getSite().getWorkbenchWindow().getActivePage().getActivePart(), event.getSelection());
- //super.selectionChanged(getSite().getWorkbenchWindow().getActivePage().getActivePart(), event.getSelection());
- }
- }
-
- public void dispose()
- {
- if (selectionManager != null)
- {
- selectionManager.removeSelectionChangedListener(this);
- }
- if (adapterFactory != null)
- {
- adapterFactory.removeListener(this);
- }
- getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(this);
- super.dispose();
- }
-
- public void notifyChanged(Notification notification)
- {
- if (getCurrentTab() != null)
- {
- refresh();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbook.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbook.java
deleted file mode 100644
index 9c43704797..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbook.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-
-public class XSDWorkbook {
- private CTabFolder tabFolder;
- private CTabItem selectedTab;
-/**
- * Workbook constructor comment.
- */
-public XSDWorkbook(Composite parent, int style) {
- tabFolder = new CTabFolder(parent, style);
-
- tabFolder.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- CTabItem newSelectedTab = (CTabItem) event.item;
- if (selectedTab == newSelectedTab) // Do nothing if the selection did not change.
- return;
-
- if (selectedTab != null && (!selectedTab.isDisposed())) {
- XSDWorkbookPage selectedPage = getWorkbookPage(selectedTab);
- if (!selectedPage.deactivate()) {
- // tabFolder.setSelection(new CTabItem[] {selectedTab});
- tabFolder.setSelection(selectedTab);
- return;
- }
- }
-
- selectedTab = newSelectedTab;
- XSDWorkbookPage newSelectedPage = getWorkbookPage(newSelectedTab);
- if (newSelectedPage != null)
- newSelectedPage.activate();
-
- }
- });
-
-}
-public XSDWorkbookPage getSelectedPage() {
-
- int index = tabFolder.getSelectionIndex();
- if (index == -1) // When can this be -1
- return null;
-
- CTabItem selectedItem = tabFolder.getItem(index);
-
- return (XSDWorkbookPage)selectedItem.getData();
-}
-public CTabFolder getTabFolder() {
-
- return tabFolder;
-
-}
-protected XSDWorkbookPage getWorkbookPage(CTabItem item) {
-
- try {
- return (XSDWorkbookPage) item.getData();
- } catch (ClassCastException e) {
- return null;
- }
-}
-public XSDWorkbookPage[] getWorkbookPages() {
-
- CTabItem[] tabItems = tabFolder.getItems();
- int nItems = tabItems.length;
- XSDWorkbookPage[] workbookPages = new XSDWorkbookPage[nItems];
- for (int i = 0; i < nItems; i++)
- workbookPages[i] = getWorkbookPage(tabItems[i]);
- return workbookPages;
-}
-public void setSelectedPage (XSDWorkbookPage workbookPage)
-{
- CTabItem newSelectedTab = workbookPage.getTabItem();
-
- if (selectedTab == newSelectedTab)
- return;
-
- selectedTab = newSelectedTab;
- workbookPage.activate();
- // tabFolder.setSelection(new CTabItem[] {newSelectedTab});
- tabFolder.setSelection(newSelectedTab);
-
-}
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbookPage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbookPage.java
deleted file mode 100644
index f865afa702..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/XSDWorkbookPage.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.properties.section;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-public abstract class XSDWorkbookPage {
- public CTabItem tabItem;
-/**
- * WorkbookPage constructor comment.
- */
-public XSDWorkbookPage(XSDWorkbook parent) {
- CTabFolder folder = parent.getTabFolder();
- tabItem = new CTabItem(folder,SWT.NONE);
- tabItem.setData(this);
-}
-public void activate() {
-
- if (tabItem.getControl() == null)
- tabItem.setControl(createControl(tabItem.getParent()));
-
-}
-protected abstract Control createControl (Composite parent);
-public boolean deactivate() {
- return true;
-}
-public void dispose() {
-
- if (tabItem == null)
- return;
-
- CTabItem oldItem = tabItem;
- tabItem = null;
- oldItem.dispose();
-}
-public CTabItem getTabItem() {
- return tabItem;
-}
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/CategoryAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/CategoryAdapter.java
deleted file mode 100644
index 3182e9a385..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/CategoryAdapter.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.edit.provider.IChangeNotifier;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.xsd.XSDSchema;
-
-
-public class CategoryAdapter // extends ItemProvider
- implements ILabelProvider, IChangeNotifier, ITreeContentProvider
-{
-
- protected String text;
-
- /**
- * This is the image returned by {@link #getImage getImage(Object)}.
- */
- protected Image image;
-
- /**
- * This is the parent returned by {@link #getParent getParent(Object)}.
- */
- protected Object parent;
-
- public CategoryAdapter(String label, Image image, Collection children, XSDSchema xsdSchema, int groupType)
- {
-// super(label, image, xsdSchema);
- this.text = label;
- this.image = image;
- this.parent = xsdSchema;
- this.xsdSchema = xsdSchema;
- this.children = children;
- this.groupType = groupType;
- }
-
- public final static int ATTRIBUTES = 1;
- public final static int ELEMENTS = 2;
- public final static int TYPES = 3;
- public final static int GROUPS = 5;
- public final static int DIRECTIVES = 6;
- public final static int NOTATIONS = 7;
- public final static int ATTRIBUTE_GROUPS = 8;
- public final static int IDENTITY_CONSTRAINTS = 9;
- public final static int ANNOTATIONS = 10;
-
- protected int groupType;
- Collection children;
- XSDSchema xsdSchema;
-
- public XSDSchema getXSDSchema()
- {
- return xsdSchema;
- }
-
- public int getGroupType()
- {
- return groupType;
- }
-
-// public boolean hasChildren(Object o)
-// {
-// return !children.isEmpty();
-// }
-
-// public Collection getChildren(Object o)
-// {
-// return children;
-// }
-
- public Image getImage(Object element)
- {
- return image;
- }
-
- public String getText(Object object)
- {
- // return object.toString();
- return text;
- }
-
- public void addListener(ILabelProviderListener listener)
- {
-
- }
-
- public boolean isLabelProperty(Object element, String property)
- {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener)
- {
-
- }
-
- public void fireNotifyChanged(Notification notification)
- {
-
- }
-
- /**
- * This adds another listener.
- */
- public void addListener(INotifyChangedListener notifyChangedListener)
- {
-
- }
-
- /**
- * This removes a listener.
- */
- public void removeListener(INotifyChangedListener notifyChangedListener)
- {
-
- }
-
- public void dispose()
- {
-
- }
-
- public Object[] getElements(Object inputElement)
- {
- return getChildren(inputElement);
- }
-
- public Object[] getChildren(Object parentElement)
- {
- return children.toArray();
- }
-
- public void setChildren(Collection list)
- {
- children = list;
- }
-
- public Object getParent(Object element)
- {
- return xsdSchema;
- }
-
- public boolean hasChildren(Object element)
- {
- return true;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAbstractAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAbstractAdapter.java
deleted file mode 100644
index 8233c5eade..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAbstractAdapter.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.edit.provider.ChangeNotifier;
-import org.eclipse.emf.edit.provider.IChangeNotifier;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-
-public class XSDAbstractAdapter extends AdapterImpl
- implements ITreeContentProvider, ILabelProvider, IChangeNotifier
-{
-
- protected AdapterFactory adapterFactory;
- /**
- *
- */
- public XSDAbstractAdapter(AdapterFactory adapterFactory)
- {
- super();
- this.adapterFactory = adapterFactory;
- }
-
- /**
- * The adapter factory is used as the type key.
- * This returns true, only if this adapter was created by the given factory.
- */
- public boolean isAdapterForType(Object type)
- {
- return type == adapterFactory;
- }
-
- public Image getImage(Object element)
- {
- return null;
- }
-
- public String getText(Object object)
- {
- return object.toString();
- }
-
- public void addListener(ILabelProviderListener listener)
- {
-
- }
-
- public boolean isLabelProperty(Object element, String property)
- {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener)
- {
-
- }
-
- public Object[] getChildren(Object parentElement)
- {
- List list = new ArrayList();
- return list.toArray();
- }
-
- public boolean hasChildren(Object object)
- {
- return false;
- }
-
- public Object getParent(Object object)
- {
- return null;
- }
-
- public Object[] getElements(Object inputElement)
- {
- return getChildren(inputElement);
- }
-
- public void dispose()
- {
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
-
- }
-
- /**
- * This is used to implement {@link IChangeNotifier}.
- */
- protected IChangeNotifier changeNotifier;
-
-
- public void notifyChanged(Notification msg)
- {
- if (msg.getEventType() != Notification.RESOLVE)
- {
- fireNotifyChanged(msg);
- }
- }
-
- /**
- * This calls {@link org.eclipse.emf.edit.provider.INotifyChangedListener#notifyChanged notifyChanged} for each listener.
- */
- public void fireNotifyChanged(Notification notification)
- {
- if (changeNotifier != null)
- {
- changeNotifier.fireNotifyChanged(notification);
- }
-
- if (adapterFactory instanceof IChangeNotifier)
- {
- IChangeNotifier changeNotifier = (IChangeNotifier)adapterFactory;
- changeNotifier.fireNotifyChanged(notification);
- }
- }
-
-
- /**
- * This adds another listener.
- */
- public void addListener(INotifyChangedListener notifyChangedListener)
- {
- if (changeNotifier == null)
- {
- changeNotifier = new ChangeNotifier();
- }
- changeNotifier.addListener(notifyChangedListener);
-
- }
-
- /**
- * This removes a listener.
- */
- public void removeListener(INotifyChangedListener notifyChangedListener)
- {
- if (changeNotifier != null)
- {
- changeNotifier.removeListener(notifyChangedListener);
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAdapterFactoryLabelProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAdapterFactoryLabelProvider.java
deleted file mode 100644
index 6cf228e7d9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAdapterFactoryLabelProvider.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.edit.provider.IChangeNotifier;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class XSDAdapterFactoryLabelProvider implements ILabelProvider, INotifyChangedListener, ITableLabelProvider {
- protected XSDModelAdapterFactoryImpl adapterFactory;
- protected Collection labelProviderListeners;
-
- /**
- *
- */
- public XSDAdapterFactoryLabelProvider(XSDModelAdapterFactoryImpl adapterFactory) {
- this.adapterFactory = adapterFactory;
- labelProviderListeners = new ArrayList();
- }
-
- /**
- * Return the wrapped AdapterFactory.
- */
- public AdapterFactory getAdapterFactory() {
- return adapterFactory;
- }
-
- /**
- * Set the wrapped AdapterFactory.
- */
- public void setAdapterFactory(XSDModelAdapterFactoryImpl adapterFactory) {
- if (this.adapterFactory instanceof IChangeNotifier) {
- ((IChangeNotifier) this.adapterFactory).removeListener(this);
- }
-
- if (adapterFactory instanceof IChangeNotifier) {
- ((IChangeNotifier) adapterFactory).addListener(this);
- }
-
- this.adapterFactory = adapterFactory;
- }
-
- /**
- * Since we won't ever generate these notifications, we can just ignore
- * this.
- */
- public void addListener(ILabelProviderListener listener) {
- labelProviderListeners.add(listener);
- }
-
- /**
- * Since we won't ever add listeners, we can just ignore this.
- */
- public void removeListener(ILabelProviderListener listener) {
- labelProviderListeners.remove(listener);
- }
-
- /**
- * This discards the content provider and removes this as a listener to
- * the {@link #adapterFactory}.
- */
- public void dispose() {
- if (this.adapterFactory instanceof IChangeNotifier) {
- ((IChangeNotifier) adapterFactory).removeListener(this);
- }
- }
-
- /**
- * This always returns true right now.
- */
- public boolean isLabelProperty(Object object, String id) {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object object) {
- ILabelProvider labelProvider = (ILabelProvider) adapterFactory.adapt(object, ILabelProvider.class);
-
- return labelProvider != null ? labelProvider.getImage(object) : null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object object) {
- // Get the adapter from the factory.
- //
- ILabelProvider labelProvider = (ILabelProvider) adapterFactory.adapt(object, ILabelProvider.class);
-
- return labelProvider != null ? labelProvider.getText(object) : object == null ? "" : object.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.edit.provider.INotifyChangedListener#notifyChanged(org.eclipse.emf.common.notify.Notification)
- */
- public void notifyChanged(Notification notification) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
- * int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return getImage(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
- * int)
- */
- public String getColumnText(Object element, int columnIndex) {
- return getText(element);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAnnotationAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAnnotationAdapter.java
deleted file mode 100644
index b57a4c5ece..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAnnotationAdapter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAnnotation;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class XSDAnnotationAdapter extends XSDAbstractAdapter
-{
- public XSDAnnotationAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object element)
- {
- return XSDEditorPlugin.getPlugin().getImage("icons/XSDAnnotate.gif");
- }
-
- public String getText(Object object)
- {
- XSDAnnotation xsdAnnotation = ((XSDAnnotation)object);
- String result = "";
- List userInformation = xsdAnnotation.getUserInformation();
- if (!userInformation.isEmpty())
- {
- Element element = (Element)userInformation.get(0);
- if (element.hasAttribute(XSDConstants.SOURCE_ATTRIBUTE))
- {
- result = element.getAttribute(XSDConstants.SOURCE_ATTRIBUTE);
- }
- else
- {
- org.w3c.dom.Node text = element.getFirstChild();
- while (text instanceof Element)
- {
- text = ((Element)text).getFirstChild();
- }
- if (text != null && text.getNodeValue() != null)
- {
- result = text.getNodeValue();
- result = result.trim();
- if (result.length() > 50)
- {
- result = result.substring(0, 50) + "...";
- }
- }
- }
- }
-
- return result;
- }
-
- public Object[] getChildren(Object parentElement)
- {
- return null;
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDAnnotation element = (XSDAnnotation)object;
- return element.getContainer();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeDeclarationAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeDeclarationAdapter.java
deleted file mode 100644
index 330925f255..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeDeclarationAdapter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-public class XSDAttributeDeclarationAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDAttributeDeclarationAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- XSDAttributeDeclaration xsdAttributeDeclaration = ((XSDAttributeDeclaration)object);
- XSDAttributeDeclaration resolvedAttributeDeclaration = xsdAttributeDeclaration.getResolvedAttributeDeclaration();
-
- if (resolvedAttributeDeclaration.getContainer() == null)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif");
- }
- // if (xsdAttributeDeclaration.getResolvedAttributeDeclaration() == xsdAttributeDeclaration)
- if (xsdAttributeDeclaration.isAttributeDeclarationReference())
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttributeRef.gif");
- }
- else
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif");
- }
-
-// return
-// XSDEditorPlugin.getPlugin().getIconImage
-// (resolvedAttributeDeclaration.getContainer() == null ?
-// "full/obj16/XSDAttributeUnresolved" :
-// xsdAttributeDeclaration.getResolvedAttributeDeclaration() == xsdAttributeDeclaration ?
-// "full/obj16/XSDAttributeDeclaration" :
-// "full/obj16/XSDAttributeUse");
- }
-
- public String getText(Object object)
- {
- XSDAttributeDeclaration xsdAttributeDeclaration = ((XSDAttributeDeclaration)object);
- XSDAttributeDeclaration resolvedAttributeDeclaration = xsdAttributeDeclaration.getResolvedAttributeDeclaration();
- String name =
- xsdAttributeDeclaration != resolvedAttributeDeclaration ?
- xsdAttributeDeclaration.getQName() :
- xsdAttributeDeclaration.getName();
-
- StringBuffer result = new StringBuffer();
- if (name == null)
- {
- result.append("'absent'");
- }
- else
- {
- result.append(name);
- }
-
- if (resolvedAttributeDeclaration.getAnonymousTypeDefinition() == null && resolvedAttributeDeclaration.getTypeDefinition() != null)
- {
- result.append(" : ");
- result.append(resolvedAttributeDeclaration.getTypeDefinition().getQName(xsdAttributeDeclaration));
- }
-
- return result.toString();
- }
-
- public Object[] getChildren(Object parentElement)
- {
- XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)parentElement;
- List list = new ArrayList();
-
- XSDTypeDefinition type = xsdAttributeDeclaration.getAnonymousTypeDefinition();
- if (type != null)
- {
- list.add(type);
- }
- return list.toArray();
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDAttributeDeclaration element = (XSDAttributeDeclaration)object;
- return element.getContainer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeGroupDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeGroupDefinitionAdapter.java
deleted file mode 100644
index a45588ea72..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeGroupDefinitionAdapter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDWildcard;
-
-
-public class XSDAttributeGroupDefinitionAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDAttributeGroupDefinitionAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- XSDAttributeGroupDefinition xsdAttributeGroupDefinition = ((XSDAttributeGroupDefinition)object);
-
- if (xsdAttributeGroupDefinition.isAttributeGroupDefinitionReference())
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttributeGroupRef.gif");
- }
- else
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttributeGroup.gif");
- }
- }
-
- public String getText(Object object)
- {
- XSDAttributeGroupDefinition xsdAttributeGroupDefinition = ((XSDAttributeGroupDefinition)object);
- String result =
- xsdAttributeGroupDefinition.isAttributeGroupDefinitionReference() ?
- xsdAttributeGroupDefinition.getQName() :
- xsdAttributeGroupDefinition.getName();
- return result == null ? "'absent'" : result;
- }
-
- public Object[] getChildren(Object parentElement)
- {
- XSDAttributeGroupDefinition xsdAttributeGroup = (XSDAttributeGroupDefinition)parentElement;
- List list = new ArrayList();
- list.addAll(xsdAttributeGroup.getContents());
-// Iterator i = xsdAttributeGroup.getContents().iterator();
-// while (i.hasNext())
-// {
-// XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent)i.next();
-// if (attrGroupContent instanceof XSDAttributeUse)
-// {
-// list.add(((XSDAttributeUse)attrGroupContent).getAttributeDeclaration());
-// }
-// else
-// {
-// list.add(attrGroupContent);
-// }
-// }
-
- XSDWildcard wildcard = xsdAttributeGroup.getAttributeWildcardContent();
- if (wildcard != null)
- {
- list.add(wildcard);
- }
- return list.toArray();
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDAttributeGroupDefinition element = (XSDAttributeGroupDefinition)object;
- return element.getContainer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeUseAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeUseAdapter.java
deleted file mode 100644
index 5c8c127703..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDAttributeUseAdapter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-
-public class XSDAttributeUseAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDAttributeUseAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- protected XSDAttributeDeclaration getDelegate(XSDAttributeUse xsdAttributeUse)
- {
- return xsdAttributeUse.getContent();
- }
-
- /**
- * This returns XSDAttributeUse.gif.
- */
- public Image getImage(Object object)
- {
- XSDAttributeUse xsdAttributeUse = ((XSDAttributeUse)object);
-
- XSDAttributeDeclaration xsdAttributeDeclaration = getDelegate(xsdAttributeUse);
- if (xsdAttributeDeclaration.isAttributeDeclarationReference())
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttributeRef.gif");
- }
- else
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif");
- }
- //return XSDEditorPlugin.getPlugin().getIconImage("full/obj16/XSDAttributeUse");
-
- }
-
- public String getText(Object object)
- {
- return getText(object, true);
- }
-
- public String getText(Object object, boolean showType)
- {
- XSDAttributeUse xsdAttributeUse = ((XSDAttributeUse)object);
- XSDAttributeDeclaration xsdAttributeDeclaration = getDelegate(xsdAttributeUse);
- if (xsdAttributeDeclaration.isAttributeDeclarationReference())
- {
- return xsdAttributeDeclaration.getResolvedAttributeDeclaration().getName();
- }
- StringBuffer result = new StringBuffer();
- if (xsdAttributeDeclaration != null)
- {
- result.append(xsdAttributeDeclaration.getName());
- }
-
- if (xsdAttributeUse.isSetConstraint())
- {
- if (result.length() != 0)
- {
- result.append(" ");
- }
- result.append('<');
- result.append(xsdAttributeUse.getConstraint());
- result.append("=\"");
- result.append(xsdAttributeUse.getLexicalValue());
- result.append("\">");
- }
-
- return result.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDComplexTypeDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDComplexTypeDefinitionAdapter.java
deleted file mode 100644
index 38f73515b4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDComplexTypeDefinitionAdapter.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.xsd.XSDComplexTypeContent;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class XSDComplexTypeDefinitionAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDComplexTypeDefinitionAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDComplexType.gif");
-// XSDComplexTypeDefinition xsdComplexTypeDefinition = ((XSDComplexTypeDefinition)object);
-// return
-// XSDEditorPlugin.getPlugin().getIconImage
-// (xsdComplexTypeDefinition.getContainer() == null ?
-// "full/obj16/XSDComplexTypeDefinitionUnresolved" :
-// "full/obj16/XSDComplexTypeDefinition");
- }
-
- public String getText(Object object)
- {
- return getText(object, true);
- }
-
- public String getText(Object object, boolean showType)
- {
- XSDComplexTypeDefinition xsdComplexTypeDefinition = ((XSDComplexTypeDefinition)object);
-
- StringBuffer result = new StringBuffer();
-
- result.append
- (xsdComplexTypeDefinition.getName() == null ?
- // xsdComplexTypeDefinition.getAliasName() :
- "local type" :
- xsdComplexTypeDefinition.getName());
-
- if (showType)
- {
- XSDTypeDefinition baseTypeDefinition = xsdComplexTypeDefinition.getBaseTypeDefinition();
- if (baseTypeDefinition != null &&
- baseTypeDefinition != xsdComplexTypeDefinition.getContent() &&
- baseTypeDefinition.getName() != null &&
- !XSDConstants.isURType(baseTypeDefinition))
- {
- result.append(" : ");
- result.append(baseTypeDefinition.getQName(xsdComplexTypeDefinition));
- }
- }
-
- return result.toString();
- }
-
- public Object[] getChildren(Object parentElement)
- {
- XSDComplexTypeDefinition xsdComplexTypeDefinition = (XSDComplexTypeDefinition)parentElement;
- List list = new ArrayList();
-
- if (xsdComplexTypeDefinition.getContent() != null)
- {
- XSDComplexTypeContent xsdComplexTypeContent = xsdComplexTypeDefinition.getContent();
- if (xsdComplexTypeContent instanceof XSDParticle)
- {
- list.add(((XSDParticle)xsdComplexTypeContent).getContent());
- }
- }
-
-// if (((XSDModelAdapterFactoryImpl)adapterFactory).getShowInherited())
-// {
-// if (xsdComplexTypeDefinition.getSyntheticParticle() != null)
-// {
-// XSDTypeDefinition type = xsdComplexTypeDefinition.getBaseTypeDefinition();
-// list.addAll(XSDChildUtility.getModelChildren(type));
-// }
-// if (xsdComplexTypeDefinition.getSyntheticWildcard() != null)
-// {
-// list.add(xsdComplexTypeDefinition.getSyntheticWildcard());
-// }
-// }
-
-// List attributes = xsdComplexTypeDefinition.getAttributeContents();
-// if (attributes.size() > 0)
-// {
-// list.addAll(attributes);
-// }
-
-// list = new ArrayList();
- if (((XSDModelAdapterFactoryImpl)adapterFactory).getShowInherited())
- {
- if (xsdComplexTypeDefinition.getDerivationMethod().getName().equals("extension"))
- {
- XSDTypeDefinition type = xsdComplexTypeDefinition.getBaseTypeDefinition();
- Iterator iter = XSDChildUtility.getModelChildren(type).iterator();
- boolean cont = true;
- while (cont)
- {
- while (iter.hasNext())
- {
- list.add(0, iter.next());
- }
-
- if (type instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)type;
- type = ctd.getBaseTypeDefinition();
-
- // defect 264957 - workbench hangs when modifying complex content
- // Since we don't filter out the current complexType from
- // the combobox, we can potentially have an endless loop
- if (ctd == type)
- {
- cont = false;
- break;
- }
-
- if (ctd.getDerivationMethod().getName().equals("extension"))
- {
- iter = XSDChildUtility.getModelChildren(type).iterator();
- }
- else
- {
- cont = false;
- }
- }
- else
- {
- cont = false;
- }
- }
-
- }
-
-
-// list.addAll(XSDChildUtility.getModelChildren(baseType));
- }
-
-// list.addAll(XSDChildUtility.getModelChildren(xsdComplexTypeDefinition));
-
- return list.toArray();
-
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDComplexTypeDefinition element = (XSDComplexTypeDefinition)object;
- return element.getContainer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDContentProvider.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDContentProvider.java
deleted file mode 100644
index 984e099274..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDContentProvider.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.edit.provider.IChangeNotifier;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticleContent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDWildcard;
-import org.w3c.dom.Node;
-
-public class XSDContentProvider implements ITreeContentProvider, INotifyChangedListener
-{
- XSDModelAdapterFactoryImpl xsdModelAdapterFactory;
-
- public XSDContentProvider(XSDModelAdapterFactoryImpl xsdModelAdapterFactoryImpl)
- {
- this.xsdModelAdapterFactory = xsdModelAdapterFactoryImpl;
-
- if (xsdModelAdapterFactory instanceof IChangeNotifier)
- {
- ((IChangeNotifier)xsdModelAdapterFactory).addListener(this);
- }
- }
-
- /*
- * @see ITreeContentProvider#getChildren(Object)
- */
- public Object[] getChildren(Object parentElement)
- {
- XSDConcreteComponent xsdComp = null;
- List list = null;
-
- // root/input is structuredmodel
- if (parentElement instanceof IDOMModel) {
- IDOMDocument domDoc = ((IDOMModel) parentElement).getDocument();
- if (domDoc != null) {
- XSDModelAdapter modelAdapter = (XSDModelAdapter) domDoc.getExistingAdapter(XSDModelAdapter.class);
- /*
- * ISSUE: Didn't want to go through initializing
- * schema if it does not already exist, so just
- * attempted to get existing adapter. If doesn't
- * exist, just don't bother working.
- */
- if (modelAdapter != null)
- xsdComp = modelAdapter.getSchema();
- if (xsdComp != null) {
- xsdModelAdapterFactory.adapt(xsdComp, xsdModelAdapterFactory);
-
- list = new ArrayList();
- list.add(xsdComp);
- return list.toArray();
- }
- }
- }
- else if (parentElement instanceof XSDConcreteComponent)
- {
- xsdComp = (XSDConcreteComponent)parentElement;
- list = new ArrayList();
- }
- else if (parentElement instanceof ITreeItemContentProvider)
- {
- return ((ITreeItemContentProvider)parentElement).getChildren(parentElement).toArray();
- }
- else if (parentElement instanceof ITreeContentProvider)
- {
- return ((ITreeContentProvider)parentElement).getChildren(parentElement);
- }
-
- if (xsdComp != null)
- {
- XSDAbstractAdapter a = (XSDAbstractAdapter)xsdModelAdapterFactory.adapt(xsdComp, xsdModelAdapterFactory);
-
- if (xsdComp instanceof XSDElementDeclaration || xsdComp instanceof XSDModelGroup || xsdComp instanceof XSDWildcard)
- {
- xsdModelAdapterFactory.adapt(((XSDParticleContent)xsdComp).getContainer(), xsdModelAdapterFactory);
- }
-
- if (a != null)
- {
- Object [] obj = a.getChildren(xsdComp);
- if (obj != null)
- {
- list = Arrays.asList(obj);
- }
- }
- }
-
- list = list != null ? list : Collections.EMPTY_LIST;
- return list.toArray();
- }
-
- /*
- * @see ITreeContentProvider#getParent(Object)
- */
- public Object getParent(Object element)
- {
- if (element instanceof Node)
- {
- return ((Node)element).getParentNode();
- }
- else if (element instanceof XSDConcreteComponent)
- {
- return ((XSDConcreteComponent)element).getContainer();
- }
- return null;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren(Object)
- */
- public boolean hasChildren(Object element)
- {
- Object[] children = getChildren(element);
- return children != null && children.length > 0;
- }
-
- /*
- * @see IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement)
- {
- return getChildren(inputElement);
- }
-
- public void notifyChanged(Notification notification)
- {
- if (viewer != null)
- {
- if (viewer instanceof StructuredViewer)
- {
- if (notification.getFeature() instanceof EAttribute)
- {
- ((StructuredViewer)viewer).update(notification.getNotifier(), null);
- }
- else
- {
- ((StructuredViewer)viewer).refresh(notification.getNotifier());
- }
- }
- else
- {
- viewer.refresh();
- }
- }
-
- }
-
- /*
- * @see IContentProvider#dispose()
- */
- public void dispose()
- {
- viewer = null;
- xsdModelAdapterFactory.removeListener(this);
- }
-
- protected Viewer viewer = null;
-
- /*
- * @see IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- this.viewer = viewer;
- }
-
- /**
- * Gets the xsd schema from document
- *
- * @param document
- * @return XSDSchema or null of one does not exist yet for document
- */
- private XSDSchema getXSDSchema(IDocument document) {
- XSDSchema schema = null;
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- try {
- if (model instanceof IDOMModel) {
- IDOMDocument domDoc = ((IDOMModel) model).getDocument();
- if (domDoc != null) {
- XSDModelAdapter modelAdapter = (XSDModelAdapter) domDoc.getExistingAdapter(XSDModelAdapter.class);
- /*
- * ISSUE: Didn't want to go through initializing
- * schema if it does not already exist, so just
- * attempted to get existing adapter. If doesn't
- * exist, just don't bother working.
- */
- if (modelAdapter != null)
- schema = modelAdapter.getSchema();
- }
- }
- }
- finally {
- model.releaseFromRead();
- }
- }
- return schema;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDElementDeclarationAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDElementDeclarationAdapter.java
deleted file mode 100644
index f273ccfbdd..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDElementDeclarationAdapter.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class XSDElementDeclarationAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDElementDeclarationAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object element)
- {
- XSDElementDeclaration xsdElementDeclaration = ((XSDElementDeclaration)element);
-
- if (!xsdElementDeclaration.isElementDeclarationReference())
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDElement.gif");
- }
- else
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDElementRef.gif");
- }
- }
-
- public String getText(Object object)
- {
- XSDElementDeclaration xsdElementDeclaration = ((XSDElementDeclaration)object);
- XSDElementDeclaration resolvedElementDeclaration = xsdElementDeclaration.getResolvedElementDeclaration();
- String name =
- xsdElementDeclaration != resolvedElementDeclaration ?
- xsdElementDeclaration.getQName() :
- xsdElementDeclaration.getName();
-
- StringBuffer result = new StringBuffer();
- if (name == null)
- {
- result.append("'absent'");
- }
- else
- {
- result.append(name);
- }
-
- if (!xsdElementDeclaration.isGlobal())
- {
- Element element = xsdElementDeclaration.getElement();
- boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
- boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
-
- if (hasMinOccurs || hasMaxOccurs)
- {
- result.append(" [");
- if (hasMinOccurs)
- {
- int min = ((XSDParticle)xsdElementDeclaration.getContainer()).getMinOccurs();
- if (min == XSDParticle.UNBOUNDED)
- {
- result.append("*");
- }
- else
- {
- result.append(String.valueOf(min));
- }
- }
- else // print default
- {
- int min = ((XSDParticle)xsdElementDeclaration.getContainer()).getMinOccurs();
- result.append(String.valueOf(min));
- }
- if (hasMaxOccurs)
- {
- int max = ((XSDParticle)xsdElementDeclaration.getContainer()).getMaxOccurs();
- result.append("..");
- if (max == XSDParticle.UNBOUNDED)
- {
- result.append("*");
- }
- else
- {
- result.append(String.valueOf(max));
- }
- }
- else // print default
- {
- result.append("..");
- int max = ((XSDParticle)xsdElementDeclaration.getContainer()).getMaxOccurs();
- result.append(String.valueOf(max));
-
- }
- result.append("]");
- }
- }
-
- if (resolvedElementDeclaration.getAnonymousTypeDefinition() == null && resolvedElementDeclaration.getTypeDefinition() != null)
- {
- result.append(" : ");
- result.append(resolvedElementDeclaration.getTypeDefinition().getQName(xsdElementDeclaration));
- }
-
- return result.toString();
- }
-
- public Object[] getChildren(Object parentElement)
- {
- XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)parentElement;
- List list = new ArrayList();
- XSDTypeDefinition type = null;
- if (xsdElementDeclaration.isElementDeclarationReference())
- {
- if (((XSDModelAdapterFactoryImpl)adapterFactory).getShowReferences())
- {
- type = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition();
- }
- }
- else
- {
- type = xsdElementDeclaration.getAnonymousTypeDefinition();
- if (type == null)
- {
- if (((XSDModelAdapterFactoryImpl)adapterFactory).getShowReferences())
- {
- type = xsdElementDeclaration.getTypeDefinition();
- }
- }
- }
-
- if (type != null && type instanceof XSDComplexTypeDefinition)
- {
- XSDComplexTypeDefinition ctType = (XSDComplexTypeDefinition)type;
- if (ctType != null)
- {
- list.add(ctType);
- }
- }
-
-// if (xsdElementDeclaration.getIdentityConstraintDefinitions() != null)
-// {
-// list.addAll(xsdElementDeclaration.getIdentityConstraintDefinitions());
-// }
-
-// return XSDChildUtility.getModelChildren(xsdElementDeclaration.getResolvedElementDeclaration()).toArray();
- return list.toArray();
-
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDElementDeclaration element = (XSDElementDeclaration)object;
- return element.getContainer();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelAdapterFactoryImpl.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelAdapterFactoryImpl.java
deleted file mode 100644
index 4b64fce158..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelAdapterFactoryImpl.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.provider.ChangeNotifier;
-import org.eclipse.emf.edit.provider.Disposable;
-import org.eclipse.emf.edit.provider.IChangeNotifier;
-import org.eclipse.emf.edit.provider.IDisposable;
-import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.xsd.XSDAnnotation;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-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.XSDWildcard;
-import org.eclipse.xsd.util.XSDAdapterFactory;
-import org.eclipse.xsd.util.XSDSwitch;
-
-public class XSDModelAdapterFactoryImpl extends XSDAdapterFactory
- implements IChangeNotifier, IDisposable
-{
- static XSDModelAdapterFactoryImpl instance;
-
- public static XSDModelAdapterFactoryImpl getInstance()
- {
- if (instance == null)
- {
- instance = new XSDModelAdapterFactoryImpl();
- }
- return instance;
- }
-
- protected IChangeNotifier changeNotifier = new ChangeNotifier();
-
- protected Disposable disposable = new Disposable();
-
- protected Collection supportedTypes = new ArrayList();
-
- protected boolean showReferences = false;
- protected boolean showInherited = false;
-
- /**
- *
- */
- public XSDModelAdapterFactoryImpl()
- {
- super();
- supportedTypes.add(ILabelProvider.class);
- }
-
- public void setShowReferences(boolean b)
- {
- showReferences = b;
- }
-
- public boolean getShowReferences()
- {
- return showReferences;
- }
-
- public void setShowInherited(boolean b)
- {
- showInherited= b;
- }
-
- public boolean getShowInherited()
- {
- return showInherited;
- }
-
- protected XSDSwitch modelSwitch = new XSDSwitch()
- {
- public Object caseXSDAnnotation(XSDAnnotation object)
- {
- return createXSDAnnotationAdapter();
- }
- public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object)
- {
- return createXSDAttributeDeclarationAdapter();
- }
- public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object)
- {
- return createXSDAttributeGroupDefinitionAdapter();
- }
- public Object caseXSDAttributeUse(XSDAttributeUse object)
- {
- return createXSDAttributeUseAdapter();
- }
- public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object)
- {
- return createXSDComplexTypeDefinitionAdapter();
- }
- public Object caseXSDElementDeclaration(XSDElementDeclaration object)
- {
- return createXSDElementDeclarationAdapter();
- }
- public Object caseXSDModelGroup(XSDModelGroup object)
- {
- return createXSDModelGroupAdapter();
- }
- public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object)
- {
- return createXSDModelGroupDefinitionAdapter();
- }
- public Object caseXSDNotationDeclaration(XSDNotationDeclaration object)
- {
- return createXSDNotationDeclarationAdapter();
- }
- public Object caseXSDParticle(XSDParticle object)
- {
- return createXSDParticleAdapter();
- }
-// public Object caseXSDParticleContent(XSDParticleContent object)
-// {
-// return createXSDParticleContentAdapter();
-// }
- public Object caseXSDSchema(XSDSchema object)
- {
- return createXSDSchemaAdapter();
- }
- public Object caseXSDImport(XSDImport object)
- {
- // return createXSDImportAdapter();
- return createXSDSchemaDirectiveAdapter();
- }
- public Object caseXSDInclude(XSDInclude object)
- {
- // return createXSDIncludeAdapter();
- return createXSDSchemaDirectiveAdapter();
- }
- public Object caseXSDRedefine(XSDRedefine object)
- {
- // return createXSDRedefineAdapter();
- return createXSDSchemaDirectiveAdapter();
- }
- public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object)
- {
- return createXSDSimpleTypeDefinitionAdapter();
-
- }
- public Object caseXSDWildcard(XSDWildcard object)
- {
- return createXSDWildcardAdapter();
- }
- public Object defaultCase(EObject object)
- {
- return createEObjectAdapter();
- }
- };
-
- public Adapter createAdapter(Notifier target)
- {
- Adapter adapter = null;
- if (target instanceof EObject)
- {
- adapter = (Adapter)modelSwitch.doSwitch((EObject)target);
- }
- return adapter;
- }
-
- /* create adapters */
-
- public Adapter createXSDAnnotationAdapter()
- {
- return new XSDAnnotationAdapter(this);
- }
-
- public Adapter createXSDAttributeDeclarationAdapter()
- {
- return new XSDAttributeDeclarationAdapter(this);
- }
-
- public Adapter createXSDAttributeGroupDefinitionAdapter()
- {
- return new XSDAttributeGroupDefinitionAdapter(this);
- }
-
- public Adapter createXSDAttributeUseAdapter()
- {
- return new XSDAttributeUseAdapter(this);
- }
-
- public Adapter createXSDComplexTypeDefinitionAdapter()
- {
- return new XSDComplexTypeDefinitionAdapter(this);
- }
-
- public Adapter createXSDElementDeclarationAdapter()
- {
- return new XSDElementDeclarationAdapter(this);
- }
-
- public Adapter createXSDModelGroupAdapter()
- {
- return new XSDModelGroupAdapter(this);
- }
-
-
- public Adapter createXSDModelGroupDefinitionAdapter()
- {
- return new XSDModelGroupDefinitionAdapter(this);
- }
-
- public Adapter createXSDNotationDeclarationAdapter()
- {
- return new XSDNotationDeclarationAdapter(this);
- }
-
- public Adapter createXSDWildcardAdapter()
- {
- return new XSDWildcardAdapter(this);
- }
-
- public Adapter createXSDParticleAdapter()
- {
- return new XSDParticleAdapter(this);
- }
-//
-// protected XSDParticleContentAdapter xsdParticleContentAdapter;
-// public Adapter createXSDParticleContentAdapter()
-// {
-// if (xsdParticleContentAdapter == null)
-// {
-// xsdParticleContentAdapter = new XSDParticleContentAdapter(this);
-// }
-// return xsdParticleContentAdapter;
-// }
-
- public Adapter createXSDSchemaAdapter()
- {
- return new XSDSchemaAdapter(this);
- }
-
- public Adapter createXSDSchemaDirectiveAdapter()
- {
- return new XSDSchemaDirectiveAdapter(this);
- }
-
- public Adapter createXSDSimpleTypeDefinitionAdapter()
- {
- return new XSDSimpleTypeDefinitionAdapter(this);
- }
-
- public Adapter createEObjectAdapter()
- {
- return null;
- }
-
- public boolean isFactoryForType(Object type)
- {
- return super.isFactoryForType(type) || supportedTypes.contains(type);
- }
-
- /**
- * This implementation substitutes the factory itself as the key for the adapter.
- */
- public Adapter adapt(Notifier notifier, Object type)
- {
- return super.adapt(notifier, this);
- }
-
- public Object adapt(Object object, Object type)
- {
- // This is a kludge to deal with enumerators, which crash the doSwitch.
- //
- if (object instanceof EObject && ((EObject)object).eClass() == null)
- {
- return null;
- }
-
- if (isFactoryForType(type))
- {
- Object adapter = super.adapt(object, type);
- if (!(type instanceof Class) || (((Class)type).isInstance(adapter)))
- {
- return adapter;
- }
- }
-
- return null;
- }
-
- public Adapter adaptNew(Notifier object, Object type)
- {
- Adapter result = super.adaptNew(object, type);
- disposable.add(result);
- return result;
- }
-
- /**
- * This adds a listener.
- */
- public void addListener(INotifyChangedListener notifyChangedListener)
- {
- changeNotifier.addListener(notifyChangedListener);
- }
-
- /**
- * This removes a listener.
- */
- public void removeListener(INotifyChangedListener notifyChangedListener)
- {
- changeNotifier.removeListener(notifyChangedListener);
- }
-
- /**
- * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
- */
- public void fireNotifyChanged(Notification notification)
- {
- Display display = Display.getDefault();
- if (display != null)
- {
- if (display.getThread() == Thread.currentThread ())
- {
- changeNotifier.fireNotifyChanged(notification);
- }
- }
-
-// if (parentAdapterFactory != null)
-// {
-// parentAdapterFactory.fireNotifyChanged(notification);
-// }
- }
-
- public void dispose()
- {
- instance = null;
- disposable.dispose();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupAdapter.java
deleted file mode 100644
index c8535b68cb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupAdapter.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.graph.XSDChildUtility;
-import org.eclipse.xsd.XSDCompositor;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class XSDModelGroupAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDModelGroupAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object element)
- {
- XSDModelGroup xsdModelGroup = ((XSDModelGroup)element);
- if (XSDCompositor.CHOICE_LITERAL == xsdModelGroup.getCompositor())
- {
- // return XSDEditorPlugin.getPlugin().getIconImage("full/obj16/XSDModelGroupChoice");
- return XSDEditorPlugin.getXSDImage("icons/XSDChoice.gif");
- }
- else if (XSDCompositor.ALL_LITERAL == xsdModelGroup.getCompositor())
- {
- // return XSDEditorPlugin.getPlugin().getIconImage("full/obj16/XSDModelGroupAll");
- return XSDEditorPlugin.getXSDImage("icons/XSDAll.gif");
- }
- else
- {
- // return XSDEditorPlugin.getPlugin().getIconImage("full/obj16/XSDModelGroupSequence");
- return XSDEditorPlugin.getXSDImage("icons/XSDSequence.gif");
- }
- }
-
- public String getText(Object object)
- {
- XSDModelGroup xsdModelGroup = ((XSDModelGroup)object);
-
- StringBuffer result = new StringBuffer();
- String name = xsdModelGroup.getCompositor().getName();
- if (name != null)
- {
- result.append(name);
- }
-
- Element element = xsdModelGroup.getElement();
-
- if (element != null)
- {
- boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
- boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
-
- if (hasMinOccurs || hasMaxOccurs)
- {
- XSDConcreteComponent comp = xsdModelGroup.getContainer();
- boolean isParticle = (comp instanceof XSDParticle);
- if (isParticle)
- {
- result.append(" [");
- }
- if (hasMinOccurs)
- {
- if (isParticle)
- {
- int min = ((XSDParticle)comp).getMinOccurs();
- if (min == XSDParticle.UNBOUNDED)
- {
- result.append("*");
- }
- else
- {
- result.append(String.valueOf(min));
- }
- }
- }
- else // print default
- {
- if (isParticle)
- {
- int min = ((XSDParticle)comp).getMinOccurs();
- result.append(String.valueOf(min));
- }
- }
- if (hasMaxOccurs)
- {
- if (isParticle)
- {
- int max = ((XSDParticle)comp).getMaxOccurs();
- result.append("..");
- if (max == XSDParticle.UNBOUNDED)
- {
- result.append("*");
- }
- else
- {
- result.append(String.valueOf(max));
- }
- }
- }
- else // print default
- {
- if (isParticle)
- {
- result.append("..");
- int max = ((XSDParticle)comp).getMaxOccurs();
- result.append(String.valueOf(max));
- }
- }
- if (isParticle)
- {
- result.append("]");
- }
- }
- }
- return result.toString();
- }
-
- public Object[] getChildren(Object parentElement)
- {
- XSDModelGroup xsdModelGroup = (XSDModelGroup)parentElement;
- List list = new ArrayList();
- // list.addAll(xsdModelGroup.getContents());
- list.addAll(XSDChildUtility.getModelChildren(xsdModelGroup));
- return list.toArray();
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDModelGroup element = (XSDModelGroup)object;
- return element.getContainer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupDefinitionAdapter.java
deleted file mode 100644
index 93e551c6c7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDModelGroupDefinitionAdapter.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-
-
-public class XSDModelGroupDefinitionAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDModelGroupDefinitionAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- XSDModelGroupDefinition xsdModelGroupDefinition = ((XSDModelGroupDefinition)object);
-
- if (xsdModelGroupDefinition.isModelGroupDefinitionReference())
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDGroupRef.gif");
- }
- else
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDGroup.gif");
- }
- }
-
- public String getText(Object object)
- {
- XSDModelGroupDefinition xsdModelGroupDefinition = ((XSDModelGroupDefinition)object);
- String result =
- xsdModelGroupDefinition.isModelGroupDefinitionReference() ?
- xsdModelGroupDefinition.getQName() :
- xsdModelGroupDefinition.getName();
- return result == null ? "'absent'" : result;
- }
-
- boolean hasChildren = false;
-
- public Object[] getChildren(Object parentElement)
- {
- XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition)parentElement;
- List list = new ArrayList();
- if (xsdModelGroupDefinition.isModelGroupDefinitionReference())
- {
- if (((XSDModelAdapterFactoryImpl)adapterFactory).getShowReferences())
- {
- list.add(xsdModelGroupDefinition.getResolvedModelGroupDefinition().getModelGroup());
- hasChildren = true;
- }
- }
- else
- {
- if (xsdModelGroupDefinition.getModelGroup() != null)
- {
- list.add(xsdModelGroupDefinition.getModelGroup());
- hasChildren = true;
- }
- }
-
- return list.toArray();
-
- }
-
- public boolean hasChildren(Object object)
- {
- return hasChildren;
- }
-
- public Object getParent(Object object)
- {
- XSDModelGroupDefinition element = (XSDModelGroupDefinition)object;
- return element.getContainer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDNotationDeclarationAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDNotationDeclarationAdapter.java
deleted file mode 100644
index 3c892745ad..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDNotationDeclarationAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDNotationDeclaration;
-
-
-public class XSDNotationDeclarationAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDNotationDeclarationAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- // return XSDEditorPlugin.getPlugin().getIconImage("full/obj16/XSDNotationDeclaration");
- return XSDEditorPlugin.getXSDImage("icons/XSDNotation.gif");
- }
-
- public String getText(Object object)
- {
- XSDNotationDeclaration xsdNotationDeclaration = ((XSDNotationDeclaration)object);
- String result = xsdNotationDeclaration.getName();
- return result == null ? "" : result;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDParticleAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDParticleAdapter.java
deleted file mode 100644
index c37e8a77c3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDParticleAdapter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.NotificationWrapper;
-import org.eclipse.wst.xsd.ui.internal.graph.model.XSDModelAdapterFactory;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDParticleContent;
-import org.eclipse.xsd.XSDWildcard;
-
-
-public class XSDParticleAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDParticleAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- // hack to notify outline and graph view of minOccurs and maxOccurs changes
- public void notifyChanged(Notification msg)
- {
- XSDParticle xsdParticle = (XSDParticle)msg.getNotifier();
- XSDParticleContent xsdParticleContent = xsdParticle.getContent();
- if (xsdParticleContent != null)
- {
- if (xsdParticleContent instanceof XSDElementDeclaration)
- {
- fireNotifyChanged(new NotificationWrapper((XSDElementDeclaration)xsdParticleContent, msg));
- XSDModelAdapterFactory.getAdapter(xsdParticleContent).firePropertyChanged(xsdParticleContent, null);
- }
- else if (xsdParticleContent instanceof XSDModelGroup)
- {
- fireNotifyChanged(new NotificationWrapper((XSDModelGroup)xsdParticleContent, msg));
- XSDModelAdapterFactory.getAdapter(xsdParticleContent).firePropertyChanged(xsdParticleContent, null);
- }
- else if (xsdParticleContent instanceof XSDWildcard)
- {
- fireNotifyChanged(new NotificationWrapper((XSDWildcard)xsdParticleContent, msg));
- XSDModelAdapterFactory.getAdapter(xsdParticleContent).firePropertyChanged(xsdParticleContent, null);
- }
- }
- // super.notifyChanged(msg);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaAdapter.java
deleted file mode 100644
index 4836bc71c2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaAdapter.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNotationDeclaration;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-
-public class XSDSchemaAdapter extends XSDAbstractAdapter {
- protected XSDPackage xsdPackage;
-
- /**
- * @param adapterFactory
- */
- public XSDSchemaAdapter(AdapterFactory adapterFactory) {
- super(adapterFactory);
- xsdPackage = XSDPackage.eINSTANCE;
- }
-
- public Image getImage(Object element) {
- return XSDEditorPlugin.getXSDImage("icons/XSDFile.gif");
- }
-
- public String getText(Object element) {
- XSDSchema xsdSchema = (XSDSchema) element;
- String result = xsdSchema.getSchemaLocation();
- if (result == null) {
- return "";
- }
- else {
- return URI.createURI(result).lastSegment();
- }
- }
-
- List children;
- private CategoryAdapter fDirectivesCategory;
- private CategoryAdapter fElementsCategory;
- private CategoryAdapter fAttributesCategory;
- private CategoryAdapter fAttributeGroupsCategory;
- private CategoryAdapter fTypesCategory;
- private CategoryAdapter fGroupsCategory;
- private CategoryAdapter fNotationsCategory;
-
- /**
- * Create all the category adapters
- *
- * @param xsdSchema
- */
- private void createCategoryAdapters(XSDSchema xsdSchema) {
- List directivesList = getDirectives(xsdSchema);
- List elementsList = getGlobalElements(xsdSchema);
- List attributeGroupList = getAttributeGroupList(xsdSchema);
- List attributesList = getAttributeList(xsdSchema);
- List groups = getGroups(xsdSchema);
- List notations = getNotations(xsdSchema);
- List types = getComplexTypes(xsdSchema);
- types.addAll(getSimpleTypes(xsdSchema));
-
- fDirectivesCategory = new CategoryAdapter( // XSDEditPlugin.getString("_UI_Elements_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_DIRECTIVES"), XSDEditorPlugin.getPlugin().getIconImage("obj16/directivesheader"), directivesList, xsdSchema, CategoryAdapter.DIRECTIVES);
- fElementsCategory = new CategoryAdapter( // XSDEditPlugin.getString("_UI_Elements_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_ELEMENTS"), XSDEditorPlugin.getPlugin().getIconImage("obj16/elementsheader"), elementsList, xsdSchema, CategoryAdapter.ELEMENTS);
- fAttributesCategory = new CategoryAdapter( // XSDEditPlugin.getString("_UI_Attributes_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_ATTRIBUTES"), XSDEditorPlugin.getPlugin().getIconImage("obj16/attributesheader"), attributesList, xsdSchema, CategoryAdapter.ATTRIBUTES);
- fAttributeGroupsCategory = new CategoryAdapter(// XSDEditPlugin.getString("_UI_AttributeGroups_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_ATTRIBUTE_GROUPS"), XSDEditorPlugin.getPlugin().getIconImage("obj16/attributegroupsheader"), attributeGroupList, xsdSchema, CategoryAdapter.ATTRIBUTE_GROUPS);
- fTypesCategory = new CategoryAdapter( // XSDEditPlugin.getString("_UI_Types_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_TYPES"), XSDEditorPlugin.getPlugin().getIconImage("obj16/typesheader"), types, xsdSchema, CategoryAdapter.TYPES);
- fGroupsCategory = new CategoryAdapter( // XSDEditPlugin.getString("_UI_ModelGroups_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_GROUPS"), XSDEditorPlugin.getPlugin().getIconImage("obj16/groupsheader"), groups, xsdSchema, CategoryAdapter.GROUPS);
- fNotationsCategory = new CategoryAdapter( // XSDEditPlugin.getString("_UI_Notations_label"),
- XSDEditorPlugin.getXSDString("_UI_GRAPH_NOTATIONS"), XSDEditorPlugin.getPlugin().getIconImage("obj16/notationsheader"), notations, xsdSchema, CategoryAdapter.NOTATIONS);
- }
-
- public void setTarget(Notifier newTarget) {
- super.setTarget(newTarget);
-
- XSDSchema xsdSchema = ((XSDSchema) newTarget);
- createCategoryAdapters(xsdSchema);
- }
-
- public Object[] getChildren(Object parentElement) {
- XSDSchema xsdSchema = ((XSDSchema) parentElement);
-
- children = new ArrayList();
-
- // just set categoryadapters' children if category adapters are
- // already created
- if (fDirectivesCategory != null) {
- List directivesList = getDirectives(xsdSchema);
- List elementsList = getGlobalElements(xsdSchema);
- List attributeGroupList = getAttributeGroupList(xsdSchema);
- List attributesList = getAttributeList(xsdSchema);
- List groups = getGroups(xsdSchema);
- List notations = getNotations(xsdSchema);
- List types = getComplexTypes(xsdSchema);
- types.addAll(getSimpleTypes(xsdSchema));
-
- fDirectivesCategory.setChildren(directivesList);
- fElementsCategory.setChildren(elementsList);
- fAttributesCategory.setChildren(attributesList);
- fAttributeGroupsCategory.setChildren(attributeGroupList);
- fTypesCategory.setChildren(types);
- fGroupsCategory.setChildren(groups);
- fNotationsCategory.setChildren(notations);
-
- // children.add
- // (new CategoryAdapter
- // ( //XSDEditPlugin.getString("_UI_IdentityConstraints_label"),
- // "Identity Constraints",
- // XSDEditorPlugin.getPlugin().getIconImage("full/obj16/XSDIdentityConstraintDefinitionKey"),
- // xsdSchema.getIdentityConstraintDefinitions(), xsdSchema,
- // CategoryAdapter.IDENTITY_CONSTRAINTS));
- // children.add
- // (new CategoryAdapter
- // ( // XSDEditPlugin.getString("_UI_Annotations_label"),
- // "Annotations",
- // XSDEditorPlugin.getPlugin().getIconImage("obj16/annotationsheader"),
- // xsdSchema.getAnnotations(), xsdSchema,
- // CategoryAdapter.ANNOTATIONS));
- }
- else {
- createCategoryAdapters(xsdSchema);
- }
-
- children.add(fDirectivesCategory);
- children.add(fElementsCategory);
- children.add(fAttributesCategory);
- children.add(fAttributeGroupsCategory);
- children.add(fTypesCategory);
- children.add(fGroupsCategory);
- children.add(fNotationsCategory);
-
- return children.toArray();
- }
-
- public boolean hasChildren(Object object) {
- return true;
- }
-
- public Object getParent(Object object) {
- return null;
- }
-
- public void notifyChanged(final Notification msg) {
- class CategoryNotification extends NotificationImpl {
- protected Object category;
-
- public CategoryNotification(Object category) {
- super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
- this.category = category;
- }
-
- public Object getNotifier() {
- return category;
- }
-
- public Object getFeature() {
- return msg.getFeature();
- }
- }
-
- if (children == null) {
- getChildren(target);
- }
-
- if (msg.getFeature() == xsdPackage.getXSDSchema_Contents()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(0);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- adapter.setChildren(getDirectives(xsdSchema));
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_ElementDeclarations()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(1);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- adapter.setChildren(getGlobalElements(xsdSchema));
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_AttributeDeclarations()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(2);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- adapter.setChildren(getAttributeList(xsdSchema));
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_AttributeGroupDefinitions()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(3);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- adapter.setChildren(getAttributeGroupList(xsdSchema));
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_TypeDefinitions()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(4);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- List types = getComplexTypes(xsdSchema);
- types.addAll(getSimpleTypes(xsdSchema));
-
- adapter.setChildren(types);
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_ModelGroupDefinitions()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(5);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- adapter.setChildren(getGroups(xsdSchema));
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_NotationDeclarations()) {
- CategoryAdapter adapter = (CategoryAdapter) children.get(6);
- XSDSchema xsdSchema = adapter.getXSDSchema();
- adapter.setChildren(getNotations(xsdSchema));
- this.fireNotifyChanged(new CategoryNotification(adapter));
- return;
- }
- // else if (msg.getFeature() ==
- // xsdPackage.getXSDSchema_IdentityConstraintDefinitions())
- // {
- // this.fireNotifyChanged(new CategoryNotification(children.get(7)));
- // return;
- // }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_Annotations()) {
- // this.fireNotifyChanged(new
- // CategoryNotification(children.get(7)));
- return;
- }
- else if (msg.getFeature() == xsdPackage.getXSDSchema_SchemaLocation()) {
- this.fireNotifyChanged(msg);
- return;
- }
-
- super.notifyChanged(msg);
- }
-
- protected List getDirectives(XSDSchema schema) {
- List list = new ArrayList();
- for (Iterator i = schema.getContents().iterator(); i.hasNext();) {
- Object o = i.next();
- if (o instanceof XSDSchemaDirective) {
- list.add(o);
- }
- }
- return list;
- }
-
- protected List getAttributeGroupList(XSDSchema xsdSchema) {
- List attributeGroupList = new ArrayList();
- for (Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator(); i.hasNext();) {
- XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) i.next();
- if (attrGroup.getRootContainer() == xsdSchema) {
- attributeGroupList.add(attrGroup);
- }
- }
- return attributeGroupList;
- }
-
- protected List getAttributeList(XSDSchema xsdSchema) {
- List attributesList = new ArrayList();
- for (Iterator iter = xsdSchema.getAttributeDeclarations().iterator(); iter.hasNext();) {
- Object o = iter.next();
- if (o instanceof XSDAttributeDeclaration) {
- XSDAttributeDeclaration attr = (XSDAttributeDeclaration) o;
- if (attr != null) {
- if (attr.getTargetNamespace() != null) {
- if (!(attr.getTargetNamespace().equals("http://www.w3.org/2001/XMLSchema-instance"))) {
- if (attr.getRootContainer() == xsdSchema) {
- attributesList.add(attr);
- }
- }
- }
- else {
- if (attr.getRootContainer() == xsdSchema) {
- attributesList.add(attr);
- }
- }
- }
- }
- }
- return attributesList;
- }
-
- protected List getGlobalElements(XSDSchema schema) {
- List elements = schema.getElementDeclarations();
- List list = new ArrayList();
- for (Iterator i = elements.iterator(); i.hasNext();) {
- XSDElementDeclaration elem = (XSDElementDeclaration) i.next();
- if (elem.getRootContainer() == schema) {
- list.add(elem);
- }
- }
- return list;
- }
-
- protected List getComplexTypes(XSDSchema schema) {
- List allTypes = schema.getTypeDefinitions();
- List list = new ArrayList();
- for (Iterator i = allTypes.iterator(); i.hasNext();) {
- XSDTypeDefinition td = (XSDTypeDefinition) i.next();
- if (td instanceof XSDComplexTypeDefinition) {
- XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) td;
- if (ct.getRootContainer() == schema) {
- list.add(ct);
- }
- }
- }
- return list;
- }
-
- protected List getSimpleTypes(XSDSchema schema) {
- List allTypes = schema.getTypeDefinitions();
- List list = new ArrayList();
- for (Iterator i = allTypes.iterator(); i.hasNext();) {
- XSDTypeDefinition td = (XSDTypeDefinition) i.next();
- if (td instanceof XSDSimpleTypeDefinition) {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) td;
- if (st.getRootContainer() == schema) {
- list.add(st);
- }
- }
- }
- return list;
- }
-
- protected List getGroups(XSDSchema schema) {
- List groups = schema.getModelGroupDefinitions();
- List list = new ArrayList();
- for (Iterator i = groups.iterator(); i.hasNext();) {
- XSDModelGroupDefinition group = (XSDModelGroupDefinition) i.next();
- if (group.getRootContainer() == schema) {
- list.add(group);
- }
- }
- return list;
- }
-
- protected List getNotations(XSDSchema schema) {
- List notations = schema.getNotationDeclarations();
- List list = new ArrayList();
- for (Iterator i = notations.iterator(); i.hasNext();) {
- XSDNotationDeclaration notation = (XSDNotationDeclaration) i.next();
- if (notation.getRootContainer() == schema) {
- list.add(notation);
- }
- }
- return list;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaDirectiveAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaDirectiveAdapter.java
deleted file mode 100644
index 47cf912e6d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSchemaDirectiveAdapter.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDRedefine;
-import org.eclipse.xsd.XSDSchemaDirective;
-
-public class XSDSchemaDirectiveAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDSchemaDirectiveAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
-
- public Image getImage(Object object)
- {
- if (object instanceof XSDImport)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDImport.gif");
- }
- else if (object instanceof XSDInclude)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDInclude.gif");
- }
- else if (object instanceof XSDRedefine)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDRedefine.gif");
- }
- return null;
- }
-
- public String getText(Object object)
- {
- XSDSchemaDirective directive = (XSDSchemaDirective)object;
- String result = directive.getSchemaLocation();
- if (result == null) result = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED") + ")";
- if (result.equals("")) result = "(" + XSDEditorPlugin.getXSDString("_UI_LABEL_NO_LOCATION_SPECIFIED")+ ")";
- return result;
-
-// XSDImport xsdImport = ((XSDImport)object);
-// String result = xsdImport.getSchemaLocation();
-// return result == null ? "" : result;
-
-// XSDInclude xsdInclude = ((XSDInclude)object);
-// String result = xsdInclude.getSchemaLocation();
-// return result == null ? "" : result;
-
-// XSDRedefine xsdRedefine = ((XSDRedefine)object);
-// String result = xsdRedefine.getSchemaLocation();
-// return result == null ? "" : result;
-
-
- }
-
- public Object[] getChildren(Object parentElement)
- {
- List list = new ArrayList();
- if (parentElement instanceof XSDRedefine)
- {
- XSDRedefine redefine = (XSDRedefine)parentElement;
- list = redefine.getContents();
- if (list == null)
- {
- list = new ArrayList();
- }
- }
- return list.toArray();
- }
-
- public boolean hasChildren(Object object)
- {
- return false;
- }
-
- public Object getParent(Object object)
- {
- return null;
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSimpleTypeDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSimpleTypeDefinitionAdapter.java
deleted file mode 100644
index 299bd3f647..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDSimpleTypeDefinitionAdapter.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDVariety;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class XSDSimpleTypeDefinitionAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDSimpleTypeDefinitionAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- XSDSimpleTypeDefinition xsdSimpleTypeDefinition = ((XSDSimpleTypeDefinition)object);
-
- if (xsdSimpleTypeDefinition.getContainer() == null)
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
-
- if (XSDVariety.LIST_LITERAL == xsdSimpleTypeDefinition.getVariety())
- {
- // return XSDEditorPlugin.getXSDImage("icons/XSDSimpleList.gif");
- return XSDEditorPlugin.getPlugin().getIconImage("obj16/smpl_list_obj");
- }
- else if (XSDVariety.UNION_LITERAL == xsdSimpleTypeDefinition.getVariety())
- {
- //return XSDEditorPlugin.getXSDImage("icons/XSDSimpleUnion.gif");
- return XSDEditorPlugin.getPlugin().getIconImage("obj16/smpl_union_obj");
- }
- else if (XSDVariety.ATOMIC_LITERAL == xsdSimpleTypeDefinition.getVariety())
- {
- // return XSDEditorPlugin.getXSDImage("icons/XSDSimpleRestrict.gif");
- Element stElement = xsdSimpleTypeDefinition.getElement();
- XSDDOMHelper domHelper = new XSDDOMHelper();
- if (domHelper.getChildNode(stElement, XSDConstants.RESTRICTION_ELEMENT_TAG) != null)
- {
- return XSDEditorPlugin.getPlugin().getIconImage("obj16/smpl_restrict_obj");
- }
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
- else if (xsdSimpleTypeDefinition.isSetVariety())
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
- else
- {
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
-
-// return
-// XSDEditorPlugin.getPlugin().getIconImage
-// (xsdSimpleTypeDefinition.getContainer() == null ?
-// "full/obj16/XSDSimpleTypeDefinitionUnresolved" :
-// XSDVariety.LIST_LITERAL == xsdSimpleTypeDefinition.getVariety() ?
-// "full/obj16/XSDSimpleTypeDefinitionList" :
-// XSDVariety.UNION_LITERAL == xsdSimpleTypeDefinition.getVariety() ?
-// "full/obj16/XSDSimpleTypeDefinitionUnion" :
-// xsdSimpleTypeDefinition.isSetVariety() ?
-// "full/obj16/XSDSimpleTypeDefinitionAtomic" :
-// "full/obj16/XSDSimpleTypeDefinition");
- }
-
- public String getText(Object object)
- {
- return getText(object, true);
- }
-
- public String getText(Object object, boolean showType)
- {
- XSDSimpleTypeDefinition xsdSimpleTypeDefinition = ((XSDSimpleTypeDefinition)object);
-
- StringBuffer result = new StringBuffer();
-
- result.append
- (xsdSimpleTypeDefinition.getName() == null ?
- // xsdSimpleTypeDefinition.getAliasName() :
- "local type" :
- xsdSimpleTypeDefinition.getName());
-
- if (showType)
- {
- XSDSimpleTypeDefinition baseTypeDefinition = xsdSimpleTypeDefinition.getBaseTypeDefinition();
- if (baseTypeDefinition != null && XSDVariety.ATOMIC_LITERAL == xsdSimpleTypeDefinition.getVariety())
- {
- if (baseTypeDefinition.getName() != null &&
- !xsdSimpleTypeDefinition.getContents().contains(baseTypeDefinition) &&
- !XSDConstants.isAnySimpleType(baseTypeDefinition))
- {
- result.append(" : ");
- result.append(baseTypeDefinition.getQName(xsdSimpleTypeDefinition));
- }
- }
- else
- {
- XSDSimpleTypeDefinition itemTypeDefinition = xsdSimpleTypeDefinition.getItemTypeDefinition();
- if (itemTypeDefinition != null)
- {
- if (itemTypeDefinition.getName() != null)
- {
- result.append(" : ");
- result.append(itemTypeDefinition.getQName(xsdSimpleTypeDefinition));
- }
- }
- else
- {
- List memberTypeDefinitions = xsdSimpleTypeDefinition.getMemberTypeDefinitions();
- if (!memberTypeDefinitions.isEmpty())
- {
- boolean first = true;
- for (Iterator members = memberTypeDefinitions.iterator(); members.hasNext(); )
- {
- XSDSimpleTypeDefinition memberTypeDefinition = (XSDSimpleTypeDefinition)members.next();
- if (memberTypeDefinition.getName() != null)
- {
- if (first)
- {
- result.append(" : ");
- first = false;
- }
- else
- {
- result.append(" | ");
- }
- result.append(memberTypeDefinition.getQName(xsdSimpleTypeDefinition));
- }
- else
- {
- break;
- }
- }
- }
- else if (result.length() == 0)
- {
- result.append("'absent'");
- }
- }
- }
- }
-
- return result.toString();
- }
-
- public Object[] getChildren(Object parentElement)
- {
- List list = new ArrayList();
- return list.toArray();
-
- }
-
- public boolean hasChildren(Object object)
- {
- return true;
- }
-
- public Object getParent(Object object)
- {
- XSDSimpleTypeDefinition element = (XSDSimpleTypeDefinition)object;
- return element.getContainer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDWildcardAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDWildcardAdapter.java
deleted file mode 100644
index b219f6b5c8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/provider/XSDWildcardAdapter.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.provider;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class XSDWildcardAdapter extends XSDAbstractAdapter
-{
-
- /**
- * @param adapterFactory
- */
- public XSDWildcardAdapter(AdapterFactory adapterFactory)
- {
- super(adapterFactory);
- }
-
- public Image getImage(Object object)
- {
- XSDWildcard xsdWildcard = (XSDWildcard)object;
- return XSDEditorPlugin.getXSDImage
- (xsdWildcard.eContainer() instanceof XSDParticle ?
- "icons/XSDAny.gif" :
- "icons/XSDAnyAttribute.gif");
- }
-
- public String getText(Object object)
- {
- XSDWildcard xsdWildcard = ((XSDWildcard)object);
-
- StringBuffer result = new StringBuffer();
- Element element = xsdWildcard.getElement();
-
- if (element != null)
- {
- result.append(element.getNodeName());
- boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
- boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
-
- if (hasMinOccurs || hasMaxOccurs)
- {
- result.append(" ["); //$NON-NLS-1$
- if (hasMinOccurs)
- {
-
- int min = ((XSDParticle)xsdWildcard.getContainer()).getMinOccurs();
- if (min == XSDParticle.UNBOUNDED)
- {
- result.append("*");
- }
- else
- {
- result.append(String.valueOf(min));
- }
- }
- else // print default
- {
- int min = ((XSDParticle)xsdWildcard.getContainer()).getMinOccurs();
- result.append(String.valueOf(min));
- }
- if (hasMaxOccurs)
- {
- int max = ((XSDParticle)xsdWildcard.getContainer()).getMaxOccurs();
- result.append("..");
- if (max == XSDParticle.UNBOUNDED)
- {
- result.append("*");
- }
- else
- {
- result.append(String.valueOf(max));
- }
- }
- else // print default
- {
- result.append("..");
- int max = ((XSDParticle)xsdWildcard.getContainer()).getMaxOccurs();
- result.append(String.valueOf(max));
- }
- result.append("]");
- }
- }
- return result.toString();
-
- }
-
- public boolean hasChildren(Object object)
- {
- return false;
- }
-
- public Object getParent(Object object)
- {
- XSDWildcard xsdWildcard = (XSDWildcard)object;
- return xsdWildcard.getContainer();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java
deleted file mode 100644
index 7b56d8d30f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class RefactoringMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.wst.xsd.ui.internal.refactor.messages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private RefactoringMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String[] getStrings(String keys[]) {
- String[] result= new String[keys.length];
- for (int i= 0; i < keys.length; i++) {
- result[i]= getString(keys[i]);
- }
- return result;
- }
-
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/XSDVisitor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/XSDVisitor.java
deleted file mode 100644
index 24bda3f2ce..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/XSDVisitor.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor;
-
-import java.util.Iterator;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeContent;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNotationDeclaration;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDParticleContent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.XSDWildcard;
-
-public class XSDVisitor
-{
- public XSDVisitor()
- {
- }
-
- protected XSDSchema schema;
-
- public void visitSchema(XSDSchema schema)
- {
- this.schema = schema;
- for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext();)
- {
- XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
- visitAttributeDeclaration(attr);
- }
- for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext();)
- {
- XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
- visitTypeDefinition(type);
- }
- for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext();)
- {
- XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
- visitElementDeclaration(element);
- }
- for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext();)
- {
- XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
- visitIdentityConstraintDefinition(identityConstraint);
- }
- for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext();)
- {
- XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
- visitModelGroupDefinition(modelGroup);
- }
- for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext();)
- {
- XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
- visitAttributeGroupDefinition(attributeGroup);
- }
- for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext();)
- {
- XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
- visitNotationDeclaration(element);
- }
-
- }
-
- public void visitAttributeDeclaration(XSDAttributeDeclaration attr)
- {
- }
-
- public void visitTypeDefinition(XSDTypeDefinition type)
- {
- if (type instanceof XSDSimpleTypeDefinition)
- {
- visitSimpleTypeDefinition((XSDSimpleTypeDefinition)type);
- }
- else if (type instanceof XSDComplexTypeDefinition)
- {
- visitComplexTypeDefinition((XSDComplexTypeDefinition)type);
- }
- }
-
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- if (element.isElementDeclarationReference())
- {
- }
- else if (element.getAnonymousTypeDefinition() != null)
- {
- visitTypeDefinition(element.getAnonymousTypeDefinition());
- }
- }
-
- public void visitIdentityConstraintDefinition(XSDIdentityConstraintDefinition identityConstraint)
- {
- }
-
- public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef)
- {
- if (!modelGroupDef.isModelGroupDefinitionReference())
- {
- if (modelGroupDef.getModelGroup() != null)
- {
- visitModelGroup(modelGroupDef.getModelGroup());
- }
- }
- }
-
- public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup)
- {
- if (attributeGroup.getAttributeUses() != null)
- {
- for (Iterator iter = attributeGroup.getAttributeUses().iterator(); iter.hasNext(); )
- {
- XSDAttributeUse attrUse = (XSDAttributeUse)iter.next();
- visitAttributeDeclaration(attrUse.getContent());
- }
- }
- }
-
- public void visitNotationDeclaration(XSDNotationDeclaration notation)
- {
- }
-
- public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type)
- {
- }
-
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- if (type.getContentType() != null)
- {
- XSDComplexTypeContent complexContent = (XSDComplexTypeContent) type.getContentType();
- if (complexContent instanceof XSDSimpleTypeDefinition)
- {
- visitSimpleTypeDefinition((XSDSimpleTypeDefinition)complexContent);
- }
- else if (complexContent instanceof XSDParticle)
- {
- visitParticle((XSDParticle) complexContent);
- }
- }
-
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent)iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse)attrGroupContent;
- visitAttributeDeclaration(attrUse.getContent());
- }
- else if (attrGroupContent instanceof XSDAttributeGroupDefinition)
- {
- visitAttributeGroupDefinition((XSDAttributeGroupDefinition)attrGroupContent);
- }
- }
- }
- }
-
- public void visitParticle(XSDParticle particle)
- {
- visitParticleContent(particle.getContent());
- }
-
- public void visitParticleContent(XSDParticleContent particleContent)
- {
- if (particleContent instanceof XSDModelGroupDefinition)
- {
- visitModelGroupDefinition((XSDModelGroupDefinition) particleContent);
- }
- else if (particleContent instanceof XSDModelGroup)
- {
- visitModelGroup((XSDModelGroup)particleContent);
- }
- else if (particleContent instanceof XSDElementDeclaration)
- {
- visitElementDeclaration((XSDElementDeclaration)particleContent);
- }
- else if (particleContent instanceof XSDWildcard)
- {
- visitWildcard((XSDWildcard)particleContent);
- }
- }
-
- public void visitModelGroup(XSDModelGroup modelGroup)
- {
- if (modelGroup.getContents() != null)
- {
- for (Iterator iterator = modelGroup.getContents().iterator(); iterator.hasNext();)
- {
- XSDParticle particle = (XSDParticle) iterator.next();
- visitParticle(particle);
- }
- }
- }
-
- public void visitWildcard(XSDWildcard wildcard)
- {
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java
deleted file mode 100644
index 6404b3d89c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.commands.MakeAnonymousTypeGlobalCommand;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameRefactoringWizard;
-import org.eclipse.wst.xsd.ui.internal.refactor.structure.MakeTypeGlobalProcessor;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.w3c.dom.Node;
-
-public class MakeAnonymousTypeGlobalAction extends SelectionDispatchAction {
-
- private String fParentName;
- private boolean isComplexType = true;
- private XSDTypeDefinition fSelectedComponent;
-
- public MakeAnonymousTypeGlobalAction(ISelectionProvider selectionProvider, XSDSchema schema) {
- super(selectionProvider);
- setText(XSDEditorPlugin.getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL")); //$NON-NLS-1$
- setSchema(schema);
- }
-
- public boolean canRun() {
-
- return fSelectedComponent != null;
- }
-
-
- private String getNewDefaultName(){
- if(fParentName != null && !"".equals(fParentName)){
- if(isComplexType){
- return fParentName + "ComplexType";
- }
- else{
- return fParentName + "SimpleType";
- }
- }
- else{
- if(isComplexType){
- return "NewComplexType";
- }
- else{
- return "NewSimpleType";
- }
- }
-
- }
- private boolean canEnable(XSDConcreteComponent xsdComponent){
- if (xsdComponent instanceof XSDComplexTypeDefinition) {
- fSelectedComponent = (XSDComplexTypeDefinition)xsdComponent;
- isComplexType = true;
- XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) xsdComponent;
- XSDConcreteComponent parent = typeDef.getContainer();
- if(parent instanceof XSDElementDeclaration){
- fParentName = ((XSDElementDeclaration)parent).getName();
- return true;
- }
- }
- else if (xsdComponent instanceof XSDSimpleTypeDefinition){
- fSelectedComponent = (XSDSimpleTypeDefinition)xsdComponent;
- isComplexType = false;
- XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComponent;
- XSDConcreteComponent parent = typeDef.getContainer();
- if(parent instanceof XSDElementDeclaration){
- fParentName = ((XSDElementDeclaration)parent).getName();
- return true;
- }
- else if(parent instanceof XSDAttributeDeclaration){
- fParentName = ((XSDAttributeDeclaration)parent).getName();
- return true;
- }
-
- }
- return false;
- }
-
- protected boolean canEnable(Object selectedObject) {
-
- if (selectedObject instanceof XSDConcreteComponent) {
- return canEnable((XSDConcreteComponent)selectedObject);
- }
- else if (selectedObject instanceof Node) {
- Node node = (Node) selectedObject;
- XSDSchema xsdSchema = getSchema();
- if (xsdSchema != null)
- {
- XSDConcreteComponent concreteComponent = xsdSchema.getCorrespondingComponent(node);
- return canEnable(concreteComponent);
- }
- }
- return false;
-
- }
-
- public void run1() {
-
- if(fSelectedComponent == null){
- return;
- }
-
- if(fSelectedComponent.getSchema() == null){
- getSchema().updateElement(true);
- }
- MakeTypeGlobalProcessor processor = new MakeTypeGlobalProcessor(fSelectedComponent, getNewDefaultName());
- RenameRefactoring refactoring = new RenameRefactoring(processor);
- try {
- RefactoringWizard wizard = new RenameRefactoringWizard(
- refactoring,
- RefactoringMessages.getString("RenameComponentWizard.defaultPageTitle"), //$NON-NLS-1$ TODO: provide correct strings
- RefactoringMessages.getString("RenameComponentWizard.inputPage.description"), //$NON-NLS-1$
- null);
- RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
- op.run(XSDEditorPlugin.getShell(), wizard.getDefaultPageTitle());
- op.getInitialConditionCheckingStatus();
- //triggerBuild();
- } catch (InterruptedException e) {
- // do nothing. User action got cancelled
- }
-
- }
-
- public void run(){
- if(fSelectedComponent == null){
- return;
- }
-
- if(fSelectedComponent.getSchema() == null){
- getSchema().updateElement(true);
- }
- DocumentImpl doc = (DocumentImpl) fSelectedComponent.getElement().getOwnerDocument();
- doc.getModel().beginRecording(
- this,
- XSDEditorPlugin
- .getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"));
- MakeAnonymousTypeGlobalCommand command = new MakeAnonymousTypeGlobalCommand(
- fSelectedComponent, getNewDefaultName());
- command.run();
- doc.getModel().endRecording(this);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java
deleted file mode 100644
index ced71d733d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xsd.ui.internal.commands.MakeLocalElementGlobalCommand;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Node;
-
-public class MakeLocalElementGlobalAction extends SelectionDispatchAction {
-
- XSDElementDeclaration fSelectedComponent;
-
- public MakeLocalElementGlobalAction(ISelectionProvider selectionProvider, XSDSchema schema) {
- super(selectionProvider);
- setText(RefactoringMessages.getString("MakeLocalElementGlobalAction.text")); //$NON-NLS-1$
- setSchema(schema);
- }
-
- public boolean canRun() {
-
- return fSelectedComponent != null;
- }
-
- protected boolean canEnable(XSDConcreteComponent selectedObject) {
-
- fSelectedComponent = null;
- if (selectedObject instanceof XSDElementDeclaration) {
- XSDElementDeclaration element = (XSDElementDeclaration) selectedObject;
- if (!element.isElementDeclarationReference() && !element.isGlobal()) {
- fSelectedComponent = element;
- }
- }
- return canRun();
- }
-
-
- protected boolean canEnable(Object selectedObject) {
-
- if (selectedObject instanceof XSDConcreteComponent) {
- return canEnable((XSDConcreteComponent)selectedObject);
- }
- else if (selectedObject instanceof Node) {
- Node node = (Node) selectedObject;
- XSDSchema xsdSchema = getSchema();
- if (xsdSchema != null)
- {
- XSDConcreteComponent concreteComponent = xsdSchema.getCorrespondingComponent(node);
- return canEnable(concreteComponent);
- }
- }
- return false;
-
- }
-
-
- public void run() {
- DocumentImpl doc = (DocumentImpl) fSelectedComponent.getElement()
- .getOwnerDocument();
- doc.getModel().beginRecording(this, getText());
- MakeLocalElementGlobalCommand command = new MakeLocalElementGlobalCommand(
- fSelectedComponent);
- command.run();
- doc.getModel().endRecording(this);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RefactorActionGroup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RefactorActionGroup.java
deleted file mode 100644
index f260bb4e7e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RefactorActionGroup.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDSchema;
-
-/**
- * Action group that adds refactor actions (for example 'Rename', 'Move') to a
- * context menu and the global menu bar.
- *
- */
-public class RefactorActionGroup extends ActionGroup {
-
- public static final String MENU_ID = "org.eclipse.wst.xsd.ui.refactoring.menu"; //$NON-NLS-1$
-
- public static final String GROUP_REORG = "reorgGroup"; //$NON-NLS-1$
-
- public static final String RENAME_ELEMENT = "org.eclipse.wst.xsd.ui.refactor.rename.element"; //$NON-NLS-1$
-
- public static final String MAKE_ELEMENT_GLOBAL = "org.eclipse.wst.xsd.ui.refactor.makeElementGlobal"; //$NON-NLS-1$
-
- public static final String MAKE_TYPE_GLOBAL = "org.eclipse.wst.xsd.ui.refactor.makeTypeGlobal"; //$NON-NLS-1$
-
- public static final String RENAME = "org.eclipse.wst.xsd.ui.refactoring.actions.Rename"; //$NON-NLS-1$
-
- /**
- * Pop-up menu: name of group for reorganize actions (value
- * <code>"group.reorganize"</code>).
- */
- public static final String GROUP_REORGANIZE = IWorkbenchActionConstants.GROUP_REORGANIZE;
-
- /**
- *
- * @deprecated
- *
- */
- private ISelectionProvider fSelectionProvider;
-
- private String fGroupName = GROUP_REORGANIZE;
-
- private SelectionDispatchAction fRenameAction;
-
- private SelectionDispatchAction fMakeLocalElementGlobal;
-
- private SelectionDispatchAction fMakeLocalTypeGlobal;
-
- private List fEditorActions;
-
- private IMenuManager fRefactorSubmenu;
-
- private static class NoActionAvailable extends Action {
- public NoActionAvailable() {
- setEnabled(true);
- setText(RefactoringMessages
- .getString("RefactorActionGroup.no_refactoring_available")); //$NON-NLS-1$
- }
- }
-
- private Action fNoActionAvailable = new NoActionAvailable();
-
- public RefactorActionGroup(ISelectionProvider selectionProvider,
- XSDSchema schema, String groupName) {
- this(selectionProvider, schema);
- fGroupName = groupName;
- }
-
- public RefactorActionGroup(ISelectionProvider selectionProvider,
- XSDSchema schema) {
- fSelectionProvider = selectionProvider;
- fEditorActions = new ArrayList();
- fRenameAction = new RenameAction(selectionProvider, schema);
- fRenameAction.setActionDefinitionId(RENAME_ELEMENT);
- fEditorActions.add(fRenameAction);
-
- fMakeLocalElementGlobal = new MakeLocalElementGlobalAction(
- selectionProvider, schema);
- fMakeLocalElementGlobal.setActionDefinitionId(MAKE_ELEMENT_GLOBAL);
- fEditorActions.add(fMakeLocalElementGlobal);
-
- fMakeLocalTypeGlobal = new MakeAnonymousTypeGlobalAction(
- selectionProvider, schema);
- fMakeLocalTypeGlobal.setActionDefinitionId(MAKE_TYPE_GLOBAL);
- fEditorActions.add(fMakeLocalTypeGlobal);
-
- initAction(fRenameAction, fSelectionProvider);
- initAction(fMakeLocalElementGlobal, fSelectionProvider);
- initAction(fMakeLocalTypeGlobal, fSelectionProvider);
- }
-
- private static void initAction(SelectionDispatchAction action,
- ISelectionProvider provider) {
-
- Assert.isNotNull(provider);
- Assert.isNotNull(action);
- action.update(provider.getSelection());
- provider.addSelectionChangedListener(action);
- }
-
- /*
- * (non-Javadoc) Method declared in ActionGroup
- */
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- actionBars.setGlobalActionHandler(RENAME, fRenameAction);
- retargetFileMenuActions(actionBars);
- }
-
- /**
- * Retargets the File actions with the corresponding refactoring actions.
- *
- * @param actionBars
- * the action bar to register the move and rename action with
- */
- public void retargetFileMenuActions(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(),
- fRenameAction);
- }
-
- /*
- * (non-Javadoc) Method declared in ActionGroup
- */
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- addRefactorSubmenu(menu);
- }
-
- /*
- * @see ActionGroup#dispose()
- */
- public void dispose() {
- disposeAction(fRenameAction, fSelectionProvider);
- disposeAction(fMakeLocalElementGlobal, fSelectionProvider);
- super.dispose();
- }
-
- private void disposeAction(ISelectionChangedListener action,
- ISelectionProvider provider) {
- if (action != null)
- provider.removeSelectionChangedListener(action);
- }
-
- private void addRefactorSubmenu(IMenuManager menu) {
-
- String menuText = RefactoringMessages.getString("RefactorMenu.label"); //$NON-NLS-1$
-
- fRefactorSubmenu = new MenuManager(menuText, MENU_ID);
- //if (fEditor != null) {
- fRefactorSubmenu.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- refactorMenuShown(manager);
- }
- });
- fRefactorSubmenu.add(fNoActionAvailable);
- if (menu.find(fRefactorSubmenu.getId()) == null) {
- if (menu.find(fGroupName) == null) {
- menu.add(fRefactorSubmenu);
- } else {
- menu.appendToGroup(fGroupName, fRefactorSubmenu);
- }
- }
-// } else {
-// if (fillRefactorMenu(fRefactorSubmenu) > 0)
-// menu.appendToGroup(fGroupName, fRefactorSubmenu);
-// }
- }
-
- private int fillRefactorMenu(IMenuManager refactorSubmenu) {
- int added = 0;
- refactorSubmenu.add(new Separator(GROUP_REORG));
- for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
- Action action = (Action) iter.next();
- added += addAction(refactorSubmenu, action);
- }
- return added;
- }
-
- private int addAction(IMenuManager menu, IAction action) {
- if (action != null && action.isEnabled()) {
- menu.add(action);
- return 1;
- }
- return 0;
- }
-
- public int addAction(IAction action) {
- if (action != null && action.isEnabled()) {
- fEditorActions.add(action);
- return 1;
- }
- return 0;
- }
-
- private void refactorMenuShown(final IMenuManager refactorSubmenu) {
- // we know that we have an MenuManager since we created it in
- // addRefactorSubmenu.
- Menu menu = ((MenuManager) refactorSubmenu).getMenu();
- menu.addMenuListener(new MenuAdapter() {
- public void menuHidden(MenuEvent e) {
- refactorMenuHidden(refactorSubmenu);
- }
- });
-// ISelection selection = (ISelection) fEditor.getSelectionManager()
-// .getSelection();
- ISelection selection = fSelectionProvider.getSelection();
- for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
- Action action = (Action) iter.next();
- if (action instanceof SelectionDispatchAction) {
- SelectionDispatchAction selectionAction = (SelectionDispatchAction) action;
- selectionAction.update(selection);
- }
- }
- refactorSubmenu.removeAll();
- if (fillRefactorMenu(refactorSubmenu) == 0)
- refactorSubmenu.add(fNoActionAvailable);
- }
-
- private void refactorMenuHidden(IMenuManager manager) {
-// ISelection selection = (ISelection) fEditor.getSelectionManager()
-// .getSelection();
- ISelection selection = fSelectionProvider.getSelection();
- for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
- Action action = (Action) iter.next();
- if (action instanceof SelectionDispatchAction) {
- SelectionDispatchAction selectionAction = (SelectionDispatchAction) action;
- selectionAction.update(selection);
- }
-
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java
deleted file mode 100644
index c9c6178061..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDSchema;
-
-
-/**
-* Renames a XML Schema element or workbench resource.
-* <p>
-* Action is applicable to selections containing elements of type
-* <code></code> or <code>IResource</code>.
-*
-* <p>
-* This class may be instantiated; it is not intended to be subclassed.
-* </p>
-
-*/
-public class RenameAction extends SelectionDispatchAction {
-
- private RenameComponentAction fRenameXSDElement;
- private RenameResourceAction fRenameResource;
-
-
- public RenameAction(ISelectionProvider selectionProvider, XSDSchema schema) {
- super(selectionProvider);
- setText(RefactoringMessages.getString("RenameAction.text")); //$NON-NLS-1$
- fRenameXSDElement= new RenameComponentAction(selectionProvider, schema);
- fRenameXSDElement.setText(getText());
- fRenameResource= new RenameResourceAction(selectionProvider);
- fRenameResource.setText(getText());
-
- }
-
- /*
- * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- fRenameXSDElement.selectionChanged(event);
- if (fRenameResource != null)
- fRenameResource.selectionChanged(event);
- setEnabled(computeEnabledState());
- }
-
- /*
- * @see SelectionDispatchAction#update(ISelection)
- */
- public void update(ISelection selection) {
- if(fRenameXSDElement != null){
- fRenameXSDElement.update(selection);
- }
- if (fRenameResource != null)
- fRenameResource.update(selection);
- setEnabled(computeEnabledState());
- }
-
- private boolean computeEnabledState(){
- if (fRenameResource != null) {
- return fRenameXSDElement.isEnabled() || fRenameResource.isEnabled();
- } else {
- return fRenameXSDElement.isEnabled();
- }
- }
-
- public void run(IStructuredSelection selection) {
- if (fRenameXSDElement.isEnabled())
- fRenameXSDElement.run(selection);
- if (fRenameResource != null && fRenameResource.isEnabled())
- fRenameResource.run(selection);
- }
-
- public void run(ITextSelection selection) {
- if (fRenameXSDElement.canRun())
- fRenameXSDElement.run(selection);
- else
- MessageDialog.openInformation(XSDEditorPlugin.getShell(), RefactoringMessages.getString("RenameAction.rename"), RefactoringMessages.getString("RenameAction.unavailable")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- public void run(ISelection selection) {
- if(selection == null){
- super.run();
- }
- else{
- super.run(selection);
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java
deleted file mode 100644
index 01527c0e24..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
-import org.eclipse.ui.actions.GlobalBuildAction;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameComponentProcessor;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameRefactoringWizard;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.w3c.dom.Node;
-
-public class RenameComponentAction extends SelectionDispatchAction {
-
- private XSDNamedComponent fSelectedComponent;
-
- public RenameComponentAction(ISelectionProvider selectionProvider,
- XSDSchema schema) {
- super(selectionProvider);
- setSchema(schema);
- }
-
- protected boolean canEnable(XSDConcreteComponent selectedObject) {
-
- fSelectedComponent = null;
- if (selectedObject instanceof XSDNamedComponent) {
- fSelectedComponent = (XSDNamedComponent) selectedObject;
-
- // if it's element reference, then this action is not appropriate
- if (fSelectedComponent instanceof XSDElementDeclaration) {
- XSDElementDeclaration element = (XSDElementDeclaration) fSelectedComponent;
- if (element.isElementDeclarationReference()) {
- fSelectedComponent = null;
- }
- }
- if(fSelectedComponent instanceof XSDTypeDefinition){
- XSDTypeDefinition type = (XSDTypeDefinition) fSelectedComponent;
- XSDConcreteComponent parent = type.getContainer();
- if (parent instanceof XSDElementDeclaration) {
- XSDElementDeclaration element = (XSDElementDeclaration) parent;
- if(element.getAnonymousTypeDefinition().equals(type)){
- fSelectedComponent = null;
- }
- }
- else if(parent instanceof XSDAttributeDeclaration) {
- XSDAttributeDeclaration element = (XSDAttributeDeclaration) parent;
- if(element.getAnonymousTypeDefinition().equals(type)){
- fSelectedComponent = null;
- }
- }
- }
- }
-
- return canRun();
- }
-
- protected boolean canEnable(Object selectedObject) {
-
- if (selectedObject instanceof XSDConcreteComponent) {
- return canEnable((XSDConcreteComponent) selectedObject);
- } else if (selectedObject instanceof Node) {
- Node node = (Node) selectedObject;
- if (getSchema() != null) {
- XSDConcreteComponent concreteComponent = getSchema()
- .getCorrespondingComponent(node);
- return canEnable(concreteComponent);
- }
- }
- return false;
-
- }
-
- public boolean canRun() {
-
- return fSelectedComponent != null;
- }
-
- public void run(ISelection selection) {
- if (fSelectedComponent.getName() == null) {
- fSelectedComponent.setName(new String());
- }
- if (fSelectedComponent.getSchema() == null) {
- if (getSchema() != null) {
- getSchema().updateElement(true);
- }
-
- }
- RenameComponentProcessor processor = new RenameComponentProcessor(
- fSelectedComponent, fSelectedComponent.getName());
- RenameRefactoring refactoring = new RenameRefactoring(processor);
- try {
- RefactoringWizard wizard = new RenameRefactoringWizard(
- refactoring,
- RefactoringMessages
- .getString("RenameComponentWizard.defaultPageTitle"), //$NON-NLS-1$ TODO: provide correct strings
- RefactoringMessages
- .getString("RenameComponentWizard.inputPage.description"), //$NON-NLS-1$
- null);
- RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
- wizard);
- op.run(XSDEditorPlugin.getShell(), wizard
- .getDefaultPageTitle());
- op.getInitialConditionCheckingStatus();
- triggerBuild();
- } catch (InterruptedException e) {
- // do nothing. User action got cancelled
- }
-
- }
-
- public static void triggerBuild() {
- if (ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
- new GlobalBuildAction(XSDEditorPlugin.getPlugin().getWorkbench()
- .getActiveWorkbenchWindow(),
- IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java
deleted file mode 100644
index cfa535b7b5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameRefactoringWizard;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameResourceProcessor;
-
-
-
-public class RenameResourceAction extends SelectionDispatchAction {
-
-
- public RenameResourceAction(ISelectionProvider selectionProvider) {
- super(selectionProvider);
- }
-
- public void selectionChanged(IStructuredSelection selection) {
- IResource element= getResource(selection);
- if (element == null) {
- setEnabled(false);
- } else {
- RenameResourceProcessor processor= new RenameResourceProcessor(element);
- setEnabled(processor.isApplicable());
-
- }
- }
-
- public void run(IStructuredSelection selection) {
- IResource resource = getResource(selection);
- RenameResourceProcessor processor= new RenameResourceProcessor(resource);
-
- if(!processor.isApplicable())
- return;
- RenameRefactoring refactoring= new RenameRefactoring(processor);
- try {
- RefactoringWizard wizard = new RenameRefactoringWizard(
- refactoring,
- RefactoringMessages.getString("RenameComponentWizard.defaultPageTitle"), //$NON-NLS-1$ TODO: provide correct strings
- RefactoringMessages.getString("RenameComponentWizard.inputPage.description"), //$NON-NLS-1$
- null);
- RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
- op.run(XSDEditorPlugin.getShell(), wizard.getDefaultPageTitle());
- op.getInitialConditionCheckingStatus();
- } catch (InterruptedException e) {
- // do nothing. User action got cancelled
- }
-
- }
-
- private static IResource getResource(IStructuredSelection selection) {
- if (selection.size() != 1)
- return null;
- Object first= selection.getFirstElement();
- if (! (first instanceof IResource))
- return null;
- return (IResource)first;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java
deleted file mode 100644
index f008e13e84..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * @author ebelisar@ca.ibm.com
- */
-public class RenameResourceActionDelegate implements IObjectActionDelegate {
-
- private ISelection fCurrentSelection;
-
- private IWorkbenchPart fPart;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fPart = targetPart;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- if (fCurrentSelection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) fCurrentSelection;
- Object first= structuredSelection.getFirstElement();
- if (first instanceof IFile) {
- RenameResourceAction renameAction = new RenameResourceAction(fPart.getSite().getSelectionProvider());
- renameAction.run(structuredSelection);
- }
- }
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- fCurrentSelection= selection;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java
deleted file mode 100644
index abe853deb6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.xsd.XSDSchema;
-
-
-
-/**
- * Action that dispatches the <code>IAction#run()</code> and the
- * <code>ISelectionChangedListener#selectionChanged</code>
- * according to the type of the selection.
- *
- * <ul>
- * <li>if selection is of type <code>ITextSelection</code> then
- * <code>run(ITextSelection)</code> and <code>selectionChanged(ITextSelection)</code>
- * is called.</li>
- * <li>if selection is of type <code>IStructuredSelection</code> then
- * <code>run(IStructuredSelection)</code> and <code>
- * selectionChanged(IStructuredSelection)</code> is called.</li>
- * <li>default is to call <code>run(ISelection)</code> and <code>
- * selectionChanged(ISelection)</code>.</li>
- * </ul>
- *
- * <p>
- * adapted from <code>org.eclipse.jdt.ui.actions.SelectionDispatchAction</code>
- * </p>
- *
- *
- */
-public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener {
-
- private ISelectionProvider fSelectionProvider;
-
- private XSDSchema fSchema;
-
- protected SelectionDispatchAction(ISelectionProvider selectionProvider) {
- Assert.isNotNull(selectionProvider);
- fSelectionProvider = selectionProvider;
- }
-
- /**
- * Returns the selection provided by the site owning this action.
- *
- * @return the site's selection
- */
- public ISelection getSelection() {
- if (getSelectionProvider() != null)
- return getSelectionProvider().getSelection();
- else
- return null;
- }
-
- /**
- * Returns the selection provider managed by the site owning this action.
- *
- * @return the site's selection provider
- */
- public ISelectionProvider getSelectionProvider() {
- return fSelectionProvider;
- }
-
- /**
- * Updates the action's enablement state according to the given selection. This
- * default implementation calls one of the <code>selectionChanged</code>
- * methods depending on the type of the passed selection.
- *
- * @param selection the selection this action is working on
- */
- public void update(ISelection selection) {
- dispatchSelectionChanged(selection);
- }
-
- /**
- * Notifies this action that the given structured selection has changed. This default
- * implementation calls <code>selectionChanged(ISelection selection)</code>.
- *
- * @param selection the new selection
- */
- public void selectionChanged(IStructuredSelection selection) {
- if (selection.size() == 1) {
- Object object = selection.getFirstElement();
- setEnabled(canEnable(object));
- }
- else{
- setEnabled(false);
- }
- }
-
- protected boolean canEnable(Object selectedObject){
- return false;
- }
-
- /**
- * Executes this actions with the given structured selection. This default implementation
- * calls <code>run(ISelection selection)</code>.
- */
- public void run(IStructuredSelection selection) {
- run((ISelection)selection);
- }
-
-
- /**
- * Notifies this action that the given text selection has changed. This default
- * implementation calls <code>selectionChanged(ISelection selection)</code>.
- *
- * @param selection the new selection
- */
- public void selectionChanged(ITextSelection selection) {
- selectionChanged((ISelection)selection);
- }
-
- /**
- * Executes this actions with the given text selection. This default implementation
- * calls <code>run(ISelection selection)</code>.
- */
- public void run(ITextSelection selection) {
- run((ISelection)selection);
- }
-
- /**
- * Notifies this action that the given selection has changed. This default
- * implementation sets the action's enablement state to <code>false</code>.
- *
- * @param selection the new selection
- */
- public void selectionChanged(ISelection selection) {
- setEnabled(false);
- }
-
- /**
- * Executes this actions with the given selection. This default implementation
- * does nothing.
- */
- public void run(ISelection selection) {
- System.out.println("SelectionDispatchAction.run");
- }
-
- /* (non-Javadoc)
- * Method declared on IAction.
- */
- public void run() {
- dispatchRun(getSelection());
-
- }
-
- /* (non-Javadoc)
- * Method declared on ISelectionChangedListener.
- */
- public void selectionChanged(SelectionChangedEvent event) {
- dispatchSelectionChanged(event.getSelection());
- }
-
- private void dispatchSelectionChanged(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- selectionChanged((IStructuredSelection)selection);
- } else if (selection instanceof ITextSelection) {
- selectionChanged((ITextSelection)selection);
- } else {
- selectionChanged(selection);
- }
- }
-
- protected void dispatchRun(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- run((IStructuredSelection)selection);
- } else if (selection instanceof ITextSelection) {
- run((ITextSelection)selection);
- } else {
- run(selection);
- }
- }
-
- public XSDSchema getSchema() {
- return fSchema;
- }
-
- public void setSchema(XSDSchema schema) {
- fSchema = schema;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java
deleted file mode 100644
index f45a1e2111..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-
-public abstract class BaseCleanup extends XSDVisitor
-{
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitSchema(XSDSchema)
- */
- public void visitSchema(XSDSchema schema)
- {
- super.visitSchema(schema);
-
- // now remove all children that were queued up for removal
-
- for (Iterator iter = childrenToRemove.iterator(); iter.hasNext(); )
- {
- Element domElement = (Element) iter.next();
- XSDDOMHelper.removeNodeAndWhitespace(domElement);
-// domElement.getParentNode().removeChild(domElement);
- }
- }
-
-
- protected ArrayList messages = new ArrayList();
-
- public ArrayList getMessages()
- {
- return messages;
- }
-
-
- protected void addMessage(String msg, XSDConcreteComponent component)
- {
-//// ErrorMessage message = new ErrorMessage();
-//
-// XSDConcreteComponent currComp = component;
-// while (!(currComp instanceof XSDSchemaContent) && currComp.getContainer() != null)
-// {
-// currComp = currComp.getContainer();
-// }
-//
-// Element domElement = currComp.getElement();
-// Node parent = domElement;
-// while (!(parent instanceof NodeImpl) && parent != null)
-// {
-// parent = parent.getParentNode();
-// }
-// if (parent instanceof NodeImpl)
-// {
-// // message.setModelObject(currComp.getElement());
-// message.setTargetObject(currComp.getElement());
-// }
-// message.setLocalizedMessage(msg);
-// ???
-// addMessage(message);
- }
-
-
-// // protected void addMessage(ErrorMessage message)
-// protected void addMessage(Message message)
-// {
-// messages.add(message);
-// }
-
-
- protected ArrayList childrenToRemove = new ArrayList();
-
-
- protected String getNamedComponentName(XSDConcreteComponent concrete)
- {
- String name = null;
- if (concrete instanceof XSDNamedComponent)
- {
- name = ((XSDNamedComponent)concrete).getName();
- }
-
- XSDConcreteComponent comp = concrete;
- while (comp != null && name == null)
- {
- comp = comp.getContainer();
- if (comp instanceof XSDNamedComponent)
- {
- name = ((XSDNamedComponent)comp).getName();
- }
- }
- return name != null ? name : "";
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java
deleted file mode 100644
index 6503971f03..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-
-public class BaseGlobalCleanup extends BaseCleanup
-{
- public BaseGlobalCleanup(XSDConcreteComponent deletedItem)
- {
- this.deletedItem = deletedItem;
- }
-
- protected XSDConcreteComponent deletedItem;
-
- protected String getDeletedQName()
- {
- return ((XSDNamedComponent)deletedItem).getQName();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java
deleted file mode 100644
index 2ff9b552bf..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalAttributeCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalAttributeCleanup.
- * @param deletedItem
- */
- public GlobalAttributeCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getGlobalAttributes();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl != null && attrDecl.isAttributeDeclarationReference())
- {
- if (deletedItem.equals(attrDecl.getResolvedAttributeDeclaration()))
- {
- if (getReplacementElementName() != null)
- {
- String msg = XSDEditorPlugin.getPlugin().getString("_UI_WARNING_RESET_ATTR_REF", getReplacementElementName());
- addMessage(msg, attrUse);
- attrUse.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- String name = getNamedComponentName(type);
- String msg = XSDEditorPlugin.getPlugin().getString("_UI_WARNING_REMOVE_ATTR_REF", name);
- addMessage(msg, attrUse.getContainer());
-
- childrenToRemove.add(attrDecl.getElement());
- }
- }
- }
- }
- }
- }
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java
deleted file mode 100644
index f858427637..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalAttributeGroupCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalAttributeGroupCleanup.
- * @param deletedItem
- */
- public GlobalAttributeGroupCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getGlobalAttributeGroups();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
-
- if (attrGroupContent instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) attrGroupContent;
-
- if (deletedItem.equals(attrGroupDef.getResolvedAttributeGroupDefinition()))
- {
- if (getReplacementElementName() != null)
- {
- String msg = XSDEditorPlugin.getXSDString("_INFO_RESET_ATTRIBUTE_GROUP_REFERENCE") + " <" + getReplacementElementName() + ">";
- addMessage(msg, attrGroupDef);
- attrGroupDef.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- // remove the attribute group reference
- String name = getNamedComponentName(type);
- String msg = XSDEditorPlugin.getXSDString("_INFO_REMOVE_ATTRIBUTE_GROUP_REFERENCE") + " <" + name + ">";
- addMessage(msg, attrGroupDef.getContainer());
-
- childrenToRemove.add(attrGroupDef.getElement());
- }
- }
- }
- }
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java
deleted file mode 100644
index 9719e3914b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalElementCleanup extends BaseGlobalCleanup
-{
-
- /**
- * Constructor for GlobalElementCleanup.
- * @param deletedItem
- */
- public GlobalElementCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getGlobalElements();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- if (element.isElementDeclarationReference())
- {
- if (deletedItem.equals(element.getResolvedElementDeclaration()))
- {
- if (getReplacementElementName() != null)
- {
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_RESET_ELEMENT_REFERENCE") + " <" + getReplacementElementName() + ">";
- String msg = "_INFO_RESET_ELEMENT_REFERENCE" + " <" + getReplacementElementName() + ">";
- addMessage(msg, element);
- element.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ELEMENT_REFERENCE") + " <" + getNamedComponentName(element.getContainer()) + ">";
- String msg = "_INFO_REMOVE_ELEMENT_REFERENCE" + " <" + getNamedComponentName(element.getContainer()) + ">";
- addMessage(msg, element.getContainer());
- childrenToRemove.add(element.getElement());
- }
- }
- }
- super.visitElementDeclaration(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java
deleted file mode 100644
index 9486ff2b11..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalGroupCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalGroupCleanup.
- * @param deletedItem
- */
- public GlobalGroupCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getModelGroups();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitModelGroupDefinition(XSDModelGroupDefinition)
- */
- public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroup)
- {
- super.visitModelGroupDefinition(modelGroup);
- if (modelGroup.isModelGroupDefinitionReference())
- {
- if (deletedItem.equals(modelGroup.getResolvedModelGroupDefinition()))
- {
- if (getReplacementElementName() != null)
- {
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_RESET_GROUP_REFERENCE") + " <" + getReplacementElementName() + ">";
- String msg = "_INFO_RESET_GROUP_REFERENCE" + " <" + getReplacementElementName() + ">";
- addMessage(msg, modelGroup);
- modelGroup.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- String name = getNamedComponentName(modelGroup);
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "_INFO_REMOVE_GROUP_REFERENCE" + " <" + name + ">";
- addMessage(msg, modelGroup.getContainer());
- childrenToRemove.add(modelGroup.getElement());
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java
deleted file mode 100644
index ed4132cbfb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class GlobalSimpleOrComplexTypeCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalSimpleOrComplexTypeCleanup.
- * @param deletedItem
- */
- public GlobalSimpleOrComplexTypeCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- if (!element.isElementDeclarationReference() &&
- deletedItem.equals(element.getTypeDefinition()))
- {
- resetTypeToString(element.getElement());
-
- String msg = "";
- if (element.isGlobal())
- {
- String pattern = XSDEditorPlugin.getXSDString("_INFO_RESET_GLOBAL_ELEMENT");
- Object args[] = {element.getName()};
- msg = MessageFormat.format(pattern, args);
- }
- else
- {
- msg = XSDEditorPlugin.getXSDString("_INFO_RESET_ELEMENT");
- msg += "<" + element.getName() + "> " + XSDEditorPlugin.getXSDString("_UI_TO_TYPE_STRING");
- }
- addMessage(msg, element);
- }
-
-
- super.visitElementDeclaration(element);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl != null &&
- !attrDecl.isAttributeDeclarationReference() &&
- deletedItem.equals(attrDecl.getTypeDefinition()))
- {
- resetTypeToString(attrDecl.getElement());
- // reset the type of the attribute decl to string
- String msg = XSDEditorPlugin.getXSDString("_INFO_RESET_ATTRIBUTE") +
- " <" + attrDecl.getName() + "> " +
- XSDEditorPlugin.getXSDString("_UI_TO_TYPE_STRING");
- addMessage(msg, attrDecl);
- resetTypeToString(attrDecl.getElement());
- }
- }
- }
- }
- XSDTypeDefinition base = type.getBaseTypeDefinition();
- if (base != null && base == deletedItem)
- {
- String msg = XSDEditorPlugin.getXSDString("_INFO_RESET_COMPLEX_TYPE") +
- " <" + getNamedComponentName(type) + "> " +
- XSDEditorPlugin.getXSDString("_UI_DERIVATION");
-
- addMessage(msg, type);
-
- type.setBaseTypeDefinition(null);
-
- java.util.List listOfCT = schema.getTypeDefinitions();
- XSDTypeDefinition typeDefinition = null;
- if (listOfCT.size() > 0)
- {
- for (Iterator iter = listOfCT.iterator(); iter.hasNext(); )
- {
- typeDefinition = (XSDTypeDefinition)iter.next();
- if (typeDefinition != deletedItem)
- {
- type.setBaseTypeDefinition(typeDefinition);
- }
- }
- }
- }
- }
-
- public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type)
- {
- if (type.getBaseTypeDefinition() == deletedItem)
- {
- type.setBaseTypeDefinition(schema.resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
- }
- }
-
- protected void resetTypeToString(Element element)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
-
- element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, prefix + "string");
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java
deleted file mode 100644
index aa40416c90..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.delete;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-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.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class XSDExternalFileCleanup extends BaseCleanup
-{
- /**
- * Constructor for XSDExternalFileCleanup.
- */
- public XSDExternalFileCleanup(String oldFilename)
- {
- super();
- this.oldFilename = oldFilename;
- }
-
- protected XSDSchema deletedSchema;
- public XSDExternalFileCleanup(XSDSchema deletedSchema)
- {
- this.deletedSchema = deletedSchema;
- }
-
- protected String oldFilename;
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- boolean addMessage = true;
- String schemaLocation = element.getSchema().getSchemaLocation();
- if (schemaLocation!= null)
- {
- if (!schemaLocation.equals(schema.getSchemaLocation()))
- {
- addMessage = false;
- }
- }
- if (element.isElementDeclarationReference())
- {
- if (isFromDeletedSchema(element.getResolvedElementDeclaration()))
- {
- if (addMessage)
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ELEMENT_REFERENCE") + " <" + getNamedComponentName(element.getContainer()) + ">";
- String msg = "_INFO_REMOVE_ELEMENT_REFERENCE" + " <" + getNamedComponentName(element.getContainer()) + ">";
- addMessage(msg, element.getContainer());
- }
- childrenToRemove.add(element.getElement());
-// Element domElement = element.getElement();
-// domElement.getParentNode().removeChild(domElement);
- }
- }
- else if (removeType(element))
- {
- String msg = "";
- if (element.isGlobal())
- {
- // String pattern = XSDPlugin.getSchemaString("_INFO_RESET_GLOBAL_ELEMENT");
- String pattern = "_INFO_RESET_GLOBAL_ELEMENT";
- Object args[] = {element.getName()};
- msg = MessageFormat.format(pattern, args);
- }
- else
- {
- // msg = XSDPlugin.getSchemaString("_INFO_RESET_ELEMENT");
- msg = "_INFO_RESET_ELEMENT";
- // msg += "<" + element.getName() + "> " + XSDPlugin.getSchemaString("_UI_TO_TYPE_STRING");
- msg += "<" + element.getName() + "> " + "_UI_TO_TYPE_STRING";
- }
- if (addMessage)
- {
- addMessage(msg, element);
- }
- }
-
-
- super.visitElementDeclaration(element);
- }
-
- protected void resetTypeToString(Element element)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
-
- element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, prefix + "string");
- }
-
- protected boolean removeType(XSDElementDeclaration element)
- {
- if (removeType(element.getTypeDefinition()))
- {
- resetTypeToString(element.getElement());
- return true;
- }
- return false;
- }
-
- protected boolean isFromDeletedSchema(XSDConcreteComponent component)
- {
- if (component == null)
- {
- return false;
- }
- XSDConcreteComponent root = component.getRootContainer();
-
- boolean isFromDeletedSchema = false;
- if (deletedSchema.getContents() != null)
- {
- Iterator contents = deletedSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent)contents.next();
- if (content instanceof XSDSchemaDirective)
- {
- XSDSchema aSchema = ((XSDSchemaDirective)content).getResolvedSchema();
- if (root != null && root.equals(aSchema))
- {
- isFromDeletedSchema = true;
- }
- }
- }
- }
- if (root != null && root.equals(deletedSchema))
- {
- isFromDeletedSchema = true;
- }
- return isFromDeletedSchema;
- }
-
- /**
- * Remove the type from the element if it belongs to the external file
- */
- protected boolean removeType(XSDTypeDefinition typeDef)
- {
- if (typeDef == null)
- {
- return false;
- }
- return isFromDeletedSchema(typeDef);
- }
-
- /**
- * @see org.eclipse.wst.xsd.utility.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl.isAttributeDeclarationReference())
- {
- if (isFromDeletedSchema(attrDecl.getResolvedAttributeDeclaration()))
- {
- String name = getNamedComponentName(type);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ATTRIBUTE_REFERENCE") +
- String msg = "_INFO_REMOVE_ATTRIBUTE_REFERENCE" +
- " <" + name + ">";
- addMessage(msg, attrDecl.getContainer());
-
- childrenToRemove.add(attrDecl.getElement());
- }
- }
- // otherwise check the type of the attribute and see if it is from the deleted schema
- else
- {
- if (removeType(attrDecl.getTypeDefinition()))
- {
- // reset the type of the attribute decl to string
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_ATTRIBUTE") +
- String msg = "_INFO_RESET_ATTRIBUTE" +
- " <" + attrDecl.getName() + "> " +
- // XSDPlugin.getSchemaString("_UI_TO_TYPE_STRING");
- "_UI_TO_TYPE_STRING";
- addMessage(msg, attrDecl);
- resetTypeToString(attrDecl.getElement());
-
- }
- }
- }
- else if (attrGroupContent instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) attrGroupContent;
-
- if (isFromDeletedSchema(attrGroupDef.getResolvedAttributeGroupDefinition()))
- {
- // remove the attribute group reference
- String name = getNamedComponentName(type);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ATTRIBUTE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "_INFO_REMOVE_ATTRIBUTE_GROUP_REFERENCE" + " <" + name + ">";
-
- addMessage(msg, attrGroupDef.getContainer());
-
- childrenToRemove.add(attrGroupDef.getElement());
- }
- }
- }
- }
-
- // For the complex type with simple content case, see the visitComplexTypeDefinition method
- XSDTypeDefinition base = type.getBaseTypeDefinition();
- if (base instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition baseType = (XSDSimpleTypeDefinition)base;
- if (isFromDeletedSchema(baseType))
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_COMPLEX_TYPE") +
- String msg = "_INFO_RESET_COMPLEX_TYPE" +
- " <" + getNamedComponentName(type) + "> " +
- // XSDPlugin.getSchemaString("_UI_DERIVATION");
- "_UI_DERIVATION";
- addMessage(msg, type);
-
- type.setBaseTypeDefinition(schema.getSchemaForSchema().resolveSimpleTypeDefinition("string"));
- }
- }
- }
-
- /**
- * @see org.eclipse.wst.xsd.utility.XSDVisitor#visitModelGroupDefinition(XSDModelGroupDefinition)
- */
- public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroup)
- {
- super.visitModelGroupDefinition(modelGroup);
- if (modelGroup.isModelGroupDefinitionReference())
- {
- if (isFromDeletedSchema(modelGroup.getResolvedModelGroupDefinition()))
- {
- String name = getNamedComponentName(modelGroup);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "_INFO_REMOVE_GROUP_REFERENCE" + " <" + name + ">";
- addMessage(msg, modelGroup.getContainer());
- childrenToRemove.add(modelGroup.getElement());
- }
- }
- }
-
- /**
- * @see org.eclipse.wst.xsd.utility.XSDVisitor#visitSimpleTypeDefinition(XSDSimpleTypeDefinition)
- */
- public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type)
- {
- super.visitSimpleTypeDefinition(type);
- XSDSimpleTypeDefinition baseType = type.getBaseTypeDefinition();
- if (isFromDeletedSchema(baseType))
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_SIMPLE_TYPE") +
- String msg = "_INFO_RESET_SIMPLE_TYPE" +
- " <" + getNamedComponentName(type) + "> " +
- // XSDPlugin.getSchemaString("_UI_DERIVATION");
- "_UI_DERIVATION";
- addMessage(msg, type);
-
-
- // This will set the simple Type base to string
- // For the complex type with simple content case, see the visitComplexTypeDefinition method
-
- type.getFacetContents().clear();
- type.getFacets().clear();
- type.setBaseTypeDefinition(schema.getSchemaForSchema().resolveSimpleTypeDefinition("string"));
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties
deleted file mode 100644
index 5432863584..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-RefactorMenu.label=Refactor
-RefactorActionGroup.no_refactoring_available=<no refactoring available>
-
-RenameAction.rename=Rename
-RenameAction.unavailable=Operation unavailable on the current selection.\nSelect a ....
-RenameAction.text=Re&name...
-
-RenameInputWizardPage.new_name= &New name:
-RenameRefactoringWizard.internal_error= Internal error during name checking: {0}
-
-
-RenameXSDElementAction.exception=Unexpected exception occurred. See log for details
-RenameXSDElementAction.not_available=Operation unavailable on the current selection.\nSelect a XSD project, folder, resource, file, attribute declarations, attribute group definitions, complex type definitions, element declarations, identity constraint definitions, model groups definitions, notation declarations, or simple type definitions.
-RenameXSDElementAction.name=Rename
-
-
-RenameSupport.dialog.title=Rename
-RenameSupport.not_available=Rename support not available
-
-RenameComponentWizard.defaultPageTitle=Rename wizard
-RenameComponentWizard.inputPage.description=Rename XML Schema component
-
-RenameInputWizardPage.update_references=Update references
-XSDComponentRenameChange.name=XML Schema component renaming: {0} to {1}
-XSDComponentRenameChange.Renaming=Renaming...
-XSDResourceRenameParticipant.compositeChangeName=XSD file rename references updating changes
-XSDRenameResourceChange.rename_resource=Renaming resource name references
-XSDRenameResourceChange.name=Resource rename: {0} to {1}
-RenameResourceRefactoring.Internal_Error=Internal error
-RenameResourceRefactoring.alread_exists=Resource already exist
-RenameResourceRefactoring.invalidName=Invalid resource name
-RenameResourceProcessor.name=Resource renaming
-MakeLocalElementGlobalAction.text=Make Local Element Global \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseRenamer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseRenamer.java
deleted file mode 100644
index 1a789e8909..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseRenamer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-/**
- * Base class for rename helpers of various named root components. This is to be used when
- * the user renames a global element, group, attribute, attribute group, complex/simple type etc
- */
-public abstract class BaseRenamer extends XSDVisitor
-{
-
-
- /**
- * Method BaseRenamer.
- * @param globalComponent - this is the component (who's parent is the schema) that has been renamed
- */
- public BaseRenamer(XSDNamedComponent globalComponent, String newName)
- {
- this.globalComponent = globalComponent;
- this.newName = newName;
- }
-
- public String getNewQName()
- {
- String qName = null;
- if (newName != null)
- {
- qName = XSDConstants.lookupQualifier(globalComponent.getElement(), globalComponent.getTargetNamespace());
- if (qName != null && qName.length() > 0)
- {
- qName += ":" + newName;
- }
- else
- {
- qName = newName;
- }
- }
- else
- {
- qName = newName;
- }
-
- return qName;
- }
-
- protected String newName;
- protected XSDNamedComponent globalComponent;
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameChange.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameChange.java
deleted file mode 100644
index 678c77faa1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameChange.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextChange;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDSwitch;
-
-
-/**
- * @author ebelisar
- *
- */
-public class ComponentRenameChange extends Change {
-
- private Map fChanges;
- private String fNewName;
-
- private String fOldName;
-
- private XSDNamedComponent fNamedComponent;
-
- public ComponentRenameChange(XSDNamedComponent component, String oldName, String newName) {
- Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- Assert.isNotNull(oldName, "old name"); //$NON-NLS-1$
-
- fNamedComponent = component;
- fOldName= oldName;
- fNewName= newName;
- }
-
-// public static Change[] createChangesFor(XSDNamedComponent component, String newName) {
-// // TODO: P1 implement search of XSD files
-// XSDSearchSupport support = XSDSearchSupport.getInstance();
-// RefactorSearchRequestor requestor = new RefactorSearchRequestor(component, newName);
-// support.searchRunnable(component, IXSDSearchConstants.WORKSPACE_SCOPE, requestor);
-//
-// return requestor.getChanges();
-//
-// }
-
- protected Change createUndoChange() {
- return new ComponentRenameChange(fNamedComponent, getNewName(), getOldName());
- }
-
- protected void doRename(IProgressMonitor pm) throws CoreException {
- // TODO P1 change temporary rename of XSD model components
- performModify(getNewName());
- }
-
- public void performModify(final String value)
- {
- if (value.length() > 0)
- {
- DelayedRenameRunnable runnable = new DelayedRenameRunnable(fNamedComponent, value);
- Display.getCurrent().asyncExec(runnable);
- }
- }
-
- protected static class DelayedRenameRunnable implements Runnable
- {
- protected XSDNamedComponent component;
- protected String name;
-
- public DelayedRenameRunnable(XSDNamedComponent component, String name)
- {
- this.component = component;
- this.name = name;
- }
-
- public void run()
- {
- component.updateElement(true);
- XSDSwitch xsdSwitch = new XSDSwitch()
- {
- public Object caseXSDTypeDefinition(XSDTypeDefinition object)
- {
- new GlobalSimpleOrComplexTypeRenamer(object, name).visitSchema(object.getSchema());
- return null;
- }
-
- public Object caseXSDElementDeclaration(XSDElementDeclaration object)
- {
- if (object.isGlobal())
- {
- new GlobalElementRenamer(object, name).visitSchema(object.getSchema());
- }
- return null;
- }
-
- public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object)
- {
- new GlobalGroupRenamer(object, name).visitSchema(object.getSchema());
- return null;
- }
- };
- xsdSwitch.doSwitch(component);
- component.setName(name);
-
- }
- }
-
- public TextChange getChange(IFile file) {
- TextChange result= (TextChange)fChanges.get(file);
- if (result == null) {
- result= new TextFileChange(file.getName(), file);
- fChanges.put(file, result);
- }
- return result;
- }
-
- public String getName() {
- return RefactoringMessages.getFormattedString("XSDComponentRenameChange.name", new String[]{getOldName(), getNewName()}); //$NON-NLS-1$
- }
-
- public final Change perform(IProgressMonitor pm) throws CoreException {
- try {
- pm.beginTask(RefactoringMessages.getString("XSDComponentRenameChange.Renaming"), 1); //$NON-NLS-1$
- Change result= createUndoChange();
- doRename(new SubProgressMonitor(pm, 1));
- return result;
- } finally {
- pm.done();
- }
- }
-
- /**
- * Gets the newName.
- *
- * @return Returns a String
- */
- protected String getNewName() {
- return fNewName;
- }
-
- /**
- * Gets the oldName
- *
- * @return Returns a String
- */
- protected String getOldName() {
- return fOldName;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
- */
- public Object getModifiedElement() {
- // TODO Auto-generated method stub
- return fNamedComponent;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void initializeValidationData(IProgressMonitor pm) {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
- */
- public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- // TODO implement change validation
- return new RefactoringStatus();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeGroupRenamer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeGroupRenamer.java
deleted file mode 100644
index d01ec4f285..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeGroupRenamer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import java.util.Iterator;
-
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalAttributeGroupRenamer extends BaseRenamer
-{
- /**
- * Constructor for GlobalAttributeGroupRenamer.
- * @param globalComponent
- */
- public GlobalAttributeGroupRenamer(XSDNamedComponent globalComponent, String newName)
- {
- super(globalComponent, newName);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
-
- if (attrGroupContent instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) attrGroupContent;
-
- if (globalComponent.equals(attrGroupDef.getResolvedAttributeGroupDefinition()))
- {
- attrGroupDef.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getNewQName());
- }
- }
- }
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeRenamer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeRenamer.java
deleted file mode 100644
index d1b3e68b74..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalAttributeRenamer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import java.util.Iterator;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalAttributeRenamer extends BaseRenamer
-{
- /**
- * Constructor for GlobalAttributeRenamer.
- * @param globalComponent
- */
- public GlobalAttributeRenamer(XSDNamedComponent globalComponent, String newName)
- {
- super(globalComponent, newName);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl != null && attrDecl.isAttributeDeclarationReference())
- {
- if (globalComponent.equals(attrDecl.getResolvedAttributeDeclaration()))
- {
- attrDecl.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getNewQName());
- }
- }
- }
- }
- }
- }
-
-
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalElementRenamer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalElementRenamer.java
deleted file mode 100644
index 869d775dc8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalElementRenamer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalElementRenamer extends BaseRenamer
-{
- /**
- * Constructor for GlobalElementRenamer.
- * @param globalComponent
- */
- public GlobalElementRenamer(XSDNamedComponent globalComponent, String newName)
- {
- super(globalComponent, newName);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- super.visitElementDeclaration(element);
- if (element.isElementDeclarationReference() &&
- globalComponent.equals(element.getResolvedElementDeclaration()))
- {
- element.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getNewQName());
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalGroupRenamer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalGroupRenamer.java
deleted file mode 100644
index b29b8e47fa..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalGroupRenamer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalGroupRenamer extends BaseRenamer
-{
-
- /**
- * Constructor for GlobalGroupRenamer.
- * @param globalComponent
- */
- public GlobalGroupRenamer(XSDNamedComponent globalComponent, String newName)
- {
- super(globalComponent, newName);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitModelGroupDefinition(XSDModelGroupDefinition)
- */
- public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroup)
- {
- super.visitModelGroupDefinition(modelGroup);
- if (modelGroup.isModelGroupDefinitionReference())
- {
- if (globalComponent.equals(modelGroup.getResolvedModelGroupDefinition()))
- {
- modelGroup.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getNewQName());
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalSimpleOrComplexTypeRenamer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalSimpleOrComplexTypeRenamer.java
deleted file mode 100644
index 63e4a67a9e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/GlobalSimpleOrComplexTypeRenamer.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import java.util.Iterator;
-
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-public class GlobalSimpleOrComplexTypeRenamer extends BaseRenamer
-{
- /**
- * Constructor for GlobalSimpleOrComplexTypeRenamer.
- * @param globalComponent
- */
- public GlobalSimpleOrComplexTypeRenamer(XSDNamedComponent globalComponent, String newName)
- {
- super(globalComponent, newName);
- }
-
-
- /**
- *
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- if (!element.isElementDeclarationReference() &&
- globalComponent.equals(element.getTypeDefinition()))
- {
- element.getElement().setAttribute(XSDConstants.TYPE_ATTRIBUTE, getNewQName());
- }
-
- super.visitElementDeclaration(element);
- }
-
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (!attrDecl.isAttributeDeclarationReference() &&
- globalComponent.equals(attrDecl.getTypeDefinition()))
- {
- attrDecl.getElement().setAttribute(XSDConstants.TYPE_ATTRIBUTE, getNewQName());
- }
- }
- }
- }
-
- XSDTypeDefinition base = type.getBaseTypeDefinition();
- if (base.equals(globalComponent))
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Element derivedByNode = helper.getDerivedByElementFromComplexType(type.getElement());
- if (derivedByNode != null)
- {
- derivedByNode.setAttribute(XSDConstants.BASE_ATTRIBUTE, getNewQName());
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/INameUpdating.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/INameUpdating.java
deleted file mode 100644
index 7aa495e850..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/INameUpdating.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
-/**
- * @author ebelisar
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public interface INameUpdating {
- //---- INameUpdating ---------------------------------------------------
- public abstract void setNewElementName(String newName);
-
- public abstract String getNewElementName();
-
- public abstract String getCurrentElementName();
-
- /* non java-doc
- * @see IRenameRefactoring#checkNewName()
- */public abstract RefactoringStatus checkNewElementName(String newName);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java
deleted file mode 100644
index 7d1cf38557..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
-import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
-import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDNamedComponent;
-
-public class RenameComponentProcessor extends RenameProcessor implements INameUpdating{
-
- private XSDNamedComponent fNamedComponent;
- private String fNewElementName;
-
- public static final String IDENTIFIER= "org.eclipse.wst.ui.xsd.renameComponentProcessor"; //$NON-NLS-1$
-
- //private QualifiedNameSearchResult fNameSearchResult;
-
- public RenameComponentProcessor(XSDNamedComponent element, String newName) {
- fNamedComponent= element;
- fNewElementName = newName;
-
- }
-
- public XSDNamedComponent getNamedComponent() {
- return fNamedComponent;
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#canEnableTextUpdating()
- */
- public boolean canEnableTextUpdating() {
- return true;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#getCurrentElementName()
- */
- public String getCurrentElementName() {
-
- return fNamedComponent.getName();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.internal.refactoring.rename.XSDRenameProcessor#getAffectedProjectNatures()
- */
- protected String[] getAffectedProjectNatures() throws CoreException {
- //TODO: find project natures of the files that are going to be refactored
- return new String[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xsd.internal.refactoring.rename.XSDRenameProcessor#loadDerivedParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus, java.util.List, java.lang.String[], org.eclipse.ltk.core.refactoring.participants.SharableParticipants)
- */
- protected void loadDerivedParticipants(RefactoringStatus status,
- List result, String[] natures, SharableParticipants shared)
- throws CoreException {
- // TODO: provide a way to load rename participants
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
- */
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws CoreException,
- OperationCanceledException {
- // TODO add code to check final conditions for component rename
- return new RefactoringStatus();
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
- */
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException, OperationCanceledException {
-// TODO add code to check initial conditions for component rename
- return new RefactoringStatus();
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
- */
- public Change createChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- // TODO P1 add change creation
-// Change[] changes = XSDComponentRenameChange.createChangesFor(this.fNamedComponent, getNewElementName());
-// CompositeChange multiChange = null;
-// if(changes.length > 0)
-// multiChange = new CompositeChange("XSD component rename participant changes", changes); //$NON-NLS-1$ TODO: externalize string
-// return multiChange;
-
-// computeNameMatches(pm);
-// Change[] changes = fNameSearchResult.getAllChanges();
-// return new CompositeChange("XSD file rename participant changes", changes); //TODO: externalize string
- pm.beginTask("", 1); //$NON-NLS-1$
- try{
- return new ComponentRenameChange(fNamedComponent, fNamedComponent.getName(), getNewElementName());
- } finally{
- pm.done();
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
- */
- public Object[] getElements() {
-
- return new Object[] {fNamedComponent};
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
- */
- public String getIdentifier() {
- return IDENTIFIER;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
- */
- public String getProcessorName() {
- return RefactoringMessages.getFormattedString(
- "RenameComponentRefactoring.name", //$NON-NLS-1$
- new String[]{fNamedComponent.getTargetNamespace() + ":" + fNamedComponent.getName(), getNewElementName()});
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
- */
- public boolean isApplicable() throws CoreException {
- if (fNamedComponent == null)
- return false;
- // TODO implement isApplicable logic for the named component,
- // verify how it is different from other condition checks
-// if (fNamedComponent.isAnonymous())
-// return false;
-// if (! Checks.isAvailable(fType))
-// return false;
-// if (isSpecialCase(fType))
-// return false;
- return true;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#checkNewElementName(java.lang.String)
- */
- public RefactoringStatus checkNewElementName(String newName){
- Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- // TODO: implement new name checking
-// RefactoringStatus result = Checks.checkTypeName(newName);
-// if (Checks.isAlreadyNamed(fType, newName))
-// result.addFatalError(RefactoringCoreMessages.getString("RenameTypeRefactoring.choose_another_name")); //$NON-NLS-1$
- return new RefactoringStatus();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#getNewElement()
- */
- public Object getNewElement() throws CoreException {
- // TODO implement this method, it's used for updating selection on new element
- return null;
- }
-
-// private void computeNameMatches(IProgressMonitor pm) throws CoreException {
-//
-// IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-// try {
-// URL fileURL = Platform.resolve(new URL(fNamedComponent.getSchema().getSchemaLocation()));
-// IFile file = workspaceRoot.getFileForLocation(new Path(fileURL.getPath()));
-// if (fNameSearchResult == null)
-// fNameSearchResult= new QualifiedNameSearchResult();
-// QualifiedNameFinder.process(fNameSearchResult, getNamedComponent().getName(),
-// getNewElementName(),
-// "*.xsd", file.getProject(), pm);
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// }
-
- public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
- RenameArguments arguments= new RenameArguments(getNewElementName(), true);
- String[] natures= getAffectedProjectNatures();
- List result= new ArrayList();
- loadElementParticipants(status, result, arguments, natures, sharedParticipants);
- loadDerivedParticipants(status, result, natures, sharedParticipants);
- return (RefactoringParticipant[])result.toArray(new RefactoringParticipant[result.size()]);
- }
-
- protected void loadElementParticipants(RefactoringStatus status, List result, RenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException {
- Object[] elements= getElements();
- for (int i= 0; i < elements.length; i++) {
- result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
- this, elements[i],
- arguments, natures, shared)));
- }
- }
-
-
- public void setNewElementName(String newName) {
-
- fNewElementName= newName;
- }
-
- public String getNewElementName() {
- return fNewElementName;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameInputWizardPage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameInputWizardPage.java
deleted file mode 100644
index c072b5e682..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameInputWizardPage.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-
-/**
- * @author ebelisar
- *
- */
-public class RenameInputWizardPage extends UserInputWizardPage{
- private String fInitialValue;
- private Text fTextField;
- private Button fUpdateReferences;
- /**
- * Creates a new text input page.
- * @param isLastUserPage <code>true</code> if this page is the wizard's last
- * user input page. Otherwise <code>false</code>.
- */
- public RenameInputWizardPage(String description, boolean isLastUserPage) {
- this(description, isLastUserPage, ""); //$NON-NLS-1$
- }
-
- /**
- * Creates a new text input page.
- * @param isLastUserPage <code>true</code> if this page is the wizard's last
- * user input page. Otherwise <code>false</code>
- * @param initialValue the initial value
- */
- public RenameInputWizardPage(String description, boolean isLastUserPage, String initialValue) {
- super("RenameInputWizardPage");
- Assert.isNotNull(initialValue);
- setDescription(description);
- fInitialValue= initialValue;
- }
-
- /**
- * Returns whether the initial input is valid. Typically it is not, because the
- * user is required to provide some information e.g. a new type name etc.
- *
- * @return <code>true</code> iff the input provided at initialization is valid
- */
- protected boolean isInitialInputValid(){
- return false;
- }
-
- /**
- * Returns whether an empty string is a valid input. Typically it is not, because
- * the user is required to provide some information e.g. a new type name etc.
- *
- * @return <code>true</code> iff an empty string is valid
- */
- protected boolean isEmptyInputValid(){
- return false;
- }
-
- /**
- * Returns the content of the text input field.
- *
- * @return the content of the text input field. Returns <code>null</code> if
- * not text input field has been created
- */
- protected String getText() {
- if (fTextField == null)
- return null;
- return fTextField.getText();
- }
-
- /**
- * Sets the new text for the text field. Does nothing if the text field has not been created.
- * @param text the new value
- */
- protected void setText(String text) {
- if (fTextField == null)
- return;
- fTextField.setText(text);
- }
-
- /**
- * Performs input validation. Returns a <code>RefactoringStatus</code> which
- * describes the result of input validation. <code>Null<code> is interpreted
- * as no error.
- */
- protected RefactoringStatus validateTextField(String text){
- return null;
- }
-
- protected Text createTextInputField(Composite parent) {
- return createTextInputField(parent, SWT.BORDER);
- }
-
- protected Text createTextInputField(Composite parent, int style) {
- fTextField= new Text(parent, style);
- fTextField.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- textModified(getText());
- }
- });
- fTextField.setText(fInitialValue);
- return fTextField;
- }
-
- /**
- * Checks the page's state and issues a corresponding error message. The page validation
- * is computed by calling <code>validatePage</code>.
- */
- protected void textModified(String text) {
- if (! isEmptyInputValid() && text.equals("")){ //$NON-NLS-1$
- setPageComplete(false);
- setErrorMessage(null);
- restoreMessage();
- return;
- }
- if ((! isInitialInputValid()) && text.equals(fInitialValue)){
- setPageComplete(false);
- setErrorMessage(null);
- restoreMessage();
- return;
- }
-
- setPageComplete(validateTextField(text));
-
-// TODO: enable preview in M4
- getRefactoringWizard().setForcePreviewReview(false);
- getContainer().updateButtons();
-
- }
-
- /**
- * Subclasses can override if they want to restore the message differently.
- * This implementation calls <code>setMessage(null)</code>, which clears the message
- * thus exposing the description.
- */
- protected void restoreMessage(){
- setMessage(null);
- }
-
- /* (non-Javadoc)
- * Method declared in IDialogPage
- */
- public void dispose() {
- fTextField= null;
- }
-
- /* (non-Javadoc)
- * Method declared in WizardPage
- */
- public void setVisible(boolean visible) {
- if (visible) {
- textModified(getText());
- }
- super.setVisible(visible);
- if (visible && fTextField != null) {
- fTextField.setFocus();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite superComposite= new Composite(parent, SWT.NONE);
- setControl(superComposite);
- initializeDialogUnits(superComposite);
-
- superComposite.setLayout(new GridLayout());
- Composite composite= new Composite(superComposite, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.verticalSpacing= 8;
- composite.setLayout(layout);
-
-
- Label label= new Label(composite, SWT.NONE);
- label.setText(getLabelText());
-
- Text text= createTextInputField(composite);
- text.selectAll();
- GridData gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint= convertWidthInCharsToPixels(25);
- text.setLayoutData(gd);
-
- addOptionalUpdateReferencesCheckbox(superComposite);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- text.setLayoutData(gd);
-
- // TODO: enable preview in M4
- getRefactoringWizard().setForcePreviewReview(false);
-
- Dialog.applyDialogFont(superComposite);
- //WorkbenchHelp.setHelp(getControl(), fHelpContextID);
-
- }
-
- private static Button createCheckbox(Composite parent, String title, boolean value) {
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(title);
- checkBox.setSelection(value);
- return checkBox;
- }
-
- private void addOptionalUpdateReferencesCheckbox(Composite result) {
-// TODO: enable update reference optioin in M4
-// final IReferenceUpdating ref= (IReferenceUpdating)getRefactoring().getAdapter(IReferenceUpdating.class);
-// if (ref == null || !ref.canEnableUpdateReferences())
-// return;
- String title= RefactoringMessages.getString("RenameInputWizardPage.update_references"); //$NON-NLS-1$
- boolean defaultValue= true;
- fUpdateReferences= createCheckbox(result, title, defaultValue);
-// ref.setUpdateReferences(fUpdateReferences.getSelection());
- fUpdateReferences.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
-// ref.setUpdateReferences(fUpdateReferences.getSelection());
- }
- });
-
- fUpdateReferences.setEnabled(false);
-
- }
-
- protected String getLabelText() {
- return RefactoringMessages.getString("RenameInputWizardPage.new_name"); //$NON-NLS-1$
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameRefactoringWizard.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameRefactoringWizard.java
deleted file mode 100644
index 4a31f2e72e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameRefactoringWizard.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-
-public class RenameRefactoringWizard extends RefactoringWizard {
-
- private final String fInputPageDescription;
-
- private final ImageDescriptor fInputPageImageDescriptor;
-
- public RenameRefactoringWizard(Refactoring refactoring, String defaultPageTitle, String inputPageDescription,
- ImageDescriptor inputPageImageDescriptor) {
- super(refactoring, DIALOG_BASED_USER_INTERFACE);
- setDefaultPageTitle(defaultPageTitle);
- fInputPageDescription= inputPageDescription;
- fInputPageImageDescriptor= inputPageImageDescriptor;
-
- }
-
- /* non java-doc
- * @see RefactoringWizard#addUserInputPages
- */
- protected void addUserInputPages() {
- String initialSetting= getProcessor().getCurrentElementName();
- RenameInputWizardPage inputPage= createInputPage(fInputPageDescription, initialSetting);
- inputPage.setImageDescriptor(fInputPageImageDescriptor);
- addPage(inputPage);
- }
-
- protected INameUpdating getProcessor() {
-
- return (INameUpdating)getRefactoring().getAdapter(INameUpdating.class);
- }
-
-
- protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
- return new RenameInputWizardPage(message, true, initialSetting) {
- protected RefactoringStatus validateTextField(String text) {
- return validateNewName(text);
- }
- };
- }
-
- protected RefactoringStatus validateNewName(String newName) {
- INameUpdating ref= getProcessor();
- ref.setNewElementName(newName);
-// try{
- return ref.checkNewElementName(newName);
-// } catch (CoreException e){
-// //XXX: should log the exception
-// String msg= e.getMessage() == null ? "": e.getMessage(); //$NON-NLS-1$
-// return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getFormattedString("RenameRefactoringWizard.internal_error", msg));//$NON-NLS-1$
-// }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java
deleted file mode 100644
index fd326c41f9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
-import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
-import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-
-public class RenameResourceProcessor extends RenameProcessor implements INameUpdating {
-
- private IResource fResource;
- private String fNewElementName;
-
- public static final String IDENTIFIER= "org.eclipse.wst.ui.xsd.renameResourceProcessor"; //$NON-NLS-1$
-
- public RenameResourceProcessor(IResource resource) {
- fResource= resource;
- if (fResource != null) {
- setNewElementName(fResource.getName());
- }
- }
-
- //---- INameUpdating ---------------------------------------------------
-
- public void setNewElementName(String newName) {
- Assert.isNotNull(newName);
- fNewElementName= newName;
- }
-
- public String getNewElementName() {
- return fNewElementName;
- }
-
- //---- IRenameProcessor methods ---------------------------------------
-
- public String getIdentifier() {
- return IDENTIFIER;
- }
-
- public boolean isApplicable() {
- if (fResource == null)
- return false;
- if (! fResource.exists())
- return false;
- if (! fResource.isAccessible())
- return false;
- return true;
- }
-
- public String getProcessorName() {
- String message= RefactoringMessages.getFormattedString("RenameResourceProcessor.name", //$NON-NLS-1$
- new String[]{getCurrentElementName(), getNewElementName()});
- return message;
- }
-
- public Object[] getElements() {
- return new Object[] {fResource};
- }
-
- public String getCurrentElementName() {
- return fResource.getName();
- }
-
- public String[] getAffectedProjectNatures() throws CoreException {
- return new String[0];
- }
-
- public Object getNewElement() {
- return ResourcesPlugin.getWorkspace().getRoot().findMember(createNewPath(getNewElementName()));
- }
-
- public boolean getUpdateReferences() {
- return true;
- }
-
- public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared) throws CoreException {
- Object[] elements= getElements();
- String[] natures= getAffectedProjectNatures();
- List result= new ArrayList();
- RenameArguments arguments= new RenameArguments(getNewElementName(), getUpdateReferences());
- for (int i= 0; i < elements.length; i++) {
- result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
- this, elements[i],
- arguments, natures, shared)));
- }
- return (RefactoringParticipant[])result.toArray(new RefactoringParticipant[result.size()]);
- }
-
- //--- Condition checking --------------------------------------------
-
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
- return new RefactoringStatus();
- }
-
- /* non java-doc
- * @see IRenameRefactoring#checkNewName()
- */
- public RefactoringStatus checkNewElementName(String newName) {
- Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- IContainer c= fResource.getParent();
- if (c == null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.Internal_Error")); //$NON-NLS-1$
-
- if (c.findMember(newName) != null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.alread_exists")); //$NON-NLS-1$
-
- if (!c.getFullPath().isValidSegment(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.invalidName")); //$NON-NLS-1$
-
- RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
- if (! result.hasFatalError())
- result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
- return result;
- }
-
- /* non java-doc
- * @see Refactoring#checkInput(IProgressMonitor)
- */
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) {
- pm.beginTask("", 1); //$NON-NLS-1$
- try{
- return new RefactoringStatus();
- } finally{
- pm.done();
- }
- }
-
- private String createNewPath(String newName){
- return fResource.getFullPath().removeLastSegments(1).append(newName).toString();
- }
-
- //--- changes
-
- /* non java-doc
- * @see IRefactoring#createChange(IProgressMonitor)
- */
- public Change createChange(IProgressMonitor pm) {
- pm.beginTask("", 1); //$NON-NLS-1$
- try{
- return new ResourceRenameChange(fResource, getNewElementName());
- } finally{
- pm.done();
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameSupport.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameSupport.java
deleted file mode 100644
index a923f3fc9c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameSupport.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
-import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
-import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.actions.GlobalBuildAction;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDNamedComponent;
-
-
-
-/**
- * Central access point to execute rename refactorings.
- * <p>
- * Note: this class is not intended to be subclassed.
- * </p>
- */
-public class RenameSupport {
-
- private RenameRefactoring fRefactoring;
- private RefactoringStatus fPreCheckStatus;
-
- /**
- * Executes some light weight precondition checking. If the returned status
- * is an error then the refactoring can't be executed at all. However,
- * returning an OK status doesn't guarantee that the refactoring can be
- * executed. It may still fail while performing the exhaustive precondition
- * checking done inside the methods <code>openDialog</code> or
- * <code>perform</code>.
- *
- * The method is mainly used to determine enable/disablement of actions.
- *
- * @return the result of the light weight precondition checking.
- *
- * @throws CoreException if an unexpected exception occurs while performing the checking.
- *
- * @see #openDialog(Shell)
- * @see #perform(Shell, IRunnableContext)
- */
- public IStatus preCheck() throws CoreException {
- ensureChecked();
- if (fPreCheckStatus.hasFatalError())
- return asStatus(fPreCheckStatus.getEntryMatchingSeverity(RefactoringStatus.FATAL));
- else
- return new Status(IStatus.OK, XSDEditorPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
- }
-
- /**
- * Opens the refactoring dialog for this rename support.
- *
- * @param parent a shell used as a parent for the refactoring dialog.
- * @throws CoreException if an unexpected exception occurs while opening the
- * dialog.
- */
- public void openDialog(Shell parent) throws CoreException {
- ensureChecked();
- if (fPreCheckStatus.hasFatalError()) {
- showInformation(parent, fPreCheckStatus);
- return;
- }
- try {
- RefactoringWizard wizard = new RenameRefactoringWizard(
- fRefactoring,
- RefactoringMessages.getString("RenameComponentWizard.defaultPageTitle"), //$NON-NLS-1$ TODO: provide correct strings
- RefactoringMessages.getString("RenameComponentWizard.inputPage.description"), //$NON-NLS-1$
- null);
- RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
- int result= op.run(parent, wizard.getDefaultPageTitle());
- op.getInitialConditionCheckingStatus();
- if (result == IDialogConstants.CANCEL_ID || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED)
- triggerBuild();
- } catch (InterruptedException e) {
- // do nothing. User action got cancelled
- }
-
- }
-
- public void triggerBuild() {
- if (ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
- new GlobalBuildAction(XSDEditorPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow(), IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
- }
- }
-
- /**
- * Executes the rename refactoring without showing a dialog to gather
- * additional user input (for example the new name of the <tt>IJavaElement</tt>).
- * Only an error dialog is shown (if necessary) to present the result
- * of the refactoring's full precondition checking.
- * <p>
- * The method has to be called from within the UI thread.
- * </p>
- *
- * @param parent a shell used as a parent for the error dialog.
- * @param context a {@link IRunnableContext} to execute the operation.
- *
- * @throws InterruptedException if the operation has been cancelled by the
- * user.
- * @throws InvocationTargetException if an error occurred while executing the
- * operation.
- *
- * @see #openDialog(Shell)
- * @see IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
- */
- public void perform(Shell parent, IRunnableContext context) throws InterruptedException, InvocationTargetException {
- try {
- ensureChecked();
- if (fPreCheckStatus.hasFatalError()) {
- showInformation(parent, fPreCheckStatus);
- return;
- }
- } catch (CoreException e){
- throw new InvocationTargetException(e);
- }
- }
-
-
-
-
- private RenameSupport(RenameComponentProcessor processor, String newName) throws CoreException {
- fRefactoring= new RenameRefactoring(processor);
-
- }
-
-
- /**
- * Creates a new rename support for the given {@link IPackageFragment}.
- *
- * @param fragment the {@link IPackageFragment} to be renamed.
- * @param newName the package fragment's new name. <code>null</code> is a
- * valid value indicating that no new name is provided.
- * @param flags flags controlling additional parameters. Valid flags are
- * <code>UPDATE_REFERENCES</code>, and <code>UPDATE_TEXTUAL_MATCHES</code>,
- * or their bitwise OR, or <code>NONE</code>.
- * @return the {@link RenameSupport}.
- * @throws CoreException if an unexpected error occurred while creating
- * the {@link RenameSupport}.
- */
- public static RenameSupport create(XSDNamedComponent component, String newName) throws CoreException {
- RenameComponentProcessor processor= new RenameComponentProcessor(component, newName);
- return new RenameSupport(processor, newName);
- }
-
-
- private void ensureChecked() throws CoreException {
- if (fPreCheckStatus == null) {
- if (!fRefactoring.isApplicable()) {
- fPreCheckStatus= RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameSupport.not_available")); //$NON-NLS-1$
- } else {
- fPreCheckStatus= new RefactoringStatus();
- }
- }
- }
-
- private void showInformation(Shell parent, RefactoringStatus status) {
- String message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL);
- MessageDialog.openInformation(parent, RefactoringMessages.getString("RenameSupport.dialog.title"), message); //$NON-NLS-1$
- }
-
- private static IStatus asStatus(RefactoringStatusEntry entry) {
- int statusSeverity= IStatus.ERROR;
- switch (entry.getSeverity()) {
- case RefactoringStatus.OK :
- statusSeverity= IStatus.OK;
- break;
- case RefactoringStatus.INFO :
- statusSeverity= IStatus.INFO;
- break;
- case RefactoringStatus.WARNING :
- case RefactoringStatus.ERROR :
- statusSeverity= IStatus.WARNING;
- break;
- }
- String pluginId= entry.getPluginId();
- int code= entry.getCode();
- if (pluginId == null) {
- pluginId= XSDEditorPlugin.PLUGIN_ID;
- code= IStatus.ERROR;
- }
- return new Status(statusSeverity, pluginId, code, entry.getMessage(), null);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java
deleted file mode 100644
index c232e2b79b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-
-/**
- * Represents a change that renames a given resource
- */
-public class ResourceRenameChange extends Change {
-
- /*
- * we cannot use handles because they became invalid when you rename the resource.
- * paths do not.
- */
- private IPath fResourcePath;
-
- private String fNewName;
-
- /**
- * @param newName includes the extension
- */
- public ResourceRenameChange(IResource resource, String newName) {
- this(resource.getFullPath(), newName);
- }
-
- private ResourceRenameChange(IPath resourcePath, String newName) {
- fResourcePath= resourcePath;
- fNewName= newName;
- }
-
- private IResource getResource() {
- return ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath);
- }
-
- public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
-
- // TODO: implement file validation, see JDTChange
- return new RefactoringStatus();
- }
-
- /*
- * to avoid the exception senders should check if a resource with the new name
- * already exists
- */
- public Change perform(IProgressMonitor pm) throws CoreException {
- try {
- if (false)
- throw new NullPointerException();
- pm.beginTask(RefactoringMessages.getString("XSDRenameResourceChange.rename_resource"), 1); //$NON-NLS-1$
-
- getResource().move(renamedResourcePath(fResourcePath, fNewName), getCoreRenameFlags(), pm);
-
- String oldName= fResourcePath.lastSegment();
- IPath newPath= renamedResourcePath(fResourcePath, fNewName);
- return new ResourceRenameChange(newPath, oldName);
- } finally {
- pm.done();
- }
- }
-
- private int getCoreRenameFlags() {
- if (getResource().isLinked())
- return IResource.SHALLOW;
- else
- return IResource.NONE;
- }
-
- /*
- * changes resource names /s/p/A.java renamed to B.java becomes /s/p/B.java
- */
- public static IPath renamedResourcePath(IPath path, String newName) {
- return path.removeLastSegments(1).append(newName);
- }
-
- public String getName() {
- return RefactoringMessages.getFormattedString(
- "XSDRenameResourceChange.name", new String[]{fResourcePath.toString(), //$NON-NLS-1$
- renamedResourcePath(fResourcePath, fNewName).toString()});
- }
-
- public Object getModifiedElement() {
- return getResource();
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void initializeValidationData(IProgressMonitor pm) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java
deleted file mode 100644
index e4699818c8..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.rename;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-
-/**
- * @author ebelisar
- */
-public class ResourceRenameParticipant extends RenameParticipant {
-
- private IFile fFile = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
- */
- protected boolean initialize(Object element) {
- if(element instanceof IFile) {
- this.fFile = (IFile) element;
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
- */
- public String getName() {
- String name = ""; //$NON-NLS-1$
- if(this.fFile != null) {
- name = fFile.getName();
- }
- return name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
- */
- public RefactoringStatus checkConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws OperationCanceledException {
- // TODO add check for file content type
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
- */
- public Change createChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- //computeQualifiedNameMatches(pm);
- //Change[] changes = fQualifiedNameSearchResult.getAllChanges();
- return new CompositeChange(RefactoringMessages.getString("XSDResourceRenameParticipant.compositeChangeName"));
-
- }
-
-// private void computeQualifiedNameMatches(IProgressMonitor pm) throws CoreException {
-// IPath fragment= fFile.getFullPath();
-// if (fQualifiedNameSearchResult == null)
-// fQualifiedNameSearchResult= new QualifiedNameSearchResult();
-// QualifiedNameFinder.process(fQualifiedNameSearchResult, fFile.getName(),
-// getArguments().getNewName(),
-// "*.xsd", fFile.getProject(), pm);
-// }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/SchemaPrefixChangeHandler.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/SchemaPrefixChangeHandler.java
deleted file mode 100644
index 35e90a35f0..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/SchemaPrefixChangeHandler.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class SchemaPrefixChangeHandler
-{
- String newPrefix;
- XSDSchema xsdSchema;
-
- public SchemaPrefixChangeHandler(XSDSchema xsdSchema, String newPrefix)
- {
- this.xsdSchema = xsdSchema;
- this.newPrefix= newPrefix;
- }
-
- public void resolve()
- {
- XSDSchemaPrefixRenamer xsdSchemaPrefixRenamer = new XSDSchemaPrefixRenamer();
- xsdSchemaPrefixRenamer.visitSchema(xsdSchema);
- }
-
- public String getNewQName(XSDTypeDefinition comp, String value, String newXSDPrefix)
- {
- String qName = null;
- if (value != null)
- {
- qName = newXSDPrefix;
- if (qName != null && qName.length() > 0)
- {
- qName += ":" + value;
- }
- else
- {
- qName = value;
- }
- }
- else
- {
- qName = value;
- }
-
- return qName;
- }
-
-
- class XSDSchemaPrefixRenamer extends XSDVisitor
- {
- public XSDSchemaPrefixRenamer()
- {
- super();
- }
-
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- super.visitElementDeclaration(element);
- XSDTypeDefinition type = element.getType();
- if (type != null)
- {
- String ns = type.getTargetNamespace();
- if (ns == null) ns = "";
-// if (ns.equals(xsdSchema.getSchemaForSchemaNamespace()))
- if (ns.equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- Element domElement = element.getElement();
- if (domElement != null && domElement instanceof IDOMNode)
- {
- Attr typeAttr = domElement.getAttributeNode(XSDConstants.TYPE_ATTRIBUTE);
- if (typeAttr != null)
- {
- element.getElement().setAttribute(XSDConstants.TYPE_ATTRIBUTE, getNewQName(type, type.getName(), newPrefix));
- }
- }
- }
- }
- }
-
- public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition simpleType)
- {
- super.visitSimpleTypeDefinition(simpleType);
- XSDTypeDefinition baseType = simpleType.getBaseTypeDefinition();
-
- if (baseType != null)
- {
- String ns = baseType.getTargetNamespace();
- if (ns == null) ns = "";
-// if (ns.equals(xsdSchema.getSchemaForSchemaNamespace()))
-// System.out.println(xsdSchema.getSchemaForSchemaNamespace());
- if (ns.equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- XSDDOMHelper domHelper = new XSDDOMHelper();
- Element derivedBy = domHelper.getDerivedByElement(simpleType.getElement());
- if (derivedBy != null && derivedBy instanceof IDOMNode)
- {
- Attr typeAttr = derivedBy.getAttributeNode(XSDConstants.BASE_ATTRIBUTE);
- if (typeAttr != null)
- {
- derivedBy.setAttribute(XSDConstants.BASE_ATTRIBUTE, getNewQName(baseType, baseType.getName(), newPrefix));
- }
- }
- }
- }
-
- XSDSimpleTypeDefinition itemType = simpleType.getItemTypeDefinition();
- if (itemType != null)
- {
- String ns = itemType.getTargetNamespace();
- if (ns == null) ns = "";
- if (ns.equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- XSDDOMHelper domHelper = new XSDDOMHelper();
- Node listNode = domHelper.getChildNode(simpleType.getElement(), XSDConstants.LIST_ELEMENT_TAG);
- if (listNode != null && listNode instanceof Element)
- {
- Element listElement = (Element)listNode;
- if (listElement instanceof IDOMNode)
- {
- Attr typeAttr = listElement.getAttributeNode(XSDConstants.ITEMTYPE_ATTRIBUTE);
- if (typeAttr != null)
- {
- listElement.setAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE, getNewQName(itemType, itemType.getName(), newPrefix));
- }
- }
- }
- }
- }
-
- List memberTypes = simpleType.getMemberTypeDefinitions();
- if (memberTypes.size() > 0)
- {
- XSDDOMHelper domHelper = new XSDDOMHelper();
- Node unionNode = domHelper.getChildNode(simpleType.getElement(), XSDConstants.UNION_ELEMENT_TAG);
- if (unionNode != null && unionNode instanceof Element)
- {
- Element unionElement = (Element)unionNode;
- if (unionElement instanceof IDOMNode)
- {
- StringBuffer sb = new StringBuffer("");
- for (Iterator i = memberTypes.iterator(); i.hasNext(); )
- {
- XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)i.next();
- String ns = st.getTargetNamespace();
- if (ns == null) ns = "";
- if (ns.equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- sb.append(getNewQName(st, st.getName(), newPrefix));
- }
- else
- {
- sb.append(st.getQName(xsdSchema));
- }
- if (i.hasNext())
- {
- sb.append(" ");
- }
- }
- unionElement.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, sb.toString());
- }
- }
- }
- }
-
- public void visitAttributeDeclaration(XSDAttributeDeclaration attr)
- {
- super.visitAttributeDeclaration(attr);
- XSDTypeDefinition type = attr.getType();
- if (type != null)
- {
- String ns = type.getTargetNamespace();
- if (ns == null) ns = "";
-// if (ns.equals(xsdSchema.getSchemaForSchemaNamespace()))
- if (ns.equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001))
- {
- Element domElement = attr.getElement();
- if (domElement != null && domElement instanceof IDOMNode)
- {
- Attr typeAttr = domElement.getAttributeNode(XSDConstants.TYPE_ATTRIBUTE);
- if (typeAttr != null)
- {
- attr.getElement().setAttribute(XSDConstants.TYPE_ATTRIBUTE, getNewQName(type, type.getName(), newPrefix));
- }
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/TargetNamespaceChangeHandler.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/TargetNamespaceChangeHandler.java
deleted file mode 100644
index ef996b1020..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/TargetNamespaceChangeHandler.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.refactor.rename;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-
-
-public class TargetNamespaceChangeHandler
-{
- String newNS;
- String oldNS;
- XSDSchema xsdSchema;
-
- public TargetNamespaceChangeHandler(XSDSchema xsdSchema, String oldNS, String newNS)
- {
- this.xsdSchema = xsdSchema;
- this.oldNS= oldNS;
- this.newNS= newNS;
- }
-
- public void resolve()
- {
- ElementReferenceRenamer elementReferenceRenamer = new ElementReferenceRenamer();
- elementReferenceRenamer.visitSchema(xsdSchema);
- AttributeReferenceRenamer attributeReferenceRenamer = new AttributeReferenceRenamer();
- attributeReferenceRenamer.visitSchema(xsdSchema);
- }
-
- class ElementReferenceRenamer extends XSDVisitor
- {
- public ElementReferenceRenamer()
- {
- super();
- }
-
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- super.visitElementDeclaration(element);
- if (element.isElementDeclarationReference())
- {
- if (element.getResolvedElementDeclaration().getTargetNamespace() != null)
- {
- if (element.getResolvedElementDeclaration().getTargetNamespace().equals(oldNS))
- {
- // set the resolved element's declaration to new ns
- // this is defect 237518 - target namespace rename creates a new namespace
- element.getResolvedElementDeclaration().setTargetNamespace(newNS);
- }
- }
- else
- {
- if (oldNS == null || (oldNS != null && oldNS.equals("")))
- {
- element.getResolvedElementDeclaration().setTargetNamespace(newNS);
- }
- }
- }
- }
- }
-
- // Similar to defect 237518 but for attributes
- class AttributeReferenceRenamer extends XSDVisitor
- {
- public AttributeReferenceRenamer()
- {
- super();
- }
-
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
- if (attrGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- if (attrDecl != null && attrDecl.isAttributeDeclarationReference())
- {
- if (attrDecl.getResolvedAttributeDeclaration().getTargetNamespace() != null)
- {
- if (attrDecl.getResolvedAttributeDeclaration().getTargetNamespace().equals(oldNS))
- {
- attrDecl.getResolvedAttributeDeclaration().setTargetNamespace(newNS);
- }
- }
- else
- {
- if (oldNS == null || (oldNS != null && oldNS.equals("")))
- {
- attrDecl.getResolvedAttributeDeclaration().setTargetNamespace(newNS);
- }
- }
- }
- }
- }
- }
- }
-
- public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup)
- {
- super.visitAttributeGroupDefinition(attributeGroup);
- EList list = attributeGroup.getAttributeUses();
- if (list != null)
- {
- for (Iterator iter = list.iterator(); iter.hasNext(); )
- {
- XSDAttributeUse attrUse = (XSDAttributeUse)iter.next();
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- if (attrDecl != null && attrDecl.isAttributeDeclarationReference())
- {
- if (attrDecl.getResolvedAttributeDeclaration().getTargetNamespace() != null)
- {
- if (attrDecl.getResolvedAttributeDeclaration().getTargetNamespace().equals(oldNS))
- {
- attrDecl.getResolvedAttributeDeclaration().setTargetNamespace(newNS);
- }
- }
- else
- {
- if (oldNS == null || (oldNS != null && oldNS.equals("")))
- {
- attrDecl.getResolvedAttributeDeclaration().setTargetNamespace(newNS);
- }
- }
- }
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java
deleted file mode 100644
index 80a6ac09f3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xsd.ui.internal.refactor.structure;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextChange;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.commands.MakeAnonymousTypeGlobalCommand;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-/**
- * @author ebelisar
- *
- */
-public class MakeTypeGlobalChange extends Change {
-
- private Map fChanges;
-
- private String fNewName;
-
- private XSDTypeDefinition fTypeComponent;
-
- public MakeTypeGlobalChange(XSDTypeDefinition component,
- String newName) {
- Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
-
- fTypeComponent = component;
- fNewName = newName;
- }
-
- // public static Change[] createChangesFor(XSDNamedComponent component,
- // String newName) {
- // // TODO: P1 implement search of XSD files
- // XSDSearchSupport support = XSDSearchSupport.getInstance();
- // RefactorSearchRequestor requestor = new
- // RefactorSearchRequestor(component, newName);
- // support.searchRunnable(component, IXSDSearchConstants.WORKSPACE_SCOPE,
- // requestor);
- //
- // return requestor.getChanges();
- //
- // }
-
- protected Change createUndoChange() {
- return new MakeTypeGlobalChange(fTypeComponent, getNewName());
- }
-
- protected void doRename(IProgressMonitor pm) throws CoreException {
- // TODO P1 change temporary rename of XSD model components
- performModify(getNewName());
- }
-
- public void performModify(final String value) {
- DelayedRenameRunnable runnable = new DelayedRenameRunnable(
- fTypeComponent, value);
- Display.getCurrent().asyncExec(runnable);
- }
-
- protected static class DelayedRenameRunnable implements Runnable {
- protected XSDTypeDefinition component;
-
- protected String name;
-
- public DelayedRenameRunnable(XSDTypeDefinition component, String name) {
- this.component = component;
- this.name = name;
- }
-
- public void run() {
- DocumentImpl doc = (DocumentImpl) component.getElement().getOwnerDocument();
- doc.getModel().beginRecording(
- this,
- XSDEditorPlugin
- .getXSDString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"));
- MakeAnonymousTypeGlobalCommand command = new MakeAnonymousTypeGlobalCommand(
- component, name);
- command.run();
- doc.getModel().endRecording(this);
- }
- }
-
- public TextChange getChange(IFile file) {
- TextChange result = (TextChange) fChanges.get(file);
- if (result == null) {
- result = new TextFileChange(file.getName(), file);
- fChanges.put(file, result);
- }
- return result;
- }
-
- public String getName() {
- return RefactoringMessages
- .getFormattedString(
- "MakeTypeGlobalChange.name", new String[] {getNewName() }); //$NON-NLS-1$
- }
-
- public final Change perform(IProgressMonitor pm) throws CoreException {
- try {
- pm.beginTask(RefactoringMessages
- .getString("XSDComponentRenameChange.Renaming"), 1); //$NON-NLS-1$
- Change result = createUndoChange();
- doRename(new SubProgressMonitor(pm, 1));
- return result;
- } finally {
- pm.done();
- }
- }
-
- /**
- * Gets the newName.
- *
- * @return Returns a String
- */
- protected String getNewName() {
- return fNewName;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
- */
- public Object getModifiedElement() {
- // TODO Auto-generated method stub
- return fTypeComponent;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void initializeValidationData(IProgressMonitor pm) {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
- */
- public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- // TODO implement change validation
- return new RefactoringStatus();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java
deleted file mode 100644
index d94fd26a0b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.structure;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
-import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
-import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
-import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
-import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
-import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
-import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
-import org.eclipse.wst.xsd.ui.internal.refactor.rename.INameUpdating;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-public class MakeTypeGlobalProcessor extends RenameProcessor implements INameUpdating{
-
- private XSDTypeDefinition fTypeComponent;
- private String fNewElementName;
-
- public static final String IDENTIFIER= "org.eclipse.wst.ui.xsd.makeTypeGlobalProcessor"; //$NON-NLS-1$
-
- //private QualifiedNameSearchResult fNameSearchResult;
-
- public MakeTypeGlobalProcessor(XSDTypeDefinition element, String newName) {
- fTypeComponent= element;
- fNewElementName = newName;
-
- }
-
- public XSDTypeDefinition getTypeComponent() {
- return fTypeComponent;
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#canEnableTextUpdating()
- */
- public boolean canEnableTextUpdating() {
- return true;
- }
-
- protected String[] getAffectedProjectNatures() throws CoreException {
- //TODO: find project natures of the files that are going to be refactored
- return new String[0];
- }
-
- protected void loadDerivedParticipants(RefactoringStatus status,
- List result, String[] natures, SharableParticipants shared)
- throws CoreException {
- // TODO: provide a way to load rename participants
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
- */
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws CoreException,
- OperationCanceledException {
- // TODO add code to check final conditions for component rename
- return new RefactoringStatus();
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
- */
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException, OperationCanceledException {
-// TODO add code to check initial conditions for component rename
- return new RefactoringStatus();
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
- */
- public Change createChange(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- // TODO P1 add change creation
-// Change[] changes = XSDComponentRenameChange.createChangesFor(this.fNamedComponent, getNewElementName());
-// CompositeChange multiChange = null;
-// if(changes.length > 0)
-// multiChange = new CompositeChange("XSD component rename participant changes", changes); //$NON-NLS-1$ TODO: externalize string
-// return multiChange;
-
-// computeNameMatches(pm);
-// Change[] changes = fNameSearchResult.getAllChanges();
-// return new CompositeChange("XSD file rename participant changes", changes); //TODO: externalize string
- pm.beginTask("", 1); //$NON-NLS-1$
- try{
- return new MakeTypeGlobalChange(fTypeComponent, getNewElementName());
- } finally{
- pm.done();
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
- */
- public Object[] getElements() {
-
- return new Object[] {fTypeComponent};
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
- */
- public String getIdentifier() {
- return IDENTIFIER;
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
- */
- public String getProcessorName() {
- return RefactoringMessages.getFormattedString(
- "MakeLocalTypeGlobalRefactoring.name", //$NON-NLS-1$
- new String[]{getNewElementName()});
-
- }
- /* (non-Javadoc)
- * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
- */
- public boolean isApplicable() throws CoreException {
- if (fTypeComponent == null)
- return false;
- // TODO implement isApplicable logic for the named component,
- // verify how it is different from other condition checks
-// if (fNamedComponent.isAnonymous())
-// return false;
-// if (! Checks.isAvailable(fType))
-// return false;
-// if (isSpecialCase(fType))
-// return false;
- return true;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#checkNewElementName(java.lang.String)
- */
- public RefactoringStatus checkNewElementName(String newName){
- Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- // TODO: implement new name checking
-// RefactoringStatus result = Checks.checkTypeName(newName);
-// if (Checks.isAlreadyNamed(fType, newName))
-// result.addFatalError(RefactoringCoreMessages.getString("RenameTypeRefactoring.choose_another_name")); //$NON-NLS-1$
- return new RefactoringStatus();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#getNewElement()
- */
- public Object getNewElement() throws CoreException {
- // TODO implement this method, it's used for updating selection on new element
- return null;
- }
-
-// private void computeNameMatches(IProgressMonitor pm) throws CoreException {
-//
-// IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-// try {
-// URL fileURL = Platform.resolve(new URL(fNamedComponent.getSchema().getSchemaLocation()));
-// IFile file = workspaceRoot.getFileForLocation(new Path(fileURL.getPath()));
-// if (fNameSearchResult == null)
-// fNameSearchResult= new QualifiedNameSearchResult();
-// QualifiedNameFinder.process(fNameSearchResult, getNamedComponent().getName(),
-// getNewElementName(),
-// "*.xsd", file.getProject(), pm);
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// }
-
- public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
- RenameArguments arguments= new RenameArguments(getNewElementName(), true);
- String[] natures= getAffectedProjectNatures();
- List result= new ArrayList();
- loadElementParticipants(status, result, arguments, natures, sharedParticipants);
- loadDerivedParticipants(status, result, natures, sharedParticipants);
- return (RefactoringParticipant[])result.toArray(new RefactoringParticipant[result.size()]);
- }
-
- protected void loadElementParticipants(RefactoringStatus status, List result, RenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException {
- Object[] elements= getElements();
- for (int i= 0; i < elements.length; i++) {
- result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
- this, elements[i],
- arguments, natures, shared)));
- }
- }
-
-
- public void setNewElementName(String newName) {
-
- fNewElementName= newName;
- }
-
- public String getNewElementName() {
- return fNewElementName;
- }
-
- public String getCurrentElementName() {
- // TODO Auto-generated method stub
- return fNewElementName;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java
deleted file mode 100644
index 199ad9475d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelAdapter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.text;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xsd.ui.internal.util.XSDSchemaLocationResolverAdapterFactory;
-import org.eclipse.xsd.XSDFactory;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.impl.XSDSchemaImpl;
-import org.eclipse.xsd.util.XSDResourceImpl;
-import org.w3c.dom.Element;
-
-public class XSDModelAdapter implements INodeAdapter
-{
- protected ResourceSet resourceSet;
- protected XSDSchema schema;
-
- public XSDSchema getSchema()
- {
- return schema;
- }
-
- public void setSchema(XSDSchema schema)
- {
- this.schema = schema;
- }
-
- public void clear()
- {
- schema = null;
- resourceSet = null;
- }
-
- public boolean isAdapterForType(Object type)
- {
- return type == XSDModelAdapter.class;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos)
- {
- }
-
- public XSDSchema createSchema(Element element)
- {
- try
- {
- IDOMNode domNode = (IDOMNode)element;
- String baseLocation = domNode.getModel().getBaseLocation();
-// System.out.println("XSDSchemalNodeAdapter.baseLocation=" + baseLocation);
-
- schema = XSDFactory.eINSTANCE.createXSDSchema();
-
- // Force the loading of the "meta" schema for schema instance instance.
- //
- String schemaForSchemaNamespace = element.getNamespaceURI();
- XSDSchemaImpl.getSchemaForSchema(schemaForSchemaNamespace);
-
- resourceSet = XSDSchemaImpl.createResourceSet();
- resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory());
-
- // TODO... gotta pester SSE folks to provide 'useful' baseLocations
- //
- URI uri = null;
- if (baseLocation.startsWith("/"))
- {
- uri = URI.createPlatformResourceURI(baseLocation);
- }
- else
- {
- uri = URI.createFileURI(baseLocation);
- }
- //System.out.println("uri=" + uri.toString());
- Resource resource = new XSDResourceImpl();
- resource.setURI(uri);
- schema = XSDFactory.eINSTANCE.createXSDSchema();
- resource.getContents().add(schema);
- resourceSet.getResources().add(resource);
- schema.setElement(element);
-
- // attach an adapter to keep the XSD model and DOM in sync
- //
- new XSDModelReconcileAdapter(element.getOwnerDocument(), schema);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return schema;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelQueryExtension.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelQueryExtension.java
deleted file mode 100644
index bf76f7a78e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelQueryExtension.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.text;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-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;
-
-public class XSDModelQueryExtension extends ModelQueryExtension
-{
- public XSDModelQueryExtension()
- {
- }
-
- public String[] getAttributeValues(Element e, String namespace, String name)
- {
- List list = new ArrayList();
-
- String currentElementName = e.getLocalName();
- Node parentNode = e.getParentNode();
- String parentName = parentNode != null ? parentNode.getLocalName() : "";
-
- if (checkName(name, "type") && XSDConstants.isSchemaForSchemaNamespace(namespace))
- {
- if (checkName(currentElementName, "attribute"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserSimpleTypeNamesList());
- }
- else if (checkName(currentElementName, "element"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList2();
- list.addAll(getTypesHelper(e).getUserSimpleTypeNamesList());
- list.addAll(getTypesHelper(e).getUserComplexTypeNamesList());
- }
- }
- else if (checkName(name, "blockDefault") ||
- checkName(name, "finalDefault"))
- {
- list.add("#all");
- list.add("substitution");
- list.add("extension");
- list.add("restriction");
- }
- else if (checkName(name, "namespace"))
- {
- if (checkName(currentElementName, "any") ||
- checkName(currentElementName, "anyAttribute"))
- {
- list.add("##any");
- list.add("##other");
- list.add("##targetNamespace");
- list.add("##local");
- }
- }
- else if (checkName(name, "maxOccurs"))
- {
- list.add("1");
- list.add("unbounded");
- }
- else if (checkName(name, "minOccurs"))
- {
- list.add("0");
- list.add("1");
- }
- else if (checkName(name, "itemType"))
- {
- if (checkName(currentElementName, "list"))
- {
- if (checkName(parentName, "simpleType"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserSimpleTypeNamesList());
- }
- }
- }
- else if (checkName(name, "memberTypes"))
- {
- if (checkName(currentElementName, "union"))
- {
- if (checkName(parentName, "simpleType"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserSimpleTypeNamesList());
- }
- }
- }
- else if (checkName(name, "base"))
- {
- if (checkName(currentElementName, "restriction"))
- {
- if (checkName(parentName, "simpleType"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserSimpleTypeNamesList());
- }
- else if (checkName(parentName, "simpleContent"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserComplexTypeNamesList());
- }
- else if (checkName(parentName, "complexContent"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserComplexTypeNamesList());
- }
- }
- else if (checkName(currentElementName, "extension"))
- {
- if (checkName(parentName, "simpleContent"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserComplexTypeNamesList());
- }
- else if (checkName(parentName, "complexContent"))
- {
- list = getTypesHelper(e).getBuiltInTypeNamesList();
- list.addAll(getTypesHelper(e).getUserComplexTypeNamesList());
- }
- }
- }
- else if (checkName(name, "ref"))
- {
- if (checkName(currentElementName, "element"))
- {
- list = getTypesHelper(e).getGlobalElements();
- }
- else if (checkName(currentElementName, "attribute"))
- {
- list = getTypesHelper(e).getGlobalAttributes();
- }
- else if (checkName(currentElementName, "attributeGroup"))
- {
- list = getTypesHelper(e).getGlobalAttributeGroups();
- }
- else if (checkName(currentElementName, "group"))
- {
- list = getTypesHelper(e).getModelGroups();
- }
- }
- else if (checkName(name, "substitutionGroup"))
- {
- if (checkName(currentElementName, "element"))
- {
- list = getTypesHelper(e).getGlobalElements();
- }
- }
-
- String[] result = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- protected XSDSchema lookupOrCreateSchemaForElement(Element element)
- {
- XSDSchema result = null;
- Document document = element.getOwnerDocument();
- if (document instanceof INodeNotifier)
- {
- INodeNotifier notifier = (INodeNotifier)document;
- XSDModelAdapter adapter = (XSDModelAdapter)notifier.getAdapterFor(XSDModelAdapter.class);
- if (adapter == null)
- {
- adapter = new XSDModelAdapter();
- notifier.addAdapter(adapter);
- adapter.createSchema(document.getDocumentElement());
- }
- result = adapter.getSchema();
- }
- return result;
- }
-
- protected TypesHelper getTypesHelper(Element element)
- {
- XSDSchema schema = lookupOrCreateSchemaForElement(element);
- return new TypesHelper(schema);
- }
-
-
- protected boolean checkName(String localName, String token)
- {
- if (localName != null && localName.trim().equals(token))
- {
- return true;
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
deleted file mode 100644
index 76b5908bee..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/text/XSDModelReconcileAdapter.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.text;
-
-import org.eclipse.swt.widgets.Display;
-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.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class XSDModelReconcileAdapter extends DocumentAdapter
-{
- INodeNotifier currentNotifier;
- int currentEventType;
- XSDSchema schema;
-
- public XSDModelReconcileAdapter(Document document, XSDSchema schema)
- {
- super(document);
- this.schema = schema;
- }
-
- boolean handlingNotifyChanged = false;
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index)
- {
- if (!handlingNotifyChanged)
- {
- handlingNotifyChanged = true;
- try
- {
- // delay handle events only in the source view
- //if (getCurrentPageType() == XSDEditorPlugin.SOURCE_PAGE &&
- // !(getActivePart() instanceof PropertySheet) &&
- // !(getActivePart() instanceof org.eclipse.ui.views.contentoutline.ContentOutline)) {
- // startDelayedEvent(notifier, eventType, feature, oldValue, newValue, index);
- //}
- //else // all other views, just handle the events right away
- {
- handleNotifyChange(notifier, eventType, feature, oldValue, newValue, index);
- }
- }
- catch (Exception e)
- {
-// XSDEditorPlugin.getPlugin().getMsgLogger().write(e);
- }
- handlingNotifyChanged = false;
- }
- }
-
- public void handleNotifyChange(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index)
- {
-// System.out.println(eventType + " : HandleNotifyChange " + notifier.hashCode() + " notifier " + notifier);
- switch (eventType)
- {
- case INodeNotifier.ADD:
- {
- if (newValue instanceof Element)
- {
- adapt((Element)newValue);
-// Add updateParentForDerivation(node, listener);
- }
- break;
- }
- case INodeNotifier.REMOVE:
- {
- Node node = (Node)notifier;
- XSDConcreteComponent listener = schema.getCorrespondingComponent(node);
-
- if (listener instanceof XSDSchema)
- {
- // we want to reset the schema's external elements when the directive is deleted
- if (feature instanceof Element)
- {
- Element elem = (Element)feature;
- if (XSDDOMHelper.inputEquals(elem, XSDConstants.INCLUDE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(elem, XSDConstants.IMPORT_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(elem, XSDConstants.REDEFINE_ELEMENT_TAG, false))
- {
- schema.reset();
- schema.update();
- }
- }
- }
- }
- case INodeNotifier.CHANGE:
- {
- Node node = (Node)notifier;
- XSDConcreteComponent listener = schema.getCorrespondingComponent(node);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- listener.elementAttributesChanged((Element)node);
- listener.elementChanged((Element)node);
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE)
- {
- listener.elementAttributesChanged(((Document)node).getDocumentElement());
- listener.elementChanged(((Document)node).getDocumentElement());
- }
- break;
- }
- case INodeNotifier.STRUCTURE_CHANGED:
- case INodeNotifier.CONTENT_CHANGED:
- {
- Node node = (Node)notifier;
- XSDConcreteComponent listener = schema.getCorrespondingComponent(node);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- listener.elementContentsChanged((Element)node);
- break;
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE)
- {
- Element docElement = ((Document)node).getDocumentElement();
- // Need to add check if doc element is being edited in the source
- if (docElement != null)
- {
- String prefix = docElement.getPrefix();
- String xmlnsString = prefix == null? "xmlns" : "xmlns:" + prefix;
- Attr attr = docElement.getAttributeNode(xmlnsString);
- boolean doParse = false;
- if (attr != null)
- {
- if (attr.getValue().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001) && docElement.getLocalName().equals("schema"))
- {
- // We have a viable schema so parse it
- doParse = true;
- }
- }
-
- if (doParse)
- {
- adapt(docElement);
- schema.setElement(docElement);
- }
- }
- }
- break;
- }
- }
- }
-
- protected DelayedEvent delayedTask;
- protected void startDelayedEvent(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index)
- {
-// System.out.println("start delayed event");
- // check if there is already a delayed task for the same notifier and eventType
-// if (delayedTask != null)
-// {
-// Notifier aNotifier = delayedTask.getNotifier();
-// int anEventType = delayedTask.getEventType();
-// if (notifier == aNotifier && anEventType == eventType)
-// {
-// // same event, just different data, delay new event
-// delayedTask.setCancel(true);
-// }
-// }
-
- delayedTask = new DelayedEvent();
-
- delayedTask.setNotifier(notifier);
- delayedTask.setEventType(eventType);
- delayedTask.setFeature(feature);
- delayedTask.setOldValue(oldValue);
- delayedTask.setNewValue(newValue);
- delayedTask.setIndex(index);
-
- Display.getDefault().timerExec(400,delayedTask);
- }
-
- class DelayedEvent implements Runnable
- {
- INodeNotifier notifier;
- int eventType;
- Object feature;
- Object oldValue;
- Object newValue;
- int index;
- boolean cancelEvent = false;
-
- /*
- * @see Runnable#run()
- */
- public void run()
- {
- if (!cancelEvent)
- {
- handleNotifyChange(notifier, eventType, feature, oldValue, newValue, index);
- if (delayedTask == this)
- {
- delayedTask = null;
- }
- }
- }
-
- public void setCancel(boolean flag)
- {
- cancelEvent = flag;
- }
-
- public void setNotifier(INodeNotifier notifier)
- {
- this.notifier = notifier;
- }
-
- public void setEventType(int eventType)
- {
- this.eventType = eventType;
- }
-
- public void setFeature(Object feature)
- {
- this.feature = feature;
- }
-
- public void setOldValue(Object oldValue)
- {
- this.oldValue = oldValue;
- }
-
- public void setNewValue(Object newValue)
- {
- this.newValue = newValue;
- }
-
- public void setIndex(int index)
- {
- this.index = index;
- }
-
- public INodeNotifier getNotifier()
- {
- return notifier;
- }
-
- public int getEventType()
- {
- return eventType;
- }
-
- public Object getNewValue()
- {
- return newValue;
- }
-
- public Object getOldValue()
- {
- return oldValue;
- }
-
- }
-}
-
-
-abstract class DocumentAdapter implements INodeAdapter
-{
- Document document;
-
- public DocumentAdapter(Document document)
- {
- this.document = document;
- ((INodeNotifier)document).addAdapter(this);
- adapt(document.getDocumentElement());
- }
-
- public void adapt(Element element)
- {
- if (((INodeNotifier)element).getExistingAdapter(this) == null)
- {
- ((INodeNotifier)element).addAdapter(this);
-
- for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling())
- {
- if (child.getNodeType() == Node.ELEMENT_NODE)
- {
- adapt((Element)child);
- }
- }
- }
- }
-
- public boolean isAdapterForType(Object type)
- {
- return type == this;
- }
-
- abstract public void notifyChanged
- (INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index);
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/OpenOnSelectionHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/OpenOnSelectionHelper.java
deleted file mode 100644
index 549dcd1aaa..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/OpenOnSelectionHelper.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditor;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDIdentityConstraintDefinition;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-public class OpenOnSelectionHelper
-{
-
- protected StructuredTextEditor textEditor;
- protected XSDSchema xsdSchema;
-
-
- public OpenOnSelectionHelper(StructuredTextEditor textEditor, XSDSchema xsdSchema)
- {
- this.textEditor = textEditor;
- this.xsdSchema = xsdSchema;
- }
-
-
- boolean lastResult;
-
- public static void openXSDEditor(String schemaLocation)
- {
- IPath schemaPath = new Path(schemaLocation);
-
- final IFile schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
-
- Display.getDefault().syncExec(new Runnable()
- {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- final IWorkbenchWindow workbenchWindow = XSDEditorPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null)
- {
- try
- {
- workbenchWindow.getActivePage().openEditor(new FileEditorInput(schemaFile), XSDEditorPlugin.XSD_EDITOR_ID);
- }
- catch (PartInitException initEx)
- {
- initEx.printStackTrace();
-// XSDEditorPlugin.getPlugin().getMsgLogger().write(initEx);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- });
- }
-
- protected boolean revealObject(final XSDConcreteComponent component)
- {
- if (component.getRootContainer().equals(xsdSchema))
- {
- Node element = component.getElement();
- if (element instanceof IndexedRegion)
- {
- IndexedRegion indexNode = (IndexedRegion) element;
- textEditor.getTextViewer().setRangeIndication(indexNode.getStartOffset(), indexNode.getEndOffset() - indexNode.getStartOffset(), true);
- return true;
- }
- return false;
- }
- else
- {
- lastResult = false;
- if (component.getSchema() != null)
- {
- String schemaLocation = URIHelper.removePlatformResourceProtocol(component.getSchema().getSchemaLocation());
- IPath schemaPath = new Path(schemaLocation);
- final IFile schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath);
- Display.getDefault().syncExec(new Runnable()
- {
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- final IWorkbenchWindow workbenchWindow = XSDEditorPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow();
- if (workbenchWindow != null)
- {
- try
- {
- // IEditorPart editorPart = workbenchWindow.getActivePage().openEditor(new FileEditorInput(schemaFile), textEditor.getXSDEditor().getEditorSite().getId());
- IEditorPart editorPart = workbenchWindow.getActivePage().openEditor(new FileEditorInput(schemaFile), XSDEditorPlugin.getPlugin().PLUGIN_ID);
- if (editorPart instanceof XSDEditor)
- {
- ((XSDEditor)editorPart).openOnGlobalReference(component);
- lastResult = true;
- }
- }
- catch (PartInitException initEx)
- {
-// XSDEditorPlugin.getPlugin().getMsgLogger().write(initEx);
- }
- }
- }
- });
- }
- return lastResult;
- }
- }
-
- public void openOnGlobalReference(XSDConcreteComponent comp)
- {
- XSDSchema schema = xsdSchema;
- String name = null;
- if (comp instanceof XSDNamedComponent)
- {
- name = ((XSDNamedComponent) comp).getName();
- }
-
- if (schema == null || name == null)
- {
- return;
- }
-
- List objects = null;
- if (comp instanceof XSDElementDeclaration)
- {
- objects = schema.getElementDeclarations();
- }
- else if (comp instanceof XSDTypeDefinition)
- {
- objects = schema.getTypeDefinitions();
- }
-
- if (objects != null)
- {
- for (Iterator iter = objects.iterator(); iter.hasNext();)
- {
- XSDNamedComponent namedComp = (XSDNamedComponent) iter.next();
-
- if (namedComp.getName().equals(name))
- {
- revealObject(namedComp);
- }
- }
- }
- }
-
- public boolean openOnSelection()
- {
- List selectedNodes = null;
- ISelection selection = textEditor.getSelectionProvider().getSelection();
- if (selection instanceof IStructuredSelection) {
- selectedNodes = ((IStructuredSelection) selection).toList();
- }
-
- if (selectedNodes != null && !selectedNodes.isEmpty())
- {
- for (Iterator i = selectedNodes.iterator(); i.hasNext();)
- {
- Object obj = i.next();
- if (xsdSchema != null)
- {
- XSDConcreteComponent xsdComp = xsdSchema.getCorrespondingComponent((Node)obj);
- XSDConcreteComponent objectToReveal = null;
-
- if (xsdComp instanceof XSDElementDeclaration)
- {
- XSDElementDeclaration elementDecl = (XSDElementDeclaration) xsdComp;
- if (elementDecl.isElementDeclarationReference())
- {
- objectToReveal = elementDecl.getResolvedElementDeclaration();
- }
- else
- {
- XSDConcreteComponent typeDef = null;
- if (elementDecl.getAnonymousTypeDefinition() == null)
- {
- typeDef = elementDecl.getTypeDefinition();
- }
-
- XSDConcreteComponent subGroupAffiliation = elementDecl.getSubstitutionGroupAffiliation();
-
- if (typeDef != null && subGroupAffiliation != null)
- {
- // we have 2 things we can navigate to, if the cursor is anywhere on the substitution attribute
- // then jump to that, otherwise just go to the typeDef.
- if (obj instanceof Attr && ((Attr)obj).getLocalName().equals(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE))
- {
- objectToReveal = subGroupAffiliation;
- }
- else
- {
- // try to reveal the type now. On success, then we return true.
- // if we fail, set the substitution group as the object to reveal as a backup plan.
- if (revealObject(typeDef))
- {
- return true;
- }
- else
- {
- objectToReveal = subGroupAffiliation;
- }
- }
- }
- else
- {
- // one or more of these is null. If the typeDef is non-null, use it. Otherwise
- // try and use the substitution group
- objectToReveal = typeDef != null ? typeDef : subGroupAffiliation;
- }
- }
- }
- else if (xsdComp instanceof XSDModelGroupDefinition)
- {
- XSDModelGroupDefinition elementDecl = (XSDModelGroupDefinition) xsdComp;
- if (elementDecl.isModelGroupDefinitionReference())
- {
- objectToReveal = elementDecl.getResolvedModelGroupDefinition();
- }
- }
- else if (xsdComp instanceof XSDAttributeDeclaration)
- {
- XSDAttributeDeclaration attrDecl = (XSDAttributeDeclaration) xsdComp;
- if (attrDecl.isAttributeDeclarationReference())
- {
- objectToReveal = attrDecl.getResolvedAttributeDeclaration();
- }
- else if (attrDecl.getAnonymousTypeDefinition() == null)
- {
- objectToReveal = attrDecl.getTypeDefinition();
- }
- }
- else if (xsdComp instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) xsdComp;
- if (attrGroupDef.isAttributeGroupDefinitionReference())
- {
- objectToReveal = attrGroupDef.getResolvedAttributeGroupDefinition();
- }
- }
- else if (xsdComp instanceof XSDIdentityConstraintDefinition)
- {
- XSDIdentityConstraintDefinition idConstraintDef = (XSDIdentityConstraintDefinition) xsdComp;
- if (idConstraintDef.getReferencedKey() != null)
- {
- objectToReveal = idConstraintDef.getReferencedKey();
- }
- }
- else if (xsdComp instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComp;
- objectToReveal = typeDef.getItemTypeDefinition();
- if (objectToReveal == null)
- {
- // if itemType attribute is not set, then check for memberType
- List memberTypes = typeDef.getMemberTypeDefinitions();
- if (memberTypes != null && memberTypes.size() > 0)
- {
- objectToReveal = (XSDConcreteComponent)memberTypes.get(0);
- }
- }
- }
- else if (xsdComp instanceof XSDTypeDefinition)
- {
- XSDTypeDefinition typeDef = (XSDTypeDefinition) xsdComp;
- objectToReveal = typeDef.getBaseType();
- }
- else if (xsdComp instanceof XSDSchemaDirective)
- {
- XSDSchemaDirective directive = (XSDSchemaDirective) xsdComp;
-// String schemaLocation = URIHelper.removePlatformResourceProtocol(directive.getResolvedSchema().getSchemaLocation());
-// openXSDEditor(schemaLocation);
-// return false;
- objectToReveal = directive.getResolvedSchema();
- }
-
- // now reveal the object if this isn't null
- if (objectToReveal != null)
- {
- return revealObject(objectToReveal);
- }
- }
- }
- }
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/SelectionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/SelectionAdapter.java
deleted file mode 100644
index 2cd1353896..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/SelectionAdapter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-public abstract class SelectionAdapter implements ISelectionProvider
-{
- protected List listenerList = new ArrayList();
- protected ISelection selection = new StructuredSelection();
- protected ISelectionProvider eventSource;
-
- public void setEventSource(ISelectionProvider eventSource)
- {
- this.eventSource = eventSource;
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.add(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.remove(listener);
- }
-
- public ISelection getSelection()
- {
- return selection;
- }
-
- /**
- * This method should be specialized to return the correct object that corresponds to the 'other' model
- */
- abstract protected Object getObjectForOtherModel(Object object);
-
-
- public void setSelection(ISelection modelSelection)
- {
- List otherModelObjectList = new ArrayList();
- if (modelSelection instanceof IStructuredSelection)
- {
- for (Iterator i = ((IStructuredSelection)modelSelection).iterator(); i.hasNext(); )
- {
- Object modelObject = i.next();
- Object otherModelObject = getObjectForOtherModel(modelObject);
- if (otherModelObject != null)
- {
- otherModelObjectList.add(otherModelObject);
- }
- }
- }
-
- StructuredSelection nodeSelection = new StructuredSelection(otherModelObjectList);
- selection = nodeSelection;
- SelectionChangedEvent event = new SelectionChangedEvent(eventSource != null ? eventSource : this, nodeSelection);
-
- for (Iterator i = listenerList.iterator(); i.hasNext(); )
- {
- ISelectionChangedListener listener = (ISelectionChangedListener)i.next();
- listener.selectionChanged(event);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/TypesHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/TypesHelper.java
deleted file mode 100644
index 006cfd6fce..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/TypesHelper.java
+++ /dev/null
@@ -1,714 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.impl.XSDImportImpl;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class TypesHelper
-{
- XSDSchema xsdSchema;
- Vector list = new Vector();
-
- public TypesHelper(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- public void updateExternalImportGlobals()
- {
- if (xsdSchema != null)
- {
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImportImpl)
- {
- XSDImportImpl anImport = (XSDImportImpl) content;
- try
- {
- if (anImport.getSchemaLocation() != null)
- {
- anImport.importSchema();
- }
- }
- catch (Exception e)
- {
-
- }
- }
- }
- }
- }
-
-
- private Vector addExternalImportedGlobalElements(Vector items)
- {
- if (xsdSchema != null)
- {
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImportImpl)
- {
- XSDImportImpl anImport = (XSDImportImpl) content;
-
- XSDSchema impSchema = anImport.getResolvedSchema();
-
- try
- {
- if (impSchema == null)
- {
- impSchema = anImport.importSchema();
- }
- }
- catch (Exception e)
- {
-
- }
-
- if (impSchema != null)
- {
- Iterator i = impSchema.getElementDeclarations().iterator();
- while (i.hasNext())
- {
- XSDElementDeclaration anElement = (XSDElementDeclaration) i.next();
- if (anElement.getName() != null)
- {
- items.addAll(getPrefixedNames(anElement.getTargetNamespace(), anElement.getName()));
- }
- }
- }
- }
- }
- }
- return items;
- }
-
- private Vector addExternalImportedAttributes(Vector items)
- {
- if (xsdSchema != null)
- {
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImportImpl)
- {
- XSDImportImpl anImport = (XSDImportImpl) content;
-
- XSDSchema impSchema = anImport.getResolvedSchema();
-
- try
- {
- if (impSchema == null)
- {
- impSchema = anImport.importSchema();
- }
- }
- catch (Exception e)
- {
-
- }
-
- if (impSchema != null)
- {
- Iterator i = impSchema.getAttributeDeclarations().iterator();
- while (i.hasNext())
- {
- XSDAttributeDeclaration attrib = (XSDAttributeDeclaration) i.next();
- if (attrib.getName() != null)
- {
- items.addAll(getPrefixedNames(attrib.getTargetNamespace(), attrib.getName()));
- }
- }
- }
- }
- }
- }
- return items;
- }
-
- private Vector addExternalImportedAttributeGroups(Vector items)
- {
- if (xsdSchema != null)
- {
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImportImpl)
- {
- XSDImportImpl anImport = (XSDImportImpl) content;
-
- XSDSchema impSchema = anImport.getResolvedSchema();
-
- try
- {
- if (impSchema == null)
- {
- impSchema = anImport.importSchema();
- }
- }
- catch (Exception e)
- {
-
- }
-
- if (impSchema != null)
- {
- Iterator i = impSchema.getAttributeGroupDefinitions().iterator();
- while (i.hasNext())
- {
- XSDAttributeGroupDefinition attrib = (XSDAttributeGroupDefinition) i.next();
- if (attrib.getName() != null)
- {
- items.addAll(getPrefixedNames(attrib.getTargetNamespace(), attrib.getName()));
- }
- }
- }
- }
- }
- }
- return items;
- }
-
- private Vector addExternalImportedGroups(Vector items)
- {
- if (xsdSchema != null)
- {
- Iterator contents = xsdSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDImportImpl)
- {
- XSDImportImpl anImport = (XSDImportImpl) content;
-
- XSDSchema impSchema = anImport.getResolvedSchema();
-
- try
- {
- if (impSchema == null)
- {
- impSchema = anImport.importSchema();
- }
- }
- catch (Exception e)
- {
- }
-
- if (impSchema != null)
- {
- Iterator i = impSchema.getModelGroupDefinitions().iterator();
- while (i.hasNext())
- {
- XSDModelGroupDefinition aGroup = (XSDModelGroupDefinition) i.next();
- if (aGroup.getName() != null)
- {
- items.addAll(getPrefixedNames(aGroup.getTargetNamespace(), aGroup.getName()));
- }
- }
- }
- }
- }
- }
- return items;
- }
-
- public java.util.List getBuiltInTypeNamesList()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- String xsdForXSDPrefix = xsdSchema.getSchemaForSchemaQNamePrefix();
- if (xsdForXSDPrefix != null && xsdForXSDPrefix.length() > 0)
- {
- xsdForXSDPrefix = xsdForXSDPrefix + ":";
- }
- else
- {
- xsdForXSDPrefix = "";
- }
-
- for (int i = 0; i < XSDDOMHelper.dataType.length; i++)
- {
- items.add(xsdForXSDPrefix + XSDDOMHelper.dataType[i][0]);
- }
- }
- return items;
- }
-
- public java.util.List getBuiltInTypeNamesList2()
- {
- List result = new ArrayList();
- if (xsdSchema != null)
- {
- List prefixes = getPrefixesForNamespace(xsdSchema.getSchemaForSchemaNamespace());
- for (int i = 0; i < XSDDOMHelper.dataType.length; i++)
- {
- for (Iterator j = prefixes.iterator(); j.hasNext();)
- {
- String prefix = (String) j.next();
- String localName = XSDDOMHelper.dataType[i][0];
- String prefixedName = (prefix != null && prefix.length() > 0) ? prefix + ":" + localName : localName;
- result.add(prefixedName);
- }
- }
- }
- return result;
- }
-
- public java.util.List getUserSimpleTypeNamesList()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- Iterator i = xsdSchema.getTypeDefinitions().iterator();
- while (i.hasNext())
- {
- XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
- if (typeDefinition instanceof XSDSimpleTypeDefinition)
- {
- items.addAll(getPrefixedNames(typeDefinition.getTargetNamespace(), typeDefinition.getName()));
- //System.out.println(typeDefinition.getQName(xsdSchema));
- //items.add(typeDefinition.getQName(xsdSchema));
- }
- }
- items.add(getPrefix(xsdSchema.getSchemaForSchemaNamespace(), true) + "anyType");
-
- // items = addExternalImportedUserSimpleTypes(items);
- items = (Vector) sortList(items);
- }
- return items;
- }
-
- public java.util.List getUserComplexTypeNamesList()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- Iterator i = xsdSchema.getTypeDefinitions().iterator();
- while (i.hasNext())
- {
- XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
- if (typeDefinition instanceof XSDComplexTypeDefinition)
- {
- items.addAll(getPrefixedNames(typeDefinition.getTargetNamespace(), typeDefinition.getName()));
- }
- }
- items = (Vector) sortList(items);
- }
- return items;
- }
-
- public java.util.List getUserSimpleTypes()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- Iterator i = xsdSchema.getTypeDefinitions().iterator();
- while (i.hasNext())
- {
- XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
- if (typeDefinition instanceof XSDSimpleTypeDefinition)
- {
- items.add(typeDefinition);
- //System.out.println(typeDefinition.getQName(xsdSchema));
- //items.add(typeDefinition.getQName(xsdSchema));
- }
- }
- // We need to add the anyType
-// items.add(getPrefix(xsdSchema.getSchemaForSchemaNamespace(), true) + "anyType");
-
- // items = addExternalImportedUserSimpleTypes(items);
- //items = (Vector) sortList(items);
- }
- return items;
- }
-
- public String getPrefix(String ns, boolean withColon)
- {
- String key = "";
-
- if (xsdSchema != null)
- {
- Map map = xsdSchema.getQNamePrefixToNamespaceMap();
- Iterator iter = map.keySet().iterator();
- while (iter.hasNext())
- {
- Object keyObj = iter.next();
- Object value = map.get(keyObj);
- if (value != null && value.toString().equals(ns))
- {
- if (keyObj != null)
- {
- key = keyObj.toString();
- }
- else
- {
- key = "";
- }
- break;
- }
- }
- if (!key.equals(""))
- {
- if (withColon)
- {
- key = key + ":";
- }
- }
- }
- return key;
- }
-
- public java.util.List getUserComplexTypes()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- Iterator i = xsdSchema.getTypeDefinitions().iterator();
- while (i.hasNext())
- {
- XSDTypeDefinition typeDefinition = (XSDTypeDefinition) i.next();
- if (typeDefinition instanceof XSDComplexTypeDefinition)
- {
- items.add(typeDefinition);
- }
- }
- }
- return items;
- }
-
- public java.util.List getGlobalElements()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getElementDeclarations() != null)
- {
- Iterator i = xsdSchema.getElementDeclarations().iterator();
- while (i.hasNext())
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) i.next();
- String name = elementDeclaration.getQName(xsdSchema);
- if (name != null)
- {
- items.add(name);
- }
- }
- }
- // items = addExternalImportedGlobalElements(items);
- items = (Vector) sortList(items);
- }
- return items;
- }
-
- public String getGlobalElement(XSDSchema relativeComponent)
- {
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getElementDeclarations() != null)
- {
- Iterator i = xsdSchema.getElementDeclarations().iterator();
- while (i.hasNext()) // just get the first one
- {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) i.next();
- if (elementDeclaration.getQName(relativeComponent) != null)
- {
- return elementDeclaration.getQName(relativeComponent);
- }
- }
- }
-
- Vector items = new Vector();
- items = addExternalImportedGlobalElements(items);
- if (items != null && items.size() > 0)
- {
- return items.get(0).toString();
- }
- }
- return null; // for disabling menu
- }
-
- public java.util.List getGlobalAttributes()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getAttributeDeclarations() != null)
- {
- Iterator i = xsdSchema.getAttributeDeclarations().iterator();
- while (i.hasNext())
- {
- XSDAttributeDeclaration attributeDeclaration = (XSDAttributeDeclaration) i.next();
- if (attributeDeclaration.getTargetNamespace() == null || (attributeDeclaration.getTargetNamespace() != null && !attributeDeclaration.getTargetNamespace().equals(XSDConstants.SCHEMA_INSTANCE_URI_2001)))
- {
- String name = attributeDeclaration.getQName(xsdSchema);
- if (name != null)
- {
- items.add(name);
- }
- }
- }
- }
- // items = addExternalImportedAttributes(items);
- items = (Vector) sortList(items);
- }
- return items;
- }
-
- public String getGlobalAttribute(XSDSchema relativeComponent)
- {
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getAttributeDeclarations() != null)
- {
- Iterator i = xsdSchema.getAttributeDeclarations().iterator();
- while (i.hasNext()) // just get the first one
- {
- XSDAttributeDeclaration attributeDeclaration = (XSDAttributeDeclaration) i.next();
- // Filter out attributes from the schema namespace
- if (!(attributeDeclaration.getTargetNamespace().equals(XSDConstants.SCHEMA_INSTANCE_URI_2001)))
- {
- if (attributeDeclaration.getQName(relativeComponent) != null)
- {
- return attributeDeclaration.getQName(relativeComponent);
- }
- }
- }
- }
-
- Vector items = new Vector();
- items = addExternalImportedAttributes(items);
- if (items != null && items.size() > 0)
- {
- return items.get(0).toString();
- }
- }
- return null; // for disabling menu
- }
-
- public java.util.List getGlobalAttributeGroups()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getAttributeGroupDefinitions() != null)
- {
- Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator();
- while (i.hasNext())
- {
- XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) i.next();
- String name = attributeGroupDefinition.getQName(xsdSchema);
- if (name != null)
- {
- items.add(name);
- }
- }
- }
- // items = addExternalImportedAttributeGroups(items);
- items = (Vector) sortList(items);
- }
- return items;
- }
-
- public String getGlobalAttributeGroup(XSDSchema relativeComponent)
- {
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getAttributeGroupDefinitions() != null)
- {
- Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator();
- while (i.hasNext()) // just get the first one
- {
- XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) i.next();
- if (attributeGroupDefinition.getQName(relativeComponent) != null)
- {
- return attributeGroupDefinition.getQName(relativeComponent);
- }
- }
- }
-
- Vector items = new Vector();
- items = addExternalImportedAttributeGroups(items);
- if (items != null && items.size() > 0)
- {
- return items.get(0).toString();
- }
- }
- return null; // for disabling menu
- }
-
- public java.util.List getModelGroups()
- {
- Vector items = new Vector();
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getModelGroupDefinitions() != null)
- {
- Iterator i = xsdSchema.getModelGroupDefinitions().iterator();
- while (i.hasNext())
- {
- XSDModelGroupDefinition modelGroupDefinition = (XSDModelGroupDefinition) i.next();
- String name = modelGroupDefinition.getQName(xsdSchema);
- if (name != null)
- {
- items.add(name);
- }
- }
- }
- // items = addExternalImportedGroups(items);
- items = (Vector) sortList(items);
- }
- return items;
- }
-
- public static java.util.List sortList(java.util.List types)
- {
- try
- {
- java.util.Collections.sort(types); // performance? n*log(n)
- }
- catch (Exception e)
- {
-// XSDEditorPlugin.getPlugin().getMsgLogger().write("Sort failed");
- }
- return types;
- }
-
- public String getModelGroup(XSDSchema relativeComponent)
- {
- if (xsdSchema != null)
- {
- updateExternalImportGlobals();
- if (xsdSchema.getModelGroupDefinitions() != null)
- {
- Iterator i = xsdSchema.getModelGroupDefinitions().iterator();
- while (i.hasNext()) // just get the first one
- {
- XSDModelGroupDefinition modelGroupDefinition = (XSDModelGroupDefinition) i.next();
- if (modelGroupDefinition.getQName(relativeComponent) != null)
- {
- return modelGroupDefinition.getQName(relativeComponent);
- }
- }
- }
-
- Vector items = new Vector();
- items = addExternalImportedGroups(items);
- if (items != null && items.size() > 0)
- {
- return items.get(0).toString();
- }
- }
- return null; // for disabling menu
- }
-
- public void updateMapAfterDelete(XSDImport deletedNode)
- {
- String ns = deletedNode.getNamespace();
- if (ns != null)
- {
- String prefix = getPrefix(ns, false);
- if (prefix != null)
- {
- prefix = prefix.trim();
- }
- String xmlnsAttr = (prefix == "") ? "xmlns" : "xmlns:" + prefix;
-
- if (prefix == "")
- {
- prefix = null;
- }
-
- if (xsdSchema != null)
- {
- Map map = xsdSchema.getQNamePrefixToNamespaceMap();
- map.remove(prefix);
- Element schemaElement = xsdSchema.getElement();
- schemaElement.removeAttribute(xmlnsAttr);
- }
- }
- }
-
- public List getPrefixedNames(String namespace, String localName)
- {
- List list = new ArrayList();
- if (namespace == null)
- {
- namespace = "";
- }
- if (xsdSchema != null && localName != null)
- {
- List prefixes = getPrefixesForNamespace(namespace);
- for (Iterator i = prefixes.iterator(); i.hasNext(); )
- {
- String prefix = (String)i.next();
- if (prefix == null) prefix = "";
- String prefixedName = prefix.length() > 0 ? prefix + ":" + localName : localName;
- list.add(prefixedName);
- }
- if (prefixes.size() == 0)
- {
- list.add(localName);
- }
- }
- return list;
- }
-
- protected List getPrefixesForNamespace(String namespace)
- {
- List list = new ArrayList();
- Map map = xsdSchema.getQNamePrefixToNamespaceMap();
- for (Iterator iter = map.keySet().iterator(); iter.hasNext();)
- {
- String prefix = (String) iter.next();
- Object value = map.get(prefix);
- if (value != null && value.toString().equals(namespace))
- {
- list.add(prefix);
- }
- }
- return list;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/ViewUtility.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/ViewUtility.java
deleted file mode 100644
index 3e71a8a8fe..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/ViewUtility.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import org.eclipse.swt.SWT;
-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.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-public class ViewUtility
-{
- private static Font font;
-
- public static Font getFont()
- {
- if (font == null)
- {
- font = new Font(Display.getCurrent(), "ms sans serif", 8, SWT.NORMAL);
- }
- return font;
- }
-
- public static void setFont(Font newFont)
- {
- font = newFont;
- }
-
- public static void setComposite(Composite comp)
- {
- // deprecated. Remove later
- }
- public static Composite createComposite(Composite parent, int numColumns)
- {
- Composite composite = new Composite(parent, SWT.NONE);
-
- composite.setFont(getFont());
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
- return composite;
- }
-
- public static Composite createComposite(Composite parent, int numColumns, boolean horizontalFill)
- {
- if (!horizontalFill)
- {
- createComposite(parent, numColumns);
- }
-
- Composite composite = new Composite(parent, SWT.NONE);
-
- composite.setFont(getFont());
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- composite.setLayoutData(data);
-
- return composite;
- }
-
- public static Composite createComposite(Composite parent, int numColumns, boolean horizontalFill, boolean verticalFill)
- {
- if (!horizontalFill && !verticalFill)
- {
- createComposite(parent, numColumns);
- }
-
- Composite composite = new Composite(parent, SWT.NONE);
-
- composite.setFont(getFont());
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- composite.setLayoutData(data);
-
- return composite;
- }
-
- public static Label createHorizontalFiller(Composite parent, int horizontalSpan)
- {
- Label label = new Label(parent, SWT.LEFT);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = horizontalSpan;
- label.setLayoutData(data);
- return label;
- }
-
- /**
- * Helper method for creating labels.
- */
- public static Label createLabel(Composite parent, String text)
- {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- public Label createLabel(Composite parent, int style, String text)
- {
- Label label = new Label(parent, style);
-// setColor(label);
- label.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- public static Label createLabel(Composite parent, String text, int alignment)
- {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = alignment;
- label.setLayoutData(data);
- return label;
- }
-
- /**
- * Helper method for creating buttons.
- */
- public static Button createPushButton(Composite parent, String label)
- {
- Button button = new Button(parent, SWT.PUSH);
- button.setText(label);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
-
- return button;
- }
-
- public static Table createTable(Composite parent)
- {
- Table table = new Table(parent, SWT.SINGLE | SWT.BORDER);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- table.setLayoutData(data);
-
- return table;
- }
-
- /**
- * Create radio button
- */
- public static Button createRadioButton(Composite parent, String label)
- {
- Button button = new Button(parent, SWT.RADIO);
- button.setText(label);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
-
- return button;
- }
-
- /**
- * Helper method for creating check box
- */
- public static Button createCheckBox(Composite parent, String label)
- {
- Button button = new Button(parent, SWT.CHECK);
- button.setText(label);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
- return button;
- }
-
- public static Combo createComboBox(Composite parent)
- {
- return createComboBox(parent, true);
- }
-
- public static Combo createComboBox(Composite parent, boolean isReadOnly)
- {
- int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN;
-
- Combo combo = new Combo(parent, style);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- combo.setLayoutData(data);
- return combo;
- }
-
- public static List createListBox(Composite parent, int width, boolean isMultiSelect)
- {
- int style = isMultiSelect ? SWT.MULTI : SWT.SINGLE;
- List list = new List(parent, style | SWT.BORDER);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- list.setLayoutData(data);
-
- return list;
- }
-
- public static List createListBox(Composite parent, int style)
- {
- List list = new List(parent, style);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- list.setLayoutData(data);
-
- return list;
- }
-
- public Text createTextField(Composite parent)
- {
- Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- text.setLayoutData(data);
-// text.addKeyListener(keyboardHandler);
- return text;
- }
-
- public static Text createTextField(Composite parent, int width)
- {
- Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- text.setLayoutData(data);
-
- return text;
- }
-
- /**
- * <code>createWrappedMultiTextField</code> creates a wrapped multitext field
- *
- * @param parent a <code>Composite</code> value
- * @param width an <code>int</code> value
- * @param numLines an <code>int</code> value representing number of characters in height
- * @param verticalFill a <code>boolean</code> value
- * @return a <code>Text</code> value
- */
- public static Text createWrappedMultiTextField(Composite parent, int width, int numLines, boolean verticalFill)
- {
- Text text = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- data.widthHint = width;
- FontData[] fontData = getFont().getFontData();
- // hack for now where on Windows, only 1 fontdata exists
- data.heightHint = numLines * fontData[0].getHeight();
- text.setLayoutData(data);
-
- return text;
- }
-
- public static Text createMultiTextField(Composite parent, int width, int height, boolean verticalFill)
- {
- Text text = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- data.widthHint = width;
- data.heightHint = height;
- text.setLayoutData(data);
-
- return text;
- }
-
- public static Group createGroup(Composite parent, int numColumns, String text, boolean verticalFill)
- {
- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
- group.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- group.setLayoutData(data);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
- return group;
- }
-
- public static Group createGroup(Composite parent, int numColumns, String text, boolean verticalFill, int alignment)
- {
- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
- group.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = alignment;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- group.setLayoutData(data);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
- return group;
- }
-
- public static Label createVerticalFiller(Composite parent, int verticalSpan)
- {
- Label label = new Label(parent, SWT.LEFT);
- label.setFont(getFont());
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.verticalSpan = verticalSpan;
- label.setLayoutData(data);
-
- return label;
- }
-
- /**
- * Creates a grid data object that occupies vertical and horizontal
- * space.
- */
- static public GridData createFill()
- {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- return gd;
- }
- /**
- * Creates a grid data object that occupies horizontal space.
- */
- static public GridData createHorizontalFill()
- {
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- return gd;
- }
- /**
- * Creates a grid data object that occupies vertical space.
- */
- static public GridData createVerticalFill()
- {
- GridData gd= new GridData();
- gd.verticalAlignment= GridData.FILL;
- gd.grabExcessVerticalSpace= true;
- return gd;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDDOMHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDDOMHelper.java
deleted file mode 100644
index 8d18a111c7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDDOMHelper.java
+++ /dev/null
@@ -1,1136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import java.util.ArrayList;
-
-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.xsd.util.XSDConstants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-public class XSDDOMHelper
-{
- public static final int LENGTH_FACET = 1;
- public static final int MIN_LENGTH_FACET = 2;
- public static final int MAX_LENGTH_FACET = 3;
- public static final int PATTERN_FACET = 4;
- public static final int ENUM_FACET = 5;
- public static final int WHITE_SPACE_FACET = 6;
-
- public static final int MAX_INCLUSIVE_FACET = 7;
- public static final int MAX_EXCLUSIVE_FACET = 8;
- public static final int MIN_INCLUSIVE_FACET = 9;
- public static final int MIN_EXCLUSIVE_FACET = 10;
-
- public static final int TOTAL_DIGITS_FACET = 11;
- public static final int FRACTION_DIGITS_FACET = 12;
-
- public static final int N_FACETS = 13;
-
- public static String[][] dataType =
- {
- //
- // Table format:
- // Type
- // Length, MinLength, MaxLength, Pattern, Enumeration,whiteSpace
- // MaxInclusive, MaxExclusive, MinInclusive, MinExclusive, TotalDigits, FractionDigits
- //
-
- // 0
- { "anySimpleType",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 1
- { "anyType",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
-
- // 2
- { "anyURI",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 3
- { "base64Binary",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 4
- { "boolean",
- "N", "N", "N", "Y", "N", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 5
- { "byte",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 6
- { "date",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 7
- { "dateTime",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 8
- { "decimal",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
-
- // 9
- { "double",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 10
- { "duration",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 11
- { "ENTITY",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 12
- { "ENTITIES",
- "Y", "Y", "Y", "N", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 13
- { "float",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 14
- { "gDay",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 15
- { "gMonth",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 16
- { "gMonthDay",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 17
- { "gYear",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 18
- { "gYearMonth",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 19
- { "hexBinary",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 20
- { "ID",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 21
- { "IDREF",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 22
- { "IDREFS",
- "Y", "Y", "Y", "N", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 23
- { "int",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 24
- { "integer",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 25
- { "language",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 26
- { "long",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 27
- { "Name",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
-
- // 28
- { "NCName",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 29
- { "negativeInteger",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 30
- { "NMTOKEN",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 31
- { "NMTOKENS",
- "Y", "Y", "Y", "N", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 32
- { "nonNegativeInteger",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 33
- { "nonPositiveInteger",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 34
- { "normalizedString",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
-
- },
-
- // 35
- { "NOTATION",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
-
- },
-
- // 36
- { "positiveInteger",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 37
- { "QName",
- "N", "N", "N", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 38
- { "short",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 39
- { "string",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 40
- { "time",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "N", "N",
- },
-
- // 41
- { "token",
- "Y", "Y", "Y", "Y", "Y", "Y",
- "N", "N", "N", "N", "N", "N",
- },
-
- // 42
- { "unsignedByte",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 43
- { "unsignedInt",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 44
- { "unsignedLong",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- // 45
- { "unsignedShort",
- "N", "N", "N", "Y", "Y", "Y",
- "Y", "Y", "Y", "Y", "Y", "Y",
- },
-
- };
-
- public static String XMLSchemaURI = "http://www.w3.org/2001/XMLSchema";
-
- /**
- * Constructor for XSDDOMHelper.
- */
- public XSDDOMHelper()
- {
- super();
- }
-
- public Node getChildNode(Element parent, String childName)
- {
-/* NodeList nodeList = parent.getElementsByTagNameNS(XMLSchemaURI, childName);
- if (nodeList.getLength() > 0)
- return nodeList.item(0);
- return null;
-*/
- NodeList list = null;
- if (parent != null)
- {
- list = parent.getChildNodes();
- }
-
- if (list != null)
- {
- // Performance issue perhaps?
- for (int i = 0; i < list.getLength(); i++)
- {
- if (list.item(i) instanceof Element)
- {
- if (list.item(i).getLocalName().equals(childName))
- {
- return list.item(i);
- }
- }
- }
- }
- return null;
- }
-
- public static String SIMPLE_TYPE = "Simple";
- public static String USER_SIMPLE_TYPE = "simpleType";
- public static String USER_COMPLEX_TYPE = "complexType";
-/*
- public void setElementType(Element element, String type)
- {
- Document doc = element.getOwnerDocument();
- if (type.equals(SIMPLE_TYPE))
- {
- removeChild(element, USER_SIMPLE_TYPE);
- removeChild(element, USER_COMPLEX_TYPE);
- element.setAttribute("type","xsd:string");
- return;
- }
- else if (type.equals(USER_SIMPLE_TYPE))
- {
- removeChild(element, USER_COMPLEX_TYPE);
- }
- else
- {
- removeChild(element, USER_SIMPLE_TYPE);
- }
- element.removeAttribute("type");
- element.appendChild(doc.createElement("xsd:"+type));
- }
-
- public String getElementType(Element element)
- {
- String tagName = element.getLocalName();
-
- if (tagName.equals(XSDConstants.ELEMENT_ELEMENT_TAG) ||
- tagName.equals(XSDConstants.ATTRIBUTE_ELEMENT_TAG))
- {
- if (element.hasAttribute("type"))
- {
- return SIMPLE_TYPE;
- }
- NodeList nodes = element.getElementsByTagNameNS(XMLSchemaURI, USER_SIMPLE_TYPE);
- if (nodes.getLength() > 0)
- {
- return USER_SIMPLE_TYPE;
- }
- nodes = element.getElementsByTagNameNS(XMLSchemaURI, USER_COMPLEX_TYPE);
- if (nodes.getLength() > 0)
- {
- return USER_COMPLEX_TYPE;
- }
- }
- return "";
- }
-*/
- public void removeDerivedByElement(Element element)
- {
- removeChild(element, XSDConstants.RESTRICTION_ELEMENT_TAG);
- removeChild(element, XSDConstants.EXTENSION_ELEMENT_TAG);
- }
-
- public String getBaseType(Element element) // for SimpleContent and ComplexContent
- {
- Node restrictionChild = getChildNode(element, "restriction");
- Node extensionChild = getChildNode(element, "extension");
- String baseType = "";
- if (restrictionChild != null)
- {
- if (restrictionChild instanceof Element)
- {
- baseType = ((Element)restrictionChild).getAttribute("base");
-// String prefix = element.getPrefix();
-// if (prefix != null && prefix.length() > 0)
-// {
-// baseType = baseType.substring(baseType.indexOf(prefix) + prefix.length() + 1);
-// }
- }
- }
- else if (extensionChild != null) // should be one or the other
- {
- if (extensionChild instanceof Element)
- {
- baseType = ((Element)extensionChild).getAttribute("base");
-// String prefix = element.getPrefix();
-// if (prefix != null && prefix.length() > 0)
-// {
-// baseType = baseType.substring(baseType.indexOf(prefix) + prefix.length() + 1);
-// }
- }
- }
- return baseType;
- }
-
- public void setDerivedByBaseType(Element element, String derivedByType, String type)
- {
- Document doc = element.getOwnerDocument();
-
- Element derivedByElement = getDerivedByElement(element);
- if (derivedByElement != null)
- {
- derivedByElement.setAttribute("base", type);
- }
- else // there really should be one already...base is required.
- {
- Element newElement = doc.createElement(derivedByType);
- newElement.setAttribute("base", type);
- element.appendChild(newElement);
- }
- }
-
- public void changeDerivedByType(Element element, String derivedByType, String type)
- {
- Document doc = element.getOwnerDocument();
-
- String prefix = element.getPrefix();
- prefix = prefix == null ? "" : prefix + ":";
-
- Element derivedByElement = getDerivedByElement(element);
-
- if (derivedByElement != null && derivedByElement.getLocalName().equals(derivedByType))
- {
- return; // it's already the derived by type
- }
- Element newNode;
- if (derivedByType.equals("restriction"))
- {
- newNode = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + XSDConstants.RESTRICTION_ELEMENT_TAG);
- }
- else
- {
- newNode = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + XSDConstants.EXTENSION_ELEMENT_TAG);
- }
-
- newNode.setAttribute("base", type);
-
- if (derivedByElement != null)
- {
- if (derivedByElement.hasChildNodes())
- {
- NodeList nodes = derivedByElement.getChildNodes();
- // use clones so we don't have a refresh problem
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- newNode.appendChild(node.cloneNode(true));
- }
- }
- element.replaceChild(newNode, derivedByElement);
- }
- else
- {
- Element parent = (Element) element.getParentNode(); // get back to complexType
- NodeList nodes = parent.getChildNodes();
- ArrayList nodeSaveList = new ArrayList();
-
- // save children. (nodes turns out to be the same object as parent;
- // deleting them from parent will delete them from nodes.)
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- nodeSaveList.add(node);
- }
-
- // remove children so we can surround them by complexContent
- for (int i = 0; i < nodeSaveList.size(); i++)
- {
- Node node = (Node) nodeSaveList.get(i);
- parent.removeChild(node);
- }
-
- // build a complexContent element
- Element complexContent = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + XSDConstants.COMPLEXCONTENT_ELEMENT_TAG);
- parent.appendChild(complexContent); // insert into complexType
- complexContent.appendChild(newNode); // insert derivation type
- for (int i = 0; i < nodeSaveList.size(); i++) // insert children previously of complexType
- {
- Node node = (Node) nodeSaveList.get(i);
- newNode.appendChild(node.cloneNode(true));
- }
-
- parent.appendChild(complexContent);
- formatChild(complexContent);
- }
- }
-
- public void setSimpleContentType(Element element, String type)
- {
- String contentTypeName = element.getLocalName();
-
- if (contentTypeName.equals(XSDConstants.UNION_ELEMENT_TAG))
- {
- element.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, type);
- }
- else if (contentTypeName.equals(XSDConstants.LIST_ELEMENT_TAG))
- {
- element.setAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE, type);
- }
- else if (contentTypeName.equals(XSDConstants.RESTRICTION_ELEMENT_TAG))
- {
- element.setAttribute(XSDConstants.BASE_ATTRIBUTE, type);
- }
- }
-
- public void removeSimpleTypeContent(Element element)
- {
- String contentTypeName = element.getLocalName();
- if (contentTypeName.equals(XSDConstants.UNION_ELEMENT_TAG))
- {
- element.removeAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE);
- }
- else if (contentTypeName.equals(XSDConstants.LIST_ELEMENT_TAG))
- {
- element.removeAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE);
- }
- else if (contentTypeName.equals(XSDConstants.RESTRICTION_ELEMENT_TAG))
- {
- element.removeAttribute(XSDConstants.BASE_ATTRIBUTE);
- }
- }
-
- public String getDerivedByName(Element element)
- {
- Node restrictionChild = getChildNode(element, "restriction");
- Node extensionChild = getChildNode(element, "extension");
- if (restrictionChild != null)
- {
- return "restriction";
- }
- if (extensionChild != null)
- {
- return "extension";
- }
- return "";
- }
-
- /**
- * Get the derived by node given the complexContent or simpleContent node
- */
- public Element getDerivedByElement(Element element)
- {
- Node restrictionChild = getChildNode(element, "restriction");
- Node extensionChild = getChildNode(element, "extension");
- if (restrictionChild != null)
- {
- if (restrictionChild instanceof Element)
- {
- return (Element)restrictionChild;
- }
- }
-
- if (extensionChild != null)
- {
- if (extensionChild instanceof Element)
- {
- return (Element)extensionChild;
- }
- }
- return null;
- }
-
- /**
- * Get the derived by node given the ComplexType node
- * Returns the first one, if say, the INVALID schema has more than one
- */
- public Element getDerivedByElementFromComplexType(Element element)
- {
- NodeList nl = element.getChildNodes();
- int j = 0;
- for (j = 0; j < nl.getLength(); j++)
- {
- Node aNode = nl.item(j);
- if (inputEquals(aNode, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- break;
- }
- else if (inputEquals(aNode, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- break;
- }
- }
- Element derivedByNode = getDerivedByElement((Element)nl.item(j));
- return derivedByNode;
- }
-
- /**
- * Get the content model given the ComplexType node
- * Returns the first one, if say, the INVALID schema has more than one
- */
- public Element getContentModelFromParent(Element element)
- {
- NodeList nl = element.getChildNodes();
- int j = 0;
- boolean modelExists = false;
- int length = nl.getLength();
- for (j = 0; j < length; j++)
- {
- Node aNode = nl.item(j);
- if (inputEquals(aNode, XSDConstants.COMPLEXCONTENT_ELEMENT_TAG, false))
- {
- modelExists = true;
- break;
- }
- else if (inputEquals(aNode, XSDConstants.SIMPLECONTENT_ELEMENT_TAG, false))
- {
- modelExists = true;
- break;
- }
- else if (inputEquals(aNode, XSDConstants.SEQUENCE_ELEMENT_TAG, false))
- {
- modelExists = true;
- break;
- }
- else if (inputEquals(aNode, XSDConstants.CHOICE_ELEMENT_TAG, false))
- {
- modelExists = true;
- break;
- }
- else if (inputEquals(aNode, XSDConstants.ALL_ELEMENT_TAG, false))
- {
- modelExists = true;
- break;
- }
- }
- if (!modelExists)
- {
- return null;
- }
-
- Element derivedByNode = (Element)nl.item(j);
- return derivedByNode;
- }
-
- /**
- *
- */
- public void changeContentModel(Element complexTypeElement, String contentModel, Element sequenceChoiceOrAllElement)
- {
- Document doc = complexTypeElement.getOwnerDocument();
-
- String prefix = complexTypeElement.getPrefix();
- prefix = prefix == null ? "" : prefix + ":";
-
- Element contentModelElement = getContentModelFromParent(complexTypeElement);
-
- if (contentModelElement.getLocalName().equals(contentModel))
- {
- return; // it's already the content model
- }
- Element newNode;
- newNode = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + contentModel);
-
- if (contentModelElement.hasChildNodes())
- {
- NodeList nodes = contentModelElement.getChildNodes();
- // use clones so we don't have a refresh problem
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- if (node instanceof Element)
- {
- if (node.getLocalName().equals(XSDConstants.ANNOTATION_ELEMENT_TAG))
- {
- if (!(XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.SEQUENCE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.CHOICE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(contentModelElement, XSDConstants.ALL_ELEMENT_TAG, false)))
- {
- newNode.appendChild(node.cloneNode(true));
- }
- }
- else if (node.getLocalName().equals(XSDConstants.RESTRICTION_ELEMENT_TAG) ||
- node.getLocalName().equals(XSDConstants.EXTENSION_ELEMENT_TAG))
- {
- newNode.appendChild(node.cloneNode(true));
- if (sequenceChoiceOrAllElement != null)
- {
- node.appendChild(sequenceChoiceOrAllElement);
- }
- }
- else
- {
- removeNodeAndWhitespace(node);
- }
- }
- else
- {
- newNode.appendChild(node.cloneNode(true));
- }
- }
- }
- complexTypeElement.replaceChild(newNode, contentModelElement);
- }
-
- public Element cloneElement(Element parent, Element sourceNode)
- {
- Document doc = parent.getOwnerDocument();
- String prefix = parent.getPrefix();
- prefix = prefix == null ? "" : prefix + ":";
-
- Element newNode = doc.createElementNS(XSDDOMHelper.XMLSchemaURI, prefix + sourceNode.getLocalName());
-
- if (sourceNode.hasChildNodes())
- {
- NodeList nodes = sourceNode.getChildNodes();
- // use clones so we don't have a refresh problem
- for (int i = 0; i < nodes.getLength(); i++)
- {
- Node node = nodes.item(i);
- newNode.appendChild(node.cloneNode(true));
- }
- }
- return newNode;
-// parent.replaceChild(newNode, sourceNode);
- }
-
- public boolean hasElementChildren(Element parentNode)
- {
- boolean hasChildrenElements = false;
- if (parentNode != null && parentNode.hasChildNodes())
- {
- NodeList nodes = parentNode.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++)
- {
- if (nodes.item(i) instanceof Element)
- {
- hasChildrenElements = true;
- break;
- }
- }
- }
- return hasChildrenElements;
- }
-
- public void removeChild(Element node, String childName)
- {
- Node child = getChildNode(node,childName);
- if (child != null)
- {
- node.removeChild(child);
- }
- }
-
- public static boolean isFacet(Object obj)
- {
- if (XSDDOMHelper.inputEquals(obj, XSDConstants.LENGTH_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.MINLENGTH_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.MAXLENGTH_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.WHITESPACE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.MAXINCLUSIVE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.MAXEXCLUSIVE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.MININCLUSIVE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.MINEXCLUSIVE_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.TOTALDIGITS_ELEMENT_TAG, false) ||
- XSDDOMHelper.inputEquals(obj, XSDConstants.FRACTIONDIGITS_ELEMENT_TAG, false))
- {
- return true;
- }
- return false;
- }
-
- public static void removeNodeAndWhitespace(Node node)
- {
- Node parentNode = node.getParentNode();
-
- Node nextElement = getNextElementNode(node);
- Node previousElement = getPreviousElementNode(node);
-
- Node nextSibling = node.getNextSibling();
- if (nextSibling instanceof Text)
- {
- parentNode.removeChild(nextSibling);
- }
-
- if (parentNode != null)
- {
- parentNode.removeChild(node);
- }
-
- if (nextElement != null)
- {
- formatChild(nextElement);
- }
-
- if (previousElement != null)
- {
- formatChild(previousElement);
- }
- }
-
- 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 Node getLastElementNode(Node parent)
- {
- Node lastChild = parent.getLastChild();
-
- while (!(lastChild instanceof Element) && lastChild != null)
- {
- lastChild = lastChild.getPreviousSibling();
- }
- return lastChild;
- }
-
- public static Node getNextElementNode(Node node)
- {
- Node next = node.getNextSibling();
-
- while (!(next instanceof Element) && next != null)
- {
- next = next.getNextSibling();
- }
- if (next instanceof Text)
- {
- return null;
- }
- return next;
- }
-
- public static Node getPreviousElementNode(Node node)
- {
- Node previous = node.getPreviousSibling();
-
- while (!(previous instanceof Element) && previous != null)
- {
- previous = previous.getPreviousSibling();
- }
- if (previous instanceof Text)
- {
- return null;
- }
- return previous;
- }
-
- public static void moveNode(Node referenceNode, Node nodeToMove, boolean isBefore)
- {
- // this assumes that the referenceNode and node to move have the same parent
- Node parent = referenceNode.getParentNode();
-
- // Get reference nodes next and previous text strings
- String referenceNodeNextString = "";
- String referenceNodePreviousString = "";
- if (referenceNode != null)
- {
- Node referenceNodeNextSibling = referenceNode.getNextSibling();
- Node referenceNodePreviousSibling = referenceNode.getPreviousSibling();
- if (referenceNodeNextSibling instanceof Text)
- {
- referenceNodeNextString = ((Text)referenceNodeNextSibling).getData();
- }
- if (referenceNodePreviousSibling instanceof Text)
- {
- referenceNodePreviousString = ((Text)referenceNodePreviousSibling).getData();
- }
- }
- // Get the dragged node's next and previous text strings
- Node nodeToMoveNextSibling = nodeToMove.getNextSibling();
- Node nodeToMovePreviousSibling = nodeToMove.getPreviousSibling();
- Node nodeToMoveNextText = null;
- String nodeToMoveNextString = "";
- String nodeToMovePreviousString = "";
- if (nodeToMoveNextSibling instanceof Text)
- {
- nodeToMoveNextText = (Text)nodeToMoveNextSibling;
- nodeToMoveNextString = ((Text)nodeToMoveNextSibling).getData();
- }
- if (nodeToMovePreviousSibling instanceof Text)
- {
- nodeToMovePreviousString = ((Text)nodeToMovePreviousSibling).getData();
- }
-
- // Get the last element's next and previous text strings
- Node lastElement = getLastElementNode(parent);
- Node lastElementNextSibling = lastElement.getNextSibling();
- Node lastElementPreviousSibling = lastElement.getPreviousSibling();
- String lastElementNextString = "";
- String lastElementPreviousString = "";
- if (lastElementNextSibling instanceof Text)
- {
- lastElementNextString = ((Text)lastElementNextSibling).getData();
- }
- if (lastElementPreviousSibling instanceof Text)
- {
- lastElementPreviousString = ((Text)lastElementPreviousSibling).getData();
- }
-
- boolean isLastElement = false; // whether the last element is dragged/moved
- if (lastElement == nodeToMove)
- {
- isLastElement = true;
- }
-
- // defect 221056 this test is required or else the node will
- // be removed from the tree and the insert will fail
- if (referenceNode != nodeToMove)
- {
- parent.removeChild(nodeToMove);
- if (referenceNode != null)
- {
- if (!isBefore)
- {
- referenceNode = getNextElementNode(referenceNode);
-// referenceNode = referenceNode.getNextSibling();
- }
- }
-
- if (referenceNode != null)
- {
- insertBefore(nodeToMove, referenceNode);
- }
- else
- {
- parent.appendChild(nodeToMove);
- }
-
- Node newLastElement = getLastElementNode(parent);
- if (referenceNode != null)
- {
- if (referenceNode != newLastElement)
- {
- if (!isLastElement)
- {
- setTextData(referenceNode, nodeToMoveNextString, nodeToMovePreviousString);
- }
- }
- setTextData(nodeToMove, referenceNodeNextString, referenceNodePreviousString);
- }
- // Remove the empty space left by the dragged node
- if (nodeToMoveNextText != null)
- {
- parent.removeChild(nodeToMoveNextText);
- }
- // special case for the last element
- if ((newLastElement == nodeToMove) || isLastElement)
- {
- setTextData(newLastElement, lastElementNextString, lastElementPreviousString);
- }
- }
- }
-
- public static void setTextData(Node target, String nextText, String previousText)
- {
- Node parent = target.getParentNode();
- Node nextSibling = target.getNextSibling();
- Node previousSibling = target.getPreviousSibling();
- if (nextSibling instanceof Text)
- {
- ((Text)nextSibling).setData(nextText);
- }
- if (nextSibling == null || nextSibling instanceof Element)
- {
- Text textNode = parent.getOwnerDocument().createTextNode("");
- textNode.setData(nextText);
- if (nextSibling != null)
- {
- parent.insertBefore(textNode, nextSibling);
- }
- else
- {
- parent.insertBefore(textNode, getNextElementNode(target));
- }
- }
-
- if (previousSibling instanceof Text)
- {
- ((Text)previousSibling).setData(previousText);
- }
- if (previousSibling == null || previousSibling instanceof Element)
- {
- Text textNode = parent.getOwnerDocument().createTextNode("");
- textNode.setData(previousText);
- parent.insertBefore(textNode, target);
- }
- }
-
- public static void insertBefore(Node nodeToInsert, Node referenceNode)
- {
- // this assumes that the referenceNode and node to move have the same parent
- Node parent = referenceNode.getParentNode();
- parent.insertBefore(nodeToInsert, referenceNode);
- }
-
- public static boolean inputEquals(Object input, String tagname, boolean isRef)
- {
- if (input instanceof Element)
- {
- Element element = (Element) input;
- if (element.getLocalName().equals(tagname))
- {
- boolean refPresent = element.hasAttribute("ref");
-
- return refPresent == isRef;
- }
- }
- return false;
- }
-
- public static void updateElementToNotAnonymous(Element element)
- {
- if (element != null)
- {
- NodeList children = element.getChildNodes();
- if (children != null)
- {
- for (int i = 0; i < children.getLength(); i++)
- {
- Node node = (Node)children.item(i);
- if (node instanceof Element)
- {
- if (node.getLocalName().equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG) ||
- node.getLocalName().equals(XSDConstants.COMPLEXTYPE_ELEMENT_TAG))
- {
- XSDDOMHelper.removeNodeAndWhitespace(node);
- i=0;
- }
- }
- }
- }
- }
- }
-
- public static boolean isAttributeRef(Element ct, String attrName, String ns)
- {
- NodeList list = ct.getChildNodes();
- int length = list.getLength();
- for (int i = 0; i < length; i++)
- {
- if (list.item(i) instanceof Element)
- {
- Element aChild = (Element)list.item(i);
- if (aChild.getLocalName().equals(XSDConstants.ATTRIBUTE_ELEMENT_TAG))
- {
- if (aChild.hasAttribute(XSDConstants.REF_ATTRIBUTE))
- {
- String refValue = aChild.getAttribute(XSDConstants.REF_ATTRIBUTE);
- if (refValue.equals(attrName))
- {
- return true;
- }
- }
- }
- }
-
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaHelper.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaHelper.java
deleted file mode 100644
index a57e619cbb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaHelper.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.xsd.XSDConcreteComponent;
-
-// TODO: KC remove this
-
-public class XSDSchemaHelper
-{
- /**
- * Constructor for XSDSchemaHelper.
- */
- public XSDSchemaHelper()
- {
- super();
- }
-
- public 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) {}
- }
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java
deleted file mode 100644
index 3c8ca3d1e1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.xsd.util.XSDSchemaLocationResolver;
-
-public class XSDSchemaLocationResolverAdapterFactory extends AdapterFactoryImpl
-{
- protected XSDSchemaLocationResolverImpl schemaLocator = new XSDSchemaLocationResolverImpl();
-
- public boolean isFactoryForType(Object type)
- {
- return type == XSDSchemaLocationResolver.class;
- }
-
- public Adapter adaptNew(Notifier target, Object type)
- {
- return schemaLocator;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverImpl.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverImpl.java
deleted file mode 100644
index 71e5f884bd..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/util/XSDSchemaLocationResolverImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.util;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDSchemaLocationResolver;
-import org.eclipse.xsd.util.XSDSchemaLocator;
-
-public class XSDSchemaLocationResolverImpl extends AdapterImpl implements XSDSchemaLocationResolver
-{
- public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI)
- {
- String baseLocation = xsdSchema.getSchemaLocation();
- String result = URIResolverPlugin.createResolver().resolve(baseLocation, namespaceURI, schemaLocationURI);
- if (result == null) {
- result = namespaceURI;
- }
- if (result == null) {
- result = "";
- }
-
- return result;
- }
-
- public boolean isAdatperForType(Object type)
- {
- return type == XSDSchemaLocator.class;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/validation/DelegatingSourceValidatorForXSD.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/validation/DelegatingSourceValidatorForXSD.java
deleted file mode 100644
index 240b0bda82..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/validation/DelegatingSourceValidatorForXSD.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.validation;
-
-import org.eclipse.wst.validation.internal.provisional.ValidationFactory;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidator;
-
-/**
- * This performs the as-you-type validation
- * @author Mark Hutchinson
- *
- */
-public class DelegatingSourceValidatorForXSD extends DelegatingSourceValidator
-{
- final private static String VALIDATOR_CLASS = "org.eclipse.wst.xsd.ui.internal.validation.Validator";
-
- public DelegatingSourceValidatorForXSD()
- { super();
- }
-
- protected IValidator getDelegateValidator()
- {
- try
- { return ValidationFactory.instance.getValidator(VALIDATOR_CLASS);
- }
- catch (Exception e)
- { //
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/EnumerationsDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/EnumerationsDialog.java
deleted file mode 100644
index eba2c64168..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/EnumerationsDialog.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.widgets;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-
-
-/**
- * Dialog to help define a list of enumerations
- * for a join. This might be replaced once we know how to
- * initiate a drag tracker
- */
-
-public class EnumerationsDialog extends org.eclipse.jface.dialogs.Dialog
-{
- public EnumerationsDialog(Shell shell)
- {
- super(shell);
- }
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- shell.setText(XSDEditorPlugin.getXSDString("_UI_ENUMERATIONS_DIALOG_TITLE"));
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.OK)
- {
- text = textField.getText();
- delimiter = delimiterField.getText();
- isPreserve = preserveWhitespace.getSelection();
- }
- super.buttonPressed(buttonId);
- }
-
- private String text, delimiter;
- private boolean isPreserve;
- public String getText() { return text; }
- public String getDelimiter() { return delimiter; }
- public boolean isPreserveWhitespace() { return isPreserve; }
-
- private Text textField;
- private Button preserveWhitespace;
- private Combo delimiterField;
- //
- // Create the controls
- //
- public Control createDialogArea(Composite parent)
- {
- Control[] tabOrder = new Control[3];
- int tabIndex = 0;
- Composite client = (Composite)super.createDialogArea(parent);
- GridLayout layout = (GridLayout)client.getLayout();
- layout.numColumns = 2;
- client.setLayout(layout);
-
- textField = ViewUtility.createWrappedMultiTextField(client, 400, 20, true);
- GridData gd = (GridData) textField.getLayoutData();
- gd.horizontalSpan = 2;
- tabOrder[tabIndex++] = textField;
-
- ViewUtility.createLabel(client, XSDEditorPlugin.getXSDString("_UI_LABEL_DELIMITER_CHAR"));
- delimiterField = ViewUtility.createComboBox(client, false);
- gd = (GridData) delimiterField.getLayoutData();
- gd.grabExcessHorizontalSpace = false;
- gd.horizontalAlignment = GridData.BEGINNING;
- gd.widthHint = 30;
- tabOrder[tabIndex++] = delimiterField;
-
- // add default delimiters
- delimiterField.add(":");
- delimiterField.add(",");
- delimiterField.add(" ");
- // set the current one to be ','
- delimiterField.setText(",");
-
- preserveWhitespace = ViewUtility.createCheckBox(client, XSDEditorPlugin.getXSDString("_UI_LABEL_PRESERVE_WHITESPACE"));
- gd = (GridData) preserveWhitespace.getLayoutData();
- gd.horizontalSpan = 2;
- tabOrder[tabIndex++] = preserveWhitespace;
-
- client.setTabList(tabOrder);
-
- return client;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/SetBaseTypeDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/SetBaseTypeDialog.java
deleted file mode 100644
index 21c32abada..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/SetBaseTypeDialog.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.widgets;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-
-
-public class SetBaseTypeDialog extends Dialog implements SelectionListener
-{
- protected Combo baseTypeCombo;
- protected Combo derivedByCombo;
- protected XSDSchema xsdSchema;
- protected Element element; // the complex type element
- private String type = "";
- private String derivedByString = "";
-
- /**
- * Constructor for SetBaseTypeDialog.
- * @param arg0
- */
- public SetBaseTypeDialog(Shell arg0, XSDSchema xsdSchema, Element element)
- {
- super(arg0);
- this.xsdSchema = xsdSchema;
- this.element = element;
- }
-
- protected void configureShell(Shell shell)
- {
- super.configureShell(shell);
- shell.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_SET_BASE_TYPE"));
- }
-
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == Dialog.OK)
- {
- type = baseTypeCombo.getText();
- derivedByString = derivedByCombo.getText();
- }
- super.buttonPressed(buttonId);
- }
-
- public String getBaseType()
- {
- return type;
- }
-
- public String getDerivedBy()
- {
- return derivedByString;
- }
-
- public void setCurrentBaseType(String type)
- {
- this.type = type;
- }
-
- public void setCurrentDerivedBy(String derivedByString)
- {
- this.derivedByString = derivedByString;
- }
-
- //
- // Create the controls
- //
- public Control createDialogArea(Composite parent)
- {
- Composite nameComposite = (Composite)super.createDialogArea(parent);
- GridLayout layout = (GridLayout)nameComposite.getLayout();
- layout.numColumns = 2;
- nameComposite.setLayout(layout);
-
- ViewUtility.createLabel(nameComposite, XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON"));
- baseTypeCombo = ViewUtility.createComboBox(nameComposite, true); // readonly
- baseTypeCombo.addSelectionListener(this);
-
- ViewUtility.createLabel(nameComposite, XSDEditorPlugin.getXSDString("_UI_LABEL_DERIVED_BY"));
- derivedByCombo = ViewUtility.createComboBox(nameComposite, true); // readonly
-
- derivedByCombo.add(XSDConstants.EXTENSION_ELEMENT_TAG);
- derivedByCombo.add(XSDConstants.RESTRICTION_ELEMENT_TAG);
- derivedByCombo.setText(derivedByString);
- initializeBaseTypeCombo();
-
- if (type.equals(""))
- {
- derivedByCombo.setText("");
- derivedByCombo.setEnabled(false);
- }
-
- return nameComposite;
- }
-
- private void initializeBaseTypeCombo()
- {
- ArrayList list = new ArrayList();
- TypesHelper helper = new TypesHelper(xsdSchema);
-
- String prefix = helper.getPrefix(xsdSchema.getTargetNamespace(), true);
-
- list.add("");
- list.addAll(helper.getBuiltInTypeNamesList());
- list.addAll(helper.getUserSimpleTypeNamesList());
- list.addAll(helper.getUserComplexTypeNamesList());
-
- // remove the current CT from the list
- list.remove(prefix + element.getAttribute("name"));
-
- baseTypeCombo.removeAll();
- for (int i = 0; i < list.size(); i++)
- {
- baseTypeCombo.add(list.get(i).toString());
- }
- baseTypeCombo.setText(type);
- handleBaseTypeComboChange();
- }
-
- private void handleBaseTypeComboChange()
- {
- String tempChoice = baseTypeCombo.getText();
- TypesHelper helper = new TypesHelper(xsdSchema);
- if (helper.getBuiltInTypeNamesList().contains(tempChoice) ||
- helper.getUserSimpleTypeNamesList().contains(tempChoice))
- {
- derivedByCombo.setText(XSDConstants.EXTENSION_ELEMENT_TAG);
- derivedByCombo.setEnabled(false);
- }
- else if (helper.getUserComplexTypeNamesList().contains(tempChoice))
- {
- derivedByCombo.setEnabled(true);
- }
- else
- {
- derivedByCombo.setText("");
- derivedByCombo.setEnabled(false);
- }
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == baseTypeCombo)
- {
- handleBaseTypeComboChange();
- }
-
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/TypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/TypeSection.java
deleted file mode 100644
index e5b6bdce5b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/TypeSection.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.widgets;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.XSDSchema;
-
-public class TypeSection
-{
- /**
- * Constructor for TypeSection.
- * @param parent
- */
- public TypeSection(Composite parent)
- {
- }
-
- protected Button simpleType;
- protected Button userSimpleType;
- protected Button userComplexType;
- protected Button noneRadio;
- protected Combo typeList;
- protected Combo derivedByCombo;
- protected boolean showUserComplexType = true;
- protected boolean showUserSimpleType = true;
- protected boolean showNone = false;
- protected boolean showDerivedBy = false;
- protected String derivedByChoices[] = { "restriction", "extension" };
- public final int NONE = 1;
- public final int BUILT_IN = 2;
- public final int SIMPLE = 3;
- public final int COMPLEX = 4;
-
- String sectionTitle = XSDEditorPlugin.getXSDString("_UI_LABEL_TYPE_INFORMATION");
- String currentObjectUuid = "";
-
- /*
- * @see FlatPageSection#createClient(Composite, WidgetFactory)
- */
- public Composite createClient(Composite parent)
- {
- Composite client = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout(1, true);
- gl.verticalSpacing = 0;
- client.setLayout(gl);
-
- if (showNone)
- {
- noneRadio = ViewUtility.createRadioButton(client, XSDEditorPlugin.getXSDString("_UI_RADIO_NONE"));
- WorkbenchHelp.setHelp(noneRadio, XSDEditorContextIds.XSDE_TYPE_HELPER_NONE);
- }
-
- simpleType = ViewUtility.createRadioButton(client, XSDEditorPlugin.getXSDString("_UI_RADIO_BUILT_IN_SIMPLE_TYPE"));
- WorkbenchHelp.setHelp(simpleType, XSDEditorContextIds.XSDE_TYPE_HELPER_BUILT_IN);
-
- if (showUserSimpleType)
- {
- userSimpleType = ViewUtility.createRadioButton(client, XSDEditorPlugin.getXSDString("_UI_RADIO_USER_DEFINED_SIMPLE_TYPE"));
- WorkbenchHelp.setHelp(userSimpleType, XSDEditorContextIds.XSDE_TYPE_HELPER_USER_DEFINED_SIMPLE);
- }
-
- if (showUserComplexType)
- {
- userComplexType = ViewUtility.createRadioButton(client, XSDEditorPlugin.getXSDString("_UI_RADIO_USER_DEFINED_COMPLEX_TYPE"));
- WorkbenchHelp.setHelp(userComplexType, XSDEditorContextIds.XSDE_TYPE_HELPER_USER_DEFINED_COMPLEX);
- }
-
- // typeList = utility.createComboBox(client);
- // WorkbenchHelp.setHelp(typeList, XSDEditorContextIds.XSDE_TYPE_HELPER_TYPE);
- // utility.createHeadingLabel(client, "Type",null);
-
- if (showDerivedBy)
- {
- Composite derivedByComposite = ViewUtility.createComposite(client, 2);
- ViewUtility.createLabel(derivedByComposite, XSDEditorPlugin.getXSDString("_UI_LABEL_DERIVED_BY"));
- derivedByCombo = ViewUtility.createComboBox(derivedByComposite);
- populateDerivedByCombo();
- WorkbenchHelp.setHelp(derivedByCombo, XSDEditorContextIds.XSDE_SIMPLE_CONTENT_DERIVED);
- derivedByCombo.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_DERIVED_BY"));
- }
- // Set the default selection
- if (showNone)
- {
- // noneRadio.setSelection(true);
- // typeList.setEnabled(false);
- }
- else
- {
- simpleType.setSelection(true);
- }
- return client;
- }
-
- public void setIsDerivedBy(boolean derive)
- {
- if (derive)
- {
- sectionTitle = XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE");
- }
- else
- {
- sectionTitle = XSDEditorPlugin.getXSDString("_UI_LABEL_TYPE_INFORMATION");
- }
- // setHeaderText(sectionTitle);
- }
-
- /**
- * Set to true if called by Complex Type & Simple Type
- */
- public void setShowDerivedBy(boolean derive)
- {
- showDerivedBy = derive;
- }
-
- /**
- * Gets the derivedByField
- * @return Returns a Button
- */
- public Combo getDerivedByCombo()
- {
- return derivedByCombo;
- }
-
- /**
- * Gets the noneRadio.
- * @return Returns a Button
- */
- public Button getNoneRadio()
- {
- return noneRadio;
- }
-
- /**
- * Gets the simpleType.
- * @return Returns a Button
- */
- public Button getSimpleType()
- {
- return simpleType;
- }
-
- /**
- * Gets the userComplexType.
- * @return Returns a Button
- */
- public Button getUserComplexType()
- {
- return userComplexType;
- }
-
- /**
- * Gets the userSimpleType.
- * @return Returns a Button
- */
- public Button getUserSimpleType()
- {
- return userSimpleType;
- }
-
- /**
- * Gets the typeList.
- * @return Returns a CCombo
- */
- public Combo getTypeList()
- {
- return typeList;
- }
-
- /**
- * Populate combo box with built-in simple types
- */
- public void populateBuiltInType(XSDSchema xsdSchema)
- {
- getTypeList().removeAll();
- List items = getBuiltInTypeNamesList(xsdSchema);
- for (int i = 0; i < items.size(); i++)
- {
- getTypeList().add(items.get(i).toString());
- }
- }
-
- public java.util.List getBuiltInTypeNamesList(XSDSchema xsdSchema)
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getBuiltInTypeNamesList();
- }
-
- /**
- * Populate combo box with user defined complex types
- */
- public void populateUserComplexType(XSDSchema xsdSchema, boolean showAnonymous)
- {
- getTypeList().removeAll();
- if (showAnonymous)
- {
- getTypeList().add(XSDEditorPlugin.getXSDString("_UI_ANONYMOUS"));
- }
-
- List items = getUserComplexTypeNamesList(xsdSchema);
- for (int i = 0; i < items.size(); i++)
- {
- getTypeList().add(items.get(i).toString());
- }
- }
-
- public java.util.List getUserComplexTypeNamesList(XSDSchema xsdSchema)
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserComplexTypeNamesList();
- }
-
- public void populateUserSimpleType(XSDSchema xsdSchema, boolean showAnonymous)
- {
- getTypeList().removeAll();
- if (showAnonymous)
- {
- getTypeList().add(XSDEditorPlugin.getXSDString("_UI_ANONYMOUS"));
- }
- List items = getUserSimpleTypeNamesList(xsdSchema);
- for (int i = 0; i < items.size(); i++)
- {
- getTypeList().add(items.get(i).toString());
- }
- }
-
- /**
- * Populate combo box with user defined simple types
- */
- public void populateUserSimpleType(XSDSchema xsdSchema)
- {
- getTypeList().removeAll();
- List items = getUserSimpleTypeNamesList(xsdSchema);
- for (int i = 0; i < items.size(); i++)
- {
- getTypeList().add(items.get(i).toString());
- }
- }
-
- public java.util.List getUserSimpleTypeNamesList(XSDSchema xsdSchema)
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- return helper.getUserSimpleTypeNamesList();
- }
-
- public String getPrefix(String ns, XSDSchema xsdSchema)
- {
- TypesHelper helper = new TypesHelper(xsdSchema);
- String key = helper.getPrefix(ns, true);
- return key;
- }
-
- /**
- * Populate combo box with derived by choices
- */
- protected void populateDerivedByCombo()
- {
- for (int i = 0; i < derivedByChoices.length; i++)
- {
- getDerivedByCombo().add(derivedByChoices[i]);
- }
- }
-
- /**
- * Gets the showUserComplexType.
- * @return Returns a boolean
- */
- public boolean getShowUserComplexType()
- {
- return showUserComplexType;
- }
-
- /**
- * Gets the showUserSimpleType.
- * @return Returns a boolean
- */
- public boolean getShowUserSimpleType()
- {
- return showUserSimpleType;
- }
-
- /**
- * Gets the showNone.
- * @return Returns a boolean
- */
- public boolean getShowNone()
- {
- return showNone;
- }
-
- /**
- * Sets the showUserComplexType.
- * @param showUserComplexType The showUserComplexType to set
- */
- public void setShowUserComplexType(boolean showUserComplexType)
- {
- this.showUserComplexType = showUserComplexType;
- }
-
- /**
- * Sets the showUserSimpleType.
- * @param showUserSimpleType The showUserSimpleType to set
- */
- public void setShowUserSimpleType(boolean showUserSimpleType)
- {
- this.showUserSimpleType = showUserSimpleType;
- }
-
- /**
- * Sets the showNone
- * @param showUserSimpleType The showNone to set
- */
- public void setShowNone(boolean showNone)
- {
- this.showNone = showNone;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/XSDEditSchemaInfoDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/XSDEditSchemaInfoDialog.java
deleted file mode 100644
index cf4d9df6c5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/widgets/XSDEditSchemaInfoDialog.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.widgets;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditSchemaInfoDialog;
-import org.eclipse.wst.xml.ui.internal.nsedit.CommonEditNamespacesTargetFieldDialog;
-
-public class XSDEditSchemaInfoDialog extends EditSchemaInfoDialog {
- String targetNamespace;
- CommonEditNamespacesTargetFieldDialog editNamespacesControl;
-
- public XSDEditSchemaInfoDialog(Shell parentShell, IPath resourceLocation, String targetNamespace) {
- super(parentShell, resourceLocation);
- this.targetNamespace = targetNamespace;
- }
-/*
- // in super
- protected CommonEditNamespacesDialog createCommonEditNamespacesDialog(Composite dialogArea)
- {
- return new CommonEditNamespacesDialog(dialogArea, resourceLocation, XMLUIPlugin.getResourceString("%_UI_NAMESPACE_DECLARATIONS"), false, true); //$NON-NLS-1$
- }
-
- // in super
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- CommonEditNamespacesDialog editNamespacesControl = createCommonEditNamespacesDialog(dialogArea);
- editNamespacesControl.setNamespaceInfoList(namespaceInfoList);
- editNamespacesControl.updateErrorMessage(namespaceInfoList);
- return dialogArea;
- }
-
- // in this
- protected CommonEditNamespacesDialog createCommonEditNamespacesDialog(Composite dialogArea)
- {
- return new CommonEditNamespacesTargetFieldDialog(dialogArea, resourceLocation); //$NON-NLS-1$
- } */
-
- // this is copy of ....
- protected Control __internalCreateDialogArea(Composite parent) {
- // create a composite with standard margins and spacing
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- applyDialogFont(composite);
- return composite;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) __internalCreateDialogArea(parent);
- editNamespacesControl = new CommonEditNamespacesTargetFieldDialog(dialogArea, resourceLocation); //$NON-NLS-1$
- if (targetNamespace != null)
- {
- editNamespacesControl.setTargetNamespace(targetNamespace);
- }
- editNamespacesControl.setNamespaceInfoList(namespaceInfoList);
- editNamespacesControl.updateErrorMessage(namespaceInfoList);
- return dialogArea;
- }
-
- public String getTargetNamespace() {
- return editNamespacesControl.getTargetNamespace();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java
deleted file mode 100644
index cdb003ac26..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.wizards;
-
-import java.io.ByteArrayInputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-
-
-public class NewXSDWizard extends Wizard implements INewWizard {
- private XSDNewFilePage newFilePage;
- private IStructuredSelection selection;
- private IWorkbench workbench;
-
- public NewXSDWizard() {
- }
-
- public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
- this.selection = aSelection;
- this.workbench = aWorkbench;
-
- this.setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/NewXSD.gif"));
- this.setWindowTitle(XSDEditorPlugin.getXSDString("_UI_WIZARD_CREATE_XSD_MODEL_TITLE"));
- }
-
- public void addPages() {
- newFilePage = new XSDNewFilePage(selection);
- addPage(newFilePage);
- }
-
- public boolean performFinish() {
- IFile file = newFilePage.createNewFile();
-
- //
- // Get the xsd schema name from the full path name
- // e.g. f:/b2b/po.xsd => schema name = po
- //
- IPath iPath = file.getFullPath().removeFileExtension();
- // String schemaName = iPath.lastSegment();
- String schemaName = iPath.lastSegment();
- String schemaPrefix = "tns";
- String prefixForSchemaNamespace = "";
- String schemaNamespaceAttribute = "xmlns";
- if (XSDEditorPlugin.getPlugin().isQualifyXMLSchemaLanguage()) {
- // Added this if check before disallowing blank prefixes in the
- // preferences...
- // Can take this out. See also XSDEditor
- if (XSDEditorPlugin.getPlugin().getXMLSchemaPrefix().trim().length() > 0) {
- prefixForSchemaNamespace = XSDEditorPlugin.getPlugin().getXMLSchemaPrefix() + ":";
- schemaNamespaceAttribute += ":" + XSDEditorPlugin.getPlugin().getXMLSchemaPrefix();
- }
- }
-
- Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences();
- String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
- if (charSet == null || charSet.trim().equals("")) {
- charSet = "UTF-8";
- }
-
- String newContents = "<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>\n";
-
- String defaultTargetURI = XSDEditorPlugin.getPlugin().getXMLSchemaTargetNamespace();
- newContents += "<" + prefixForSchemaNamespace + "schema " + schemaNamespaceAttribute + "=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"" + defaultTargetURI + schemaName + "\" xmlns:" + schemaPrefix + "=\"" + defaultTargetURI + schemaName + "\">\n</" + prefixForSchemaNamespace + "schema>";
-
- try {
- byte[] bytes = newContents.getBytes(charSet);
- ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
-
- file.setContents(inputStream, true, false, null);
- inputStream.close();
- }
- catch (Exception e) {
- // XSDEditorPlugin.getPlugin().getMsgLogger().write("Error writing
- // default content:\n" + newContents);
- // XSDEditorPlugin.getPlugin().getMsgLogger().write(e);
- }
-
- if (file != null) {
- revealSelection(new StructuredSelection(file));
- }
-
- openEditor(file);
-
- return true;
- }
-
- private void revealSelection(final ISelection selection) {
- if (selection != null) {
- IWorkbench workbench2;
- if (workbench == null)
- {
- workbench2 = XSDEditorPlugin.getPlugin().getWorkbench();
- }
- else
- {
- workbench2 = workbench;
- }
- final IWorkbenchWindow workbenchWindow = workbench2.getActiveWorkbenchWindow();
- final IWorkbenchPart focusPart = workbenchWindow.getActivePage().getActivePart();
- if (focusPart instanceof ISetSelectionTarget) {
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- ((ISetSelectionTarget) focusPart).selectReveal(selection);
- }
- });
- }
- }
- }
-
- public void openEditor(final IFile iFile) {
- if (iFile != null) {
- IWorkbench workbench2;
- if (workbench == null)
- {
- workbench2 = XSDEditorPlugin.getPlugin().getWorkbench();
- }
- else
- {
- workbench2 = workbench;
- }
- final IWorkbenchWindow workbenchWindow = workbench2.getActiveWorkbenchWindow();
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), XSDEditorPlugin.XSD_EDITOR_ID);
- }
- catch (PartInitException ex) {
- }
- }
- });
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexCompositionPage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexCompositionPage.java
deleted file mode 100644
index e7923d6134..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexCompositionPage.java
+++ /dev/null
@@ -1,958 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Based on version 1.12 of original xsdeditor
-package org.eclipse.wst.xsd.ui.internal.wizards;
-
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-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.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.XSDPatternFacet;
-
-
-
-/*
--other regex features (eg case sensitivity, ^ or $, |, etc etc)
--smarter model
--better keyboard navigation
--update list of tokens
-*/
-
-public class RegexCompositionPage extends WizardPage
-{
- private static final boolean debug = false;
-
- /* The text representation of our pattern. */
- private StyledText value;
-
- /* The StyleRange used to color code the current parse error. */
- private StyleRange currentError;
-
- /* The regex terms we can form tokens from. */
- private Combo terms;
-
- /* The checkbox for activating auto-escape mode. */
- private Button escapeCheckbox;
-
- /* On/off status of auto-escape mode. */
- private boolean autoEscapeStatus;
-
- /* The Add Token button. */
- private Button add;
-
-
- // The following controls are used in the occurrence selection group
-
- private Text repeatValue;
-
- private Text rangeMinValue;
- private Text rangeMaxValue;
- private Label rangeToLabel;
-
- private Button singleRadio;
- private Button starRadio;
- private Button plusRadio;
- private Button optionalRadio;
- private Button repeatRadio;
- private Button rangeRadio;
-
-
- // The following variables used as part of the model.
-
- /* Our pattern. */
- private XSDPatternFacet pattern;
-
- /* Model used to store the current token. */
- private RegexNode node;
-
- /* The flags passed to the new RegularExpression object. Default value includes:
- X = XMLSchema mode */
- private String regexFlags = "X";
-
-
- /* Is the current regex token valid? */
- private boolean isValidToken;
-
- /* The label used to indicate the value's caret position when it looses focus. */
- private Label caretLabel;
-
- /* The pixel offsets needed to align the label icon with the caret location.
- These are dependent on the icon used. */
- private static final int CARET_LABEL_X_OFFSET = -3;
- private static final int CARET_LABEL_Y_OFFSET = 19;
-
-
- /* Enumerated constants for specifying the type of an error message. */
- private static final int TOKEN = 0;
- private static final int SELECTION = 1;
- private static final int PARSE = 2;
-
- private static final int NUM_ERROR_MESSAGE_TYPES = 3;
-
- /* The current error message for each type of error. A value of null indicates no message.
- The array is indexed according to the above constants.
- */
- private String[] currentErrorMessages;
-
-
- public RegexCompositionPage(XSDPatternFacet pattern)
- {
- super(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_COMPOSITION_PAGE_TITLE"));
- this.pattern = pattern;
-
- setTitle(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_COMPOSITION_PAGE_TITLE"));
- setDescription(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_COMPOSITION_PAGE_DESCRIPTION"));
- }
-
- public void createControl(Composite parent)
- {
- // Set up our model and validator
- node = new RegexNode();
-
- isValidToken = true;
-
- currentErrorMessages = new String[NUM_ERROR_MESSAGE_TYPES];
-
- // The main composite
- Composite composite= new Composite(parent, SWT.NONE);
- WorkbenchHelp.setHelp(composite, XSDEditorContextIds.XSDR_COMPOSITION_PAGE);
- composite.setLayout(new GridLayout());
-
-
- // The composite for the token combo box, label, and auto-escape checkbox
- Composite tokenComposite = new Composite (composite, SWT.NONE);
- GridLayout tokenCompositeLayout = new GridLayout();
- tokenCompositeLayout.numColumns = 3;
- tokenCompositeLayout.marginWidth = 0;
- tokenComposite.setLayout(tokenCompositeLayout);
-
-
- new Label(tokenComposite, SWT.LEFT).setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TOKEN_LABEL"));
-
- terms = new Combo(tokenComposite, SWT.DROP_DOWN);
- WorkbenchHelp.setHelp(terms, XSDEditorContextIds.XSDR_COMPOSITION_TOKEN);
- for (int i = 0; i < RegexNode.getNumRegexTerms(); i++)
- {
- terms.add(RegexNode.getRegexTermText(i));
- }
- terms.addListener(SWT.Modify, new ComboListener());
- terms.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_TERMS"));
-
- escapeCheckbox = new Button(tokenComposite, SWT.CHECK);
- escapeCheckbox.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_AUTO_ESCAPE_CHECKBOX_LABEL"));
- escapeCheckbox.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_AUTO_ESCAPE_CHECKBOX"));
- escapeCheckbox.addSelectionListener(new CheckboxListener());
- autoEscapeStatus = false;
-
- tokenComposite.pack();
-
-
- // Set up the composites pertaining to the selection of occurrence quantifiers
-
- Group occurrenceSelectionArea = new Group(composite, SWT.NONE);
- occurrenceSelectionArea.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_OCCURENCE_LABEL"));
- WorkbenchHelp.setHelp(occurrenceSelectionArea, XSDEditorContextIds.XSDR_COMPOSITION_OCCURRENCE_GROUP);
- GridLayout selectionAreaLayout = new GridLayout();
- selectionAreaLayout.numColumns = 2;
- occurrenceSelectionArea.setLayout(selectionAreaLayout);
-
- // Listener used for all of the text fields
- TextListener textListener = new TextListener();
-
-
- // Add the radio buttons
- RadioSelectListener radioSelectListener = new RadioSelectListener();
-
- singleRadio = addOccurenceRadioButton(RegexNode.SINGLE, occurrenceSelectionArea, radioSelectListener);
- WorkbenchHelp.setHelp(singleRadio, XSDEditorContextIds.XSDR_COMPOSITION_JUST_ONCE);
- ViewUtility.createHorizontalFiller(occurrenceSelectionArea, 1);
-
- starRadio = addOccurenceRadioButton(RegexNode.STAR, occurrenceSelectionArea, radioSelectListener);
- WorkbenchHelp.setHelp(starRadio, XSDEditorContextIds.XSDR_COMPOSITION_ZERO_OR_MORE);
- ViewUtility.createHorizontalFiller(occurrenceSelectionArea, 1);
-
- plusRadio = addOccurenceRadioButton(RegexNode.PLUS, occurrenceSelectionArea, radioSelectListener);
- WorkbenchHelp.setHelp(plusRadio, XSDEditorContextIds.XSDR_COMPOSITION_ONE_OR_MORE);
- ViewUtility.createHorizontalFiller(occurrenceSelectionArea, 1);
-
- optionalRadio = addOccurenceRadioButton(RegexNode.OPTIONAL, occurrenceSelectionArea, radioSelectListener);
- WorkbenchHelp.setHelp(optionalRadio, XSDEditorContextIds.XSDR_COMPOSITION_OPTIONAL);
- ViewUtility.createHorizontalFiller(occurrenceSelectionArea, 1);
-
- repeatRadio = addOccurenceRadioButton(RegexNode.REPEAT, occurrenceSelectionArea, radioSelectListener);
- WorkbenchHelp.setHelp(repeatRadio, XSDEditorContextIds.XSDR_COMPOSITION_REPEAT);
-
- // Add text field for specifying number of repeats
- Composite repeatWidgets = new Composite(occurrenceSelectionArea, SWT.NONE);
- RowLayout repeatWidgetsLayout = new RowLayout();
- repeatWidgetsLayout.marginTop = 0;
- repeatWidgetsLayout.marginBottom = 0;
- repeatWidgetsLayout.marginLeft = 0;
- repeatWidgetsLayout.marginRight = 0;
- repeatWidgets.setLayout(repeatWidgetsLayout);
-
- repeatValue = new Text(repeatWidgets, SWT.SINGLE | SWT.BORDER);
- repeatValue.addListener(SWT.Modify, textListener);
- WorkbenchHelp.setHelp(repeatValue, XSDEditorContextIds.XSDR_COMPOSITION_REPEAT_TEXT);
- repeatValue.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_REPEAT"));
- setEnabledStatus(RegexNode.REPEAT, false);
-
- repeatWidgets.pack();
-
- rangeRadio = addOccurenceRadioButton(RegexNode.RANGE, occurrenceSelectionArea, radioSelectListener);
- WorkbenchHelp.setHelp(rangeRadio, XSDEditorContextIds.XSDR_COMPOSITION_RANGE);
-
- // Add text fields and labels for specifying the range
- Composite rangeWidgets = new Composite(occurrenceSelectionArea, SWT.NONE);
- RowLayout rangeWidgetsLayout = new RowLayout();
- rangeWidgetsLayout.marginTop = 0;
- rangeWidgetsLayout.marginBottom = 0;
- rangeWidgetsLayout.marginLeft = 0;
- rangeWidgetsLayout.marginRight = 0;
- rangeWidgets.setLayout(rangeWidgetsLayout);
-
- rangeMinValue = new Text(rangeWidgets, SWT.SINGLE | SWT.BORDER);
- rangeMinValue.addListener(SWT.Modify, textListener);
- WorkbenchHelp.setHelp(rangeMinValue, XSDEditorContextIds.XSDR_COMPOSITION_RANGE_MIN);
- rangeMinValue.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_MIN"));
-
- rangeToLabel = new Label(rangeWidgets, SWT.NONE);
- rangeToLabel.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TO_LABEL"));
-
- rangeMaxValue = new Text(rangeWidgets, SWT.SINGLE | SWT.BORDER);
- rangeMaxValue.addListener(SWT.Modify, textListener);
- rangeMaxValue.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_MAX"));
- WorkbenchHelp.setHelp(rangeMaxValue, XSDEditorContextIds.XSDR_COMPOSITION_RANGE_MAX);
-
- setEnabledStatus(RegexNode.RANGE, false);
- rangeWidgets.pack();
-
- singleRadio.setSelection(true);
-
- occurrenceSelectionArea.pack();
-
- // The add button
- add = new Button(composite, SWT.PUSH);
- add.addSelectionListener(new ButtonSelectListener());
- add.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_ADD_BUTTON_LABEL"));
- WorkbenchHelp.setHelp(add, XSDEditorContextIds.XSDR_COMPOSITION_ADD);
- add.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_ADD_BUTTON"));
-
-
- Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-
- // Our main text box
-
- Label valueLabel= new Label(composite, SWT.LEFT);
- valueLabel.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_CURRENT_REGEX_LABEL"));
-
- value = new StyledText(composite, SWT.SINGLE | SWT.BORDER);
- value.addListener(SWT.Modify, textListener);
- value.addListener(SWT.Selection, textListener);
- WorkbenchHelp.setHelp(value, XSDEditorContextIds.XSDR_COMPOSITION_CURRENT);
- value.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_CURRENT_REGEX"));
- value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- value.setFocus();
-
- // StyleRange used for highlighting parse errors
- currentError = new StyleRange();
- currentError.length = 1;
- currentError.foreground = parent.getDisplay().getSystemColor(SWT.COLOR_RED);
-
- // The caret label
- caretLabel = new Label(composite, SWT.LEFT);
- caretLabel.setImage(XSDEditorPlugin.getXSDImage("icons/RegexWizardArrow.gif"));
- caretLabel.setToolTipText(XSDEditorPlugin.getXSDString("_UI_TOOLTIP_REGEX_WIZARD_CARET_LABEL"));
- setShowCaretLabel(true);
-
- value.addFocusListener(new TextFocusListener());
-
- terms.select(0);
-
-
- setControl(composite);
- }
-
-
- public void setVisible(boolean visible)
- {
- super.setVisible(visible);
-
- value.setText(pattern.getLexicalValue());
- value.setCaretOffset(value.getCharCount());
- }
-
- public void dispose()
- {
- super.dispose();
- }
-
-
- /**
- * Sets the visible status of caretLabel to status. If status is true, then we also update the position
- * of caretLabel in one of two ways. If there is no active selection in value, we set caretLabel's
- * position to correspond with the position of the actual caret. Alternatively, if there is an active selection
- * in value, we set caretLabel's position to the beginning of the selection.
- *
- * @param The new visibility status of caretLabel.
- */
- private void setShowCaretLabel(boolean status)
- {
- if (status)
- {
-
- int offset;
-
- if (value.getSelectionText().equals(""))
- {
- offset = value.getCaretOffset();
- }
- else
- {
- offset = value.getSelection().x;
- }
-
- Point p = value.getLocationAtOffset(offset);
-
- p.x += value.getLocation().x;
- p.y = value.getLocation().y;
-
- // Place the label under value, and make sure it is aligned with the caret.
- // The offsets are dependent on the icon used.
- p.x += CARET_LABEL_X_OFFSET;
- p.y += CARET_LABEL_Y_OFFSET;
-
- if (debug)
- {
- System.out.println("POINT: " + p);
- }
-
- caretLabel.setLocation(p);
- caretLabel.setVisible(true);
- }
- else
- {
- caretLabel.setVisible(false);
- }
- }
-
-
- /**
- * Adds a new radio button to Composite c with SelectionListener l. The text of the button is the String associated with
- * quantifier.
- *
- * @param quantifier The desired quantifier, as enumerated in RegexNode.
- * @param c The Composite to add the buttons to (normally occurrenceRadioButtons).
- * @param l The SelectionListener (normally radioSelectionListener).
- * @return The newly created button.
- */
- private Button addOccurenceRadioButton(int quantifier, Composite c, SelectionListener l)
- {
- Button result = new Button(c, SWT.RADIO);
- result.setText(RegexNode.getQuantifierText(quantifier));
- result.addSelectionListener(l);
- return result;
- }
-
-
- /**
- * Validates the regex in value. If the regex is valid, clears the Wizard's error message. If it's not valid,
- * sets the Wizard's error message accordingly.
- *
- * @return Whether the regex is valid.
- */
- private boolean validateRegex()
- {
-
- boolean isValid;
- try
- {
- // We validate the regex by checking whether we get a ParseException.
- // By default, we assume that it's valid unless we determine otherwise.
- isValid = true;
- displayRegexErrorMessage(null);
- value.setStyleRange(null);
-
- Pattern.compile(value.getText());
- }
- catch (PatternSyntaxException pe)
- {
- isValid = false;
- displayRegexErrorMessage(pe.getMessage());
-
- // An off-by-one bug in the xerces regex parser will sometimes return a location for the parseError that
- // is off the end of the string. If this is the case, then we want to highlight the last character.
- if (pe.getIndex() >= value.getText().length())
- {
- currentError.start = value.getText().length() - 1;
- }
- else
- {
- currentError.start = pe.getIndex();
- }
-
- if (debug)
- {
- System.out.println("Parse Error location: " + pe.getIndex());
- System.out.println("currentError.start: " + currentError.start);
- }
-
- value.setStyleRange(currentError);
-
- }
-
- // Another bug in the xerces parser will sometimes throw a RuntimeException instead of a ParseException.
- // When we get a RuntimeException, we aren't provided with the additional information we need to highlight
- // the parse error. So, we merely report that there is an error.
- catch (RuntimeException re)
- {
- displayRegexErrorMessage("");
- value.setStyleRange(null);
- isValid = false;
- }
-
- setPageComplete(isValid);
- return isValid;
- }
-
-
- /**
- * Manages the display of error messages.
- * Sets the error message for type to errorMessage. If errorMessage != null, then we set the Wizard's error message
- * to errorMessage. If errorMessage == null, then we check whether we have a pending message of another type.
- * If we do, then it is displayed as the Wizard's error message. If we don't, then the Wizard's error message field
- * is cleared.
- *
- * @param errorMessage The text of the new error message. A value of null indicates that the error message should
- * be cleared.
- * @param type The error type, one of PARSE, TOKEN, or SELECTION.
- */
- private void displayErrorMessage(String errorMessage, int type)
- {
- String messageToDisplay = null;
-
-
- currentErrorMessages[type] = errorMessage;
-
- messageToDisplay = errorMessage;
-
- for (int i = 0; i < NUM_ERROR_MESSAGE_TYPES; i++)
- {
- if (messageToDisplay != null)
- {
- break;
- }
- messageToDisplay = currentErrorMessages[i];
- }
-
- setErrorMessage(messageToDisplay);
- }
-
-
- /**
- * Sets the Wizard's error message to message, preceded by a standard prefix.
- *
- * @param message The new error message (or null to clear it).
- */
- private void displayRegexErrorMessage (String errorMessage)
- {
- if (errorMessage == null)
- {
- displayErrorMessage(null, PARSE);
- }
- else
- {
- if (errorMessage.trim().equals("")) // when there is no error message available.
- {
- displayErrorMessage(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_REGEX_ERROR"),
- PARSE);
- }
- else
- {
- displayErrorMessage(errorMessage, PARSE);
- }
- }
- }
-
-
- /**
- * Updates the token status. Sets isValidToken to status && the status of the other error type.
- * If status is true, we clear the wizard's error message for this type; if it is false, we set it to errorMessage.
- *
- * @param status The new isValidToken value.
- * @param errorMessage The new error message.
- * @param type The type of the error (either TOKEN or SELECTION).
- */
- private void setTokenStatus (boolean status, String errorMessage, int type)
- {
- boolean otherTypeStatus = (type == TOKEN) ?
- currentErrorMessages[SELECTION] == null :
- currentErrorMessages[TOKEN] == null;
-
- isValidToken = status && otherTypeStatus;
- add.setEnabled(isValidToken);
-
- if (status)
- {
- displayErrorMessage(null, type);
- }
- else
- {
- if (errorMessage != null && errorMessage.trim().equals("")) // when there is no error message available.
- {
- displayErrorMessage(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_TOKEN_ERROR"),
- type);
- }
- else
- {
- displayErrorMessage(errorMessage, type);
- }
- }
- }
-
-
- /**
- * Updates the token status. Sets isValidToken to status && the status of the other error type.
- * Also clears the wizard's error message for this type.
- * Usually used to set isValidToken to true.
- *
- * @param status The new isValidToken value.
- * @param type The type of the error (either TOKEN or SELECTION).
- */
- private void setTokenStatus(boolean status, int type)
- {
- setTokenStatus(status, null, type);
- }
-
-
-
- /**
- * Sets the enabled status of the text fields and labels associated with the specified quantifier.
- * If status is true, then fields and labels associated with other quantifiers are disabled.
- * @param quantifier The quantifier whose elements' enabled status we wish to change
- * (as enumerated in RegexNode).
- * @param status The new status of the elements. If true, then all elements associated with other buttons
- * are disabled.
- */
- private void setEnabledStatus(int quantifier, boolean status)
- {
- switch (quantifier)
- {
-
- case RegexNode.REPEAT:
- repeatValue.setEnabled(status);
- if (status)
- {
- rangeMinValue.setEnabled(false);
- rangeMaxValue.setEnabled(false);
- rangeToLabel.setEnabled(false);
- }
- break;
-
- case RegexNode.RANGE:
- rangeMinValue.setEnabled(status);
- rangeMaxValue.setEnabled(status);
- rangeToLabel.setEnabled(status);
- if (status)
- {
- repeatValue.setEnabled(false);
- }
- break;
-
- }
- }
-
- /**
- * Checks to see if there is a selection in value. If there is not, we set the Wizard's error message accordingly.
- * If there is, we update the contents of node. If "Current Selection" is not the current token, then
- * we clear the Selection error message.
- */
- private void updateCurrentSelectionStatus()
- {
- if (terms.getSelectionIndex() == RegexNode.SELECTION)
- {
- String selection = value.getSelectionText();
- if (selection.equals(""))
- {
- setTokenStatus(false, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_SELECTION_ERROR"), SELECTION);
- }
- else
- {
- setTokenStatus(true, SELECTION);
- node.setContents(selection);
- node.setHasParens(true);
- }
- }
- else
- {
- setTokenStatus(true, SELECTION);
- }
- }
-
- /**
- * Updates the enabled status of the auto-escape checkbox. If status is true, we enable the checkbox, and
- * set its selection status and node's auto-escape status to the value of autoEscapeStatus. If status is
- * false, then we disable and deselect the checkbox, and set node's status to false.
- *
- * @param status The new enabled status.
- */
- private void setEscapeCheckboxEnabledStatus(boolean status)
- {
- if (status)
- {
- escapeCheckbox.setEnabled(true);
- escapeCheckbox.setSelection(autoEscapeStatus);
- node.setAutoEscapeStatus(autoEscapeStatus);
- }
- else
- {
- escapeCheckbox.setEnabled(false);
- escapeCheckbox.setSelection(false);
- node.setAutoEscapeStatus(false);
- }
- }
-
-
- /**
- * Returns the current regex flags.
- */
- String getFlags()
- {
- return regexFlags;
- }
-
- /**
- * Returns the current XSDPattern model.
- */
- XSDPatternFacet getPattern()
- {
- return pattern;
- }
-
-
- /**
- * Returns a string consisting of the values of min, max, and repeat stored in node.
- * Used for debugging purposes only.
- */
- private String getAllFieldValues()
- {
- String result = "";
- result += "Min: " + node.getMin() + "\n";
- result += "Max: " + node.getMax() + "\n";
- result += "Repeat: " + node.getRepeat() + "\n";
- result += "\n";
- return result;
- }
-
-
- /* Listener for the add button. */
- class ButtonSelectListener implements SelectionListener
- {
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- // Precondition: isValidToken == true
- public void widgetSelected(SelectionEvent e)
- {
- if (!isValidToken) // should never happen
- {
- System.out.println("Attempted to add an invalid token.");
- System.out.println(node.toString());
- System.out.println(getAllFieldValues());
- return;
- }
-
- // Whether there is anything selected in value.
- boolean isActiveSelection = value.getSelectionCount() != 0;
-
- value.insert(node.toString());
-
- if (terms.getSelectionIndex() == RegexNode.SELECTION)
- {
- updateCurrentSelectionStatus();
- }
-
- // If nothing is selected, then we need to advance the caret location.
- if (!isActiveSelection)
- {
- value.setCaretOffset(value.getCaretOffset() + node.toString().length());
- }
-
- value.setFocus();
-
- }
-
- }
-
-
- /* Listener for the terms combo box. */
- class ComboListener implements Listener
- {
- public void handleEvent(Event e)
- {
-
- updateCurrentSelectionStatus();
-
- // If the user has typed in a token
- if (terms.getSelectionIndex() == -1)
- {
- setEscapeCheckboxEnabledStatus(true);
- node.setContents(terms.getText());
- node.setHasParens(true);
-
-
- if (debug)
- {
- System.out.println(terms.getText());
- }
-
- }
- else if (terms.getSelectionIndex() == RegexNode.SELECTION)
- {
- setEscapeCheckboxEnabledStatus(false);
- }
- else
- {
- node.setContents(RegexNode.getRegexTermValue(terms.getSelectionIndex()));
- node.setHasParens(false);
- setEscapeCheckboxEnabledStatus(false);
- }
- }
- }
-
-
- /* Listener for enabling/disabling caretLabel. */
- class TextFocusListener implements FocusListener
- {
- public void focusGained(FocusEvent e)
- {
- setShowCaretLabel(false);
- }
- public void focusLost(FocusEvent e)
- {
- setShowCaretLabel(true);
- }
- }
-
-
-
- /* Listener for the text fields. */
- class TextListener implements Listener
- {
- public void handleEvent (Event e)
- {
-
- if (debug)
- {
- System.out.println("Inside TextListener handler");
- System.out.println(e);
- System.out.println(getAllFieldValues());
- }
-
-
- if ( (e.widget == value) && (e.type == SWT.Modify) )
- {
- pattern.setLexicalValue(value.getText());
- validateRegex();
- }
-
- else if (e.widget == value && e.type == SWT.Selection)
- {
- if (terms.getSelectionIndex() == RegexNode.SELECTION)
- {
- updateCurrentSelectionStatus();
- }
- }
-
- else if (e.widget == rangeMinValue)
- {
- boolean isValid = node.setMin(rangeMinValue.getText());
-
- if (isValid)
- {
- setTokenStatus(true, null, TOKEN);
- }
- else
- {
- setTokenStatus(false, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_MIN_ERROR_SUFFIX"), TOKEN);
- }
- }
-
- else if (e.widget == rangeMaxValue)
- {
- boolean isValid = node.setMax(rangeMaxValue.getText());
-
- if (node.getMin() == RegexNode.EMPTY)
- {
- setTokenStatus(false, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_MISSING_MIN_ERROR_SUFFIX"), TOKEN);
- }
- else if (isValid)
- {
- setTokenStatus(true, null, TOKEN);
- }
- else
- {
- setTokenStatus(false, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_MAX_ERROR_SUFFIX"), TOKEN);
- }
- }
-
- else // (e.widget == repeatValue)
- {
- boolean isValid = node.setRepeat(repeatValue.getText());
- if (isValid)
- {
- setTokenStatus(true, null, TOKEN);
- }
- else
- {
- setTokenStatus(false, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_REPEAT_ERROR_SUFFIX"), TOKEN);
- }
- }
- }
- }
-
- /* Listener for the auto-escape checkbox. */
- class CheckboxListener implements SelectionListener
- {
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- boolean newStatus = !autoEscapeStatus;
- node.setAutoEscapeStatus(newStatus);
- autoEscapeStatus = newStatus;
-
- if (debug)
- {
- System.out.println("AutoEscape Status: " + node.getAutoEscapeStatus());
- }
- }
-
- }
-
-
- /* Listener for the radio buttons. */
- class RadioSelectListener implements SelectionListener
- {
- public void widgetDefaultSelected(SelectionEvent e)
- {
- }
-
- public void widgetSelected(SelectionEvent e)
- {
- if (debug)
- {
- System.out.println(getAllFieldValues());
- }
-
-
- int currentQuantifier = getQuantifier(e);
-
- node.setQuantifier(currentQuantifier);
-
- switch (currentQuantifier)
- {
- case RegexNode.SINGLE:
- case RegexNode.STAR:
- case RegexNode.PLUS:
- case RegexNode.OPTIONAL:
- setEnabledStatus(RegexNode.REPEAT, false);
- setEnabledStatus(RegexNode.RANGE, false);
- setTokenStatus(true, TOKEN);
- break;
-
- case RegexNode.REPEAT:
- setEnabledStatus(RegexNode.REPEAT, true);
- setTokenStatus(node.hasValidRepeat(), XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_REPEAT_ERROR_SUFFIX"), TOKEN);
- repeatValue.setFocus();
- break;
-
- case RegexNode.RANGE:
- setEnabledStatus(RegexNode.RANGE, true);
- String error = (node.hasValidMin()) ?
- XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_MAX_ERROR_SUFFIX") :
- XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_INVALID_MIN_ERROR_SUFFIX");
-
- setTokenStatus( node.hasValidMin() && node.hasValidMax(), error, TOKEN);
- rangeMinValue.setFocus();
- break;
- }
- }
-
- private int getQuantifier(SelectionEvent e)
- {
-
- if (e.widget == singleRadio)
- {
- return RegexNode.SINGLE;
- }
-
- else if (e.widget == starRadio)
- {
- return RegexNode.STAR;
- }
-
- else if (e.widget == plusRadio)
- {
- return RegexNode.PLUS;
- }
-
- else if (e.widget == optionalRadio)
- {
- return RegexNode.OPTIONAL;
- }
-
- else if (e.widget == repeatRadio)
- {
- return RegexNode.REPEAT;
- }
-
- else if (e.widget == rangeRadio)
- {
- return RegexNode.RANGE;
- }
-
- else // can't get here
- {
- return RegexNode.EMPTY;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexNode.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexNode.java
deleted file mode 100644
index 2844709541..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexNode.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.wizards;
-
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-
-
-class RegexNode
-{
- private String contents;
- private int min;
- private int max;
- private int repeat;
- private int quantifier;
- private boolean hasParens;
- private boolean autoEscapeStatus;
-
-
- /* Quantifiers. */
- public static final int SINGLE = 0;
- public static final int STAR = 1;
- public static final int PLUS = 2;
- public static final int OPTIONAL = 3;
- public static final int REPEAT = 4;
- public static final int RANGE = 5;
-
- /* Regex quantifiers. First column is the on-screen textual representation, second column is the
- on-screen regex representation. The two are concatenated together to form the on-screen
- representation.
- Indexing of this array must correspond to the values of the quantifier constants above.
- */
- private static final String[][] regexQuantifiers =
- {
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_QUANTIFIER_SINGLE"), "" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_QUANTIFIER_STAR"), "*" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_QUANTIFIER_PLUS"), "+" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_QUANTIFIER_OPTIONAL"), "?" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_QUANTIFIER_REPEAT"), "" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_QUANTIFIER_RANGE"), "" },
- };
-
-
- /* Regex tokens. First column is the on-screen representation, second column is the regex representation.
- More tokens can be added, but it is assumed that "Current Selection" is the last element in the array.
- If this is not the case, then the value of the SELECTION constant below will need to be changed
- accordingly.
- Also note that because these are java Strings, backslashes must be escaped (this is only relevant to the
- second column of the array).
- */
- private static final String[][] regexTerms =
- {
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_ANY_CHAR"), "." },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_ALPHANUMERIC_CHAR"), "\\w" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_WHITESPACE"), "\\s" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_DIGIT"), "\\d" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_UPPER"), "[A-Z]" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_LOWER"), "[a-z]" },
- { XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TERM_SELECTION"), "" },
- };
-
- /* Token enumerated constants. */
-
- // SELECTION must correspond to the index in regexTerms of "Current Selection". This is assumed to be
- // the last element.
- public static final int SELECTION = regexTerms.length - 1;
-
- public static final int EMPTY = -1;
-
- /*
- The metacharacters recognized by XML Schema.
- Note that the double backslash ("\\") actually represents an escaped single backslash character ("\").
- */
- private static final String metacharacters = ".\\?*+{}()[]";
-
-
- public static String getRegexTermText(int i)
- {
- if (i == SELECTION)
- {
- return regexTerms[i][0];
- }
- else
- {
- return regexTerms[i][0] + " ( " + regexTerms[i][1] + " )";
- }
- }
-
- public static String getRegexTermValue(int i)
- {
- if (i == SELECTION) // shouldn't happen
- {
- return "";
- }
- else
- {
- return regexTerms[i][1];
- }
- }
-
- public static int getNumRegexTerms()
- {
- return regexTerms.length;
- }
-
- public static String getQuantifierText(int i)
- {
- String result = regexQuantifiers[i][0];
-
- if (!regexQuantifiers[i][1].equals(""))
- {
- result += " ( ";
- result += regexQuantifiers[i][1];
- result += " )";
- }
-
- return result;
- }
-
- public RegexNode()
- {
- this.contents = "";
- this.quantifier = SINGLE;
- this.min = EMPTY;
- this.max = EMPTY;
- this.repeat = EMPTY;
- this.hasParens = false;
-
- }
-
-
- public String getContents()
- {
- return contents;
- }
-
- public void setContents(String contents)
- {
- this.contents = contents;
- }
-
-
- public int getQuantifier()
- {
- return quantifier;
- }
-
- public void setQuantifier(int quantifier)
- {
- this.quantifier = quantifier;
- }
-
-
- public int getMin()
- {
- return min;
- }
-
- public void setMin(int min)
- {
- this.min = min;
- }
-
- /**
- * Sets this.min to the integer representation of min iff min is a valid value (i.e. greater than 0).
- * Sets this.min to EMPTY if it is not.
- *
- * @param min The new min value
- * @returns Whether min was a valid value
- */
- public boolean setMin(String min)
- {
- this.min = convertToInt(min);
-
- // min > max is an invalid case, unless max is EMPTY (since EMPTY == -1).
- if ( (this.max != EMPTY) && (this.min > this.max) )
- {
- return false;
- }
-
- return (this.min >= 0);
- }
-
-
- public int getMax()
- {
- return max;
- }
-
- public void setMax(int max)
- {
- this.max = max;
- }
-
- /**
- * Sets this.max to the integer representation of max iff max is a valid value (i.e. greater than 0).
- * Sets this.max to EMPTY if it is not.
- *
- * @param max The new max value
- * @returns Whether max was a valid value, or (whether max == the empty string && min has a valid value)
- */
- public boolean setMax(String max)
- {
- this.max = convertToInt(max);
-
- // The empty string is a valid max value iff min has a valid value.
- // This is due to the fact that {n,} means "at least n times" in regex parlance.
- if (max.equals("") && this.min != EMPTY)
- {
- return true;
- }
-
- else if (this.max < this.min)
- {
- return false;
- }
-
- else
- {
- return (this.max >= 0);
- }
- }
-
-
-
- public int getRepeat()
- {
- return repeat;
- }
-
- public void setRepeat(int repeat)
- {
- this.repeat = repeat;
- }
-
- /**
- * Sets this.repeat to the integer representation of repeat iff repeat is a valid value (i.e. greater than 0).
- * Sets this.repeat to EMPTY if it is not.
- *
- * @param repeat The new repeat value
- * @returns Whether repeat was a valid value
- */
- public boolean setRepeat(String repeat)
- {
- this.repeat = convertToInt(repeat);
- return (this.repeat >= 0);
- }
-
-
-
- /**
- * Returns the integer representation of s. If s is less than zero, or if s is not an int
- * (i.e. if Integer.parseInt would throw a NumberFormatException), then returns EMPTY.
- *
- * @param s The String to convert.
- * @returns The integer representation of s.
- */
- private int convertToInt(String s)
- {
- int result;
- try
- {
- result = Integer.parseInt(s);
- if (result < 0)
- {
- result = EMPTY;
- }
- }
- catch (NumberFormatException e)
- {
- result = EMPTY;
- }
-
- return result;
- }
-
-
- public boolean getHasParens()
- {
- return hasParens;
- }
-
- public void setHasParens(boolean status)
- {
- this.hasParens = status;
- }
-
- public boolean getAutoEscapeStatus()
- {
- return autoEscapeStatus;
- }
-
- public void setAutoEscapeStatus(boolean status)
- {
- this.autoEscapeStatus = status;
- }
-
- /**
- * Returns an escaped version of s. In other words, each occurrence of a metacharacter ( .\?*+{}()[] )
- * is replaced by that character preceded by a backslash.
- *
- * @param s The String to escape.
- * @returns An escaped version of s.
- */
- private String addEscapeCharacters(String s)
- {
- StringBuffer result = new StringBuffer("");
-
- for (int i = 0; i < s.length(); i++)
- {
- char currentChar = s.charAt(i);
-
- if (isMetachar(currentChar))
- {
- result.append("\\"); // Note that this is an escaped backslash, not a double backslash.
- }
- result.append(currentChar);
-
- }
-
- return result.toString();
- }
-
- /**
- * Checks whether c is a metacharacter as defined in the static variable metacharacters.
- *
- * @param c The character to check.
- * @returns Whether c is a metacharacter.
- */
- private boolean isMetachar(char c)
- {
- return metacharacters.indexOf(c) != -1;
- }
-
-
- public boolean hasValidMin()
- {
- return (min != EMPTY);
- }
-
- public boolean hasValidMax()
- {
- return(max != EMPTY);
- }
-
- public boolean hasValidRepeat()
- {
- return(repeat != EMPTY);
- }
-
- public String toString()
- {
- String result = "";
-
- if (hasParens)
- {
- result += "(";
- }
-
- if (autoEscapeStatus)
- {
- result += addEscapeCharacters(contents);
- }
- else
- {
- result += contents;
- }
-
-
- if (hasParens)
- {
- result += ")";
- }
-
- switch (quantifier)
- {
- case STAR:
- result += "*";
- break;
-
- case PLUS:
- result += "+";
- break;
-
- case OPTIONAL:
- result += "?";
- break;
-
- case REPEAT:
- result += "{" + repeat + "}";
- break;
-
- case RANGE:
- result += "{" + min + ",";
- if (max == EMPTY)
- {
- result += "";
- }
- else
- {
- result += max;
- }
- result += "}";
- break;
-
- // SINGLE is a fall through
-
- }
- return result;
-
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexTestingPage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexTestingPage.java
deleted file mode 100644
index 9abe27199a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexTestingPage.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// Based on version 1.6 of original xsdeditor
-package org.eclipse.wst.xsd.ui.internal.wizards;
-
-import java.util.regex.Pattern;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorContextIds;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-
-
-public class RegexTestingPage extends WizardPage
-{
- /* Validator from xerces package. */
-// private RegularExpression validator;
-
- /* Displays the status of the match. */
- private Label matchLabel;
-
-
- /* The regex. */
- private Text value;
-
- /* The string the user is trying to match against the regex. */
- private StyledText testString;
-
- public RegexTestingPage()
- {
- super(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TESTING_PAGE_TITLE"));
-
- setTitle(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TESTING_PAGE_TITLE"));
- setDescription(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TESTING_PAGE_DESCRIPTION"));
- }
-
-
- public void createControl(Composite parent)
- {
- Composite composite = ViewUtility.createComposite(parent, 1);
- WorkbenchHelp.setHelp(composite, XSDEditorContextIds.XSDR_TEST_PAGE);
-
- matchLabel = new Label(composite, SWT.WRAP);
- matchLabel.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TESTING_PAGE_DESCRIPTION"));
- FontData[] fontData = matchLabel.getFont().getFontData();
- GridData dataF = new GridData();
- dataF.widthHint = 400;
- dataF.heightHint = 6 * fontData[0].getHeight();
- matchLabel.setLayoutData(dataF);
-
- Composite controls = new Composite(composite, SWT.NONE);
- GridLayout controlsLayout = new GridLayout();
- controlsLayout.numColumns = 2;
- controls.setLayout(controlsLayout);
- controls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- new Label(controls, SWT.LEFT).setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_REGEX_LABEL"));
- value = new Text(controls, SWT.BORDER | SWT.READ_ONLY);
- value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-
- new Label(controls, SWT.LEFT).setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_SAMPLE_TEXT"));
- testString = new StyledText(controls, SWT.SINGLE | SWT.BORDER);
- WorkbenchHelp.setHelp(testString, XSDEditorContextIds.XSDR_TEST_SAMPLE);
- testString.addListener(SWT.Modify, new TestStringListener());
- testString.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- controls.pack();
-
- Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- GC gc = new GC(separator);
- Point pointSize = gc.stringExtent(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TESTING_PAGE_DESCRIPTION"));
- GridData gd = new GridData();
- gd.widthHint = (int)(pointSize.x / 2 + gc.getAdvanceWidth('M')*11);
- gd.horizontalAlignment= GridData.FILL;
- separator.setLayoutData(gd);
-
- composite.pack();
-
- setControl(composite);
- }
-
-
- private String getPatternValue()
- {
- return ( (RegexCompositionPage)getPreviousPage() ).getPattern().getLexicalValue();
- }
-
- private String getFlags()
- {
- return ( (RegexCompositionPage)getPreviousPage() ).getFlags();
- }
-
- public void setVisible(boolean visible)
- {
- super.setVisible(visible);
-
- String pattern = getPatternValue();
- getFlags();
-
- value.setText(pattern);
-
- updateMatchStatus();
-
- testString.setFocus();
- }
-
- class TestStringListener implements Listener
- {
- public void handleEvent(Event e)
- {
- updateMatchStatus();
- }
- }
-
- private void updateMatchStatus()
- {
- if (Pattern.matches(getPatternValue(), testString.getText()))
- {
-// matchLabel.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_MATCHES"));
- setMessage(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_MATCHES"), 1);
- }
- else
- {
- setMessage(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_DOES_NOT_MATCH"), 2);
-// matchLabel.setText(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_DOES_NOT_MATCH"));
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexWizard.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexWizard.java
deleted file mode 100644
index 95da3f76c6..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/RegexWizard.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.wizards;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.xsd.XSDPatternFacet;
-import org.eclipse.xsd.impl.XSDFactoryImpl;
-
-
-public class RegexWizard extends Wizard
-{
- private RegexCompositionPage compositionPage;
- private RegexTestingPage testingPage;
-
- /* The original, unchanged pattern. */
- private XSDPatternFacet originalPattern;
-
- /* A copy of the original pattern that is passed into the wizard. */
- private XSDPatternFacet modifiedPattern;
-
- String pattern;
-
- public RegexWizard(String expr)
- {
- super();
- setWindowTitle(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TITLE"));
- setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/regx_wiz.gif"));
-
- XSDFactoryImpl factory = new XSDFactoryImpl();
- modifiedPattern = factory.createXSDPatternFacet();
- modifiedPattern.setLexicalValue(expr);
-
- originalPattern = factory.createXSDPatternFacet();
- originalPattern.setLexicalValue(expr);
-
- compositionPage = new RegexCompositionPage(modifiedPattern);
- addPage(compositionPage);
-
- testingPage = new RegexTestingPage();
- addPage(testingPage);
- }
-
- public String getPattern()
- {
- return pattern;
- }
-
- public boolean performFinish()
- {
- pattern = modifiedPattern.getLexicalValue();
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDLocationChoicePage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDLocationChoicePage.java
deleted file mode 100644
index 204ff2df3c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDLocationChoicePage.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.wizards;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-
-
-public class XSDLocationChoicePage extends WizardPage
-{
- protected Button radioButton1;
- protected Button radioButton2;
-
- public XSDLocationChoicePage()
- {
- super("XSDLocationChoicePage");
-
- this.setTitle(XSDEditorPlugin.getXSDString("_UI_WIZARD_INCLUDE_FILE_TITLE"));
- this.setDescription(XSDEditorPlugin.getXSDString("_UI_WIZARD_INCLUDE_FILE_DESC"));
- }
-
- public boolean isPageComplete()
- {
- return true;
- }
-
- public void createControl(Composite parent)
- {
- Composite base = new Composite(parent, SWT.NONE);
- base.setLayout(new GridLayout());
-
- ViewUtility.createLabel(base, XSDEditorPlugin.getXSDString("_UI_LABEL_INCLUDE_URL_FILE"));
- Composite radioButtonsGroup = ViewUtility.createComposite(base, 1, true);
-
- radioButton1 = ViewUtility.createRadioButton(radioButtonsGroup,
- XSDEditorPlugin.getXSDString("_UI_RADIO_FILE"));
-
- radioButton2 = ViewUtility.createRadioButton(radioButtonsGroup,
- XSDEditorPlugin.getXSDString("_UI_RADIO_URL"));
-
- radioButton1.setSelection(true);
-
- setControl(base);
- }
-
- // actions on finish
- public boolean performFinish()
- {
- return true;
- }
-
- public boolean isURL()
- {
- return radioButton2.getSelection();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDNewFilePage.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDNewFilePage.java
deleted file mode 100644
index db12cd6606..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDNewFilePage.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.wizards;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-
-
-public class XSDNewFilePage extends WizardNewFileCreationPage
-{
- public XSDNewFilePage(IStructuredSelection selection)
- {
- super(XSDEditorPlugin.getXSDString("_UI_CREATEXSD"), selection);
- setTitle(XSDEditorPlugin.getXSDString("_UI_NEW_XML_SCHEMA_TITLE"));
- setDescription(XSDEditorPlugin.getXSDString("_UI_CREATE_A_NEW_XML_SCHEMA_DESC"));
- }
-
- public void createControl(Composite parent)
- {
- // inherit default container and name specification widgets
- super.createControl(parent);
-
- this.setFileName(computeDefaultFileName());
-
- setPageComplete(validatePage());
- }
-
- protected boolean validatePage()
- {
- Path newName = new Path(getFileName());
- String fullFileName = getFileName();
- String extension = newName.getFileExtension();
- if (extension == null || !extension.equalsIgnoreCase("xsd"))
- {
- setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_FILENAME_MUST_END_XSD"));
- return false;
- }
- else
- {
- setErrorMessage(null);
- }
-
- // check for file should be case insensitive
- String sameName = existsFileAnyCase(fullFileName);
- if (sameName != null)
- {
- setErrorMessage(XSDEditorPlugin.getPlugin().getString("_ERROR_FILE_ALREADY_EXISTS", sameName)); //$NON-NLS-1$
- return false;
- }
-
- return super.validatePage();
- }
-
- public String defaultName = "NewXMLSchema"; //$NON-NLS-1$
- public String defaultFileExtension = ".xsd"; //$NON-NLS-1$
- public String[] filterExtensions = { "*.xsd"}; //$NON-NLS-1$
-
- protected String computeDefaultFileName()
- {
- int count = 0;
- String fileName = defaultName + defaultFileExtension;
- IPath containerFullPath = getContainerFullPath();
- if (containerFullPath != null)
- {
- while (true)
- {
- IPath path = containerFullPath.append(fileName);
- if (ResourcesPlugin.getWorkspace().getRoot().exists(path))
- {
- count++;
- fileName = defaultName + count + defaultFileExtension;
- }
- else
- {
- break;
- }
- }
- }
- return fileName;
- }
-
- // returns true if file of specified name exists in any case for selected container
- protected String existsFileAnyCase(String fileName)
- {
- if ( (getContainerFullPath() != null) && (getContainerFullPath().isEmpty() == false)
- && (fileName.compareTo("") != 0))
- {
- //look through all resources at the specified container - compare in upper case
- IResource parent = ResourcesPlugin.getWorkspace().getRoot().findMember(getContainerFullPath());
- if (parent instanceof IContainer)
- {
- IContainer container = (IContainer) parent;
- try
- {
- IResource[] members = container.members();
- String enteredFileUpper = fileName.toUpperCase();
- for (int i=0; i<members.length; i++)
- {
- String resourceUpperName = members[i].getName().toUpperCase();
- if (resourceUpperName.equals(enteredFileUpper))
- {
- return members[i].getName();
- }
- }
- }
- catch (CoreException e)
- {
- }
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDSelectIncludeFileWizard.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDSelectIncludeFileWizard.java
deleted file mode 100644
index 16e2ac78e3..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/XSDSelectIncludeFileWizard.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.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.wizards;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.ui.internal.viewers.SelectSingleFilePage;
-import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.util.ViewUtility;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDParser;
-
-
-/**
- * Extend the base wizard to select a file from the project or outside the workbench
- * and add error handling
- */
-public class XSDSelectIncludeFileWizard extends Wizard implements INewWizard
-{
- boolean isInclude;
- XSDSchema mainSchema;
- XSDSchema externalSchema;
-
- XSDLocationChoicePage choicePage;
- XSDSelectSingleFilePage filePage;
- XSDURLPage urlPage;
-
- IFile resultFile;
- String resultURL;
- String namespace = "";
-
- public XSDSelectIncludeFileWizard(XSDSchema mainSchema, boolean isInclude,
- String title, String desc,
- ViewerFilter filter,
- IStructuredSelection selection)
- {
- super();
- setWindowTitle(title);
- setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/NewXSD.gif"));
-
- setNeedsProgressMonitor(true);
-
- // Choice Page
- choicePage = new XSDLocationChoicePage();
-
- // Select File Page
- filePage = new XSDSelectSingleFilePage(PlatformUI.getWorkbench(), selection, true);
- filePage.setTitle(title);
- filePage.setDescription(desc);
- filePage.addFilter(filter);
-
- // URL Page
- urlPage = new XSDURLPage();
- urlPage.setTitle(title);
- urlPage.setDescription(XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_URL"));
-
- this.mainSchema = mainSchema;
- this.isInclude = isInclude;
- }
-
- public void init(IWorkbench aWorkbench, IStructuredSelection aSelection)
- {
- }
-
- public void addPages()
- {
- addPage(choicePage);
- addPage(filePage);
- addPage(urlPage);
- }
-
- public IWizardPage getNextPage(IWizardPage currentPage)
- {
- WizardPage nextPage = null;
-
- if (currentPage == choicePage)
- {
- if (choicePage.isURL())
- {
- nextPage = urlPage;
- }
- else
- {
- nextPage = filePage;
- }
- }
- return nextPage;
- }
-
- public boolean canFinish()
- {
- if (!choicePage.isURL())
- {
- return filePage.isPageComplete();
- }
- return true;
- }
-
- public boolean performFinish()
- {
- if (choicePage.isURL())
- {
- try
- {
- getContainer().run(false, true, urlPage.getRunnable());
- resultURL = urlPage.getURL();
- }
- catch (Exception e)
- {
- return false;
- }
- return true;
- }
- else
- {
- resultFile = filePage.getFile();
- }
- return true;
- }
-
- /**
- * Get the MOF object that represents the external file
- */
- public XSDSchema getExternalSchema()
- {
- return externalSchema;
- }
-
- public IFile getResultFile()
- {
- return resultFile;
- }
-
- public String getURL()
- {
- return resultURL;
- }
-
- public String getNamespace()
- {
- return namespace;
- }
-
- /**
- * Create a MOF model for the imported file
- */
- protected String doLoadExternalModel(IProgressMonitor monitor, String xsdModelFile, String xsdFileName)
- {
- String errorMessage = null;
- String currentNameSpace = mainSchema.getTargetNamespace();
-
- monitor.beginTask("Loading XML Schema", 100);
- monitor.worked(50);
-
- XSDParser parser = new XSDParser();
- parser.parse(xsdModelFile);
-
- externalSchema = parser.getSchema();
- if (externalSchema != null)
- {
- String extNamespace = externalSchema.getTargetNamespace();
- namespace = extNamespace;
-
- if (externalSchema.getDiagnostics() != null &&
- externalSchema.getDiagnostics().size() > 0)
- {
- errorMessage = XSDEditorPlugin.getPlugin().getString("_UI_INCORRECT_XML_SCHEMA", xsdFileName);
- }
- else
- {
- if (isInclude)
- {
- // Check the namespace to make sure they are the same as current file
- if (extNamespace != null)
- {
- if (currentNameSpace != null && !extNamespace.equals(currentNameSpace))
- {
- errorMessage = XSDEditorPlugin.getPlugin().getString("_UI_DIFFERENT_NAME_SPACE", xsdFileName);
- }
- }
- }
- 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.getPlugin().getString("_UI_SAME_NAME_SPACE", xsdFileName);
- }
- }
- }
- }
- }
- else
- {
- errorMessage = XSDEditorPlugin.getPlugin().getString("_UI_INCORRECT_XML_SCHEMA", xsdFileName);
- }
-
- monitor.subTask("Finish Loading");
- monitor.worked(80);
-
- return errorMessage;
- }
-
-
- /**
- * URL page
- */
- class XSDURLPage extends WizardPage
- {
- Text urlField;
- String saveString;
-
- public XSDURLPage()
- {
- super("URLPage");
- }
-
- public void createControl(Composite parent)
- {
- Composite client = ViewUtility.createComposite(parent,2);
- ViewUtility.setComposite(client);
-
- ViewUtility.createLabel(client, XSDEditorPlugin.getXSDString("_UI_LABEL_URL"));
- ViewUtility.createLabel(client, "");
-
- urlField = ViewUtility.createTextField(client, 50);
- saveString = "http://";
- urlField.setText(saveString);
-
- setControl(client);
- }
-
- public String getURL()
- {
- return urlField.getText();
- }
-
- private boolean openExternalSchema(IProgressMonitor monitor)
- {
- String text = urlField.getText();
-// if (text.equals(saveString))
-// {
-// return false;
-// }
-// saveString = text;
-
- if (text.equals(""))
- {
- setErrorMessage(XSDEditorPlugin.getXSDString("_UI_SPECIFY_URL"));
- return false;
- }
-
- if ( !text.startsWith("http://") )
- {
- setErrorMessage(XSDEditorPlugin.getXSDString("_UI_URL_START_WITH"));
- return false;
- }
-
- setErrorMessage(null);
- String errorMessage = doLoadExternalModel(monitor, text, text);
- if (errorMessage != null)
- {
- setErrorMessage(errorMessage);
- return false;
- }
- else
- {
- return true;
- }
- }
-
- public IRunnableWithProgress getRunnable()
- {
- return new IRunnableWithProgress()
- {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException
- {
- if (monitor == null)
- {
- monitor= new NullProgressMonitor();
- }
- monitor.beginTask("", 6);
-
- boolean ok = openExternalSchema(monitor);
-
- if (!ok)
- {
- throw new InvocationTargetException(new java.lang.Error());
- }
-
- monitor.done();
- }
- };
- }
- }
-
- /**
- * Select XML Schema File
- */
- class XSDSelectSingleFilePage extends SelectSingleFilePage
- {
- public XSDSelectSingleFilePage(IWorkbench workbench, IStructuredSelection selection, boolean isFileMandatory)
- {
- super(workbench,selection,isFileMandatory);
- }
-
- private boolean openExternalSchema()
- {
- // Get the fully-qualified file name
- IFile iFile = getFile();
- if (iFile == null)
- return false;
-
- setErrorMessage(null);
-
- String xsdModelFile = iFile.getLocation().toOSString();
- String xsdFileName = iFile.getName();
- String errorMessage = doLoadExternalModel(new NullProgressMonitor(), xsdModelFile, xsdFileName);
-
- if (errorMessage != null)
- {
- setErrorMessage(errorMessage);
- return false;
- }
- else
- {
- return true;
- }
- }
-
- public boolean isPageComplete()
- {
- if (choicePage.isURL())
- {
- return true;
- }
-
- if (super.isPageComplete())
- {
- return openExternalSchema();
- }
- return super.isPageComplete();
- }
- }
-}

Back to the top