diff options
author | nitind | 2011-12-07 18:50:12 +0000 |
---|---|---|
committer | nitind | 2011-12-07 18:50:12 +0000 |
commit | 92657ae25d54d2d8f3318aadfb4591b5bad0a1b0 (patch) | |
tree | 9f079da25506a9fb2170b884079e18910bcb2346 /bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters | |
parent | 5dc4a3721c537f53c492964027eb5fdd3618a960 (diff) | |
download | webtools.sourceediting-201112071853.tar.gz webtools.sourceediting-201112071853.tar.xz webtools.sourceediting-201112071853.zip |
This commit was manufactured by cvs2svn to create tag 'v201112071853'.v201112071853
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters')
26 files changed, 0 insertions, 5661 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/CategoryAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/CategoryAdapter.java deleted file mode 100644 index cd995eeeae..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/CategoryAdapter.java +++ /dev/null @@ -1,175 +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.adapters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IModelProxy; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeDeclarationAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeGroupDefinitionAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDComplexTypeDefinitionAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDSchemaDirectiveAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDModelGroupDefinitionAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDSimpleTypeDefinitionAction; -import org.eclipse.xsd.XSDSchema; - -public class CategoryAdapter extends XSDBaseAdapter implements IModelProxy, IActionProvider, IADTObjectListener -{ - protected String text; - protected Image image; - protected Object parent; - protected int groupType; - protected Collection children, allChildren; // children from current schema, children from current schema and includes - XSDSchema xsdSchema; - - public CategoryAdapter(String label, Image image, Collection children, XSDSchema xsdSchema, int groupType) - { - this.text = label; - this.image = image; - this.parent = xsdSchema; - this.xsdSchema = xsdSchema; - this.target = xsdSchema; - this.children = children; - this.groupType = groupType; - } - - public final static int ATTRIBUTES = 1; - public final static int ELEMENTS = 2; - public final static int TYPES = 3; - public final static int GROUPS = 5; - public final static int DIRECTIVES = 6; - public final static int NOTATIONS = 7; - public final static int ATTRIBUTE_GROUPS = 8; - public final static int IDENTITY_CONSTRAINTS = 9; - public final static int ANNOTATIONS = 10; - - public XSDSchema getXSDSchema() - { - return xsdSchema; - } - - public int getGroupType() - { - return groupType; - } - - public Image getImage() - { - return image; - } - - public String getText() - { - return text; - } - - public ITreeElement[] getChildren() - { - return (ITreeElement[]) children.toArray(new ITreeElement[0]); - } - - public ITreeElement[] getAllChildren() - { - return (ITreeElement[]) allChildren.toArray(new ITreeElement[0]); - } - - public void setChildren(Collection list) - { - children = list; - } - - public void setAllChildren(Collection list) - { - allChildren = list; - } - - public Object getParent(Object element) - { - return xsdSchema; - } - - public boolean hasChildren(Object element) - { - return true; - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - - } - - public String[] getActions(Object object) - { - Collection actionIDs = new ArrayList(); - - switch (groupType) - { - case TYPES : { - actionIDs.add(AddXSDComplexTypeDefinitionAction.ID); - actionIDs.add(AddXSDSimpleTypeDefinitionAction.ID); - break; - } - case ELEMENTS : { - actionIDs.add(AddXSDElementAction.ID); - break; - } - case GROUPS : { - actionIDs.add(AddXSDModelGroupDefinitionAction.MODELGROUPDEFINITION_ID); - break; - } - case ATTRIBUTES : { - actionIDs.add(AddXSDAttributeDeclarationAction.ID); - actionIDs.add(AddXSDAttributeGroupDefinitionAction.ID); - break; - } - case ATTRIBUTE_GROUPS : { - actionIDs.add(AddXSDAttributeGroupDefinitionAction.ID); - break; - } - case DIRECTIVES : { - actionIDs.add(AddXSDSchemaDirectiveAction.INCLUDE_ID); - actionIDs.add(AddXSDSchemaDirectiveAction.IMPORT_ID); - actionIDs.add(AddXSDSchemaDirectiveAction.REDEFINE_ID); - break; - } - } - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(ShowPropertiesViewAction.ID); - return (String [])actionIDs.toArray(new String[0]); - } - - public void propertyChanged(Object object, String property) - { - if (getText().equals(property)) - notifyListeners(this, property); - } - - public List getTypes() - { - return null; - } - - public IModel getModel() - { - return (IModel)XSDAdapterFactory.getInstance().adapt(xsdSchema); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/RedefineCategoryAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/RedefineCategoryAdapter.java deleted file mode 100644 index 83e8c924ba..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/RedefineCategoryAdapter.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.adapters; - - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDRedefinedAttributeGroupAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDRedefinedComplexTypeAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDRedefinedModelGroupAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDRedefinedSimpleTypeAction; -import org.eclipse.xsd.XSDRedefine; - - -public class RedefineCategoryAdapter extends CategoryAdapter -{ - protected XSDRedefine xsdRedefine; - private XSDRedefineAdapter xsdRedefineAdapter; - - public RedefineCategoryAdapter(String label, Image image, Collection children, XSDRedefine xsdRedefine, XSDRedefineAdapter xsdRedefineAdapter, int groupType) - { - super(label, image, children, xsdRedefine.getSchema(), groupType); - this.xsdRedefine = xsdRedefine; - this.target = xsdRedefine; - this.xsdRedefineAdapter = xsdRedefineAdapter; - } - - public XSDRedefine getXSDRedefine() - { - return xsdRedefine; - } - - public String[] getActions(Object object) - { - Collection actionIDs = new ArrayList(); - - switch (groupType) - { - case TYPES: - { - actionIDs.add(AddXSDRedefinedComplexTypeAction.ID); - actionIDs.add(AddXSDRedefinedSimpleTypeAction.ID); - break; - } - case GROUPS: - { - actionIDs.add(AddXSDRedefinedModelGroupAction.ID); - break; - } - case ATTRIBUTES: - case ATTRIBUTE_GROUPS: - { - actionIDs.add(AddXSDRedefinedAttributeGroupAction.ID); - break; - } - } - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(ShowPropertiesViewAction.ID); - return (String[])actionIDs.toArray(new String [0]); - } - - public IModel getModel() - { - return (IModel)XSDAdapterFactory.getInstance().adapt(xsdRedefine.getSchema()); - } - - - public XSDRedefineAdapter getXsdRedefineAdapter() { - return xsdRedefineAdapter; - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAdapterFactory.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAdapterFactory.java deleted file mode 100644 index a05ce01b12..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAdapterFactory.java +++ /dev/null @@ -1,153 +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.adapters; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDEnumerationFacet; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDSwitch; - -public class XSDAdapterFactory extends AdapterFactoryImpl -{ - protected static XSDAdapterFactory instance; - - public static XSDAdapterFactory getInstance() - { - if (instance == null) - { - // first use the one defined by the configuration - instance = XSDEditorPlugin.getPlugin().getXSDEditorConfiguration().getAdapterFactory(); - // if there isn't one, then use the default - if (instance == null) - instance = new XSDAdapterFactory(); - } - return instance; - } - - public Adapter createAdapter(Notifier target) - { - XSDSwitch xsdSwitch = new XSDSwitch() - { - public Object caseXSDSchemaDirective(XSDSchemaDirective object) - { - return new XSDSchemaDirectiveAdapter(); - } - - public Object caseXSDWildcard(XSDWildcard object) - { - return new XSDWildcardAdapter(); - } - - public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object) - { - return new XSDAttributeGroupDefinitionAdapter(); - } - - public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) - { - return new XSDModelGroupDefinitionAdapter(); - } - - public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object) - { - return new XSDAttributeDeclarationAdapter(); - } - - public Object caseXSDAttributeUse(XSDAttributeUse object) - { - return new XSDAttributeUseAdapter(); - } - - public Object caseXSDParticle(XSDParticle object) - { - return new XSDParticleAdapter(); - } - - public Object caseXSDElementDeclaration(XSDElementDeclaration object) - { - return new XSDElementDeclarationAdapter(); - } - - public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) - { - return new XSDSimpleTypeDefinitionAdapter(); - } - - public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object) - { - // we don't like exposing the 'anyType' type as a visible complex type - // so we adapt it in a specialized way so that it's treated as simple type - // that way it doesn't show up as a reference from a field - // - if ("anyType".equals(object.getName())) //$NON-NLS-1$ - { - return new XSDAnyTypeDefinitionAdapter(); - } - else - { - return new XSDComplexTypeDefinitionAdapter(); - } - } - - public Object caseXSDModelGroup(XSDModelGroup object) - { - return new XSDModelGroupAdapter(); - } - - public Object caseXSDSchema(XSDSchema object) - { - return new XSDSchemaAdapter(); - } - - public Object caseXSDEnumerationFacet(XSDEnumerationFacet object) - { - return new XSDEnumerationFacetAdapter(); - } - - public Object caseXSDRedefine(XSDRedefine object) - { - return new XSDRedefineAdapter(); - } - }; - Object o = xsdSwitch.doSwitch((EObject) target); - Adapter result = null; - if (o instanceof Adapter) - { - result = (Adapter) o; - } - else - { -// Thread.dumpStack(); - } - return result; - } - - public Adapter adapt(Notifier target) - { - return adapt(target, this); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAnyTypeDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAnyTypeDefinitionAdapter.java deleted file mode 100644 index 3e8dc51a32..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAnyTypeDefinitionAdapter.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.xsd.XSDConcreteComponent; - -public class XSDAnyTypeDefinitionAdapter extends XSDTypeDefinitionAdapter -{ - public boolean isComplexType() - { - return false; - } - - public boolean isFocusAllowed() - { - return false; - } - - public String[] getActions(Object object) - { - return null; - } - - public boolean isAnonymous() - { - return false; - } - - public IADTObject getTopContainer() - { - return null; - } - - public Command getDeleteCommand() - { - return null; - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(((XSDConcreteComponent)target).getSchema()); - return (IModel)adapter; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeDeclarationAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeDeclarationAdapter.java deleted file mode 100644 index 2ed6b4fb10..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeDeclarationAdapter.java +++ /dev/null @@ -1,111 +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.adapters; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeDeclarationAction; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; - -public class XSDAttributeDeclarationAdapter extends XSDBaseAttributeAdapter implements IActionProvider -{ - protected XSDAttributeDeclaration getXSDAttributeDeclaration() - { - return (XSDAttributeDeclaration)target; - } - - protected XSDAttributeDeclaration getResolvedXSDAttributeDeclaration() - { - return getXSDAttributeDeclaration().getResolvedAttributeDeclaration(); - } - - public boolean isGlobal() - { - return getXSDAttributeDeclaration().eContainer() instanceof XSDSchema; - } - - public boolean isReference() - { - return getXSDAttributeDeclaration().isAttributeDeclarationReference(); - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDAttributeDeclaration().getSchema()); - return (IModel)adapter; - } - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=251008 - public String[] getActions(Object object) - { - if(!isGlobal()) - { - List defaultActions = new ArrayList(); - defaultActions = Arrays.asList(super.getActions(object)); - - ArrayList list = new ArrayList(); - list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_INSERT_ATTRIBUTE); - list.add(AddXSDAttributeDeclarationAction.BEFORE_SELECTED_ID); - list.add(AddXSDAttributeDeclarationAction.AFTER_SELECTED_ID); - list.add(BaseSelectionAction.SUBMENU_END_ID); - - int len = defaultActions.size(); - for(int i = 0; i < len; i++) - { - if (defaultActions.get(i).equals(AddXSDAttributeDeclarationAction.ID)) - { - continue; - } - list.add(defaultActions.get(i)); - } - return (String [])list.toArray(new String[0]); - } - else - { - return super.getActions(object); - } - } - - - public boolean isFocusAllowed() - { - return isGlobal(); - } - - public String getTypeNameQualifier() - { - XSDTypeDefinition type = getResolvedXSDAttributeDeclaration().getTypeDefinition(); - if (type != null) - { - return type.getTargetNamespace(); - } - return ""; - } - - public IADTObject getTopContainer() - { - if (!isGlobal()) - { - return getGlobalXSDContainer(getXSDAttributeDeclaration()); - } - return this; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeGroupDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeGroupDefinitionAdapter.java deleted file mode 100644 index 6ecebef7e5..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeGroupDefinitionAdapter.java +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAnyAttributeAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeDeclarationAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDWildcard; - -public class XSDAttributeGroupDefinitionAdapter extends XSDBaseAdapter implements IStructure, IActionProvider, IGraphElement, IADTObjectListener -{ - public static final Image ATTRIBUTE_GROUP_REF_ICON_IMAGE = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAttributeGroupRef.gif"); - public static final Image ATTRIBUTE_GROUP_REF_DISABLED_ICON_IMAGE = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAttributeGroupRefdis.gif"); - public static final Image ATTRIBUTE_GROUP_ICON_IMAGE = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAttributeGroup.gif"); - public static final Image ATTRIBUTE_GROUP_DISABLED_ICON_IMAGE = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAttributeGroupdis.gif"); - - protected List fields = null; - protected List otherThingsToListenTo = null; - protected boolean readOnly; - protected boolean changeReadOnlyField =false; - protected HashMap deletedTypes = new HashMap(); - - public XSDAttributeGroupDefinitionAdapter() - { - super(); - } - - public XSDAttributeGroupDefinition getXSDAttributeGroupDefinition() - { - return (XSDAttributeGroupDefinition) target; - } - - public Image getImage() - { - XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition) target; - if (xsdAttributeGroupDefinition.isAttributeGroupDefinitionReference()) - { - return isReadOnly() ? ATTRIBUTE_GROUP_REF_DISABLED_ICON_IMAGE : ATTRIBUTE_GROUP_REF_ICON_IMAGE; - } - else - { - return isReadOnly() ? ATTRIBUTE_GROUP_DISABLED_ICON_IMAGE : ATTRIBUTE_GROUP_ICON_IMAGE; - } - } - - public String getText() - { - XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition) target; - String result = xsdAttributeGroupDefinition.isAttributeGroupDefinitionReference() ? xsdAttributeGroupDefinition.getQName() : xsdAttributeGroupDefinition.getName(); - return result == null ? Messages._UI_LABEL_ABSENT : result; - } - - public ITreeElement[] getChildren() - { - XSDAttributeGroupDefinition xsdAttributeGroup = (XSDAttributeGroupDefinition) target; - List list = new ArrayList(); - Iterator iterator = xsdAttributeGroup.getContents().iterator(); - while (iterator.hasNext()) - { - Object o = iterator.next(); - if (o instanceof XSDAttributeUse) - { - list.add(((XSDAttributeUse)o).getAttributeDeclaration()); - } - else - { - list.add(o); - } - } - XSDWildcard wildcard = xsdAttributeGroup.getAttributeWildcardContent(); - if (wildcard != null) - { - list.add(wildcard); - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]); - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - list.add(AddXSDAttributeDeclarationAction.ID); - list.add(AddXSDAnyAttributeAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - Object schema = getEditorSchema(); - XSDAttributeGroupDefinition attributeGroupDefinition = getXSDAttributeGroupDefinition(); - if (attributeGroupDefinition.getSchema() == schema) - { - XSDConcreteComponent container = attributeGroupDefinition.getContainer(); - if (container == schema || container instanceof XSDRedefine) - { - list.add(SetInputToGraphView.ID); - } - } - else - { - list.add(OpenInNewEditor.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - return (String [])list.toArray(new String[0]); - } - - public Command getAddNewFieldCommand(String fieldKind) - { - return null; - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDAttributeGroupDefinition()); - } - - public List getFields() - { - if (fields == null) - { - fields = new ArrayList(); - otherThingsToListenTo = new ArrayList(); - XSDVisitorForFields visitor = new XSDVisitorForFields(); - visitor.visitAttributeGroupDefinition(getXSDAttributeGroupDefinition()); - populateAdapterList(visitor.concreteComponentList, fields); - populateAdapterList(visitor.thingsWeNeedToListenTo, otherThingsToListenTo); - for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext();) - { - Adapter adapter = (Adapter) i.next(); - if (adapter instanceof IADTObject) - { - IADTObject adtObject = (IADTObject) adapter; - adtObject.registerListener(this); - } - } - } - return fields; - } - - protected void clearFields() - { - if (otherThingsToListenTo != null) - { - for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext();) - { - Adapter adapter = (Adapter) i.next(); - if (adapter instanceof IADTObject) - { - IADTObject adtObject = (IADTObject) adapter; - adtObject.unregisterListener(this); - } - } - } - fields = null; - otherThingsToListenTo = null; - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDAttributeGroupDefinition().getSchema()); - return (IModel)adapter; - } - - public String getName() - { - // TODO (cs) ... review this - return getText(); - } - - public boolean isFocusAllowed() - { - XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition) target; - if (xsdAttributeGroupDefinition.isAttributeGroupDefinitionReference()) - { - return false; - } - return true; - } - - public IADTObject getTopContainer() - { - XSDAttributeGroupDefinition attrGroupDef = getXSDAttributeGroupDefinition(); - XSDConcreteComponent container = attrGroupDef.getContainer(); - if (container instanceof XSDSchema || container instanceof XSDRedefine) - return this; - else - return getGlobalXSDContainer(attrGroupDef); - } - - public void notifyChanged(Notification msg) - { - clearFields(); - super.notifyChanged(msg); - } - - public void propertyChanged(Object object, String property) - { - clearFields(); - notifyListeners(this, null); - } - public boolean isReadOnly() - { - XSDAttributeGroupDefinition xsdAttributeGroupDefinition = (XSDAttributeGroupDefinition) target; - if (hasSetReadOnlyField()) - { - deletedTypes.put(xsdAttributeGroupDefinition.getName(), new Boolean(true)); - changeReadOnlyField = false; - return readOnly; - } - else - { - if (deletedTypes!= null ) - { - Boolean deleted = ((Boolean)deletedTypes.get(xsdAttributeGroupDefinition.getName())); - if (deleted != null && deleted.booleanValue()) - { - return true; - } - else - { - return super.isReadOnly(); - } - } - else - { - return super.isReadOnly(); - } - } - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - public boolean hasSetReadOnlyField() { - return changeReadOnlyField; - } - - public void setChangeReadOnlyField(boolean setReadOnlyField) { - this.changeReadOnlyField = setReadOnlyField; - } - - public void updateDeletedMap(String addComponent) { - if (deletedTypes.get(addComponent) != null) - { - deletedTypes.clear(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeUseAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeUseAdapter.java deleted file mode 100644 index 668365c990..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDAttributeUseAdapter.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDTypeDefinition; - -public class XSDAttributeUseAdapter extends XSDBaseAttributeAdapter implements IActionProvider -{ - protected XSDAttributeDeclaration getXSDAttributeDeclaration() - { - return getXSDAttributeUse().getAttributeDeclaration(); - } - - protected XSDAttributeDeclaration getResolvedXSDAttributeDeclaration() - { - return getXSDAttributeDeclaration().getResolvedAttributeDeclaration(); - } - - protected XSDAttributeUse getXSDAttributeUse() - { - return (XSDAttributeUse)target; - } - - public XSDAttributeUseAdapter() - { - super(); - } - - public String getText() - { - return getTextForAttributeUse(getXSDAttributeUse(), true); - } - - public String getTextForAttributeUse(XSDAttributeUse attributeUse, boolean showType) - { - XSDAttributeDeclaration ad = attributeUse.getAttributeDeclaration(); - - StringBuffer result = new StringBuffer(); - result.append(getTextForAttribute(ad, showType)); - /* - if (xsdAttributeUse.isSetConstraint()) - { - if (result.length() != 0) - { - result.append(" "); - } - result.append('<'); - result.append(xsdAttributeUse.getConstraint()); - result.append("=\""); - result.append(xsdAttributeUse.getLexicalValue()); - result.append("\">"); - } - */ - return result.toString(); - } - - public boolean isGlobal() - { - return false; - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDAttributeDeclaration().getSchema()); - return (IModel)adapter; - } - - public String getTypeNameQualifier() - { - XSDTypeDefinition type = getResolvedXSDAttributeDeclaration().getTypeDefinition(); - if (type != null) - { - return type.getTargetNamespace(); - } - return ""; - } - - public IADTObject getTopContainer() - { - return getGlobalXSDContainer(getXSDAttributeUse()); - } - - public boolean isReference() - { - return getXSDAttributeUse().getAttributeDeclaration().isAttributeDeclarationReference(); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDBaseAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDBaseAdapter.java deleted file mode 100644 index 4db258d737..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDBaseAdapter.java +++ /dev/null @@ -1,238 +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.adapters; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xml.core.internal.document.ElementImpl; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.w3c.dom.Element; - -public class XSDBaseAdapter extends AdapterImpl implements IADTObject, ITreeElement -{ - protected List listenerList = new ArrayList(); - - public boolean isAdapterForType(Object type) - { - return type == XSDAdapterFactory.getInstance(); - } - - public void populateAdapterList(List notifierList, List adapterList) - { - for (Iterator i = notifierList.iterator(); i.hasNext(); ) - { - Object obj = i.next(); - if (obj instanceof XSDConcreteComponent) - { - XSDConcreteComponent component = (XSDConcreteComponent)obj; - adapterList.add(XSDAdapterFactory.getInstance().adapt(component)); - } - else - { - adapterList.add(obj); - } - } - } - - public void registerListener(IADTObjectListener listener) - { - if (!listenerList.contains(listener)) - { - listenerList.add(listener); - } - } - - public void unregisterListener(IADTObjectListener listener) - { - listenerList.remove(listener); - } - - public void notifyChanged(Notification msg) - { - super.notifyChanged(msg); - notifyListeners(this, null); - } - - protected void notifyListeners(Object changedObject, String property) - { - List clonedListenerList = new ArrayList(); - clonedListenerList.addAll(listenerList); - for (Iterator i = clonedListenerList.iterator(); i.hasNext(); ) - { - IADTObjectListener listener = (IADTObjectListener)i.next(); - listener.propertyChanged(this, property); - } - } - - public ITreeElement[] getChildren() - { - return null; - } - - public Image getImage() - { - return null; - } - - public String getText() - { - return ""; //$NON-NLS-1$ - } - - public ITreeElement getParent() - { - return null; - } - - public boolean hasChildren() - { - if (getChildren() != null) - { - return getChildren().length > 0; - } - return false; - } - - - /** - * Implements IField getContainerType. Get parent Complex Type containing the field - * @return IComplexType - */ - public IComplexType getContainerType() - { - XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) target; - XSDConcreteComponent parent = null; - XSDComplexTypeDefinition ct = null; - for (parent = xsdConcreteComponent.getContainer(); parent != null; ) - { - if (parent instanceof XSDComplexTypeDefinition) - { - ct = (XSDComplexTypeDefinition)parent; - break; - } - parent = parent.getContainer(); - } - if (ct != null) - { - return (IComplexType)XSDAdapterFactory.getInstance().adapt(ct); - } - return null; - } - - public boolean isReadOnly() - { - XSDSchema xsdSchema = null; - try - { - IEditorPart editorPart = null; - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) - { - IWorkbenchPage page = window.getActivePage(); - if (page != null) - { - editorPart = page.getActiveEditor(); - } - } - if (target instanceof XSDConcreteComponent) - { - xsdSchema = ((XSDConcreteComponent)target).getSchema(); - } - if (editorPart == null) - { - return fallBackCheckIsReadOnly(); - } - - XSDSchema editorSchema = (XSDSchema)editorPart.getAdapter(XSDSchema.class); - if (xsdSchema != null && xsdSchema == editorSchema) - { - return false; - } - else - { - return fallBackCheckIsReadOnly(); - } - } - catch(Exception e) - { - - } - return true; - } - - private boolean fallBackCheckIsReadOnly() - { - Element element = ((XSDConcreteComponent)target).getElement(); - if (element instanceof IDOMNode - || element instanceof ElementImpl) - { - return false; - } - return true; - } - - protected Object getEditorSchema() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - return editorPart.getAdapter(XSDSchema.class); - } - - protected IADTObject getGlobalXSDContainer(XSDConcreteComponent component) - { - XSDConcreteComponent c = component.getContainer(); - // We want the top most structural component - while (c != null && - !(c.getContainer() instanceof XSDSchema) && - !(c instanceof XSDComplexTypeDefinition) && - !(c instanceof XSDSimpleTypeDefinition) && - !(c instanceof XSDModelGroupDefinition) && - !(c instanceof XSDAttributeGroupDefinition)) - { - c = c.getContainer(); - } - Adapter adapter = XSDAdapterFactory.getInstance().adapt(c); - if (adapter instanceof IADTObject) - return (IADTObject)adapter; - return null; - } - - /** - * Indicates the presence of an abstract attribute - * @return true if the component's abstract attribute is true - */ - public boolean isAbstract() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDBaseAttributeAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDBaseAttributeAdapter.java deleted file mode 100644 index 9984076ba4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDBaseAttributeAdapter.java +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeDeclarationAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; - -// a base adapter for reuse by an AttributeUse and AttributeDeclaration -// -public abstract class XSDBaseAttributeAdapter extends XSDBaseAdapter implements IField, IGraphElement -{ - protected abstract XSDAttributeDeclaration getXSDAttributeDeclaration(); - protected abstract XSDAttributeDeclaration getResolvedXSDAttributeDeclaration(); - - public XSDBaseAttributeAdapter() - { - super(); - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - if (!isGlobal()) - { - list.add(AddXSDAttributeDeclarationAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - } - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - Object schema = getEditorSchema(); - if (getXSDAttributeDeclaration().getSchema() == schema) - { - if (getXSDAttributeDeclaration().getContainer() == schema) - { - list.add(SetInputToGraphView.ID); - } - } - else - { - list.add(OpenInNewEditor.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - return (String[]) list.toArray(new String[0]); - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDAttributeDeclaration()); - } - - public String getKind() - { - return XSDConstants.ATTRIBUTE_ELEMENT_TAG; - } - - public int getMaxOccurs() - { - // TODO Auto-generated method stub - return -3; - } - - public int getMinOccurs() - { - // TODO Auto-generated method stub - return -3; - } - - public String getName() - { - XSDAttributeDeclaration resolvedAttributeDeclaration = getResolvedXSDAttributeDeclaration(); - String name = resolvedAttributeDeclaration.getName(); - return (name == null) ? "" : name; //$NON-NLS-1$ - } - - public IType getType() - { - XSDTypeDefinition td = getResolvedXSDAttributeDeclaration().getTypeDefinition(); - return (td != null) ? (IType) XSDAdapterFactory.getInstance().adapt(td) : null; - } - - public String getTypeName() - { - IType type = getType(); - if (type != null) - { - return type.getName(); - } - return ""; - } - - public String getTypeNameQualifier() - { - XSDAttributeDeclaration attr = getResolvedXSDAttributeDeclaration(); - if (attr != null) - { - if (attr.getTypeDefinition() != null) - { - return attr.getTypeDefinition().getTargetNamespace(); - } - } - return null; - } - - public Command getUpdateMaxOccursCommand(int maxOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateMinOccursCommand(int minOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateNameCommand(String name) - { - return new UpdateNameCommand(Messages._UI_ACTION_UPDATE_NAME, getResolvedXSDAttributeDeclaration(), name); - } - - public Command getUpdateTypeNameCommand(String typeName, String quailifier) - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getImage() - */ - public Image getImage() - { - XSDAttributeDeclaration xsdAttributeDeclaration = getXSDAttributeDeclaration(); // don't want the resolved attribute - if (xsdAttributeDeclaration.isAttributeDeclarationReference()) - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAttributeRefdis.gif"); - } - return XSDEditorPlugin.getXSDImage("icons/XSDAttributeRef.gif"); //$NON-NLS-1$ - } - else - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAttributedis.gif"); - } - return XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif"); //$NON-NLS-1$ - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getText() - */ - public String getText() - { - return getTextForAttribute(getResolvedXSDAttributeDeclaration(), true); - } - - public String getTextForAttribute(XSDAttributeDeclaration ad, boolean showType) - { - ad = ad.getResolvedAttributeDeclaration(); - String name = ad.getName(); - StringBuffer result = new StringBuffer(); - if (name == null) - { - result.append(" " + Messages._UI_LABEL_ABSENT + " "); //$NON-NLS-1$ //$NON-NLS-2$ - } - else - { - result.append(name); - } - if (ad.getAnonymousTypeDefinition() == null && ad.getTypeDefinition() != null) - { - result.append(" : "); //$NON-NLS-1$ - // result.append(resolvedAttributeDeclaration.getTypeDefinition().getQName(xsdAttributeDeclaration)); - result.append(ad.getTypeDefinition().getName()); - } - return result.toString(); - } - - public boolean isGlobal() - { - return false; - } - - public boolean isReference() - { - return false; - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDAttributeDeclaration().getSchema()); - return (IModel)adapter; - } - - public boolean isFocusAllowed() - { - return false; - } -} - diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDChildUtility.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDChildUtility.java deleted file mode 100644 index 191110cd66..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDChildUtility.java +++ /dev/null @@ -1,280 +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.adapters; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDSwitch; - - -public class XSDChildUtility -{ - static public List getModelChildren(Object model) - { - XSDChildVisitor visitor = new XSDChildVisitor(model); - visitor.visitXSDObject(model); - return visitor.list; - } - - static public List getImmediateDerivedTypes(XSDComplexTypeDefinition complexType) - { - ArrayList typesDerivedFrom = new ArrayList(); - - // A handy convenience method quickly gets all - // typeDefinitions within our schema; note that - // whether or not this returns types in included, - // imported, or redefined schemas is subject to change - List typedefs = complexType.getSchema().getTypeDefinitions(); - - for (Iterator iter = typedefs.iterator(); iter.hasNext(); ) - { - XSDTypeDefinition typedef = (XSDTypeDefinition)iter.next(); - // Walk the baseTypes from this typedef seeing if any - // of them match the requested one - if (complexType.equals(typedef.getBaseType())) - { - // We found it, return the original one and continue - typesDerivedFrom.add(typedef); - } - } - return typesDerivedFrom; - } - // TODO... use the XSDVisitor defined in xsdeditor.util instead - // - public static class XSDChildVisitor extends XSDVisitor - { - Object root; - List list = new ArrayList(); - - public XSDChildVisitor(Object root) - { - this.root = root; - } - - public void visitXSDModelGroup(XSDModelGroup xsdModelGroup) - { - if (xsdModelGroup != root) - { - list.add(xsdModelGroup); - } - else - { - super.visitXSDModelGroup(xsdModelGroup); - } - } - - public void visitXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) - { - if (xsdModelGroupDefinition != root) - { - list.add(xsdModelGroupDefinition); - } - else - { - super.visitXSDModelGroupDefinition(xsdModelGroupDefinition); - } - } - - public void visitXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration) - { - if (xsdElementDeclaration != root) - { - list.add(xsdElementDeclaration); - - } - else - { - super.visitXSDElementDeclaration(xsdElementDeclaration); - } - } - - public void visitXSDComplexTypeDefinition(XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - if (xsdComplexTypeDefinition != root) - { - if (xsdComplexTypeDefinition.getName() != null || getModelChildren(xsdComplexTypeDefinition).size() > 0) - { - list.add(xsdComplexTypeDefinition); - } - } - else - { - super.visitXSDComplexTypeDefinition(xsdComplexTypeDefinition); - } - } - - public void visitXSDWildcard(XSDWildcard xsdWildCard) - { - if (xsdWildCard != root) - { - list.add(xsdWildCard); - } - else - { - super.visitXSDWildcard(xsdWildCard); - } - } - } - - - public static class XSDVisitor - { - int indent = 0; - - public void visitXSDObject(Object object) - { - if (object == null) - return; - - XSDSwitch theSwitch = new XSDSwitch() - { - public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object) - { - visitXSDComplexTypeDefinition(object); - return null; - } - - public Object caseXSDAttributeUse(XSDAttributeUse object) - { - visitXSDAttributeUse(object); - return null; - } - - public Object caseXSDElementDeclaration(XSDElementDeclaration object) - { - visitXSDElementDeclaration(object); - return null; - } - - public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) - { - visitXSDModelGroupDefinition(object); - return super.caseXSDModelGroupDefinition(object); - } - - public Object caseXSDModelGroup(XSDModelGroup object) - { - visitXSDModelGroup(object); - return super.caseXSDModelGroup(object); - } - - public Object caseXSDParticle(XSDParticle object) - { - visitXSDParticle(object); - return null; - } - - public Object caseXSDSchema(XSDSchema object) - { - visitXSDSchema(object); - return null; - } - - public Object caseXSDWildcard(XSDWildcard object) - { - visitXSDWildcard(object); - return null; - } - }; - theSwitch.doSwitch((EObject)object); - } - - public void visitXSDAttributeUse(XSDAttributeUse xsdAttributeUse) - { -// printIndented("@" + xsdAttributeUse.getAttributeDeclaration().getName()); - } - - public void visitXSDSchema(XSDSchema xsdSchema) - { - indent += 2; - for (Iterator iterator = xsdSchema.getElementDeclarations().iterator(); iterator.hasNext(); ) - { - visitXSDObject(iterator.next()); - } - indent -= 2; - } - - public void visitXSDElementDeclaration(XSDElementDeclaration xsdElementDeclaration) - { - indent += 2; - XSDTypeDefinition td = xsdElementDeclaration.getTypeDefinition(); - if (td == null) - { - td = xsdElementDeclaration.getAnonymousTypeDefinition(); - } - visitXSDObject(td); - indent -= 2; - } - - public void visitXSDComplexTypeDefinition(XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - indent += 2; - for (Iterator i = xsdComplexTypeDefinition.getAttributeUses().iterator(); i.hasNext(); ) - { - visitXSDObject(i.next()); - } - visitXSDObject(xsdComplexTypeDefinition.getContent()); - indent -= 2; - } - - public void visitXSDModelGroup(XSDModelGroup xsdModelGroup) - { - indent += 2; - for (Iterator iterator = xsdModelGroup.getContents().iterator(); iterator.hasNext(); ) - { - visitXSDObject(iterator.next()); - } - indent -= 2; - } - - public void visitXSDModelGroupDefinition(XSDModelGroupDefinition xsdModelGroupDefinition) - { - indent += 2; - visitXSDObject(xsdModelGroupDefinition.getResolvedModelGroupDefinition().getModelGroup()); - indent -= 2; - } - - public void visitXSDParticle(XSDParticle xsdParticle) - { - indent += 2; - if (xsdParticle.getContent() != null) - visitXSDObject(xsdParticle.getContent()); - indent -= 2; - } - - public void visitXSDWildcard(XSDWildcard object) - { - - } - - public void printIndented(String string) - { - //String spaces = ""; - //for (int i = 0; i < indent; i++) - //{ - // spaces += " "; - //} - - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDComplexTypeDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDComplexTypeDefinitionAdapter.java deleted file mode 100644 index 4ad7e9057b..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDComplexTypeDefinitionAdapter.java +++ /dev/null @@ -1,566 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.action.Action; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAnyAttributeAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAnyElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeDeclarationAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeGroupDefinitionAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDEnumerationFacetAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDModelGroupAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetBaseTypeAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDElementCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.SpaceFiller; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeGroupContent; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeContent; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDDerivationMethod; -import org.eclipse.xsd.XSDEnumerationFacet; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDParticleContent; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDComplexTypeDefinitionAdapter extends XSDTypeDefinitionAdapter implements IComplexType, IADTObjectListener -{ - protected List fields = null; - protected List otherThingsToListenTo = null; - protected boolean readOnly; - protected boolean changeReadOnlyField =false; - protected HashMap deletedTypes = new HashMap(); - - public XSDComplexTypeDefinition getXSDComplexTypeDefinition() - { - return (XSDComplexTypeDefinition) target; - } - - public IType getSuperType() - { - XSDTypeDefinition td = getXSDTypeDefinition().getBaseType(); - - // test to filter out the 'anyType' type ... don't want to see that - // - if (td != null && !td.getName().equals("anyType")) //$NON-NLS-1$ - { - return (IType) XSDAdapterFactory.getInstance().adapt(td); - } - return null; - } - - protected void clearFields() - { - if (otherThingsToListenTo != null) - { - for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext();) - { - Adapter adapter = (Adapter) i.next(); - if (adapter instanceof IADTObject) - { - IADTObject adtObject = (IADTObject) adapter; - adtObject.unregisterListener(this); - } - } - } - fields = null; - otherThingsToListenTo = null; - } - - public List getFields() - { - if (fields == null) - { - fields = new ArrayList(); - otherThingsToListenTo = new ArrayList(); - - XSDVisitorForFields visitor = new XSDVisitorForFieldsWithSpaceFillers(); - visitor.visitComplexTypeDefinition(getXSDComplexTypeDefinition()); - populateAdapterList(visitor.concreteComponentList, fields); - populateAdapterList(visitor.thingsWeNeedToListenTo, otherThingsToListenTo); - for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext();) - { - Adapter adapter = (Adapter) i.next(); - if (adapter instanceof IADTObject) - { - IADTObject adtObject = (IADTObject) adapter; - adtObject.registerListener(this); - } - } - } - return fields; - } - - class XSDVisitorForFieldsWithSpaceFillers extends XSDVisitorForFields - { - public XSDVisitorForFieldsWithSpaceFillers() - { - super(); - } - - public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) - { - for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext();) - { - Object o = it.next(); - if (o instanceof XSDAttributeUse) - { - XSDAttributeUse attributeUse = (XSDAttributeUse) o; - concreteComponentList.add(attributeUse.getAttributeDeclaration()); - thingsWeNeedToListenTo.add(attributeUse.getAttributeDeclaration()); - } - else if (o instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) o; - thingsWeNeedToListenTo.add(attrGroup); - if (attrGroup.isAttributeGroupDefinitionReference()) - { - attrGroup = attrGroup.getResolvedAttributeGroupDefinition(); - if (attrGroup.getContents().size() == 0) - { - concreteComponentList.add(new SpaceFiller("attribute")); //$NON-NLS-1$ - } - visitAttributeGroupDefinition(attrGroup); - } - } - } - } - - public void visitModelGroup(XSDModelGroup modelGroup) - { - int numOfChildren = modelGroup.getContents().size(); - if (numOfChildren == 0) - { - concreteComponentList.add(new SpaceFiller("element")); //$NON-NLS-1$ - } - super.visitModelGroup(modelGroup); - } - - public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) - { - XSDModelGroupDefinition resolvedModelGroupDef = modelGroupDef.getResolvedModelGroupDefinition(); - if (visitedGroups.contains(resolvedModelGroupDef.getModelGroup())) - { - concreteComponentList.add(new SpaceFiller("element")); //$NON-NLS-1$ - } - super.visitModelGroupDefinition(modelGroupDef); - } - } - - public List getModelGroups() - { - List groups = new ArrayList(); - groups.addAll(XSDChildUtility.getModelChildren(getXSDComplexTypeDefinition())); - return groups; - } - - public List getAttributeGroupContent() - { - EList attrContent = getXSDComplexTypeDefinition().getAttributeContents(); - List attrUses = new ArrayList(); - List list = new ArrayList(); - - for (Iterator it = attrContent.iterator(); it.hasNext();) - { - XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) it.next(); - - if (attrGroupContent instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) attrGroupContent; - list.add(XSDAdapterFactory.getInstance().adapt(attributeGroupDefinition)); - getAttributeUses(attributeGroupDefinition, attrUses); - } - else - { - attrUses.add(attrGroupContent); - list.add(new TargetConnectionSpaceFiller(this)); - } - } - return list; - } - - public boolean isComplexType() - { - return true; - } - - public void notifyChanged(Notification msg) - { - clearFields(); - super.notifyChanged(msg); - } - - public Command getUpdateNameCommand(String newName) - { - return new UpdateNameCommand(Messages._UI_ACTION_UPDATE_NAME, getXSDComplexTypeDefinition(), newName); - } - - public Command getAddNewFieldCommand(String fieldKind) - { - return new AddXSDElementCommand(Messages._UI_ACTION_ADD_FIELD, getXSDComplexTypeDefinition()); - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDComplexTypeDefinition()); - } - - protected class AddNewFieldCommand extends Command - { - protected String defaultName; - protected String fieldKind; - - AddNewFieldCommand(String defaultName, String fieldKind) - { - this.defaultName = defaultName; - this.fieldKind = fieldKind; - } - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - Object schema = getEditorSchema(); - - XSDComplexTypeDefinition complexType = getXSDComplexTypeDefinition(); - Object contentType = getContentType(); - XSDDerivationMethod derivation = complexType.getDerivationMethod(); - if (contentType instanceof XSDSimpleTypeDefinition) - { - List fields = getFields(); - boolean hasSimpleContentAttributes = false; - for (Iterator iterator = fields.iterator(); iterator.hasNext(); ) - { - Object field = iterator.next(); - // We have attributes, so we need to add the compartment for housing the attributes - if (field instanceof XSDAttributeDeclarationAdapter) - { - hasSimpleContentAttributes = true; - break; - } - } - - if (hasSimpleContentAttributes || XSDDerivationMethod.EXTENSION_LITERAL.equals(derivation)) - { - list.add(AddXSDAttributeDeclarationAction.ID); - } - else if (XSDDerivationMethod.RESTRICTION_LITERAL.equals(derivation)) - { - list.add(AddXSDEnumerationFacetAction.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(SetBaseTypeAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - } - else - { - list.add(AddXSDElementAction.ID); - list.add(AddXSDElementAction.REF_ID); - list.add(AddXSDAnyElementAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(AddXSDAttributeDeclarationAction.ID); - list.add(AddXSDAttributeDeclarationAction.REF_ID); - list.add(AddXSDAttributeGroupDefinitionAction.REF_ID); - list.add(AddXSDAnyAttributeAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(AddXSDModelGroupAction.SEQUENCE_ID); - list.add(AddXSDModelGroupAction.CHOICE_ID); - list.add(AddXSDModelGroupAction.ALL_ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(SetBaseTypeAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - } - if (complexType.getSchema() == schema) - { - XSDConcreteComponent container = complexType.getContainer(); - if (container == schema || container instanceof XSDRedefine) - { - list.add(SetInputToGraphView.ID); - } - } - else - { - list.add(OpenInNewEditor.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - String[] result = new String[list.size()]; - list.toArray(result); - return result; - } - - public void propertyChanged(Object object, String property) - { - clearFields(); - notifyListeners(this, null); - } - - class BogusAction extends Action - { - BogusAction(String name) - { - super(name); - } - - public void run() - { - // TODO Auto-generated method stub - super.run(); - } - } - - public ITreeElement[] getChildren() - { - XSDComplexTypeDefinition xsdComplexTypeDefinition = getXSDComplexTypeDefinition(); - List list = new ArrayList(); - // Add attributes - for (Iterator i = xsdComplexTypeDefinition.getAttributeContents().iterator(); i.hasNext();) - { - Object obj = i.next(); - if (obj instanceof XSDAttributeUse) - { - list.add(((XSDAttributeUse)obj).getAttributeDeclaration()); - } - else if (obj instanceof XSDAttributeGroupDefinition) - { - getAttributeUses((XSDAttributeGroupDefinition) obj, list); - } - } - // Add enumerations - boolean canHaveEnumerations = xsdComplexTypeDefinition.getContentType() instanceof XSDSimpleTypeDefinition && - XSDDerivationMethod.RESTRICTION_LITERAL.equals(xsdComplexTypeDefinition.getDerivationMethod()); - if (canHaveEnumerations) - { - Object contentType = getContentType(); - if (contentType != null) - { - for (Iterator iterator = ((XSDSimpleTypeDefinition)contentType).getEnumerationFacets().iterator(); iterator.hasNext();) - { - XSDEnumerationFacet enumerationFacet = (XSDEnumerationFacet)iterator.next(); - list.add(enumerationFacet); - } - } - } - XSDWildcard anyAttr = xsdComplexTypeDefinition.getAttributeWildcard(); - if (anyAttr != null) - list.add(anyAttr); - // get immediate XSD Model Group of this complex type - if (xsdComplexTypeDefinition.getContent() != null) - { - XSDComplexTypeContent xsdComplexTypeContent = xsdComplexTypeDefinition.getContent(); - if (xsdComplexTypeContent instanceof XSDParticle) - { - XSDParticleContent particleContent = ((XSDParticle) xsdComplexTypeContent).getContent(); - if (particleContent instanceof XSDModelGroup) - { - list.add(particleContent); - } - } - } - // get inherited XSD Model Group of this complex type - boolean showInheritedContent = XSDEditorPlugin.getPlugin().getShowInheritedContent(); - if (showInheritedContent) - { - XSDTypeDefinition typeDef = xsdComplexTypeDefinition.getBaseTypeDefinition(); - if (typeDef instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition baseCT = (XSDComplexTypeDefinition) typeDef; - if (baseCT.getTargetNamespace() != null && !baseCT.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) - { - if (baseCT.getContent() != null) - { - XSDComplexTypeContent xsdComplexTypeContent = baseCT.getContent(); - if (xsdComplexTypeContent instanceof XSDParticle) - { - XSDParticleContent particleContent = ((XSDParticle) xsdComplexTypeContent).getContent(); - if (particleContent instanceof XSDModelGroup) - { - list.add(particleContent); - } - } - } - } - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]); - } - - public Image getImage() - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDComplexTypedis.gif"); //$NON-NLS-1$ - } - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDComplexType.gif"); //$NON-NLS-1$ - } - - public String getText() - { - XSDComplexTypeDefinition xsdComplexTypeDefinition = (XSDComplexTypeDefinition) target; - - StringBuffer result = new StringBuffer(); - - result.append(xsdComplexTypeDefinition.getName() == null ? "local type" : xsdComplexTypeDefinition.getName()); //$NON-NLS-1$ - - XSDTypeDefinition baseTypeDefinition = xsdComplexTypeDefinition.getBaseTypeDefinition(); - if (baseTypeDefinition != null && baseTypeDefinition != xsdComplexTypeDefinition.getContent() && baseTypeDefinition.getName() != null && !XSDConstants.isURType(baseTypeDefinition)) - { - - try{ - String qName = baseTypeDefinition.getQName(xsdComplexTypeDefinition); - result.append(" : "); //$NON-NLS-1$ - result.append(qName); - } - catch (Exception e) - { - return result.toString(); - } - - } - - return result.toString(); - } - - public void getAttributeUses(XSDAttributeGroupDefinition attributeGroupDefinition, List list) - { - Iterator i = attributeGroupDefinition.getResolvedAttributeGroupDefinition().getContents().iterator(); - - while (i.hasNext()) - { - XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) i.next(); - - if (attrGroupContent instanceof XSDAttributeGroupDefinition) - { - getAttributeUses((XSDAttributeGroupDefinition) attrGroupContent, list); - } - else - { - list.add(XSDAdapterFactory.getInstance().adapt(attrGroupContent)); - } - } - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDComplexTypeDefinition().getSchema()); - return (IModel)adapter; - } - - public boolean isFocusAllowed() - { - return true; - } - - public boolean isAnonymous() - { - XSDComplexTypeDefinition xsdComplexTypeDefinition = (XSDComplexTypeDefinition) target; - return !(xsdComplexTypeDefinition.eContainer() instanceof XSDSchema || - xsdComplexTypeDefinition.eContainer() instanceof XSDRedefine); - } - - public IADTObject getTopContainer() - { - return this; - } - - public boolean isAbstract() - { - return getXSDComplexTypeDefinition().isAbstract(); - } - - public Object getContentType() - { - return getXSDComplexTypeDefinition().getContent(); - } - public boolean isReadOnly() - { - XSDComplexTypeDefinition xsdComplexTypeDefinition = (XSDComplexTypeDefinition) target; - if (hasSetReadOnlyField()) - { - deletedTypes.put(xsdComplexTypeDefinition.getName(), new Boolean(true)); - changeReadOnlyField = false; - return readOnly; - } - else - { - if (deletedTypes!= null ) - { - Boolean deleted = ((Boolean)deletedTypes.get(xsdComplexTypeDefinition.getName())); - if (deleted != null && deleted.booleanValue()) - return true; - else return super.isReadOnly(); - } - else - return super.isReadOnly(); - } - } - -public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; -} - -public boolean hasSetReadOnlyField() { - return changeReadOnlyField; -} - -public void setChangeReadOnlyField(boolean setReadOnlyField) { - this.changeReadOnlyField = setReadOnlyField; -} - -public void updateDeletedMap(String addComponent) -{ - if (deletedTypes.get(addComponent) != null) - { - deletedTypes.clear(); - } -} -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDElementDeclarationAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDElementDeclarationAdapter.java deleted file mode 100644 index c1501d72d0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDElementDeclarationAdapter.java +++ /dev/null @@ -1,339 +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.adapters; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.osgi.util.TextProcessor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.IAnnotationProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicityAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetTypeAction; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDElementDeclarationAdapter extends XSDParticleAdapter implements IField, IActionProvider, IAnnotationProvider, IGraphElement -{ - protected XSDElementDeclaration getXSDElementDeclaration() - { - return (XSDElementDeclaration) target; - } - - public String getName() - { - String name = getXSDElementDeclaration().getResolvedElementDeclaration().getName(); - return (name == null) ? "" : name; //$NON-NLS-1$ - } - - public String getTypeName() - { - IType type = getType(); - if (type != null) - { - return type.getName(); - } - return null; - } - - public String getTypeNameQualifier() - { - XSDTypeDefinition type = getXSDElementDeclaration().getResolvedElementDeclaration().getTypeDefinition(); - if (type != null) - { - return type.getTargetNamespace(); - } - return ""; - } - - public IType getType() - { - XSDTypeDefinition td = getXSDElementDeclaration().getResolvedElementDeclaration().getTypeDefinition(); - //if (td != null && - // td.getTargetNamespace() != null && td.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) return null; - return (td != null) ? (IType) XSDAdapterFactory.getInstance().adapt(td) : null; - } - - public Image getImage() - { - XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) target; - - if (!xsdElementDeclaration.isElementDeclarationReference()) - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDElementdis.gif"); - } - return XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"); //$NON-NLS-1$ - } - else - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDElementRefdis.gif"); - } - return XSDEditorPlugin.getXSDImage("icons/XSDElementRef.gif"); //$NON-NLS-1$ - } - } - - public String getText() - { - XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) target; - XSDElementDeclaration resolvedElementDeclaration = xsdElementDeclaration.getResolvedElementDeclaration(); - //String name = xsdElementDeclaration != resolvedElementDeclaration ? xsdElementDeclaration.getQName() : xsdElementDeclaration.getName(); - String name = resolvedElementDeclaration.getName(); - - StringBuffer result = new StringBuffer(); - if (name == null) - { - result.append(Messages._UI_LABEL_ABSENT); - } - else - { - result.append(name); - } - - if (!xsdElementDeclaration.isGlobal()) - { - Element element = xsdElementDeclaration.getElement(); - boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE); - boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE); - - if (hasMinOccurs || hasMaxOccurs) - { - result.append(" ["); //$NON-NLS-1$ - if (hasMinOccurs) - { - int min = ((XSDParticle) xsdElementDeclaration.getContainer()).getMinOccurs(); - if (min == XSDParticle.UNBOUNDED) - { - result.append("*"); //$NON-NLS-1$ - } - else - { - result.append(String.valueOf(min)); - } - } - else - // print default - { - int min = ((XSDParticle) xsdElementDeclaration.getContainer()).getMinOccurs(); - result.append(String.valueOf(min)); - } - if (hasMaxOccurs) - { - int max = ((XSDParticle) xsdElementDeclaration.getContainer()).getMaxOccurs(); - result.append(".."); //$NON-NLS-1$ - if (max == XSDParticle.UNBOUNDED) - { - result.append("*"); //$NON-NLS-1$ - } - else - { - result.append(String.valueOf(max)); - } - } - else - // print default - { - result.append(".."); //$NON-NLS-1$ - int max = ((XSDParticle) xsdElementDeclaration.getContainer()).getMaxOccurs(); - result.append(String.valueOf(max)); - - } - result.append("]"); //$NON-NLS-1$ - } - } - - if (resolvedElementDeclaration.getAnonymousTypeDefinition() == null && resolvedElementDeclaration.getTypeDefinition() != null) - { - result.append(" : "); //$NON-NLS-1$ - // result.append(resolvedElementDeclaration.getTypeDefinition().getQName(xsdElementDeclaration)); - result.append(resolvedElementDeclaration.getTypeDefinition().getName()); - } - - String text = result.toString(); - String processedString = TextProcessor.process(text, ":"); - return processedString; - - } - - public ITreeElement[] getChildren() - { - XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) target; - List list = new ArrayList(); - XSDTypeDefinition type = null; - if (xsdElementDeclaration.isElementDeclarationReference()) - { - type = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition(); - } - else - { - type = xsdElementDeclaration.getAnonymousTypeDefinition(); - if (type == null) - { - type = xsdElementDeclaration.getTypeDefinition(); - } - } - - if (type instanceof XSDComplexTypeDefinition && type.getTargetNamespace() != null && !type.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) - { - XSDComplexTypeDefinition ctType = (XSDComplexTypeDefinition) type; - if (ctType != null) - { - if (xsdElementDeclaration.isGlobal()) - list.add(ctType); - } - } - - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]); - - } - - public String getKind() - { - return "element"; //$NON-NLS-1$ - } - - public boolean isGlobal() - { - return getXSDElementDeclaration().eContainer() instanceof XSDSchema; - } - - public boolean isReference() - { - return ((XSDElementDeclaration) target).isElementDeclarationReference(); - } - - public Command getUpdateMaxOccursCommand(int maxOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateMinOccursCommand(int minOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateNameCommand(String name) - { - return new UpdateNameCommand(Messages._UI_ACTION_UPDATE_NAME, getXSDElementDeclaration().getResolvedElementDeclaration(), name); - } - - public Command getUpdateTypeNameCommand(String typeName, String quailifier) - { - // TODO Auto-generated method stub - return null; - } - - public Command getDeleteCommand() - { - // TODO Auto-generated method stub - return new DeleteCommand(getXSDElementDeclaration()); - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - - if (!isGlobal()) - { - list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_INSERT_ELEMENT); - list.add(AddXSDElementAction.BEFORE_SELECTED_ID); - list.add(AddXSDElementAction.AFTER_SELECTED_ID); - list.add(BaseSelectionAction.SUBMENU_END_ID); - } - - list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_TYPE); - list.add(SetTypeAction.SET_NEW_TYPE_ID); - list.add(SetTypeAction.SELECT_EXISTING_TYPE_ID); - list.add(BaseSelectionAction.SUBMENU_END_ID); - - list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY); - list.add(SetMultiplicityAction.REQUIRED_ID); - list.add(SetMultiplicityAction.ZERO_OR_ONE_ID); - list.add(SetMultiplicityAction.ZERO_OR_MORE_ID); - list.add(SetMultiplicityAction.ONE_OR_MORE_ID); - list.add(BaseSelectionAction.SUBMENU_END_ID); - - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - Object schema = getEditorSchema(); - if (getXSDElementDeclaration().getSchema() == schema) - { - if (getXSDElementDeclaration().getContainer() == schema) - { - list.add(SetInputToGraphView.ID); - } - } - else - { - list.add(OpenInNewEditor.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - return (String [])list.toArray(new String[0]); - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDElementDeclaration().getSchema()); - return (IModel)adapter; - } - - public boolean isFocusAllowed() - { - return isGlobal(); - } - - public IADTObject getTopContainer() - { - if (!isGlobal()) - { - return getGlobalXSDContainer(getXSDElementDeclaration()); - } - return this; - } - - public boolean isAbstract() - { - return getXSDElementDeclaration().isAbstract(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDEmptyFieldAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDEmptyFieldAdapter.java deleted file mode 100644 index 7e9b8fc997..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDEmptyFieldAdapter.java +++ /dev/null @@ -1,120 +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.adapters; - -import org.eclipse.gef.commands.Command; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; - -/** - * @deprecated not used - */ -public class XSDEmptyFieldAdapter extends XSDBaseAdapter implements IField -{ - String kind; - public XSDEmptyFieldAdapter() - { - super(); - } - - public String getKind() - { - return kind; - } - - public void setKind(String kind) - { - this.kind = kind; - } - - public String getName() - { - return null; - } - - public String getTypeName() - { - // TODO Auto-generated method stub - return null; - } - - public String getTypeNameQualifier() - { - // TODO Auto-generated method stub - return null; - } - - public IType getType() - { - // TODO Auto-generated method stub - return null; - } - - public int getMinOccurs() - { - // TODO Auto-generated method stub - return 0; - } - - public int getMaxOccurs() - { - // TODO Auto-generated method stub - return 0; - } - - public boolean isGlobal() - { - return false; - } - - public Command getUpdateMinOccursCommand(int minOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateMaxOccursCommand(int maxOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateTypeNameCommand(String typeName, String quailifier) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateNameCommand(String name) - { - // TODO Auto-generated method stub - return null; - } - - public Command getDeleteCommand() - { - // TODO Auto-generated method stub - return null; - } - - public IModel getModel() - { - // TODO Auto-generated method stub - return null; - } - - public boolean isReference() - { - // TODO Auto-generated method stub - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDEnumerationFacetAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDEnumerationFacetAdapter.java deleted file mode 100644 index e6dfbe9685..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDEnumerationFacetAdapter.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.adapters; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDEnumerationFacetAction; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDEnumerationFacet; - -public class XSDEnumerationFacetAdapter extends XSDBaseAdapter implements IActionProvider, IGraphElement -{ - public XSDEnumerationFacet getXSDEnumerationFacet() - { - return (XSDEnumerationFacet)target; - } - - public XSDEnumerationFacetAdapter() - { - super(); - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - - list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_INSERT_ENUMERATION); - list.add(AddXSDEnumerationFacetAction.BEFORE_SELECTED_ID); - list.add(AddXSDEnumerationFacetAction.AFTER_SELECTED_ID); - list.add(BaseSelectionAction.SUBMENU_END_ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - return (String [])list.toArray(new String[0]); - } - - public Image getImage() - { - return XSDEditorPlugin.getXSDImage("icons/XSDSimpleEnum.gif"); //$NON-NLS-1$ - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDEnumerationFacet()); - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDEnumerationFacet().getSchema()); - return (IModel)adapter; - } - - public IADTObject getTopContainer() - { - return getGlobalXSDContainer(getXSDEnumerationFacet()); - } - - public boolean isFocusAllowed() - { - return false; - } - - public String getText() - { - return getXSDEnumerationFacet().getLexicalValue(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDModelGroupAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDModelGroupAdapter.java deleted file mode 100644 index 904acec553..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDModelGroupAdapter.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAnyElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDModelGroupAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDModelGroupDefinitionAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicityAction; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.design.figures.ModelGroupFigure; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDParticleContent; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDModelGroupAdapter extends XSDParticleAdapter implements IActionProvider, IGraphElement -{ - XSDModelGroup getXSDModelGroup() - { - return (XSDModelGroup) target; - } - - public XSDModelGroupAdapter() - { - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getImage() - */ - public Image getImage() - { - XSDModelGroup xsdModelGroup = getXSDModelGroup(); - if (XSDCompositor.CHOICE_LITERAL == xsdModelGroup.getCompositor()) - { - return ModelGroupFigure.CHOICE_ICON_IMAGE; - } - else if (XSDCompositor.ALL_LITERAL == xsdModelGroup.getCompositor()) - { - return ModelGroupFigure.ALL_ICON_IMAGE; - } - else - { - return ModelGroupFigure.SEQUENCE_ICON_IMAGE; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getText() - */ - public String getText() - { - XSDModelGroup xsdModelGroup = getXSDModelGroup(); - - StringBuffer result = new StringBuffer(); - String name = xsdModelGroup.getCompositor().getName(); - if (name != null) - { - result.append(name); - } - - Element element = xsdModelGroup.getElement(); - - if (element != null) - { - boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE); - boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE); - - if (hasMinOccurs || hasMaxOccurs) - { - result.append(" ["); //$NON-NLS-1$ - if (hasMinOccurs) - { - int min = ((XSDParticle) xsdModelGroup.getContainer()).getMinOccurs(); - if (min == XSDParticle.UNBOUNDED) - { - result.append("*"); //$NON-NLS-1$ - } - else - { - result.append(String.valueOf(min)); - } - } - else - // print default - { - int min = ((XSDParticle) xsdModelGroup.getContainer()).getMinOccurs(); - result.append(String.valueOf(min)); - } - if (hasMaxOccurs) - { - int max = ((XSDParticle) xsdModelGroup.getContainer()).getMaxOccurs(); - result.append(".."); //$NON-NLS-1$ - if (max == XSDParticle.UNBOUNDED) - { - result.append("*"); //$NON-NLS-1$ - } - else - { - result.append(String.valueOf(max)); - } - } - else - // print default - { - result.append(".."); //$NON-NLS-1$ - int max = ((XSDParticle) xsdModelGroup.getContainer()).getMaxOccurs(); - result.append(String.valueOf(max)); - } - result.append("]"); //$NON-NLS-1$ - } - } - return result.toString(); - } - - public ITreeElement[] getChildren() - { - XSDModelGroup xsdModelGroup = getXSDModelGroup(); - List list = new ArrayList(); - for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) - { - Object object = i.next(); - XSDParticleContent particle = ((XSDParticle)object).getContent(); - if (particle instanceof XSDElementDeclaration) - { - list.add(particle); - } - else if (particle instanceof XSDWildcard) - { - list.add(particle); - } - else if (particle instanceof XSDModelGroup) - { - list.add(particle); - } - else if (particle instanceof XSDModelGroupDefinition) - { - //list.add(((XSDModelGroupDefinition)particle).getResolvedModelGroupDefinition()); - list.add(particle); - } - } - - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return (ITreeElement []) adapterList.toArray(new ITreeElement[0]); - } - - public Object getParent(Object object) - { - XSDModelGroup element = (XSDModelGroup) object; - return element.getContainer(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider#getActions(java.lang.Object) - */ - public String[] getActions(Object object) - { - Collection actionIDs = new ArrayList(); - actionIDs.add(AddXSDElementAction.ID); - actionIDs.add(AddXSDElementAction.REF_ID); - actionIDs.add(AddXSDAnyElementAction.ID); - // Add Element Ref - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(AddXSDModelGroupAction.SEQUENCE_ID); - actionIDs.add(AddXSDModelGroupAction.CHOICE_ID); - actionIDs.add(AddXSDModelGroupAction.ALL_ID); - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(AddXSDModelGroupDefinitionAction.MODELGROUPDEFINITIONREF_ID); -// actionIDs.add(AddFieldAction.ID); - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - // Add Any - - actionIDs.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY); - actionIDs.add(SetMultiplicityAction.REQUIRED_ID); - actionIDs.add(SetMultiplicityAction.ZERO_OR_ONE_ID); - actionIDs.add(SetMultiplicityAction.ZERO_OR_MORE_ID); - actionIDs.add(SetMultiplicityAction.ONE_OR_MORE_ID); - actionIDs.add(BaseSelectionAction.SUBMENU_END_ID); - - if (!(getParent(target) instanceof XSDModelGroupDefinition)) - { - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(DeleteAction.ID); - } - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(ShowPropertiesViewAction.ID); - - return (String [])actionIDs.toArray(new String[0]); - } - - public int getMaxOccurs() - { - return getMaxOccurs(getXSDModelGroup()); - } - - public int getMinOccurs() - { - return getMinOccurs(getXSDModelGroup()); - } - - public IADTObject getTopContainer() - { - XSDModelGroup xsdModelGroup = getXSDModelGroup(); - return getGlobalXSDContainer(xsdModelGroup); - } - - public boolean isFocusAllowed() - { - return false; - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDModelGroup()); - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDModelGroup().getSchema()); - return (IModel)adapter; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDModelGroupDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDModelGroupDefinitionAdapter.java deleted file mode 100644 index 6fcd1934f1..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDModelGroupDefinitionAdapter.java +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IStructure; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDModelGroupAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicityAction; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.design.editparts.model.SpaceFiller; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; - -public class XSDModelGroupDefinitionAdapter extends XSDParticleAdapter implements IStructure, IActionProvider, IGraphElement, IADTObjectListener -{ - public static final Image MODEL_GROUP_ICON = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDGroup.gif"); //$NON-NLS-1$ - public static final Image MODEL_GROUP_DISABLED_ICON = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDGroupdis.gif"); //$NON-NLS-1$ - public static final Image MODEL_GROUP_REF_ICON = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDGroupRef.gif"); //$NON-NLS-1$ - public static final Image MODEL_GROUP_REF_DISABLED_ICON = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDGroupRefdis.gif"); //$NON-NLS-1$ - - protected List fields = null; - protected List otherThingsToListenTo = null; - protected boolean readOnly; - protected boolean changeReadOnlyField =false; - protected HashMap deletedTypes = new HashMap(); - - public XSDModelGroupDefinitionAdapter() - { - super(); - } - - public XSDModelGroupDefinition getXSDModelGroupDefinition() - { - return (XSDModelGroupDefinition) target; - } - - public Image getImage() - { - XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition) target; - - if (xsdModelGroupDefinition.isModelGroupDefinitionReference()) - { - if (isReadOnly()) - { - return MODEL_GROUP_REF_DISABLED_ICON; - } - return MODEL_GROUP_REF_ICON; - } - else - { - if (isReadOnly()) - { - return MODEL_GROUP_DISABLED_ICON; - } - return MODEL_GROUP_ICON; - } - } - - public String getText() - { - XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition) target; - if (xsdModelGroupDefinition.getResolvedModelGroupDefinition().getContainer() == null && xsdModelGroupDefinition.getName() ==null) return ""; // Removed - String result = xsdModelGroupDefinition.isModelGroupDefinitionReference() ? xsdModelGroupDefinition.getQName() : xsdModelGroupDefinition.getName(); - return result == null ? Messages._UI_LABEL_ABSENT : result; - } - - public ITreeElement[] getChildren() - { - XSDModelGroupDefinition def = (XSDModelGroupDefinition)target; - List list = new ArrayList(); - // Bug246036 - need to stop showing element content in a cycle. - // And, we should not show any element content for references otherwise there will be two - // entries in the tree viewer for the same item - if (!def.isModelGroupDefinitionReference()) - { - XSDModelGroup xsdModelGroup = ((XSDModelGroupDefinition) target).getResolvedModelGroupDefinition().getModelGroup(); - if (xsdModelGroup != null) - list.add(xsdModelGroup); - } - - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider#getActions(java.lang.Object) - */ - public String[] getActions(Object object) - { - Collection list = new ArrayList(); - - XSDModelGroupDefinition modelGroupDefinition = getXSDModelGroupDefinition(); - boolean isModelGroupReference = modelGroupDefinition.isModelGroupDefinitionReference(); - if (!isModelGroupReference) - { - list.add(AddXSDElementAction.ID); - list.add(AddXSDElementAction.REF_ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(AddXSDModelGroupAction.SEQUENCE_ID); - list.add(AddXSDModelGroupAction.CHOICE_ID); - list.add(AddXSDModelGroupAction.ALL_ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - } - - list.add(DeleteAction.ID); - - if (isModelGroupReference) - { - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY); - list.add(SetMultiplicityAction.REQUIRED_ID); - list.add(SetMultiplicityAction.ZERO_OR_ONE_ID); - list.add(SetMultiplicityAction.ZERO_OR_MORE_ID); - list.add(SetMultiplicityAction.ONE_OR_MORE_ID); - list.add(BaseSelectionAction.SUBMENU_END_ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - Object schema = getEditorSchema(); - if (modelGroupDefinition.getSchema() == schema) - { - XSDConcreteComponent container = modelGroupDefinition.getContainer(); - if (container == schema || container instanceof XSDRedefine) - { - list.add(SetInputToGraphView.ID); - } - } - else - { - list.add(OpenInNewEditor.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - - return (String [])list.toArray(new String[0]); - } - - public Command getAddNewFieldCommand(String fieldKind) - { - return null; - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDModelGroupDefinition()); - } - - // TODO Common this up with XSDComplexType's. See also getFields - protected void clearFields() - { - if (otherThingsToListenTo != null) - { - for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext();) - { - Adapter adapter = (Adapter) i.next(); - if (adapter instanceof IADTObject) - { - IADTObject adtObject = (IADTObject) adapter; - adtObject.unregisterListener(this); - } - } - } - fields = null; - otherThingsToListenTo = null; - } - - public List getFields() - { - List fields = new ArrayList(); - otherThingsToListenTo = new ArrayList(); - XSDVisitorForFields visitor = new XSDVisitorForGroupFieldsWithSpaceFillers(); - visitor.visitModelGroupDefinition(getXSDModelGroupDefinition()); - populateAdapterList(visitor.concreteComponentList, fields); - - // TODO (cs) common a base class for a structure thingee - // - populateAdapterList(visitor.thingsWeNeedToListenTo, otherThingsToListenTo); - for (Iterator i = otherThingsToListenTo.iterator(); i.hasNext();) - { - Adapter adapter = (Adapter) i.next(); - if (adapter instanceof IADTObject) - { - IADTObject adtObject = (IADTObject) adapter; - adtObject.registerListener(this); - } - } - return fields; - } - - protected class XSDVisitorForGroupFieldsWithSpaceFillers extends XSDVisitorForFields - { - public XSDVisitorForGroupFieldsWithSpaceFillers() - { - super(); - } - - public void visitModelGroup(XSDModelGroup modelGroup) - { - int numOfChildren = modelGroup.getContents().size(); - if (numOfChildren == 0) - { - concreteComponentList.add(new SpaceFiller("element")); //$NON-NLS-1$ - } - super.visitModelGroup(modelGroup); - } - - public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) - { - XSDModelGroupDefinition resolvedModelGroupDef = modelGroupDef.getResolvedModelGroupDefinition(); - if (visitedGroups.contains(resolvedModelGroupDef.getModelGroup())) - { - concreteComponentList.add(new SpaceFiller("element")); //$NON-NLS-1$ - } - super.visitModelGroupDefinition(modelGroupDef); - } - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDModelGroupDefinition().getSchema()); - return (IModel)adapter; - } - public String getName() - { - return getText(); - } - - public boolean isFocusAllowed() - { - XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition) target; - if (xsdModelGroupDefinition.isModelGroupDefinitionReference()) - { - return false; - } - return true; - } - - public void propertyChanged(Object object, String property) - { - clearFields(); - notifyListeners(this, null); - } - - public int getMaxOccurs() - { - return getMaxOccurs(getXSDModelGroupDefinition()); - } - - public int getMinOccurs() - { - return getMinOccurs(getXSDModelGroupDefinition()); - } - - public IADTObject getTopContainer() - { - XSDModelGroupDefinition group = getXSDModelGroupDefinition(); - XSDConcreteComponent container = group.getContainer(); - if (container instanceof XSDSchema || container instanceof XSDRedefine) - return this; - else - return getGlobalXSDContainer(group); - } - public boolean isReadOnly() - { - XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition) target; - if (hasSetReadOnlyField()) - { - deletedTypes.put(xsdModelGroupDefinition.getName(), new Boolean(true)); - changeReadOnlyField = false; - return readOnly; - } - else - { - if (deletedTypes!= null ) - { - Boolean deleted = ((Boolean)deletedTypes.get(xsdModelGroupDefinition.getName())); - if (deleted != null && deleted.booleanValue()) - return true; - else return super.isReadOnly(); - } - else - return super.isReadOnly(); - } - - - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - public boolean hasSetReadOnlyField() { - return changeReadOnlyField; - } - - public void setChangeReadOnlyField(boolean setReadOnlyField) { - this.changeReadOnlyField = setReadOnlyField; - } - - public void updateDeletedMap(String addComponent) { - if (deletedTypes.get(addComponent) != null) - deletedTypes.clear(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDParticleAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDParticleAdapter.java deleted file mode 100644 index a26649ce7a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDParticleAdapter.java +++ /dev/null @@ -1,161 +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.adapters; - -import org.eclipse.wst.xsd.ui.internal.adt.design.IAnnotationProvider; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDParticle; - -public class XSDParticleAdapter extends XSDBaseAdapter implements IAnnotationProvider -{ - public XSDParticleAdapter() - { - super(); - } - - public int getMaxOccurs() - { - return getMaxOccurs((XSDConcreteComponent) target); - } - - public int getMinOccurs() - { - return getMinOccurs((XSDConcreteComponent) target); - } - - public static int getMinOccurs(XSDConcreteComponent component) - { - int minOccur = -2; - if (component != null) - { - Object o = component.getContainer(); - if (o instanceof XSDParticle) - { - if (((XSDParticle) o).isSetMinOccurs()) - { - try - { - minOccur = ((XSDParticle) o).getMinOccurs(); - } - catch (Exception e) - { - } - } - } - } - return minOccur; - } - - public static int getMaxOccurs(XSDConcreteComponent component) - { - int maxOccur = -2; - if (component != null) - { - Object o = component.getContainer(); - if (o instanceof XSDParticle) - { - if (((XSDParticle) o).isSetMaxOccurs()) - { - try - { - maxOccur = ((XSDParticle) o).getMaxOccurs(); - } - catch (Exception e) - { - } - } - } - } - return maxOccur; - } - - public String getNameAnnotationString() - { - return buildAnnotationString(true); - } - - public String getNameAnnotationToolTipString() - { - return buildAnnotationString(false); - } - - public String getTypeAnnotationString() - { - return null; - } - - public String getTypeAnnotationToolTipString() - { - return null; - } - - protected String buildAnnotationString(boolean isForLabel) - { - String occurenceDescription = ""; //$NON-NLS-1$ - String toolTipDescription = ""; //$NON-NLS-1$ - // TODO: set int values as defined constants - // -2 means the user didn't specify (so the default is 1) - int minOccurs = getMinOccurs(); - int maxOccurs = getMaxOccurs(); - - // This is for the attribute field case, which has no - // occurrence attributes - if (minOccurs == -3 && maxOccurs == -3) - { - occurenceDescription = ""; //$NON-NLS-1$ - } - else if (minOccurs == 0 && (maxOccurs == -2 || maxOccurs == 1)) - { - occurenceDescription = "[0..1]"; //$NON-NLS-1$ - toolTipDescription = Messages._UI_LABEL_OPTIONAL; - } - else if (minOccurs == 0 && maxOccurs == -1) - { - occurenceDescription = "[0..*]"; //$NON-NLS-1$ - toolTipDescription = Messages._UI_LABEL_ZERO_OR_MORE; - } - else if ((minOccurs == 1 && maxOccurs == -1) || (minOccurs == -2 && maxOccurs == -1)) - { - occurenceDescription = "[1..*]"; //$NON-NLS-1$ - toolTipDescription = Messages._UI_LABEL_ONE_OR_MORE; - } - else if ((minOccurs == 1 && maxOccurs == 1) || (minOccurs == -2 && maxOccurs == 1) || (minOccurs == 1 && maxOccurs == -2)) - { - occurenceDescription = "[1..1]"; //$NON-NLS-1$ - toolTipDescription = Messages._UI_LABEL_REQUIRED; - } - else if (minOccurs == -2 && maxOccurs == -2) - { - occurenceDescription = ""; //$NON-NLS-1$ - // none specified, so don't have any toolTip description - } - else - { - if (maxOccurs == -2) - maxOccurs = 1; - String maxSymbol = maxOccurs == -1 ? "*" : "" + maxOccurs; //$NON-NLS-1$ //$NON-NLS-2$ - String minSymbol = minOccurs == -2 ? "1" : "" + minOccurs; //$NON-NLS-1$ //$NON-NLS-2$ - occurenceDescription = "[" + minSymbol + ".." + maxSymbol + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - toolTipDescription = Messages._UI_LABEL_ARRAY; - } - - if (isForLabel) - { - return occurenceDescription; - } - else - { - return toolTipDescription; - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDRedefineAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDRedefineAdapter.java deleted file mode 100644 index 66bc64fe21..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDRedefineAdapter.java +++ /dev/null @@ -1,295 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.adapters; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.NotificationImpl; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDPackage; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDRedefineContent; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - - -public class XSDRedefineAdapter extends XSDSchemaDirectiveAdapter -{ - - public XSDRedefineAdapter() - { - super(); - } - - public ITreeElement[] getChildren() - { - XSDRedefine xsdRedefine = (XSDRedefine)getTarget(); - - children = new ArrayList(); - - if (attributesCategory != null) - { - List attributes = getCategoryChildren(CategoryAdapter.ATTRIBUTES); - List groups = getCategoryChildren(CategoryAdapter.GROUPS); - List types = getCategoryChildren(CategoryAdapter.TYPES); - - attributesCategory.setChildren(attributes); - attributesCategory.setAllChildren(attributes); - typesCategory.setChildren(types); - typesCategory.setAllChildren(types); - groupsCategory.setChildren(groups); - groupsCategory.setAllChildren(groups); - } - else - { - createCategoryAdapters(xsdRedefine); - } - - children.add(attributesCategory); - children.add(typesCategory); - children.add(groupsCategory); - - return (ITreeElement[])children.toArray(new ITreeElement [0]); - } - - public IADTObject getTopContainer() - { - return this; - } - - public boolean isFocusAllowed() - { - return true; - } - - protected List types = null; - - protected List children, allChildren; - - protected CategoryAdapter attributesCategory; - - protected CategoryAdapter typesCategory; - - protected CategoryAdapter groupsCategory; - - /** - * Create all the category adapters - * - * @param xsdRedefine the parent redefine component - */ - private void createCategoryAdapters(XSDRedefine xsdRedefine) - { - List attributes = getCategoryChildren(CategoryAdapter.ATTRIBUTES); - List groups = getCategoryChildren(CategoryAdapter.GROUPS); - List types = getCategoryChildren(CategoryAdapter.TYPES); - - XSDEditorPlugin xsdEditorPlugin = XSDEditorPlugin.getDefault(); - attributesCategory = new RedefineCategoryAdapter( - Messages._UI_GRAPH_REDEFINE_ATTRIBUTE_GROUPS, - xsdEditorPlugin.getIconImage("obj16/attributesheader"), attributes, xsdRedefine, this, CategoryAdapter.ATTRIBUTES); //$NON-NLS-1$ - attributesCategory.setAllChildren(attributes); - registerListener(attributesCategory); - - typesCategory = new RedefineCategoryAdapter( - Messages._UI_GRAPH_REDEFINE_TYPES, - xsdEditorPlugin.getIconImage("obj16/typesheader"), types, xsdRedefine, this, CategoryAdapter.TYPES); //$NON-NLS-1$ - typesCategory.setAllChildren(types); - registerListener(typesCategory); - - groupsCategory = new RedefineCategoryAdapter( - Messages._UI_GRAPH_REDEFINE_GROUPS, - xsdEditorPlugin.getIconImage("obj16/groupsheader"), groups, xsdRedefine, this, CategoryAdapter.GROUPS); //$NON-NLS-1$ - groupsCategory.setAllChildren(groups); - registerListener(groupsCategory); - } - - public void notifyChanged(final Notification msg) - { - class CategoryNotification extends NotificationImpl - { - protected Object category; - - public CategoryNotification(Object category) - { - super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition()); - this.category = category; - } - - public Object getNotifier() - { - return category; - } - - public Object getFeature() - { - return msg.getFeature(); - } - } - - if (children == null) - { - getChildren(); - } - - Object newValue = msg.getNewValue(); - Object oldValue = msg.getOldValue(); - - if (XSDPackage.eINSTANCE.getXSDRedefine_Contents() == msg.getFeature()) - { - if ((newValue instanceof XSDAttributeGroupDefinition) || oldValue instanceof XSDAttributeGroupDefinition) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES); - Assert.isTrue(adapter != null); - List list = getCategoryChildren(CategoryAdapter.ATTRIBUTES); - adapter.setChildren(list); - adapter.setAllChildren(list); - - if (adapter.getModel() instanceof XSDSchemaAdapter) - { - XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter)adapter.getModel(); - schemaAdapter.notifyChanged(msg); - } - - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if ((newValue instanceof XSDComplexTypeDefinition || newValue instanceof XSDSimpleTypeDefinition) || (oldValue instanceof XSDComplexTypeDefinition || oldValue instanceof XSDSimpleTypeDefinition)) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES); - Assert.isTrue(adapter != null); - List types = getCategoryChildren(CategoryAdapter.TYPES); - adapter.setChildren(types); - adapter.setAllChildren(types); - if (adapter.getModel() instanceof XSDSchemaAdapter) - { - XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter)adapter.getModel(); - schemaAdapter.notifyChanged(msg); - } - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (newValue instanceof XSDModelGroupDefinition || oldValue instanceof XSDModelGroupDefinition) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS); - Assert.isTrue(adapter != null); - List list = getCategoryChildren(CategoryAdapter.GROUPS); - adapter.setChildren(list); - adapter.setAllChildren(list); - if (adapter.getModel() instanceof XSDSchemaAdapter) - { - XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter)adapter.getModel(); - schemaAdapter.notifyChanged(msg); - } - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) - { - return; - } - } - super.notifyChanged(msg); - } - - private void updateCategories() - { - getChildren(); - } - - public CategoryAdapter getCategory(int category) - { - if (children == null) - { - updateCategories(); - } - int length = children.size(); - CategoryAdapter adapter = null; - for (int index = 0; index < length; index++) - { - adapter = (CategoryAdapter)children.get(index); - if (adapter.getGroupType() == category) - { - break; - } - } - return adapter; - } - - public String[] getActions(Object object) - { - Collection actionIDs = new ArrayList(); - - actionIDs.add(DeleteAction.ID); - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(SetInputToGraphView.ID); - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(ShowPropertiesViewAction.ID); - - return (String[])actionIDs.toArray(new String [0]); - } - - public void propertyChanged(Object object, String property) - { - notifyListeners(object, property); - } - - public Image getImage() - { - return XSDEditorPlugin.getXSDImage("icons/XSDRedefine.gif"); //$NON-NLS-1$ - } - - private List getCategoryChildren(int category) - { - List list = new ArrayList(); - XSDRedefine redefine = (XSDRedefine)target; - Iterator iterator = redefine.getContents().iterator(); - while (iterator.hasNext()) - { - XSDRedefineContent redefineContent = (XSDRedefineContent)iterator.next(); - - if (redefineContent instanceof XSDAttributeGroupDefinition && category == CategoryAdapter.ATTRIBUTES) - { - list.add(redefineContent); - } - else if (redefineContent instanceof XSDModelGroupDefinition && category == CategoryAdapter.GROUPS) - { - list.add(redefineContent); - } - else if (redefineContent instanceof XSDComplexTypeDefinition && category == CategoryAdapter.TYPES) - { - list.add(redefineContent); - } - else if (redefineContent instanceof XSDSimpleTypeDefinition && category == CategoryAdapter.TYPES) - { - list.add(redefineContent); - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return adapterList; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java deleted file mode 100644 index fe30e58473..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java +++ /dev/null @@ -1,537 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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 - * Tada Takatoshi / Fujitsu - bug 245480 - provided initial patch - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.adapters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.NotificationImpl; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObjectListener; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDComplexTypeDefinitionAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDPackage; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDSchemaAdapter extends XSDBaseAdapter implements IActionProvider, IModel, IADTObjectListener -{ - protected List types = null; - protected List children, allChildren; - - protected CategoryAdapter fDirectivesCategory; - protected CategoryAdapter fElementsCategory; - protected CategoryAdapter fAttributesCategory; - protected CategoryAdapter fTypesCategory; - protected CategoryAdapter fGroupsCategory; - - /** - * Create all the category adapters - * - * @param xsdSchema - */ - protected void createCategoryAdapters(XSDSchema xsdSchema) - { - List directivesList = getDirectives(xsdSchema); - List elementsList = getGlobalElements(xsdSchema); - List attributesList = getAttributeList(xsdSchema); - List groups = getGroups(xsdSchema); - List types = getComplexTypes(xsdSchema); - types.addAll(getSimpleTypes(xsdSchema)); - - fDirectivesCategory = new CategoryAdapter(Messages._UI_GRAPH_DIRECTIVES, XSDEditorPlugin.getDefault().getIconImage("obj16/directivesheader"), directivesList, xsdSchema, CategoryAdapter.DIRECTIVES); //$NON-NLS-1$ - fDirectivesCategory.setAllChildren(directivesList); - registerListener(fDirectivesCategory); - - fElementsCategory = new CategoryAdapter(Messages._UI_GRAPH_ELEMENTS, XSDEditorPlugin.getDefault().getIconImage("obj16/elementsheader"), elementsList, xsdSchema, CategoryAdapter.ELEMENTS); //$NON-NLS-1$ - fElementsCategory.setAllChildren(getGlobalElements(xsdSchema, true)); - registerListener(fElementsCategory); - - fAttributesCategory = new CategoryAdapter(Messages._UI_GRAPH_ATTRIBUTES, XSDEditorPlugin.getDefault().getIconImage("obj16/attributesheader"), attributesList, xsdSchema, CategoryAdapter.ATTRIBUTES); //$NON-NLS-1$ - fAttributesCategory.setAllChildren(getAttributeList(xsdSchema,true)); - registerListener(fAttributesCategory); - - fTypesCategory = new CategoryAdapter(Messages._UI_GRAPH_TYPES, XSDEditorPlugin.getDefault().getIconImage("obj16/typesheader"), types, xsdSchema, CategoryAdapter.TYPES); //$NON-NLS-1$ - fTypesCategory.setAllChildren(getTypes(xsdSchema, true)); - registerListener(fTypesCategory); - - fGroupsCategory = new CategoryAdapter(Messages._UI_GRAPH_GROUPS, XSDEditorPlugin.getDefault().getIconImage("obj16/groupsheader"), groups, xsdSchema, CategoryAdapter.GROUPS); //$NON-NLS-1$ - fGroupsCategory.setAllChildren(getGroups(xsdSchema,true)); - registerListener(fGroupsCategory); - } - - public List getTypes() - { - if (types == null) - { - types = new ArrayList(); - XSDSchema schema = (XSDSchema) target; - List concreteComponentList = new ArrayList(); - for (Iterator i = schema.getContents().iterator(); i.hasNext();) - { - XSDConcreteComponent component = (XSDConcreteComponent) i.next(); - if (component instanceof XSDTypeDefinition) - { - concreteComponentList.add(component); - } - } - populateAdapterList(concreteComponentList, types); - } - return types; - } - - protected boolean isSameNamespace(String ns1, String ns2) - { - if (ns1 == null) ns1 = ""; - if (ns2 == null) ns2 = ""; - - if (ns1.equals(ns2)) - { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getChildren() - */ - public ITreeElement[] getChildren() - { - XSDSchema xsdSchema = (XSDSchema) getTarget(); - - children = new ArrayList(); - - // just set categoryadapters' children if category adapters are - // already created - if (fDirectivesCategory != null) - { - List directivesList = getDirectives(xsdSchema); - List elementsList = getGlobalElements(xsdSchema); - List attributesList = getAttributeList(xsdSchema); - List groups = getGroups(xsdSchema); - List types = getComplexTypes(xsdSchema); - types.addAll(getSimpleTypes(xsdSchema)); - - fDirectivesCategory.setChildren(directivesList); - fDirectivesCategory.setAllChildren(directivesList); - fElementsCategory.setChildren(elementsList); - fElementsCategory.setAllChildren(getGlobalElements(xsdSchema, true)); - fAttributesCategory.setChildren(attributesList); - fAttributesCategory.setAllChildren(getAttributeList(xsdSchema, true)); - fTypesCategory.setChildren(types); - fTypesCategory.setAllChildren(getTypes(xsdSchema, true)); - fGroupsCategory.setChildren(groups); - fGroupsCategory.setAllChildren(getGroups(xsdSchema, true)); - } - else - { - createCategoryAdapters(xsdSchema); - } - - children.add(fDirectivesCategory); - children.add(fElementsCategory); - children.add(fAttributesCategory); - children.add(fTypesCategory); - children.add(fGroupsCategory); - - return (ITreeElement[]) children.toArray(new ITreeElement[0]); - } - - public void notifyChanged(final Notification msg) - { - class CategoryNotification extends NotificationImpl - { - protected Object category; - - public CategoryNotification(Object category) - { - super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition()); - this.category = category; - } - - public Object getNotifier() - { - return category; - } - - public Object getFeature() - { - return msg.getFeature(); - } - } - - if (children == null) - { - getChildren(); - } - - Object newValue = msg.getNewValue(); - - Object oldValue = msg.getOldValue(); - // Bug 245480 - Deletion of Include, Import and Redefine is not reflected in the Outline view - // We only want to refresh the Directives folder for any changes to XSDDirectives. The first case covers - // changes to one directive, whereas the missing case as reported in bug 245480 covers changes to a list - // of directives. - boolean updateDirectivesCategory = false; - if (oldValue instanceof XSDSchemaDirective) - { - updateDirectivesCategory = true; - } - else if (oldValue instanceof Collection) - { - Iterator iterator = ((Collection) oldValue).iterator(); - while (iterator.hasNext()) - { - Object obj = iterator.next(); - if (obj instanceof XSDSchemaDirective) - { - // if we find at least one directive, then we should refresh the folder - updateDirectivesCategory = true; - break; - } - } - } - - if (newValue instanceof XSDInclude || newValue instanceof XSDImport || newValue instanceof XSDRedefine || - (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Contents() && updateDirectivesCategory) || // handle the case for delete directive - msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_IncorporatedVersions()) // updates to the imports/includes - { - CategoryAdapter adapter = getCategory(CategoryAdapter.DIRECTIVES); - Assert.isTrue(adapter != null); - XSDSchema xsdSchema = adapter.getXSDSchema(); - adapter.setChildren(getDirectives(xsdSchema)); - adapter.setAllChildren(getDirectives(xsdSchema)); - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ElementDeclarations()) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.ELEMENTS); - Assert.isTrue(adapter != null); - XSDSchema xsdSchema = adapter.getXSDSchema(); - adapter.setChildren(getGlobalElements(xsdSchema)); - adapter.setAllChildren(getGlobalElements(xsdSchema, true)); - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeDeclarations() || - msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeGroupDefinitions()) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES); - Assert.isTrue(adapter != null); - XSDSchema xsdSchema = adapter.getXSDSchema(); - adapter.setChildren(getAttributeList(xsdSchema)); - adapter.setAllChildren(getAttributeList(xsdSchema, true)); - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_TypeDefinitions()) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES); - Assert.isTrue(adapter != null); - XSDSchema xsdSchema = adapter.getXSDSchema(); - List types = getComplexTypes(xsdSchema); - types.addAll(getSimpleTypes(xsdSchema)); - - adapter.setChildren(types); - adapter.setAllChildren(getTypes(xsdSchema, true)); - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ModelGroupDefinitions()) - { - CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS); - Assert.isTrue(adapter != null); - XSDSchema xsdSchema = adapter.getXSDSchema(); - adapter.setChildren(getGroups(xsdSchema)); - adapter.setAllChildren(getGroups(xsdSchema, true)); - notifyListeners(new CategoryNotification(adapter), adapter.getText()); - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) - { - return; - } - else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_SchemaLocation()) - { - notifyListeners(msg, null); - return; - } - - types = null; - getTypes(); - - super.notifyChanged(msg); - } - - public void updateCategories() - { - // TODO: revisit this - getChildren(); - } - - public CategoryAdapter getCategory(int category) - { - if (children == null) updateCategories(); // init categories - int length = children.size(); - CategoryAdapter adapter = null; - for (int i = 0; i < length; i++) - { - adapter = (CategoryAdapter) children.get(i); - if (adapter.getGroupType() == category) - { - break; - } - } - return adapter; - } - - public List getDirectives(XSDSchema schema) - { - List list = new ArrayList(); - for (Iterator i = schema.getContents().iterator(); i.hasNext();) - { - Object o = i.next(); - if (o instanceof XSDSchemaDirective) - { - list.add(o); - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return adapterList; - } - - public List getGlobalElements(XSDSchema schema, boolean showFromIncludes) - { - List elements = schema.getElementDeclarations(); - List list = new ArrayList(); - for (Iterator i = elements.iterator(); i.hasNext();) - { - XSDElementDeclaration elem = (XSDElementDeclaration) i.next(); - if (shouldShowComponent(elem, schema, showFromIncludes)) - { - list.add(elem); - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return adapterList; - } - - public List getGlobalElements(XSDSchema schema) - { - return getGlobalElements(schema, false); - } - - /** - * @param schema - * @return - */ - public List getComplexTypes(XSDSchema schema, boolean showFromIncludes) - { - List allTypes = schema.getTypeDefinitions(); - List list = new ArrayList(); - for (Iterator i = allTypes.iterator(); i.hasNext();) - { - XSDTypeDefinition td = (XSDTypeDefinition) i.next(); - if (td instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) td; - if (shouldShowComponent(ct, schema, showFromIncludes)) - { - list.add(ct); - } - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return adapterList; - } - - public List getComplexTypes(XSDSchema schema) - { - return getComplexTypes(schema, false); - } - - public List getTypes(XSDSchema schema, boolean showFromIncludes) - { - List list = getComplexTypes(schema, showFromIncludes); - list.addAll(getSimpleTypes(schema, showFromIncludes)); - return list; - } - - public List getAttributeGroupList(XSDSchema xsdSchema, boolean showFromIncludes) - { - List attributeGroupList = new ArrayList(); - for (Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator(); i.hasNext();) - { - XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) i.next(); - if (shouldShowComponent(attrGroup, xsdSchema, showFromIncludes)) - { - attributeGroupList.add(attrGroup); - } - } - List adapterList = new ArrayList(); - populateAdapterList(attributeGroupList, adapterList); - return adapterList; - } - - public List getAttributeGroupList(XSDSchema xsdSchema) - { - return getAttributeGroupList(xsdSchema, false); - } - - public List getAttributeList(XSDSchema xsdSchema, boolean showFromIncludes) - { - List attributesList = new ArrayList(); - for (Iterator iter = xsdSchema.getAttributeDeclarations().iterator(); iter.hasNext();) - { - Object o = iter.next(); - if (o instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration attr = (XSDAttributeDeclaration) o; - if (attr != null) - { - if (attr.getTargetNamespace() != null) - { - if (!(attr.getTargetNamespace().equals(XSDConstants.SCHEMA_INSTANCE_URI_2001))) - { - if (shouldShowComponent(attr, xsdSchema,showFromIncludes)) - { - attributesList.add(attr); - } - } - } - else - { - if (shouldShowComponent(attr, xsdSchema,showFromIncludes)) - { - attributesList.add(attr); - } - } - } - } - } - - attributesList.addAll(getAttributeGroupList(xsdSchema, showFromIncludes)); - - List adapterList = new ArrayList(); - populateAdapterList(attributesList, adapterList); - return adapterList; - } - - public List getAttributeList(XSDSchema xsdSchema) - { - return getAttributeList(xsdSchema, false); - } - - public List getSimpleTypes(XSDSchema schema, boolean showFromIncludes) - { - List allTypes = schema.getTypeDefinitions(); - List list = new ArrayList(); - for (Iterator i = allTypes.iterator(); i.hasNext();) - { - XSDTypeDefinition td = (XSDTypeDefinition) i.next(); - if (td instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) td; - if (shouldShowComponent(st, schema, showFromIncludes)) - { - list.add(st); - } - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return adapterList; - } - - public List getSimpleTypes(XSDSchema schema) - { - return getSimpleTypes(schema, false); - } - - public List getGroups(XSDSchema schema, boolean showFromIncludes) - { - List groups = schema.getModelGroupDefinitions(); - List list = new ArrayList(); - for (Iterator i = groups.iterator(); i.hasNext();) - { - XSDModelGroupDefinition group = (XSDModelGroupDefinition) i.next(); - if (shouldShowComponent(group, schema, showFromIncludes)) - { - list.add(group); - } - } - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return adapterList; - } - - public List getGroups(XSDSchema schema) - { - return getGroups(schema, false); - } - - public String[] getActions(Object object) - { - Collection actionIDs = new ArrayList(); - actionIDs.add(AddXSDElementAction.ID); - actionIDs.add(AddXSDComplexTypeDefinitionAction.ID); - - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(ShowPropertiesViewAction.ID); - return (String [])actionIDs.toArray(new String[0]); - } - - public void propertyChanged(Object object, String property) - { - notifyListeners(object, property); - } - - public Image getImage() - { - return XSDEditorPlugin.getXSDImage("icons/XSDFile.gif"); //$NON-NLS-1$ - } - - protected boolean shouldShowComponent(XSDNamedComponent component, XSDSchema schema, boolean showFromIncludes) - { - return isSameNamespace(component.getTargetNamespace(), schema.getTargetNamespace()) && (component.getRootContainer() == schema || showFromIncludes); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaDirectiveAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaDirectiveAdapter.java deleted file mode 100644 index d7e89eb4ae..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaDirectiveAdapter.java +++ /dev/null @@ -1,131 +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.adapters; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; - -public class XSDSchemaDirectiveAdapter extends XSDBaseAdapter implements IActionProvider, IGraphElement -{ - public Image getImage() - { - XSDSchemaDirective object = (XSDSchemaDirective) target; - if (object instanceof XSDImport) - { - return XSDEditorPlugin.getXSDImage("icons/XSDImport.gif"); //$NON-NLS-1$ - } - else if (object instanceof XSDInclude) - { - return XSDEditorPlugin.getXSDImage("icons/XSDInclude.gif"); //$NON-NLS-1$ - } - else if (object instanceof XSDRedefine) - { - return XSDEditorPlugin.getXSDImage("icons/XSDRedefine.gif"); //$NON-NLS-1$ - } - return null; - } - - public String getText() - { - XSDSchemaDirective directive = (XSDSchemaDirective) target; - String result = ""; - - String location = directive.getSchemaLocation(); - if (location == null || location.equals("") ) - { - result = "(" + Messages._UI_LABEL_NO_LOCATION_SPECIFIED + ")"; - } - else - { - result = location; - } - - // only show the namespace when the directiave is an import - // (otherwise the namespace is obviously the same as the containing schema's) - if (directive instanceof XSDImport) - { - XSDImport importObj = (XSDImport) directive; - String namespace = importObj.getNamespace(); - if (namespace != null) - { - result += " {" + namespace + "}"; - } - } - return result; - } - - public ITreeElement[] getChildren() - { - List list = new ArrayList(); - - List adapterList = new ArrayList(); - populateAdapterList(list, adapterList); - return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]); - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - list.add(OpenInNewEditor.ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - - return (String [])list.toArray(new String[0]); - } - - public Command getDeleteCommand() - { - XSDSchemaDirective object = (XSDSchemaDirective) target; - return new DeleteCommand(object); - } - - public IModel getModel() - { - XSDSchema object = ((XSDSchemaDirective) target).getSchema(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(object); - return (IModel)adapter; - } - - public IADTObject getTopContainer() - { - // There is currently no drill-down details view of directives - // The top level container is the schema - return getModel(); - } - - public boolean isFocusAllowed() - { - return false; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSimpleContentAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSimpleContentAdapter.java deleted file mode 100644 index a66f6a9fab..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSimpleContentAdapter.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.adapters; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -public class XSDSimpleContentAdapter extends XSDBaseAdapter implements IActionProvider, IGraphElement -{ - - public XSDSimpleContentAdapter() - { - } - - public XSDSimpleTypeDefinition getXSDSimpleTypeContent() - { - return (XSDSimpleTypeDefinition)target; - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - return (String [])list.toArray(new String[0]); - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDSimpleTypeContent()); - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDSimpleTypeContent().getSchema()); - return (IModel)adapter; - } - - public IADTObject getTopContainer() - { - XSDConcreteComponent c = getXSDSimpleTypeContent().getContainer(); - if (c instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) c; - Adapter adapter = XSDAdapterFactory.getInstance().adapt(ct); - if (adapter instanceof IADTObject) - return (IADTObject)adapter; - } - - return null; - } - - public boolean isFocusAllowed() - { - return false; - } - - public Image getImage() - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDSimpleContent.gif"); //$NON-NLS-1$ - } - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDSimpleContent.gif"); //$NON-NLS-1$ - } - - public String getText() - { - return ""; - } - - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSimpleTypeDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSimpleTypeDefinitionAdapter.java deleted file mode 100644 index 105c362866..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSimpleTypeDefinitionAdapter.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.SetInputToGraphView; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDEnumerationFacetAction; -import org.eclipse.wst.xsd.ui.internal.common.actions.OpenInNewEditor; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetBaseTypeAction; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDVariety; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDSimpleTypeDefinitionAdapter extends XSDTypeDefinitionAdapter -{ - protected boolean readOnly; - protected boolean changeReadOnlyField =false; - protected HashMap deletedTypes = new HashMap(); - public Image getImage() - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/simpletypedis_obj.gif"); //$NON-NLS-1$ - } - return XSDEditorPlugin.getPlugin().getIcon("obj16/simpletype_obj.gif"); //$NON-NLS-1$ - } - - public String getDisplayName() - { - return getName(); - } - - public String getText() - { - return getText(true); - } - - public String getText(boolean showType) - { - XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target; - - StringBuffer result = new StringBuffer(); - - result.append(xsdSimpleTypeDefinition.getName() == null ? Messages._UI_LABEL_LOCAL_TYPE : xsdSimpleTypeDefinition.getName()); - - if (showType) - { - XSDSimpleTypeDefinition baseTypeDefinition = xsdSimpleTypeDefinition.getBaseTypeDefinition(); - if (baseTypeDefinition != null && XSDVariety.ATOMIC_LITERAL == xsdSimpleTypeDefinition.getVariety()) - { - if (baseTypeDefinition.getName() != null && !xsdSimpleTypeDefinition.getContents().contains(baseTypeDefinition) && !XSDConstants.isAnySimpleType(baseTypeDefinition)) - { - try { - String qName = baseTypeDefinition.getQName(xsdSimpleTypeDefinition); - result.append(" : "); //$NON-NLS-1$ - result.append(qName); - } - catch (Exception e) - { - } - } - } - else - { - XSDSimpleTypeDefinition itemTypeDefinition = xsdSimpleTypeDefinition.getItemTypeDefinition(); - if (itemTypeDefinition != null) - { - if (itemTypeDefinition.getName() != null) - { - result.append(" : "); //$NON-NLS-1$ - result.append(itemTypeDefinition.getQName(xsdSimpleTypeDefinition)); - } - } - else - { - List memberTypeDefinitions = xsdSimpleTypeDefinition.getMemberTypeDefinitions(); - if (!memberTypeDefinitions.isEmpty()) - { - boolean first = true; - for (Iterator members = memberTypeDefinitions.iterator(); members.hasNext();) - { - XSDSimpleTypeDefinition memberTypeDefinition = (XSDSimpleTypeDefinition) members.next(); - if (memberTypeDefinition.getName() != null) - { - if (first) - { - result.append(" : "); //$NON-NLS-1$ - first = false; - } - else - { - result.append(" | "); //$NON-NLS-1$ - } - result.append(memberTypeDefinition.getQName(xsdSimpleTypeDefinition)); - } - else - { - break; - } - } - } - else if (result.length() == 0) - { - result.append(Messages._UI_LABEL_ABSENT); - } - } - } - } - - return result.toString(); - } - - public boolean hasChildren() - { - return true; - } - - public boolean isComplexType() - { - return false; - } - - public boolean isFocusAllowed() - { - XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target; - if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace())) - { - return false; - } - if (xsdSimpleTypeDefinition.getName() == null) - { - return isAnonymous(); - } - return true; - } - - public String[] getActions(Object object) - { - List list = new ArrayList(); - list.add(AddXSDEnumerationFacetAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(SetBaseTypeAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(DeleteAction.ID); - list.add(BaseSelectionAction.SEPARATOR_ID); - Object schema = getEditorSchema(); - XSDTypeDefinition typeDefinition = getXSDTypeDefinition(); - if (typeDefinition.getSchema() == schema) - { - XSDConcreteComponent container = typeDefinition.getContainer(); - if (container == schema || container instanceof XSDRedefine) - { - list.add(SetInputToGraphView.ID); - } - } - else - { - list.add(OpenInNewEditor.ID); - } - list.add(BaseSelectionAction.SEPARATOR_ID); - list.add(ShowPropertiesViewAction.ID); - - return (String [])list.toArray(new String[0]); - } - - public boolean isAnonymous() - { - XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target; - EObject eContainer = xsdSimpleTypeDefinition.eContainer(); - return !(eContainer instanceof XSDSchema || - eContainer instanceof XSDRedefine); - } - - public IADTObject getTopContainer() - { - return this; - } - - public Command getDeleteCommand() - { - return new DeleteCommand(getXSDTypeDefinition()); - } - - public IModel getModel() - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(getXSDTypeDefinition().getSchema()); - return (IModel)adapter; - } - - public ITreeElement[] getChildren() - { - List adapterList = new ArrayList(); - XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target; - List list = xsdSimpleTypeDefinition.getEnumerationFacets(); - populateAdapterList(list, adapterList); - return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]); - } - public boolean isReadOnly() - { - XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) target; - if (hasSetReadOnlyField()) - { - deletedTypes.put(xsdSimpleTypeDefinition.getName(), new Boolean(true)); - changeReadOnlyField = false; - return readOnly; - } - else - { - if (deletedTypes!= null ) - { - Boolean deleted = ((Boolean)deletedTypes.get(xsdSimpleTypeDefinition.getName())); - if (deleted != null && deleted.booleanValue()) - return true; - else return super.isReadOnly(); - } - else - return super.isReadOnly(); - } - - - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - public boolean hasSetReadOnlyField() { - return changeReadOnlyField; - } - - public void setChangeReadOnlyField(boolean setReadOnlyField) { - this.changeReadOnlyField = setReadOnlyField; - } - - public void updateDeletedMap(String addComponent) { - if (deletedTypes.get(addComponent) != null) - deletedTypes.clear(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDTypeDefinitionAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDTypeDefinitionAdapter.java deleted file mode 100644 index 7ecd548cc6..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDTypeDefinitionAdapter.java +++ /dev/null @@ -1,69 +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.adapters; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.commands.Command; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; - -public abstract class XSDTypeDefinitionAdapter extends XSDBaseAdapter implements IType, IActionProvider, IGraphElement -{ - public XSDTypeDefinition getXSDTypeDefinition() - { - return (XSDTypeDefinition)target; - } - - public String getName() - { - EObject eContainer = getXSDTypeDefinition().eContainer(); - if (eContainer instanceof XSDSchema || eContainer instanceof XSDRedefine) - { - return getXSDTypeDefinition().getName(); - } - else - { - if (eContainer instanceof XSDNamedComponent) - { - XSDNamedComponent ed = (XSDNamedComponent)eContainer; - return "(" + ed.getName() + "Type)"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - return null; - } - - public String getQualifier() - { - return getXSDTypeDefinition().getTargetNamespace(); - } - - public IType getSuperType() - { - XSDTypeDefinition td = getXSDTypeDefinition().getBaseType(); - return td != null ? (IType)XSDAdapterFactory.getInstance().adapt(td) : null; - } - - public Command getUpdateNameCommand(String newName) - { - // TODO Auto-generated method stub - return null; - } - - public boolean isComplexType() - { - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDVisitor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDVisitor.java deleted file mode 100644 index 5e2b5c15b4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDVisitor.java +++ /dev/null @@ -1,247 +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.adapters; - -import java.util.Iterator; -import java.util.Stack; - -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeContent; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDIdentityConstraintDefinition; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDNotationDeclaration; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDParticleContent; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDWildcard; - -public class XSDVisitor -{ - public XSDVisitor() - { - circularDefinitionFound = false; - visitedGroups = new Stack(); - } - - public boolean circularDefinitionFound = false; - protected XSDSchema schema; - protected Stack visitedGroups = new Stack(); - - public void visitSchema(XSDSchema schema) - { - this.schema = schema; - for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext();) - { - XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next(); - visitAttributeDeclaration(attr); - } - for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext();) - { - XSDTypeDefinition type = (XSDTypeDefinition) iterator.next(); - visitTypeDefinition(type); - } - for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext();) - { - XSDElementDeclaration element = (XSDElementDeclaration) iterator.next(); - visitElementDeclaration(element); - } - for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext();) - { - XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next(); - visitIdentityConstraintDefinition(identityConstraint); - } - for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext();) - { - XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next(); - visitModelGroupDefinition(modelGroup); - } - for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext();) - { - XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next(); - visitAttributeGroupDefinition(attributeGroup); - } - for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext();) - { - XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next(); - visitNotationDeclaration(element); - } - - } - - public void visitAttributeDeclaration(XSDAttributeDeclaration attr) - { - } - - public void visitTypeDefinition(XSDTypeDefinition type) - { - if (type instanceof XSDSimpleTypeDefinition) - { - visitSimpleTypeDefinition((XSDSimpleTypeDefinition)type); - } - else if (type instanceof XSDComplexTypeDefinition) - { - visitComplexTypeDefinition((XSDComplexTypeDefinition)type); - } - } - - public void visitElementDeclaration(XSDElementDeclaration element) - { - if (element.isElementDeclarationReference()) - { - visitElementDeclaration(element.getResolvedElementDeclaration()); - } - else if (element.getAnonymousTypeDefinition() != null) - { - visitTypeDefinition(element.getAnonymousTypeDefinition()); - } - } - - public void visitIdentityConstraintDefinition(XSDIdentityConstraintDefinition identityConstraint) - { - } - - public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) - { - if (!modelGroupDef.isModelGroupDefinitionReference()) - { - if (modelGroupDef.getModelGroup() != null) - { - if ((visitedGroups.contains(modelGroupDef.getResolvedModelGroupDefinition().getModelGroup()))) - { - circularDefinitionFound = true; - return; - } - visitedGroups.push(modelGroupDef.getModelGroup()); - visitModelGroup(modelGroupDef.getModelGroup()); - visitedGroups.pop(); - } - } - else - { - XSDModelGroupDefinition resolvedGroupDef = modelGroupDef.getResolvedModelGroupDefinition(); - XSDModelGroup modelGroup = resolvedGroupDef.getModelGroup(); - - if ((visitedGroups.contains(modelGroup))) - { - circularDefinitionFound = true; - return; - } - - visitedGroups.push(modelGroup); - if (modelGroup != null) - { - visitModelGroup(modelGroup); - } - visitedGroups.pop(); - } - } - - public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) - { - for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext(); ) - { - Object o = it.next(); - if (o instanceof XSDAttributeUse) - { - XSDAttributeUse attrUse = (XSDAttributeUse)o; - visitAttributeDeclaration(attrUse.getContent()); - } - else if (o instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition)o; - visitAttributeGroupDefinition(attrGroup.getResolvedAttributeGroupDefinition()); - } - } - } - - public void visitRedefine(XSDRedefine redefine) - { - - } - - public void visitNotationDeclaration(XSDNotationDeclaration notation) - { - } - - public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type) - { - } - - public void visitComplexTypeContent(XSDSimpleTypeDefinition content) - { - - } - - public void visitComplexTypeDefinition(XSDComplexTypeDefinition type) - { - if (type.getContent() != null) - { - XSDComplexTypeContent complexContent = type.getContent(); - if (complexContent instanceof XSDSimpleTypeDefinition) - { - visitComplexTypeContent((XSDSimpleTypeDefinition)complexContent); - } - else if (complexContent instanceof XSDParticle) - { - visitParticle((XSDParticle) complexContent); - } - } - } - - public void visitParticle(XSDParticle particle) - { - visitParticleContent(particle.getContent()); - } - - public void visitParticleContent(XSDParticleContent particleContent) - { - if (particleContent instanceof XSDModelGroupDefinition) - { - visitModelGroupDefinition((XSDModelGroupDefinition) particleContent); - } - else if (particleContent instanceof XSDModelGroup) - { - visitModelGroup((XSDModelGroup)particleContent); - } - else if (particleContent instanceof XSDElementDeclaration) - { - visitElementDeclaration((XSDElementDeclaration)particleContent); - } - else if (particleContent instanceof XSDWildcard) - { - visitWildcard((XSDWildcard)particleContent); - } - } - - public void visitModelGroup(XSDModelGroup modelGroup) - { - if (modelGroup.getContents() != null) - { - for (Iterator iterator = modelGroup.getContents().iterator(); iterator.hasNext();) - { - XSDParticle particle = (XSDParticle) iterator.next(); - visitParticle(particle); - } - } - } - - public void visitWildcard(XSDWildcard wildcard) - { - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDVisitorForFields.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDVisitorForFields.java deleted file mode 100644 index 48a0f34396..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDVisitorForFields.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupContent; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDWildcard; - -public class XSDVisitorForFields extends XSDVisitor -{ - public XSDVisitorForFields() - { - super(); - } - - public List concreteComponentList = new ArrayList(); - public List thingsWeNeedToListenTo = new ArrayList(); - - public void visitComplexTypeDefinition(XSDComplexTypeDefinition type) - { - if (type.getAttributeContents() != null) - { - for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); ) - { - XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent)iter.next(); - if (attrGroupContent instanceof XSDAttributeUse) - { - XSDAttributeUse attrUse = (XSDAttributeUse)attrGroupContent; - - visitAttributeDeclaration(attrUse.getContent()); - -// if (attrUse.getAttributeDeclaration() != attrUse.getContent()) -// { -// visitAttributeDeclaration(attrUse.getContent()); -// } -// else -// { -// thingsWeNeedToListenTo.add(attrUse.getAttributeDeclaration()); -// concreteComponentList.add(attrUse.getAttributeDeclaration()); -// } - } - else if (attrGroupContent instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition)attrGroupContent; - thingsWeNeedToListenTo.add(attrGroup); - if (attrGroup.isAttributeGroupDefinitionReference()) - { - attrGroup = attrGroup.getResolvedAttributeGroupDefinition(); - visitAttributeGroupDefinition(attrGroup); - } - } - } - } - if (type.getAttributeWildcard() != null) - { - thingsWeNeedToListenTo.add(type.getAttributeWildcard()); - concreteComponentList.add(type.getAttributeWildcard()); - } - super.visitComplexTypeDefinition(type); - } - - public void visitComplexTypeContent(XSDSimpleTypeDefinition content) - { - thingsWeNeedToListenTo.add(content); - - super.visitComplexTypeContent(content); - } - - - public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) - { - // listen to definition in case it changes - XSDModelGroupDefinition resolvedModelGroupDef = modelGroupDef.getResolvedModelGroupDefinition(); - if (visitedGroups.contains(resolvedModelGroupDef.getModelGroup())) return; - - if (modelGroupDef.isModelGroupDefinitionReference()) - { - // if it's a reference we need to listen to the reference incase it changes - if (!thingsWeNeedToListenTo.contains(modelGroupDef)) - thingsWeNeedToListenTo.add(modelGroupDef); - } - super.visitModelGroupDefinition(modelGroupDef); - } - - public void visitModelGroup(XSDModelGroup modelGroup) - { - super.visitModelGroup(modelGroup); - thingsWeNeedToListenTo.add(modelGroup); - } - - public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) - { - for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext(); ) - { - Object o = it.next(); - if (o instanceof XSDAttributeUse) - { - XSDAttributeUse attributeUse = (XSDAttributeUse)o; - concreteComponentList.add(attributeUse.getAttributeDeclaration()); - thingsWeNeedToListenTo.add(attributeUse.getAttributeDeclaration()); - } - else if (o instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition)o; - thingsWeNeedToListenTo.add(attrGroup); - if (attrGroup.isAttributeGroupDefinitionReference()) - { - attrGroup = attrGroup.getResolvedAttributeGroupDefinition(); - visitAttributeGroupDefinition(attrGroup); - } - } - } - - XSDWildcard anyAttribute = attributeGroup.getAttributeWildcardContent(); - if (anyAttribute != null) - { - concreteComponentList.add(anyAttribute); - thingsWeNeedToListenTo.add(anyAttribute); - } - - } - - public void visitParticle(XSDParticle particle) - { - thingsWeNeedToListenTo.add(particle); - super.visitParticle(particle); - } - - public void visitWildcard(XSDWildcard wildcard) - { - concreteComponentList.add(wildcard); - } - - public void visitElementDeclaration(XSDElementDeclaration element) - { - if (element.isElementDeclarationReference()) - { - thingsWeNeedToListenTo.add(element); - thingsWeNeedToListenTo.add(element.getResolvedElementDeclaration()); - // now, add the reference as a field - concreteComponentList.add(element); - } - else - { - concreteComponentList.add(element.getResolvedElementDeclaration()); - // note... we intentionally ommit the call to super.visitElementDeclaration() - // since we don't want to delve down deeper than the element - } - } - - public void visitAttributeDeclaration(XSDAttributeDeclaration attr) - { - if (attr.isAttributeDeclarationReference()) - { - thingsWeNeedToListenTo.add(attr); - thingsWeNeedToListenTo.add(attr.getResolvedAttributeDeclaration()); - concreteComponentList.add(attr); - } - else - { - concreteComponentList.add(attr.getResolvedAttributeDeclaration()); - thingsWeNeedToListenTo.add(attr.getResolvedAttributeDeclaration()); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDWildcardAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDWildcardAdapter.java deleted file mode 100644 index 1d9c140ee9..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDWildcardAdapter.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 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.adapters; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.DeleteAction; -import org.eclipse.wst.xsd.ui.internal.adt.actions.ShowPropertiesViewAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel; -import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDWildcardAdapter extends XSDParticleAdapter implements IField, IActionProvider, IGraphElement -{ -// public static final Image ANYELEMENT_ICON = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAny.gif"); //$NON-NLS-1$ -// public static final Image ANYELEMENT_DISABLED_ICON = XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAny.gif"); //$NON-NLS-1$ - - public XSDWildcardAdapter() - { - - } - - public Image getImage() - { - XSDWildcard xsdWildcard = (XSDWildcard) target; - - if (xsdWildcard.eContainer() instanceof XSDParticle) - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAnydis.gif"); //$NON-NLS-1$ - } - return XSDEditorPlugin.getXSDImage("icons/XSDAny.gif"); //$NON-NLS-1$ - } - else - { - if (isReadOnly()) - { - return XSDEditorPlugin.getPlugin().getIcon("obj16/XSDAnyAttributedis.gif"); //$NON-NLS-1$ - } - return XSDEditorPlugin.getXSDImage("icons/XSDAnyAttribute.gif"); //$NON-NLS-1$ - } - } - - public String getText() - { - XSDWildcard xsdWildcard = (XSDWildcard) target; - - StringBuffer result = new StringBuffer(); - Element element = xsdWildcard.getElement(); - - if (element != null) - { - result.append(element.getNodeName()); - boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE); - boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE); - - if (hasMinOccurs || hasMaxOccurs) - { - result.append(" ["); //$NON-NLS-1$ - if (hasMinOccurs) - { - - int min = ((XSDParticle) xsdWildcard.getContainer()).getMinOccurs(); - if (min == XSDParticle.UNBOUNDED) - { - result.append("*"); //$NON-NLS-1$ - } - else - { - result.append(String.valueOf(min)); - } - } - else - // print default - { - int min = ((XSDParticle) xsdWildcard.getContainer()).getMinOccurs(); - result.append(String.valueOf(min)); - } - if (hasMaxOccurs) - { - int max = ((XSDParticle) xsdWildcard.getContainer()).getMaxOccurs(); - result.append(".."); //$NON-NLS-1$ - if (max == XSDParticle.UNBOUNDED) - { - result.append("*"); //$NON-NLS-1$ - } - else - { - result.append(String.valueOf(max)); - } - } - else - // print default - { - result.append(".."); //$NON-NLS-1$ - int max = ((XSDParticle) xsdWildcard.getContainer()).getMaxOccurs(); - result.append(String.valueOf(max)); - } - result.append("]"); //$NON-NLS-1$ - } - } - return result.toString(); - - } - - public boolean hasChildren() - { - return false; - } - - public Object getParent(Object object) - { - XSDWildcard xsdWildcard = (XSDWildcard) target; - return xsdWildcard.getContainer(); - } - - public Command getDeleteCommand() - { - return new DeleteCommand((XSDWildcard) target); - } - - public String getKind() - { - XSDWildcard xsdWildcard = (XSDWildcard) target; - if (xsdWildcard.eContainer() instanceof XSDParticle) - { - return "element"; //$NON-NLS-1$ - } - return "attribute"; - } - - public IModel getModel() - { - return null; - } - - public String getName() - { - XSDWildcard xsdWildcard = (XSDWildcard) target; - if (xsdWildcard.eContainer() instanceof XSDParticle) - { - return "any"; //$NON-NLS-1$ - } - return "anyAttribute"; //$NON-NLS-1$ - } - - public IType getType() - { - return null; - } - - public String getTypeName() - { - return ""; //$NON-NLS-1$ - } - - public String getTypeNameQualifier() - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateMaxOccursCommand(int maxOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateMinOccursCommand(int minOccurs) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateNameCommand(String name) - { - // TODO Auto-generated method stub - return null; - } - - public Command getUpdateTypeNameCommand(String typeName, String quailifier) - { - // TODO Auto-generated method stub - return null; - } - - public boolean isGlobal() - { - return false; - } - - public boolean isReference() - { - return false; - } - - public String[] getActions(Object object) - { - Collection actionIDs = new ArrayList(); - actionIDs.add(DeleteAction.ID); - actionIDs.add(BaseSelectionAction.SEPARATOR_ID); - actionIDs.add(ShowPropertiesViewAction.ID); - return (String [])actionIDs.toArray(new String[0]); - } - - public IADTObject getTopContainer() - { - return getGlobalXSDContainer((XSDWildcard) target); - } - - public boolean isFocusAllowed() - { - return false; - } -} |