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-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/BuiltInTypesTreeViewerProvider.java221
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewComponentDialog.java196
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementButtonHandler.java26
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementDialog.java92
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeButtonHandler.java26
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeDialog.java209
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/SelectBuiltInTypesForFilteringDialog.java108
7 files changed, 0 insertions, 878 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/BuiltInTypesTreeViewerProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/BuiltInTypesTreeViewerProvider.java
deleted file mode 100644
index f0cecbb770..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/BuiltInTypesTreeViewerProvider.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Trung de Irene <trungha@ca.ibm.com>
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-import org.eclipse.xsd.util.XSDConstants;
-
-
-/**
- * This class provides the content for SelectBuiltInTypesForFilterDialog
- * readability Warning: Some simple tricks to tweak efficiency are used
- */
-public class BuiltInTypesTreeViewerProvider {
-
- ILabelProvider labelProvider;
-
- ITreeContentProvider contentProvider;
-
-// private static final String CONST_PARENT = "parent";
-
- /**
- * Currently there are 3 subgroups: Numbers, Data and Time, Other
- * Folks can choose to expand to more subgroups
- */
- private static int BUILT_IN_TYPES_SUB_GROUP = 3;
-
- static String[] numberTypes =
- { "base64Binary", "byte", "decimal", "double", "float", "hexBinary",
- "int", "integer", "long", "negativeInteger", "nonNegativeInteger",
- "nonPositiveInteger", "positiveInteger", "short", "unsignedByte",
- "unsignedInt", "unsignedLong", "unsignedShort"};
-
- static String[] dateAndTimeTypes =
- { "date", "dateTime", "duration", "gDay",
- "gMonth", "gMonthDay", "gYear", "gYearMonth", "time"};
-
-
- public static List getAllBuiltInTypes() {
- List items = new ArrayList();
- //for (int i = 0; i < XSDDOMHelper.dataType.length; i++) {
- // items.add(XSDDOMHelper.dataType[i][0]);
- //}
- Iterator it = items.iterator();
-
- List mainContainer = new ArrayList(BUILT_IN_TYPES_SUB_GROUP);
- ComponentSpecification header = new ComponentSpecification("", "Root", null);
- mainContainer.add(header);
-
- List numbersGroup = new ArrayList();
- header = new ComponentSpecification("", "Numbers", null);
- numbersGroup.add(header);
- mainContainer.add(numbersGroup);
-
- List dateAndTimeGroup = new ArrayList();
- header = new ComponentSpecification("", "Date and Time", null);
- dateAndTimeGroup.add(header);
- mainContainer.add(dateAndTimeGroup);
-
- List otherGroup = new ArrayList();
- header = new ComponentSpecification("", "Other", null);
- otherGroup.add(header);
- mainContainer.add(otherGroup);
-
- while (it.hasNext()) {
- Object item = it.next();
- String name = item.toString();
-
- ComponentSpecification builtInTypeItem = new ComponentSpecification(name, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, null);
-
- // if this built-In Type is in Number group
- if ( partOf(name, numberTypes) ){
- // Set parent
- //builtInTypeItem.addAttributeInfo(CONST_PARENT, numbersGroup);
-
- numbersGroup.add(builtInTypeItem);
- }
- // if this built-In Type is in Date-and-Time group
- else if ( partOf(name, dateAndTimeTypes)){
- //builtInTypeItem.addAttributeInfo(CONST_PARENT, dateAndTimeGroup);
- dateAndTimeGroup.add(builtInTypeItem);
- }
- // otherwise, put in Other group
- else {
- //builtInTypeItem.addAttributeInfo(CONST_PARENT, otherGroup);
- otherGroup.add(builtInTypeItem);
- }
- }
-
- return mainContainer;
- }
-
- public ILabelProvider getLabelProvider(){
- if (labelProvider != null)
- return labelProvider;
-
- labelProvider = new BuiltInTypeLabelProvider();
- return labelProvider;
- }
-
- public ITreeContentProvider getContentProvider() {
- if (contentProvider != null)
- return contentProvider;
-
- contentProvider = new BuiltInTypesTreeContentProvider();
- return contentProvider;
- }
-
- /**
- * Determines whether an equivalent of 'item' appears in 'array'
- * @param item
- * @param array
- * @return
- */
- private static boolean partOf(String item, String[] array){
- for(int i = 0; i < array.length; i++ ){
- if ( item.equals(array[i]) ){
- return true;
- }
- }
- return false;
- }
-
- class BuiltInTypeLabelProvider implements ILabelProvider{
- public Image getImage(Object element) {
- if ( getText(element).equals("Numbers") )
- return XSDEditorPlugin.getXSDImage("icons/XSDNumberTypes.gif");
- if ( getText(element).equals("Date and Time") )
- return XSDEditorPlugin.getXSDImage("icons/XSDDateAndTimeTypes.gif");
- if ( getText(element).equals("Other") )
- return XSDEditorPlugin.getXSDImage("icons/browsebutton.gif");
- if ( element instanceof ComponentSpecification ){
- return XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif");
- }
- return null;
- }
-
- public String getText(Object element) {
- ComponentSpecification spec = null;
-
- /* if not non-leaf node, the first element has the name for
- * the whole list */
- if (element instanceof List){
- spec = (ComponentSpecification) ((List) element).get(0);
- }
- else if (element instanceof ComponentSpecification ){
- spec = (ComponentSpecification) element;
- }
- return spec.getName();
- }
-
- public void addListener(ILabelProviderListener listener) {
-
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
-
- }
-
- }
-
-
- class BuiltInTypesTreeContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof List) {
- List parentContent = (List) parentElement;
-
- /** Ignore the first element (which contains the name of this list
- * ie. 'Numbers', 'Date and time', 'Other') */
- return parentContent.subList(1, parentContent.size()).toArray();
- }
- return new Object[0];
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (getChildren(element).length > 1) {
- return true;
- }
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewComponentDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewComponentDialog.java
deleted file mode 100644
index aa0c49e02e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewComponentDialog.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xsd.ui.internal.editor.Messages;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds;
-
-public class NewComponentDialog extends Dialog implements ModifyListener
-{
- protected Text nameField;
- protected Button okButton;
- protected String name;
- protected String title;
- protected Label errorMessageLabel;
- protected List usedNames;
-
- public NewComponentDialog(Shell parentShell, String title, String defaultName)
- {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- name = defaultName;
- this.title = title;
- }
-
- public NewComponentDialog(Shell parentShell, String title, String defaultName, List usedNames)
- {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- name = defaultName;
- this.title = title;
- this.usedNames = usedNames;
- }
-
- public int createAndOpen()
- {
- create();
- getShell().setText(title);
- setBlockOnOpen(true);
- return open();
- }
-
- protected Control createContents(Composite parent)
- {
- Control control = super.createContents(parent);
- nameField.forceFocus();
- nameField.selectAll();
- updateErrorMessage();
- return control;
- }
-
-
- protected void createButtonsForButtonBar(Composite parent)
- {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected void createHeaderContent(Composite parent)
- {
- }
-
- protected void createExtendedContent(Composite parent)
- {
- }
-
- protected Control createDialogArea(Composite parent)
- {
- Composite dialogArea = (Composite)super.createDialogArea(parent);
-
- createHeaderContent(dialogArea);
-
- Composite composite = new Composite(dialogArea, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- composite.setLayout(layout);
-
- GridData gdFill= new GridData();
- gdFill.horizontalAlignment= GridData.FILL;
- gdFill.grabExcessHorizontalSpace= true;
- gdFill.verticalAlignment= GridData.FILL;
- gdFill.grabExcessVerticalSpace= true;
- composite.setLayoutData(gdFill);
-
- Label nameLabel = new Label(composite, SWT.NONE);
- nameLabel.setText(Messages.UI_LABEL_NAME);
-
- nameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridData gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.grabExcessHorizontalSpace= true;
- gd.widthHint = 200;
- nameField.setLayoutData(gd);
- nameField.setText(name);
- nameField.addModifyListener(this);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(nameField, XSDEditorCSHelpIds.NEWTYPE_NAME);
-
- createExtendedContent(dialogArea);
-
- // error message
- errorMessageLabel = new Label(dialogArea, SWT.NONE);
- errorMessageLabel.setText("error message goes here");
- GridData gd2 = new GridData();
- gd2.horizontalAlignment= GridData.FILL;
- gd2.grabExcessHorizontalSpace= true;
- gd2.widthHint = 200;
- errorMessageLabel.setLayoutData(gd2);
-// Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
-// errorMessageLabel.setForeground(color);
-
- return dialogArea;
- }
-
- public void modifyText(ModifyEvent e)
- {
- updateErrorMessage();
- }
-
- protected String computeErrorMessage(String name)
- {
- if (usedNames == null)
- return null;
-
- Iterator iterator = usedNames.iterator();
- while (iterator.hasNext()) {
- if (name.equalsIgnoreCase((String) iterator.next())) {
- return org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ERROR_NAME_ALREADY_USED; //$NON-NLS-1$
- }
- }
-
- return null;
- }
-
- protected void updateErrorMessage()
- {
- String errorMessage = null;
- String name = nameField.getText().trim();
- if (name.length() > 0)
- {
- errorMessage = computeErrorMessage(name);
- }
- else
- {
- errorMessage = ""; //$NON-NLS-1$
- }
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- okButton.setEnabled(errorMessage == null);
- }
-
- protected void buttonPressed(int buttonId)
- {
- if (buttonId == IDialogConstants.OK_ID)
- {
- name = nameField.getText();
- }
- super.buttonPressed(buttonId);
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setUsedNames(List usedNames) {
- this.usedNames = usedNames;
- }
-
- public void setDefaultName(String name) {
- this.name = name;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementButtonHandler.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementButtonHandler.java
deleted file mode 100644
index 9c83571743..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementButtonHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import org.eclipse.wst.common.ui.internal.search.dialogs.INewComponentHandler;
-
-public class NewElementButtonHandler implements INewComponentHandler
-{
- public NewElementButtonHandler()
- {
- }
-
- public void openNewComponentDialog()
- {
- NewElementDialog newElementDialog = new NewElementDialog();
- newElementDialog.createAndOpen();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementDialog.java
deleted file mode 100644
index 2a0619b52b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewElementDialog.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog;
-import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils;
-import org.eclipse.wst.xsd.ui.internal.editor.Messages;
-import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-
-public class NewElementDialog extends NewComponentDialog implements IComponentDialog
-{
- protected XSDSchema schema;
- protected Object setObject;
- protected int typeKind;
- protected Object selection;
-
- public NewElementDialog()
- {
- super(Display.getCurrent().getActiveShell(), Messages._UI_LABEL_NEW_ELEMENT, "NewElement"); //$NON-NLS-1$
- }
-
- public NewElementDialog(XSDSchema schema)
- {
- super(Display.getCurrent().getActiveShell(), Messages._UI_LABEL_NEW_ELEMENT, "NewElement"); //$NON-NLS-1$
- this.schema = schema;
- }
-
- private void setup() {
- if (schema != null) {
- List usedNames = getUsedElementNames();
- setUsedNames(usedNames);
- setDefaultName(XSDCommonUIUtils.createUniqueElementName("NewElement", schema.getElementDeclarations()));
- }
- }
-
- public int createAndOpen()
- {
- setup();
- int returnCode = super.createAndOpen();
- if (returnCode == 0)
- {
- if (setObject instanceof Adapter)
- {
- //Command command = new AddComplexTypeDefinitionCommand(getName(), schema);
- }
- }
- return returnCode;
- }
-
- public ComponentSpecification getSelectedComponent()
- {
- ComponentSpecification componentSpecification = new ComponentSpecification(null, getName(), null);
- componentSpecification.setMetaName(IXSDSearchConstants.ELEMENT_META_NAME);
- componentSpecification.setNew(true);
- return componentSpecification;
- }
-
- public void setInitialSelection(ComponentSpecification componentSpecification)
- {
- // TODO Auto-generated method stub
- }
-
- private List getUsedElementNames() {
- List usedNames = new ArrayList();
- if (schema != null ) {
- List elementsList = schema.getElementDeclarations();
- Iterator elements = elementsList.iterator();
- while (elements.hasNext()) {
- usedNames.add(((XSDElementDeclaration) elements.next()).getName());
- }
- }
-
- return usedNames;
- }
- }
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeButtonHandler.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeButtonHandler.java
deleted file mode 100644
index e815a88b8d..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeButtonHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import org.eclipse.wst.common.ui.internal.search.dialogs.INewComponentHandler;
-
-public class NewTypeButtonHandler implements INewComponentHandler
-{
- public NewTypeButtonHandler()
- {
- }
-
- public void openNewComponentDialog()
- {
- NewTypeDialog newTypeDialog = new NewTypeDialog();
- newTypeDialog.createAndOpen();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeDialog.java
deleted file mode 100644
index e4aaf041ce..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeDialog.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog;
-import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils;
-import org.eclipse.wst.xsd.ui.internal.editor.Messages;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds;
-import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-
-public class NewTypeDialog extends NewComponentDialog implements IComponentDialog
-{
- protected XSDSchema schema;
- protected static int SIMPLE_TYPE = 0;
- protected static int COMPLEX_TYPE = 1;
- protected Object setObject;
- protected int typeKind;
- protected Object selection;
- protected boolean allowComplexType = true;
- protected boolean allowAnonymousType = true;
- protected boolean anonymousType = false;
- private Button complexTypeButton;
- private Button simpleTypeButton;
- private Button anonymousTypeCheckBox;
-
- public NewTypeDialog()
- {
- super(Display.getCurrent().getActiveShell(), Messages._UI_LABEL_NEW_TYPE, "NewType"); //$NON-NLS-1$
- }
-
- public NewTypeDialog(XSDSchema schema)
- {
- super(Display.getCurrent().getActiveShell(), Messages._UI_LABEL_NEW_TYPE, "NewType"); //$NON-NLS-1$
- this.schema = schema;
- }
-
- private void setup() {
- if (schema != null) {
- List usedNames = getUsedTypeNames();
- setUsedNames(usedNames);
- setDefaultName(XSDCommonUIUtils.createUniqueElementName("NewType", schema.getTypeDefinitions()));
- }
- }
-
- public int createAndOpen()
- {
- setup();
- int returnCode = super.createAndOpen();
- if (returnCode == 0)
- {
- if (setObject instanceof Adapter)
- {
- //Command command = new AddComplexTypeDefinitionCommand(getName(), schema);
- }
- }
- return returnCode;
- }
-
- public ComponentSpecification getSelectedComponent()
- {
- ComponentSpecification componentSpecification;
- if ( anonymousType )
- componentSpecification = new ComponentSpecification(null, null, null);
- else
- componentSpecification = new ComponentSpecification(null, getName(), null);
- componentSpecification.setMetaName(typeKind == COMPLEX_TYPE ? IXSDSearchConstants.COMPLEX_TYPE_META_NAME : IXSDSearchConstants.SIMPLE_TYPE_META_NAME);
- componentSpecification.setNew(true);
- //componentSpecification.
- return componentSpecification;
- }
-
- public void setInitialSelection(ComponentSpecification componentSpecification)
- {
- // TODO Auto-generated method stub
- }
-
- protected void createHeaderContent(Composite parent)
- {
- complexTypeButton = new Button(parent, SWT.RADIO);
- complexTypeButton.setText(Messages._UI_LABEL_COMPLEX_TYPE);
- complexTypeButton.setEnabled(allowComplexType);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(complexTypeButton, XSDEditorCSHelpIds.NEWTYPE_COMPLEXTYPE);
-
- simpleTypeButton = new Button(parent, SWT.RADIO);
- simpleTypeButton.setText(Messages._UI_LABEL_SIMPLE_TYPE);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(simpleTypeButton, XSDEditorCSHelpIds.NEWTYPE_SIMPLETYPE);
-
- SelectionAdapter listener = new SelectionAdapter()
- {
- public void widgetSelected(SelectionEvent e)
- {
- if (e.widget == simpleTypeButton)
- {
- typeKind = SIMPLE_TYPE;
- }
- else if (e.widget == complexTypeButton)
- {
- typeKind = COMPLEX_TYPE;
- }
- else if (allowAnonymousType && e.widget == anonymousTypeCheckBox)
- {
- if (anonymousTypeCheckBox.getSelection() == true)
- {
- nameField.setEnabled(false);
- anonymousType = true;
- }
- else
- {
- nameField.setEnabled(true);
- anonymousType = false;
- }
- }
- }
- };
- if (allowComplexType)
- {
- complexTypeButton.setSelection(true);
- typeKind = COMPLEX_TYPE;
- }
- else
- {
- simpleTypeButton.setSelection(true);
- typeKind = SIMPLE_TYPE;
- }
-
- simpleTypeButton.addSelectionListener(listener);
- complexTypeButton.addSelectionListener(listener);
-
- Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
- GridData gd = new GridData(GridData.FILL_BOTH);
- separator.setLayoutData(gd);
-
- if (allowAnonymousType )
- {
- anonymousTypeCheckBox = new Button(parent, SWT.CHECK);
- anonymousTypeCheckBox.setText(Messages._UI_LABEL_CREATE_ANON_TYPE);
- }
-
- if (anonymousTypeCheckBox != null)
- anonymousTypeCheckBox.addSelectionListener(listener);
- }
-
- // TODO: Can we remove this?
- protected String getNormalizedLocation(String location)
- {
- try
- {
- URL url = new URL(location);
- URL resolvedURL = FileLocator.resolve(url);
- location = resolvedURL.getPath();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return location;
- }
-
- public void allowComplexType(boolean value)
- {
- this.allowComplexType= value;
- }
-
- public void allowAnonymousType(boolean value)
- {
- this.allowAnonymousType = value;
- }
-
- private List getUsedTypeNames() {
- List usedNames = new ArrayList();
-
- if (schema != null) {
- List typesList = schema.getTypeDefinitions();
- Iterator types = typesList.iterator();
- while (types.hasNext()) {
- usedNames.add(((XSDTypeDefinition) types.next()).getName());
- }
- }
-
- return usedNames;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/SelectBuiltInTypesForFilteringDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/SelectBuiltInTypesForFilteringDialog.java
deleted file mode 100644
index a437d6cdab..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/SelectBuiltInTypesForFilteringDialog.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Trung de Irene <trungha@ca.ibm.com>
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification;
-import org.eclipse.wst.xsd.ui.internal.editor.Messages;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-
-/**
- * The BuiltInTypesFilteringDialog is a SelectionDialog that allows the user to
- * select a ...
- */
-public class SelectBuiltInTypesForFilteringDialog extends CheckedTreeSelectionDialog {
-
- public final static String CUSTOM_LIST_SEPARATOR = XSDEditorPlugin.CUSTOM_LIST_SEPARATOR;
-
- public SelectBuiltInTypesForFilteringDialog(Shell parent,
- ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
- super(parent, labelProvider, contentProvider);
-
- init();
- }
-
- public CheckboxTreeViewer getTreeViewer(){
- return super.getTreeViewer();
- }
-
- private void init(){
- // grey state enable
- setContainerMode(true);
-
- setTitle(Messages._UI_LABEL_SET_COMMON_BUILT_IN_TYPES);
- setMessage(Messages._UI_LABEL_SELECT_TYPES_FILTER_OUT);
-
- //super.create();
- //super.getTreeViewer().setSorter(new ViewerSorter());
-
- }
-
- /**
- * Returns a String acting as list of built-in types selected by the user
- * in the filter dialog (white space acts as the item separator).
- * Suggest using getSelectedBuiltInTypesFromString
- * to get a concrete array of selected types.
- * We can only store String in the plugin preference's storage so we have
- * use this method for conversion
- */
- public static String getTypesListInString(Object[] chosenTypes) {
- String returningList = ""; //$NON-NLS-1$
- for (int i = 0; i < chosenTypes.length; i++){
- if ( chosenTypes[i] instanceof ComponentSpecification){
- ComponentSpecification aType =
- (ComponentSpecification) chosenTypes[i];
-
- returningList += aType.getName() + CUSTOM_LIST_SEPARATOR;
- }
- /* else selectedBuiltInTypes[i] instanceof List, ie. a parentNode
- * we ignore it. */
- }
- return returningList;
- }
-
- /**
- * Filters out all built-In type not recorded in the 'listString' and
- * returns the result in a List
- * Warning: recursive method
- * @param listString
- * @param aContainer
- * Containing all types
- * @return a subset of what 'aContainer' has as specified by 'listString'
- */
- public static List getSelectedBuiltInTypesFromString(String listString,
- List aContainer) {
- List selectedTypes = new ArrayList();
-
- // ignore the 'header' item in the container, starting from i = 1
- for (int i = 1; i < aContainer.size(); i++){
- Object o = aContainer.get(i);
- if ( o instanceof ComponentSpecification){
- ComponentSpecification aType = (ComponentSpecification) o;
- String typeName = aType.getName();
- // if typeName's name appears in 'listString'
- if ( listString.indexOf(typeName + CUSTOM_LIST_SEPARATOR) != -1)
- selectedTypes.add(o);
- }
- else if ( o instanceof List){
- selectedTypes.addAll( getSelectedBuiltInTypesFromString(listString, (List) o) );
- }
- }
- return selectedTypes;
- }
-}

Back to the top