Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Torregrosa Paez2016-03-17 10:55:31 +0000
committerPablo Torregrosa Paez2016-03-17 10:55:44 +0000
commit2c48ebdb7e454b7f776bc156252234a58053b3de (patch)
tree481bb834d32cd211f09225a785d01abd6c4797fa /target_explorer/plugins
parent99298ec95b3698b343c9743cf382380442cba9f2 (diff)
downloadorg.eclipse.tcf-2c48ebdb7e454b7f776bc156252234a58053b3de.tar.gz
org.eclipse.tcf-2c48ebdb7e454b7f776bc156252234a58053b3de.tar.xz
org.eclipse.tcf-2c48ebdb7e454b7f776bc156252234a58053b3de.zip
Target Explorer: Improved building and disposal of Target Actions menu
Change-Id: I78bcbdb0cbfff692f27ce959a56f9872da507dc6 Signed-off-by: Pablo Torregrosa Paez <pablo.torregrosa@windriver.com>
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsCommandHandler.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsMenuContribution.java23
2 files changed, 31 insertions, 6 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsCommandHandler.java
index cc5ebe764..942432432 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsCommandHandler.java
@@ -64,11 +64,15 @@ public class DefaultContextActionsCommandHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// Get the position of the ToolItem
- Event eventTrigger = (Event) event.getTrigger();
- ToolItem toolItem = (ToolItem) eventTrigger.widget;
- Rectangle bounds = toolItem.getBounds();
- if ( bounds != null ) {
- menuLocation = toolItem.getParent().toDisplay(bounds.x, bounds.y + bounds.height);
+ if (event.getTrigger() instanceof Event) {
+ Event eventTrigger = (Event) event.getTrigger();
+ if (eventTrigger.widget instanceof ToolItem) {
+ ToolItem toolItem = (ToolItem) eventTrigger.widget;
+ Rectangle bounds = toolItem.getBounds();
+ if ( bounds != null ) {
+ menuLocation = toolItem.getParent().toDisplay(bounds.x, bounds.y + bounds.height);
+ }
+ }
}
fMenuCreator.createMenu();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsMenuContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsMenuContribution.java
index e16b7a1e3..1ee839952 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsMenuContribution.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DefaultContextActionsMenuContribution.java
@@ -10,17 +10,22 @@
package org.eclipse.tcf.te.tcf.ui.handler;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.ContributionManager;
import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuListener2;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.menus.ExtensionContributionFactory;
import org.eclipse.ui.menus.IContributionRoot;
import org.eclipse.ui.menus.IMenuService;
import org.eclipse.ui.services.IServiceLocator;
-public class DefaultContextActionsMenuContribution extends ExtensionContributionFactory {
+public class DefaultContextActionsMenuContribution extends ExtensionContributionFactory implements IMenuListener2 {
@SuppressWarnings("cast")
@Override
@@ -45,4 +50,20 @@ public class DefaultContextActionsMenuContribution extends ExtensionContribution
}
}
}
+
+ @Override
+ public void menuAboutToShow(IMenuManager manager) {
+ }
+
+ @Override
+ public void menuAboutToHide(final IMenuManager manager) {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ workbench.getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IMenuService service = (IMenuService) workbench.getService(IMenuService.class);
+ service.releaseContributions((ContributionManager) manager);
+ }
+ });
+ }
}

Back to the top