Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java158
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java76
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java118
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java156
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java78
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java57
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameTargetNamespaceAction.java78
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java195
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorActionGroup.java70
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorGroupActionDelegate.java60
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDSelectionDispatchAction.java54
11 files changed, 0 insertions, 1100 deletions
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
deleted file mode 100644
index cb3f3bfc8c..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeAnonymousTypeGlobalAction.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.editor.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)){ //$NON-NLS-1$
- if(isComplexType){
- return fParentName + "ComplexType"; //$NON-NLS-1$
- }
- else{
- return fParentName + "SimpleType"; //$NON-NLS-1$
- }
- }
- else{
- if(isComplexType){
- return "NewComplexType"; //$NON-NLS-1$
- }
- else{
- return "NewSimpleType"; //$NON-NLS-1$
- }
- }
-
- }
- 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) && super.canEnable(selectedObject);
- }
- else if (selectedObject instanceof Node) {
- Node node = (Node) selectedObject;
- XSDConcreteComponent concreteComponent = getSchema().getCorrespondingComponent(node);
- return canEnable(concreteComponent) && super.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
deleted file mode 100644
index 847b127ce7..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/MakeLocalElementGlobalAction.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.RefactoringMessages;
-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);
- 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) && super.canEnable(selectedObject);
- }
- else if (selectedObject instanceof Node) {
- Node node = (Node) selectedObject;
- XSDConcreteComponent concreteComponent = getSchema()
- .getCorrespondingComponent(node);
- return canEnable(concreteComponent) && super.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
deleted file mode 100644
index 01d2fb7546..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameAction.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.editor.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
deleted file mode 100644
index 8fca3619e2..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameComponentAction.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.common.ui.internal.dialogs.SaveDirtyFilesDialog;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xsd.ui.internal.editor.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) && super.canEnable(selectedObject);
- } else if (selectedObject instanceof Node)
- {
- Node node = (Node) selectedObject;
- if (getSchema() != null)
- {
- XSDConcreteComponent concreteComponent = getSchema()
- .getCorrespondingComponent(node);
- return canEnable(concreteComponent) && super.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);
- }
-
- }
-
- boolean rc = SaveDirtyFilesDialog.saveDirtyFiles();
- if (!rc)
- {
- return;
- }
- 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());
-
- // TODO (cs) I'm not sure why we need to do this. See bug 145700
- //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
deleted file mode 100644
index 17d7d9fa8a..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceAction.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.editor.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
deleted file mode 100644
index 444a5abbf9..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameResourceActionDelegate.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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
deleted file mode 100644
index 58ceedc9ac..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/RenameTargetNamespaceAction.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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.editor.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 super.canEnable(selectedObject);
-
- }
-
- 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
deleted file mode 100644
index 7a2aaca5e4..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/SelectionDispatchAction.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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) {
-
- }
-
- /* (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
deleted file mode 100644
index 0169f2625e..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorActionGroup.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.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
deleted file mode 100644
index a0873fc8cb..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDRefactorGroupActionDelegate.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper;
-import org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup;
-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.XSDSchema;
-
-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) {
- XSDSchema schema = (XSDSchema)editor.getAdapter(XSDSchema.class);
- ISelectionMapper mapper = (ISelectionMapper)editor.getAdapter(ISelectionMapper.class);
- if (schema != null)
- {
- ISelection selection = mapper != null ? mapper.mapSelection(fSelection) : fSelection;
- RefactorActionGroup refactorMenuGroup = new XSDRefactorActionGroup(selection, schema);
- RefactorGroupSubMenu subMenu = new RefactorGroupSubMenu(refactorMenuGroup);
- subMenu.fill(menu, -1);
- }
- }
-
- }
-
- }
-}
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
deleted file mode 100644
index ba28df9f87..0000000000
--- a/bundles/org.eclipse.wst.xsd.ui/src-refactor/org/eclipse/wst/xsd/ui/internal/refactor/actions/XSDSelectionDispatchAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xsd.ui.internal.refactor.actions;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.xsd.XSDConcreteComponent;
-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;
- }
-
- protected boolean canEnable(Object selectedComponent)
- {
- XSDSchema selectedComponentSchema = null;
- if (selectedComponent instanceof XSDConcreteComponent)
- {
- selectedComponentSchema = ((XSDConcreteComponent)selectedComponent).getSchema();
- }
-
- if (selectedComponentSchema != null && selectedComponentSchema == getSchema() )
- {
- return true;
- }
- return false;
- }
-
-}

Back to the top