import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.function.Consumer;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
+import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.common.request.UnaryRead;
import org.simantics.ui.selection.WorkbenchSelectionUtils;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ISelectionUtils;
+import org.simantics.utils.ui.SWTUtils;
/**
* @author Tuukka Lehtonen
openEditorWithSelection(DistrictDiagramEditor.ID, input, selection);
}
+ public static boolean openDNDiagramWithSelection(Display display, List<Resource> dnElements) throws DatabaseException {
+ if (dnElements.isEmpty())
+ return false;
+
+ Input in = Simantics.getSession().syncRequest(
+ new ElementToInput(dnElements.get(0)));
+ if (in == null)
+ return false;
+
+ SWTUtils.asyncExec(display,
+ () -> openDNDiagramEditorWithSelection(in, dnElements.toArray()));
+ return true;
+ }
+
}
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.simantics.Simantics;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.district.network.ui.DistrictNetworkUIUtil;
import org.simantics.district.route.RouteJob;
import org.simantics.district.route.RouterConfiguration;
import org.simantics.utils.ui.ISelectionUtils;
-import org.simantics.utils.ui.SWTUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.thenAccept(dnElements -> {
if (!dnElements.isEmpty()) {
try {
- openDiagram(display, dnElements);
+ DistrictNetworkUIUtil.openDNDiagramWithSelection(display, dnElements);
} catch (DatabaseException e) {
LOGGER.error("Failed to open district network diagram with selection {}", dnElements); //$NON-NLS-1$
}
RouterConfiguration config = new RouterConfiguration();
new RouteJob(config, route, result).schedule();
}
-
- public static boolean openDiagram(Display display, List<Resource> dnElements) throws DatabaseException {
- if (dnElements.isEmpty())
- return false;
-
- DistrictNetworkUIUtil.Input in = Simantics.getSession().syncRequest(
- new DistrictNetworkUIUtil.ElementToInput(dnElements.get(0)));
- if (in == null)
- return false;
-
- SWTUtils.asyncExec(display,
- () -> DistrictNetworkUIUtil.openDNDiagramEditorWithSelection(in, dnElements.toArray()));
- return true;
- }
-
-}
\ No newline at end of file
+}