Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/plugin.xml42
-rw-r--r--org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/handler/GenerateNewRefactoringHenshinCommandHandler.java54
2 files changed, 95 insertions, 1 deletions
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml b/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml
index db3961b..a1b6545 100644
--- a/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml
+++ b/org.eclipse.emf.refactor.refactoring.henshin/plugin.xml
@@ -11,5 +11,45 @@
name="Refactoring (specified in Henshin)">
</wizard>
</extension>
-
+ <extension
+ id="org.eclipse.emf.refactor.qa.menu"
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <menu
+ id="org.eclipse.emf.refactor.generator.menu"
+ label="EMF Quality Assurance (define new techniques)">
+ <command
+ commandId="org.eclipse.emf.refactor.refactoring.henshin.generateNewRefactoringHenshinCommand"
+ icon="icons/refactoring.png"
+ label="Generate New Refactoring (specified in Henshin)"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ <iterate
+ ifEmpty="false">
+ <instanceof
+ value="org.eclipse.emf.ecore.EObject">
+ </instanceof>
+ </iterate>
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.emf.refactor.refactoring.henshin.generateNewRefactoringHenshinCommand"
+ name="GenerateNewRefactoringHenshinCommand">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.emf.refactor.refactoring.henshin.handler.GenerateNewRefactoringHenshinCommandHandler"
+ commandId="org.eclipse.emf.refactor.refactoring.henshin.generateNewRefactoringHenshinCommand">
+ </handler>
+ </extension>
</plugin>
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/handler/GenerateNewRefactoringHenshinCommandHandler.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/handler/GenerateNewRefactoringHenshinCommandHandler.java
new file mode 100644
index 0000000..48c2174
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/handler/GenerateNewRefactoringHenshinCommandHandler.java
@@ -0,0 +1,54 @@
+package org.eclipse.emf.refactor.refactoring.henshin.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.refactor.refactoring.henshin.ui.NewRefactoringWizardHenshin;
+import org.eclipse.emf.refactor.refactoring.managers.SelectionManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class GenerateNewRefactoringHenshinCommandHandler implements IHandler {
+
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) { }
+
+ @Override
+ public void dispose() { }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ ISelection selection = win.getSelectionService().getSelection();
+ List<EObject> context = SelectionManager.getESelection(selection);
+ EObject selectedEObject = context.get(0);
+ String metamodel = ((EPackage) selectedEObject.eClass().eContainer()).getNsURI();
+ String contextType = selectedEObject.eClass().getInstanceClass().getSimpleName();
+ NewRefactoringWizardHenshin wizard = new NewRefactoringWizardHenshin(metamodel, contextType);
+ wizard.init(win.getWorkbench(), (IStructuredSelection) selection);
+ WizardDialog dialog = new WizardDialog(win.getShell(), wizard);
+ return dialog.open();
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) { }
+
+}

Back to the top