refactoring MOVE OPERATION added
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController$1.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController$1.class new file mode 100644 index 0000000..1401f66 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController$1.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController$InternalRefactoringProcessor.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController$InternalRefactoringProcessor.class new file mode 100644 index 0000000..948abc7 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController$InternalRefactoringProcessor.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController.class new file mode 100644 index 0000000..79cdb38 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringDataManagement.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringDataManagement.class new file mode 100644 index 0000000..0322dc7 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringDataManagement.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringGuiHandler.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringGuiHandler.class new file mode 100644 index 0000000..e3e39c1 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringGuiHandler.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest$1.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest$1.class new file mode 100644 index 0000000..0dc5e26 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest$1.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest.class new file mode 100644 index 0000000..87191a5 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizard.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizard.class new file mode 100644 index 0000000..98478db --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizard.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizardPage.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizardPage.class new file mode 100644 index 0000000..675994b --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizardPage.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/plugin.xml b/org.eclipse.emf.refactor.refactorings.uml24/plugin.xml index 46e5f46..4c8ff22 100644 --- a/org.eclipse.emf.refactor.refactorings.uml24/plugin.xml +++ b/org.eclipse.emf.refactor.refactorings.uml24/plugin.xml
@@ -25,6 +25,12 @@ id="org.eclipse.emf.refactor.refactorings.uml24.moveattribute" menulabel="Move Attribute" namespaceUri="http://www.eclipse.org/uml2/4.0.0/UML"/> +<refactoring + controller="org.eclipse.emf.refactor.refactorings.uml24.moveoperation.RefactoringController" + gui="org.eclipse.emf.refactor.refactorings.uml24.moveoperation.RefactoringGuiHandler" + id="org.eclipse.emf.refactor.refactorings.uml24.moveoperation" + menulabel="Move Operation" + namespaceUri="http://www.eclipse.org/uml2/4.0.0/UML"/> <refactoring controller="org.eclipse.emf.refactor.refactorings.uml24.pullupattribute.RefactoringController" gui="org.eclipse.emf.refactor.refactorings.uml24.pullupattribute.RefactoringGuiHandler"
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController.java new file mode 100644 index 0000000..670174d --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringController.java
@@ -0,0 +1,264 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringController.javajet,v 1.3 2011/01/21 13:08:06 tarendt Exp $ + */ +package org.eclipse.emf.refactor.refactorings.uml24.moveoperation; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.refactor.refactoring.core.Refactoring; +import org.eclipse.emf.refactor.refactoring.interfaces.IController; +import org.eclipse.emf.refactor.refactoring.interfaces.IDataManagement; +import org.eclipse.emf.refactor.refactoring.runtime.ltk.LtkEmfRefactoringProcessorAdapter; +import org.eclipse.emf.refactor.refactorings.uml24.UmlUtils; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.VisibilityKind; + + +public final class RefactoringController implements IController{ + + /** + * Refactoring supported by the controller. + * @generated + */ + private Refactoring parent; + + /** + * DataManagement object of the model refactoring. + * @generated + */ + private RefactoringDataManagement dataManagement = + new RefactoringDataManagement(); + + /** + * Invocation context of the model refactoring. + * @generated + */ + private List<EObject> selection = new ArrayList<EObject>(); + + /** + * Ltk RefactoringProcessor of the model refactoring. + * @generated + */ + private InternalRefactoringProcessor refactoringProcessor = null; + + /** + * Gets the Refactoring supported by the controller. + * @return Refactoring supported by the controller. + * @see org.eclipse.emf.refactor.common.core.IController#getParent() + * @generated + */ + @Override + public Refactoring getParent() { + return this.parent; + } + + /** + * Sets the Refactoring supported by the controller. + * @param emfRefactoring Refactoring supported by the controller. + * @see org.eclipse.emf.refactor.common.core.IController# + * setParent(org.eclipse.emf.refactor.common.core.Refactoring) + * @generated + */ + @Override + public void setParent(Refactoring emfRefactoring) { + this.parent = emfRefactoring; + } + + /** + * Returns the DataManagement object of the model refactoring. + * @return DataManagement object of the model refactoring. + * @see org.eclipse.emf.refactor.common.core.IController# + * getDataManagementObject() + * @generated + */ + @Override + public IDataManagement getDataManagementObject() { + return this.dataManagement; + } + + /** + * Returns the ltk RefactoringProcessor of the model refactoring. + * @return Ltk RefactoringProcessor of the model refactoring. + * @see org.eclipse.emf.refactor.common.core.IController# + * getLtkRefactoringProcessor() + * @generated + */ + @Override + public RefactoringProcessor getLtkRefactoringProcessor() { + return this.refactoringProcessor; + } + + /** + * Sets the selected EObject (invocation context of the model refactoring). + * @param selection Invocation context of the model refactoring. + * @see org.eclipse.emf.refactor.common.core.IController# + * setSelection(java.util.List) + * @generated + */ + @Override + public void setSelection(List<EObject> selection) { + this.selection = selection; + this.refactoringProcessor = + new InternalRefactoringProcessor(this.selection); + } + + /** + * Returns a Runnable object that executes the model refactoring. + * @return Runnable object that executes the model refactoring. + * @generated + */ + private Runnable applyRefactoring() { + return new Runnable() { + /** + * @see java.lang.Runnable#run() + * @generated + */ + @Override + public void run() { + org.eclipse.uml2.uml.Operation selectedEObject = + (org.eclipse.uml2.uml.Operation) dataManagement. + getInPortByName(dataManagement.SELECTEDEOBJECT).getValue(); + String className = + (String) dataManagement.getInPortByName("className").getValue(); + // execute: move selected operation to specified class + List<Class> associatedClasses = + UmlUtils.getOne2OneAssociatedClasses(selectedEObject.getClass_()); + Class newClass = UmlUtils.getAssociatedClass(associatedClasses, className); + Class oldClass = selectedEObject.getClass_(); + oldClass.getOwnedOperations().remove(selectedEObject); + newClass.getOwnedOperations().add(selectedEObject); + } + }; + } + + /** + * Internal class for providing an instance of a LTK RefactoringProcessor + * used for EMF model refactorings. + * @generated + */ + public final class InternalRefactoringProcessor extends + LtkEmfRefactoringProcessorAdapter { + + /** + * Constructor using the invocation context of the model refactoring. + * @param selection Invocation context of the model refactoring. + * @generated + */ + private InternalRefactoringProcessor(List<EObject> selection){ + super(getParent(), selection, applyRefactoring()); + } + + /** + * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor# + * checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor) + * @generated + */ + @Override + public RefactoringStatus checkInitialConditions(){ + RefactoringStatus result = new RefactoringStatus(); + org.eclipse.uml2.uml.Operation selectedEObject = + (org.eclipse.uml2.uml.Operation) dataManagement. + getInPortByName(dataManagement.SELECTEDEOBJECT).getValue(); + // test: the selected operation must be owned by a class + String msg = "This refactoring can only be applied" + + " on operations which are owned by a class!"; + if (selectedEObject.getClass_() == null) { + result.addFatalError(msg); + } else { + // test: the selected operation must be public + msg = "This refactoring can only be applied on public operations!"; + if (! selectedEObject.getVisibility().equals(VisibilityKind.PUBLIC_LITERAL)) + result.addFatalError(msg); + // test: the owning class must be related to at least one other class + // using a bidirectional association with multiplicity 1:1 + msg = "The owning class is not related to at least one other class " + + "using a bidirectional association with multiplicity 1:1 " + + "and public association ends!"; + List<Class> associatedClasses = + UmlUtils.getOne2OneAssociatedClasses(selectedEObject.getClass_()); + if (associatedClasses.isEmpty()) result.addFatalError(msg); + } + //if (result.hasEntries()) MessageDialog.openInformation(null, "", result.getEntries().toString()); + return result; + } + + /** + * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor# + * checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) + * @generated + */ + @Override + public RefactoringStatus checkFinalConditions(){ + RefactoringStatus result = new RefactoringStatus(); + org.eclipse.uml2.uml.Operation selectedEObject = + (org.eclipse.uml2.uml.Operation) dataManagement. + getInPortByName(dataManagement.SELECTEDEOBJECT).getValue(); + String className = + (String) dataManagement.getInPortByName("className").getValue(); + // test: the owning class must be related to a class with the specified + // name using a bidirectional association with multiplicity 1:1 + String msg = "The owning class is not related to a class named '" + + className + "' using a bidirectional association with " + + "multiplicity 1:1 and public association ends!"; + List<Class> associatedClasses = + UmlUtils.getOne2OneAssociatedClasses(selectedEObject.getClass_()); + if (! UmlUtils.isAssociatedClass(associatedClasses, className)) { + result.addFatalError(msg); + } else { + // test: the associated class must not own an operation with the + // same name as the selected operation and a similar parameter list + msg = "The associated class already owns an operation named '" + + selectedEObject.getName() + "' having the same signature " + + "(type and parameter list)!"; + Class cl = UmlUtils.getAssociatedClass(associatedClasses, className); + if (classOwnsOperation(cl, selectedEObject)) result.addFatalError(msg); + // test: the associated class must already inherit an operation with the + // same name as the selected operation and a similar parameter list + msg = "The associated class already inherits an an operation named '" + + selectedEObject.getName() + "' having the same signature " + + "(type and parameter list)!"; + if (classInheritsOperation(cl, selectedEObject)) result.addFatalError(msg); + } + if (result.hasEntries()) MessageDialog.openInformation(null, "", result.getEntries().toString()); + return result; + } + + private boolean classInheritsOperation(Class cl, Operation operation) { + for (NamedElement namedElement : cl.getInheritedMembers()) { + if (namedElement instanceof Operation) { + Operation inheritedOperation = (Operation) namedElement; + if (inheritedOperation.getName().equals(operation.getName()) + && UmlUtils.haveSameTypes(inheritedOperation, operation) + && UmlUtils.haveSameSignatures(inheritedOperation, operation)) { + return true; + } + } + } + return false; + } + + private boolean classOwnsOperation(Class cl, Operation operation) { + for (Operation op : cl.getOwnedOperations()) { + if (op.getName().equals(operation.getName()) + && UmlUtils.haveSameTypes(op, operation) + && UmlUtils.haveSameSignatures(op, operation)) { + return true; + } + } + return false; + } + + } + +} \ No newline at end of file
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringDataManagement.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringDataManagement.java new file mode 100644 index 0000000..624e9ee --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringDataManagement.java
@@ -0,0 +1,57 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringDataManagement.javajet,v 1.2 2011/01/21 13:08:06 tarendt Exp $ + */ + package org.eclipse.emf.refactor.refactorings.uml24.moveoperation; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.refactor.refactoring.core.Port; +import org.eclipse.emf.refactor.refactoring.runtime.DataManagementAdapter; + +/** + * Class for specific data concerning a model refactoring. + * @generated + */ +public class RefactoringDataManagement extends DataManagementAdapter { + + protected final String SELECTEDEOBJECT = "selectedEObject"; + + /** + * Default constructor. + * @generated + */ + public RefactoringDataManagement() { + this.addPorts(); + } + + /** + * Adds the ports to the data management used for parameter passing. + * @generated + */ + private void addPorts(){ + this.inPorts.add + (new Port<org.eclipse.uml2.uml.Operation> + (SELECTEDEOBJECT, org.eclipse.uml2.uml.Operation.class)); + this.inPorts.add + (new Port<String> + ("className", String.class, "unspecified")); + } + + /** + * @see org.eclipse.emf.refactor.common.core.IDataManagement# + * preselect(java.util.List) + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void preselect(List<EObject> selection) { + getInPortByName(SELECTEDEOBJECT). + setValue((org.eclipse.uml2.uml.Operation) selection.get(0)); + } + +} + \ No newline at end of file
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringGuiHandler.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringGuiHandler.java new file mode 100644 index 0000000..ea98e7b --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringGuiHandler.java
@@ -0,0 +1,76 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringGuiHandler.javajet,v 1.1 2010/07/15 13:08:44 tarendt Exp $ + */ + package org.eclipse.emf.refactor.refactorings.uml24.moveoperation; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.refactor.refactoring.core.Refactoring; +import org.eclipse.emf.refactor.refactoring.interfaces.IGuiHandler; +import org.eclipse.ltk.ui.refactoring.RefactoringWizard; + +/** + * Class used for specifying gui topics of a specific model refactoring. + * @generated + */ +public class RefactoringGuiHandler implements IGuiHandler { + + /** + * Refactoring supported by the GuiHandler. + * @generated + */ + Refactoring parent; + + /** + * @see org.eclipse.emf.refactor.common.core.ui.IGuiHandler#getParent() + * @generated + */ + @Override + public Refactoring getParent() { + return parent; + } + + /** + * @see org.eclipse.emf.refactor.common.core.ui.IGuiHandler# + * setParent(org.eclipse.emf.refactor.common.core.Refactoring) + * @generated + */ + @Override + public void setParent(Refactoring emfRefactoring) { + this.parent = emfRefactoring; + } + + /** + * @see org.eclipse.emf.refactor.common.core.ui.IGuiHandler#show() + * @generated + */ + @Override + public RefactoringWizard show() { + return new org.eclipse.emf.refactor.refactorings.uml24.moveoperation.RefactoringWizard + ((RefactoringController)this.parent.getController()); + } + + /** + * @see org.eclipse.emf.refactor.common.core.ui.IGuiHandler# + * showInMenu(java.util.List) + * @generated + */ + @Override + public boolean showInMenu(List<EObject> selection) { + if (selection.size() > 1) return false; + for(EObject o:selection){ + if(null != o){ + if (o instanceof org.eclipse.uml2.uml.Operation) { + return true; + } + } + } + return false; + } + +} + \ No newline at end of file
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest.java new file mode 100644 index 0000000..d63bf77 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringTest.java
@@ -0,0 +1,97 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringTest.javajet,v 1.2 2011/03/16 16:14:21 tarendt Exp $ + */ + +package org.eclipse.emf.refactor.refactorings.uml24.moveoperation; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.refactor.refactoring.core.Refactoring; +import org.eclipse.emf.refactor.refactoring.runtime.test.JUnitTestCaseAdapter; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * Class used for running individual JUnit test cases + * of the specific model refactoring. + * @generated + */ +@RunWith(value = Parameterized.class) +public class RefactoringTest extends JUnitTestCaseAdapter { + + /** + * Number of test cases. + * @generated + */ + private String number; + + /** + * Constructor implementation. + * @param number Number of test cases. + * @generated + */ + public RefactoringTest(String number) throws IOException { + super("de.unimarburg.swt.refactorings.uml.moveoperation", + "uml", + new File(".").getCanonicalPath(), + new Refactoring(null, "", "http://www.eclipse.org/uml2/3.0.0/UML", new RefactoringGuiHandler(), new RefactoringController())); + register(UMLPackage.eINSTANCE); + this.number = number; + } + + @Parameters + public static Collection<Object[]> data() { + List<String> testNumbers = getTestNumbers(); + Object[][] data = new Object[testNumbers.size()][1]; + for (int i = 0; i < testNumbers.size(); i++) { + data[i][0] = testNumbers.get(i); + } + return Arrays.asList(data); + } + + private static List<String> getTestNumbers() { + List<String> numbers = new ArrayList<String>(); + try { + String pathPrefix = new File(".").getCanonicalPath() + "/tests/" + "de.unimarburg.swt.refactorings.uml.moveoperation"; + File testCaseDir = new File(pathPrefix,"/"); + FilenameFilter filter = new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.startsWith("test_"); + } + }; + String[] children = testCaseDir.list(filter); + if (children != null) { + for (String child : children) { + numbers.add( + child.substring( + child.indexOf('_') + 1)); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return numbers; + } + + /** + * Runs the test. + */ + @Test + public void test() { + System.out.println("running test test_" + number); + executeTestCase(number); + } + +} \ No newline at end of file
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizard.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizard.java new file mode 100644 index 0000000..47e3d79 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizard.java
@@ -0,0 +1,40 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringWizard.javajet,v 1.1 2010/07/15 13:08:44 tarendt Exp $ + */ + package org.eclipse.emf.refactor.refactorings.uml24.moveoperation; + +import org.eclipse.emf.refactor.refactoring.interfaces.IController; +import org.eclipse.emf.refactor.refactoring.runtime.ltk.ui.AbstractRefactoringWizard; + +/** + * Class used for providing an implementation of an LTK + * RefactoringWizard in EMF Refactor. + * @generated + */ +public class RefactoringWizard + extends AbstractRefactoringWizard { + + /** + * Default constructor implementation. + * @param controller Controller of the EMF model refactoring. + * @generated + */ + public RefactoringWizard(IController controller) { + super(controller); + } + + /** + * @see org.eclipse.ltk.ui.refactoring.RefactoringWizard# + * addUserInputPages() + * @generated + */ + @Override + protected void addUserInputPages() { + addPage(new RefactoringWizardPage + (controller.getParent().getName(), (RefactoringController)controller)); + } + +}
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizardPage.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizardPage.java new file mode 100644 index 0000000..38fe552 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/moveoperation/RefactoringWizardPage.java
@@ -0,0 +1,124 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringWizardPage.javajet,v 1.1 2010/07/15 13:08:44 tarendt Exp $ + */ + package org.eclipse.emf.refactor.refactorings.uml24.moveoperation; + +import java.util.List; + +import org.eclipse.emf.refactor.refactoring.runtime.ltk.ui.AbstractRefactoringWizard; +import org.eclipse.emf.refactor.refactoring.runtime.ui.IInputPageButtonCreator; +import org.eclipse.emf.refactor.refactoring.runtime.ui.InputPageButtonLoader; +import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +/** + * Class for setting model refactoring specific parameters + * by the user. + * @generated + */ +public class RefactoringWizardPage extends + UserInputWizardPage implements Listener { + + /** + * Controller of the EMF model refactoring. + * @generated + */ + private final RefactoringController controller; + + /** + * Label for each parameter. + * @generated + */ + private Label classNameLabel; + + /** + * TextField for each parameter. + * @generated + */ + private Text classNameWidget; + + /** + * Default constructor using a name and the controller of the + * EMF model refactoring. + * @param name Name of the WizardPage. + * @param controller Controller of the EMF model refactoring. + * @generated + */ + public RefactoringWizardPage + (String name, RefactoringController controller) { + super(name); + this.controller = controller; + } + + /** + * @see org.eclipse.swt.widgets.Listener# + * handleEvent(org.eclipse.swt.widgets.Event) + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void handleEvent(Event event) { + getWizard().getContainer().updateButtons(); + + if (classNameWidget != null) { + String className = classNameWidget.getText(); + if (!className.isEmpty()){ + ((RefactoringDataManagement) + this.controller.getDataManagementObject()). + getInPortByName("className"). + setValue(className); + } else { + ((RefactoringDataManagement) + this.controller.getDataManagementObject()). + getInPortByName("className"). + setValue("unspecified"); + } + } + + } + + /** + * @see org.eclipse.jface.dialogs.IDialogPage# + * createControl(org.eclipse.swt.widgets.Composite) + * @generated + */ + @Override + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridLayout gl = new GridLayout(); + gl.numColumns = 2; + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + composite.setLayout(gl); + + + classNameLabel = new Label(composite, SWT.NONE); + classNameLabel.setText("Name of the associated class: "); + classNameLabel.setEnabled(true); + + classNameWidget = new Text(composite, SWT.BORDER); + classNameWidget.setToolTipText + ("value of variable 'className'"); + classNameWidget.setEnabled(true); + classNameWidget.setLayoutData(gd); + classNameWidget.addListener(SWT.Modify, this); + + List<IInputPageButtonCreator> buttonCreators = InputPageButtonLoader.iNSTANCE.getInputPageButtonCreatorClasses(); + for(IInputPageButtonCreator creator : buttonCreators){ + creator.createButton(composite, controller, (AbstractRefactoringWizard)this.getWizard()); + } + + setControl(composite); + } + +} + \ No newline at end of file