This commit was manufactured by cvs2svn to create tag 'R1_0_0'.
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/Checks.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/Checks.java
new file mode 100644
index 0000000..92a2027
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/Checks.java
@@ -0,0 +1,27 @@
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
+
+public class Checks {
+
+ public static RefactoringStatus checkName(String name) {
+ RefactoringStatus result= new RefactoringStatus();
+ if ("".equals(name)) //$NON-NLS-1$
+ return RefactoringStatus.createFatalErrorStatus("RefactoringMessages.Checks_Choose_name");
+ return result;
+ }
+
+ public static boolean isAlreadyNamed(RefactoringComponent element, String name){
+ return name.equals(element.getName());
+ }
+
+ public static RefactoringStatus checkComponentName(String name) {
+ RefactoringStatus result= new RefactoringStatus();
+ if (!NameValidator.isValid(name)) //$NON-NLS-1$
+ return RefactoringStatus.createFatalErrorStatus("RefactoringMessages.Checks_Choose_name");
+
+ return result;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/INameUpdating.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/INameUpdating.java
new file mode 100644
index 0000000..76adc4d
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/INameUpdating.java
@@ -0,0 +1,20 @@
+/*
+ * Created on Feb 16, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+/**
+ * @author ebelisar
+ */
+public interface INameUpdating {
+
+ public abstract void setNewElementName(String newName);
+ public abstract String getNewElementName();
+ public abstract String getCurrentElementName();
+ public abstract RefactoringStatus checkNewElementName(String newName);
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/IReferenceUpdating.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/IReferenceUpdating.java
new file mode 100644
index 0000000..2b65694
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/IReferenceUpdating.java
@@ -0,0 +1,24 @@
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+public interface IReferenceUpdating {
+
+ /**
+ * Checks if this refactoring object is capable of updating references to the renamed element.
+ */
+ public boolean canEnableUpdateReferences();
+
+ /**
+ * If <code>canUpdateReferences</code> returns <code>true</code>, then this method is used to
+ * inform the refactoring object whether references should be updated.
+ * This call can be ignored if <code>canUpdateReferences</code> returns <code>false</code>.
+ */
+ public void setUpdateReferences(boolean update);
+
+ /**
+ * If <code>canUpdateReferences</code> returns <code>true</code>, then this method is used to
+ * ask the refactoring object whether references should be updated.
+ * This call can be ignored if <code>canUpdateReferences</code> returns <code>false</code>.
+ */
+ public boolean getUpdateReferences();
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringComponent.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringComponent.java
new file mode 100644
index 0000000..8f4dc58
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringComponent.java
@@ -0,0 +1,51 @@
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+
+
+public interface RefactoringComponent
+{
+ /**
+ * @return the name of the component that is refactored. E.g. "foo"
+ */
+ public String getName();
+
+ /**
+ * @return the namespace of the component that is refactored. E.g. "http://foo"
+ */
+ public String getNamespaceURI();
+
+ /**
+ * The basic DOM element is used by the refactoring processor/participant to get
+ * access to the file location.
+ *
+ * @return the Structured Source Editor XML DOM element object that underlines the
+ * combonent being refactore.
+ *
+ * @see IDOMElement
+ */
+ public IDOMElement getElement();
+
+ /**
+ * @return the qualified name of the type of the refactored component.
+ *
+ * <p>
+ * A qualified name consists of a local name and a namespace.
+ * E.g. "complexType"-local name, "http://www.w3.org/2001/XMLSchema"-namespace
+ * </p>
+ *
+ * @see QualifiedName
+ */
+ public QualifiedName getTypeQName();
+
+ /**
+ * The model object may be required to be given to the refactored participants as is or
+ * other objects could be derived from it.
+ *
+ * @return the principal object being refactored, such as an instance of WSDLElement or
+ * XSDNamedComponent
+ */
+ public Object getModelObject();
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java
new file mode 100644
index 0000000..7b56d8d
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/RefactoringMessages.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class RefactoringMessages {
+
+ private static final String RESOURCE_BUNDLE= "org.eclipse.wst.xsd.ui.internal.refactor.messages";//$NON-NLS-1$
+
+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ private RefactoringMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+
+ public static String[] getStrings(String keys[]) {
+ String[] result= new String[keys.length];
+ for (int i= 0; i < keys.length; i++) {
+ result[i]= getString(keys[i]);
+ }
+ return result;
+ }
+
+ public static String getFormattedString(String key, Object arg) {
+ return getFormattedString(key, new Object[] { arg });
+ }
+
+ public static String getFormattedString(String key, Object[] args) {
+ return MessageFormat.format(getString(key), args);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/Startup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/Startup.java
new file mode 100644
index 0000000..4a3fc53
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/Startup.java
@@ -0,0 +1,14 @@
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+
+import org.eclipse.ui.IStartup;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+
+public class Startup implements IStartup {
+
+ public void earlyStartup() {
+ XSDEditorPlugin.getPlugin();
+
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/TextChangeManager.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/TextChangeManager.java
new file mode 100644
index 0000000..69ff744
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/TextChangeManager.java
@@ -0,0 +1,101 @@
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+
+/**
+ * A <code>TextChangeManager</code> manages associations between <code>IFile</code> and <code>TextChange</code> objects.
+ */
+public class TextChangeManager {
+
+ private Map fMap= new HashMap(10); // IFile -> TextChange
+
+ private final boolean fKeepExecutedTextEdits;
+
+ public TextChangeManager() {
+ this(false);
+ }
+
+ public TextChangeManager(boolean keepExecutedTextEdits) {
+ fKeepExecutedTextEdits= keepExecutedTextEdits;
+ }
+
+ /**
+ * Adds an association between the given file and the passed
+ * change to this manager.
+ *
+ * @param file the file (key)
+ * @param change the change associated with the file
+ */
+ public void manage(IFile file, TextChange change) {
+ fMap.put(file, change);
+ }
+
+ /**
+ * Returns the <code>TextChange</code> associated with the given file.
+ * If the manager does not already manage an association it creates a one.
+ *
+ * @param file the file for which the text buffer change is requested
+ * @return the text change associated with the given file.
+ */
+ public TextChange get(IFile file) {
+ TextChange result= (TextChange)fMap.get(file);
+ if (result == null) {
+ result= new TextFileChange(file.toString(), file);
+ result.setKeepPreviewEdits(fKeepExecutedTextEdits);
+ fMap.put(file, result);
+ }
+ return result;
+ }
+
+ /**
+ * Removes the <tt>TextChange</tt> managed under the given key
+ * <code>unit<code>.
+ *
+ * @param unit the key determining the <tt>TextChange</tt> to be removed.
+ * @return the removed <tt>TextChange</tt>.
+ */
+ public TextChange remove(IFile unit) {
+ return (TextChange)fMap.remove(unit);
+ }
+
+ /**
+ * Returns all text changes managed by this instance.
+ *
+ * @return all text changes managed by this instance
+ */
+ public TextChange[] getAllChanges(){
+ return (TextChange[])fMap.values().toArray(new TextChange[fMap.values().size()]);
+ }
+
+ /**
+ * Returns all files managed by this instance.
+ *
+ * @return all files managed by this instance
+ */
+ public IFile[] getAllCompilationUnits(){
+ return (IFile[]) fMap.keySet().toArray(new IFile[fMap.keySet().size()]);
+ }
+
+ /**
+ * Clears all associations between resources and text changes.
+ */
+ public void clear() {
+ fMap.clear();
+ }
+
+ /**
+ * Returns if any text changes are managed for the specified file.
+ *
+ * @param file the file
+ * @return <code>true</code> if any text changes are managed for the specified file and <code>false</code> otherwise
+ */
+ public boolean containsChangesIn(IFile file){
+ return fMap.containsKey(file);
+ }
+}
+
+
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/XMLRefactoringComponent.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/XMLRefactoringComponent.java
new file mode 100644
index 0000000..93eac43
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/XMLRefactoringComponent.java
@@ -0,0 +1,67 @@
+package org.eclipse.wst.xsd.ui.internal.refactor;
+
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+
+
+public class XMLRefactoringComponent implements RefactoringComponent
+{
+ // The name of the component being refactored
+ String name;
+
+ // The namespace in which component is defined, e.g. XML or WSDL target namespace
+ String targetNamespace;
+
+ // Optional model object that is refactored
+ Object model;
+
+ // SED DOM object that underlines the component being refactored
+ IDOMElement domElement;
+
+ public XMLRefactoringComponent(Object modelObject, IDOMElement domElement, String name, String namespace)
+ {
+ super();
+ this.model = modelObject;
+ this.domElement = domElement;
+ this.name = name;
+ this.targetNamespace = namespace;
+
+
+ }
+
+ public XMLRefactoringComponent(IDOMElement domElement, String name, String namespace)
+ {
+ super();
+ this.domElement = domElement;
+ this.name = name;
+ this.targetNamespace = namespace;
+ }
+
+ public Object getModelObject()
+ {
+ return model;
+ }
+
+ public IDOMElement getElement()
+ {
+ return domElement;
+ }
+
+ public String getName()
+ {
+
+ return name;
+ }
+
+ public String getNamespaceURI()
+ {
+ return targetNamespace;
+ }
+
+
+ public QualifiedName getTypeQName()
+ {
+ return new QualifiedName(domElement.getNamespaceURI(), domElement.getLocalName());
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java
new file mode 100644
index 0000000..6216de7
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+import org.eclipse.wst.xsd.ui.internal.refactor.structure.MakeAnonymousTypeGlobalCommand;
+import org.eclipse.wst.xsd.ui.internal.refactor.structure.MakeTypeGlobalProcessor;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactoringWizardMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RenameRefactoringWizard;
+import org.eclipse.xsd.XSDAttributeDeclaration;
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import org.eclipse.xsd.XSDTypeDefinition;
+import org.w3c.dom.Node;
+
+public class MakeAnonymousTypeGlobalAction extends XSDSelectionDispatchAction {
+
+ private String fParentName;
+ private boolean isComplexType = true;
+ private XSDTypeDefinition fSelectedComponent;
+
+ public MakeAnonymousTypeGlobalAction(ISelection selection, XSDSchema schema) {
+ super(selection, schema);
+ setText(RefactoringWizardMessages.MakeAnonymousTypeGlobalAction_text); //$NON-NLS-1$
+ }
+
+ public boolean canRun() {
+
+ return fSelectedComponent != null;
+ }
+
+
+ private String getNewDefaultName(){
+ if(fParentName != null && !"".equals(fParentName)){
+ if(isComplexType){
+ return fParentName + "ComplexType";
+ }
+ else{
+ return fParentName + "SimpleType";
+ }
+ }
+ else{
+ if(isComplexType){
+ return "NewComplexType";
+ }
+ else{
+ return "NewSimpleType";
+ }
+ }
+
+ }
+ private boolean canEnable(XSDConcreteComponent xsdComponent){
+ if (xsdComponent instanceof XSDComplexTypeDefinition) {
+ fSelectedComponent = (XSDComplexTypeDefinition)xsdComponent;
+ isComplexType = true;
+ XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) xsdComponent;
+ XSDConcreteComponent parent = typeDef.getContainer();
+ if(parent instanceof XSDElementDeclaration){
+ fParentName = ((XSDElementDeclaration)parent).getName();
+ return true;
+ }
+ }
+ else if (xsdComponent instanceof XSDSimpleTypeDefinition){
+ fSelectedComponent = (XSDSimpleTypeDefinition)xsdComponent;
+ isComplexType = false;
+ XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComponent;
+ XSDConcreteComponent parent = typeDef.getContainer();
+ if(parent instanceof XSDElementDeclaration){
+ fParentName = ((XSDElementDeclaration)parent).getName();
+ return true;
+ }
+ else if(parent instanceof XSDAttributeDeclaration){
+ fParentName = ((XSDAttributeDeclaration)parent).getName();
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ protected boolean canEnable(Object selectedObject) {
+
+ if (selectedObject instanceof XSDConcreteComponent) {
+ return canEnable((XSDConcreteComponent)selectedObject);
+ }
+ else if (selectedObject instanceof Node) {
+ Node node = (Node) selectedObject;
+ XSDConcreteComponent concreteComponent = getSchema().getCorrespondingComponent(node);
+ return canEnable(concreteComponent);
+
+ }
+ return false;
+
+ }
+
+ public void run1() {
+
+ if(fSelectedComponent == null){
+ return;
+ }
+
+ if(fSelectedComponent.getSchema() == null){
+ getSchema().updateElement(true);
+ }
+ MakeTypeGlobalProcessor processor = new MakeTypeGlobalProcessor(fSelectedComponent, getNewDefaultName());
+ RenameRefactoring refactoring = new RenameRefactoring(processor);
+ try {
+ RefactoringWizard wizard = new RenameRefactoringWizard(
+ refactoring,
+ RefactoringWizardMessages.RenameComponentWizard_defaultPageTitle, // TODO: provide correct strings
+ RefactoringWizardMessages.RenameComponentWizard_inputPage_description, null);
+ RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
+ op.run(XSDEditorPlugin.getShell(), wizard.getDefaultPageTitle());
+ //triggerBuild();
+ } catch (InterruptedException e) {
+ // do nothing. User action got cancelled
+ }
+
+ }
+
+ public void run(){
+ if(fSelectedComponent == null){
+ return;
+ }
+
+ if(fSelectedComponent.getSchema() == null){
+ getSchema().updateElement(true);
+ }
+ DocumentImpl doc = (DocumentImpl) fSelectedComponent.getElement().getOwnerDocument();
+ doc.getModel().beginRecording(
+ this,
+ RefactoringWizardMessages.MakeAnonymousTypeGlobalAction_text);
+ MakeAnonymousTypeGlobalCommand command = new MakeAnonymousTypeGlobalCommand(
+ fSelectedComponent, getNewDefaultName());
+ command.run();
+ doc.getModel().endRecording(this);
+ }
+
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java
new file mode 100644
index 0000000..ea4de4e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
+import org.eclipse.wst.xsd.ui.internal.refactor.structure.MakeLocalElementGlobalCommand;
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDSchema;
+import org.w3c.dom.Node;
+
+public class MakeLocalElementGlobalAction extends XSDSelectionDispatchAction {
+
+ XSDElementDeclaration fSelectedComponent;
+
+ public MakeLocalElementGlobalAction(ISelection selection, XSDSchema schema) {
+ super(selection, schema);
+ //TODO cs : fix up translation
+ setText("Make Global");
+ //setText(RefactoringMessages.getString("MakeLocalElementGlobalAction.text")); //$NON-NLS-1$
+ }
+
+ public boolean canRun() {
+
+ return fSelectedComponent != null;
+ }
+
+ protected boolean canEnable(XSDConcreteComponent selectedObject) {
+
+ fSelectedComponent = null;
+ if (selectedObject instanceof XSDElementDeclaration) {
+ XSDElementDeclaration element = (XSDElementDeclaration) selectedObject;
+ if (!element.isElementDeclarationReference() && !element.isGlobal()) {
+ fSelectedComponent = element;
+ }
+ }
+ return canRun();
+ }
+
+
+ protected boolean canEnable(Object selectedObject) {
+
+ if (selectedObject instanceof XSDConcreteComponent) {
+ return canEnable((XSDConcreteComponent)selectedObject);
+ }
+ else if (selectedObject instanceof Node) {
+ Node node = (Node) selectedObject;
+ XSDConcreteComponent concreteComponent = getSchema()
+ .getCorrespondingComponent(node);
+ return canEnable(concreteComponent);
+ }
+ return false;
+
+ }
+
+
+ public void run() {
+ DocumentImpl doc = (DocumentImpl) fSelectedComponent.getElement()
+ .getOwnerDocument();
+ doc.getModel().beginRecording(this, getText());
+ MakeLocalElementGlobalCommand command = new MakeLocalElementGlobalCommand(
+ fSelectedComponent);
+ command.run();
+ doc.getModel().endRecording(this);
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java
new file mode 100644
index 0000000..6b1d8b8
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java
@@ -0,0 +1,108 @@
+
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactoringWizardMessages;
+
+
+
+/**
+* Renames a XML Schema element or workbench resource.
+* <p>
+* Action is applicable to selections containing elements of type
+* <code></code> or <code>IResource</code>.
+*
+* <p>
+* This class may be instantiated; it is not intended to be subclassed.
+* </p>
+
+*/
+public class RenameAction extends SelectionDispatchAction {
+
+ private SelectionDispatchAction renameComponentAction;
+ private SelectionDispatchAction renameResourceAction;
+
+
+ public RenameAction(ISelection selection) {
+ super(selection);
+ setText(RefactoringWizardMessages.RenameAction_text);
+ renameResourceAction= new RenameResourceAction(selection);
+ renameResourceAction.setText(getText());
+
+ }
+ public RenameAction(ISelection selection, Object model) {
+ super(selection);
+ setText(RefactoringWizardMessages.RenameAction_text);
+ renameComponentAction= new RenameComponentAction(selection, model);
+ renameComponentAction.setText(getText());
+ renameResourceAction= new RenameResourceAction(selection);
+ renameResourceAction.setText(getText());
+
+ }
+
+
+
+ /*
+ * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ renameComponentAction.selectionChanged(event);
+ if (renameResourceAction != null)
+ renameResourceAction.selectionChanged(event);
+ setEnabled(computeEnabledState());
+ }
+
+ /*
+ * @see SelectionDispatchAction#update(ISelection)
+ */
+ public void update(ISelection selection) {
+ if(renameComponentAction != null){
+ renameComponentAction.update(selection);
+ }
+ if (renameResourceAction != null)
+ renameResourceAction.update(selection);
+ setEnabled(computeEnabledState());
+ }
+
+ private boolean computeEnabledState(){
+ if (renameResourceAction != null) {
+ return renameComponentAction.isEnabled() || renameResourceAction.isEnabled();
+ } else {
+ return renameComponentAction.isEnabled();
+ }
+ }
+
+ public void run(IStructuredSelection selection) {
+ if (renameComponentAction != null && renameComponentAction.isEnabled())
+ renameComponentAction.run(selection);
+ if (renameResourceAction != null && renameResourceAction.isEnabled())
+ renameResourceAction.run(selection);
+ }
+
+ public void run(ITextSelection selection) {
+ if (renameComponentAction != null && renameComponentAction.canRun())
+ renameComponentAction.run(selection);
+ else
+ MessageDialog.openInformation(XSDEditorPlugin.getShell(), RefactoringWizardMessages.RenameAction_rename, RefactoringWizardMessages.RenameAction_unavailable);
+ }
+ public void run(ISelection selection) {
+ if(selection == null){
+ super.run();
+ }
+ else{
+ super.run(selection);
+ }
+
+ }
+ public final void setRenameComponentAction(
+ SelectionDispatchAction renameComponentAction)
+ {
+ this.renameComponentAction = renameComponentAction;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java
new file mode 100644
index 0000000..7cbc3fe
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.ui.actions.GlobalBuildAction;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringComponent;
+import org.eclipse.wst.xsd.ui.internal.refactor.XMLRefactoringComponent;
+import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameComponentProcessor;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactoringWizardMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RenameRefactoringWizard;
+import org.eclipse.xsd.XSDAttributeDeclaration;
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDNamedComponent;
+import org.eclipse.xsd.XSDTypeDefinition;
+import org.w3c.dom.Node;
+
+public class RenameComponentAction extends XSDSelectionDispatchAction {
+
+ private XSDNamedComponent selectedComponent;
+
+ public RenameComponentAction(ISelection selection,
+ Object aModel) {
+ super(selection, aModel);
+
+ }
+
+ protected boolean canEnable(XSDConcreteComponent selectedObject) {
+
+ selectedComponent = null;
+ if (selectedObject instanceof XSDNamedComponent) {
+ selectedComponent = (XSDNamedComponent) selectedObject;
+
+ // if it's element reference, then this action is not appropriate
+ if (selectedComponent instanceof XSDElementDeclaration) {
+ XSDElementDeclaration element = (XSDElementDeclaration) selectedComponent;
+ if (element.isElementDeclarationReference()) {
+ selectedComponent = null;
+ }
+ }
+ if(selectedComponent instanceof XSDTypeDefinition){
+ XSDTypeDefinition type = (XSDTypeDefinition) selectedComponent;
+ XSDConcreteComponent parent = type.getContainer();
+ if (parent instanceof XSDElementDeclaration) {
+ XSDElementDeclaration element = (XSDElementDeclaration) parent;
+ if(element.getAnonymousTypeDefinition().equals(type)){
+ selectedComponent = null;
+ }
+ }
+ else if(parent instanceof XSDAttributeDeclaration) {
+ XSDAttributeDeclaration element = (XSDAttributeDeclaration) parent;
+ if(element.getAnonymousTypeDefinition().equals(type)){
+ selectedComponent = null;
+ }
+ }
+ }
+ }
+
+ return canRun();
+ }
+
+ protected boolean canEnable(Object selectedObject) {
+
+ if (selectedObject instanceof XSDConcreteComponent) {
+ return canEnable((XSDConcreteComponent) selectedObject);
+ } else if (selectedObject instanceof Node) {
+ Node node = (Node) selectedObject;
+ if (getSchema() != null) {
+ XSDConcreteComponent concreteComponent = getSchema()
+ .getCorrespondingComponent(node);
+ return canEnable(concreteComponent);
+ }
+ }
+ return false;
+
+ }
+
+ public boolean canRun() {
+
+ return selectedComponent != null;
+ }
+
+ public void run(ISelection selection) {
+ if (selectedComponent.getName() == null) {
+ selectedComponent.setName(new String());
+ }
+ if (selectedComponent.getSchema() == null) {
+ if (getSchema() != null) {
+ getSchema().updateElement(true);
+ }
+
+ }
+ RefactoringComponent component = new XMLRefactoringComponent(
+ selectedComponent,
+ (IDOMElement)selectedComponent.getElement(),
+ selectedComponent.getName(),
+ selectedComponent.getTargetNamespace());
+
+ RenameComponentProcessor processor = new RenameComponentProcessor(
+ component, selectedComponent.getName());
+ RenameRefactoring refactoring = new RenameRefactoring(processor);
+ try {
+ RefactoringWizard wizard = new RenameRefactoringWizard(
+ refactoring,
+ RefactoringWizardMessages.RenameComponentWizard_defaultPageTitle,
+ RefactoringWizardMessages
+ .RenameComponentWizard_inputPage_description,
+ null);
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
+ wizard);
+ op.run(XSDEditorPlugin.getShell(), wizard
+ .getDefaultPageTitle());
+ triggerBuild();
+ } catch (InterruptedException e) {
+ // do nothing. User action got cancelled
+ }
+
+ }
+
+ public static void triggerBuild() {
+ if (ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
+ new GlobalBuildAction(XSDEditorPlugin.getPlugin().getWorkbench()
+ .getActiveWorkbenchWindow(),
+ IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java
new file mode 100644
index 0000000..722e5e9
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameResourceProcessor;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactoringWizardMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RenameRefactoringWizard;
+
+
+
+public class RenameResourceAction extends SelectionDispatchAction {
+
+
+
+
+ public RenameResourceAction(ISelection selection)
+ {
+ super(selection);
+ }
+
+ public void selectionChanged(IStructuredSelection selection) {
+ IResource element= getResource(selection);
+ if (element == null) {
+ setEnabled(false);
+ } else {
+ RenameResourceProcessor processor= new RenameResourceProcessor(element);
+ setEnabled(processor.isApplicable());
+
+ }
+ }
+
+ public void run(IStructuredSelection selection) {
+ IResource resource = getResource(selection);
+ RenameResourceProcessor processor= new RenameResourceProcessor(resource);
+
+ if(!processor.isApplicable())
+ return;
+ RenameRefactoring refactoring= new RenameRefactoring(processor);
+ try {
+ RefactoringWizard wizard = new RenameRefactoringWizard(
+ refactoring,
+ RefactoringWizardMessages.RenameComponentWizard_defaultPageTitle, //TODO: provide correct strings
+ RefactoringWizardMessages.RenameComponentWizard_inputPage_description,
+ null);
+ RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
+ op.run(XSDEditorPlugin.getShell(), wizard.getDefaultPageTitle());
+ } catch (InterruptedException e) {
+ // do nothing. User action got cancelled
+ }
+
+ }
+
+ private static IResource getResource(IStructuredSelection selection) {
+ if (selection.size() != 1)
+ return null;
+ Object first= selection.getFirstElement();
+ if (! (first instanceof IResource))
+ return null;
+ return (IResource)first;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java
new file mode 100644
index 0000000..073f55d
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @author ebelisar@ca.ibm.com
+ */
+public class RenameResourceActionDelegate implements IObjectActionDelegate {
+
+ private ISelection fCurrentSelection;
+
+ private IWorkbenchPart fPart;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ fPart = targetPart;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ if (fCurrentSelection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection= (IStructuredSelection) fCurrentSelection;
+ Object first= structuredSelection.getFirstElement();
+ if (first instanceof IFile) {
+ RenameResourceAction renameAction = new RenameResourceAction(structuredSelection);
+ renameAction.run(structuredSelection);
+ }
+ }
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ fCurrentSelection= selection;
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameTargetNamespaceAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameTargetNamespaceAction.java
new file mode 100644
index 0000000..e7dac64
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameTargetNamespaceAction.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.ui.actions.GlobalBuildAction;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameTargetNamespaceProcessor;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactoringWizardMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RenameRefactoringWizard;
+
+public class RenameTargetNamespaceAction extends XSDSelectionDispatchAction {
+
+ public RenameTargetNamespaceAction(ISelection selection,
+ Object aModel) {
+ super(selection, aModel);
+ setText(RefactoringWizardMessages.RenameTargetNamespace_text);
+
+ }
+
+
+ protected boolean canEnable(Object selectedObject) {
+
+ return getSchema() != null;
+
+ }
+
+ public boolean canRun() {
+
+ return getSchema() != null;
+ }
+
+
+ public void run(ISelection selection) {
+
+
+ RenameTargetNamespaceProcessor processor = new RenameTargetNamespaceProcessor(getSchema(), getSchema().getTargetNamespace());
+ RenameRefactoring refactoring = new RenameRefactoring(processor);
+ try {
+ RefactoringWizard wizard = new RenameRefactoringWizard(
+ refactoring,
+ RefactoringWizardMessages.RenameComponentWizard_defaultPageTitle,//TODO: provide correct strings
+ RefactoringWizardMessages.RenameComponentWizard_inputPage_description,
+ null);
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
+ wizard);
+ op.run(XSDEditorPlugin.getShell(), wizard
+ .getDefaultPageTitle());
+ triggerBuild();
+ } catch (InterruptedException e) {
+ // do nothing. User action got cancelled
+ }
+
+ }
+
+ public static void triggerBuild() {
+ if (ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
+ new GlobalBuildAction(XSDEditorPlugin.getPlugin().getWorkbench()
+ .getActiveWorkbenchWindow(),
+ IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java
new file mode 100644
index 0000000..879eb31
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+
+
+/**
+ * Action that dispatches the <code>IAction#run()</code> and the
+ * <code>ISelectionChangedListener#selectionChanged</code>
+ * according to the type of the selection.
+ *
+ * <ul>
+ * <li>if selection is of type <code>ITextSelection</code> then
+ * <code>run(ITextSelection)</code> and <code>selectionChanged(ITextSelection)</code>
+ * is called.</li>
+ * <li>if selection is of type <code>IStructuredSelection</code> then
+ * <code>run(IStructuredSelection)</code> and <code>
+ * selectionChanged(IStructuredSelection)</code> is called.</li>
+ * <li>default is to call <code>run(ISelection)</code> and <code>
+ * selectionChanged(ISelection)</code>.</li>
+ * </ul>
+ *
+ * <p>
+ * adapted from <code>org.eclipse.jdt.ui.actions.SelectionDispatchAction</code>
+ * </p>
+ *
+ *
+ */
+public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener {
+
+ private ISelection selection;
+
+ private Object model;
+
+ protected SelectionDispatchAction(ISelection selection) {
+ Assert.isNotNull(selection);
+ this.selection = selection;
+
+ }
+
+ /**
+ * Returns the selection provided by the site owning this action.
+ *
+ * @return the site's selection
+ */
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ /**
+ * Updates the action's enablement state according to the given selection. This
+ * default implementation calls one of the <code>selectionChanged</code>
+ * methods depending on the type of the passed selection.
+ *
+ * @param selection the selection this action is working on
+ */
+ public void update(ISelection selection) {
+ dispatchSelectionChanged(selection);
+ }
+
+ /**
+ * Notifies this action that the given structured selection has changed. This default
+ * implementation calls <code>selectionChanged(ISelection selection)</code>.
+ *
+ * @param selection the new selection
+ */
+ public void selectionChanged(IStructuredSelection selection) {
+ if (selection.size() == 1) {
+ Object object = selection.getFirstElement();
+ setEnabled(canEnable(object));
+ }
+ else{
+ setEnabled(false);
+ }
+ }
+
+ protected boolean canEnable(Object selectedObject){
+ return false;
+ }
+
+ /**
+ * Executes this actions with the given structured selection. This default implementation
+ * calls <code>run(ISelection selection)</code>.
+ */
+ public void run(IStructuredSelection selection) {
+ run((ISelection)selection);
+ }
+
+
+ /**
+ * Notifies this action that the given text selection has changed. This default
+ * implementation calls <code>selectionChanged(ISelection selection)</code>.
+ *
+ * @param selection the new selection
+ */
+ public void selectionChanged(ITextSelection selection) {
+ selectionChanged((ISelection)selection);
+ }
+
+ /**
+ * Executes this actions with the given text selection. This default implementation
+ * calls <code>run(ISelection selection)</code>.
+ */
+ public void run(ITextSelection selection) {
+ run((ISelection)selection);
+ }
+
+ /**
+ * Notifies this action that the given selection has changed. This default
+ * implementation sets the action's enablement state to <code>false</code>.
+ *
+ * @param selection the new selection
+ */
+ public void selectionChanged(ISelection selection) {
+ setEnabled(false);
+ }
+
+ /**
+ * Executes this actions with the given selection. This default implementation
+ * does nothing.
+ */
+ public void run(ISelection selection) {
+ System.out.println("SelectionDispatchAction.run");
+ }
+
+ /* (non-Javadoc)
+ * Method declared on IAction.
+ */
+ public void run() {
+ dispatchRun(getSelection());
+
+ }
+
+ /* (non-Javadoc)
+ * Method declared on ISelectionChangedListener.
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ dispatchSelectionChanged(event.getSelection());
+ }
+
+ private void dispatchSelectionChanged(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ selectionChanged((IStructuredSelection)selection);
+ } else if (selection instanceof ITextSelection) {
+ selectionChanged((ITextSelection)selection);
+ } else {
+ selectionChanged(selection);
+ }
+ }
+
+ protected void dispatchRun(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ run((IStructuredSelection)selection);
+ } else if (selection instanceof ITextSelection) {
+ run((ITextSelection)selection);
+ } else {
+ run(selection);
+ }
+ }
+
+ public final Object getModel()
+ {
+ return model;
+ }
+
+ public final void setModel(Object model)
+ {
+ this.model = model;
+ }
+
+ public boolean canRun() {
+
+ return true;
+ }
+
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorActionGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorActionGroup.java
new file mode 100644
index 0000000..950fc6f
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorActionGroup.java
@@ -0,0 +1,59 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import java.util.ArrayList;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup;
+import org.eclipse.xsd.XSDSchema;
+
+public class XSDRefactorActionGroup extends RefactorActionGroup {
+
+ private static final String MAKE_ELEMENT_GLOBAL = "org.eclipse.wst.xsd.ui.refactor.makeElementGlobal"; //$NON-NLS-1$
+
+ private static final String MAKE_TYPE_GLOBAL = "org.eclipse.wst.xsd.ui.refactor.makeTypeGlobal"; //$NON-NLS-1$
+
+ private static final String RENAME_ELEMENT = "org.eclipse.wst.xsd.ui.refactor.rename.element"; //$NON-NLS-1$
+
+ private static final String RENAME_TARGET_NAMESPCE = "org.eclipse.wst.xsd.ui.refactor.renameTargetNamespace"; //$NON-NLS-1$
+
+ private SelectionDispatchAction fMakeLocalElementGlobal;
+
+ private SelectionDispatchAction fMakeLocalTypeGlobal;
+
+ public XSDRefactorActionGroup(ISelection selection,
+ XSDSchema schema) {
+ super(selection);
+ fEditorActions = new ArrayList();
+ fRenameAction = new RenameAction(selection, schema);
+ fRenameAction.setActionDefinitionId(RENAME_ELEMENT);
+ fEditorActions.add(fRenameAction);
+
+ fRenameTargetNamespace = new RenameTargetNamespaceAction(
+ selection, schema);
+ fRenameTargetNamespace.setActionDefinitionId(RENAME_TARGET_NAMESPCE);
+ fEditorActions.add(fRenameTargetNamespace);
+
+ fMakeLocalElementGlobal = new MakeLocalElementGlobalAction(
+ selection, schema);
+ fMakeLocalElementGlobal.setActionDefinitionId(MAKE_ELEMENT_GLOBAL);
+ fEditorActions.add(fMakeLocalElementGlobal);
+
+ fMakeLocalTypeGlobal = new MakeAnonymousTypeGlobalAction(
+ selection, schema);
+ fMakeLocalTypeGlobal.setActionDefinitionId(MAKE_TYPE_GLOBAL);
+ fEditorActions.add(fMakeLocalTypeGlobal);
+
+ initAction(fRenameAction, selection);
+ initAction(fRenameTargetNamespace, selection);
+ initAction(fMakeLocalElementGlobal, selection);
+ initAction(fMakeLocalTypeGlobal, selection);
+ }
+
+ public void dispose() {
+// disposeAction(fRenameAction, selection);
+// disposeAction(fMakeLocalElementGlobal, selection);
+// disposeAction(fMakeLocalTypeGlobal, selection);
+// disposeAction(fRenameTargetNamespace, selection);
+ super.dispose();
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorGroupActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorGroupActionDelegate.java
new file mode 100644
index 0000000..965fc4e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorGroupActionDelegate.java
@@ -0,0 +1,85 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import java.io.IOException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupActionDelegate;
+import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupSubMenu;
+import org.eclipse.xsd.XSDFactory;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.util.XSDResourceImpl;
+
+public class XSDRefactorGroupActionDelegate extends RefactorGroupActionDelegate {
+
+ public XSDRefactorGroupActionDelegate() {
+ super();
+ }
+
+ /**
+ * Fills the menu with applicable refactor sub-menues
+ * @param menu The menu to fill
+ */
+ protected void fillMenu(Menu menu) {
+ if (fSelection == null) {
+ return;
+ }
+ if (workbenchPart != null) {
+ IWorkbenchPartSite site = workbenchPart.getSite();
+ if (site == null)
+ return;
+
+ IEditorPart editor = site.getPage().getActiveEditor();
+ if (editor != null) {
+ IEditorInput editorInput = editor.getEditorInput();
+ if(editorInput instanceof IFileEditorInput){
+ IFileEditorInput fileInput = (IFileEditorInput)editorInput;
+ XSDSchema schema = createXMLSchema(fileInput.getFile(), resourceSet);
+ RefactorActionGroup refactorMenuGroup = new XSDRefactorActionGroup(fSelection, schema);
+ RefactorGroupSubMenu subMenu = new RefactorGroupSubMenu(refactorMenuGroup);
+ subMenu.fill(menu, -1);
+ }
+
+ }
+
+ }
+
+ }
+
+ public static XSDSchema createXMLSchema(IFile file, ResourceSet set) {
+
+ URI uri = URI.createFileURI(file.getLocation().toString());
+ XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
+ // we need this model to be able to get locations
+ try {
+ IStructuredModel structuredModel = StructuredModelManager.getModelManager().getModelForEdit(file);
+ IDOMModel domModel = (IDOMModel) structuredModel;
+ Resource xsdResource = new XSDResourceImpl();
+ xsdResource.setURI(uri);
+ schema = XSDFactory.eINSTANCE.createXSDSchema();
+ xsdResource.getContents().add(schema);
+ schema.setElement(domModel.getDocument().getDocumentElement());
+ if(set != null){
+ set.getResources().add(xsdResource);
+ }
+ } catch (IOException e) {
+ // do nothing
+ } catch (CoreException e) {
+ // do nothing
+ }
+ return schema;
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDSelectionDispatchAction.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDSelectionDispatchAction.java
new file mode 100644
index 0000000..05c72d4
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDSelectionDispatchAction.java
@@ -0,0 +1,29 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.actions;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.xsd.XSDSchema;
+
+public class XSDSelectionDispatchAction extends SelectionDispatchAction
+{
+
+
+
+ public XSDSelectionDispatchAction(ISelection selection, Object model)
+ {
+ super(selection);
+ setModel(model);
+ }
+
+ protected XSDSchema getSchema(){
+ Object model = getModel();
+ if(model instanceof XSDSchema)
+ {
+ return (XSDSchema) model;
+ }
+
+ return null;
+ }
+
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties
new file mode 100644
index 0000000..48483a1
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/messages.properties
@@ -0,0 +1,41 @@
+RefactorMenu.label=Refactor
+RefactorActionGroup.no_refactoring_available=<no refactoring available>
+
+RenameAction.rename=Rename
+RenameAction.unavailable=Operation unavailable on the current selection.\nSelect a ....
+RenameAction.text=Re&name...
+
+RenameInputWizardPage.new_name= &New name:
+RenameRefactoringWizard.internal_error= Internal error during name checking: {0}
+
+
+RenameXSDElementAction.exception=Unexpected exception occurred. See log for details
+RenameXSDElementAction.not_available=Operation unavailable on the current selection.\nSelect a XSD project, folder, resource, file, attribute declarations, attribute group definitions, complex type definitions, element declarations, identity constraint definitions, model groups definitions, notation declarations, or simple type definitions.
+RenameXSDElementAction.name=Rename
+
+
+RenameSupport.dialog.title=Rename
+RenameSupport.not_available=Rename support not available
+
+RenameComponentWizard.defaultPageTitle=Rename wizard
+RenameComponentWizard.inputPage.description=Rename XML Schema component
+
+RenameInputWizardPage.update_references=Update references
+XSDComponentRenameChange.name=XML Schema component renaming in {0}: {1} to {2}
+XSDComponentRenameChange.Renaming=Renaming...
+ResourceRenameParticipant.compositeChangeName=XSD file rename references updating changes
+RenameResourceChange.rename_resource_reference_change=Renaming resource name references
+XSDRenameResourceChange.name=Resource rename: {0} to {1}
+RenameResourceRefactoring.Internal_Error=Internal error
+RenameResourceRefactoring.alread_exists=Resource already exist
+RenameResourceRefactoring.invalidName=Invalid resource name
+RenameResourceProcessor.name=Resource renaming
+MakeLocalElementGlobalAction.text=Make Local Element Global
+XSDComponentRenameParticipant.Component_Refactoring_updates=XML Schema refactoring changes
+WSDLComponentRenameParticipant.Component_Refactoring_updates=WSDL refactoring changes
+RenameComponentProcessor.Component_Refactoring_updates=Component name refactoring changes
+RenameComponentProcessor.Component_Refactoring_update_declatation=Update component declaration/definition
+RenameComponentProcessor.Component_Refactoring_update_reference=Update component reference
+XSDComponentRenameParticipant.xsd_component_rename_participant=XSD component rename participant
+WSDLComponentRenameParticipant.wsdl_component_rename_participant=WSDL component rename participant
+ResourceRenameParticipant.File_Rename_update_reference=File rename refactoring changes
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameArguments.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameArguments.java
new file mode 100644
index 0000000..f90685d
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ComponentRenameArguments.java
@@ -0,0 +1,41 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.util.Map;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.wst.xsd.ui.internal.refactor.TextChangeManager;
+
+public class ComponentRenameArguments extends RenameArguments {
+
+ TextChangeManager changeManager;
+ Map matches;
+ String qualifier;
+
+ public ComponentRenameArguments(String newName, boolean updateReferences) {
+ super(newName, updateReferences);
+ }
+
+ public TextChangeManager getChangeManager() {
+ return changeManager;
+ }
+
+ public void setChangeManager(TextChangeManager changeManager) {
+ this.changeManager = changeManager;
+ }
+
+ public Map getMatches() {
+ return matches;
+ }
+
+ public void setMatches(Map matches) {
+ this.matches = matches;
+ }
+
+ public String getQualifier() {
+ return qualifier;
+ }
+
+ public void setQualifier(String qualifier) {
+ this.qualifier = qualifier;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java
new file mode 100644
index 0000000..fea1823
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameComponentProcessor.java
@@ -0,0 +1,484 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.wst.common.core.search.SearchEngine;
+import org.eclipse.wst.common.core.search.SearchMatch;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+import org.eclipse.wst.common.core.search.pattern.SearchPattern;
+import org.eclipse.wst.common.core.search.scope.SearchScope;
+import org.eclipse.wst.common.core.search.scope.SelectionSearchScope;
+import org.eclipse.wst.common.core.search.scope.WorkspaceSearchScope;
+import org.eclipse.wst.common.core.search.util.CollectingSearchRequestor;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentReferencePattern;
+import org.eclipse.wst.xsd.ui.internal.refactor.Checks;
+import org.eclipse.wst.xsd.ui.internal.refactor.INameUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.IReferenceUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringComponent;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.TextChangeManager;
+import org.eclipse.wst.xsd.ui.internal.refactor.util.TextChangeCompatibility;
+
+
+
+public class RenameComponentProcessor extends RenameProcessor implements INameUpdating, IReferenceUpdating {
+ public static final String IDENTIFIER = "org.eclipse.wst.xml.refactor.renameComponentProcessor"; //$NON-NLS-1$
+
+ public static String quoteString(String value) {
+ value = value == null ? "" : value;
+
+ StringBuffer sb = new StringBuffer();
+ if (!value.startsWith("\"")) {
+ sb.append("\"");
+ }
+ sb.append(value);
+ if (!value.endsWith("\"")) {
+ sb.append("\"");
+ }
+ return sb.toString();
+ }
+
+ private TextChangeManager changeManager;
+
+ private String newName;
+
+ private RefactoringComponent selectedComponent;
+
+ private boolean updateReferences = true;
+
+ private Map references = new HashMap();
+
+ public RenameComponentProcessor(RefactoringComponent selectedComponent) {
+ this.selectedComponent = selectedComponent;
+ }
+
+ public RenameComponentProcessor(RefactoringComponent selectedComponent, String newName) {
+ this.newName = newName;
+ this.selectedComponent = selectedComponent;
+ }
+
+ private void addDeclarationUpdate(TextChangeManager manager) throws CoreException {
+ String fileStr = selectedComponent.getElement().getModel().getBaseLocation();
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileStr));
+ addDeclarationUpdate(manager, file);
+ }
+
+ final void addDeclarationUpdate(TextChangeManager manager, IFile file) throws CoreException {
+
+ String componentName = selectedComponent.getName();
+ String componentNamespace = selectedComponent.getNamespaceURI();
+ QualifiedName elementQName = new QualifiedName(componentNamespace, componentName);
+ QualifiedName typeQName = selectedComponent.getTypeQName();
+
+
+
+ SearchScope scope = new WorkspaceSearchScope();
+ if (file != null) {
+ scope = new SelectionSearchScope(new IResource[]{file});
+ }
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
+ SearchPattern pattern = new XMLComponentDeclarationPattern(file, elementQName, typeQName);
+ SearchEngine searchEngine = new SearchEngine();
+ searchEngine.search(pattern, requestor, scope, new NullProgressMonitor());
+ List results = requestor.getResults();
+ for (Iterator iter = results.iterator(); iter.hasNext();) {
+ SearchMatch match = (SearchMatch) iter.next();
+ if (match != null) {
+ TextChange textChange = manager.get(match.getFile());
+ String newName = getNewElementName();
+ newName = quoteString(newName);
+
+ ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), match.getLength(), newName);
+ String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_declatation");;
+ TextChangeCompatibility.addTextEdit(textChange, editName, replaceEdit);
+ }
+ }
+ }
+
+ void addOccurrences(TextChangeManager manager, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
+
+ String fileStr = selectedComponent.getElement().getModel().getBaseLocation();
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileStr));
+
+ String componentName = selectedComponent.getName();
+ String componentNamespace = selectedComponent.getNamespaceURI();
+ QualifiedName elementQName = new QualifiedName(componentNamespace, componentName);
+ QualifiedName typeQName = selectedComponent.getTypeQName();
+
+ SearchEngine searchEngine = new SearchEngine();
+
+ SortingSearchRequestor requestor = new SortingSearchRequestor();
+ SearchPattern pattern = new XMLComponentReferencePattern(file, elementQName, typeQName);
+ searchEngine.search(pattern, requestor, new WorkspaceSearchScope(), new NullProgressMonitor());
+ references = requestor.getResults();
+ // for (Iterator iter = references.iterator(); iter.hasNext();) {
+ // SearchMatch match = (SearchMatch) iter.next();
+
+ // TextChange textChange = manager.get(match.getFile());
+ // String newName = getNewElementName();
+ // if(match.getObject() instanceof Node){
+ // Node node = (Node)match.getObject();
+ // if(node instanceof IDOMAttr){
+ // IDOMAttr attr = (IDOMAttr)node;
+ // IDOMElement element = (IDOMElement)attr.getOwnerElement() ;
+ // newName = getNewQName(element, componentNamespace, newName);
+ // }
+ // newName = quoteString(newName);
+ // }
+ //
+ // ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(),
+ // match.getLength(), newName );
+ // String editName =
+ // RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_reference");
+ // TextChangeCompatibility.addTextEdit(textChange, editName,
+ // replaceEdit);
+
+ // }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#canEnableTextUpdating()
+ */
+ public boolean canEnableTextUpdating() {
+ return true;
+ }
+
+ public boolean canEnableUpdateReferences() {
+ return true;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException {
+ Assert.isNotNull(monitor);
+ Assert.isNotNull(context);
+ final RefactoringStatus status = new RefactoringStatus();
+ try {
+ monitor.beginTask("", 2); //$NON-NLS-1$
+ monitor.setTaskName("RefactoringMessages.RenameComponentRefactoring_checking");
+ status.merge(checkNewElementName(getNewElementName()));
+ monitor.worked(1);
+ monitor.setTaskName("RefactoringMessages.RenameComponentRefactoring_searching");
+ status.merge(createRenameChanges(new SubProgressMonitor(monitor, 1)));
+ }
+ finally {
+ monitor.done();
+ }
+ return status;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ // TODO add code to check initial conditions for component rename
+ Assert.isNotNull(pm);
+ try {
+ return new RefactoringStatus();
+ }
+ finally {
+ pm.done();
+ }
+
+ }
+
+ public final RefactoringStatus checkNewElementName(final String name) {
+ Assert.isNotNull(name);
+ final RefactoringStatus result = Checks.checkName(name);
+ result.merge(Checks.checkComponentName(name));
+ if (Checks.isAlreadyNamed(selectedComponent, name))
+ result.addFatalError("RefactoringMessages.RenameComponentRefactoring_another_name");
+ return result;
+ }
+
+ private Object[] computeDerivedElements() {
+
+ Object[] elements = getElements();
+ // Object[] results = new Object[elements.length];
+ // for(int i=0; i< elements.length; i++){
+ // RefactoringComponent component = (RefactoringComponent)elements[i];
+ // results[i] = component.getAdaptee();
+ //
+ // }
+ return elements;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ // don't create any change now, all the changes are in changeManger
+ // variable and will be combined in postCreateChange method
+ return null;
+ }
+
+ private TextChangeManager updateChangeManager(IProgressMonitor pm, RefactoringStatus status) throws CoreException {
+ TextChangeManager manager = getChangeManager();
+ System.out.println("addDeclarationUpate-------------------");
+ // only one declaration gets updated
+ addDeclarationUpdate(manager);
+ if (getUpdateReferences()) {
+ System.out.println("addOccurences--------------------------");
+ addOccurrences(manager, pm, status);
+ }
+ return manager;
+ }
+
+ private RefactoringStatus createRenameChanges(final IProgressMonitor monitor) throws CoreException {
+ Assert.isNotNull(monitor);
+ final RefactoringStatus status = new RefactoringStatus();
+ try {
+ monitor.beginTask("RefactoringMessages.RenameComponentRefactoring_searching", 1);
+ updateChangeManager(new SubProgressMonitor(monitor, 1), status);
+ }
+ finally {
+ monitor.done();
+ }
+ return status;
+ }
+
+ public TextChangeManager getChangeManager() {
+
+ if (changeManager == null) {
+ changeManager = new TextChangeManager(false);
+ }
+ return changeManager;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xsd.internal.refactoring.rename.XSDRenameProcessor#getAffectedProjectNatures()
+ */
+ protected String[] getAffectedProjectNatures() throws CoreException {
+ // TODO: find project natures of the files that are going to be
+ // refactored
+ return new String[]{"org.eclipse.jdt.core.javanature"};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#getCurrentElementName()
+ */
+ public String getCurrentElementName() {
+ //
+ return selectedComponent.getName();
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
+ */
+ public Object[] getElements() {
+ Object model = selectedComponent.getModelObject();
+ if (model != null) {
+ return new Object[]{model};
+ }
+ return new Object[0];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
+ */
+ public String getIdentifier() {
+ return IDENTIFIER;
+ }
+
+ public String getNewElementName() {
+ return newName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
+ */
+ public String getProcessorName() {
+ return RefactoringMessages.getFormattedString("RenameComponentRefactoring.name", //$NON-NLS-1$
+ new String[]{selectedComponent.getNamespaceURI() + ":" + selectedComponent.getName(), newName});
+
+ }
+
+
+ public boolean getUpdateReferences() {
+ return updateReferences;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
+ */
+ public boolean isApplicable() throws CoreException {
+ if (selectedComponent == null)
+ return false;
+ // TODO implement isApplicable logic for the named component,
+ // verify how it is different from other condition checks
+ // if (fNamedComponent.isAnonymous())
+ // return false;
+ // if (! Checks.isAvailable(fType))
+ // return false;
+ // if (isSpecialCase(fType))
+ // return false;
+ return true;
+ }
+
+ protected void loadDerivedParticipants(RefactoringStatus status, List result, Object[] derivedElements, ComponentRenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException {
+ if (derivedElements != null) {
+ for (int i = 0; i < derivedElements.length; i++) {
+ RenameParticipant[] participants = ParticipantManager.loadRenameParticipants(status, this, derivedElements[i], arguments, natures, shared);
+ result.addAll(Arrays.asList(participants));
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xsd.internal.refactoring.rename.XSDRenameProcessor#loadDerivedParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus,
+ * java.util.List, java.lang.String[],
+ * org.eclipse.ltk.core.refactoring.participants.SharableParticipants)
+ */
+ protected void loadDerivedParticipants(RefactoringStatus status, List result, String[] natures, SharableParticipants shared) throws CoreException {
+ ComponentRenameArguments arguments = new ComponentRenameArguments(getNewElementName(), getUpdateReferences());
+ arguments.setMatches(references);
+ arguments.setQualifier(selectedComponent.getNamespaceURI());
+ // pass in changeManger to the participants so that it can collect all
+ // changes/per files
+ arguments.setChangeManager(getChangeManager());
+ loadDerivedParticipants(status, result, computeDerivedElements(), arguments, natures, shared);
+ }
+
+ protected void loadElementParticipants(RefactoringStatus status, List result, RenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException {
+ Object[] elements = new Object[0];// getElements();
+ for (int i = 0; i < elements.length; i++) {
+ result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status, this, elements[i], arguments, natures, shared)));
+ }
+ }
+
+
+ public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
+ RenameArguments arguments = new RenameArguments(getNewElementName(), getUpdateReferences());
+ String[] natures = getAffectedProjectNatures();
+ List result = new ArrayList();
+ loadElementParticipants(status, result, arguments, natures, sharedParticipants);
+ loadDerivedParticipants(status, result, natures, sharedParticipants);
+ for (Iterator i = result.iterator(); i.hasNext();) {
+ Object o = i.next();
+ if (o instanceof XMLComponentRenameParticipant) {
+ XMLComponentRenameParticipant p = (XMLComponentRenameParticipant) o;
+ // getChangeManager()
+ p.setChangeManager(getChangeManager());
+ }
+ }
+
+ return (RefactoringParticipant[]) result.toArray(new RefactoringParticipant[result.size()]);
+ }
+
+ public void setNewElementName(String newName) {
+ Assert.isNotNull(newName);
+ this.newName = newName;
+ }
+
+ public void setUpdateReferences(boolean update) {
+ updateReferences = update;
+
+ }
+
+ public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException, OperationCanceledException {
+ Assert.isNotNull(pm);
+ try {
+ String changeName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_updates");
+ TextChange[] changes = changeManager.getAllChanges();
+ // System.out.println("all changes(" + getChangeManager() + ")" +
+ // changes.length);
+ // System.out.println("add cus " +
+ // changeManager.getAllCompilationUnits().length);
+ Comparator c = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ TextFileChange c1 = (TextFileChange) o1;
+ TextFileChange c2 = (TextFileChange) o2;
+ return Collator.getInstance().compare(c1.getFile().getFullPath(), c2.getFile().getFullPath());
+ }
+ };
+ if (changes.length > 0) {
+ // Arrays.sort(changes, c);
+ CompositeChange compositeChange = new CompositeChange("!" + changeName, changes);
+ compositeChange.markAsSynthetic();
+ return compositeChange;
+ }
+ else {
+ return null;
+ }
+
+ }
+ finally {
+ pm.done();
+ }
+ }
+
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java
new file mode 100644
index 0000000..f0a326e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameResourceProcessor.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.wst.xsd.ui.internal.refactor.INameUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+
+public class RenameResourceProcessor extends RenameProcessor implements INameUpdating {
+
+ private IResource fResource;
+ private String fNewElementName;
+
+ public static final String IDENTIFIER= "org.eclipse.wst.ui.xsd.renameResourceProcessor"; //$NON-NLS-1$
+
+ public RenameResourceProcessor(IResource resource) {
+ fResource= resource;
+ if (fResource != null) {
+ setNewElementName(fResource.getName());
+ }
+ }
+
+ //---- INameUpdating ---------------------------------------------------
+
+ public void setNewElementName(String newName) {
+ Assert.isNotNull(newName);
+ fNewElementName= newName;
+ }
+
+ public String getNewElementName() {
+ return fNewElementName;
+ }
+
+ //---- IRenameProcessor methods ---------------------------------------
+
+ public String getIdentifier() {
+ return IDENTIFIER;
+ }
+
+ public boolean isApplicable() {
+ if (fResource == null)
+ return false;
+ if (! fResource.exists())
+ return false;
+ if (! fResource.isAccessible())
+ return false;
+ return true;
+ }
+
+ public String getProcessorName() {
+ String message= RefactoringMessages.getFormattedString("RenameResourceProcessor.name", //$NON-NLS-1$
+ new String[]{getCurrentElementName(), getNewElementName()});
+ return message;
+ }
+
+ public Object[] getElements() {
+ return new Object[] {fResource};
+ }
+
+ public String getCurrentElementName() {
+ return fResource.getName();
+ }
+
+ public String[] getAffectedProjectNatures() throws CoreException {
+ return new String[0];
+ }
+
+ public Object getNewElement() {
+
+
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(createNewPath(getNewElementName()));
+ }
+
+ public boolean getUpdateReferences() {
+ return true;
+ }
+
+ public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared) throws CoreException {
+ Object[] elements= getElements();
+ String[] natures= getAffectedProjectNatures();
+ List result= new ArrayList();
+ RenameArguments arguments= new RenameArguments(getNewElementName(), getUpdateReferences());
+ for (int i= 0; i < elements.length; i++) {
+ result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
+ this, elements[i],
+ arguments, natures, shared)));
+ }
+ return (RefactoringParticipant[])result.toArray(new RefactoringParticipant[result.size()]);
+ }
+
+ //--- Condition checking --------------------------------------------
+
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
+ return new RefactoringStatus();
+ }
+
+ /* non java-doc
+ * @see IRenameRefactoring#checkNewName()
+ */
+ public RefactoringStatus checkNewElementName(String newName) {
+ Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
+ IContainer c= fResource.getParent();
+ if (c == null)
+ return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.Internal_Error")); //$NON-NLS-1$
+
+ if (c.findMember(newName) != null)
+ return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.alread_exists")); //$NON-NLS-1$
+
+ if (!c.getFullPath().isValidSegment(newName))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getString("RenameResourceRefactoring.invalidName")); //$NON-NLS-1$
+
+ RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, fResource.getType()));
+ if (! result.hasFatalError())
+ result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
+ return result;
+ }
+
+ /* non java-doc
+ * @see Refactoring#checkInput(IProgressMonitor)
+ */
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) {
+ pm.beginTask("", 1); //$NON-NLS-1$
+ try{
+ return new RefactoringStatus();
+ } finally{
+ pm.done();
+ }
+ }
+
+ private String createNewPath(String newName){
+ return fResource.getFullPath().removeLastSegments(1).append(newName).toString();
+ }
+
+ //--- changes
+
+ /* non java-doc
+ * @see IRefactoring#createChange(IProgressMonitor)
+ */
+ public Change createChange(IProgressMonitor pm) {
+ pm.beginTask("", 1); //$NON-NLS-1$
+ try{
+ return new ResourceRenameChange(fResource, getNewElementName());
+ } finally{
+ pm.done();
+ }
+ }
+}
+
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameTargetNamespaceProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameTargetNamespaceProcessor.java
new file mode 100644
index 0000000..03fe81e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/RenameTargetNamespaceProcessor.java
@@ -0,0 +1,418 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.wst.xsd.ui.internal.refactor.INameUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.IReferenceUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringComponent;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.TextChangeManager;
+import org.eclipse.xsd.XSDSchema;
+
+
+public class RenameTargetNamespaceProcessor extends RenameProcessor implements INameUpdating, IReferenceUpdating
+{
+ private String newNamespace;
+ private boolean updateReferences = true;
+ private TextChangeManager changeManager;
+ private XSDSchema model;
+
+
+ public static final String IDENTIFIER = "org.eclipse.wst.ui.xsd.renameComponentProcessor"; //$NON-NLS-1$
+
+ public RenameTargetNamespaceProcessor(XSDSchema model, String newName)
+ {
+ this.model = model;
+ this.newNamespace = newName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#canEnableTextUpdating()
+ */
+ public boolean canEnableTextUpdating()
+ {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#getCurrentElementName()
+ */
+ public String getCurrentElementName()
+ {
+ //
+ return model.getTargetNamespace();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xsd.internal.refactoring.rename.XSDRenameProcessor#getAffectedProjectNatures()
+ */
+ protected String[] getAffectedProjectNatures() throws CoreException
+ {
+ // TODO: find project natures of the files that are going to be
+ // refactored
+ return new String[]{"org.eclipse.jdt.core.javanature"};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xsd.internal.refactoring.rename.XSDRenameProcessor#loadDerivedParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus,
+ * java.util.List, java.lang.String[],
+ * org.eclipse.ltk.core.refactoring.participants.SharableParticipants)
+ */
+ protected void loadDerivedParticipants(RefactoringStatus status,
+ List result, String[] natures, SharableParticipants shared)
+ throws CoreException
+ {
+ String newCUName= getNewElementName(); //$NON-NLS-1$
+ RenameArguments arguments= new RenameArguments(newCUName, getUpdateReferences());
+ loadDerivedParticipants(status, result,
+ computeDerivedElements(), arguments,
+ natures, shared);
+ }
+
+ protected void loadDerivedParticipants(RefactoringStatus status, List result, Object[] derivedElements,
+ RenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException {
+ if (derivedElements != null) {
+ for (int i= 0; i < derivedElements.length; i++) {
+ RenameParticipant[] participants= ParticipantManager.loadRenameParticipants(status,
+ this, derivedElements[i],
+ arguments, natures, shared);
+ result.addAll(Arrays.asList(participants));
+ }
+ }
+
+ }
+
+ private Object[] computeDerivedElements() {
+
+ Object[] elements = getElements();
+ Object[] results = new Object[elements.length];
+ for(int i=0; i< elements.length; i++){
+ RefactoringComponent component = (RefactoringComponent)elements[i];
+ results[i] = component.getModelObject();
+
+ }
+ return results;
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws CoreException,
+ OperationCanceledException
+ {
+ try
+ {
+ RefactoringStatus result = new RefactoringStatus();
+ pm.beginTask("", 9); //$NON-NLS-1$
+ changeManager = createChangeManager(new SubProgressMonitor(pm, 1),
+ result);
+ return result;
+ } finally
+ {
+ pm.done();
+ }
+
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException
+ {
+ // TODO add code to check initial conditions for component rename
+ return new RefactoringStatus();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException
+ {
+ try
+ {
+ String changeName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_updates");
+ return new CompositeChange(changeName, changeManager.getAllChanges());
+ } finally
+ {
+ pm.done();
+ }
+
+ // Change[] changes = ComponentRenameChange.createChangesFor(
+ // this.fNamedComponent, getNewElementName());
+ //
+ // if (changes.length > 0)
+ // {
+ // CompositeChange multiChange = null;
+ // multiChange = new CompositeChange(
+ // "XSD component rename participant changes", changes); //$NON-NLS-1$
+ // TODO: externalize string
+ // return multiChange;
+ // } else
+ // {
+ //
+ // return new ComponentRenameChange(
+ // fNamedComponent,
+ // fNamedComponent.getName(),
+ // getNewElementName(),
+ // fNamedComponent.getSchema());
+ // }
+
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
+ */
+ public Object[] getElements()
+ {
+ return new Object[] { model };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
+ */
+ public String getIdentifier()
+ {
+ return IDENTIFIER;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
+ */
+ public String getProcessorName()
+ {
+ return RefactoringMessages.getFormattedString(
+ "RenameComponentRefactoring.name", //$NON-NLS-1$
+ new String[]
+ {
+ getCurrentElementName(),
+ getNewElementName() });
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
+ */
+ public boolean isApplicable() throws CoreException
+ {
+ if (getModel() == null)
+ return false;
+ // TODO implement isApplicable logic for the named component,
+ // verify how it is different from other condition checks
+ // if (fNamedComponent.isAnonymous())
+ // return false;
+ // if (! Checks.isAvailable(fType))
+ // return false;
+ // if (isSpecialCase(fType))
+ // return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#checkNewElementName(java.lang.String)
+ */
+ public RefactoringStatus checkNewElementName(String newName)
+ {
+ Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
+ // TODO: implement new name checking
+ // RefactoringStatus result = Checks.checkTypeName(newName);
+ // if (Checks.isAlreadyNamed(fType, newName))
+ // result.addFatalError(RefactoringCoreMessages.getString("RenameTypeRefactoring.choose_another_name"));
+ // //$NON-NLS-1$
+ return new RefactoringStatus();
+ }
+
+ public final RefactoringParticipant[] loadParticipants(
+ RefactoringStatus status, SharableParticipants sharedParticipants)
+ throws CoreException
+ {
+ RenameArguments arguments = new RenameArguments(getNewElementName(),
+ true);
+ String[] natures = getAffectedProjectNatures();
+ List result = new ArrayList();
+ loadElementParticipants(status, result, arguments, natures,
+ sharedParticipants);
+ loadDerivedParticipants(status, result, natures, sharedParticipants);
+ return (RefactoringParticipant[]) result
+ .toArray(new RefactoringParticipant[result.size()]);
+ }
+
+ protected void loadElementParticipants(RefactoringStatus status,
+ List result, RenameArguments arguments, String[] natures,
+ SharableParticipants shared) throws CoreException
+ {
+ Object[] elements = getElements();
+ for (int i = 0; i < elements.length; i++)
+ {
+ result.addAll(Arrays.asList(ParticipantManager
+ .loadRenameParticipants(status, this, elements[i],
+ arguments, natures, shared)));
+ }
+ }
+
+ private TextChangeManager createChangeManager(IProgressMonitor pm,
+ RefactoringStatus status) throws CoreException
+ {
+ TextChangeManager manager = new TextChangeManager(false);
+ // only one declaration gets updated
+ addDeclarationUpdate(manager);
+ return manager;
+ }
+
+ private void addDeclarationUpdate(TextChangeManager manager)
+
+ {
+ String fileStr = getModel().getSchemaLocation();
+ URI uri = URI.createPlatformResourceURI(fileStr);
+ try
+ {
+ URL url = new URL(uri.toString());
+ url = Platform.resolve(url);
+ if(url != null){
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile file = root.getFileForLocation(new Path(url.getFile()));
+ if(file != null ){
+ TextChange change = manager.get(file);
+ addDeclarationUpdate(change);
+ }
+ }
+ } catch (MalformedURLException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
+
+
+ final void addDeclarationUpdate(TextChange change)
+ {
+// String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_declatation");;
+//
+// NamedComponentRenamer renamer = new NamedComponentRenamer(
+// selectedComponent.getElement(), newNamespace);
+// renamer.renameComponent();
+// List textEdits = renamer.getTextEdits();
+// for (int j = 0; j < textEdits.size(); j++)
+// {
+// ReplaceEdit replaceEdit = (ReplaceEdit) textEdits
+// .get(j);
+// TextChangeCompatibility.addTextEdit(change,
+// editName, replaceEdit);
+// }
+ }
+
+ public void setNewElementName(String newName)
+ {
+ this.newNamespace = newName;
+ }
+
+ public String getNewElementName()
+ {
+ return newNamespace;
+ }
+
+
+
+ public boolean canEnableUpdateReferences()
+ {
+ return true;
+ }
+
+ public boolean getUpdateReferences()
+ {
+ return updateReferences;
+ }
+
+ public void setUpdateReferences(boolean update)
+ {
+ updateReferences = update;
+
+ }
+
+ public final TextChangeManager getChangeManager()
+ {
+ return changeManager;
+ }
+
+ public final XSDSchema getModel()
+ {
+ return model;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java
new file mode 100644
index 0000000..ed6650c
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameChange.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+
+/**
+ * Represents a change that renames a given resource
+ */
+public class ResourceRenameChange extends Change {
+
+ /*
+ * we cannot use handles because they became invalid when you rename the resource.
+ * paths do not.
+ */
+ private IPath fResourcePath;
+
+ private String fNewName;
+
+ /**
+ * @param newName includes the extension
+ */
+ public ResourceRenameChange(IResource resource, String newName) {
+ this(resource.getFullPath(), newName);
+ }
+
+ private ResourceRenameChange(IPath resourcePath, String newName) {
+ fResourcePath= resourcePath;
+ fNewName= newName;
+ }
+
+ private IResource getResource() {
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath);
+ }
+
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
+
+ // TODO: implement file validation, see JDTChange
+ return new RefactoringStatus();
+ }
+
+ /*
+ * to avoid the exception senders should check if a resource with the new name
+ * already exists
+ */
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ try {
+ if (false)
+ throw new NullPointerException();
+ pm.beginTask(RefactoringMessages.getString("XSDRenameResourceChange.rename_resource"), 1); //$NON-NLS-1$
+
+ getResource().move(renamedResourcePath(fResourcePath, fNewName), getCoreRenameFlags(), pm);
+
+ String oldName= fResourcePath.lastSegment();
+ IPath newPath= renamedResourcePath(fResourcePath, fNewName);
+ return new ResourceRenameChange(newPath, oldName);
+ } finally {
+ pm.done();
+ }
+ }
+
+ private int getCoreRenameFlags() {
+ if (getResource().isLinked())
+ return IResource.SHALLOW;
+ else
+ return IResource.NONE;
+ }
+
+ /*
+ * changes resource names /s/p/A.java renamed to B.java becomes /s/p/B.java
+ */
+ public static IPath renamedResourcePath(IPath path, String newName) {
+ return path.removeLastSegments(1).append(newName);
+ }
+
+ public String getName() {
+ return RefactoringMessages.getFormattedString(
+ "XSDRenameResourceChange.name", new String[]{fResourcePath.toString(), //$NON-NLS-1$
+ renamedResourcePath(fResourcePath, fNewName).toString()});
+ }
+
+ public Object getModifiedElement() {
+ return getResource();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void initializeValidationData(IProgressMonitor pm) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java
new file mode 100644
index 0000000..78c9932
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/ResourceRenameParticipant.java
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.TextChangeManager;
+import org.eclipse.xsd.XSDNamedComponent;
+import org.eclipse.xsd.XSDSchema;
+
+/**
+ * This rename participant creates text changes for the references of the XSD and WSDL files
+ */
+public class ResourceRenameParticipant extends RenameParticipant {
+
+ private IFile file = null;
+ private TextChangeManager changeManager;
+
+
+ private static String XSD_CONTENT_TYPE_ID = "org.eclipse.wst.xsd.core.xsdsource";
+ private static String WSDL_CONTENT_TYPE_ID = "org.eclipse.wst.wsdl.wsdlsource";
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
+ */
+ protected boolean initialize(Object element) {
+ if(element instanceof IFile) {
+ // check if file has XSD or WSDL content
+ IFile aFile = (IFile) element;
+ try {
+ IContentDescription description = aFile.getContentDescription();
+ IContentType contentType = description.getContentType();
+ if(contentType != null){
+ if(XSD_CONTENT_TYPE_ID.equals(contentType.getId()) ||
+ WSDL_CONTENT_TYPE_ID.equals(contentType.getId())){
+ file = aFile;
+ return true;
+ }
+ }
+ } catch (CoreException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
+ */
+ public String getName() {
+ return RefactoringMessages.getString("ResourceRenameParticipant.compositeChangeName");
+ }
+
+ private IPath getNewFilePath() {
+
+ IPath oldPath = file.getRawLocation();
+ IPath newPath = oldPath.removeLastSegments(1).append(getArguments().getNewName());
+ return newPath;
+ }
+
+ public RefactoringStatus checkConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws OperationCanceledException
+ {
+ RefactoringStatus result = new RefactoringStatus();
+ try
+ {
+ pm.beginTask("", 9); //$NON-NLS-1$
+ changeManager = createChangeManager(new SubProgressMonitor(pm, 1),
+ result);
+
+ } catch(CoreException e){
+ result.addFatalError(e.toString());
+ }
+ finally
+ {
+ pm.done();
+ }
+ return result;
+
+ }
+
+
+
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException
+ {
+ try
+ {
+ String changeName = RefactoringMessages.getString("RenameResourceChange.rename_resource_reference_change");
+ TextChange[] changes = changeManager.getAllChanges();
+ if(changes.length > 0){
+ return new CompositeChange(changeName, changes);
+ }
+ else{
+ return null;
+ }
+
+ } finally
+ {
+ pm.done();
+ }
+
+ }
+
+
+ private TextChangeManager createChangeManager(IProgressMonitor pm,
+ RefactoringStatus status) throws CoreException
+ {
+ TextChangeManager manager = new TextChangeManager(false);
+ // only one declaration gets updated
+ //addDeclarationUpdate(manager);
+ if (getArguments().getUpdateReferences())
+ addOccurrences(manager, pm, status);
+ return manager;
+ }
+
+
+
+ void addOccurrences(TextChangeManager manager, IProgressMonitor pm,
+ RefactoringStatus status) throws CoreException
+ {
+//
+// Object[] occurrences = SearchTools.getFileDependencies(file);
+// pm.beginTask("", occurrences.length); //$NON-NLS-1$
+//
+// for (int i = 0; i < occurrences.length; i++)
+// {
+// Object object = occurrences[i];
+//
+// if (object instanceof SearchResultGroup)
+// {
+// SearchResultGroup searchResult = (SearchResultGroup) object;
+// if (searchResult == null)
+// continue;
+//
+// IFile referencingFile = (IFile)searchResult.getResource();
+//
+// resourceSet = new ResourceSetImpl();
+// // for each result file create XSD model and get component from that model
+// resourceSet.getAdapterFactories().add(
+// new XSDSchemaLocationResolverAdapterFactory());
+// URI uri = URI.createFileURI(referencingFile.getLocation().toPortableString());
+// try
+// {
+// XSDSchema schema = XSDFactory.eINSTANCE.createXSDSchema();
+// IStructuredModel structuredModel = StructuredModelManager.getModelManager().getModelForRead(referencingFile);
+// IDOMModel domModel = (IDOMModel) structuredModel;
+// Resource resource = new XSDResourceImpl();
+// resource.setURI(uri);
+// schema = XSDFactory.eINSTANCE.createXSDSchema();
+// resource.getContents().add(schema);
+// resourceSet.getResources().add(resource);
+// schema.setElement(domModel.getDocument().getDocumentElement());
+// // get target namespace
+// String stringPath = file.getLocation().toString();
+// String targetNamespace = XMLQuickScan.getTargetNamespace(stringPath);
+// targetNamespace = targetNamespace == null ? "" : targetNamespace;
+//
+// List textEdits = new ArrayList();
+// SearchMatch[] matches = searchResult.getSearchResults();
+//
+// for (int j = 0; j < matches.length; j++) {
+// SearchMatch match = matches[j];
+//
+// FileReferenceRenamer renamer = new FileReferenceRenamer(
+// match.getAttrValue(), targetNamespace, getNewFilePath().toString(), schema);
+// renamer.visitSchema(schema);
+// textEdits.addAll(renamer.getTextEdits());
+// }
+//
+//
+// if(!textEdits.isEmpty()){
+// TextChange textChange = manager.get(referencingFile);
+// for (int j = 0; j < textEdits.size(); j++)
+// {
+// ReplaceEdit replaceEdit = (ReplaceEdit) textEdits
+// .get(j);
+// String editName = RefactoringMessages.getString("ResourceRenameParticipant.File_Rename_update_reference");
+// TextChangeCompatibility.addTextEdit(textChange,
+// editName, replaceEdit);
+// }
+// }
+//
+// } catch (Exception e)
+// {
+// e.printStackTrace();
+// } finally
+// {
+//
+// }
+// }
+// }
+ }
+
+
+ public class ReferenceLocationFinder
+ {
+ protected XSDNamedComponent component;
+ protected String name;
+ protected XSDSchema referencingSchema;
+ protected List results = new ArrayList();
+
+ public ReferenceLocationFinder(XSDNamedComponent component,
+ String name, XSDSchema referencingSchema)
+ {
+ this.component = component;
+ this.name = name;
+ this.referencingSchema = referencingSchema;
+ }
+
+ public void run()
+ {
+
+ //XSDSwitch xsdSwitch = new XSDSwitch()
+// {
+// public Object caseXSDTypeDefinition(XSDTypeDefinition object)
+// {
+// GlobalTypeReferenceRenamer renamer = new GlobalTypeReferenceRenamer(
+// object.getName(), object.getTargetNamespace(), name, referencingSchema);
+// renamer.visitSchema(referencingSchema);
+// results.addAll(renamer.getTextEdits());
+// return null;
+// }
+//
+// public Object caseXSDElementDeclaration(
+// XSDElementDeclaration object)
+// {
+// if (object.isGlobal())
+// {
+// GlobalElementRenamer renamer = new GlobalElementRenamer(
+// object.getName(), object.getTargetNamespace(), name, referencingSchema);
+// renamer.visitSchema(referencingSchema);
+// results.addAll(renamer.getTextEdits());
+// }
+// return null;
+// }
+//
+// public Object caseXSDModelGroupDefinition(
+// XSDModelGroupDefinition object)
+// {
+// GlobalGroupRenamer renamer = new GlobalGroupRenamer(
+// object.getName(), object.getTargetNamespace(), name, referencingSchema);
+// renamer.visitSchema(referencingSchema);
+// return null;
+// }
+// };
+ //xsdSwitch.doSwitch(component);
+// component.setName(name);
+// try
+// {
+// referencingSchema.eResource().save(new HashMap());
+// } catch (IOException e)
+// {
+// e.printStackTrace();
+// }
+
+ }
+
+ public final List getResults()
+ {
+ return results;
+ }
+ }
+
+
+
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/SortingSearchRequestor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/SortingSearchRequestor.java
new file mode 100644
index 0000000..25179e7
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/SortingSearchRequestor.java
@@ -0,0 +1,76 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.common.core.search.SearchMatch;
+import org.eclipse.wst.common.core.search.SearchRequestor;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class SortingSearchRequestor extends SearchRequestor {
+
+ public static String NONAMESPACE = "nonamespace";
+
+
+ private Map fFound;
+
+ public SortingSearchRequestor() {
+ fFound= new HashMap();
+ }
+
+
+
+ /**
+ * @return a List of {@link SearchMatch}es (sorted by namespace)
+ */
+ public Map/* namespace - <SearchMatch>*/ getResults() {
+ return fFound;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.common.core.search.internal.provisional.SearchRequestor#acceptSearchMatch(org.eclipse.wst.common.search.internal.provisional.SearchMatch)
+ */
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+
+
+ if(match != null && match.getObject() instanceof Node){
+ Node node = (Node)match.getObject();
+ Element domElement = null;
+ switch (node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE:
+ domElement = ((Attr)node).getOwnerElement();
+ break;
+ case Node.ELEMENT_NODE:
+ domElement = ((Element)node);
+ break;
+ default:
+ break;
+ }
+ String namespace = domElement.getNamespaceURI();
+ if(namespace == null || namespace.equals("")){
+ namespace = NONAMESPACE;
+ }
+ List matches = getMatches(namespace);
+ matches.add(match);
+ }
+
+ }
+
+ private List getMatches(String namespace){
+ Object matches = fFound.get(namespace);
+ if(!(matches instanceof List)){
+ matches = new ArrayList();
+ fFound.put(namespace, matches);
+ }
+ return (List)matches;
+
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/XMLComponentRenameParticipant.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/XMLComponentRenameParticipant.java
new file mode 100644
index 0000000..cce160c
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/XMLComponentRenameParticipant.java
@@ -0,0 +1,129 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.wst.common.core.search.SearchMatch;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+import org.eclipse.wst.xsd.ui.internal.refactor.TextChangeManager;
+import org.eclipse.wst.xsd.ui.internal.refactor.util.TextChangeCompatibility;
+import org.eclipse.xsd.util.XSDConstants;
+import org.w3c.dom.Node;
+
+public class XMLComponentRenameParticipant extends RenameParticipant {
+
+ protected SearchMatch match;
+
+ protected TextChangeManager changeManager;
+ protected List matches;
+
+
+
+ protected boolean initialize(Object element) {
+
+ if(getArguments() instanceof ComponentRenameArguments){
+ // changeManger is passed in from the RenameComponentProcessor to collect all the changes
+ changeManager = ((ComponentRenameArguments)getArguments()).getChangeManager();
+ }
+
+ return false;
+ }
+
+ public String getName() {
+ return "XML Component Rename Participant";
+ }
+
+ public RefactoringStatus checkConditions(IProgressMonitor monitor,
+ CheckConditionsContext context) throws OperationCanceledException {
+ return null;
+ }
+
+ public TextChangeManager getChangeManager(){
+
+ if(changeManager == null){
+ changeManager = new TextChangeManager(false);
+ }
+ return changeManager;
+
+ }
+
+ private RefactoringStatus createRenameChanges(final IProgressMonitor monitor) throws CoreException {
+ Assert.isNotNull(monitor);
+ final RefactoringStatus status= new RefactoringStatus();
+ try {
+ monitor.beginTask("RefactoringMessages.RenameComponentRefactoring_searching", 1);
+ createRenameChanges(new SubProgressMonitor(monitor, 1));
+ //updateChangeManager(new SubProgressMonitor(monitor, 1), status);
+ } finally {
+ monitor.done();
+ }
+ return status;
+ }
+
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ //System.out.println("createChange(" + getChangeManager() + ")" + matches.size());
+ for (Iterator iter = matches.iterator(); iter.hasNext();) {
+ SearchMatch match = (SearchMatch) iter.next();
+ TextChange textChange = getChangeManager().get(match.getFile());
+ String newName = getArguments().getNewName();
+ String qualifier = "";
+ if(getArguments() instanceof ComponentRenameArguments){
+ qualifier = ((ComponentRenameArguments)getArguments()).getQualifier();
+ }
+ if(match.getObject() instanceof Node){
+ Node node = (Node)match.getObject();
+ if(node instanceof IDOMAttr){
+ IDOMAttr attr = (IDOMAttr)node;
+ IDOMElement element = (IDOMElement)attr.getOwnerElement() ;
+ newName = getNewQName(element, qualifier, newName);
+ }
+ newName = RenameComponentProcessor.quoteString(newName);
+ }
+
+ ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), match.getLength(), newName );
+ String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_reference");
+ // System.out.println("textChange " + textChange + "/ replaceEdit " + replaceEdit);
+ TextChangeCompatibility.addTextEdit(textChange, editName, replaceEdit);
+ }
+ // don't create any change now, all the changes are in changeManger variable and will be combined in RenameComponentProcessor.postCreateChange method
+ return null;
+ }
+
+ private static String getNewQName(Node node, String targetNamespace, String newName) {
+ StringBuffer sb = new StringBuffer();
+ if (newName != null) {
+ String prefix = XSDConstants.lookupQualifier(node, targetNamespace);
+ if (prefix != null && prefix.length() > 0) {
+ sb.append(prefix);
+ sb.append(":");
+ sb.append(newName);
+ } else {
+ sb.append(newName);
+ }
+ } else {
+ sb.append(newName);
+ }
+
+ return sb.toString();
+ }
+
+ public void setChangeManager(TextChangeManager changeManager)
+ {
+ this.changeManager = changeManager;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDComponentRenameParticipant.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDComponentRenameParticipant.java
new file mode 100644
index 0000000..c61fc01
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDComponentRenameParticipant.java
@@ -0,0 +1,32 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.rename;
+
+import java.util.List;
+import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
+import org.eclipse.xsd.XSDNamedComponent;
+
+/**
+ * This participant takes case of renaming matches that are XSD components
+ */
+public class XSDComponentRenameParticipant extends XMLComponentRenameParticipant {
+
+protected boolean initialize(Object element) {
+ super.initialize(element);
+ if(element instanceof XSDNamedComponent){
+ if(getArguments() instanceof ComponentRenameArguments){
+ matches = (List)((ComponentRenameArguments)getArguments()).getMatches().get(IXSDSearchConstants.XMLSCHEMA_NAMESPACE);
+ }
+ if(matches != null){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getName() {
+
+ return "XSD component rename participant";
+ }
+
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/AbstractCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/AbstractCommand.java
new file mode 100644
index 0000000..3972831
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/AbstractCommand.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.structure;
+
+import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
+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.xsd.XSDConcreteComponent;
+import org.w3c.dom.Element;
+
+public abstract class AbstractCommand
+{
+ private XSDConcreteComponent parent;
+ private XSDConcreteComponent model;
+
+ protected AbstractCommand(XSDConcreteComponent parent)
+ {
+ this.parent = parent;
+ }
+
+ public abstract void run();
+
+ protected XSDConcreteComponent getParent()
+ {
+ return parent;
+ }
+
+ public XSDConcreteComponent getModelObject()
+ {
+ return model;
+ }
+
+ protected void setModelObject(XSDConcreteComponent model)
+ {
+ this.model = model;
+ }
+
+ // Establish part-whole relationship
+ protected abstract boolean adopt(XSDConcreteComponent model);
+
+ 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();
+ }
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeAnonymousTypeGlobalCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeAnonymousTypeGlobalCommand.java
new file mode 100644
index 0000000..95f96a4
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeAnonymousTypeGlobalCommand.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.structure;
+
+import org.eclipse.xsd.XSDAttributeDeclaration;
+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;
+
+public final class MakeAnonymousTypeGlobalCommand extends AbstractCommand {
+
+ String fNewName;
+
+ public MakeAnonymousTypeGlobalCommand(XSDConcreteComponent element,
+ String newName) {
+ super(element.getContainer());
+ setModelObject(element);
+ fNewName = newName;
+ }
+
+ public void run() {
+ XSDConcreteComponent model = getModelObject();
+ XSDConcreteComponent parent = model.getContainer();
+ XSDTypeDefinition globalTypeDef = null;
+ if (model instanceof XSDComplexTypeDefinition) {
+ if (parent instanceof XSDElementDeclaration) {
+ // clone typedef with it's content and set it global
+ globalTypeDef = (XSDComplexTypeDefinition) model
+ .cloneConcreteComponent(true, false);
+ globalTypeDef.setName(fNewName);
+ parent.getSchema().getContents().add(globalTypeDef);
+ ((XSDElementDeclaration) parent)
+ .setTypeDefinition(globalTypeDef);
+ }
+ } else if (model instanceof XSDSimpleTypeDefinition) {
+
+ XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) model;
+ if (parent instanceof XSDElementDeclaration) {
+ // clone typedef with it's content and set it global
+ globalTypeDef = (XSDSimpleTypeDefinition) typeDef
+ .cloneConcreteComponent(true, false);
+ globalTypeDef.setName(fNewName);
+ parent.getSchema().getContents().add(globalTypeDef);
+ ((XSDElementDeclaration) parent)
+ .setTypeDefinition(globalTypeDef);
+ formatChild(globalTypeDef.getElement());
+
+ } else if (parent instanceof XSDAttributeDeclaration) {
+ // clone typedef with it's content and set it global
+ globalTypeDef = (XSDSimpleTypeDefinition) typeDef
+ .cloneConcreteComponent(true, false);
+ globalTypeDef.setName(fNewName);
+ parent.getSchema().getContents().add(globalTypeDef);
+ ((XSDAttributeDeclaration) parent)
+ .setTypeDefinition((XSDSimpleTypeDefinition) globalTypeDef);
+
+ }
+
+ }
+
+ formatChild(globalTypeDef.getElement());
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
+ */
+ protected boolean adopt(XSDConcreteComponent model) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java
new file mode 100644
index 0000000..28bc4ac
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeLocalElementGlobalCommand.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.structure;
+
+import org.eclipse.xsd.XSDComplexTypeContent;
+import org.eclipse.xsd.XSDConcreteComponent;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDFactory;
+import org.eclipse.xsd.XSDModelGroup;
+import org.eclipse.xsd.XSDParticle;
+import org.eclipse.xsd.XSDTypeDefinition;
+
+public final class MakeLocalElementGlobalCommand extends AbstractCommand
+{
+
+ public MakeLocalElementGlobalCommand
+ (XSDConcreteComponent element)
+ {
+ super(element.getContainer());
+ setModelObject(element);
+ }
+
+ public void run()
+ {
+
+ if(getModelObject() instanceof XSDElementDeclaration){
+
+ XSDElementDeclaration element = (XSDElementDeclaration)getModelObject();
+ XSDConcreteComponent parent = getParent();
+ XSDConcreteComponent container = parent.getContainer();
+
+ // clone element with it's content and set it global
+ XSDConcreteComponent elementDecl = ((XSDElementDeclaration)getModelObject()).cloneConcreteComponent(true, true);
+ container.getSchema().getContents().add(elementDecl);
+
+ // create local element and set it's reference to the global one
+ XSDElementDeclaration elementRef =
+ XSDFactory.eINSTANCE.createXSDElementDeclaration();
+ elementRef.setValue(element.getValue());
+ elementRef.setResolvedElementDeclaration((XSDElementDeclaration)elementDecl);
+
+ // now set content models
+ if(parent instanceof XSDComplexTypeContent){
+ if(container instanceof XSDModelGroup){
+ XSDModelGroup modelGroup = (XSDModelGroup)container;
+ // disconnect parent from its container
+ int index = modelGroup.getContents().indexOf(parent);
+ XSDParticle particle =
+ XSDFactory.eINSTANCE.createXSDParticle();
+ particle.setContent(elementRef);
+ modelGroup.getContents().add(index, particle);
+
+ modelGroup.getContents().remove(parent);
+ modelGroup.updateElement(true);
+ formatChild(modelGroup.getElement());
+ }
+ }
+ else if(parent instanceof XSDTypeDefinition){
+ System.out.println("MakeLocalElementGlobalCommand.run: parent instanceof XSDTypeDefinition");
+
+ }
+
+ container.getSchema().updateElement(true);
+ formatChild(elementDecl.getElement());
+
+ }
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#adopt(org.eclipse.xsd.XSDConcreteComponent)
+ */
+ protected boolean adopt(XSDConcreteComponent model) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java
new file mode 100644
index 0000000..b737c45
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalChange.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.xsd.ui.internal.refactor.structure;
+
+import java.util.Map;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.text.Assert;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+import org.eclipse.xsd.XSDTypeDefinition;
+
+/**
+ * @author ebelisar
+ *
+ */
+public class MakeTypeGlobalChange extends Change {
+
+ private Map fChanges;
+
+ private String fNewName;
+
+ private XSDTypeDefinition fTypeComponent;
+
+ public MakeTypeGlobalChange(XSDTypeDefinition component,
+ String newName) {
+ Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
+
+ fTypeComponent = component;
+ fNewName = newName;
+ }
+
+ // public static Change[] createChangesFor(XSDNamedComponent component,
+ // String newName) {
+ // // TODO: P1 implement search of XSD files
+ // XSDSearchSupport support = XSDSearchSupport.getInstance();
+ // RefactorSearchRequestor requestor = new
+ // RefactorSearchRequestor(component, newName);
+ // support.searchRunnable(component, IXSDSearchConstants.WORKSPACE_SCOPE,
+ // requestor);
+ //
+ // return requestor.getChanges();
+ //
+ // }
+
+ protected Change createUndoChange() {
+ return new MakeTypeGlobalChange(fTypeComponent, getNewName());
+ }
+
+ protected void doRename(IProgressMonitor pm) throws CoreException {
+ // TODO P1 change temporary rename of XSD model components
+ performModify(getNewName());
+ }
+
+ public void performModify(final String value) {
+ DelayedRenameRunnable runnable = new DelayedRenameRunnable(
+ fTypeComponent, value);
+ // TODO: remove Display
+ //Display.getCurrent().asyncExec(runnable);
+ }
+
+ protected static class DelayedRenameRunnable implements Runnable {
+ protected XSDTypeDefinition component;
+
+ protected String name;
+
+ public DelayedRenameRunnable(XSDTypeDefinition component, String name) {
+ this.component = component;
+ this.name = name;
+ }
+
+ public void run() {
+ DocumentImpl doc = (DocumentImpl) component.getElement().getOwnerDocument();
+ doc.getModel().beginRecording(
+ this,
+ RefactoringMessages
+ .getString("_UI_ACTION_MAKE_ANONYMOUS_TYPE_GLOBAL"));
+ MakeAnonymousTypeGlobalCommand command = new MakeAnonymousTypeGlobalCommand(
+ component, name);
+ command.run();
+ doc.getModel().endRecording(this);
+ }
+ }
+
+ public TextChange getChange(IFile file) {
+ TextChange result = (TextChange) fChanges.get(file);
+ if (result == null) {
+ result = new TextFileChange(file.getName(), file);
+ fChanges.put(file, result);
+ }
+ return result;
+ }
+
+ public String getName() {
+ return RefactoringMessages
+ .getFormattedString(
+ "MakeTypeGlobalChange.name", new String[] {getNewName() }); //$NON-NLS-1$
+ }
+
+ public final Change perform(IProgressMonitor pm) throws CoreException {
+ try {
+ pm.beginTask(RefactoringMessages
+ .getString("XSDComponentRenameChange.Renaming"), 1); //$NON-NLS-1$
+ Change result = createUndoChange();
+ doRename(new SubProgressMonitor(pm, 1));
+ return result;
+ } finally {
+ pm.done();
+ }
+ }
+
+ /**
+ * Gets the newName.
+ *
+ * @return Returns a String
+ */
+ protected String getNewName() {
+ return fNewName;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
+ */
+ public Object getModifiedElement() {
+ // TODO Auto-generated method stub
+ return fTypeComponent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void initializeValidationData(IProgressMonitor pm) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ // TODO implement change validation
+ return new RefactoringStatus();
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java
new file mode 100644
index 0000000..28f09f2
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/structure/MakeTypeGlobalProcessor.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.structure;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.wst.xsd.ui.internal.refactor.INameUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+import org.eclipse.xsd.XSDTypeDefinition;
+
+public class MakeTypeGlobalProcessor extends RenameProcessor implements INameUpdating{
+
+ private XSDTypeDefinition fTypeComponent;
+ private String fNewElementName;
+
+ public static final String IDENTIFIER= "org.eclipse.wst.ui.xsd.makeTypeGlobalProcessor"; //$NON-NLS-1$
+
+ //private QualifiedNameSearchResult fNameSearchResult;
+
+ public MakeTypeGlobalProcessor(XSDTypeDefinition element, String newName) {
+ fTypeComponent= element;
+ fNewElementName = newName;
+
+ }
+
+ public XSDTypeDefinition getTypeComponent() {
+ return fTypeComponent;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.ITextUpdating#canEnableTextUpdating()
+ */
+ public boolean canEnableTextUpdating() {
+ return true;
+ }
+
+ protected String[] getAffectedProjectNatures() throws CoreException {
+ //TODO: find project natures of the files that are going to be refactored
+ return new String[0];
+ }
+
+ protected void loadDerivedParticipants(RefactoringStatus status,
+ List result, String[] natures, SharableParticipants shared)
+ throws CoreException {
+ // TODO: provide a way to load rename participants
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws CoreException,
+ OperationCanceledException {
+ // TODO add code to check final conditions for component rename
+ return new RefactoringStatus();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+// TODO add code to check initial conditions for component rename
+ return new RefactoringStatus();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ // TODO P1 add change creation
+// Change[] changes = XSDComponentRenameChange.createChangesFor(this.fNamedComponent, getNewElementName());
+// CompositeChange multiChange = null;
+// if(changes.length > 0)
+// multiChange = new CompositeChange("XSD component rename participant changes", changes); //$NON-NLS-1$ TODO: externalize string
+// return multiChange;
+
+// computeNameMatches(pm);
+// Change[] changes = fNameSearchResult.getAllChanges();
+// return new CompositeChange("XSD file rename participant changes", changes); //TODO: externalize string
+ pm.beginTask("", 1); //$NON-NLS-1$
+ try{
+ return new MakeTypeGlobalChange(fTypeComponent, getNewElementName());
+ } finally{
+ pm.done();
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
+ */
+ public Object[] getElements() {
+
+ return new Object[] {fTypeComponent};
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
+ */
+ public String getIdentifier() {
+ return IDENTIFIER;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
+ */
+ public String getProcessorName() {
+ return RefactoringMessages.getFormattedString(
+ "MakeLocalTypeGlobalRefactoring.name", //$NON-NLS-1$
+ new String[]{getNewElementName()});
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
+ */
+ public boolean isApplicable() throws CoreException {
+ if (fTypeComponent == null)
+ return false;
+ // TODO implement isApplicable logic for the named component,
+ // verify how it is different from other condition checks
+// if (fNamedComponent.isAnonymous())
+// return false;
+// if (! Checks.isAvailable(fType))
+// return false;
+// if (isSpecialCase(fType))
+// return false;
+ return true;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#checkNewElementName(java.lang.String)
+ */
+ public RefactoringStatus checkNewElementName(String newName){
+ Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
+ // TODO: implement new name checking
+// RefactoringStatus result = Checks.checkTypeName(newName);
+// if (Checks.isAlreadyNamed(fType, newName))
+// result.addFatalError(RefactoringCoreMessages.getString("RenameTypeRefactoring.choose_another_name")); //$NON-NLS-1$
+ return new RefactoringStatus();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating#getNewElement()
+ */
+ public Object getNewElement() throws CoreException {
+ // TODO implement this method, it's used for updating selection on new element
+ return null;
+ }
+
+// private void computeNameMatches(IProgressMonitor pm) throws CoreException {
+//
+// IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+// try {
+// URL fileURL = Platform.resolve(new URL(fNamedComponent.getSchema().getSchemaLocation()));
+// IFile file = workspaceRoot.getFileForLocation(new Path(fileURL.getPath()));
+// if (fNameSearchResult == null)
+// fNameSearchResult= new QualifiedNameSearchResult();
+// QualifiedNameFinder.process(fNameSearchResult, getNamedComponent().getName(),
+// getNewElementName(),
+// "*.xsd", file.getProject(), pm);
+// } catch (IOException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// }
+
+ public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException {
+ RenameArguments arguments= new RenameArguments(getNewElementName(), true);
+ String[] natures= getAffectedProjectNatures();
+ List result= new ArrayList();
+ loadElementParticipants(status, result, arguments, natures, sharedParticipants);
+ loadDerivedParticipants(status, result, natures, sharedParticipants);
+ return (RefactoringParticipant[])result.toArray(new RefactoringParticipant[result.size()]);
+ }
+
+ protected void loadElementParticipants(RefactoringStatus status, List result, RenameArguments arguments, String[] natures, SharableParticipants shared) throws CoreException {
+ Object[] elements= getElements();
+ for (int i= 0; i < elements.length; i++) {
+ result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status,
+ this, elements[i],
+ arguments, natures, shared)));
+ }
+ }
+
+
+ public void setNewElementName(String newName) {
+
+ fNewElementName= newName;
+ }
+
+ public String getNewElementName() {
+ return fNewElementName;
+ }
+
+ public String getCurrentElementName() {
+ // TODO Auto-generated method stub
+ return fNewElementName;
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/util/LinkURLHelper.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/util/LinkURLHelper.java
new file mode 100644
index 0000000..30274d4
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/util/LinkURLHelper.java
@@ -0,0 +1,288 @@
+/*
+ * Created on Sep 21, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.wst.xsd.ui.internal.refactor.util;
+
+
+
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.eclipse.wst.common.uriresolver.internal.URI;
+import org.eclipse.wst.sse.core.internal.util.PathHelper;
+
+
+/**
+ * Hyperlink manager. Proved useful services like link conversion
+ * An utility class to help other parsre modules to convert links
+ */
+public class LinkURLHelper {
+
+ private static final String FILE_PROTOCOL_SEARCH_SIG = "file:/";//$NON-NLS-1$
+ private static final String FILE_PROTOCOL_SIG = "file:///";//$NON-NLS-1$
+ private static String RELATIVE_PATH_SIG = "..";//$NON-NLS-1$
+ private static final String FORWARD_SLASH = "/";//$NON-NLS-1$
+ private URL fBaseUrl = null; // base url. assumed to a absulute url
+ private String fBaseUrlString = null;
+ private URL fDocRoot = null;
+ private String fDocRootString = null;
+
+ public LinkURLHelper(String baseUrl) {
+ initialize(baseUrl, null);
+ }
+
+
+ public LinkURLHelper(String baseUrl, String docRoot) {
+ initialize(baseUrl, docRoot);
+ }
+
+ /**
+ * Special adujust for file url
+ */
+ public String adjustFileProtocolUrl(String url) {
+ if (url.startsWith(FILE_PROTOCOL_SEARCH_SIG)) {
+ url = FILE_PROTOCOL_SIG + url.substring(FILE_PROTOCOL_SEARCH_SIG.length());
+ }
+ return url;
+ }
+
+ private String convert(String url, URL baseUrl, String urlString) {
+ String absUrl = url;
+ if (baseUrl != null) {
+ try {
+ // do special thing file protocol
+ if (baseUrl.getProtocol().equalsIgnoreCase("file")) {//$NON-NLS-1$
+ // remove the fist
+ if (url.startsWith("/"))//$NON-NLS-1$
+ url = url.substring(1);
+ // empty string causes malformed exception
+ String tempUrl = url;
+ if ("".equals(url))//$NON-NLS-1$
+ tempUrl = " ";//$NON-NLS-1$
+ URL newUrl = new URL(baseUrl, tempUrl);
+ // do extra math for file protocol to support ie based
+ absUrl = adjustFileProtocolUrl(newUrl.toString());
+ }
+ else {
+ URL newUrl = new URL(fBaseUrl, url);
+ absUrl = newUrl.toString();
+ }
+ }
+ catch (MalformedURLException me) {
+ }
+ // convert everything to forward slash
+ absUrl = PathHelper.switchToForwardSlashes(absUrl);
+ }
+ else {
+ // the given may be based on file
+ if (urlString != null) {
+ // swich the url to proper direction
+ url = PathHelper.removeLeadingSeparator(url);
+ File fle = new File(urlString, url);
+ absUrl = fle.getPath();
+
+ }
+ // convert everything to forward slash
+ absUrl = PathHelper.switchToForwardSlashes(absUrl);
+
+ // if the path ends with ".." we need to add a terminating slash or
+ // else the link will not be resolved correctly. (it will look like
+ // /url/path/to/somewhere/.. instead of /url/path/to/
+ if (absUrl.endsWith(FORWARD_SLASH + RELATIVE_PATH_SIG)) {
+ absUrl += FORWARD_SLASH;
+ }
+ }
+
+ // resolve relative path to absolute
+ absUrl = PathHelper.adjustPath(absUrl);
+ return absUrl;
+ }
+
+ private void initialize(String baseUrl, String docRoot) {
+ //
+ // Find out whether baes url is a url or file name
+ //
+ if ( URI.validScheme(baseUrl) ) {
+ try {
+ String temp = PathHelper.appendTrailingURLSlash(baseUrl);
+ fBaseUrl = new URL(temp);
+ }
+ catch (MalformedURLException mue) {
+ // it is a file based url
+ fBaseUrlString = baseUrl;
+ }
+ }
+ else {
+ // it is a file based url
+ fBaseUrlString = baseUrl;
+ }
+
+ // do the same for doc root
+ if (docRoot != null) {
+ if ( URI.validScheme(docRoot) ) {
+ try {
+ String temp = PathHelper.appendTrailingURLSlash(docRoot);
+ fDocRoot = new URL(temp);
+
+ }
+ catch (MalformedURLException mue) {
+ // it is a file based url
+ fDocRootString = docRoot;
+ }
+ }
+ else {
+ // it is a file based url
+ fDocRootString = docRoot;
+ }
+ }
+ }
+
+ /**
+ * Convert the given url to a abolute url using the base url
+ * Input url can be of any othe following format
+ * Absolute urls
+ * --------------
+ * . http://www.foo.com/
+ * . http://www.foo.com
+ * . http://www.foo.com/folder
+ * . http://www.foo.com/folder/
+ * . http://www.foo.com/index.html
+ * . http://www.foo.com/folder/index.html
+ * . http://www.foo.com/folder/../index.html
+ * Url relative on document root
+ * -------------------------
+ * . /
+ * . /folder
+ * . /index.html
+ * . /folder/index.html
+ * . /folder/../index.html
+ *
+ * Self relative
+ * -------------------------
+ * . index.html
+ * . ./index.html
+ * . ../index.html
+ * . folder/index.html
+ * . folder/../index.html
+ *
+ * file based url adds another dimension since it doesn't have a document root
+ * So uses fDocRoot if provided
+ */
+ public String toAbsolute(String url) {
+ String absUrl = url;
+
+ URL newUrl = null;
+ // try to see it is a absolute url
+ if ( URI.validScheme(url) ) {
+ try {
+ newUrl = new URL(url);
+ }
+ catch (MalformedURLException me) {
+ }
+ }
+ // if document root is provided
+ // do special case
+ if (newUrl == null) {
+ if (fDocRoot == null && fDocRootString == null) {
+ // try to check relative url
+ absUrl = convert(url, fBaseUrl, fBaseUrlString);
+ }
+ else {
+ // doc root is provided
+ // if the url is a doc root based use doc root
+
+ if (url.startsWith("/"))//$NON-NLS-1$
+ absUrl = convert(url, fDocRoot, fDocRootString);
+ else
+ absUrl = convert(url, fBaseUrl, fBaseUrlString);
+
+ }
+ }
+ return absUrl;
+ }
+
+ /**
+ * Convert from an absolute url to relative url based on the given url
+ * Both are assumed to be ablsute url
+ */
+ public String toRelative(String url, String documentUrl) {
+ String output = url;
+ // assuming both urls are absolute
+ try {
+ URL inputUrl = new URL(url);
+ URL docUrl = new URL(documentUrl);
+ // filter out if the urls are not fro the same domain
+ if (!inputUrl.getProtocol().equals(docUrl.getProtocol()) || !inputUrl.getHost().equals(docUrl.getHost()) || inputUrl.getPort() != docUrl.getPort())
+ return output;
+ // both url are coming form the same place
+ // strip off the domain parts
+ String inputName = inputUrl.getFile();
+ String docName = docUrl.getFile();
+ output = PathHelper.convertToRelative(inputName, docName);
+ }
+ catch (MalformedURLException me) {
+ output = null;
+ }
+ return output;
+ }
+
+// /*
+// */
+// protected String getScheme(String passedSpec) {
+// if (passedSpec != null) {
+//
+// final String spec = passedSpec.trim();
+//
+// // protocol(scheme) java.net.URL can recognize is detemined
+// // what URL.getURLStreamHandle(protocol) returns.
+// // in Eclipse, only :
+// // valoader:
+// // file:
+// // jar:
+// // platform:
+// // doc:
+// // ftp:
+// // gopher:
+// // http:
+// // mailto:
+// // netdoc:
+// // systemresource:
+// // verbatim:
+// // can recognize. Otherwise, it throws exception...
+// // the following code comes from hpbcom/url.cpp, Url::parse_protocol()
+// final int limit = spec.length();
+// String newProtocol = null;
+// for( int index = 0; index < limit; index++ ) {
+// final char p = spec.charAt(index);
+// if (p == '/') {
+// break;
+// }
+// if (p == ':') {
+// newProtocol = spec.substring(0, index);
+// break;
+// }
+// }
+// // copy end
+//
+//
+// if (newProtocol != null && newProtocol.length() > 1 ) {
+// for ( int i = 0; i < PROTOCOLS.length; i++ ){
+// if (newProtocol.compareToIgnoreCase(PROTOCOLS[i]) == 0) {
+// // matched;
+// return newProtocol;
+// }
+// }
+// }
+// }
+// //i don't know what is newProtocol. Ask URI class itself.
+// //No, calling URI again is very slow. So, just give up
+// //URI uri = new URI(spec);
+// //return uri.getScheme();
+// return null;//$NON-NLS-1$
+// }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/util/TextChangeCompatibility.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/util/TextChangeCompatibility.java
new file mode 100644
index 0000000..7f93a4f
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/util/TextChangeCompatibility.java
@@ -0,0 +1,86 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.util;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.edits.TextEditGroup;
+
+/**
+ * A utility class to provide compatibility with the old
+ * text change API of adding text edits directly and auto
+ * inserting them into the tree.
+ */
+public class TextChangeCompatibility {
+
+ public static void addTextEdit(TextChange change, String name, TextEdit edit) {
+ Assert.isNotNull(change);
+ Assert.isNotNull(name);
+ Assert.isNotNull(edit);
+ TextEdit root= change.getEdit();
+ if (root == null) {
+ root= new MultiTextEdit();
+ change.setEdit(root);
+ }
+ insert(root, edit);
+ change.addTextEditGroup(new TextEditGroup(name, edit));
+ }
+
+ public static void addTextEdit(TextChange change, String name, TextEdit[] edits) {
+ Assert.isNotNull(change);
+ Assert.isNotNull(name);
+ Assert.isNotNull(edits);
+ TextEdit root= change.getEdit();
+ if (root == null) {
+ root= new MultiTextEdit();
+ change.setEdit(root);
+ }
+ for (int i= 0; i < edits.length; i++) {
+ insert(root, edits[i]);
+ }
+ change.addTextEditGroup(new TextEditGroup(name, edits));
+ }
+
+ public static void insert(TextEdit parent, TextEdit edit) {
+ if (!parent.hasChildren()) {
+ parent.addChild(edit);
+ return;
+ }
+ TextEdit[] children= parent.getChildren();
+ // First dive down to find the right parent.
+ for (int i= 0; i < children.length; i++) {
+ TextEdit child= children[i];
+ if (covers(child, edit)) {
+ insert(child, edit);
+ return;
+ }
+ }
+ // We have the right parent. Now check if some of the children have to
+ // be moved under the new edit since it is covering it.
+ for (int i= children.length - 1; i >= 0; i--) {
+ TextEdit child= children[i];
+ if (covers(edit, child)) {
+ parent.removeChild(i);
+ edit.addChild(child);
+ }
+ }
+ parent.addChild(edit);
+ }
+
+ private static boolean covers(TextEdit thisEdit, TextEdit otherEdit) {
+ if (thisEdit.getLength() == 0) // an insertion point can't cover anything
+ return false;
+
+ int thisOffset= thisEdit.getOffset();
+ int thisEnd= thisEdit.getExclusiveEnd();
+ if (otherEdit.getLength() == 0) {
+ int otherOffset= otherEdit.getOffset();
+ return thisOffset < otherOffset && otherOffset < thisEnd;
+ } else {
+ int otherOffset= otherEdit.getOffset();
+ int otherEnd= otherEdit.getExclusiveEnd();
+ return thisOffset <= otherOffset && otherEnd <= thisEnd;
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorActionGroup.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorActionGroup.java
new file mode 100644
index 0000000..303d1dc
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorActionGroup.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.wst.xsd.ui.internal.refactor.actions.RenameAction;
+import org.eclipse.wst.xsd.ui.internal.refactor.actions.SelectionDispatchAction;
+
+/**
+ * Action group that adds refactor actions (for example 'Rename', 'Move') to a
+ * context menu and the global menu bar.
+ *
+ */
+public abstract class RefactorActionGroup extends ActionGroup {
+
+ private static class NoActionAvailable extends Action {
+ public NoActionAvailable() {
+ setEnabled(true);
+ setText(RefactoringWizardMessages.RefactorActionGroup_no_refactoring_available);
+ }
+ }
+
+ /**
+ * Pop-up menu: name of group for reorganize actions (value
+ * <code>"group.reorganize"</code>).
+ */
+ public static final String GROUP_REORGANIZE = IWorkbenchActionConstants.GROUP_REORGANIZE;
+
+ public static final String MENU_ID = "org.eclipse.wst.xsd.ui.refactoring.menu"; //$NON-NLS-1$
+
+ public static final String RENAME = "org.eclipse.wst.xsd.ui.refactoring.actions.Rename"; //$NON-NLS-1$
+
+
+ protected static void initAction(SelectionDispatchAction action,
+ ISelection selection) {
+
+ Assert.isNotNull(selection);
+ Assert.isNotNull(action);
+ action.update(selection);
+ //provider.addSelectionChangedListener(action);
+ }
+
+ protected List fEditorActions;
+
+ private String fGroupName = GROUP_REORGANIZE;
+
+ private Action fNoActionAvailable = new NoActionAvailable();
+
+ protected RenameAction fRenameAction;
+
+ protected SelectionDispatchAction fRenameTargetNamespace;
+
+ protected ISelection selection;
+
+ public RefactorActionGroup(ISelection selection) {
+ this.selection = selection;
+
+ }
+
+ public int addAction(IAction action) {
+ if (action != null && action.isEnabled()) {
+ fEditorActions.add(action);
+ return 1;
+ }
+ return 0;
+ }
+
+ private void addRefactorSubmenu(IMenuManager menu) {
+
+ IMenuManager refactorSubmenu = new MenuManager(RefactoringWizardMessages.RefactorMenu_label, MENU_ID);
+ refactorSubmenu.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ refactorMenuShown(manager);
+ }
+ });
+ refactorSubmenu.add(fNoActionAvailable);
+ if (menu.find(refactorSubmenu.getId()) == null) {
+ if (menu.find(fGroupName) == null) {
+ menu.add(refactorSubmenu);
+ } else {
+ menu.appendToGroup(fGroupName, refactorSubmenu);
+ }
+ }
+ }
+
+ protected void disposeAction(ISelectionChangedListener action,
+ ISelectionProvider provider) {
+ if (action != null)
+ provider.removeSelectionChangedListener(action);
+ }
+
+ /*
+ * (non-Javadoc) Method declared in ActionGroup
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ super.fillActionBars(actionBars);
+ actionBars.setGlobalActionHandler(RENAME, fRenameAction);
+ retargetFileMenuActions(actionBars);
+ }
+
+ public void fillActions(List enabledActions) {
+
+ if(selection != null && fEditorActions != null){
+ for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
+ Action action = (Action) iter.next();
+ if (action instanceof SelectionDispatchAction) {
+ SelectionDispatchAction selectionAction = (SelectionDispatchAction) action;
+ selectionAction.update(selection);
+ }
+
+ }
+ for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
+ Action action = (Action) iter.next();
+ if (action != null && action.isEnabled()) {
+ enabledActions.add(action);
+ }
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc) Method declared in ActionGroup
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+ addRefactorSubmenu(menu);
+ }
+
+ private int fillRefactorMenu(IMenuManager refactorSubmenu) {
+ int added = 0;
+ refactorSubmenu.add(new Separator(GROUP_REORGANIZE));
+ for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
+ Action action = (Action) iter.next();
+ if (action != null && action.isEnabled()) {
+ fEditorActions.add(action);
+ return 1;
+ }
+ }
+ return added;
+ }
+
+ private void refactorMenuHidden(IMenuManager manager) {
+
+ for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
+ Action action = (Action) iter.next();
+ if (action instanceof SelectionDispatchAction) {
+ SelectionDispatchAction selectionAction = (SelectionDispatchAction) action;
+ selectionAction.update(selection);
+ }
+
+ }
+ }
+
+ private void refactorMenuShown(final IMenuManager refactorSubmenu) {
+ // we know that we have an MenuManager since we created it in
+ // addRefactorSubmenu.
+ Menu menu = ((MenuManager) refactorSubmenu).getMenu();
+ menu.addMenuListener(new MenuAdapter() {
+ public void menuHidden(MenuEvent e) {
+ refactorMenuHidden(refactorSubmenu);
+ }
+ });
+
+ for (Iterator iter = fEditorActions.iterator(); iter.hasNext();) {
+ Action action = (Action) iter.next();
+ if (action instanceof SelectionDispatchAction) {
+ SelectionDispatchAction selectionAction = (SelectionDispatchAction) action;
+ selectionAction.update(selection);
+ }
+ }
+ refactorSubmenu.removeAll();
+ if (fillRefactorMenu(refactorSubmenu) == 0)
+ refactorSubmenu.add(fNoActionAvailable);
+ }
+
+ /**
+ * Retargets the File actions with the corresponding refactoring actions.
+ *
+ * @param actionBars
+ * the action bar to register the move and rename action with
+ */
+ public void retargetFileMenuActions(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(),
+ fRenameAction);
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorGroupActionDelegate.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorGroupActionDelegate.java
new file mode 100644
index 0000000..983a838
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorGroupActionDelegate.java
@@ -0,0 +1,135 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.wizard;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public abstract class RefactorGroupActionDelegate implements IObjectActionDelegate, IEditorActionDelegate, IMenuCreator {
+
+ protected ISelection fSelection;
+ private IAction fDelegateAction;
+ // whether to re-fill the menu (reset on selection change)
+ private boolean fFillMenu = true;
+ protected IWorkbenchPart workbenchPart;
+ protected ResourceSet resourceSet = new ResourceSetImpl();
+
+
+ public RefactorGroupActionDelegate() {
+
+ }
+
+ /*
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ workbenchPart = targetPart;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#dispose()
+ */
+ public void dispose() {
+ // nothing to do
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
+ */
+ public Menu getMenu(Control parent) {
+ // never called
+ return null;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
+ */
+ public Menu getMenu(Menu parent) {
+ //Create the new menu. The menu will get filled when it is about to be shown. see fillMenu(Menu).
+ Menu menu = new Menu(parent);
+ /**
+ * Add listener to repopulate the menu each time
+ * it is shown because MenuManager.update(boolean, boolean)
+ * doesn't dispose pulldown ActionContribution items for each popup menu.
+ */
+ menu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ if (fFillMenu) {
+ Menu m = (Menu)e.widget;
+ MenuItem[] items = m.getItems();
+ for (int i=0; i < items.length; i++) {
+ items[i].dispose();
+ }
+ fillMenu(m);
+ fFillMenu = false;
+ }
+ }
+ });
+ return menu;
+ }
+
+ /*
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ // Never called because we become a menu.
+ }
+
+ /*
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ fDelegateAction = action;
+ updateWith(selection);
+
+ }
+
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ workbenchPart = targetEditor;
+ fDelegateAction = action;
+ if (targetEditor != null && targetEditor.getEditorSite() != null && targetEditor.getEditorSite().getSelectionProvider() != null) {
+ updateWith(targetEditor.getEditorSite().getSelectionProvider().getSelection());
+ }
+
+ }
+
+ public void updateWith(ISelection selection) {
+ fSelection = selection;
+ if (fDelegateAction != null) {
+ boolean enable = false;
+ if (selection != null) {
+ if (selection instanceof ITextSelection) {
+ //if (((ITextSelection) selection).getLength() > 0) {
+ enable = true;
+ //}
+ }
+ else if(selection instanceof IStructuredSelection ){
+ enable = !selection.isEmpty();
+ }
+ }
+ // enable action
+ fDelegateAction.setEnabled(enable);
+
+ // fill submenu
+ fFillMenu = true;
+ fDelegateAction.setMenuCreator(this);
+
+
+ }
+
+ }
+
+
+ protected abstract void fillMenu(Menu menu);
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorGroupSubMenu.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorGroupSubMenu.java
new file mode 100644
index 0000000..e402607
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactorGroupSubMenu.java
@@ -0,0 +1,46 @@
+package org.eclipse.wst.xsd.ui.internal.refactor.wizard;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+public class RefactorGroupSubMenu extends CompoundContributionItem {
+
+ RefactorActionGroup fRefactorMenuGroup;
+
+
+ public RefactorGroupSubMenu(RefactorActionGroup refactorMenuGroup) {
+ super();
+ fRefactorMenuGroup = refactorMenuGroup;
+ }
+
+ public RefactorGroupSubMenu(String id) {
+ super(id);
+ }
+
+ protected IContributionItem[] getContributionItems() {
+ ArrayList actionsList = new ArrayList();
+ ArrayList contribList = new ArrayList();
+ fRefactorMenuGroup.fillActions(actionsList);
+
+ if (actionsList != null && !actionsList.isEmpty()) {
+ for (Iterator iter = actionsList.iterator(); iter.hasNext();) {
+ IAction action = (IAction) iter.next();
+ contribList.add(new ActionContributionItem(action));
+ }
+ } else {
+ Action dummyAction = new Action(RefactoringWizardMessages.RefactorActionGroup_no_refactoring_available) {
+ // dummy inner class; no methods
+ };
+ dummyAction.setEnabled(false);
+ contribList.add(new ActionContributionItem(dummyAction));
+ }
+ return (IContributionItem[]) contribList.toArray(new IContributionItem[contribList.size()]);
+
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactoringWizardMessages.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactoringWizardMessages.java
new file mode 100644
index 0000000..03140c8
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RefactoringWizardMessages.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public class RefactoringWizardMessages extends NLS {
+
+ private static final String BUNDLE_NAME= "org.eclipse.wst.xsd.ui.internal.refactor.wizard.messages";//$NON-NLS-1$
+
+ public static String RefactorMenu_label;
+ public static String RefactorActionGroup_no_refactoring_available;
+
+ public static String RenameAction_rename;
+ public static String RenameAction_unavailable;
+ public static String RenameAction_text;
+
+ public static String RenameInputWizardPage_new_name;
+ public static String RenameRefactoringWizard_internal_error;
+
+ public static String RenameTargetNamespace_text;
+
+ public static String RenameXSDElementAction_exception;
+ public static String RenameXSDElementAction_not_available;
+ public static String RenameXSDElementAction_name;
+
+ public static String RenameSupport_dialog_title;
+ public static String RenameSupport_not_available;
+
+ public static String RenameComponentWizard_defaultPageTitle;
+ public static String RenameComponentWizard_inputPage_description;
+
+ public static String RenameInputWizardPage_update_references;
+ public static String XSDComponentRenameChange_name;
+ public static String XSDComponentRenameChange_Renaming;
+ public static String ResourceRenameParticipant_compositeChangeName;
+ public static String RenameResourceChange_rename_resource_reference_change;
+ public static String XSDRenameResourceChange_name;
+ public static String RenameResourceRefactoring_Internal_Error;
+ public static String RenameResourceRefactoring_alread_exists;
+ public static String RenameResourceRefactoring_invalidName;
+ public static String RenameResourceProcessor_name;
+ public static String MakeAnonymousTypeGlobalAction_text;
+ public static String MakeLocalElementGlobalAction_text;
+ public static String XSDComponentRenameParticipant_Component_Refactoring_updates;
+ public static String WSDLComponentRenameParticipant_Component_Refactoring_updates;
+ public static String RenameComponentProcessor_Component_Refactoring_updates;
+ public static String RenameComponentProcessor_Component_Refactoring_update_declatation;
+ public static String RenameComponentProcessor_Component_Refactoring_update_reference;
+ public static String XSDComponentRenameParticipant_xsd_component_rename_participant;
+ public static String WSDLComponentRenameParticipant_wsdl_component_rename_participant;
+ public static String ResourceRenameParticipant_File_Rename_update_reference;
+
+
+ private RefactoringWizardMessages() {
+ // Do not instantiate
+ }
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, RefactoringWizardMessages.class);
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RenameInputWizardPage.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RenameInputWizardPage.java
new file mode 100644
index 0000000..5d4ccd4
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RenameInputWizardPage.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.refactor.wizard;
+
+
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.xsd.ui.internal.refactor.IReferenceUpdating;
+import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringMessages;
+
+/**
+ * @author ebelisar
+ *
+ */
+public class RenameInputWizardPage extends UserInputWizardPage{
+ private String fInitialValue;
+ private Text fTextField;
+ private Button fUpdateReferences;
+ /**
+ * Creates a new text input page.
+ * @param isLastUserPage <code>true</code> if this page is the wizard's last
+ * user input page. Otherwise <code>false</code>.
+ */
+ public RenameInputWizardPage(String description, boolean isLastUserPage) {
+ this(description, isLastUserPage, ""); //$NON-NLS-1$
+ }
+
+ /**
+ * Creates a new text input page.
+ * @param isLastUserPage <code>true</code> if this page is the wizard's last
+ * user input page. Otherwise <code>false</code>
+ * @param initialValue the initial value
+ */
+ public RenameInputWizardPage(String description, boolean isLastUserPage, String initialValue) {
+ super("RenameInputWizardPage");
+ Assert.isNotNull(initialValue);
+ setDescription(description);
+ fInitialValue= initialValue;
+ }
+
+ /**
+ * Returns whether the initial input is valid. Typically it is not, because the
+ * user is required to provide some information e.g. a new type name etc.
+ *
+ * @return <code>true</code> iff the input provided at initialization is valid
+ */
+ protected boolean isInitialInputValid(){
+ return false;
+ }
+
+ /**
+ * Returns whether an empty string is a valid input. Typically it is not, because
+ * the user is required to provide some information e.g. a new type name etc.
+ *
+ * @return <code>true</code> iff an empty string is valid
+ */
+ protected boolean isEmptyInputValid(){
+ return false;
+ }
+
+ /**
+ * Returns the content of the text input field.
+ *
+ * @return the content of the text input field. Returns <code>null</code> if
+ * not text input field has been created
+ */
+ protected String getText() {
+ if (fTextField == null)
+ return null;
+ return fTextField.getText();
+ }
+
+ /**
+ * Sets the new text for the text field. Does nothing if the text field has not been created.
+ * @param text the new value
+ */
+ protected void setText(String text) {
+ if (fTextField == null)
+ return;
+ fTextField.setText(text);
+ }
+
+ /**
+ * Performs input validation. Returns a <code>RefactoringStatus</code> which
+ * describes the result of input validation. <code>Null<code> is interpreted
+ * as no error.
+ */
+ protected RefactoringStatus validateTextField(String text){
+ return null;
+ }
+
+ protected Text createTextInputField(Composite parent) {
+ return createTextInputField(parent, SWT.BORDER);
+ }
+
+ protected Text createTextInputField(Composite parent, int style) {
+ fTextField= new Text(parent, style);
+ fTextField.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ textModified(getText());
+ }
+ });
+ fTextField.setText(fInitialValue);
+ return fTextField;
+ }
+
+ /**
+ * Checks the page's state and issues a corresponding error message. The page validation
+ * is computed by calling <code>validatePage</code>.
+ */
+ protected void textModified(String text) {
+ if (! isEmptyInputValid() && text.equals("")){ //$NON-NLS-1$
+ setPageComplete(false);
+ setErrorMessage(null);
+ restoreMessage();
+ return;
+ }
+ if ((! isInitialInputValid()) && text.equals(fInitialValue)){
+ setPageComplete(false);
+ setErrorMessage(null);
+ restoreMessage();
+ return;
+ }
+
+ setPageComplete(validateTextField(text));
+
+// TODO: enable preview in M4
+ getRefactoringWizard().setForcePreviewReview(false);
+ getContainer().updateButtons();
+
+ }
+
+ /**
+ * Subclasses can override if they want to restore the message differently.
+ * This implementation calls <code>setMessage(null)</code>, which clears the message
+ * thus exposing the description.
+ */
+ protected void restoreMessage(){
+ setMessage(null);
+ }
+
+ /* (non-Javadoc)
+ * Method declared in IDialogPage
+ */
+ public void dispose() {
+ fTextField= null;
+ }
+
+ /* (non-Javadoc)
+ * Method declared in WizardPage
+ */
+ public void setVisible(boolean visible) {
+ if (visible) {
+ textModified(getText());
+ }
+ super.setVisible(visible);
+ if (visible && fTextField != null) {
+ fTextField.setFocus();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite superComposite= new Composite(parent, SWT.NONE);
+ setControl(superComposite);
+ initializeDialogUnits(superComposite);
+
+ superComposite.setLayout(new GridLayout());
+ Composite composite= new Composite(superComposite, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ layout.verticalSpacing= 8;
+ composite.setLayout(layout);
+
+
+ Label label= new Label(composite, SWT.NONE);
+ label.setText(getLabelText());
+
+ Text text= createTextInputField(composite);
+ text.selectAll();
+ GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint= convertWidthInCharsToPixels(25);
+ text.setLayoutData(gd);
+
+ addOptionalUpdateReferencesCheckbox(superComposite);
+ gd= new GridData(GridData.FILL_HORIZONTAL);
+ text.setLayoutData(gd);
+
+ getRefactoringWizard().setForcePreviewReview(false);
+
+ Dialog.applyDialogFont(superComposite);
+ //WorkbenchHelp.setHelp(getControl(), fHelpContextID);
+
+ }
+
+ private static Button createCheckbox(Composite parent, String title, boolean value) {
+ Button checkBox= new Button(parent, SWT.CHECK);
+ checkBox.setText(title);
+ checkBox.setSelection(value);
+ return checkBox;
+ }
+
+ private void addOptionalUpdateReferencesCheckbox(Composite result) {
+
+ final IReferenceUpdating ref= (IReferenceUpdating)getRefactoring().getAdapter(IReferenceUpdating.class);
+ if (ref == null || !ref.canEnableUpdateReferences())
+ return;
+ String title= RefactoringMessages.getString("RenameInputWizardPage.update_references"); //$NON-NLS-1$
+ boolean defaultValue= true;
+ fUpdateReferences= createCheckbox(result, title, defaultValue);
+ ref.setUpdateReferences(fUpdateReferences.getSelection());
+ fUpdateReferences.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ ref.setUpdateReferences(fUpdateReferences.getSelection());
+ }
+ });
+ fUpdateReferences.setEnabled(true);
+ }
+
+ protected String getLabelText() {
+ return RefactoringMessages.getString("RenameInputWizardPage.new_name"); //$NON-NLS-1$
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RenameRefactoringWizard.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RenameRefactoringWizard.java
new file mode 100644
index 0000000..8200353
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/RenameRefactoringWizard.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.xsd.ui.internal.refactor.wizard;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.wst.xsd.ui.internal.refactor.INameUpdating;
+
+public class RenameRefactoringWizard extends RefactoringWizard {
+
+ private final String fInputPageDescription;
+
+ private final ImageDescriptor fInputPageImageDescriptor;
+
+ public RenameRefactoringWizard(Refactoring refactoring, String defaultPageTitle, String inputPageDescription,
+ ImageDescriptor inputPageImageDescriptor) {
+ super(refactoring, DIALOG_BASED_USER_INTERFACE);
+ setDefaultPageTitle(defaultPageTitle);
+ fInputPageDescription= inputPageDescription;
+ fInputPageImageDescriptor= inputPageImageDescriptor;
+
+ }
+
+ /* non java-doc
+ * @see RefactoringWizard#addUserInputPages
+ */
+ protected void addUserInputPages() {
+ String initialSetting= getProcessor().getCurrentElementName();
+ RenameInputWizardPage inputPage= createInputPage(fInputPageDescription, initialSetting);
+ inputPage.setImageDescriptor(fInputPageImageDescriptor);
+ addPage(inputPage);
+ }
+
+ protected INameUpdating getProcessor() {
+
+ return (INameUpdating)getRefactoring().getAdapter(INameUpdating.class);
+ }
+
+
+ protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
+ return new RenameInputWizardPage(message, true, initialSetting) {
+ protected RefactoringStatus validateTextField(String text) {
+ return validateNewName(text);
+ }
+ };
+ }
+
+ protected RefactoringStatus validateNewName(String newName) {
+ INameUpdating ref= getProcessor();
+ ref.setNewElementName(newName);
+// try{
+ return ref.checkNewElementName(newName);
+// } catch (CoreException e){
+// //XXX: should log the exception
+// String msg= e.getMessage() == null ? "": e.getMessage(); //$NON-NLS-1$
+// return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.getFormattedString("RenameRefactoringWizard.internal_error", msg));//$NON-NLS-1$
+// }
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/messages.properties b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/messages.properties
new file mode 100644
index 0000000..7bcd71f
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/wizard/messages.properties
@@ -0,0 +1,55 @@
+###############################################################################
+# 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
+###############################################################################
+
+RefactorMenu_label=Refactor
+RefactorActionGroup_no_refactoring_available=<no refactoring available>
+
+RenameAction_rename=Rename
+RenameAction_unavailable=Operation unavailable on the current selection.\nSelect a ....
+RenameAction_text=Re&name...
+
+RenameInputWizardPage_new_name= &New name:
+RenameRefactoringWizard_internal_error= Internal error during name checking: {0}
+
+
+RenameXSDElementAction_exception=Unexpected exception occurred. See log for details
+RenameXSDElementAction_not_available=Operation unavailable on the current selection.\nSelect a XSD project, folder, resource, file, attribute declarations, attribute group definitions, complex type definitions, element declarations, identity constraint definitions, model groups definitions, notation declarations, or simple type definitions.
+RenameXSDElementAction_name=Rename
+
+
+RenameSupport_dialog_title=Rename
+RenameSupport_not_available=Rename support not available
+
+RenameComponentWizard_defaultPageTitle=Rename wizard
+RenameComponentWizard_inputPage_description=Rename XML Schema component
+
+RenameInputWizardPage_update_references=Update references
+XSDComponentRenameChange_name=XML Schema component renaming in {0}: {1} to {2}
+XSDComponentRenameChange_Renaming=Renaming...
+ResourceRenameParticipant_compositeChangeName=XSD file rename references updating changes
+RenameResourceChange_rename_resource_reference_change=Renaming resource name references
+XSDRenameResourceChange_name=Resource rename: {0} to {1}
+RenameResourceRefactoring_Internal_Error=Internal error
+RenameResourceRefactoring_alread_exists=Resource already exist
+RenameResourceRefactoring_invalidName=Invalid resource name
+RenameResourceProcessor_name=Resource renaming
+MakeAnonymousTypeGlobalAction_text=Make Anonymous Type Global
+MakeLocalElementGlobalAction_text=Make Local Element Global
+XSDComponentRenameParticipant_Component_Refactoring_updates=XML Schema refactoring changes
+WSDLComponentRenameParticipant_Component_Refactoring_updates=WSDL Schema refactoring changes
+RenameComponentProcessor_Component_Refactoring_updates=Component name refactoring changes
+RenameComponentProcessor_Component_Refactoring_update_declatation=Update component declaration/definition
+RenameComponentProcessor_Component_Refactoring_update_reference=Update component reference
+XSDComponentRenameParticipant_xsd_component_rename_participant=XSD component rename participant
+WSDLComponentRenameParticipant_wsdl_component_rename_participant=WSDL component rename participant
+ResourceRenameParticipant_File_Rename_update_reference=File rename refactoring changes
+
+RenameTargetNamespace_text=Rename Target Namespace
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/IXSDSearchConstants.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/IXSDSearchConstants.java
new file mode 100644
index 0000000..b65703a
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/IXSDSearchConstants.java
@@ -0,0 +1,18 @@
+package org.eclipse.wst.xsd.ui.internal.search;
+
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+
+// todo ... move
+public interface IXSDSearchConstants {
+
+ public static final String XMLSCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
+ public static String XSD_CONTENT_TYPE_ID = "org.eclipse.wst.xsd.core.xsdsource";
+
+ public static final QualifiedName COMPLEX_TYPE_META_NAME = new QualifiedName (XMLSCHEMA_NAMESPACE, "complexType");
+ public static final QualifiedName SIMPLE_TYPE_META_NAME = new QualifiedName (XMLSCHEMA_NAMESPACE, "simpleType");
+ public static final QualifiedName ELEMENT_META_NAME = new QualifiedName (XMLSCHEMA_NAMESPACE, "element");
+ public static final QualifiedName ATTRIBUTE_META_NAME = new QualifiedName (XMLSCHEMA_NAMESPACE, "attribute");
+ public static final QualifiedName ATTRIBUTE_GROUP_META_NAME = new QualifiedName (XMLSCHEMA_NAMESPACE, "attributeGroup");
+ public static final QualifiedName GROUP_META_NAME = new QualifiedName (XMLSCHEMA_NAMESPACE, "group");
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchContributor.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchContributor.java
new file mode 100644
index 0000000..3fdc553
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchContributor.java
@@ -0,0 +1,68 @@
+package org.eclipse.wst.xsd.ui.internal.search;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import org.eclipse.wst.common.core.search.pattern.SearchPattern;
+import org.eclipse.wst.xml.core.internal.search.ComponentSearchContributor;
+import org.eclipse.wst.xml.core.internal.search.XMLSearchPattern;
+
+public class XSDSearchContributor extends ComponentSearchContributor {
+
+
+ protected void initializeReferences() {
+ references = new HashMap();
+ String ns = IXSDSearchConstants.XMLSCHEMA_NAMESPACE;
+
+ List patterns = new ArrayList();
+ patterns.add(new XMLSearchPattern( ns, "element", "ref"));
+ patterns.add(new XMLSearchPattern( ns, "element", "substitutionGroup"));
+ references.put(IXSDSearchConstants.ELEMENT_META_NAME, patterns);
+
+ patterns = new ArrayList();
+ patterns.add(new XMLSearchPattern( ns, "restriction", "base"));
+ patterns.add(new XMLSearchPattern( ns, "extension", "base"));
+ patterns.add(new XMLSearchPattern( ns, "element", "type"));
+ references.put(IXSDSearchConstants.COMPLEX_TYPE_META_NAME, patterns);
+
+ patterns = new ArrayList();
+ patterns.add(new XMLSearchPattern( ns, "restriction", "base"));
+ patterns.add(new XMLSearchPattern( ns, "extension", "base"));
+ patterns.add(new XMLSearchPattern( ns, "attribute", "type"));
+ patterns.add(new XMLSearchPattern( ns, "union", "memberTypes"));
+
+ references.put(IXSDSearchConstants.SIMPLE_TYPE_META_NAME, patterns);
+
+ }
+
+ protected void initializeDeclarations(){
+
+ declarations = new HashMap();
+ String ns = IXSDSearchConstants.XMLSCHEMA_NAMESPACE;
+
+ SearchPattern pattern = new XMLSearchPattern( ns, "element", "name");
+ declarations.put(IXSDSearchConstants.ELEMENT_META_NAME, pattern);
+
+ pattern = new XMLSearchPattern(ns, "complexType", "name");
+ declarations.put(IXSDSearchConstants.COMPLEX_TYPE_META_NAME, pattern);
+
+ pattern = new XMLSearchPattern(ns, "simpleType", "name");
+ declarations.put(IXSDSearchConstants.SIMPLE_TYPE_META_NAME, pattern);
+
+ pattern = new XMLSearchPattern(ns, "attribute", "name");
+ declarations.put(IXSDSearchConstants.ATTRIBUTE_META_NAME, pattern);
+
+ pattern = new XMLSearchPattern(ns, "attributeGroup", "name");
+ declarations.put(IXSDSearchConstants.ATTRIBUTE_GROUP_META_NAME, pattern);
+
+ pattern = new XMLSearchPattern(ns, "group", "name");
+ declarations.put(IXSDSearchConstants.GROUP_META_NAME, pattern);
+
+ }
+
+ protected void initializeSupportedNamespaces() {
+ namespaces = new String[]{ IXSDSearchConstants.XMLSCHEMA_NAMESPACE};
+ }
+
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchParticipant.java b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchParticipant.java
new file mode 100644
index 0000000..ae0b1a6
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/search/XSDSearchParticipant.java
@@ -0,0 +1,32 @@
+package org.eclipse.wst.xsd.ui.internal.search;
+
+import org.eclipse.wst.common.core.search.pattern.SearchPattern;
+import org.eclipse.wst.xml.core.internal.search.ComponentSearchContributor;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentSearchPattern;
+import org.eclipse.wst.xml.core.internal.search.XMLSearchParticipant;
+
+public class XSDSearchParticipant extends XMLSearchParticipant {
+
+ private static String ID = "org.eclipse.wst.xsd.search.XSDSearchParticipant";
+
+ public boolean initialize(SearchPattern pattern, String[] contentTypes){
+
+ super.initialize(pattern, contentTypes);
+ id = ID;
+ if(pattern instanceof XMLComponentSearchPattern ){
+ XMLComponentSearchPattern componentPattern = (XMLComponentSearchPattern)pattern;
+ String namespace = componentPattern.getMetaName().getNamespace();
+ if(IXSDSearchConstants.XMLSCHEMA_NAMESPACE.equals(namespace)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public ComponentSearchContributor getSearchContributor() {
+
+ return new XSDSearchContributor();
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseCleanup.java
new file mode 100644
index 0000000..3a3da3b
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/BaseCleanup.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.rename;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+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/rename/XSDExternalFileCleanup.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDExternalFileCleanup.java
new file mode 100644
index 0000000..e96619e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDExternalFileCleanup.java
@@ -0,0 +1,298 @@
+/*******************************************************************************
+ * 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.rename;
+
+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"));
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDVisitor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDVisitor.java
new file mode 100644
index 0000000..4acf32d
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/refactor/rename/XSDVisitor.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * 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.rename;
+
+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.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.XSDSchema;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import org.eclipse.xsd.XSDTypeDefinition;
+import org.eclipse.xsd.XSDWildcard;
+
+public class XSDVisitor
+{
+ public XSDVisitor()
+ {
+ }
+
+ protected XSDSchema schema;
+
+ 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())
+ {
+ }
+ 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)
+ {
+ visitModelGroup(modelGroupDef.getModelGroup());
+ }
+ }
+ }
+
+ public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup)
+ {
+ if (attributeGroup.getAttributeUses() != null)
+ {
+ for (Iterator iter = attributeGroup.getAttributeUses().iterator(); iter.hasNext(); )
+ {
+ XSDAttributeUse attrUse = (XSDAttributeUse)iter.next();
+ visitAttributeDeclaration(attrUse.getContent());
+ }
+ }
+ }
+
+ public void visitNotationDeclaration(XSDNotationDeclaration notation)
+ {
+ }
+
+ public void visitSimpleTypeDefinition(XSDSimpleTypeDefinition type)
+ {
+ }
+
+ public void visitComplexTypeDefinition(XSDComplexTypeDefinition type)
+ {
+ if (type.getContentType() != null)
+ {
+ XSDComplexTypeContent complexContent = (XSDComplexTypeContent) type.getContentType();
+ if (complexContent instanceof XSDSimpleTypeDefinition)
+ {
+ visitSimpleTypeDefinition((XSDSimpleTypeDefinition)complexContent);
+ }
+ else if (complexContent instanceof XSDParticle)
+ {
+ visitParticle((XSDParticle) complexContent);
+ }
+ }
+
+ 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());
+ }
+ else if (attrGroupContent instanceof XSDAttributeGroupDefinition)
+ {
+ visitAttributeGroupDefinition((XSDAttributeGroupDefinition)attrGroupContent);
+ }
+ }
+ }
+ }
+
+ 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/development/org.eclipse.wst.sse.unittests/.classpath b/development/org.eclipse.wst.sse.unittests/.classpath
deleted file mode 100644
index 751c8f2..0000000
--- a/development/org.eclipse.wst.sse.unittests/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/development/org.eclipse.wst.sse.unittests/.cvsignore b/development/org.eclipse.wst.sse.unittests/.cvsignore
deleted file mode 100644
index a37b9c5..0000000
--- a/development/org.eclipse.wst.sse.unittests/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-bin
-build.properties
-build.xml
-ssejunit.jar
-temp.folder
diff --git a/development/org.eclipse.wst.sse.unittests/.project b/development/org.eclipse.wst.sse.unittests/.project
deleted file mode 100644
index e6f5109..0000000
--- a/development/org.eclipse.wst.sse.unittests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.sse.unittests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/development/org.eclipse.wst.sse.unittests/.settings/org.eclipse.jdt.core.prefs b/development/org.eclipse.wst.sse.unittests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index c1373fb..0000000
--- a/development/org.eclipse.wst.sse.unittests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,58 +0,0 @@
-#Mon May 30 19:10:44 EDT 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/development/org.eclipse.wst.sse.unittests/.settings/org.eclipse.pde.prefs b/development/org.eclipse.wst.sse.unittests/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 498dec4..0000000
--- a/development/org.eclipse.wst.sse.unittests/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Fri May 27 23:41:23 EDT 2005
-compilers.p.illegal-att-value=0
-compilers.p.no-required-att=0
-compilers.p.unknown-attribute=0
-compilers.p.unknown-class=0
-compilers.p.unknown-element=0
-compilers.p.unknown-resource=0
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.p.unused-element-or-attribute=0
-compilers.use-project=true
-eclipse.preferences.version=1
diff --git a/development/org.eclipse.wst.sse.unittests/META-INF/MANIFEST.MF b/development/org.eclipse.wst.sse.unittests/META-INF/MANIFEST.MF
deleted file mode 100644
index 20c3b77..0000000
--- a/development/org.eclipse.wst.sse.unittests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,37 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Unittests
-Bundle-SymbolicName: org.eclipse.wst.sse.unittests; singleton:=true
-Bundle-Version: 0.7.0
-Bundle-ClassPath: sseunittests.jar
-Bundle-Vendor: Eclipse.org
-Bundle-Localization: plugin
-Export-Package: org.eclipse.wst.sse.unittests
-Require-Bundle: org.junit,
- org.eclipse.core.resources,
- org.eclipse.core.runtime,
- org.eclipse.jst.jsp.core.tests,
- org.eclipse.jst.jsp.tests.encoding,
- org.eclipse.jst.jsp.ui.tests,
- org.eclipse.jst.jsp.ui.tests.performance,
- org.eclipse.wst.css.core.tests,
- org.eclipse.wst.css.tests.encoding,
- org.eclipse.wst.css.ui.tests.performance,
- org.eclipse.wst.dtd.ui.tests,
- org.eclipse.wst.html.core.tests,
- org.eclipse.wst.html.tests.encoding,
- org.eclipse.wst.html.ui.tests,
- org.eclipse.wst.html.ui.tests.performance,
- org.eclipse.wst.sse.core.tests,
- org.eclipse.wst.sse.ui.tests,
- org.eclipse.wst.sse.ui.tests.performance,
- org.eclipse.wst.xml.core.tests,
- org.eclipse.wst.xml.tests.encoding,
- org.eclipse.wst.xml.ui.tests,
- org.eclipse.wst.xml.ui.tests.performance,
- org.eclipse.wst.xml.validation.tests,
- org.eclipse.wst.xml.ui,
- org.eclipse.wst.javascript.ui,
- org.eclipse.wst.xsd.validation.tests,
- org.eclipse.wst.css.ui.tests,
- org.eclipse.wst.sse.ui
diff --git a/development/org.eclipse.wst.sse.unittests/icons/sourceEditor.gif b/development/org.eclipse.wst.sse.unittests/icons/sourceEditor.gif
deleted file mode 100644
index 75ebdb8..0000000
--- a/development/org.eclipse.wst.sse.unittests/icons/sourceEditor.gif
+++ /dev/null
Binary files differ
diff --git a/development/org.eclipse.wst.sse.unittests/plugin.properties b/development/org.eclipse.wst.sse.unittests/plugin.properties
deleted file mode 100644
index 535a870..0000000
--- a/development/org.eclipse.wst.sse.unittests/plugin.properties
+++ /dev/null
@@ -1,14 +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
-#
-###############################################################################
-XML_Source_Page_Editor.name=XML Source Page Editor
-JavaScript_Source_Page_Editor.name=JavaScript Source Page Editor
-
diff --git a/development/org.eclipse.wst.sse.unittests/plugin.xml b/development/org.eclipse.wst.sse.unittests/plugin.xml
deleted file mode 100644
index c869906..0000000
--- a/development/org.eclipse.wst.sse.unittests/plugin.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
- <extension point="org.eclipse.ui.editors">
- <editor
- name="%XML_Source_Page_Editor.name"
- icon="icons/sourceEditor.gif"
- contributorClass="org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML"
- class="org.eclipse.wst.sse.ui.StructuredTextEditor"
- symbolicFontName="org.eclipse.wst.sse.ui.textfont"
- id="org.eclipse.core.runtime.xml.source">
- <contentTypeBinding
- contentTypeId="org.eclipse.core.runtime.xml" />
- <contentTypeBinding
- contentTypeId="org.eclipse.wst.xml.core.xmlsource" />
- </editor>
- </extension>
- <extension point="org.eclipse.ui.editors">
- <editor
- name="%JavaScript_Source_Page_Editor.name"
- icon="icons/sourceEditor.gif"
- extensions="js"
- contributorClass="org.eclipse.wst.javascript.ui.internal.actions.ActionContributorJS"
- class="org.eclipse.wst.javascript.ui.internal.editor.JSEditor"
- symbolicFontName="org.eclipse.wst.sse.ui.textfont"
- id="org.eclipse.wst.javascript.core.javascriptsource.source">
- <contentTypeBinding
- contentTypeId="org.eclipse.wst.javascript.core.javascriptsource" />
- </editor>
- </extension>
-</plugin>
\ No newline at end of file
diff --git a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/MasterListTestSuite.java b/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/MasterListTestSuite.java
deleted file mode 100644
index a2ea5b3..0000000
--- a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/MasterListTestSuite.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.sse.unittests;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.jst.jsp.core.tests.JSPCoreTestSuite;
-import org.eclipse.jst.jsp.tests.encoding.JSPEncodingTestSuite;
-import org.eclipse.jst.jsp.ui.tests.JSPUITestSuite;
-import org.eclipse.wst.css.core.tests.CSSCoreTestSuite;
-import org.eclipse.wst.css.tests.encoding.CSSEncodingTestSuite;
-import org.eclipse.wst.css.ui.tests.CSSUITestSuite;
-import org.eclipse.wst.dtd.ui.tests.DTDUITestSuite;
-import org.eclipse.wst.html.core.tests.HTMLCoreTestSuite;
-import org.eclipse.wst.html.tests.encoding.HTMLEncodingTestSuite;
-import org.eclipse.wst.html.ui.tests.HTMLUITestSuite;
-import org.eclipse.wst.sse.core.tests.SSEModelTestSuite;
-import org.eclipse.wst.sse.ui.tests.SSEUITestSuite;
-import org.eclipse.wst.xml.core.tests.SSEModelXMLTestSuite;
-import org.eclipse.wst.xml.tests.encoding.EncodingTestSuite;
-import org.eclipse.wst.xml.ui.tests.XMLUITestSuite;
-import org.eclipse.wst.xml.validation.tests.internal.AllXMLTests;
-import org.eclipse.wst.xsd.validation.tests.internal.AllXSDTests;
-
-/*****************************************************************************
- * Copyright (c) 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
- *
- ****************************************************************************/
-
-public class MasterListTestSuite extends TestSuite {
-
- public MasterListTestSuite() {
- super("All Tests");
-
- System.setProperty("wtp.autotest.noninteractive", "true");
-
- addTest(SSEModelTestSuite.suite());
- addTest(SSEModelXMLTestSuite.suite());
- addTest(CSSCoreTestSuite.suite());
- addTest(HTMLCoreTestSuite.suite());
- addTest(JSPCoreTestSuite.suite());
-
- addTest(AllXMLTests.suite());
-
- addTest(EncodingTestSuite.suite());
- addTest(CSSEncodingTestSuite.suite());
- addTest(HTMLEncodingTestSuite.suite());
- addTest(JSPEncodingTestSuite.suite());
-
- addTest(CSSUITestSuite.suite());
- addTest(HTMLUITestSuite.suite());
- addTest(SSEUITestSuite.suite());
- addTest(XMLUITestSuite.suite());
- addTest(DTDUITestSuite.suite());
- addTest(JSPUITestSuite.suite());
-
- addTest(AllXSDTests.suite());
- //addTest(RegressionBucket.suite());
- //addTest(AllTestCases.suite());
-
- }
-
- public void testAll() {
- // this method needs to exist, but doesn't really do anything
- // other than to signal to create an instance of this class.
- // The rest it automatic from the tests added in constructor.
- }
-}
diff --git a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/MasterPerformanceTestSuite.java b/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/MasterPerformanceTestSuite.java
deleted file mode 100644
index 8491014..0000000
--- a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/MasterPerformanceTestSuite.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.sse.unittests;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.jst.jsp.ui.tests.performance.JSPUIPerformanceTests;
-import org.eclipse.wst.css.ui.tests.performance.CSSUIPerformanceTestSuite;
-import org.eclipse.wst.html.ui.tests.performance.HTMLUIPerformanceTestSuite;
-import org.eclipse.wst.sse.ui.tests.performance.SSEUIPerformanceTestSuite;
-import org.eclipse.wst.xml.ui.tests.performance.XMLUIPerformanceTestSuite;
-
-/*****************************************************************************
- * Copyright (c) 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
- *
- ****************************************************************************/
-
-public class MasterPerformanceTestSuite extends TestSuite {
-
- public MasterPerformanceTestSuite() {
- super("All Tests");
-
- addTest(JSPUIPerformanceTests.suite());
- addTest(CSSUIPerformanceTestSuite.suite());
- addTest(HTMLUIPerformanceTestSuite.suite());
- addTest(SSEUIPerformanceTestSuite.suite());
- addTest(XMLUIPerformanceTestSuite.suite());
-
-
- }
-
- public void testAll() {
- // this method needs to exist, but doesn't really do anything
- }
-
-}
diff --git a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/minortools/TestStringUtils.java b/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/minortools/TestStringUtils.java
deleted file mode 100644
index 300d5e5..0000000
--- a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/minortools/TestStringUtils.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.sse.unittests.minortools;
-
-
-
-public class TestStringUtils {
-
- /**
- * TestStringUtils constructor comment.
- */
- private TestStringUtils() {
- super();
- }
-
- /**
- * Replace matching literal portions of a string with another string
- */
- public static String replace(String aString, String source, String target) {
- if (aString == null)
- return null;
- String normalString = ""; //$NON-NLS-1$
- int length = aString.length();
- int position = 0;
- int previous = 0;
- int spacer = source.length();
- while (position + spacer - 1 < length && aString.indexOf(source, position) > -1) {
- position = aString.indexOf(source, previous);
- normalString = normalString + aString.substring(previous, position) + target;
- position += spacer;
- previous = position;
- }
- normalString = normalString + aString.substring(position, aString.length());
-
- return normalString;
- }
-
-}
\ No newline at end of file
diff --git a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/minortools/VersionRemover.java b/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/minortools/VersionRemover.java
deleted file mode 100644
index 811a668..0000000
--- a/development/org.eclipse.wst.sse.unittests/src/org/eclipse/wst/sse/unittests/minortools/VersionRemover.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.sse.unittests.minortools;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.eclipse.wst.xml.core.tests.util.CommonXML;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-
-
-/**
- * Modifies plugin.xml and fragment.xml files to not require specific versions
- * of their plugin dependencies.
- *
- * @author nitin
- */
-public class VersionRemover {
-
- char[] charbuff = new char[2048];
- StringBuffer s = null;
-
- public VersionRemover() {
- super();
- }
-
-
-
- public static void main(String[] args) {
- if (args.length < 1)
- new VersionRemover().visit(new File("d:/target"));
- else
- new VersionRemover().visit(new File(args[0]));
- }
-
-
-
- protected void visit(File file) {
- // Skip directories like org.eclipse.*, org.apache.*, and org.junit.*
- if (file.isDirectory() && !file.getName().startsWith("org.eclipse.") && !file.getName().startsWith("org.apache") && !file.getName().startsWith("org.junit")) {
- String[] contents = file.list();
- for (int i = 0; i < contents.length; i++)
- visit(new File(file.getAbsolutePath() + '/' + contents[i]));
- }
- else {
- fixupFile(file);
- }
- }
-
- protected void fixupFile(File file) {
- // only load and fixup files named plugin.xml or fragment.xml under eclipse\plugins\XXXXXXX.*
- if (!(file.getName().equalsIgnoreCase("plugin.xml") || file.getName().equalsIgnoreCase("fragment.xml")) || file.getAbsolutePath().indexOf("eclipse\\plugins\\XXXXXXX.") == -1)
- return;
- // System.out.println(file.getAbsolutePath());
- try {
- Document doc = CommonXML.getDocumentBuilder().parse(file);
- NodeList imports = null;
- if (file.getName().equalsIgnoreCase("plugin.xml"))
- imports = doc.getElementsByTagName("import");
- else if (file.getName().equalsIgnoreCase("fragment.xml"))
- imports = doc.getElementsByTagName("fragment");
- boolean changed = false;
- for (int i = 0; i < imports.getLength(); i++) {
- Node importNode = imports.item(i);
- if (importNode.getNodeName().equalsIgnoreCase("import") && importNode.getAttributes().getNamedItem("version") != null) {
- changed = true;
- importNode.getAttributes().removeNamedItem("version");
- }
- if (importNode.getAttributes().getNamedItem("plugin-version") != null) {
- changed = true;
- importNode.getAttributes().removeNamedItem("plugin-version");
- }
- if (importNode.getAttributes().getNamedItem("match") != null) {
- importNode.getAttributes().removeNamedItem("match");
- changed = true;
- }
- }
- if (changed) {
- FileOutputStream ostream = new FileOutputStream(file.getAbsolutePath());
- CommonXML.serialize(doc, ostream);
- ostream.close();
- System.out.println("Modified " + file.getAbsolutePath());
- }
- }
- catch (SAXException e) {
- System.err.println(file.getPath() + ": " + e);
- }
- catch (IOException e) {
- System.err.println(file.getPath() + ": " + e);
- }
- }
-}
\ No newline at end of file