Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarendt2014-04-15 14:57:30 +0000
committertarendt2014-04-15 14:57:30 +0000
commit16f43f87178d6d0eff8a6e288d1663ee5332e750 (patch)
tree469c76360baa9a0055a98ff060c80838b9455dba
parent9f8b0972119dd5ddc8c7913329a225656fdc64a0 (diff)
downloadorg.eclipse.emf.refactor.refactoring-16f43f87178d6d0eff8a6e288d1663ee5332e750.tar.gz
org.eclipse.emf.refactor.refactoring-16f43f87178d6d0eff8a6e288d1663ee5332e750.tar.xz
org.eclipse.emf.refactor.refactoring-16f43f87178d6d0eff8a6e288d1663ee5332e750.zip
menu appearance improved (icon added)
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu$1.classbin3089 -> 3089 bytes
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/bin/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.classbin3491 -> 5408 bytes
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml1
-rw-r--r--org.eclipse.emf.refactor.refactoring.papyrus/src/org/eclipse/emf/refactor/refactoring/papyrus/ui/PapyrusModelApplicationMenu.java48
4 files changed, 46 insertions, 3 deletions
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
index 99c2b64..6a0b228 100644
--- 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
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
index b69b21c..1eb0ac3 100644
--- 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
Binary files differ
diff --git a/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml b/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml
index 55e4bde..c4e7778 100644
--- a/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml
+++ b/org.eclipse.emf.refactor.refactoring.papyrus/plugin.xml
@@ -54,6 +54,7 @@
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any">
<menu
+ icon="icons/refactoring.png"
label="Papyrus UML Model Refactorings">
<visibleWhen
checkEnabled="true">
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
index e75fd04..666fa38 100644
--- 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
@@ -1,13 +1,19 @@
package org.eclipse.emf.refactor.refactoring.papyrus.ui;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
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.Activator;
import org.eclipse.emf.refactor.refactoring.papyrus.managers.PapyrusSelectionManager;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -15,6 +21,7 @@ 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.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
@@ -23,15 +30,28 @@ import org.eclipse.swt.widgets.Shell;
public class PapyrusModelApplicationMenu extends ContributionItem {
private final List<EObject> selection;
+ private final String iconDir = "icons/";
+ private final String iconFile = "refactoring.png";
+ private Image image;
public PapyrusModelApplicationMenu() {
selection = PapyrusSelectionManager.getENotationSelection();
+ try {
+ image = new Image(getDisplay(), getFullPath(iconDir + iconFile));
+ } catch (Exception e) {
+ image = null;
+ }
System.out.println("PapyrusNotationApplicationMenu::selection: " + selection);
}
public PapyrusModelApplicationMenu(String id) {
super(id);
selection = PapyrusSelectionManager.getENotationSelection();
+ try {
+ image = new Image(getDisplay(), getFullPath(iconDir + iconFile));
+ } catch (Exception e) {
+ image = null;
+ }
System.out.println("PapyrusNotationApplicationMenu::selection: " + selection);
}
@@ -41,9 +61,9 @@ public class PapyrusModelApplicationMenu extends ContributionItem {
IProject project = ProjectManager.getActualProject();
LinkedList<Refactoring> refactorings =
ConfigurationManager.getSelectedRefactorings(project);
- for(final Refactoring r : refactorings){
+ for(final Refactoring r : refactorings) {
if(r.getGui().showInMenu(this.selection)){
- MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
+ MenuItem menuItem = new MenuItem(menu, SWT.CHECK, menu.getItemCount());
menuItem.setText(r.getName());
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -60,14 +80,36 @@ public class PapyrusModelApplicationMenu extends ContributionItem {
new RefactoringWizardOpenOperation
(r.getGui().show());
dialog.run(shell, "Refactoring: " + r.getName());
-
} catch (Exception e2) {
MessageDialog
.openError(null, "Error", e2.getMessage());
}
}
});
+ if (image != null) {
+ menuItem.setImage(image);
+ }
}
}
}
+
+ private String getFullPath(String path){
+ URL url = FileLocator.find(Activator.getDefault().getBundle(), new Path(path), Collections.EMPTY_MAP);
+ URL fileUrl = null;
+ try {
+ fileUrl = FileLocator.toFileURL(url);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ return fileUrl.getPath();
+ }
+
+ public static Display getDisplay() {
+ Display display = Display.getCurrent();
+ //may be null if outside the UI thread
+ if (display == null)
+ display = Display.getDefault();
+ return display;
+ }
} \ No newline at end of file

Back to the top