Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java107
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java29
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java106
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java102
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java84
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java152
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java299
8 files changed, 0 insertions, 963 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java
deleted file mode 100644
index f45a1e2111..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseCleanup.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor;
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-
-public abstract class BaseCleanup extends XSDVisitor
-{
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitSchema(XSDSchema)
- */
- public void visitSchema(XSDSchema schema)
- {
- super.visitSchema(schema);
-
- // now remove all children that were queued up for removal
-
- for (Iterator iter = childrenToRemove.iterator(); iter.hasNext(); )
- {
- Element domElement = (Element) iter.next();
- XSDDOMHelper.removeNodeAndWhitespace(domElement);
-// domElement.getParentNode().removeChild(domElement);
- }
- }
-
-
- protected ArrayList messages = new ArrayList();
-
- public ArrayList getMessages()
- {
- return messages;
- }
-
-
- protected void addMessage(String msg, XSDConcreteComponent component)
- {
-//// ErrorMessage message = new ErrorMessage();
-//
-// XSDConcreteComponent currComp = component;
-// while (!(currComp instanceof XSDSchemaContent) && currComp.getContainer() != null)
-// {
-// currComp = currComp.getContainer();
-// }
-//
-// Element domElement = currComp.getElement();
-// Node parent = domElement;
-// while (!(parent instanceof NodeImpl) && parent != null)
-// {
-// parent = parent.getParentNode();
-// }
-// if (parent instanceof NodeImpl)
-// {
-// // message.setModelObject(currComp.getElement());
-// message.setTargetObject(currComp.getElement());
-// }
-// message.setLocalizedMessage(msg);
-// ???
-// addMessage(message);
- }
-
-
-// // protected void addMessage(ErrorMessage message)
-// protected void addMessage(Message message)
-// {
-// messages.add(message);
-// }
-
-
- protected ArrayList childrenToRemove = new ArrayList();
-
-
- protected String getNamedComponentName(XSDConcreteComponent concrete)
- {
- String name = null;
- if (concrete instanceof XSDNamedComponent)
- {
- name = ((XSDNamedComponent)concrete).getName();
- }
-
- XSDConcreteComponent comp = concrete;
- while (comp != null && name == null)
- {
- comp = comp.getContainer();
- if (comp instanceof XSDNamedComponent)
- {
- name = ((XSDNamedComponent)comp).getName();
- }
- }
- return name != null ? name : "";
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java
deleted file mode 100644
index 6503971f03..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/BaseGlobalCleanup.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDNamedComponent;
-
-public class BaseGlobalCleanup extends BaseCleanup
-{
- public BaseGlobalCleanup(XSDConcreteComponent deletedItem)
- {
- this.deletedItem = deletedItem;
- }
-
- protected XSDConcreteComponent deletedItem;
-
- protected String getDeletedQName()
- {
- return ((XSDNamedComponent)deletedItem).getQName();
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java
deleted file mode 100644
index 64c5779f40..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeCleanup.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalAttributeCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalAttributeCleanup.
- * @param deletedItem
- */
- public GlobalAttributeCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getGlobalAttributes();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(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;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl != null && attrDecl.isAttributeDeclarationReference())
- {
- if (deletedItem.equals(attrDecl.getResolvedAttributeDeclaration()))
- {
- if (getReplacementElementName() != null)
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_ATTRIBUTE_REFERENCE") + " <" + getReplacementElementName() + ">";
- String msg = "Reset attribute reference " + " <" + getReplacementElementName() + ">";
- addMessage(msg, attrUse);
- attrUse.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- String name = getNamedComponentName(type);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ATTRIBUTE_REFERENCE") +
- String msg = "Remove attribute reference " +
- " <" + name + ">";
- addMessage(msg, attrUse.getContainer());
-
- childrenToRemove.add(attrDecl.getElement());
- }
- }
- }
- }
- }
- }
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java
deleted file mode 100644
index 2d5ed5c029..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalAttributeGroupCleanup.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalAttributeGroupCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalAttributeGroupCleanup.
- * @param deletedItem
- */
- public GlobalAttributeGroupCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getGlobalAttributeGroups();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(type);
- if (type.getAttributeContents() != null)
- {
- for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); )
- {
- XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
-
- if (attrGroupContent instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) attrGroupContent;
-
- if (deletedItem.equals(attrGroupDef.getResolvedAttributeGroupDefinition()))
- {
- if (getReplacementElementName() != null)
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_ATTRIBUTE_GROUP_REFERENCE") + " <" + getReplacementElementName() + ">";
- String msg = "Reset attribute group reference " + " <" + getReplacementElementName() + ">";
- addMessage(msg, attrGroupDef);
- attrGroupDef.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- // remove the attribute group reference
- String name = getNamedComponentName(type);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ATTRIBUTE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "Remove attribute group reference " + " <" + name + ">";
-
- addMessage(msg, attrGroupDef.getContainer());
-
- childrenToRemove.add(attrGroupDef.getElement());
- }
- }
- }
- }
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java
deleted file mode 100644
index 9719e3914b..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalElementCleanup.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalElementCleanup extends BaseGlobalCleanup
-{
-
- /**
- * Constructor for GlobalElementCleanup.
- * @param deletedItem
- */
- public GlobalElementCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getGlobalElements();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- if (element.isElementDeclarationReference())
- {
- if (deletedItem.equals(element.getResolvedElementDeclaration()))
- {
- if (getReplacementElementName() != null)
- {
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_RESET_ELEMENT_REFERENCE") + " <" + getReplacementElementName() + ">";
- String msg = "_INFO_RESET_ELEMENT_REFERENCE" + " <" + getReplacementElementName() + ">";
- addMessage(msg, element);
- element.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ELEMENT_REFERENCE") + " <" + getNamedComponentName(element.getContainer()) + ">";
- String msg = "_INFO_REMOVE_ELEMENT_REFERENCE" + " <" + getNamedComponentName(element.getContainer()) + ">";
- addMessage(msg, element.getContainer());
- childrenToRemove.add(element.getElement());
- }
- }
- }
- super.visitElementDeclaration(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java
deleted file mode 100644
index 9486ff2b11..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalGroupCleanup.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-
-public class GlobalGroupCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalGroupCleanup.
- * @param deletedItem
- */
- public GlobalGroupCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- protected String replacementName = null;
-
- protected String getReplacementElementName()
- {
- if (replacementName == null)
- {
- TypesHelper helper = new TypesHelper(schema);
-
- List elements = helper.getModelGroups();
-
- String deletedName = getDeletedQName();
- for (Iterator i = elements.iterator(); i.hasNext();)
- {
- String name = (String) i.next();
- if (!name.equals(deletedName))
- {
- replacementName = name;
- break;
- }
- }
- }
- return replacementName;
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitModelGroupDefinition(XSDModelGroupDefinition)
- */
- public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroup)
- {
- super.visitModelGroupDefinition(modelGroup);
- if (modelGroup.isModelGroupDefinitionReference())
- {
- if (deletedItem.equals(modelGroup.getResolvedModelGroupDefinition()))
- {
- if (getReplacementElementName() != null)
- {
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_RESET_GROUP_REFERENCE") + " <" + getReplacementElementName() + ">";
- String msg = "_INFO_RESET_GROUP_REFERENCE" + " <" + getReplacementElementName() + ">";
- addMessage(msg, modelGroup);
- modelGroup.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, getReplacementElementName());
- }
- else
- {
- String name = getNamedComponentName(modelGroup);
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "_INFO_REMOVE_GROUP_REFERENCE" + " <" + name + ">";
- addMessage(msg, modelGroup.getContainer());
- childrenToRemove.add(modelGroup.getElement());
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java
deleted file mode 100644
index f4a0cc31c2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/GlobalSimpleOrComplexTypeCleanup.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-
-import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class GlobalSimpleOrComplexTypeCleanup extends BaseGlobalCleanup
-{
- /**
- * Constructor for GlobalSimpleOrComplexTypeCleanup.
- * @param deletedItem
- */
- public GlobalSimpleOrComplexTypeCleanup(XSDConcreteComponent deletedItem)
- {
- super(deletedItem);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- if (!element.isElementDeclarationReference() &&
- deletedItem.equals(element.getTypeDefinition()))
- {
- resetTypeToString(element.getElement());
-
- String msg = "";
- if (element.isGlobal())
- {
- // KCPort String pattern = XSDPlugin.getSchemaString("_INFO_RESET_GLOBAL_ELEMENT");
- String pattern = "_INFO_RESET_GLOBAL_ELEMENT";
- Object args[] = {element.getName()};
- msg = MessageFormat.format(pattern, args);
- }
- else
- {
- // KCPort msg = XSDPlugin.getSchemaString("_INFO_RESET_ELEMENT");
- msg = "_INFO_RESET_ELEMENT";
- // KCPort msg += "<" + element.getName() + "> " + XSDPlugin.getSchemaString("_UI_TO_TYPE_STRING");
- msg += "<" + element.getName() + "> " + "_UI_TO_TYPE_STRING";
- }
- addMessage(msg, element);
- }
-
-
- super.visitElementDeclaration(element);
- }
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(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;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl != null &&
- !attrDecl.isAttributeDeclarationReference() &&
- deletedItem.equals(attrDecl.getTypeDefinition()))
- {
- resetTypeToString(attrDecl.getElement());
- // reset the type of the attribute decl to string
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_RESET_ATTRIBUTE") +
- String msg = "_INFO_RESET_ATTRIBUTE" +
- " <" + attrDecl.getName() + "> " +
- // KCPort XSDPlugin.getSchemaString("_UI_TO_TYPE_STRING");
- "_UI_TO_TYPE_STRING";
- addMessage(msg, attrDecl);
- resetTypeToString(attrDecl.getElement());
- }
- }
- }
- }
- XSDTypeDefinition base = type.getBaseTypeDefinition();
- if (base != null && base == deletedItem)
- {
- XSDDOMHelper helper = new XSDDOMHelper();
- Element derivedByNode = helper.getDerivedByElement(type.getElement());
-
- // KCPort String msg = XSDPlugin.getSchemaString("_INFO_RESET_COMPLEX_TYPE") +
- String msg = "_INFO_RESET_COMPLEX_TYPE" +
- " <" + getNamedComponentName(type) + "> " +
- // KCPort XSDPlugin.getSchemaString("_UI_DERIVATION");
- "_UI_DERIVATION";
- addMessage(msg, type);
-
- type.setBaseTypeDefinition(null);
-
- java.util.List listOfCT = schema.getTypeDefinitions();
- XSDTypeDefinition typeDefinition = null;
- if (listOfCT.size() > 0)
- {
- for (Iterator iter = listOfCT.iterator(); iter.hasNext(); )
- {
- typeDefinition = (XSDTypeDefinition)iter.next();
- if (typeDefinition != deletedItem)
- {
- type.setBaseTypeDefinition(typeDefinition);
- }
- }
- }
- }
- }
-
- public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type)
- {
- if (type.getBaseTypeDefinition() == deletedItem)
- {
- type.setBaseTypeDefinition(schema.resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
- }
- }
-
- protected void resetTypeToString(Element element)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
-
- element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, prefix + "string");
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java
deleted file mode 100644
index aa40416c90..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/delete/XSDExternalFileCleanup.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.delete;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeGroupContent;
-import org.eclipse.xsd.XSDAttributeGroupDefinition;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDConcreteComponent;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-
-public class XSDExternalFileCleanup extends BaseCleanup
-{
- /**
- * Constructor for XSDExternalFileCleanup.
- */
- public XSDExternalFileCleanup(String oldFilename)
- {
- super();
- this.oldFilename = oldFilename;
- }
-
- protected XSDSchema deletedSchema;
- public XSDExternalFileCleanup(XSDSchema deletedSchema)
- {
- this.deletedSchema = deletedSchema;
- }
-
- protected String oldFilename;
-
- /**
- * @see org.eclipse.wst.xsd.ui.internal.refactor.XSDVisitor#visitElementDeclaration(XSDElementDeclaration)
- */
- public void visitElementDeclaration(XSDElementDeclaration element)
- {
- boolean addMessage = true;
- String schemaLocation = element.getSchema().getSchemaLocation();
- if (schemaLocation!= null)
- {
- if (!schemaLocation.equals(schema.getSchemaLocation()))
- {
- addMessage = false;
- }
- }
- if (element.isElementDeclarationReference())
- {
- if (isFromDeletedSchema(element.getResolvedElementDeclaration()))
- {
- if (addMessage)
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ELEMENT_REFERENCE") + " <" + getNamedComponentName(element.getContainer()) + ">";
- String msg = "_INFO_REMOVE_ELEMENT_REFERENCE" + " <" + getNamedComponentName(element.getContainer()) + ">";
- addMessage(msg, element.getContainer());
- }
- childrenToRemove.add(element.getElement());
-// Element domElement = element.getElement();
-// domElement.getParentNode().removeChild(domElement);
- }
- }
- else if (removeType(element))
- {
- String msg = "";
- if (element.isGlobal())
- {
- // String pattern = XSDPlugin.getSchemaString("_INFO_RESET_GLOBAL_ELEMENT");
- String pattern = "_INFO_RESET_GLOBAL_ELEMENT";
- Object args[] = {element.getName()};
- msg = MessageFormat.format(pattern, args);
- }
- else
- {
- // msg = XSDPlugin.getSchemaString("_INFO_RESET_ELEMENT");
- msg = "_INFO_RESET_ELEMENT";
- // msg += "<" + element.getName() + "> " + XSDPlugin.getSchemaString("_UI_TO_TYPE_STRING");
- msg += "<" + element.getName() + "> " + "_UI_TO_TYPE_STRING";
- }
- if (addMessage)
- {
- addMessage(msg, element);
- }
- }
-
-
- super.visitElementDeclaration(element);
- }
-
- protected void resetTypeToString(Element element)
- {
- String prefix = element.getPrefix();
- prefix = (prefix == null) ? "" : (prefix + ":");
-
- element.setAttribute(XSDConstants.TYPE_ATTRIBUTE, prefix + "string");
- }
-
- protected boolean removeType(XSDElementDeclaration element)
- {
- if (removeType(element.getTypeDefinition()))
- {
- resetTypeToString(element.getElement());
- return true;
- }
- return false;
- }
-
- protected boolean isFromDeletedSchema(XSDConcreteComponent component)
- {
- if (component == null)
- {
- return false;
- }
- XSDConcreteComponent root = component.getRootContainer();
-
- boolean isFromDeletedSchema = false;
- if (deletedSchema.getContents() != null)
- {
- Iterator contents = deletedSchema.getContents().iterator();
- while (contents.hasNext())
- {
- XSDSchemaContent content = (XSDSchemaContent)contents.next();
- if (content instanceof XSDSchemaDirective)
- {
- XSDSchema aSchema = ((XSDSchemaDirective)content).getResolvedSchema();
- if (root != null && root.equals(aSchema))
- {
- isFromDeletedSchema = true;
- }
- }
- }
- }
- if (root != null && root.equals(deletedSchema))
- {
- isFromDeletedSchema = true;
- }
- return isFromDeletedSchema;
- }
-
- /**
- * Remove the type from the element if it belongs to the external file
- */
- protected boolean removeType(XSDTypeDefinition typeDef)
- {
- if (typeDef == null)
- {
- return false;
- }
- return isFromDeletedSchema(typeDef);
- }
-
- /**
- * @see org.eclipse.wst.xsd.utility.XSDVisitor#visitComplexTypeDefinition(XSDComplexTypeDefinition)
- */
- public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
- {
- super.visitComplexTypeDefinition(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;
- XSDAttributeDeclaration attrDecl = attrUse.getContent();
-
- // now is this a reference?
- if (attrDecl.isAttributeDeclarationReference())
- {
- if (isFromDeletedSchema(attrDecl.getResolvedAttributeDeclaration()))
- {
- String name = getNamedComponentName(type);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ATTRIBUTE_REFERENCE") +
- String msg = "_INFO_REMOVE_ATTRIBUTE_REFERENCE" +
- " <" + name + ">";
- addMessage(msg, attrDecl.getContainer());
-
- childrenToRemove.add(attrDecl.getElement());
- }
- }
- // otherwise check the type of the attribute and see if it is from the deleted schema
- else
- {
- if (removeType(attrDecl.getTypeDefinition()))
- {
- // reset the type of the attribute decl to string
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_ATTRIBUTE") +
- String msg = "_INFO_RESET_ATTRIBUTE" +
- " <" + attrDecl.getName() + "> " +
- // XSDPlugin.getSchemaString("_UI_TO_TYPE_STRING");
- "_UI_TO_TYPE_STRING";
- addMessage(msg, attrDecl);
- resetTypeToString(attrDecl.getElement());
-
- }
- }
- }
- else if (attrGroupContent instanceof XSDAttributeGroupDefinition)
- {
- XSDAttributeGroupDefinition attrGroupDef = (XSDAttributeGroupDefinition) attrGroupContent;
-
- if (isFromDeletedSchema(attrGroupDef.getResolvedAttributeGroupDefinition()))
- {
- // remove the attribute group reference
- String name = getNamedComponentName(type);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_ATTRIBUTE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "_INFO_REMOVE_ATTRIBUTE_GROUP_REFERENCE" + " <" + name + ">";
-
- addMessage(msg, attrGroupDef.getContainer());
-
- childrenToRemove.add(attrGroupDef.getElement());
- }
- }
- }
- }
-
- // For the complex type with simple content case, see the visitComplexTypeDefinition method
- XSDTypeDefinition base = type.getBaseTypeDefinition();
- if (base instanceof XSDSimpleTypeDefinition)
- {
- XSDSimpleTypeDefinition baseType = (XSDSimpleTypeDefinition)base;
- if (isFromDeletedSchema(baseType))
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_COMPLEX_TYPE") +
- String msg = "_INFO_RESET_COMPLEX_TYPE" +
- " <" + getNamedComponentName(type) + "> " +
- // XSDPlugin.getSchemaString("_UI_DERIVATION");
- "_UI_DERIVATION";
- addMessage(msg, type);
-
- type.setBaseTypeDefinition(schema.getSchemaForSchema().resolveSimpleTypeDefinition("string"));
- }
- }
- }
-
- /**
- * @see org.eclipse.wst.xsd.utility.XSDVisitor#visitModelGroupDefinition(XSDModelGroupDefinition)
- */
- public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroup)
- {
- super.visitModelGroupDefinition(modelGroup);
- if (modelGroup.isModelGroupDefinitionReference())
- {
- if (isFromDeletedSchema(modelGroup.getResolvedModelGroupDefinition()))
- {
- String name = getNamedComponentName(modelGroup);
- // String msg = XSDPlugin.getSchemaString("_INFO_REMOVE_GROUP_REFERENCE") + " <" + name + ">";
- String msg = "_INFO_REMOVE_GROUP_REFERENCE" + " <" + name + ">";
- addMessage(msg, modelGroup.getContainer());
- childrenToRemove.add(modelGroup.getElement());
- }
- }
- }
-
- /**
- * @see org.eclipse.wst.xsd.utility.XSDVisitor#visitSimpleTypeDefinition(XSDSimpleTypeDefinition)
- */
- public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type)
- {
- super.visitSimpleTypeDefinition(type);
- XSDSimpleTypeDefinition baseType = type.getBaseTypeDefinition();
- if (isFromDeletedSchema(baseType))
- {
- // String msg = XSDPlugin.getSchemaString("_INFO_RESET_SIMPLE_TYPE") +
- String msg = "_INFO_RESET_SIMPLE_TYPE" +
- " <" + getNamedComponentName(type) + "> " +
- // XSDPlugin.getSchemaString("_UI_DERIVATION");
- "_UI_DERIVATION";
- addMessage(msg, type);
-
-
- // This will set the simple Type base to string
- // For the complex type with simple content case, see the visitComplexTypeDefinition method
-
- type.getFacetContents().clear();
- type.getFacets().clear();
- type.setBaseTypeDefinition(schema.getSchemaForSchema().resolveSimpleTypeDefinition("string"));
- }
- }
-
-}

Back to the top