Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarendt2012-10-15 18:25:38 +0000
committertarendt2012-10-15 18:25:38 +0000
commit1a7a23b709efb4b032ebc195986d5537bc500032 (patch)
tree83d50b6e83f3945ba6dbcd9828b7b67d2ac0966c
downloadorg.eclipse.emf.refactor.refactoring-1a7a23b709efb4b032ebc195986d5537bc500032.tar.gz
org.eclipse.emf.refactor.refactoring-1a7a23b709efb4b032ebc195986d5537bc500032.tar.xz
org.eclipse.emf.refactor.refactoring-1a7a23b709efb4b032ebc195986d5537bc500032.zip
initial commit
-rw-r--r--org.eclipse.emf.refactor.refactoring/.classpath7
-rw-r--r--org.eclipse.emf.refactor.refactoring/.project28
-rw-r--r--org.eclipse.emf.refactor.refactoring/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--org.eclipse.emf.refactor.refactoring/META-INF/MANIFEST.MF18
-rw-r--r--org.eclipse.emf.refactor.refactoring/build.properties8
-rw-r--r--org.eclipse.emf.refactor.refactoring/plugin.xml6
-rw-r--r--org.eclipse.emf.refactor.refactoring/schema/refactorings.exsd150
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/Activator.java52
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/ExtensionPointTags.java14
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Port.java166
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Refactoring.java233
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/RefactoringLoader.java77
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IController.java57
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IDataManagement.java67
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IGuiHandler.java54
-rw-r--r--org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/managers/RefactoringManager.java64
16 files changed, 1008 insertions, 0 deletions
diff --git a/org.eclipse.emf.refactor.refactoring/.classpath b/org.eclipse.emf.refactor.refactoring/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.emf.refactor.refactoring/.project b/org.eclipse.emf.refactor.refactoring/.project
new file mode 100644
index 0000000..28c75a3
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.emf.refactor.refactoring</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.emf.refactor.refactoring/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.emf.refactor.refactoring/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c537b63
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.emf.refactor.refactoring/META-INF/MANIFEST.MF b/org.eclipse.emf.refactor.refactoring/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..46b85c8
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Refactoring
+Bundle-SymbolicName: org.eclipse.emf.refactor.refactoring;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Bundle-Activator: org.eclipse.emf.refactor.refactoring.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.emf.ecore;bundle-version="2.8.1",
+ org.eclipse.ltk.core.refactoring;bundle-version="3.6.0",
+ org.eclipse.ltk.ui.refactoring;bundle-version="3.7.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.emf.refactor.refactoring,
+ org.eclipse.emf.refactor.refactoring.core,
+ org.eclipse.emf.refactor.refactoring.interfaces,
+ org.eclipse.emf.refactor.refactoring.managers
diff --git a/org.eclipse.emf.refactor.refactoring/build.properties b/org.eclipse.emf.refactor.refactoring/build.properties
new file mode 100644
index 0000000..1b09d56
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ bin/,\
+ schema/,\
+ src/
diff --git a/org.eclipse.emf.refactor.refactoring/plugin.xml b/org.eclipse.emf.refactor.refactoring/plugin.xml
new file mode 100644
index 0000000..643461b
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/plugin.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="org.eclipse.emf.refactor.refactorings" name="Refactorings" schema="schema/refactorings.exsd"/>
+
+</plugin>
diff --git a/org.eclipse.emf.refactor.refactoring/schema/refactorings.exsd b/org.eclipse.emf.refactor.refactoring/schema/refactorings.exsd
new file mode 100644
index 0000000..a7fd1fc
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/schema/refactorings.exsd
@@ -0,0 +1,150 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.refactor.common.groupmanagement" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.refactor" id="refactorings" name="org.eclipse.emf.refactor.refactorings"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="refactoring" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="refactoring">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="namespaceUri" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="menulabel" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="controller" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.refactor.common.core.IController"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="gui" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.refactor.common.core.ui.IGuiHandler"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ /*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/Activator.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/Activator.java
new file mode 100644
index 0000000..e285811
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/Activator.java
@@ -0,0 +1,52 @@
+package org.eclipse.emf.refactor.refactoring;
+
+import org.eclipse.emf.refactor.refactoring.managers.RefactoringManager;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.emf.refactor.refactoring"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ RefactoringManager.getInstance();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/ExtensionPointTags.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/ExtensionPointTags.java
new file mode 100644
index 0000000..ddce7c9
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/ExtensionPointTags.java
@@ -0,0 +1,14 @@
+package org.eclipse.emf.refactor.refactoring.core;
+
+public class ExtensionPointTags {
+
+ public static final String EXTENSION_POINT_TAG= "extension";
+ public static final String EXTENSION_POINT_NAME= "org.eclipse.emf.refactor.refactorings";
+ public static final String REFACTORING_TAG = "refactoring";
+ public static final String REFACTORING_ID_TAG = "id";
+ public static final String REFACTORING_NSURI_TAG = "namespaceUri";
+ public static final String REFACTORING_MENULABEL_TAG = "menulabel";
+ public static final String REFACTORING_CONTROLLER_TAG = "controller";
+ public static final String REFACTORING_GUI_TAG = "gui";
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Port.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Port.java
new file mode 100644
index 0000000..02710fb
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Port.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.core;
+
+/**
+ * Class used for model refactoring parameters with specific name, description,
+ * value, and type.
+ * @generated NOT
+ * @author Florian Mantz
+ */
+@SuppressWarnings("rawtypes")
+public class Port<T> implements Comparable<Port> {
+
+ /**
+ * Name of the port.
+ */
+ final private String name;
+
+ /**
+ * Description of the port.
+ */
+ final private String description;
+
+ /**
+ * Type of the port.
+ */
+ final private Class<T> type;
+
+ /**
+ * Value of the port.
+ */
+ private T value;
+
+ /**
+ * Default constructor.
+ * @param name Name of the port.
+ * @param type Type of the port.
+ * @param description Description of the port.
+ * @param initialValue Initial value of the port.
+ */
+ public Port(String name, Class<T> type, String description, T initialValue) {
+ this.name = name;
+ this.type = type;
+ this.description = description;
+ this.value = initialValue;
+ }
+
+ /**
+ * Constructor without description.
+ * @param name Name of the port.
+ * @param type Type of the port.
+ * @param initial Initial value of the port.
+ */
+ public Port(String name, Class<T> type, T initial) {
+ this(name,type,"",initial);
+ }
+
+ /**
+ * Contructor without description and initial value,
+ * @param name Name of the port.
+ * @param type Type of the port.
+ */
+ public Port(String name, Class<T> type) {
+ this(name,type,"",null);
+ }
+
+ /**
+ * Gets the Name of the port.
+ * @return Name of the port.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the description of the port.
+ * @return Description of the port.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the value of the port.
+ * @return Value of the port.
+ */
+ public T getValue() {
+ return value;
+ }
+
+ /**
+ * Gets the type of the port.
+ * @return Type of the port.
+ */
+ public Class<T> getType(){
+ return type;
+ }
+
+ /**
+ * Sets the value of the port.
+ * @param value Value of the port.
+ */
+ public void setValue(T value) {
+ this.value = value;
+ }
+
+ /**
+ * Connects two ports of equal types by setting the value of this to
+ * that of the given port.
+ * @param port Port whose value is the new value of this.
+ */
+ public void connect(Port<T> port){
+ if(! port.getType().equals(this.getType())){
+ throw new IllegalArgumentException("Ports are not of equal type");
+ }
+ this.value = port.getValue();
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Port other = (Port) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(Port port) {
+ return port.name.compareTo(this.name);
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Refactoring.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Refactoring.java
new file mode 100644
index 0000000..af0c761
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Refactoring.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.core;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.emf.refactor.refactoring.interfaces.IController;
+import org.eclipse.emf.refactor.refactoring.interfaces.IGuiHandler;
+import org.eclipse.emf.refactor.refactoring.managers.RefactoringManager;
+
+/**
+ * Base class of a specific emf model refactoring.
+ * @generated NOT
+ * @author Florian Mantz
+ */
+public class Refactoring implements Comparable<Refactoring> {
+
+ /**
+ * Id of the emf model refactoring.
+ */
+ private final String id;
+
+ /**
+ * Name of the emf model refactoring.
+ */
+ private final String name;
+
+ /**
+ * Namespace of the emf model refactoring.
+ */
+ private final String namespaceUri;
+
+ /**
+ * GuiHandler object of the emf model refactoring.
+ */
+ private final IGuiHandler gui;
+
+ /**
+ * Controller object of the emf model refactoring.
+ */
+ private IController controller;
+
+ /**
+ * ConfigurationElement object of the emf model refactoring used
+ * for lazy loading.
+ */
+ private IConfigurationElement rawRefactoring;
+
+ /**
+ * Contructs an emf model refactoring with GuiHandler object.
+ * @param id Id of the emf model refactoring.
+ * @param name Name of the emf model refactoring.
+ * @param namespaceUri Namespace of the emf model refactoring.
+ * @param gui GuiHandler object of the emf model refactoring.
+ */
+ private Refactoring
+ (String id, String name, String namespaceUri,IGuiHandler gui) {
+ this.id = id;
+ this.name = name;
+ this.namespaceUri = namespaceUri;
+ this.gui = gui;
+ this.gui.setParent(this);
+ }
+
+ /**
+ * Contructs an emf model refactoring with GuiHandler and a controller
+ * object.
+ * @param id Id of the emf model refactoring.
+ * @param name Name of the emf model refactoring.
+ * @param namespaceUri Namespace of the emf model refactoring.
+ * @param gui GuiHandler object of the emf model refactoring.
+ * @param controller Controller object of the emf model refactoring.
+ */
+ public Refactoring
+ (String id, String name, String namespaceUri,
+ IGuiHandler gui, IController controller){
+ this(id,name,namespaceUri,gui);
+ this.controller = controller;
+ this.controller.setParent(this);
+ }
+
+ /**
+ * Contructs an emf model refactoring with GuiHandler and a
+ * ConfigurationElement object.
+ * @param id Id of the emf model refactoring.
+ * @param name Name of the emf model refactoring.
+ * @param namespaceUri Namespace of the emf model refactoring.
+ * @param gui GuiHandler object of the emf model refactoring.
+ * @param rawRefactoring ConfigurationElement object of the emf model
+ * refactoring.
+ */
+ public Refactoring
+ (String id, String name, String namespaceUri,
+ IGuiHandler gui, IConfigurationElement rawRefactoring){
+ this(id,name,namespaceUri,gui);
+ this.rawRefactoring = rawRefactoring;
+ }
+
+ /**
+ * Gets the namespace of the emf model refactoring.
+ * @return Namespace of the emf model refactoring.
+ */
+ public String getNamespaceUri(){
+ return namespaceUri;
+ }
+
+ /**
+ * Gets the id of the emf model refactoring.
+ * @return Id of the emf model refactoring.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Gets the name of the emf model refactoring.
+ * @return Name of the emf model refactoring.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the controller object of the emf model refactoring.
+ * @return Controller object of the emf model refactoring.
+ */
+ public IController getController() {
+ lazyLoadController();
+ return controller;
+ }
+
+ private void lazyLoadController() {
+ if(null == controller){
+ try {
+ this.controller =
+ (IController)rawRefactoring
+ .createExecutableExtension("controller");
+ this.controller.setParent(this);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Gets the guiHandler object of the emf model refactoring.
+ * @return GuiHandler object of the emf model refactoring.
+ */
+ public IGuiHandler getGui() {
+ return gui;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Refactoring other = (Refactoring) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(Refactoring emfRefactoring) {
+ if(this.equals(emfRefactoring))return 0;
+ if(this.getName().equals(emfRefactoring.getName())){
+ return emfRefactoring.id.hashCode() - this.id.hashCode();
+ }else{
+ return emfRefactoring.getName().compareTo(this.getName());
+ }
+ }
+
+ /**
+ * Returns the emf model refactoring with the specified id.
+ * @param id Id of the emf model refactoring to be returned.
+ * @return Emf model refactoring with the specified id.
+ */
+ public static Refactoring getById(String id){
+ for (Refactoring r :
+ RefactoringManager.getInstance().getRefactorings()){
+ if(r.getId().equals(id)){
+ return r;
+ }
+ }
+ throw
+ new IllegalArgumentException("Refactoring id does not exist!");
+ }
+
+ /**
+ * Return a list of all registered emf model refactorings.
+ * @return List of all registered emf model refactorings.
+ */
+ public static List<Refactoring> getRefactorings(){
+ return new LinkedList<Refactoring>
+ (RefactoringManager.getInstance().getRefactorings());
+ }
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/RefactoringLoader.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/RefactoringLoader.java
new file mode 100644
index 0000000..237b431
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/RefactoringLoader.java
@@ -0,0 +1,77 @@
+package org.eclipse.emf.refactor.refactoring.core;
+
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.refactor.refactoring.interfaces.IController;
+import org.eclipse.emf.refactor.refactoring.interfaces.IGuiHandler;
+
+public class RefactoringLoader {
+
+ /**
+ * Loads a list of Refactoring objects out of the descriptions of
+ * the corresponding extension point servings.
+ * @return Created list of Refactoring objects.
+ */
+ public static SortedSet<Refactoring> loadRefactorings() {
+ SortedSet<Refactoring> r = new TreeSet<Refactoring>();
+ IConfigurationElement[] rawRefactorings =
+ Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(ExtensionPointTags.EXTENSION_POINT_NAME);
+ for(IConfigurationElement e : rawRefactorings){
+ try {
+ if(e.getName().equals(ExtensionPointTags.REFACTORING_TAG)){
+ Refactoring ref = createRefactoring(e);
+ if(null != ref)r.add(ref);
+ }
+ } catch (Exception e2) {
+ e2.printStackTrace();
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Creates an Refactoring object out of the description of
+ * the corresponding extension point serving.
+ * @param rawRefactoring description of the corresponding extension
+ * point serving.
+ * @return Created Refactoring object.
+ */
+ private static Refactoring createRefactoring
+ (IConfigurationElement rawRefactoring){
+ try {
+ final String id = rawRefactoring.getAttribute(ExtensionPointTags.REFACTORING_ID_TAG);
+ final String name = rawRefactoring.getAttribute(ExtensionPointTags.REFACTORING_MENULABEL_TAG);
+ IController controller = null;
+ IGuiHandler gui = null;
+ final String controllerClassName =
+ rawRefactoring.getAttribute(ExtensionPointTags.REFACTORING_CONTROLLER_TAG);
+ final String guiClassName =
+ rawRefactoring.getAttribute(ExtensionPointTags.REFACTORING_GUI_TAG);
+ final String namespaceUri =
+ rawRefactoring.getAttribute(ExtensionPointTags.REFACTORING_NSURI_TAG);
+ if(controllerClassName.equals(guiClassName)){
+ controller = (IController)rawRefactoring
+ .createExecutableExtension(ExtensionPointTags.REFACTORING_CONTROLLER_TAG);
+ gui = (IGuiHandler)controller;
+ return
+ new Refactoring
+ (id, name, namespaceUri, gui, controller);
+
+ } else {
+ //Only create gui, controller is lazy loaded:
+ gui = (IGuiHandler)rawRefactoring
+ .createExecutableExtension(ExtensionPointTags.REFACTORING_GUI_TAG);
+ return
+ new Refactoring
+ (id, name, namespaceUri, gui, rawRefactoring);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IController.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IController.java
new file mode 100644
index 0000000..14ae7e9
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IController.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.interfaces;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.refactoring.core.Refactoring;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
+
+/**
+ * Interface used for specifying the controller of a specific model refactoring.
+ * @generated NOT
+ * @author Thorsten Arendt
+ */
+public interface IController {
+
+ /**
+ * Sets the EmfRefactoring supported by the controller.
+ * @param emfRefactoring EmfRefactoring supported by the controller.
+ */
+ public void setParent(Refactoring refactoring);
+
+ /**
+ * Gets the EmfRefactoring supported by the controller.
+ * @return EmfRefactoring supported by the controller.
+ */
+ public Refactoring getParent();
+
+ /**
+ * Sets the selected EObject (invocation context of the model refactoring).
+ * @param selection Invocation context of the model refactoring.
+ */
+ public void setSelection(List<EObject> selection);
+
+ /**
+ * Returns the DataManagement object of the model refactoring.
+ * @return DataManagement object of the model refactoring.
+ */
+ public IDataManagement getDataManagementObject();
+
+
+ /**
+ * Returns the ltk RefactoringProcessor of the model refactoring.
+ * @return Ltk RefactoringProcessor of the model refactoring.
+ */
+ public RefactoringProcessor getLtkRefactoringProcessor();
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IDataManagement.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IDataManagement.java
new file mode 100644
index 0000000..4aac2c9
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IDataManagement.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.interfaces;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.refactoring.core.Port;
+
+/**
+ * Interface used for specific data concerning a model refactoring.
+ * @generated NOT
+ * @author Florian Mantz
+ */
+public interface IDataManagement {
+
+ /**
+ * Method for preselecting port values.
+ * @param selection Invocation context of the model refactoring.
+ */
+ public void preselect(List<EObject> selection);
+
+ /**
+ * Gets the input model refactoring port with the given name.
+ * @param name Name of the input port to be returned.
+ * @return Input model refactoring port with the given name.
+ */
+ @SuppressWarnings("rawtypes")
+ public Port getInPortByName(String name);
+
+ /**
+ * Gets the output model refactoring port with the given name.
+ * @param name Name of the output port to be returned.
+ * @return Output model refactoring port with the given name.
+ */
+ @SuppressWarnings("rawtypes")
+ public Port getOutPortByName(String name);
+
+ /**
+ * Gets the input ports of the model refactoring.
+ * @return Input ports of the model refactoring.
+ */
+ @SuppressWarnings("rawtypes")
+ public Set<Port> getInPorts();
+
+ /**
+ * Gets the output ports of the model refactoring.
+ * @return Output ports of the model refactoring.
+ */
+ @SuppressWarnings("rawtypes")
+ public Set<Port> getOutPorts();
+
+ /**
+ * Initializes the output ports of the model refactoring.
+ */
+ public void initOutPorts();
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IGuiHandler.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IGuiHandler.java
new file mode 100644
index 0000000..8807986
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IGuiHandler.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.interfaces;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.refactoring.core.Refactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+/**
+ * Interface used for specifying gui topics of a specific model refactoring.
+ * @generated NOT
+ * @author Florian Mantz
+ */
+public interface IGuiHandler {
+
+ /**
+ * Sets the EmfRefactoring supported by the GuiHandler.
+ * @param emfRefactoring EmfRefactoring supported by the GuiHandler.
+ */
+ public void setParent(Refactoring refactoring);
+
+ /**
+ * Gets the EmfRefactoring supported by the GuiHandler.
+ * @return EmfRefactoring supported by the GuiHandler.
+ */
+ public Refactoring getParent();
+
+
+ /**
+ * Specifies whether the model refactoring can be invoked from the
+ * context menu of the given selection context.
+ * @param selection Invocation context of the model refactoring.
+ * @return true, if the model refactoring can be invoked from the
+ * context menu of the given selection context, false otherwise.
+ */
+ public boolean showInMenu(List<EObject> selection);
+
+ /**
+ * Initializes the ltk RefactoringWzard of the model refactoring.
+ * @return Ltk RefactoringWzard of the model refactoring.
+ */
+ public RefactoringWizard show();
+
+}
diff --git a/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/managers/RefactoringManager.java b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/managers/RefactoringManager.java
new file mode 100644
index 0000000..eb133c6
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/managers/RefactoringManager.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) Philipps University of Marburg. 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:
+ * Philipps University of Marburg - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.refactor.refactoring.managers;
+
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.emf.refactor.refactoring.core.Refactoring;
+import org.eclipse.emf.refactor.refactoring.core.RefactoringLoader;
+
+/**
+ * Main manager class of EMF Refactor wrt model refactorings.
+ * @generated NOT
+ * @author Florian Mantz
+ */
+public final class RefactoringManager {
+
+ /**
+ * Singleton instance.
+ */
+ private static RefactoringManager instance;
+
+ /**
+ * Set of all registered emf model refactorings.
+ */
+ private final SortedSet<Refactoring> refactorings =
+ new TreeSet<Refactoring>();
+
+ /**
+ * Private constructor.
+ */
+ private RefactoringManager() {
+ this.refactorings.addAll(RefactoringLoader.loadRefactorings());
+ System.out.println("RefactoringManager initialized!");
+ }
+
+ /**
+ * Returns the singleton instance.
+ * @return
+ */
+ public static RefactoringManager getInstance() {
+ if(null == instance ) {
+ instance = new RefactoringManager();
+ }
+ return instance;
+ }
+
+ /**
+ * Gets a set of all registered emf model refactorings.
+ * @return Set of all registered emf model refactorings.
+ */
+ public SortedSet<Refactoring> getRefactorings() {
+ return refactorings;
+ }
+
+}

Back to the top