Skip to main content
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/IOpenInNewEditor.java16
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewAttributeDialog.java93
-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.java212
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/SelectBuiltInTypesForFilteringDialog.java108
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDEditSchemaNS.java44
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java416
11 files changed, 0 insertions, 1450 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/IOpenInNewEditor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/IOpenInNewEditor.java
deleted file mode 100644
index 5e2c520e61..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/IOpenInNewEditor.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-public interface IOpenInNewEditor
-{
- public void openXSDEditor();
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewAttributeDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewAttributeDialog.java
deleted file mode 100644
index 5602942882..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewAttributeDialog.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDSchema;
-
-public class NewAttributeDialog extends NewComponentDialog implements IComponentDialog
-{
- protected XSDSchema schema;
- protected Object setObject;
- protected int typeKind;
- protected Object selection;
-
- public NewAttributeDialog()
- {
- super(Display.getCurrent().getActiveShell(), Messages._UI_LABEL_NEW_ATTRIBUTE, "NewAttribute"); //$NON-NLS-1$
- }
-
- public NewAttributeDialog(XSDSchema schema)
- {
- super(Display.getCurrent().getActiveShell(), Messages._UI_LABEL_NEW_ATTRIBUTE, "NewAttribute"); //$NON-NLS-1$
- this.schema = schema;
- }
-
- private void setup() {
- if (schema != null) {
- List usedNames = getUsedElementNames();
- setUsedNames(usedNames);
- setDefaultName(XSDCommonUIUtils.createUniqueElementName("NewAttribute", schema.getAttributeDeclarations()));
- }
- }
-
- 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.ATTRIBUTE_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.getAttributeDeclarations();
- Iterator elements = elementsList.iterator();
- while (elements.hasNext()) {
- usedNames.add(((XSDAttributeDeclaration) elements.next()).getName());
- }
- }
-
- return usedNames;
- }
-
-}
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 45fec61d50..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/NewTypeDialog.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-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(name, 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);
- }
-
- /**
- * This method will be removed in the next WTP release.
- * @deprecated
- */
- 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;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDEditSchemaNS.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDEditSchemaNS.java
deleted file mode 100644
index 43e520d2a1..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDEditSchemaNS.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditSchemaInfoDialog;
-import org.eclipse.wst.xml.ui.internal.nsedit.CommonEditNamespacesDialog;
-
-public class XSDEditSchemaNS extends EditSchemaInfoDialog
-{
- CommonEditNamespacesDialog editNamespacesControl;
-
- public XSDEditSchemaNS(Shell parentShell, IPath resourceLocation)
- {
- super(parentShell, resourceLocation);
- }
-
- protected Control createDialogArea(Composite parent)
- {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- editNamespacesControl = new CommonEditNamespacesDialog(composite, resourceLocation, XMLUIMessages._UI_NAMESPACE_DECLARATIONS);
-
- editNamespacesControl.setNamespaceInfoList(namespaceInfoList);
- editNamespacesControl.updateErrorMessage(namespaceInfoList);
-
- return composite;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java
deleted file mode 100644
index 33adbdeff4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/dialogs/XSDGraphViewerDialog.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.dialogs;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.draw2d.ColorConstants;
-import org.eclipse.gef.EditPartFactory;
-import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.PopupDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory;
-import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart;
-import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootEditPart;
-import org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.figures.TypeVizFigureFactory;
-import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor;
-import org.eclipse.wst.xsd.ui.internal.common.util.Messages;
-import org.eclipse.wst.xsd.ui.internal.design.editparts.XSDEditPartFactory;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDSchema;
-
-public class XSDGraphViewerDialog extends PopupDialog
-{
- protected Object model;
- protected ScrollingGraphicalViewer viewer;
- protected IOpenInNewEditor openInNewEditorHelper;
- private OpenEditorLinkListener linkListener;
- private Label nsInfoLabel;
- private Hyperlink link;
- private String infoText;
- private Font infoFont;
- private String uniqueID;
- private PreviewControlListener moveListener;
-
- private static String X_ORIGIN = "DIALOG_X_ORIGIN"; //$NON-NLS-1$
- private static String Y_ORIGIN = "DIALOG_Y_ORIGIN"; //$NON-NLS-1$
- private boolean isHighContrast = false;
-
- public XSDGraphViewerDialog(Shell parentShell, String titleText, String infoText, Object model, String ID)
- {
- // INFOPOPUP_SHELLSTYLE works properly on both Windows and Linux.
- super(parentShell, INFOPOPUP_SHELLSTYLE, true, true, true, true, false, titleText, infoText);
- setModel(model);
- linkListener = new OpenEditorLinkListener();
- this.infoText = infoText;
- this.uniqueID = ID;
- Assert.isTrue(ID != null && ID.length() > 0);
- moveListener = new PreviewControlListener();
- try
- {
- isHighContrast = Display.getDefault().getHighContrast();
- }
- catch (Exception e) {
- // ignore
- }
- create();
- }
-
- public void setOpenExternalEditor(IOpenInNewEditor helper)
- {
- this.openInNewEditorHelper = helper;
- }
-
- protected void fillDialogMenu(IMenuManager dialogMenu)
- {
- super.fillDialogMenu(dialogMenu);
- dialogMenu.add(new Separator());
- dialogMenu.add(new ClosePopup());
- dialogMenu.add(new Separator());
- dialogMenu.add(new SetOpenInEditor());
- }
-
- protected Control createDialogArea(Composite parent)
- {
- viewer = new ScrollingGraphicalViewer();
- Composite c = (Composite)super.createDialogArea(parent);
-
- if (isHighContrast)
- {
- c.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- }
- else
- {
- c.setBackground(ColorConstants.white);
- }
- c.setLayout(new FillLayout());
-
- RootEditPart root = new RootEditPart();
- viewer.setRootEditPart(root);
-
- viewer.createControl(c);
-
- // The graphical viewer tool tip processing creates an extra shell which
- // interferes with the PopupDialog's deactivation logic.
- removeMouseListeners(viewer.getControl());
-
- if (isHighContrast)
- {
- viewer.getControl().setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- }
- else
- {
- viewer.getControl().setBackground(ColorConstants.white);
- }
- EditPartFactory editPartFactory = new XSDEditPartFactory(new TypeVizFigureFactory());
- viewer.setEditPartFactory(editPartFactory);
-
- RootContentEditPart rootContentEditPart = new RootContentEditPart();
- rootContentEditPart.setModel(model);
- viewer.setContents(rootContentEditPart);
-
- getShell().addControlListener(moveListener);
- return c;
- }
-
- private void removeMouseListeners(Control control)
- {
- Listener[] listeners = control.getListeners(SWT.MouseEnter);
- control.removeListener(SWT.MouseEnter, listeners[0]);
-
- listeners = control.getListeners(SWT.MouseExit);
- control.removeListener(SWT.MouseExit, listeners[0]);
-
- listeners = control.getListeners(SWT.MouseHover);
- control.removeListener(SWT.MouseHover, listeners[0]);
-
- listeners = control.getListeners(SWT.MouseMove);
- control.removeListener(SWT.MouseMove, listeners[0]);
-
- listeners = control.getListeners(SWT.MouseDown);
- control.removeListener(SWT.MouseDown, listeners[0]);
-
- listeners = control.getListeners(SWT.MouseUp);
- control.removeListener(SWT.MouseUp, listeners[0]);
-
- listeners = control.getListeners(SWT.MouseDoubleClick);
- control.removeListener(SWT.MouseDoubleClick, listeners[0]);
- }
-
- protected Control createInfoTextArea(Composite parent)
- {
- Composite infoComposite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(2, false);
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- infoComposite.setLayout(gridLayout);
- GridData gd = new GridData(GridData.FILL_BOTH);
- infoComposite.setLayoutData(gd);
-
- nsInfoLabel = new Label(infoComposite, SWT.LEFT);
- nsInfoLabel.setText(infoText);
-
- Font font = nsInfoLabel.getFont();
- FontData[] fontDatas = font.getFontData();
- for (int i = 0; i < fontDatas.length; i++)
- {
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
- }
- infoFont = new Font(nsInfoLabel.getDisplay(), fontDatas);
- nsInfoLabel.setFont(infoFont);
- gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- nsInfoLabel.setLayoutData(gd);
- nsInfoLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
-
- link = new Hyperlink(infoComposite, SWT.RIGHT);
- // Remove mnemonic ampersand. It would be better to have a separate string in the future.
- String label = Messages._UI_ACTION_OPEN_IN_NEW_EDITOR.replaceAll("&", "");
- link.setText(label);
- link.setFont(infoFont);
- link.addHyperlinkListener(linkListener);
- return infoComposite;
- }
-
- private void setModel(Object model)
- {
- Assert.isTrue(model instanceof XSDConcreteComponent);
- this.model = XSDAdapterFactory.getInstance().adapt((XSDConcreteComponent) model);
- }
-
- protected class SetOpenInEditor extends Action
- {
- public SetOpenInEditor()
- {
- super(Messages._UI_ACTION_OPEN_IN_NEW_EDITOR);
- }
-
- public void run()
- {
- if (openInNewEditorHelper != null)
- {
- try
- {
- openInNewEditorHelper.openXSDEditor();
- }
- catch (Exception e)
- {
-
- }
- }
- }
- }
-
- private class ClosePopup extends Action {
- public ClosePopup()
- {
- super(Messages._UI_ACTION_CLOSE_SCHEMA_PREVIEW_POPUP);
- }
-
- public void run()
- {
- close();
- }
- }
-
- protected IDialogSettings getDialogSettings()
- {
- IDialogSettings settings= XSDEditorPlugin.getDefault().getDialogSettings().getSection(uniqueID);
- if (settings == null)
- settings= XSDEditorPlugin.getDefault().getDialogSettings().addNewSection(uniqueID);
-
- return settings;
- }
-
- protected Point getInitialLocation(Point initialSize)
- {
- Point result = super.getInitialLocation(initialSize);
-
- IDialogSettings settings = getDialogSettings();
- if (settings != null)
- {
- try
- {
-
- String prefix = uniqueID == null ? getClass().getName() : uniqueID;
- int x = settings.getInt(prefix + X_ORIGIN);
- int y = settings.getInt(prefix + Y_ORIGIN);
- result = new Point(x, y);
- Shell parent = getParentShell();
- if (parent != null)
- {
- Point parentLocation = parent.getLocation();
- result.x += parentLocation.x;
- result.y += parentLocation.y;
- }
- }
- catch (NumberFormatException e)
- {
- }
- }
- return result;
- }
-
- protected void saveDialogBounds(Shell shell)
- {
- IDialogSettings settings = getDialogSettings();
- if (settings != null)
- {
- Point shellLocation = shell.getLocation();
- Shell parent = getParentShell();
- if (parent != null)
- {
- Point parentLocation = parent.getLocation();
- shellLocation.x -= parentLocation.x;
- shellLocation.y -= parentLocation.y;
- }
- String prefix = uniqueID == null ? getClass().getName() : uniqueID;
- settings.put(prefix + X_ORIGIN, shellLocation.x);
- settings.put(prefix + Y_ORIGIN, shellLocation.y);
- }
- }
-
-
- public boolean close()
- {
- if (getShell() == null || getShell().isDisposed())
- {
- return true;
- }
-
- getShell().removeControlListener(moveListener);
- if (link != null)
- link.removeHyperlinkListener(linkListener);
- if (infoFont != null)
- infoFont.dispose();
- infoFont = null;
- return super.close();
- }
-
- private final class OpenEditorLinkListener implements IHyperlinkListener
- {
-
- public void linkActivated(HyperlinkEvent e)
- {
- new SetOpenInEditor().run();
- close();
- }
-
- public void linkEntered(HyperlinkEvent e)
- {
- link.setForeground(ColorConstants.lightBlue);
- }
-
- public void linkExited(HyperlinkEvent e)
- {
- link.setForeground(link.getParent().getForeground());
- }
-
- }
-
- protected class PreviewControlListener implements ControlListener
- {
-
- public void controlMoved(ControlEvent e)
- {
- saveDialogBounds(getShell());
- }
-
- public void controlResized(ControlEvent e)
- {
- }
- }
-
- /**
- * @deprecated since 1.2.101
- * @param xsdComponent
- * @param schema
- * @param editorName
- */
- public static void openNonXSDResourceSchema(XSDConcreteComponent xsdComponent, XSDSchema schema, String editorName)
- {
- openInlineSchema(getCurrentEditorInput(), xsdComponent, schema, editorName);
- }
-
- public static void openInlineSchema(IEditorInput editorInput, XSDConcreteComponent xsdComponent, XSDSchema schema, String editorName)
- {
- OpenInNewEditor.openInlineSchema(editorInput, xsdComponent, schema, editorName);
- }
-
- /**
- * @deprecated
- */
- public static void openXSDEditor(XSDConcreteComponent xsdComponent)
- {
- openXSDEditor(getCurrentEditorInput(), xsdComponent.getSchema(), xsdComponent);
- }
-
- public static void openXSDEditor(IEditorInput editorInput, XSDSchema schema, XSDConcreteComponent xsdComponent)
- {
- OpenInNewEditor.openXSDEditor(editorInput, schema, xsdComponent);
- }
-
- private static IEditorInput getCurrentEditorInput()
- {
- try
- {
- IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = null;
- if (workbenchWindow != null)
- {
- page = workbenchWindow.getActivePage();
- if (page != null)
- {
- IEditorPart editorPart = page.getActiveEditor();
- if (editorPart != null)
- {
- return editorPart.getEditorInput();
- }
- }
- }
- }
- catch (Exception e)
- {
-
- }
- return null;
- }
-
- protected Control getFocusControl()
- {
- return link;
- }
-}

Back to the top