refactoring RENAME OPERATION added
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController$1.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController$1.class new file mode 100644 index 0000000..7728ab1 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController$1.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController$InternalRefactoringProcessor.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController$InternalRefactoringProcessor.class new file mode 100644 index 0000000..675c5de --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController$InternalRefactoringProcessor.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController.class new file mode 100644 index 0000000..5cf9632 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringDataManagement.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringDataManagement.class new file mode 100644 index 0000000..04bae1e --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringDataManagement.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringGuiHandler.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringGuiHandler.class new file mode 100644 index 0000000..423b7fb --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringGuiHandler.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest$1.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest$1.class new file mode 100644 index 0000000..38f8eef --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest$1.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest.class new file mode 100644 index 0000000..0085110 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizard.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizard.class new file mode 100644 index 0000000..940a35f --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizard.class Binary files differ
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizardPage.class b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizardPage.class new file mode 100644 index 0000000..c76936c --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/bin/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/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 1249620..4ab2ffc 100644 --- a/org.eclipse.emf.refactor.refactorings.uml24/plugin.xml +++ b/org.eclipse.emf.refactor.refactorings.uml24/plugin.xml
@@ -14,6 +14,12 @@ menulabel="Rename Class" namespaceUri="http://www.eclipse.org/uml2/4.0.0/UML"/> <refactoring + controller="org.eclipse.emf.refactor.refactorings.uml24.renameoperation.RefactoringController" + gui="org.eclipse.emf.refactor.refactorings.uml24.renameoperation.RefactoringGuiHandler" + id="org.eclipse.emf.refactor.refactorings.uml24.renameoperation" + menulabel="Rename 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" id="org.eclipse.emf.refactor.refactorings.uml24.pullupattribute"
diff --git a/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController.java new file mode 100644 index 0000000..51b6f1a --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringController.java
@@ -0,0 +1,237 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringController.javajet,v 1.3 2011/01/21 13:08:06 tarendt Exp $ + */ +package org.eclipse.emf.refactor.refactorings.uml24.renameoperation; + +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.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; + + +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 Refactoring 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 Refactoring) { + this.parent = Refactoring; + } + + /** + * 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); + System.out.println(selection.get(0).eIsProxy()); + System.out.println("Selection: " + selection.get(0)); + System.out.println("eResource: " + selection.get(0).eResource()); + } + + /** + * 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 newName = + (String) dataManagement.getInPortByName("newName").getValue(); + // execute: rename selected operation to the inserted name + selectedEObject.setName(newName); + } + }; + } + + /** + * 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); + 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 newName = + (String) dataManagement.getInPortByName("newName").getValue(); + // test: the inserted name must be different from the old operation name + String msg = "The selected operation is already named '" + newName + "'!"; + if (selectedEObject.getName().equals(newName)) result.addFatalError(msg); + // the owning class must not own an operation with the inserted name + // and a similar parameter list + msg = "The owning class already owns an operation named '" + newName + "'" + + " having the same signature (type and parameter list)!"; + Class cl = selectedEObject.getClass_(); + if (classOwnsOperation(cl, selectedEObject, newName)) result.addFatalError(msg); + // the owning class must not inherit an operation with the inserted name + // and a similar parameter list + msg = "The owning class already inherits an operation named '" + newName + "'" + + " having the same signature (type and parameter list)!"; + if (classInheritsOperation(cl, selectedEObject, newName)) result.addFatalError(msg); + return result; + } + + private boolean classInheritsOperation(Class cl, Operation operationToRename, + String newName) { + for (NamedElement namedElement : cl.getInheritedMembers()) { + if (namedElement instanceof Operation) { + Operation inheritedOperation = (Operation) namedElement; + if (inheritedOperation.getName().equals(newName) + && UmlUtils.haveSameTypes(inheritedOperation, operationToRename) + && UmlUtils.haveSameSignatures(inheritedOperation, operationToRename)) { + return true; + } + } + } + return false; + } + + private boolean classOwnsOperation(Class cl, Operation operationToRename, + String newName) { + for (Operation op : cl.getOwnedOperations()) { + if (op != operationToRename) { + if (op.getName().equals(newName) + && UmlUtils.haveSameTypes(op, operationToRename) + && UmlUtils.haveSameSignatures(op, operationToRename)) { + 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/renameoperation/RefactoringDataManagement.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringDataManagement.java new file mode 100644 index 0000000..9cabd0b --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/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.renameoperation; + +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> + ("newName", 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/renameoperation/RefactoringGuiHandler.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringGuiHandler.java new file mode 100644 index 0000000..ad44735 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringGuiHandler.java
@@ -0,0 +1,75 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringGuiHandler.javajet,v 1.1 2010/07/15 13:08:44 tarendt Exp $ + */ + package org.eclipse.emf.refactor.refactorings.uml24.renameoperation; + +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 Refactoring) { + this.parent = Refactoring; + } + + /** + * @see org.eclipse.emf.refactor.common.core.ui.IGuiHandler#show() + * @generated + */ + @Override + public RefactoringWizard show() { + return new org.eclipse.emf.refactor.refactorings.uml24.renameoperation.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/renameoperation/RefactoringTest.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest.java new file mode 100644 index 0000000..734e71d --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringTest.java
@@ -0,0 +1,99 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringTest.javajet,v 1.2 2011/03/16 16:14:21 tarendt Exp $ + */ + +package org.eclipse.emf.refactor.refactorings.uml24.renameoperation; + +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.emf.refactor.refactorings.uml24.renameoperation.RefactoringController; +import org.eclipse.emf.refactor.refactorings.uml24.renameoperation.RefactoringGuiHandler; +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("org.eclipse.emf.refactor.refactorings.uml24.RenameMethod", + "uml", + new File(".").getCanonicalPath(), + new Refactoring(null, "", "http://www.eclipse.org/uml2/4.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.renameoperation"; + 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/renameoperation/RefactoringWizard.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizard.java new file mode 100644 index 0000000..5e4cb95 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizard.java
@@ -0,0 +1,41 @@ +/** + * <copyright> + * </copyright> + * + * $Id: RefactoringWizard.javajet,v 1.1 2010/07/15 13:08:44 tarendt Exp $ + */ + package org.eclipse.emf.refactor.refactorings.uml24.renameoperation; + +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/renameoperation/RefactoringWizardPage.java b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/RefactoringWizardPage.java new file mode 100644 index 0000000..a2ddf42 --- /dev/null +++ b/org.eclipse.emf.refactor.refactorings.uml24/src/org/eclipse/emf/refactor/refactorings/uml24/renameoperation/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.renameoperation; + +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 newNameLabel; + + /** + * TextField for each parameter. + * @generated + */ + private Text newNameWidget; + + /** + * 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 (newNameWidget != null) { + String newName = newNameWidget.getText(); + if (!newName.isEmpty()){ + ((RefactoringDataManagement) + this.controller.getDataManagementObject()). + getInPortByName("newName"). + setValue(newName); + } else { + ((RefactoringDataManagement) + this.controller.getDataManagementObject()). + getInPortByName("newName"). + 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); + + + newNameLabel = new Label(composite, SWT.NONE); + newNameLabel.setText("New name of the operation: "); + newNameLabel.setEnabled(true); + + newNameWidget = new Text(composite, SWT.BORDER); + newNameWidget.setToolTipText + ("value of variable 'newName'"); + newNameWidget.setEnabled(true); + newNameWidget.setLayoutData(gd); + newNameWidget.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