diff options
| author | Olivier Prouvost | 2014-03-03 14:52:30 +0000 |
|---|---|---|
| committer | Wim Jongman | 2014-05-27 19:55:56 +0000 |
| commit | 063d4a133182bee3fb1fb7a8086f13d2b32dd1c9 (patch) | |
| tree | 969ea8f28be97ca7b7fad9af81bb7291f2ec6f4a | |
| parent | 3cb4e381064f5ae94584e24d5e0f016556d4dd07 (diff) | |
| download | org.eclipse.e4.tools-063d4a133182bee3fb1fb7a8086f13d2b32dd1c9.tar.gz org.eclipse.e4.tools-063d4a133182bee3fb1fb7a8086f13d2b32dd1c9.tar.xz org.eclipse.e4.tools-063d4a133182bee3fb1fb7a8086f13d2b32dd1c9.zip | |
Bug 428903 - Having a common 'debug' window for all spies I20140527-2200
Define a new plugin org.eclipse.e4.tools.spy, used as common for all
spies. It contains the spyPart extension point, SpyProcessor (reads the
extensions), and SpyHandler (open the E4 spies window).
Define the context spy and live model editor using this plugin and its
extension point.
Fix versions in plugin.xml of org.eclipse.e4.tools.spy and others
Fix 5 :
- add comments in the spyPart extension point schema
- manage the event spy using spyPart extension
- Remove unused code to declare commands (processor in model editor,
installer in event spy)
- Now live model editor, event spy and context spy are updated.
Change-Id: I1b50e43bbbb0fbb4c296747fbef97fac3c97d59a
Signed-off-by: Olivier Prouvost <olivier.prouvost@opcoach.com>
30 files changed, 1149 insertions, 651 deletions
diff --git a/bundles/org.eclipse.e4.tools.context.spy/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.context.spy/META-INF/MANIFEST.MF index 3c8fad6c..f41d2784 100644 --- a/bundles/org.eclipse.e4.tools.context.spy/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.tools.context.spy/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.e4.ui.services;bundle-version="1.0.0", org.eclipse.e4.core.di;bundle-version="1.3.0", org.eclipse.e4.core.services;bundle-version="1.1.0", - org.eclipse.e4.ui.workbench.swt + org.eclipse.e4.ui.workbench.swt, + org.eclipse.e4.tools.spy;bundle-version="0.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: javax.annotation;version="1.1.0" diff --git a/bundles/org.eclipse.e4.tools.context.spy/plugin.xml b/bundles/org.eclipse.e4.tools.context.spy/plugin.xml index fc720442..e1cffaff 100644 --- a/bundles/org.eclipse.e4.tools.context.spy/plugin.xml +++ b/bundles/org.eclipse.e4.tools.context.spy/plugin.xml @@ -1,13 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <plugin> - <extension - id="id1" - point="org.eclipse.e4.workbench.model"> - <processor - beforefragment="false" - class="org.eclipse.e4.tools.context.spy.ContextSpyProcessor"> - </processor> + <extension point="org.eclipse.e4.tools.spy.spyPart"> + <spyPart + description="Context Spy to understand what is behind the scene of injection" + icon="icons/annotation_obj.gif" + name="Context spy" + part="org.eclipse.e4.tools.context.spy.ContextSpyPart" + shortcut="M2+M3+F10"> + </spyPart> </extension> - - </plugin> diff --git a/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java b/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java deleted file mode 100644 index 8e4798f4..00000000 --- a/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * 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: - * Olivier Prouvost <olivier.prouvost@opcoach.com> - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.tools.context.spy; - -import java.util.List; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; - -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; -import org.eclipse.e4.ui.model.application.commands.MCommand; -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.descriptor.basic.MPartDescriptor; -import org.eclipse.e4.ui.workbench.modeling.EModelService; - -public class ContextSpyProcessor -{ - private static final String ORG_ECLIPSE_UI_CONTEXTS_DIALOG_AND_WINDOW = "org.eclipse.ui.contexts.dialogAndWindow"; - private static final String CONTEXT_SPY_SHORTCUT = "M2+M3+F10"; - private static final String E4_SPIES_BINDING_TABLE = "e4.tooling.spies.bindings"; - private static final String CONTEXT_SPY_HANDLER = "e4.tooling.context.spy.handler"; - private static final String CONTEXT_SPY_COMMAND = "e4.tooling.context.spy.command"; - private static final String CONTEXT_SPY_CONTRIBUTOR_URI = "platform:/plugin/org.eclipse.e4.tools.context.spy"; - - @Inject - MApplication application; - @Inject - EModelService modelService; - - @PostConstruct - public void process() - { - // This processor must : - // 1. Add the e4.tooling.context.spy Command, if not present - // 2. Add the e4.tooling.context.spy.handler Handler, if not present - // 3. Deal with binding context - // 4. Add the org.eclipse.e4.tools.context.spy.view part descriptor, if - // not present - // Warning : do not use findElement on modelService, it returns only - // MUIElements - - // .............................. - // 1. Add the command - // .............................. - MCommand command = null; - for (MCommand cmd : application.getCommands()) - { - if (CONTEXT_SPY_COMMAND.equals(cmd.getElementId())) - { - command = cmd; - break; - } - } - - if (command == null) - { - command = modelService.createModelElement(MCommand.class); - command.setElementId(CONTEXT_SPY_COMMAND); - command.setCommandName("Show E4 Context Spy"); - command.setContributorURI(CONTEXT_SPY_CONTRIBUTOR_URI); - command.setDescription("Show the Eclipse 4 contexts and their contents"); - application.getCommands().add(command); - } - - // .............................. - // 2. Add the handler - // .............................. - MHandler handler = null; - for (MHandler hdl : application.getHandlers()) - { - if (CONTEXT_SPY_HANDLER.equals(hdl.getElementId())) - { - handler = hdl; - break; - } - } - - if (handler == null) - { - handler = modelService.createModelElement(MHandler.class); - handler.setElementId(CONTEXT_SPY_HANDLER); - handler.setContributionURI("bundleclass://org.eclipse.e4.tools.context.spy/org.eclipse.e4.tools.context.spy.ContextSpyHandler"); - handler.setContributorURI(CONTEXT_SPY_CONTRIBUTOR_URI); - application.getHandlers().add(handler); - } - - handler.setCommand(command); - - // .............................. - // 3. Deal with key bindings - // .............................. - bindSpyKeyBinding(CONTEXT_SPY_SHORTCUT, command); - - // .............................. - // 4. Add part descriptor - // .............................. - MPartDescriptor descriptor = null; - for (MPartDescriptor mp : application.getDescriptors()) - { - if (ContextSpyPart.CONTEXT_SPY_VIEW_DESC.equals(mp.getElementId())) - { - descriptor = mp; - break; - } - } - - // If descriptor not yet in descriptor list, add it now - if (descriptor == null) - { - descriptor = modelService.createModelElement(MPartDescriptor.class); - descriptor.setCategory("org.eclipse.e4.secondaryDataStack"); - descriptor.setElementId(ContextSpyPart.CONTEXT_SPY_VIEW_DESC); - descriptor.getTags().add("View"); - descriptor.getTags().add("categoryTag:General"); - - descriptor.setLabel("Context Spy"); - descriptor - .setContributionURI("bundleclass://org.eclipse.e4.tools.context.spy/org.eclipse.e4.tools.context.spy.ContextSpyPart"); - descriptor.setContributorURI(CONTEXT_SPY_CONTRIBUTOR_URI); - descriptor.setIconURI(CONTEXT_SPY_CONTRIBUTOR_URI + "/icons/annotation_obj.gif"); - application.getDescriptors().add(descriptor); - } - - } - - /** - * Helper method to get or create the binding table for all spies (where - * spies will add their key binding). Bind this table with the - * org.eclipse.ui.contexts.dialogAndWindow binding context which should be - * present (create it if not) - * - * This method will probably move to the common spy plugin providing common - * spy stuff (see bug #428903) - * - * @param application - * @return - */ - public void bindSpyKeyBinding(String keySequence, MCommand cmd) - { - // This method must : - // search for a binding table having the binding context 'dialog and - // window' - // If none found, create it and also the binding context - // Then can add the KeyBinding if not already added - - MBindingTable spyBindingTable = null; - for (MBindingTable bt : application.getBindingTables()) - if (ORG_ECLIPSE_UI_CONTEXTS_DIALOG_AND_WINDOW.equals(bt.getBindingContext().getElementId())) - { - spyBindingTable = bt; - } - - // Binding table has not been yet added... Create it and bind it to - // org.eclipse.ui.contexts.dialogAndWindow binding context - // If this context does not yet exist, create it also. - if (spyBindingTable == null) - { - - MBindingContext bc = null; - final List<MBindingContext> bindingContexts = application - .getBindingContexts(); - if (bindingContexts.size() == 0) { - bc = modelService.createModelElement(MBindingContext.class); - bc.setElementId("org.eclipse.ui.contexts.window"); - } else { - // Prefer org.eclipse.ui.contexts.dialogAndWindow but randomly - // select another one - // if org.eclipse.ui.contexts.dialogAndWindow cannot be found - for (MBindingContext aBindingContext : bindingContexts) { - bc = aBindingContext; - if ("org.eclipse.ui.contexts.dialogAndWindow" - .equals(aBindingContext.getElementId())) { - break; - } - } - } - - - - // Can now create the binding table and bind it to this context... - spyBindingTable = modelService.createModelElement(MBindingTable.class); - spyBindingTable.setElementId(E4_SPIES_BINDING_TABLE); - spyBindingTable.setBindingContext(bc); - application.getBindingTables().add(spyBindingTable); - } - - // Search for the key binding if already present - for (MKeyBinding kb : spyBindingTable.getBindings()) - if (keySequence.equals(kb.getKeySequence())) - { - // A binding with this key sequence is already present. Check if - // command is the same - if (kb.getCommand().getElementId().equals(cmd.getElementId())) - return; - else - { - // Must log an error : key binding already exists in this - // table but with another command - System.out.println("WARNING : Cannot bind the command '" + cmd.getElementId() + "' to the keySequence : " - + keySequence + " because the command " + kb.getCommand().getElementId() + " is already bound !"); - return; - } - } - - // Key binding is not yet in table... can add it now. - MKeyBinding binding = modelService.createModelElement(MKeyBinding.class); - binding.setElementId(cmd.getElementId() + ".binding"); - binding.setContributorURI(cmd.getContributorURI()); - binding.setKeySequence(keySequence); - spyBindingTable.getBindings().add(binding); - binding.setCommand(cmd); - - } - -} diff --git a/bundles/org.eclipse.e4.tools.emf.liveeditor/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.emf.liveeditor/META-INF/MANIFEST.MF index f1f8a149..850f7070 100644 --- a/bundles/org.eclipse.e4.tools.emf.liveeditor/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.tools.emf.liveeditor/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.e4.ui.services;bundle-version="0.9.1", org.eclipse.e4.core.di;bundle-version="0.9.0", org.eclipse.jface;bundle-version="3.6.0", org.eclipse.equinox.registry;bundle-version="3.5.0", - org.eclipse.e4.ui.di;bundle-version="0.9.0" + org.eclipse.e4.ui.di;bundle-version="0.9.0", + org.eclipse.e4.tools.spy;bundle-version="0.1.0" Bundle-Vendor: %Bundle-Vendor Service-Component: OSGI-INF/extensionlookup.xml Bundle-ActivationPolicy: lazy diff --git a/bundles/org.eclipse.e4.tools.emf.liveeditor/plugin.xml b/bundles/org.eclipse.e4.tools.emf.liveeditor/plugin.xml index 32784e53..da661ebd 100644 --- a/bundles/org.eclipse.e4.tools.emf.liveeditor/plugin.xml +++ b/bundles/org.eclipse.e4.tools.emf.liveeditor/plugin.xml @@ -2,12 +2,14 @@ <?eclipse version="3.4"?> <plugin> <extension - id="id1" - point="org.eclipse.e4.workbench.model"> - <processor - beforefragment="false" - class="org.eclipse.e4.tools.emf.liveeditor.ModelProcessor"> - </processor> + point="org.eclipse.e4.tools.spy.spyPart"> + <spyPart + description="Open the live model editor" + icon="icons/full/obj16/application_lightning.png" + name="Live Model Editor" + part="org.eclipse.e4.tools.emf.liveeditor.LivePartDelegator" + shortcut="M2+M3+F9"> + </spyPart> </extension> </plugin> diff --git a/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java b/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java deleted file mode 100644 index 3802f8d2..00000000 --- a/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 - 2013 BestSolution.at and others. - * 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: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * Lars Vogel <lars.vogel@gmail.com> - Bug 419723, 422644, 428728 - * Markus A. Kuppe <bugs.eclipse.org@lemmster.de> - Bug 421259 - ******************************************************************************/ -package org.eclipse.e4.tools.emf.liveeditor; - -import java.util.List; - -import org.eclipse.e4.core.di.annotations.Execute; -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; -import org.eclipse.e4.ui.model.application.commands.MCommand; -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.descriptor.basic.MPartDescriptor; -import org.eclipse.e4.ui.workbench.modeling.EModelService; - -public class ModelProcessor { - - private static final String E4_TOOLING_LIVEMODEL_HANDLER = "e4.tooling.livemodel.handler"; - private static final String E4_TOOLING_LIVEMODEL = "e4.tooling.livemodel"; - - @Execute - public void process(MApplication application, EModelService modelService) { - - MCommand command = null; - for (MCommand cmd : application.getCommands()) { - if (E4_TOOLING_LIVEMODEL.equals(cmd.getElementId())) { - command = cmd; - } - } - // List<MCommand> commands = modelService.findElements(application, - // E4_TOOLING_LIVEMODEL, MCommand.class, null); - - if (command == null) { - command = modelService.createModelElement(MCommand.class); - command.setElementId(E4_TOOLING_LIVEMODEL); - command.setCommandName("Show Live Application Model"); - command.setDescription("Show the running application model"); - application.getCommands().add(command); - } - - MHandler handler = null; - - for (MHandler hdl : application.getHandlers()) { - if (E4_TOOLING_LIVEMODEL_HANDLER.equals(hdl.getElementId())) { - handler = hdl; - } - } - - if (handler == null) { - handler = modelService.createModelElement(MHandler.class); - handler.setElementId(E4_TOOLING_LIVEMODEL_HANDLER); - handler.setContributionURI("bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.OpenLiveDialogHandler"); - application.getHandlers().add(handler); - } - - handler.setCommand(command); - - MKeyBinding binding = null; - - if (application.getBindingTables().size() <= 0) { - MBindingContext bc = null; - final List<MBindingContext> bindingContexts = application - .getBindingContexts(); - if (bindingContexts.size() == 0) { - bc = modelService.createModelElement(MBindingContext.class); - bc.setElementId("org.eclipse.ui.contexts.window"); - } else { - // Prefer org.eclipse.ui.contexts.dialogAndWindow but randomly - // select another one - // if org.eclipse.ui.contexts.dialogAndWindow cannot be found - for (MBindingContext aBindingContext : bindingContexts) { - bc = aBindingContext; - if ("org.eclipse.ui.contexts.dialogAndWindow" - .equals(aBindingContext.getElementId())) { - break; - } - } - } - MBindingTable bt = modelService - .createModelElement(MBindingTable.class); - bt.setElementId("e4.tooling.livemodel.bindingTable"); - bt.setBindingContext(bc); - application.getBindingTables().add(bt); - } - List<MKeyBinding> keyBindings = modelService.findElements(application, - "e4.tooling.livemodel.binding", MKeyBinding.class, null); - - if (keyBindings.size() == 0) { - binding = modelService.createModelElement(MKeyBinding.class); - binding.setElementId("e4.tooling.livemodel.binding"); - binding.setKeySequence("M2+M3+F9"); - if (application.getBindingTables().size() > 0) { - application.getBindingTables().get(0).getBindings() - .add(binding); - } - } else { - binding = keyBindings.get(0); - } - binding.setCommand(command); - - MPartDescriptor descriptor = null; - List<MPartDescriptor> descriptors = modelService.findElements( - application, "org.eclipse.e4.tools.emf.liveeditor.view", - MPartDescriptor.class, null); - - if (descriptors.size() == 0) { - descriptor = modelService.createModelElement(MPartDescriptor.class); - descriptor.setCategory("org.eclipse.e4.secondaryDataStack"); - descriptor.setElementId("org.eclipse.e4.tools.emf.liveeditor.view"); - descriptor.getTags().add("View"); - descriptor.getTags().add("categoryTag:General"); - - descriptor.setLabel("Live Application Model"); - descriptor - .setContributionURI("bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.LivePartDelegator"); - descriptor - .setIconURI("platform:/plugin/org.eclipse.e4.tools.emf.liveeditor/icons/full/obj16/application_lightning.png"); - application.getDescriptors().add(descriptor); - } - } - -} diff --git a/bundles/org.eclipse.e4.tools.event.spy/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.event.spy/META-INF/MANIFEST.MF index 1e68fae3..8f845a0e 100644 --- a/bundles/org.eclipse.e4.tools.event.spy/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.tools.event.spy/META-INF/MANIFEST.MF @@ -21,12 +21,13 @@ Require-Bundle: org.eclipse.ui, org.eclipse.jface.databinding, org.eclipse.core.databinding.observable, org.eclipse.core.databinding.beans, - org.eclipse.core.databinding.property + org.eclipse.core.databinding.property, + org.eclipse.e4.tools.spy, + org.eclipse.e4.ui.di Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: javax.annotation;version="1.1.0" Export-Package: org.eclipse.e4.tools.event.spy, - org.eclipse.e4.tools.event.spy.handlers, org.eclipse.e4.tools.event.spy.internal.core;x-internal:=true, org.eclipse.e4.tools.event.spy.internal.model;x-internal:=true, org.eclipse.e4.tools.event.spy.internal.ui;x-internal:=true, diff --git a/bundles/org.eclipse.e4.tools.event.spy/icons/eventspy.gif b/bundles/org.eclipse.e4.tools.event.spy/icons/eventspy.gif Binary files differnew file mode 100644 index 00000000..c984fba7 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.event.spy/icons/eventspy.gif diff --git a/bundles/org.eclipse.e4.tools.event.spy/plugin.xml b/bundles/org.eclipse.e4.tools.event.spy/plugin.xml index e9395f19..e5ba6731 100644 --- a/bundles/org.eclipse.e4.tools.event.spy/plugin.xml +++ b/bundles/org.eclipse.e4.tools.event.spy/plugin.xml @@ -2,13 +2,14 @@ <?eclipse version="3.4"?> <plugin> <extension - id="org.eclipse.e4.tools.event.spy" - name="E4 Event spy" - point="org.eclipse.e4.workbench.model"> - <processor - beforefragment="false" - class="org.eclipse.e4.tools.event.spy.Installer"> - </processor> + point="org.eclipse.e4.tools.spy.spyPart"> + <spyPart + description="Open the Event Spy" + icon="icons/eventspy.gif" + name="Event Spy" + part="org.eclipse.e4.tools.event.spy.internal.ui.SpyDialog" + shortcut="M2+M3+F8"> + </spyPart> </extension> </plugin> diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/BindingDescriptor.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/BindingDescriptor.java deleted file mode 100644 index a24513c1..00000000 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/BindingDescriptor.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.tools.event.spy; - -public enum BindingDescriptor { - OpenSpyDialogInDialogAndWindow("M2+M3+F8", "org.eclipse.ui.contexts.dialogAndWindow"); - - private String bindingContextId; - - private String keySequence; - - private BindingDescriptor(String keySequence, String bindingContextId) { - this.keySequence = keySequence; - this.bindingContextId = bindingContextId; - } - - public String getBindingContextId() { - return bindingContextId; - } - - public String getKeySequence() { - return keySequence; - } -} diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/CommandDescriptor.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/CommandDescriptor.java deleted file mode 100644 index 866ddf47..00000000 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/CommandDescriptor.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.tools.event.spy; - -public enum CommandDescriptor { - OpenSpyDialog("org.eclipse.e4.tools.event.spy.openSpyDialog.cmd", "Open event spy dialog"); - - private String id; - - private String name; - - private CommandDescriptor(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } -} diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Constants.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Constants.java index ca03c44b..f00b6de2 100644 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Constants.java +++ b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Constants.java @@ -17,7 +17,5 @@ import org.eclipse.e4.ui.bindings.EBindingService; public class Constants { public static final String PLUGIN_ID = PluginUtils.getBundleId(Constants.class); - public static final String BINDING_MODIFIED_BY_USER_TAG = EBindingService.TYPE_ATTR_TAG + ":user"; - public static final String BINDING_DELETED_BY_USER_TAG = EBindingService.DELETED_BINDING_TAG; } diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Installer.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Installer.java deleted file mode 100644 index a2e23a2b..00000000 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/Installer.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.tools.event.spy; - - -import javax.inject.Inject; - -import org.eclipse.e4.core.di.annotations.Execute; -import org.eclipse.e4.tools.event.spy.handlers.OpenSpyDialogHandler; -import org.eclipse.e4.tools.event.spy.internal.util.LoggerWrapper; -import org.eclipse.e4.tools.event.spy.internal.util.PluginUtils; -import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.commands.MBindingTable; -import org.eclipse.e4.ui.model.application.commands.MCommand; -import org.eclipse.e4.ui.model.application.commands.MCommandsFactory; -import org.eclipse.e4.ui.model.application.commands.MHandler; -import org.eclipse.e4.ui.model.application.commands.MKeyBinding; - -@SuppressWarnings("restriction") -public class Installer { - @Inject - private MApplication application; - - @Inject - private LoggerWrapper logger; - - @Execute - public void execute() { - logger.info("installing ..."); - - registerCommand(CommandDescriptor.OpenSpyDialog, BindingDescriptor.OpenSpyDialogInDialogAndWindow, OpenSpyDialogHandler.class); - - logger.info("installed"); - } - - private void registerCommand(CommandDescriptor commandDesc, BindingDescriptor bindingDesc, Class<?> handlerCls) { - MCommand command = getCommand(application, commandDesc); - if (command == null) { - command = createCommand(commandDesc); - application.getCommands().add(command); - } - - Object binding = getBindingOrBindingTable(application, command, bindingDesc); - if (binding == null) { - logger.warn("binding context ''{0}'' for command ''{1}'' not found", - bindingDesc.getBindingContextId(), commandDesc.getName()); - return; - } - - if (binding instanceof MKeyBinding) { - MKeyBinding keyBinding = (MKeyBinding) binding; - if (keyBinding.getTags().contains(Constants.BINDING_MODIFIED_BY_USER_TAG)) { - logger.info("key binding for command ''{0}'' changed to {1}", commandDesc.getName(), keyBinding.getKeySequence()); - - } else if (keyBinding.getTags().contains(Constants.BINDING_DELETED_BY_USER_TAG)) { - logger.info("key binding for command ''{0}'' has been deleted. The command is disabled", commandDesc.getName()); - } - return; //command already processed - } - - ((MBindingTable) binding).getBindings().add(createKeyBinding(command, bindingDesc)); - logger.info("key binding for command ''{0}'' is {1}", commandDesc.getName(), bindingDesc.getKeySequence()); - - MHandler handler = getHandler(application, commandDesc); - if (handler == null) { - handler = createHandler(command, handlerCls); - application.getHandlers().add(handler); - } - } - - private MCommand getCommand(MApplication application, CommandDescriptor descriptor) { - for (MCommand command: application.getCommands()) { - if (descriptor.getId().equals(command.getElementId())) { - return command; - } - } - return null; - } - - private MCommand createCommand(CommandDescriptor descriptor) { - MCommand command = MCommandsFactory.INSTANCE.createCommand(); - command.setElementId(descriptor.getId()); - command.setCommandName(descriptor.getName()); - command.setContributorURI(PluginUtils.getContributorURI()); - return command; - } - - private MHandler getHandler(MApplication application, CommandDescriptor descriptor) { - for (MHandler handler: application.getHandlers()) { - if (descriptor.getId().equals(handler.getElementId())) { - return handler; - } - } - return null; - } - - private MHandler createHandler(MCommand command, Class<?> handlerCls) { - MHandler handler = MCommandsFactory.INSTANCE.createHandler(); - handler.setElementId(command.getElementId()); - handler.setCommand(command); - handler.setContributionURI(PluginUtils.getContributionURI(handlerCls)); - handler.setContributorURI(PluginUtils.getContributorURI()); - return handler; - } - - private Object getBindingOrBindingTable(MApplication application, MCommand command, BindingDescriptor descriptor) { - MBindingTable result = null; - for (MBindingTable bindingTable: application.getBindingTables()) { - for (MKeyBinding keyBinding : bindingTable.getBindings()) { - if (keyBinding.getCommand() == command) { - return keyBinding; - } - } - if (descriptor.getBindingContextId().equals(bindingTable.getBindingContext().getElementId())) { - result = bindingTable; - } - } - return result; - } - - private MKeyBinding createKeyBinding(MCommand command, BindingDescriptor descriptor) { - MKeyBinding keyBinding = MCommandsFactory.INSTANCE.createKeyBinding(); - keyBinding.setElementId(command.getElementId()); - keyBinding.setCommand(command); - keyBinding.setKeySequence(descriptor.getKeySequence()); - keyBinding.setContributorURI(PluginUtils.getContributorURI()); - return keyBinding; - } -} diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/handlers/OpenSpyDialogHandler.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/handlers/OpenSpyDialogHandler.java deleted file mode 100644 index 7070d2f1..00000000 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/handlers/OpenSpyDialogHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.e4.tools.event.spy.handlers; - -import org.eclipse.e4.core.contexts.ContextInjectionFactory; -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.di.annotations.Execute; -import org.eclipse.e4.tools.event.spy.internal.ui.SpyDialog; - -public class OpenSpyDialogHandler { - @Execute - public void execute(IEclipseContext context) { - ContextInjectionFactory.make(SpyDialog.class, context).open(); - } -} diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/CapturedEventFilters.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/CapturedEventFilters.java index 936378c2..922d5411 100644 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/CapturedEventFilters.java +++ b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/CapturedEventFilters.java @@ -65,6 +65,9 @@ public class CapturedEventFilters { private Text baseTopicText; + // For bug 428903 : cache the text value for predestroy to avoid widget disposed exception. + private String baseTopicTextValue = BASE_EVENT_TOPIC; + private List filters; private java.util.List<CapturedEventFilter> rawFilters; @@ -135,10 +138,12 @@ public class CapturedEventFilters { baseTopicText.setLayoutData(new RowData(312, SWT.DEFAULT)); baseTopicText.setText(BASE_EVENT_TOPIC); baseTopicText.addFocusListener(new FocusAdapter() { + public void focusLost(FocusEvent e) { if (baseTopicText.getText().trim().length() == 0) { baseTopicText.setText(BASE_EVENT_TOPIC); } + baseTopicTextValue = baseTopicText.getText(); } }); @@ -281,7 +286,7 @@ public class CapturedEventFilters { } public String getBaseTopic() { - return baseTopicText.getText(); + return baseTopicTextValue; } public boolean hasFilters() { diff --git a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/SpyDialog.java b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/SpyDialog.java index 78f25e6d..6b9c9188 100644 --- a/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/SpyDialog.java +++ b/bundles/org.eclipse.e4.tools.event.spy/src/org/eclipse/e4/tools/event/spy/internal/ui/SpyDialog.java @@ -7,14 +7,19 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Olivier Prouvost <olivier.prouvost@opcoach.com> + * - Fix bug 428903 : transform this dialog into a part to be definied with spyPart extension *******************************************************************************/ package org.eclipse.e4.tools.event.spy.internal.ui; import java.util.Collection; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import javax.inject.Inject; import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.tools.event.spy.internal.core.EventMonitor; import org.eclipse.e4.tools.event.spy.internal.model.CapturedEvent; @@ -22,17 +27,14 @@ import org.eclipse.e4.tools.event.spy.internal.model.CapturedEventFilter; import org.eclipse.e4.tools.event.spy.internal.util.JDTUtils; import org.eclipse.e4.tools.event.spy.internal.util.LoggerWrapper; import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowData; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -public class SpyDialog extends Dialog implements EventMonitor.NewEventListener { +public class SpyDialog /*extends Dialog */ implements EventMonitor.NewEventListener { private final static String DIALOG_TITLE = "Event spy dialog"; private final static String[] SHOW_FILTER_LINK_TEXT = new String[]{"Show filters", "Hide filters"}; @@ -56,11 +58,6 @@ public class SpyDialog extends Dialog implements EventMonitor.NewEventListener { @Inject private MApplication appplication; - @Inject - public SpyDialog(Shell shell) { - super(shell); - setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE); - } /* Layout scheme: * @@ -86,29 +83,24 @@ public class SpyDialog extends Dialog implements EventMonitor.NewEventListener { * * */ - @Override - protected Point getInitialSize() { - return new Point(608, 450); - } - @Override - protected Control createDialogArea(Composite parent) { - outer = (Composite) super.createDialogArea(parent); - SpyDialogMemento memento = (SpyDialogMemento) appplication - .getContext().get(SpyDialogMemento.class.getName()); - + @PostConstruct + protected void createDialogArea(Composite parent, @Optional SpyDialogMemento memento) { + + // Bug 428903 : create now a part, and inject directly optional memento (set in saveDialogMemento). + + outer = parent; + + outer.setLayout(new GridLayout()); + outer.setLayoutData(new GridData(GridData.FILL_BOTH)); + createActionBar(outer); createFilters(outer, memento); createCapturedEventTree(outer); - return outer; - } - - @Override - public boolean close() { - saveDialogMemento(); - return super.close(); } + + @PreDestroy private void saveDialogMemento() { SpyDialogMemento memento = null; String baseTopic = capturedEventFilters.getBaseTopic(); @@ -189,16 +181,6 @@ public class SpyDialog extends Dialog implements EventMonitor.NewEventListener { }); } - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(DIALOG_TITLE); - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - //do nothing - } public void captureEvents() { capturedEventTree.removeAll(); @@ -207,14 +189,14 @@ public class SpyDialog extends Dialog implements EventMonitor.NewEventListener { eventMonitor.setNewEventListener(this); } eventMonitor.start(capturedEventFilters.getBaseTopic(), capturedEventFilters.getFilters()); - getShell().setText(DIALOG_TITLE + " - capturing..."); + // getShell().setText(DIALOG_TITLE + " - capturing..."); } public void stopCaptureEvents() { if (eventMonitor != null) { eventMonitor.stop(); } - getShell().setText(DIALOG_TITLE); + // getShell().setText(DIALOG_TITLE); } public void newEvent(CapturedEvent event) { diff --git a/bundles/org.eclipse.e4.tools.spy/.classpath b/bundles/org.eclipse.e4.tools.spy/.classpath new file mode 100644 index 00000000..ad32c83a --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/bundles/org.eclipse.e4.tools.spy/.project b/bundles/org.eclipse.e4.tools.spy/.project new file mode 100644 index 00000000..3787da9b --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.e4.tools.spy</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/bundles/org.eclipse.e4.tools.spy/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.e4.tools.spy/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..c537b630 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/.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/bundles/org.eclipse.e4.tools.spy/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.e4.tools.spy/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000..f29e940a --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/bundles/org.eclipse.e4.tools.spy/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.spy/META-INF/MANIFEST.MF new file mode 100644 index 00000000..b6216a56 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Common for Spies +Bundle-SymbolicName: org.eclipse.e4.tools.spy;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: javax.inject;bundle-version="1.0.0", + org.eclipse.e4.ui.model.workbench, + org.eclipse.core.runtime;bundle-version="3.9.0", + org.eclipse.e4.core.di, + org.eclipse.e4.core.services, + org.eclipse.e4.ui.workbench, + org.eclipse.e4.ui.services, + org.eclipse.e4.core.contexts, + org.eclipse.e4.ui.di, + org.eclipse.equinox.event +Import-Package: javax.annotation;version="1.1.0" diff --git a/bundles/org.eclipse.e4.tools.spy/build.properties b/bundles/org.eclipse.e4.tools.spy/build.properties new file mode 100644 index 00000000..34d2e4d2 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/bundles/org.eclipse.e4.tools.spy/epl-v10.html b/bundles/org.eclipse.e4.tools.spy/epl-v10.html new file mode 100644 index 00000000..fd391227 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/epl-v10.html @@ -0,0 +1,261 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Public License - Version 1.0</title> +<style type="text/css"> + body { + size: 8.5in 11.0in; + margin: 0.25in 0.5in 0.25in 0.5in; + tab-interval: 0.5in; + } + p { + margin-left: auto; + margin-top: 0.5em; + margin-bottom: 0.5em; + } + p.list { + margin-left: 0.5in; + margin-top: 0.05em; + margin-bottom: 0.05em; + } + </style> + +</head> + +<body lang="EN-US"> + +<h2>Eclipse Public License - v 1.0</h2> + +<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR +DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS +AGREEMENT.</p> + +<p><b>1. DEFINITIONS</b></p> + +<p>"Contribution" means:</p> + +<p class="list">a) in the case of the initial Contributor, the initial +code and documentation distributed under this Agreement, and</p> +<p class="list">b) in the case of each subsequent Contributor:</p> +<p class="list">i) changes to the Program, and</p> +<p class="list">ii) additions to the Program;</p> +<p class="list">where such changes and/or additions to the Program +originate from and are distributed by that particular Contributor. A +Contribution 'originates' from a Contributor if it was added to the +Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) +are not derivative works of the Program.</p> + +<p>"Contributor" means any person or entity that distributes +the Program.</p> + +<p>"Licensed Patents" mean patent claims licensable by a +Contributor which are necessarily infringed by the use or sale of its +Contribution alone or when combined with the Program.</p> + +<p>"Program" means the Contributions distributed in accordance +with this Agreement.</p> + +<p>"Recipient" means anyone who receives the Program under +this Agreement, including all Contributors.</p> + +<p><b>2. GRANT OF RIGHTS</b></p> + +<p class="list">a) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works +of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in +source code and object code form.</p> + +<p class="list">b) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, +offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent +license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, +such addition of the Contribution causes such combination to be covered +by the Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder.</p> + +<p class="list">c) Recipient understands that although each Contributor +grants the licenses to its Contributions set forth herein, no assurances +are provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility to +secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow Recipient +to distribute the Program, it is Recipient's responsibility to acquire +that license before distributing the Program.</p> + +<p class="list">d) Each Contributor represents that to its knowledge it +has sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement.</p> + +<p><b>3. REQUIREMENTS</b></p> + +<p>A Contributor may choose to distribute the Program in object code +form under its own license agreement, provided that:</p> + +<p class="list">a) it complies with the terms and conditions of this +Agreement; and</p> + +<p class="list">b) its license agreement:</p> + +<p class="list">i) effectively disclaims on behalf of all Contributors +all warranties and conditions, express and implied, including warranties +or conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose;</p> + +<p class="list">ii) effectively excludes on behalf of all Contributors +all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits;</p> + +<p class="list">iii) states that any provisions which differ from this +Agreement are offered by that Contributor alone and not by any other +party; and</p> + +<p class="list">iv) states that source code for the Program is available +from such Contributor, and informs licensees how to obtain it in a +reasonable manner on or through a medium customarily used for software +exchange.</p> + +<p>When the Program is made available in source code form:</p> + +<p class="list">a) it must be made available under this Agreement; and</p> + +<p class="list">b) a copy of this Agreement must be included with each +copy of the Program.</p> + +<p>Contributors may not remove or alter any copyright notices contained +within the Program.</p> + +<p>Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution.</p> + +<p><b>4. COMMERCIAL DISTRIBUTION</b></p> + +<p>Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use of +the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor +includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and +indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the +acts or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In +order to qualify, an Indemnified Contributor must: a) promptly notify +the Commercial Contributor in writing of such claim, and b) allow the +Commercial Contributor to control, and cooperate with the Commercial +Contributor in, the defense and any related settlement negotiations. The +Indemnified Contributor may participate in any such claim at its own +expense.</p> + +<p>For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages.</p> + +<p><b>5. NO WARRANTY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, +ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable laws, +damage to or loss of data, programs or equipment, and unavailability or +interruption of operations.</p> + +<p><b>6. DISCLAIMER OF LIABILITY</b></p> + +<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT +NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p> + +<p><b>7. GENERAL</b></p> + +<p>If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable.</p> + +<p>If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the +date such litigation is filed.</p> + +<p>All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of time +after becoming aware of such noncompliance. If all Recipient's rights +under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.</p> + +<p>Everyone is permitted to copy and distribute copies of this +Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The +Agreement Steward reserves the right to publish new versions (including +revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse +Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a +suitable separate entity. Each new version of the Agreement will be +given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version +of the Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved.</p> + +<p>This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No party +to this Agreement will bring a legal action under this Agreement more +than one year after the cause of action arose. Each party waives its +rights to a jury trial in any resulting litigation.</p> + +</body> + +</html> diff --git a/bundles/org.eclipse.e4.tools.spy/notice.html b/bundles/org.eclipse.e4.tools.spy/notice.html new file mode 100644 index 00000000..f19c483b --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/notice.html @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>Eclipse Foundation Software User Agreement</title> +</head> + +<body lang="EN-US"> +<h2>Eclipse Foundation Software User Agreement</h2> +<p>February 1, 2011</p> + +<h3>Usage Of Content</h3> + +<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p> + +<h3>Applicable Licenses</h3> + +<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. + For purposes of the EPL, "Program" will mean the Content.</p> + +<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").</p> + +<ul> + <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").</li> + <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".</li> + <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.</li> + <li>Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.</li> +</ul> + +<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:</p> + +<ul> + <li>The top-level (root) directory</li> + <li>Plug-in and Fragment directories</li> + <li>Inside Plug-ins and Fragments packaged as JARs</li> + <li>Sub-directories of the directory named "src" of certain Plug-ins</li> + <li>Feature directories</li> +</ul> + +<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.</p> + +<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p> + +<ul> + <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li> + <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li> + <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li> + <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li> + <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li> + <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li> +</ul> + +<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p> + + +<h3>Use of Provisioning Technology</h3> + +<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a + href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a> + ("Specification").</p> + +<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p> + +<ol> + <li>A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.</li> + <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.</li> + <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li> +</ol> + +<h3>Cryptography</h3> + +<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.</p> + +<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p> +</body> +</html> diff --git a/bundles/org.eclipse.e4.tools.spy/plugin.xml b/bundles/org.eclipse.e4.tools.spy/plugin.xml new file mode 100644 index 00000000..fe57ab28 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/plugin.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin> + <extension-point id="spyPart" name="spyPart" schema="schema/spyPart.exsd"/> + <extension + id="id2" + point="org.eclipse.e4.workbench.model"> + <processor + beforefragment="false" + class="org.eclipse.e4.tools.spy.SpyProcessor"> + </processor> + </extension> + + + +</plugin> diff --git a/bundles/org.eclipse.e4.tools.spy/pom.xml b/bundles/org.eclipse.e4.tools.spy/pom.xml new file mode 100644 index 00000000..dbcb7c64 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/pom.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.e4.tools</groupId> + <artifactId>e4-tools-aggregator</artifactId> + <version>0.16.0-SNAPSHOT</version> + <relativePath>../../</relativePath> + </parent> + + <groupId>org.eclipse.e4</groupId> + <artifactId>org.eclipse.e4.tools.spy</artifactId> + <version>0.1.0.qualifier</version> + <packaging>eclipse-plugin</packaging> + +</project> diff --git a/bundles/org.eclipse.e4.tools.spy/schema/spyPart.exsd b/bundles/org.eclipse.e4.tools.spy/schema/spyPart.exsd new file mode 100644 index 00000000..e15b3d56 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/schema/spyPart.exsd @@ -0,0 +1,184 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.e4.tools.spy" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.e4.tools.spy" id="spyPart" name="spyPart"/> + </appinfo> + <documentation> + <p>A spy is a specific window used to help the debug of your application. </p> +<p>It can be opened with a key board short cut, and the first time, all the spies will appear in the same window (called 'E4 spies'). This window reminds to the developper all the available spies in a main toolbar.</p> +<br/>To add a spy, just describe the part, and the shortcut. +This extension point is then managed by this plugin to add automatically short cut, handlers, command and icon in the application model. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="spyPart" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="spyPart"> + <complexType> + <attribute name="name" type="string"> + <annotation> + <documentation> + The name of the spy (displayed in the tab) + </documentation> + </annotation> + </attribute> + <attribute name="part" type="string"> + <annotation> + <documentation> + The pojo class of the spy part. There is no contraints of ihneritance for this part. There must be a @PostConstruct method to create the contents : + +<br/> +<p> +@PostConstruct +public void mySpyContent(Composite parent) +{ + // Create your contents here. +} +</p> + </documentation> + <appinfo> + <meta.attribute kind="java"/> + </appinfo> + </annotation> + </attribute> + <attribute name="shortcut" type="string"> + <annotation> + <documentation> + <p>The keyboard short cut to apply (must be something like : M2+M3+F10 for ALT SHIFT F10) </p> + +<p> +This key sequence should consist of one or more key strokes. Key strokes are separated by spaces. Key strokes consist of one or more keys held down at the same time. This should be zero or more modifier keys, and one other key. The keys are separated by the <code>+</code> character. +</p> +<p> +The recognized modifiers keys are <code>M1</code>, <code>M2</code>, <code>M3</code>, <code>M4</code>, <code>ALT</code>, <code>COMMAND</code>, <code>CTRL</code>, and <code>SHIFT</code>. The "M" modifier keys are a platform-independent way of representing keys, and these are generally preferred. <code>M1</code> is the <code>COMMAND</code> key on MacOS X, and the <code>CTRL</code> key on most other platforms. <code>M2</code> is the <code>SHIFT</code> key. <code>M3</code> is the <code>Option</code> key on MacOS X, and the <code>ALT</code> key on most other platforms. <code>M4</code> is the <code>CTRL</code> key on MacOS X, and is undefined on other platforms. +Since <code>M2+M3+&lt;Letter&gt;</code> (<code>Alt+Shift+&lt;Letter&gt;</code>) is reserved on MacOS X for writing special characters, such bindings are commonly undefined for <code>platform="carbon"</code> and redefined as <code>M1+M3+&lt;Letter&gt;</code>. +</p> +<p> +The actual key is generally specified simply as the ASCII character, in uppercase. So, for example <code>F</code> or <code>,</code> are examples of such keys. However, there are some special keys; keys that have no printable ASCII representation. The following is a list of the current special keys: <code>ARROW_DOWN</code>, <code>ARROW_LEFT</code>, <code>ARROW_RIGHT</code>, <code>ARROW_UP</code>, <code>BREAK</code>, <code>BS</code>, <code>CAPS_LOCK</code>, <code>CR</code>, <code>DEL</code>, <code>END</code>, <code>ESC</code>, <code>F1</code>, <code>F2</code>, <code>F3</code>, <code>F4</code>, <code>F5</code>, <code>F6</code>, <code>F7</code>, <code>F8</code>, <code>F9</code>, <code>F10</code>, <code>F11</code>, <code>F12</code>, <code>F13</code>, <code>F14</code>, <code>F15</code>, <code>FF</code>, <code>HOME</code>, <code>INSERT</code>, <code>LF</code>, <code>NUL</code>, <code>NUM_LOCK</code>, <code>NUMPAD_0</code>, <code>NUMPAD_1</code>, <code>NUMPAD_2</code>, <code>NUMPAD_3</code>, <code>NUMPAD_4</code>, <code>NUMPAD_5</code>, <code>NUMPAD_6</code>, <code>NUMPAD_7</code>, <code>NUMPAD_8</code>, <code>NUMPAD_9</code>, <code>NUMPAD_ADD</code>, <code>NUMPAD_DECIMAL</code>, <code>NUMPAD_DIVIDE</code>, <code>NUMPAD_ENTER</code>, <code>NUMPAD_EQUAL</code>, <code>NUMPAD_MULTIPLY</code>, <code>NUMPAD_SUBTRACT</code>, <code>PAGE_UP</code>, <code>PAGE_DOWN</code>, <code>PAUSE</code>, <code>PRINT_SCREEN</code>, <code>SCROLL_LOCK</code>, <code>SPACE</code>, <code>TAB</code> and <code>VT</code>. +</p> +<p> +We also understand some alternative names for some common special keys. For example, we accept both <code>ESC</code> and <code>ESCAPE</code>, and <code>CR</code>, <code>ENTER</code> and <code>RETURN</code> are all the same. +</p> +<p> +It is also strongly recommended that you keep the key sequences short. One or two is the most you should need. Use contexts to give key sequences different meanings in different parts of your application. At the very most, you should not use any key sequence that contains more than four key strokes. +</p> + </documentation> + </annotation> + </attribute> + <attribute name="description" type="string"> + <annotation> + <documentation> + Description of the spy + </documentation> + </annotation> + </attribute> + <attribute name="icon" type="string"> + <annotation> + <documentation> + Path to the icon of this spy (used in the E4 spies window toolbar). + </documentation> + <appinfo> + <meta.attribute kind="resource"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + Luna M7 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + Here is an example of usage. Associate icon, name and shorcut to the spy part to be displayed + + This is the sample definition for the context spy part. +<p> +<pre> + <extension point="org.eclipse.e4.tools.spy.spyPart"> + <spyPart + description="Context Spy to understand what is behind the scene of injection" + icon="icons/annotation_obj.gif" + name="Context spy" + part="org.eclipse.e4.tools.context.spy.ContextSpyPart" + shortcut="M2+M3+F10"> + </spyPart> + </extension> +</pre> +</p> + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="apiinfo"/> + </appinfo> + <documentation> + The value of the <samp>part</samp> element's <samp>class</samp> attribute must be a simple POJO displaying the 'spied' information. + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + The E4 tools project provides 4 implementations of this extension point : + +<ul> +<li> the live model editor (ie : model spy) </li> +<li> the context spy (to display E4 contexts)</li> +<li> the event spy (to trace IEventBroker events) </li> +<li> the css spy (to display css information)</li> +</ul> + </documentation> + </annotation> + + +</schema> diff --git a/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyHandler.java b/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyHandler.java new file mode 100644 index 00000000..c60aaddc --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyHandler.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * Copyright (c) 2014 OPCoach. + * 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: + * 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 + *******************************************************************************/ +package org.eclipse.e4.tools.spy; + +import java.util.List; + +import javax.inject.Named; + +import org.eclipse.e4.core.contexts.ContextInjectionFactory; +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.di.Focus; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.model.application.commands.MCommand; +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.advanced.MPlaceholder; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; +import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; +import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow; +import org.eclipse.e4.ui.model.application.ui.basic.MWindow; +import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem; +import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.eclipse.e4.ui.workbench.modeling.EPartService; +import org.osgi.framework.FrameworkUtil; + +public class SpyHandler +{ + private static final int DEFAULT_SPY_WINDOW_HEIGHT = 600; + private static final int DEFAULT_SPY_WINDOW_WIDTH = 1000; + private static final String E4_SPIES_WINDOW_LABEL = "E4 Spies window"; + private static final String E4_SPIES_WINDOW = "org.eclipse.e4.tools.spy.window"; + private static final String E4_SPIES_TRIMBAR = "org.eclipse.e4.tools.spy.trimbar"; + private static final String E4_SPIES_TOOLBAR = "org.eclipse.e4.tools.spy.toolbar"; + private static final String E4_SPIES_PART_STACK = "org.eclipse.e4.tools.spy.partStack"; + + /** + * This method open the spy view part at the correct location : - if it has + * never been opened, it add this spy in the E4 window - if it is already + * opened, just activate it - if it has already opened and closed, find it, + * and open it at the same location + * + * @param ps + * part Service to manage parts elements + * @param viewID + * the spy view to be displayed + * @param appli + * current application + * @param modelService + * model service to create elements + */ + @Execute + public void run(EPartService ps, @Optional @Named(SpyProcessor.SPY_COMMAND_PARAM) String viewID, MApplication appli, + EModelService modelService) + { + MWindow spyWindow = getOrCreateSpyWindow(appli, modelService); + + MPartStack partStack = (MPartStack) modelService.find(E4_SPIES_PART_STACK, spyWindow); + + MPart p = ps.findPart(viewID); + if (p == null) + { + // Create the part in the spyWindow... + p = ps.createPart(viewID); + partStack.getChildren().add(p); + partStack.setSelectedElement(p); + } + + p.setVisible(true); + + // modelService.bringToTop(spyWindow); + ps.activate(p, true); + + } + + private MWindow getOrCreateSpyWindow(MApplication appli, EModelService modelService) + { + List<MWindow> existingWindow = modelService.findElements(appli, E4_SPIES_WINDOW, MWindow.class, null); + if (existingWindow.size() >= 1) + return existingWindow.get(0); + + // Now spy window for the moment... add one... + String contributorURI = "platform:/plugin/" + FrameworkUtil.getBundle(getClass()).getSymbolicName(); + + MTrimmedWindow tw = modelService.createModelElement(MTrimmedWindow.class); + tw.setElementId(E4_SPIES_WINDOW); + tw.setLabel(E4_SPIES_WINDOW_LABEL); + tw.setContributorURI(contributorURI); + + MTrimBar trimBar = modelService.createModelElement(MTrimBar.class); + trimBar.setElementId(E4_SPIES_TRIMBAR); + trimBar.setContributorURI(contributorURI); + tw.getTrimBars().add(trimBar); + + MToolBar toolbar = modelService.createModelElement(MToolBar.class); + toolbar.setElementId(E4_SPIES_TOOLBAR); + toolbar.setContributorURI(contributorURI); + trimBar.getChildren().add(toolbar); + + // Create one toolbar element for each 'spy' tagged descriptor + for (MPartDescriptor mp : appli.getDescriptors()) + { + if (mp.getTags().contains(SpyProcessor.SPY_TAG)) + { + // Create a toolitem bound to the command. + MHandledToolItem toolItem = modelService.createModelElement(MHandledToolItem.class); + toolItem.setContributorURI(contributorURI); + + // Search for spy command (added by processor) + MCommand spyCmd = null; + for (MCommand cmd : appli.getCommands()) + { + if (SpyProcessor.SPY_COMMAND.equals(cmd.getElementId())) + { + // Do nothing if command exists + spyCmd = cmd; + break; + } + } + toolItem.setCommand(spyCmd); + toolItem.setIconURI(mp.getIconURI()); + toolItem.setLabel(mp.getLabel()); + toolItem.setTooltip("Open the " + mp.getLabel()); + toolbar.getChildren().add(toolItem); + + // Add the parameter for the view to open + MParameter p = modelService.createModelElement(MParameter.class); + p.setName(SpyProcessor.SPY_COMMAND_PARAM); + p.setValue(mp.getElementId()); + toolItem.getParameters().add(p); + + } + } + + tw.setWidth(DEFAULT_SPY_WINDOW_WIDTH); + tw.setHeight(DEFAULT_SPY_WINDOW_HEIGHT); + appli.getChildren().get(0).getWindows().add(tw); + + MPartStack partStack = modelService.createModelElement(MPartStack.class); + partStack.setElementId(E4_SPIES_PART_STACK); + tw.getChildren().add(partStack); + + return tw; + + } +} 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 new file mode 100644 index 00000000..c78b5210 --- /dev/null +++ b/bundles/org.eclipse.e4.tools.spy/src/org/eclipse/e4/tools/spy/SpyProcessor.java @@ -0,0 +1,282 @@ +/******************************************************************************* + * Copyright (c) 2014 OPCoach. + * 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: + * 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 + *******************************************************************************/ +package org.eclipse.e4.tools.spy; + +import java.net.URL; +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +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.model.application.MApplication; +import org.eclipse.e4.ui.model.application.commands.MBindingContext; +import org.eclipse.e4.ui.model.application.commands.MBindingTable; +import org.eclipse.e4.ui.model.application.commands.MCommand; +import org.eclipse.e4.ui.model.application.commands.MCommandParameter; +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.workbench.modeling.EModelService; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** A base class for all spies processors */ +public class SpyProcessor +{ + static final String SPY_TAG = "Spy"; + + public static final String SPY_COMMAND = "org.eclipse.e4.tools.spy.command"; + public static final String SPY_COMMAND_PARAM = "org.eclipse.e4.tools.spy.command.partID"; + + private static final String SPY_HANDLER = "org.eclipse.e4.tools.spy.handler"; + private static final String E4_SPIES_BINDING_TABLE = "org.eclipse.e4.tools.spy.bindings"; + + @Inject + MApplication application; + @Inject + EModelService modelService; + @Inject + Logger log; + + @Execute + public void process(IExtensionRegistry extRegistry) + { + // This processor will read all spy extensions and automatically create + // the command, handler and binding + // to open this spy in the dedicated spy window. + + // First of all, it creates the spyCommand having one parameter (Id of + // the part to display) and defaut handler for this command. + MCommand command = getOrCreateSpyCommand(); + + for (IConfigurationElement e : extRegistry.getConfigurationElementsFor("org.eclipse.e4.tools.spy.spyPart")) + { + String partName = e.getAttribute("name"); + String shortCut = e.getAttribute("shortcut"); + String iconPath = e.getAttribute("icon"); + String desc = e.getAttribute("description"); + + Bundle b = Platform.getBundle(e.getNamespaceIdentifier()); + String partID = e.getAttribute("part"); + try + { + Class<?> partClass = b.loadClass(partID); + // Bind the command with the binding, and add the view ID as + // parameter. + // The part class name will be the ID of the part descriptor + bindSpyKeyBinding(shortCut, command, partID); + + // Add the descriptor in application + addSpyPartDescriptor(partID, partName, b.getEntry(iconPath), partClass); + + } catch (InvalidRegistryObjectException e1) + { + e1.printStackTrace(); + } catch (ClassNotFoundException e1) + { + log.error("The class '" + partID + "' can not be instantiated. Check name or launch config"); + e1.printStackTrace(); + } + + // Can create the command in model + + } + + } + + public MCommand getOrCreateSpyCommand() + { + // DO NOT USE findElement on ModelService (it searches only in MUIElements) + for (MCommand cmd : application.getCommands()) + { + if (SPY_COMMAND.equals(cmd.getElementId())) + { + // Do nothing if command exists + return cmd; + } + } + + MCommand command = modelService.createModelElement(MCommand.class); + command.setElementId(SPY_COMMAND); + command.setCommandName("Open a spy"); + String contributorURI = "platform:/plugin/" + FrameworkUtil.getBundle(getClass()).getSymbolicName(); + command.setContributorURI(contributorURI); + command.setDescription("Open a spy in the E4 spy window"); + + // Parameter (will be the ID of the part descriptor (ie, the full + // qualified class name)) + // It will be received in the Handler and send by keybinding + MCommandParameter cp = modelService.createModelElement(MCommandParameter.class); + cp.setElementId(SPY_COMMAND_PARAM); + cp.setName("viewPart"); + cp.setContributorURI(contributorURI); + command.getParameters().add(cp); + + application.getCommands().add(command); + + // Create the default handler for this command + // (will receive the parameter) + for (MHandler hdl : application.getHandlers()) + { + if (SPY_HANDLER.equals(hdl.getElementId())) + { + // Do nothing if handler exists, return the command + return command; + } + } + + // Create the handler for this command. + MHandler handler = modelService.createModelElement(MHandler.class); + handler.setElementId(SPY_HANDLER); + handler.setContributionURI("bundleclass://org.eclipse.e4.tools.spy/org.eclipse.e4.tools.spy.SpyHandler"); + handler.setContributorURI("platform:/plugin/org.eclipse.e4.tools.spy"); + application.getHandlers().add(handler); + + handler.setCommand(command); + + return command; + + } + + /** + * Helper method to get or create the binding table for all spies (where + * spies will add their key binding). Bind this table with the + * org.eclipse.ui.contexts.dialogAndWindow binding context which should be + * present (create it if not) + * + * This method will probably move to the common spy plugin providing common + * spy stuff (see bug #428903) + * + * @param application + * @return + */ + public void bindSpyKeyBinding(String keySequence, MCommand cmd, String paramViewId) + { + // This method must : + // search for a binding table having the binding context 'dialog and + // window' + // If none found, create it and also the binding context + // Then can add the KeyBinding if not already added + + MBindingTable spyBindingTable = null; + for (MBindingTable bt : application.getBindingTables()) + if (E4_SPIES_BINDING_TABLE.equals(bt.getElementId())) + { + spyBindingTable = bt; + } + + // Binding table has not been yet added... Create it and bind it to + // org.eclipse.ui.contexts.dialogAndWindow binding context + // If this context does not yet exist, create it also. + if (spyBindingTable == null) + { + + MBindingContext bc = null; + final List<MBindingContext> bindingContexts = application.getBindingContexts(); + if (bindingContexts.size() == 0) + { + bc = modelService.createModelElement(MBindingContext.class); + bc.setElementId("org.eclipse.ui.contexts.window"); + } else + { + // Prefer org.eclipse.ui.contexts.dialogAndWindow but randomly + // select another one + // if org.eclipse.ui.contexts.dialogAndWindow cannot be found + for (MBindingContext aBindingContext : bindingContexts) + { + bc = aBindingContext; + if ("org.eclipse.ui.contexts.dialogAndWindow".equals(aBindingContext.getElementId())) + { + break; + } + } + } + + // Can now create the binding table and bind it to this + // context... + spyBindingTable = modelService.createModelElement(MBindingTable.class); + spyBindingTable.setElementId(E4_SPIES_BINDING_TABLE); + spyBindingTable.setBindingContext(bc); + application.getBindingTables().add(spyBindingTable); + + } + + // Search for the key binding if already present + for (MKeyBinding kb : spyBindingTable.getBindings()) + if (keySequence.equals(kb.getKeySequence())) + { + // A binding with this key sequence is already present. Check if + // command is the same + if (kb.getCommand().getElementId().equals(cmd.getElementId())) + return; + else + { + // Must log an error : key binding already exists in this + // table but with another command + System.out.println("WARNING : Cannot bind the command '" + cmd.getElementId() + "' to the keySequence : " + + keySequence + " because the command " + kb.getCommand().getElementId() + " is already bound !"); + return; + } + } + + // Key binding is not yet in table... can add it now. + MKeyBinding binding = modelService.createModelElement(MKeyBinding.class); + binding.setElementId(cmd.getElementId() + ".binding"); + binding.setContributorURI(cmd.getContributorURI()); + binding.setKeySequence(keySequence); + + MParameter p = modelService.createModelElement(MParameter.class); + p.setName(SPY_COMMAND_PARAM); + p.setValue(paramViewId); + binding.getParameters().add(p); + + spyBindingTable.getBindings().add(binding); + binding.setCommand(cmd); + + } + + public void addSpyPartDescriptor(String partId, String partLabel, URL iconPath, Class<?> spyPartClass) + { + for (MPartDescriptor mp : application.getDescriptors()) + { + if (partId.equals(mp.getElementId())) + { + // Already added, do nothing + return; + } + } + + // If descriptor not yet in descriptor list, add it now + MPartDescriptor descriptor = modelService.createModelElement(MPartDescriptor.class); + descriptor.setCategory("org.eclipse.e4.secondaryDataStack"); + descriptor.setElementId(partId); + descriptor.getTags().add("View"); + descriptor.getTags().add(SPY_TAG); + descriptor.getTags().add("categoryTag:General"); + + descriptor.setLabel(partLabel); + descriptor.setCloseable(true); + String bundle = FrameworkUtil.getBundle(spyPartClass).getSymbolicName(); + descriptor.setContributionURI("bundleclass://" + bundle + "/" + spyPartClass.getCanonicalName()); + String contributorURI = "platform:/plugin/" + FrameworkUtil.getBundle(spyPartClass).getSymbolicName(); + descriptor.setContributorURI(contributorURI); + descriptor.setIconURI(iconPath.toString()); + application.getDescriptors().add(descriptor); + + } +} @@ -58,6 +58,7 @@ <module>./bundles/org.eclipse.e4.tools.orion.text.editor</module> <module>./bundles/org.eclipse.e4.tools.css.spy</module> <module>./bundles/org.eclipse.e4.tools.context.spy</module> + <module>./bundles/org.eclipse.e4.tools.spy</module> <module>./bundles/org.eclipse.e4.tools.event.spy</module> <module>./features/org.eclipse.e4.core.tools.feature</module> <module>./features/org.eclipse.e4.tools.css.editor.feature</module> |
