]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Fix context menu for route view 57/2557/4
authorjsimomaa <jani.simomaa@gmail.com>
Mon, 17 Dec 2018 10:44:50 +0000 (12:44 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Mon, 17 Dec 2018 10:47:58 +0000 (10:47 +0000)
gitlab #25

Change-Id: I3e7af22cc0775e3b98fc7a6864c26098f8a224c4

org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteTree.java
org.simantics.district.route.ui/src/org/simantics/district/route/ui/RouteView.java

index c275b5b5f6be008b207f25e8da1b43ad2b3efcc3..e58d6a68ec9d4d833c35f929e7405ab1f6c47242 100644 (file)
@@ -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();
+    }
+
 }
index 77725b7c0d6f6c874f738e95e468e0d318c9c4d6..0d99b37486fdf557e813e720ce9812b80f2bece5 100644 (file)
@@ -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