From fac4285b1eb76730493ddbb7cf0f6acd8da17da1 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 17 Dec 2018 12:44:50 +0200 Subject: [PATCH] Fix context menu for route view gitlab #25 Change-Id: I3e7af22cc0775e3b98fc7a6864c26098f8a224c4 --- .../org/simantics/district/route/ui/RouteTree.java | 11 +++++------ .../org/simantics/district/route/ui/RouteView.java | 9 ++++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteTree.java b/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteTree.java index c275b5b5..e58d6a68 100644 --- a/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteTree.java +++ b/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteTree.java @@ -1,7 +1,6 @@ package org.simantics.district.route.ui; import java.util.List; -import java.util.concurrent.CompletableFuture; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.jface.layout.GridDataFactory; @@ -10,11 +9,8 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; @@ -22,10 +18,9 @@ import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; -import org.simantics.db.Resource; +import org.eclipse.swt.widgets.Tree; import org.simantics.district.route.Route; import org.simantics.district.route.RouteEvent; -import org.simantics.district.route.RouteJob; import org.simantics.district.route.RouteService; import org.simantics.district.route.RouteServiceListener; import org.simantics.district.route.Waypoint; @@ -218,4 +213,8 @@ public class RouteTree extends Composite { } } + public Tree getTree() { + return tree.getTree(); + } + } diff --git a/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteView.java b/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteView.java index 77725b7c..0d99b374 100644 --- a/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteView.java +++ b/org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteView.java @@ -13,8 +13,11 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.model.application.ui.menu.MMenuContribution; import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory; import org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu; +import org.eclipse.e4.ui.services.EMenuService; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.swt.widgets.Composite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Tuukka Lehtonen @@ -22,6 +25,8 @@ import org.eclipse.swt.widgets.Composite; */ public class RouteView { + private static final Logger LOGGER = LoggerFactory.getLogger(RouteView.class); + private static final String POPUP_CONTRIBUTION_ID = "org.simantics.district.route.ui.contextMenu"; public static final String POPUP_ELEMENT_ID = "org.simantics.district.route.ui.popup"; @@ -50,8 +55,10 @@ public class RouteView { } @PostConstruct - public void postConstruct(Composite parent) { + public void postConstruct(Composite parent, EMenuService menuService) { this.ui = new RouteTree(parent, 0, selectionService); + if (!(menuService.registerContextMenu(this.ui.getTree(), POPUP_ELEMENT_ID))) + LOGGER.warn("Could not register context menu {}", POPUP_ELEMENT_ID); } @PreDestroy -- 2.47.1