Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java360
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java75
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/IXSDToolbarAction.java19
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDAttributeAction.java248
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDBaseAction.java28
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDElementAction.java173
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java292
7 files changed, 0 insertions, 1195 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java
deleted file mode 100644
index 15f3b73146..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/CreateElementAction.java
+++ /dev/null
@@ -1,360 +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.actions;
-import java.util.List;
-
-import org.eclipse.gef.ui.parts.AbstractEditPartViewer;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-// issue (cs) can we remove this?
-//
-public class CreateElementAction extends Action
-{
- protected String description;
- protected Element parentNode;
-
- protected ISelectionProvider selectionProvider;
- protected XSDSchema xsdSchema;
-
- protected Object sourceContext;
-
- /**
- * Constructor for CreateElementAction.
- */
- public CreateElementAction()
- {
- super();
- }
- /**
- * Constructor for CreateElementAction.
- * @param text
- */
- public CreateElementAction(String text)
- {
- super(text);
- }
- /**
- * Constructor for CreateElementAction.
- * @param text
- * @param image
- */
- public CreateElementAction(String text, ImageDescriptor image)
- {
- super(text, image);
- }
-
- public void setXSDSchema(XSDSchema xsdSchema)
- {
- this.xsdSchema = xsdSchema;
- }
-
- public void setSelectionProvider(ISelectionProvider selectionProvider)
- {
- this.selectionProvider = selectionProvider;
- }
-
- public void setSourceContext(Object sourceContext)
- {
- this.sourceContext = sourceContext;
- }
-
- /**
- * Gets the parentNode.
- * @return Returns a Element
- */
- public Element getParentNode()
- {
- return parentNode;
- }
-
- /**
- * Sets the parentNode.
- * @param parentNode The parentNode to set
- */
- public void setParentNode(Element parentNode)
- {
- this.parentNode = parentNode;
- }
-
- boolean isGlobal = false;
-
- public void setIsGlobal(boolean isGlobal)
- {
- this.isGlobal = isGlobal;
- }
-
- public boolean getIsGlobal()
- {
- return isGlobal;
- }
-
- protected Node relativeNode;
- protected String elementTag;
- public void setElementTag(String elementTag)
- {
- this.elementTag = elementTag;
- }
-
- public DocumentImpl getDocument()
- {
- return (DocumentImpl) getParentNode().getOwnerDocument();
- }
-
- public void beginRecording(String description)
- {
- getDocument().getModel().beginRecording(this, description);
- }
-
- public void endRecording()
- {
- DocumentImpl doc = getDocument();
-
- doc.getModel().endRecording(this);
- }
-
- public Element createAndAddNewChildElement()
- {
- String prefix = parentNode.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":"); //$NON-NLS-1$ //$NON-NLS-2$
- Element childNode = getDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + elementTag);
- if (getAttributes() != null)
- {
- List attributes = getAttributes();
- for (int i = 0; i < attributes.size(); i++)
- {
- DOMAttribute attr = (DOMAttribute) attributes.get(i);
- childNode.setAttribute(attr.getName(), attr.getValue());
- }
- }
- if (getRelativeNode() == null)
- {
- parentNode.appendChild(childNode);
- }
- else
- {
- parentNode.insertBefore(childNode,getRelativeNode());
- }
-
- if (isGlobal && getRelativeNode() == null)
- {
- Text textNode = getDocument().createTextNode("\n\n"); //$NON-NLS-1$
- parentNode.appendChild(textNode);
- }
- else if (isGlobal && getRelativeNode() != null)
- {
- Text textNode = getDocument().createTextNode("\n\n"); //$NON-NLS-1$
- parentNode.insertBefore(textNode, getRelativeNode());
- }
-
- formatChild(childNode);
-
- return childNode;
- }
-
- protected void formatChild(Element child)
- {
- if (child instanceof IDOMNode)
- {
- IDOMModel model = ((IDOMNode)child).getModel();
- try
- {
- // tell the model that we are about to make a big model change
- model.aboutToChangeModel();
-
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(child);
- }
- finally
- {
- // tell the model that we are done with the big model change
- model.changedModel();
- }
- }
- }
- /*
- * @see IAction#run()
- */
- public void run()
- {
- beginRecording(getDescription());
- final Element child = createAndAddNewChildElement();
- endRecording();
-
- if (selectionProvider != null)
- {
- final XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(child);
-// selectionProvider.setSelection(new StructuredSelection(comp));
-
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- if (comp instanceof XSDAttributeDeclaration)
- {
- if (((XSDAttributeDeclaration)comp).getContainer() instanceof XSDAttributeUse)
- {
- if (comp.getContainer().getContainer() instanceof XSDAttributeGroupDefinition)
- {
- selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
- }
- else if (comp.getContainer().getContainer() instanceof XSDComplexTypeDefinition)
- {
- if (XSDDOMHelper.inputEquals(child, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true))
- {
- selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- }
- else
- {
- selectionProvider.setSelection(new StructuredSelection(comp));
- }
- if (comp instanceof XSDNamedComponent)
- {
- if (sourceContext instanceof AbstractEditPartViewer)
- {
-// AbstractEditPartViewer viewer = (AbstractEditPartViewer)sourceContext;
-
-// Object obj = viewer.getSelectedEditParts().get(0);
-
-// if (obj instanceof GraphicalEditPart)
-// {
-// if (obj instanceof ElementDeclarationEditPart)
-// {
-// XSDElementDeclaration elem = ((ElementDeclarationEditPart)obj).getXSDElementDeclaration();
-// if (!elem.isElementDeclarationReference())
-// {
-// ((ElementDeclarationEditPart)obj).doEditName();
-// }
-// }
-// else if (obj instanceof ModelGroupDefinitionEditPart)
-// {
-// XSDModelGroupDefinition group = ((ModelGroupDefinitionEditPart)obj).getXSDModelGroupDefinition();
-// if (!group.isModelGroupDefinitionReference())
-// {
-// ((ModelGroupDefinitionEditPart)obj).doEditName();
-// }
-// }
-// else if (obj instanceof ComplexTypeDefinitionEditPart)
-// {
-// XSDComplexTypeDefinition ct = ((ComplexTypeDefinitionEditPart)obj).getXSDComplexTypeDefinition();
-// if (ct.getName() != null)
-// {
-// ((ComplexTypeDefinitionEditPart)obj).doEditName();
-// }
-// }
-// else if (obj instanceof TopLevelComponentEditPart)
-// {
-// ((TopLevelComponentEditPart)obj).doEditName();
-// }
-// }
-
- }
- }
- }
- };
- Display.getDefault().timerExec(50,runnable);
- }
- }
-
- /**
- * Gets the relativeNode.
- * @return Returns a Element
- */
- public Node getRelativeNode()
- {
- return relativeNode;
- }
-
- /**
- * Sets the relativeNode.
- * @param relativeNode The relativeNode to set
- */
- public void setRelativeNode(Node relativeNode)
- {
- this.relativeNode = relativeNode;
- }
-
- /**
- * Gets the description.
- * @return Returns a String
- */
- public String getDescription()
- {
- if (description == null)
- {
- return getText();
- }
- return description;
- }
-
- /**
- * Sets the description.
- * @param description The description to set
- */
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- protected List attributes;
- /**
- * Gets the nameAttribute.
- * @return Returns a String
- */
- public List getAttributes()
- {
- return attributes;
- }
-
- /**
- * Sets the attributes.
- * @param attributes The attributes to set
- */
- public void setAttributes(List attributes)
- {
- this.attributes = attributes;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java
deleted file mode 100644
index 5c4f35a8ab..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/DOMAttribute.java
+++ /dev/null
@@ -1,75 +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.actions;
-
-// issue (cs) remove this
-/**
- * @version 1.0
- * @author
- */
-public class DOMAttribute
-{
- /**
- * Constructor for DOMAttribute.
- */
- public DOMAttribute()
- {
- super();
- }
-
- /**
- * Constructor for DOMAttribute.
- */
- public DOMAttribute(String name, String value)
- {
- super();
- this.name = name;
- this.value = value;
- }
-
- protected String name, value;
- /**
- * Gets the value.
- * @return Returns a String
- */
- public String getValue()
- {
- return value;
- }
-
- /**
- * Sets the value.
- * @param value The value to set
- */
- public void setValue(String value)
- {
- this.value = value;
- }
-
- /**
- * Gets the name.
- * @return Returns a String
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * Sets the name.
- * @param name The name to set
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/IXSDToolbarAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/IXSDToolbarAction.java
deleted file mode 100644
index 52199f65e9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/IXSDToolbarAction.java
+++ /dev/null
@@ -1,19 +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.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.ui.IEditorPart;
-
-public interface IXSDToolbarAction extends IAction
-{
- public void setEditorPart(IEditorPart editorPart);
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDAttributeAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDAttributeAction.java
deleted file mode 100644
index 069a2f77d5..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDAttributeAction.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.actions;
-
-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.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.w3c.dom.Node;
-
-public class MoveXSDAttributeAction extends MoveXSDBaseAction
-{
- private static int INSERT_BEFORE = 0;
- private static int INSERT_AFTER = 1;
- private static int INSERT_DIRECT = 2;
- protected List selectedNodes;
- protected Node parentNode;
- protected Node previousRefChild, nextRefChild;
- int insertType;
-
- XSDConcreteComponent parentComponent;
- XSDConcreteComponent selected, previousRefComponent, nextRefComponent;
- boolean insertAtEnd = true;
-
- public MoveXSDAttributeAction(XSDConcreteComponent parentComponent, XSDConcreteComponent selected, XSDConcreteComponent previousRefChildComponent, XSDConcreteComponent nextRefChildComponent)
- {
- super();
- this.parentComponent = parentComponent;
- this.selected = selected;
- this.previousRefComponent = previousRefChildComponent;
- this.nextRefComponent = nextRefChildComponent;
-
- if (parentComponent == null)
- return;
- parentNode = parentComponent.getElement();
- nextRefChild = nextRefChildComponent != null ? nextRefChildComponent.getElement() : null;
- previousRefChild = previousRefChildComponent != null ? previousRefChildComponent.getElement() : null;
-
- if (nextRefComponent != null)
- {
- if (nextRefComponent.getContainer().getContainer() == parentComponent)
- {
- insertType = INSERT_BEFORE;
- }
- }
- if (previousRefComponent != null)
- {
- if (previousRefComponent.getContainer().getContainer() == parentComponent)
- {
- insertType = INSERT_AFTER;
- }
- }
- if (nextRefChildComponent == null && previousRefChildComponent == null)
- {
- insertType = INSERT_DIRECT;
- }
- }
-
- public MoveXSDAttributeAction(XSDConcreteComponent parentComponent, XSDConcreteComponent selected, XSDConcreteComponent previousRefChildComponent, XSDConcreteComponent nextRefChildComponent, boolean insertAtEnd)
- {
- this(parentComponent, selected, previousRefChildComponent, nextRefChildComponent);
- this.insertAtEnd = insertAtEnd;
- }
-
- public boolean canMove()
- {
- boolean result = true;
-
- if (nextRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDElementDeclaration || parentComponent == null)
- return false;
-
- return result;
- }
-
- /*
- * @see IAction#run()
- */
- public void run()
- {
- if (parentComponent instanceof XSDAttributeGroupDefinition)
- {
- moveUnderXSDAttributeGroupDefinition((XSDAttributeGroupDefinition) parentComponent);
- }
- else if (parentComponent instanceof XSDComplexTypeDefinition)
- {
- moveUnderXSDComplexTypeDefinition((XSDComplexTypeDefinition) parentComponent);
- }
- }
-
- protected void moveUnderXSDAttributeGroupDefinition(XSDAttributeGroupDefinition parentGroup)
- {
- int originalIndex = 0;
- for (Iterator iterator = parentGroup.getContents().iterator(); iterator.hasNext();)
- {
- XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent) iterator.next();
- if (attributeGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeDeclaration attribute = ((XSDAttributeUse) attributeGroupContent).getContent();
- if (attribute == selected)
- {
- parentGroup.getContents().remove(attribute.getContainer());
- break;
- }
- }
- originalIndex++;
- }
- int index = 0;
- boolean addedBack = false;
- if (insertType == INSERT_DIRECT)
- {
- XSDConcreteComponent container = selected.getContainer();
- if (container != null)
- {
- if (insertAtEnd)
- ((XSDAttributeGroupDefinition) parentComponent).getResolvedAttributeGroupDefinition().getContents().add(container);
- else
- ((XSDAttributeGroupDefinition) parentComponent).getResolvedAttributeGroupDefinition().getContents().add(0, container);
- addedBack = true;
- }
- return;
- }
-
- List attributeGroupContents = parentGroup.getContents();
- for (Iterator iterator = attributeGroupContents.iterator(); iterator.hasNext();)
- {
- XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent) iterator.next();
- if (attributeGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeDeclaration attribute = ((XSDAttributeUse) attributeGroupContent).getContent();
- if (insertType == INSERT_BEFORE)
- {
- if (attribute == nextRefComponent)
- {
- parentGroup.getContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- if (selected == nextRefComponent && originalIndex == index)
- {
- parentGroup.getContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- }
- else if (insertType == INSERT_AFTER)
- {
- if (attribute == previousRefComponent)
- {
- parentGroup.getContents().add(index + 1, selected.getContainer());
- addedBack = true;
- break;
- }
- if (selected == previousRefComponent && originalIndex == index)
- {
- parentGroup.getContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- }
- }
- index++;
- }
- if (attributeGroupContents.size() == 0)
- {
- parentGroup.getContents().add(selected.getContainer());
- addedBack = true;
- }
-
- if (!addedBack)
- {
- parentGroup.getContents().add(originalIndex, selected.getContainer());
- }
- }
-
- protected void moveUnderXSDComplexTypeDefinition(XSDComplexTypeDefinition complexType)
- {
- int originalIndex = 0;
- for (Iterator iterator = complexType.getAttributeContents().iterator(); iterator.hasNext();)
- {
- XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent) iterator.next();
- if (attributeGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeDeclaration attribute = ((XSDAttributeUse) attributeGroupContent).getContent();
- if (attribute == selected)
- {
- complexType.getAttributeContents().remove(attribute.getContainer());
- break;
- }
- }
- originalIndex++;
- }
- int index = 0;
- boolean addedBack = false;
- List attributeGroupContents = complexType.getAttributeContents();
- for (Iterator iterator = attributeGroupContents.iterator(); iterator.hasNext();)
- {
- XSDAttributeGroupContent attributeGroupContent = (XSDAttributeGroupContent) iterator.next();
- if (attributeGroupContent instanceof XSDAttributeUse)
- {
- XSDAttributeDeclaration attribute = ((XSDAttributeUse) attributeGroupContent).getContent();
- if (insertType == INSERT_AFTER)
- {
- if (attribute == previousRefComponent)
- {
- complexType.getAttributeContents().add(index + 1, selected.getContainer());
- addedBack = true;
- break;
- }
- }
- else if (insertType == INSERT_BEFORE)
- {
- if (attribute == nextRefComponent)
- {
- complexType.getAttributeContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- }
- }
- index++;
- }
- if (attributeGroupContents.size() == 0)
- {
- complexType.getAttributeContents().add(selected.getContainer());
- addedBack = true;
- }
-
- if (!addedBack)
- {
- complexType.getAttributeContents().add(originalIndex, selected.getContainer());
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDBaseAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDBaseAction.java
deleted file mode 100644
index c6d99065be..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDBaseAction.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.actions;
-
-import org.eclipse.jface.action.Action;
-
-public class MoveXSDBaseAction extends Action
-{
-
- public MoveXSDBaseAction()
- {
- super();
- }
-
- public boolean canMove()
- {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDElementAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDElementAction.java
deleted file mode 100644
index 7e73ff5e9f..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/MoveXSDElementAction.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.actions;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDParticleContent;
-import org.w3c.dom.Node;
-
-public class MoveXSDElementAction extends MoveXSDBaseAction
-{
- private static int INSERT_BEFORE = 0;
- private static int INSERT_AFTER = 1;
- private static int INSERT_DIRECT = 2;
- protected List selectedNodes;
- protected Node parentNode;
- protected Node previousRefChild, nextRefChild;
- int insertType;
-
- XSDModelGroup parentModelGroup;
- XSDConcreteComponent selected, previousRefComponent, nextRefComponent;
- boolean insertAtEnd = true;
-
- public MoveXSDElementAction(XSDModelGroup parentComponent, XSDConcreteComponent selected, XSDConcreteComponent previousRefChildComponent, XSDConcreteComponent nextRefChildComponent)
- {
- super();
- this.parentModelGroup = parentComponent;
- this.selected = selected;
- this.previousRefComponent = previousRefChildComponent;
- this.nextRefComponent = nextRefChildComponent;
-
- if (parentComponent == null)
- return;
- parentNode = parentComponent.getElement();
- nextRefChild = nextRefChildComponent != null ? nextRefChildComponent.getElement() : null;
- previousRefChild = previousRefChildComponent != null ? previousRefChildComponent.getElement() : null;
-
- if (nextRefComponent != null)
- {
- if (nextRefComponent.getContainer().getContainer() == parentModelGroup)
- {
- insertType = INSERT_BEFORE;
- }
- }
- if (previousRefComponent != null)
- {
- if (previousRefComponent.getContainer().getContainer() == parentModelGroup)
- {
- insertType = INSERT_AFTER;
- }
- }
- if (nextRefChildComponent == null && previousRefChildComponent == null)
- {
- insertType = INSERT_DIRECT;
- }
- }
-
- public MoveXSDElementAction(XSDModelGroup parentComponent, XSDConcreteComponent selected, XSDConcreteComponent previousRefChildComponent, XSDConcreteComponent nextRefChildComponent, boolean insertAtEnd)
- {
- this(parentComponent, selected, previousRefChildComponent, nextRefChildComponent);
- this.insertAtEnd = insertAtEnd;
- }
-
- public boolean canMove()
- {
- boolean result = true;
-
- if (nextRefComponent instanceof XSDAttributeDeclaration || previousRefComponent instanceof XSDAttributeDeclaration || parentModelGroup == null)
- return false;
-
- return result;
- }
-
- /*
- * @see IAction#run()
- */
- public void run()
- {
- int originalIndex = 0;
- for (Iterator particles = parentModelGroup.getContents().iterator(); particles.hasNext();)
- {
- XSDParticle particle = (XSDParticle) particles.next();
- XSDParticleContent particleContent = particle.getContent();
- if (particleContent == selected)
- {
- parentModelGroup.getContents().remove(particle);
- break;
- }
- originalIndex++;
- }
- int index = 0;
- boolean addedBack = false;
- if (insertType == INSERT_DIRECT)
- {
- XSDConcreteComponent container = selected.getContainer();
- if (container != null)
- {
- XSDConcreteComponent container2 = container.getContainer();
- if (container2 instanceof XSDModelGroup)
- {
- ((XSDModelGroup) container2).getContents().remove(container);
- }
- if (insertAtEnd)
- parentModelGroup.getContents().add(container);
- else
- parentModelGroup.getContents().add(0, container);
- addedBack = true;
- }
- return;
- }
-
- List particles = parentModelGroup.getContents();
- for (Iterator iterator = particles.iterator(); iterator.hasNext();)
- {
- XSDParticle particle = (XSDParticle) iterator.next();
- XSDParticleContent particleContent = particle.getContent();
- if (insertType == INSERT_BEFORE)
- {
- if (particleContent == nextRefComponent)
- {
- parentModelGroup.getContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- if (selected == nextRefComponent && originalIndex == index)
- {
- parentModelGroup.getContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- }
- else if (insertType == INSERT_AFTER)
- {
- if (particleContent == previousRefComponent)
- {
- parentModelGroup.getContents().add(index + 1, selected.getContainer());
- addedBack = true;
- break;
- }
- if (selected == previousRefComponent && originalIndex == index)
- {
- parentModelGroup.getContents().add(index, selected.getContainer());
- addedBack = true;
- break;
- }
- }
- index++;
- }
- if (particles.size() == 0)
- {
- parentModelGroup.getContents().add(selected.getContainer());
- addedBack = true;
- }
-
- if (!addedBack)
- {
- parentModelGroup.getContents().add(originalIndex, selected.getContainer());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java
deleted file mode 100644
index 6a573b3107..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/actions/XSDEditNamespacesAction.java
+++ /dev/null
@@ -1,292 +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.actions;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceInfoManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonResources;
-import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNamespaceInformationCommand;
-import org.eclipse.wst.xsd.ui.internal.common.util.Messages;
-import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
-import org.eclipse.wst.xsd.ui.internal.nsedit.SchemaPrefixChangeHandler;
-import org.eclipse.wst.xsd.ui.internal.nsedit.TargetNamespaceChangeHandler;
-import org.eclipse.wst.xsd.ui.internal.widgets.XSDEditSchemaInfoDialog;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public class XSDEditNamespacesAction extends Action
-{
- private Element element;
- private String resourceLocation;
- private XSDSchema xsdSchema;
- private DOMNamespaceInfoManager namespaceInfoManager = new DOMNamespaceInfoManager();
-
- public XSDEditNamespacesAction(String label, Element element, Node node)
- {
- super();
- setText(label);
-
- this.element = element;
- // /////////////////// This needs to be changed....
- this.resourceLocation = "dummy";
- }
-
- public XSDEditNamespacesAction(String label, Element element, Node node, XSDSchema schema)
- {
- this(label, element, node);
- xsdSchema = schema;
- }
-
- public void run()
- {
- if (element != null)
- {
- Shell shell = XMLCommonResources.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- String targetNamespace = null;
- if (xsdSchema != null)
- {
- targetNamespace = xsdSchema.getTargetNamespace();
- }
- XSDEditSchemaInfoDialog dialog = new XSDEditSchemaInfoDialog(shell, new Path(resourceLocation), targetNamespace);
-
- List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element);
- List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList);
-
- // here we store a copy of the old info for each NamespaceInfo
- // this info will be used in createPrefixMapping() to figure out how to
- // update the document in response to these changes
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext();)
- {
- NamespaceInfo info = (NamespaceInfo) i.next();
- NamespaceInfo oldCopy = new NamespaceInfo(info);
- info.setProperty("oldCopy", oldCopy); //$NON-NLS-1$
- }
-
- dialog.setNamespaceInfoList(namespaceInfoList);
- dialog.create();
- dialog.getShell().setSize(500, 400);
- dialog.getShell().setText(XMLCommonResources.getInstance().getString("_UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE")); //$NON-NLS-1$
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- String xsdPrefix = null; //$NON-NLS-1$
- String origXSDPrefix = xsdSchema.getSchemaForSchemaQNamePrefix();
- String newTNSPrefix = "";
-
- if (dialog.getReturnCode() == Window.OK)
- {
- Element xsdSchemaElement = xsdSchema.getElement();
- DocumentImpl doc = (DocumentImpl) xsdSchemaElement.getOwnerDocument();
-
- List newInfoList = dialog.getNamespaceInfoList();
-
- // see if we need to rename any prefixes
- Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList);
-
- String origTNSPrefix = null;
- Map origPrefixMap = xsdSchema.getQNamePrefixToNamespaceMap();
- for (Iterator iter = origPrefixMap.keySet().iterator(); iter.hasNext();)
- {
- String key = (String) iter.next();
- String ns = (String) origPrefixMap.get(key);
- if ((targetNamespace == null && ns == null) || targetNamespace != null && targetNamespace.equals(ns))
- {
- origTNSPrefix = key;
- break;
- }
- }
- Map map2 = new Hashtable();
- for (Iterator iter = newInfoList.iterator(); iter.hasNext();)
- {
- NamespaceInfo ni = (NamespaceInfo) iter.next();
- String pref = ni.prefix;
- String uri = ni.uri;
- if (pref == null)
- pref = ""; //$NON-NLS-1$
- if (uri == null)
- uri = ""; //$NON-NLS-1$
- if (XSDConstants.isSchemaForSchemaNamespace(uri))
- {
- xsdPrefix = pref;
- }
- if (uri.equals(dialog.getTargetNamespace()))
- {
- newTNSPrefix = pref;
- }
- map2.put(pref, uri);
- }
-
- if (map2.size() > 0)
- {
- try
- {
-
- doc.getModel().beginRecording(this, XSDEditorPlugin.getXSDString("_UI_NAMESPACE_CHANGE"));
- boolean targetNamespaceChanged = (targetNamespace != null && !targetNamespace.equals(dialog.getTargetNamespace()) || targetNamespace == null && dialog.getTargetNamespace() != null);
- boolean tnsPrefixChanged = !newTNSPrefix.equals(origTNSPrefix);
- boolean xsdPrefixChanged = (!(origXSDPrefix == null && xsdPrefix.equals("")) || (origXSDPrefix != null && !origXSDPrefix.equals(xsdPrefix)));
-
- xsdSchema.setIncrementalUpdate(false);
-
- // First handle the prefix change for the target namespace
- if (tnsPrefixChanged)
- {
- prefixMapping.remove(origTNSPrefix);
- UpdateNamespaceInformationCommand command = new UpdateNamespaceInformationCommand(Messages._UI_ACTION_NAMESPACE_INFORMATION_CHANGE, xsdSchema, newTNSPrefix, targetNamespace);
- command.execute();
- xsdSchema.update();
- }
- // Second, handle the target namespace change
- if (targetNamespaceChanged)
- {
- // set the targetNamespace attribute
- xsdSchema.setTargetNamespace(dialog.getTargetNamespace());
-
- TargetNamespaceChangeHandler targetNamespaceChangeHandler = new TargetNamespaceChangeHandler(xsdSchema, targetNamespace, dialog.getTargetNamespace());
- targetNamespaceChangeHandler.resolve();
- }
-
-
- // Now handle the other changes. PrefixMapping size should be
- // greater than 0 for any remaining prefix changes
-
- if (prefixMapping.size() > 0)
- {
- for (Iterator iter = prefixMapping.keySet().iterator(); iter.hasNext();)
- {
- String oldPrefix = (String) iter.next();
- String newPrefix = (String) prefixMapping.get(oldPrefix);
-
- // Now update any references to this old prefix in the schema
- // with the value of the new prefix
- String ns = (String) origPrefixMap.get(oldPrefix);
- SchemaPrefixChangeHandler spch = new SchemaPrefixChangeHandler(xsdSchema, newPrefix, ns != null? ns : ""); //$NON-NLS-1$
- spch.resolve();
- }
- }
- namespaceInfoManager.removeNamespaceInfo(element);
- namespaceInfoManager.addNamespaceInfo(element, newInfoList, false);
-
- // Third, handle the schema for schema prefix change
- if (xsdPrefixChanged)
- {
- if (xsdPrefix != null && xsdPrefix.length() == 0)
- {
- xsdSchema.setSchemaForSchemaQNamePrefix(null);
- }
- else
- {
- xsdSchema.setSchemaForSchemaQNamePrefix(xsdPrefix);
- }
-
- namespaceInfoManager.removeNamespaceInfo(element);
- namespaceInfoManager.addNamespaceInfo(element, newInfoList, false);
- xsdSchema.setIncrementalUpdate(true);
-
- // Now change the references to any schema types/components ie. string --> xs:string
- SchemaPrefixChangeHandler spch = new SchemaPrefixChangeHandler(xsdSchema, xsdPrefix);
- spch.resolve();
-
- // Change the prefix for all schema components
- updateAllNodes(element, xsdPrefix);
-
- prefixMapping.remove(origXSDPrefix != null? origXSDPrefix : ""); //$NON-NLS-1$
- }
- xsdSchema.setIncrementalUpdate(true);
- }
- catch (Exception e)
- {
- }
- finally
- {
- xsdSchema.update();
- doc.getModel().endRecording(this);
- }
- }
- }
- }
- }
-
- protected Map createPrefixMapping(List oldList, List newList)
- {
- Map map = new Hashtable();
-
- Hashtable oldURIToPrefixTable = new Hashtable();
- for (Iterator i = oldList.iterator(); i.hasNext();)
- {
- NamespaceInfo oldInfo = (NamespaceInfo) i.next();
- oldURIToPrefixTable.put(oldInfo.uri, oldInfo);
- }
-
- for (Iterator i = newList.iterator(); i.hasNext();)
- {
- NamespaceInfo newInfo = (NamespaceInfo) i.next();
- NamespaceInfo oldInfo = (NamespaceInfo) oldURIToPrefixTable.get(newInfo.uri != null ? newInfo.uri : ""); //$NON-NLS-1$
-
- // if oldInfo is non null ... there's a matching URI in the old set
- // we can use its prefix to detemine out mapping
- //
- // if oldInfo is null ... we use the 'oldCopy' we stashed away
- // assuming that the user changed the URI and the prefix
- if (oldInfo == null)
- {
- oldInfo = (NamespaceInfo) newInfo.getProperty("oldCopy"); //$NON-NLS-1$
- }
-
- if (oldInfo != null)
- {
- String newPrefix = newInfo.prefix != null ? newInfo.prefix : ""; //$NON-NLS-1$
- String oldPrefix = oldInfo.prefix != null ? oldInfo.prefix : ""; //$NON-NLS-1$
- if (!oldPrefix.equals(newPrefix))
- {
- map.put(oldPrefix, newPrefix);
- }
- }
- }
- return map;
- }
-
- private void updateAllNodes(Element element, String prefix)
- {
- element.setPrefix(prefix);
- NodeList list = element.getChildNodes();
- if (list != null)
- {
- for (int i = 0; i < list.getLength(); i++)
- {
- Node child = list.item(i);
- if (child != null && child instanceof Element)
- {
- child.setPrefix(prefix);
- if (child.hasChildNodes())
- {
- updateAllNodes((Element) child, prefix);
- }
- }
- }
- }
- }
-
-}

Back to the top