Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarendt2013-09-23 17:53:11 -0400
committertarendt2013-09-23 17:53:11 -0400
commita9ba597812ecd01e5a1a26ac7eb1d6219dc40411 (patch)
tree8ea28ca1b8ceef0285e174fe9f49e81280e016bb
parentef61ecedd486e08e9dab1e5aa21d75a2c4f4a493 (diff)
downloadorg.eclipse.emf.refactor.refactoring-a9ba597812ecd01e5a1a26ac7eb1d6219dc40411.tar.gz
org.eclipse.emf.refactor.refactoring-a9ba597812ecd01e5a1a26ac7eb1d6219dc40411.tar.xz
org.eclipse.emf.refactor.refactoring-a9ba597812ecd01e5a1a26ac7eb1d6219dc40411.zip
notation refactoring support
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.classbin0 -> 1127 bytes
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.classbin2271 -> 4713 bytes
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu$1.classbin0 -> 3089 bytes
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.classbin0 -> 3491 bytes
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml33
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.java29
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.java47
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.java73
9 files changed, 183 insertions, 0 deletions
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/META-INF/MANIFEST.MF b/org.eclipse.emf.refactor.refactoring.papyrus/META-INF/MANIFEST.MF
index 98b3f53..2d93bed 100644
--- a/org.eclipse.emf.refactor.refactoring.papyrus/META-INF/MANIFEST.MF
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/META-INF/MANIFEST.MF
@@ -17,3 +17,4 @@ Require-Bundle: org.eclipse.ui,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.ui
+Export-Package: org.eclipse.emf.refactor.refactoring.papyrus.managers
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.class b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.class
new file mode 100644
index 0000000..1e1ff5e
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.class b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.class
index 38d50b2..7121c12 100644
--- a/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.class
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu$1.class b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu$1.class
new file mode 100644
index 0000000..99c2b64
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu$1.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.class b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.class
new file mode 100644
index 0000000..b69b21c
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.class
Binary files differ
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml b/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml
index 04dc999..55e4bde 100644
--- a/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml
@@ -48,4 +48,37 @@
</handler>
</extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.ui.popup.any">
+ <menu
+ label="Papyrus UML Model Refactorings">
+ <visibleWhen
+ checkEnabled="true">
+ <iterate
+ ifEmpty="false">
+ <or>
+ <instanceof
+ value="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem">
+ </instanceof>
+ </or>
+ </iterate>
+ </visibleWhen>
+ <dynamic
+ class="org.eclipse.emf.refactor.refactoring.papyrus.ui.PapyrusModelApplicationMenu"
+ id="org.eclipse.emf.refactor.papyrus.dynamicmenu">
+ </dynamic>
+ </menu>
+ </menuContribution>
+ </extension>
+
+
+
+
+
</plugin>
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.java b/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.java
new file mode 100644
index 0000000..a7c5c76
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusManager.java
@@ -0,0 +1,29 @@
+package org.eclipse.emf.refactor.refactoring.papyrus.managers;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+
+public class PapyrusManager {
+
+ private static PapyrusManager instance;
+ private Diagram diagram;
+
+ private PapyrusManager() {
+ setDiagram(null);
+ System.out.println("PapyrusManager initialized!");
+ }
+
+ public static PapyrusManager getInstance() {
+ if (instance == null) {
+ instance = new PapyrusManager();
+ }
+ return instance;
+ }
+
+ public Diagram getDiagram() {
+ return diagram;
+ }
+
+ public void setDiagram(Diagram diagram) {
+ this.diagram = diagram;
+ }
+}
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.java b/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.java
index 36e6e55..cd97759 100644
--- a/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.java
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/managers/PapyrusSelectionManager.java
@@ -3,13 +3,49 @@ package org.eclipse.emf.refactor.refactoring.papyrus.managers;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
import org.eclipse.emf.refactor.refactoring.managers.SelectionManager;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
@SuppressWarnings("restriction")
public class PapyrusSelectionManager extends SelectionManager {
+
+ public static List<EObject> getENotationSelection() {
+ ISelection selection =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getSelectionService().getSelection();
+ List<EObject> r = SelectionManager.getESelection(selection);
+ for (Object o : getSelection(selection)) {
+ if (o instanceof IGraphicalEditPart) {
+ System.out.println("instanceof IGraphicalEditPart");
+ IGraphicalEditPart gep = (IGraphicalEditPart) o;
+ System.out.println("element: " + gep.resolveSemanticElement());
+ System.out.println("notation view: " + gep.getNotationView());
+ System.out.println("notation view element: " + gep.getNotationView().getElement());
+ EObject root = EcoreUtil.getRootContainer(gep.getNotationView());
+ System.out.println("root: " + root);
+ r.add(gep.getNotationView().getElement());
+ PapyrusManager.getInstance().setDiagram((Diagram) root);
+ r.add(root);
+ } else {
+ return null;
+ }
+ }
+ return r;
+ }
+
+ public static List<EObject> getESelection() {
+ ISelection selection =
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getSelectionService().getSelection();
+ return getESelection(selection);
+ }
public static List<EObject> getESelection(ISelection selection) {
if (selection == null)
@@ -34,5 +70,16 @@ public class PapyrusSelectionManager extends SelectionManager {
}
return r;
}
+
+ public static void getDiagram() {
+ IWorkbenchWindow[] iwws = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (IWorkbenchWindow iww : iwws) {
+ System.out.println("IWorkbenchWindow: " + iww);
+ IWorkbenchPage[] iwps = iww.getPages();
+ for (IWorkbenchPage iwp : iwps) {
+ System.out.println("IWorkbenchPage: " + iwp);
+ }
+ }
+ }
}
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.java b/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.java
new file mode 100644
index 0000000..e75fd04
--- /dev/null
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.java
@@ -0,0 +1,73 @@
+package org.eclipse.emf.refactor.refactoring.papyrus.ui;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.refactor.refactoring.configuration.managers.ConfigurationManager;
+import org.eclipse.emf.refactor.refactoring.core.Refactoring;
+import org.eclipse.emf.refactor.refactoring.managers.ProjectManager;
+import org.eclipse.emf.refactor.refactoring.papyrus.managers.PapyrusSelectionManager;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+public class PapyrusModelApplicationMenu extends ContributionItem {
+
+ private final List<EObject> selection;
+
+ public PapyrusModelApplicationMenu() {
+ selection = PapyrusSelectionManager.getENotationSelection();
+ System.out.println("PapyrusNotationApplicationMenu::selection: " + selection);
+ }
+
+ public PapyrusModelApplicationMenu(String id) {
+ super(id);
+ selection = PapyrusSelectionManager.getENotationSelection();
+ System.out.println("PapyrusNotationApplicationMenu::selection: " + selection);
+ }
+
+ @Override
+ public void fill(Menu menu, int index) {
+ ConfigurationManager.getInstance();
+ IProject project = ProjectManager.getActualProject();
+ LinkedList<Refactoring> refactorings =
+ ConfigurationManager.getSelectedRefactorings(project);
+ for(final Refactoring r : refactorings){
+ if(r.getGui().showInMenu(this.selection)){
+ MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
+ menuItem.setText(r.getName());
+ menuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ //1. Set Selection:
+ r.getController().setSelection(selection);
+ //2. Preselect Values:
+ r.getController().getDataManagementObject()
+ .preselect(selection);
+ //3. Show Refactoring-Gui:
+ Shell shell =
+ Display.getDefault().getActiveShell();
+ RefactoringWizardOpenOperation dialog =
+ new RefactoringWizardOpenOperation
+ (r.getGui().show());
+ dialog.run(shell, "Refactoring: " + r.getName());
+
+ } catch (Exception e2) {
+ MessageDialog
+ .openError(null, "Error", e2.getMessage());
+ }
+ }
+ });
+ }
+ }
+ }
+} \ No newline at end of file

Back to the top