From 1a7a23b709efb4b032ebc195986d5537bc500032 Mon Sep 17 00:00:00 2001
From: tarendt
Date: Mon, 15 Oct 2012 18:25:38 +0000
Subject: initial commit
---
org.eclipse.emf.refactor.refactoring/.classpath | 7 +
org.eclipse.emf.refactor.refactoring/.project | 28 +++
.../.settings/org.eclipse.jdt.core.prefs | 7 +
.../META-INF/MANIFEST.MF | 18 ++
.../build.properties | 8 +
org.eclipse.emf.refactor.refactoring/plugin.xml | 6 +
.../schema/refactorings.exsd | 150 +++++++++++++
.../emf/refactor/refactoring/Activator.java | 52 +++++
.../refactoring/core/ExtensionPointTags.java | 14 ++
.../emf/refactor/refactoring/core/Port.java | 166 +++++++++++++++
.../emf/refactor/refactoring/core/Refactoring.java | 233 +++++++++++++++++++++
.../refactoring/core/RefactoringLoader.java | 77 +++++++
.../refactoring/interfaces/IController.java | 57 +++++
.../refactoring/interfaces/IDataManagement.java | 67 ++++++
.../refactoring/interfaces/IGuiHandler.java | 54 +++++
.../refactoring/managers/RefactoringManager.java | 64 ++++++
16 files changed, 1008 insertions(+)
create mode 100644 org.eclipse.emf.refactor.refactoring/.classpath
create mode 100644 org.eclipse.emf.refactor.refactoring/.project
create mode 100644 org.eclipse.emf.refactor.refactoring/.settings/org.eclipse.jdt.core.prefs
create mode 100644 org.eclipse.emf.refactor.refactoring/META-INF/MANIFEST.MF
create mode 100644 org.eclipse.emf.refactor.refactoring/build.properties
create mode 100644 org.eclipse.emf.refactor.refactoring/plugin.xml
create mode 100644 org.eclipse.emf.refactor.refactoring/schema/refactorings.exsd
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/Activator.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/ExtensionPointTags.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Port.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/Refactoring.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/core/RefactoringLoader.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IController.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IDataManagement.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/interfaces/IGuiHandler.java
create mode 100644 org.eclipse.emf.refactor.refactoring/src/org/eclipse/emf/refactor/refactoring/managers/RefactoringManager.java
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 @@
+
+
+
+
+
+
+
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 @@
+
+
+ org.eclipse.emf.refactor.refactoring
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
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 @@
+
+
+
+
+
+
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 @@
+
+
+
+
+
+
+
+
+ [Enter description of this extension point.]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [Enter the first release in which this extension point appears.]
+
+
+
+
+
+
+
+
+ [Enter extension point usage example here.]
+
+
+
+
+
+
+
+
+ [Enter API information here.]
+
+
+
+
+
+
+
+
+ [Enter information about supplied implementation of this extension point.]
+
+
+
+
+
+
+
+
+ /*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+
+
+
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 implements Comparable {
+
+ /**
+ * Name of the port.
+ */
+ final private String name;
+
+ /**
+ * Description of the port.
+ */
+ final private String description;
+
+ /**
+ * Type of the port.
+ */
+ final private Class 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 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 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 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 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 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 {
+
+ /**
+ * 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 getRefactorings(){
+ return new LinkedList
+ (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 loadRefactorings() {
+ SortedSet r = new TreeSet();
+ 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 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 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 getInPorts();
+
+ /**
+ * Gets the output ports of the model refactoring.
+ * @return Output ports of the model refactoring.
+ */
+ @SuppressWarnings("rawtypes")
+ public Set 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 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 refactorings =
+ new TreeSet();
+
+ /**
+ * 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 getRefactorings() {
+ return refactorings;
+ }
+
+}
--
cgit v1.2.3