Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Prouvost2016-01-13 13:02:15 +0000
committerOlivier Prouvost2016-01-13 14:25:28 +0000
commit89ac2390067f0e283154e322a7af014eb0e2f1d1 (patch)
treea60b16bc2b4a19190321049393b9a8c234d01dbe
parent2ce73c5af56bff3303251048b12cc2f915bc00cb (diff)
downloadorg.eclipse.e4.tools-89ac2390067f0e283154e322a7af014eb0e2f1d1.tar.gz
org.eclipse.e4.tools-89ac2390067f0e283154e322a7af014eb0e2f1d1.tar.xz
org.eclipse.e4.tools-89ac2390067f0e283154e322a7af014eb0e2f1d1.zip
Bug 482250 - Add a menu 'E4 Spies' to access to the spies
Change-Id: I74b366edeb4a11c8afe4c981bf1ffc81e2384dcc Signed-off-by: Olivier Prouvost <olivier.prouvost@opcoach.com>
-rw-r--r--bundles/org.eclipse.e4.tools.spy/build.properties5
-rw-r--r--bundles/org.eclipse.e4.tools.spy/fragment.e4xmi14
-rw-r--r--bundles/org.eclipse.e4.tools.spy/plugin.xml4
-rw-r--r--bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyProcessor.java35
4 files changed, 52 insertions, 6 deletions
diff --git a/bundles/org.eclipse.e4.tools.spy/build.properties b/bundles/org.eclipse.e4.tools.spy/build.properties
index e9863e28..9afdcd18 100644
--- a/bundles/org.eclipse.e4.tools.spy/build.properties
+++ b/bundles/org.eclipse.e4.tools.spy/build.properties
@@ -1,5 +1,6 @@
-source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ fragment.e4xmi
+source.. = src/
diff --git a/bundles/org.eclipse.e4.tools.spy/fragment.e4xmi b/bundles/org.eclipse.e4.tools.spy/fragment.e4xmi
new file mode 100644
index 00000000..a3aac1ba
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.spy/fragment.e4xmi
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ASCII"?>
+<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_Yv7zwLnQEeWXX4KE4W3FyQ">
+ <fragments xsi:type="fragment:StringModelFragment" xmi:id="_ZeXAALnQEeWXX4KE4W3FyQ" featurename="menuContributions" parentElementId="xpath:/" positionInList="">
+ <elements xsi:type="menu:MenuContribution" xmi:id="_br97sLn_EeWJoqtWvx7b2g" elementId="org.eclipse.e4.tools.spy.menucontribution.0" positionInParent="after=additions" parentId="org.eclipse.ui.main.menu">
+ <children xsi:type="menu:Menu" xmi:id="_fUHHELn_EeWJoqtWvx7b2g" elementId="window" label="Window"/>
+ </elements>
+ <elements xsi:type="menu:MenuContribution" xmi:id="_dFxLkLnQEeWXX4KE4W3FyQ" elementId="org.eclipse.e4.tools.spy.menucontribution" positionInParent="after=additions" parentId="window">
+ <children xsi:type="menu:MenuSeparator" xmi:id="_Xncg4LoAEeWJoqtWvx7b2g" elementId="org.eclipse.e4.tools.spy.menuseparator.0"/>
+ <children xsi:type="menu:Menu" xmi:id="_9DJHILnQEeWXX4KE4W3FyQ" elementId="org.eclipse.e4.tools.spy.menu.e4spies" label="Spies" tooltip="">
+ <children xsi:type="menu:DynamicMenuContribution" xmi:id="_iCu00LnQEeWXX4KE4W3FyQ" elementId="org.eclipse.e4.tools.spy.dynamicmenucontribution.0" label="E4 Spies" contributionURI="bundleclass://org.eclipse.e4.tools.spy/org.eclipse.e4.tools.spy.SpyProcessor"/>
+ </children>
+ </elements>
+ </fragments>
+</fragment:ModelFragments>
diff --git a/bundles/org.eclipse.e4.tools.spy/plugin.xml b/bundles/org.eclipse.e4.tools.spy/plugin.xml
index fe57ab28..57dab0cf 100644
--- a/bundles/org.eclipse.e4.tools.spy/plugin.xml
+++ b/bundles/org.eclipse.e4.tools.spy/plugin.xml
@@ -8,6 +8,10 @@
beforefragment="false"
class="org.eclipse.e4.tools.spy.SpyProcessor">
</processor>
+ <fragment
+ apply="initial"
+ uri="fragment.e4xmi">
+ </fragment>
</extension>
diff --git a/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyProcessor.java b/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyProcessor.java
index 8f3d5ec7..34da03ac 100644
--- a/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyProcessor.java
+++ b/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyProcessor.java
@@ -8,6 +8,7 @@
* Contributors:
* Olivier Prouvost <olivier.prouvost@opcoach.com> - initial API and implementation
* Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 428903 - Having a common 'debug' window for all spies
+ * Olivier Prouvost <olivier.prouvost@opcoach.com> - Bug 482250 - Add a menu 'E4 Spies' to access to the spies
*******************************************************************************/
package org.eclipse.e4.tools.spy;
@@ -21,6 +22,7 @@ import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.log.Logger;
+import org.eclipse.e4.ui.di.AboutToShow;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MBindingContext;
import org.eclipse.e4.ui.model.application.commands.MBindingTable;
@@ -30,6 +32,8 @@ import org.eclipse.e4.ui.model.application.commands.MHandler;
import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
@@ -77,7 +81,7 @@ public class SpyProcessor {
bindSpyKeyBinding(shortCut, command, partID);
// Add the descriptor in application
- addSpyPartDescriptor(partID, partName, iconPath, partClass);
+ addSpyPartDescriptor(partID, partName, iconPath, partClass, desc);
} catch (InvalidRegistryObjectException e1) {
e1.printStackTrace();
@@ -86,8 +90,6 @@ public class SpyProcessor {
e1.printStackTrace();
}
- // Can create the command in model
-
}
}
@@ -231,7 +233,8 @@ public class SpyProcessor {
}
- public void addSpyPartDescriptor(String partId, String partLabel, String iconPath, Class<?> spyPartClass) {
+ public void addSpyPartDescriptor(String partId, String partLabel, String iconPath, Class<?> spyPartClass,
+ String desc) {
for (MPartDescriptor mp : application.getDescriptors()) {
if (partId.equals(mp.getElementId())) {
// Already added, do nothing
@@ -243,6 +246,7 @@ public class SpyProcessor {
MPartDescriptor descriptor = modelService.createModelElement(MPartDescriptor.class);
descriptor.setCategory("Eclipse runtime spies");
descriptor.setElementId(partId);
+ descriptor.setDescription(desc);
descriptor.getTags().add("View");
descriptor.getTags().add(SPY_TAG);
descriptor.getTags().add("categoryTag:Eclipse runtime spies");
@@ -255,6 +259,29 @@ public class SpyProcessor {
descriptor.setContributorURI(contributorURI);
descriptor.setIconURI(contributorURI + "/" + iconPath);
application.getDescriptors().add(descriptor);
+ }
+
+
+ @AboutToShow
+ public void fillE4SpyMenu(List<MMenuElement> items) {
+
+ MCommand command = getOrCreateSpyCommand();
+ for (MPartDescriptor mp : application.getDescriptors()) {
+ if (mp.getTags().contains(SPY_TAG)) {
+ MHandledMenuItem hi = modelService.createModelElement(MHandledMenuItem.class);
+ hi.setCommand(command);
+ hi.setLabel(mp.getLabel());
+ hi.setContributorURI(mp.getContributorURI());
+ hi.setIconURI(mp.getIconURI());
+ hi.setTooltip(mp.getDescription());
+
+ MParameter p = modelService.createModelElement(MParameter.class);
+ p.setName(SPY_COMMAND_PARAM);
+ p.setValue(mp.getElementId());
+ hi.getParameters().add(p);
+ items.add(hi);
+ }
+ }
}
}

Back to the top