import org.eclipse.ui.PlatformUI;
import org.simantics.db.Resource;
import org.simantics.diagram.ui.DiagramModelHints;
+import org.simantics.district.network.ui.adapters.DistrictNetworkVertexElement;
import org.simantics.district.network.ui.internal.Activator;
import org.simantics.district.route.Route;
import org.simantics.district.route.RouteEvent;
import org.simantics.g2d.diagram.handler.PickContext;
import org.simantics.g2d.diagram.participant.Selection;
import org.simantics.g2d.diagram.participant.pointertool.AbstractMode;
+import org.simantics.g2d.element.ElementClass;
import org.simantics.g2d.element.ElementUtils;
import org.simantics.g2d.element.IElement;
import org.simantics.g2d.participant.TransformUtil;
return;
Object o = ElementUtils.getObject(element);
- if (o instanceof Resource) {
+ if (o instanceof Resource && filterAcceptableElement(element, o)) {
Waypoint wp = route.createWaypoint(o);
route.addWaypoint(wp);
}
}
+ /**
+ * For now, routing can only start from vertices
+ *
+ * @return true if element is a vertex
+ */
+ private boolean filterAcceptableElement(IElement element, Object o) {
+ ElementClass elementClass = element.getElementClass();
+ return elementClass.getId().equals(DistrictNetworkVertexElement.CLASS.getId());
+ }
+
@SGInit
public void initSG(G2DParentNode parent) {
this.parent = parent;