]> gerrit.simantics Code Review - simantics/district.git/blob
7568ea308d7b6e975cb3564ee28c6674092e5355
[simantics/district.git] /
1 package org.simantics.district.route.ui.handlers;
2
3 import java.util.List;
4 import java.util.concurrent.CompletableFuture;
5
6 import javax.inject.Named;
7
8 import org.eclipse.e4.core.di.annotations.Execute;
9 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
10 import org.eclipse.e4.ui.services.IServiceConstants;
11 import org.eclipse.jface.viewers.ISelection;
12 import org.eclipse.swt.widgets.Shell;
13 import org.simantics.db.layer0.variable.Variable;
14 import org.simantics.district.route.Route;
15 import org.simantics.district.route.RouteJob;
16 import org.simantics.district.route.RouterConfiguration;
17 import org.simantics.utils.ui.ISelectionUtils;
18
19 /**
20  * @author Tuukka Lehtonen
21  */
22 public class SelectRouteOnDiagram {
23
24     @Execute
25     public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell activeShell,
26             @Named(IServiceConstants.ACTIVE_PART) MPart part,
27             @Named(IServiceConstants.ACTIVE_SELECTION) ISelection selection) {
28         // get selected route
29         Route route = ISelectionUtils.filterSingleSelection(selection, Route.class);
30         if (route == null)
31             return;
32
33         CompletableFuture<List<Variable>> result = new CompletableFuture<>();
34         RouterConfiguration config = new RouterConfiguration();
35         new RouteJob(config, route, result).schedule();
36     }
37
38 }