Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties')
-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
89 files changed, 0 insertions, 22649 deletions
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;
-}
-}

Back to the top