From: Tuukka Lehtonen Date: Wed, 12 Oct 2016 08:15:59 +0000 (+0300) Subject: Sync git svn branch with SVN repository r33324. X-Git-Tag: v1.25.0~70^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=bd5bc6e45f700e755b61bd112631796631330ecb;p=simantics%2Fplatform.git Sync git svn branch with SVN repository r33324. refs #6751 [PRIVATE-12404] refs #6752 [PRIVATE-12401] --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ModelledConnectionAdvisor.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ModelledConnectionAdvisor.java index 8ecf15874..16495f4cc 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ModelledConnectionAdvisor.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/connection/ModelledConnectionAdvisor.java @@ -127,7 +127,13 @@ public class ModelledConnectionAdvisor implements IConnectionAdvisor { cps.add(getConnectionPoint(graph, element2, term2, true)); ConnectionJudgement judgement = modelingRules.judgeConnection(graph, cps); - if (judgement.type == ConnectionJudgementType.LEGAL) + if (judgement.type == ConnectionJudgementType.LEGAL + // #6751, Apros #12404: a connection should not be automatically + // denied just because it is not perfectly legal. Further legality + // should be decided on the client side even though the IConnectionAdvisor + // interface is not documented to return ConnectionJudgement instances, + // because the interface knows nothing about this class. + || judgement.type == ConnectionJudgementType.CANBEMADELEGAL) return judgement; return null; } diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/AbstractFlagType.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/AbstractFlagType.java index 0f1a96563..a11c10319 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/AbstractFlagType.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/AbstractFlagType.java @@ -49,16 +49,17 @@ public abstract class AbstractFlagType implements IFlagType { } public static Mode getMode(ReadGraph graph, Resource flag) throws DatabaseException { - int joinCount = graph.getObjects(flag, DiagramResource.getInstance(graph).FlagIsJoinedBy).size(); + DiagramResource DIA = DiagramResource.getInstance(graph); + int joinCount = graph.getObjects(flag, DIA.FlagIsJoinedBy).size(); if(joinCount == 0) return FlagClass.Mode.Internal; else if(joinCount == 1) { - Resource otherFlag = FlagUtil.getPossibleCounterpart(graph, flag); - if(otherFlag == null /* FIXME just to get around npe */ || - DiagramGraphUtil.onSameDiagram(graph, flag, otherFlag)) - return FlagClass.Mode.Internal; - else - return FlagClass.Mode.External; + for (Resource connectionJoin : graph.getObjects(flag, DIA.FlagIsJoinedBy)) + for (Resource otherFlag : graph.getObjects(connectionJoin, DIA.JoinsFlag)) + if (!flag.equals(otherFlag) + && !DiagramGraphUtil.onSameDiagram(graph, flag, otherFlag)) + return FlagClass.Mode.External; + return FlagClass.Mode.Internal; } else return new FlagClass.External(joinCount); diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/FlagUtil.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/FlagUtil.java index 27dc9e307..2a0e14b93 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/FlagUtil.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/flag/FlagUtil.java @@ -28,6 +28,7 @@ import org.simantics.db.common.utils.NameUtils; import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ServiceException; +import org.simantics.db.function.DbBiFunction; import org.simantics.db.function.DbConsumer; import org.simantics.db.layer0.util.RemoverUtil; import org.simantics.db.layer0.variable.Variable; @@ -130,6 +131,21 @@ public final class FlagUtil { return count; } + public static int forCounterparts(ReadGraph graph, Resource flag, DbBiFunction procedure) throws DatabaseException { + DiagramResource DIA = DiagramResource.getInstance(graph); + int count = 0; + for (Resource connectionJoin : graph.getObjects(flag, DIA.FlagIsJoinedBy)) { + for (Resource otherFlag : graph.getObjects(connectionJoin, DIA.JoinsFlag)) { + if (!flag.equals(otherFlag)) { + if (!procedure.apply(connectionJoin, otherFlag)) + return ++count; + ++count; + } + } + } + return count; + } + /** * Returns all flags that are joined with the given flag including the flag given as parameter. */ diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java index 4aaa717d8..71a8d2829 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Deque; -import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -39,12 +38,15 @@ import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.diagram.connection.RouteGraph; import org.simantics.diagram.connection.RouteGraphConnectionClass; +import org.simantics.diagram.connection.RouteLine; import org.simantics.diagram.connection.RouteTerminal; +import org.simantics.diagram.connection.delta.RouteGraphDelta; import org.simantics.diagram.connection.rendering.arrows.PlainLineEndStyle; import org.simantics.diagram.content.ResourceTerminal; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.diagram.synchronization.ISynchronizationContext; import org.simantics.diagram.synchronization.SynchronizationHints; +import org.simantics.diagram.synchronization.graph.RouteGraphConnection; import org.simantics.g2d.canvas.ICanvasContext; import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency; import org.simantics.g2d.canvas.impl.DependencyReflection.Reference; @@ -54,6 +56,7 @@ import org.simantics.g2d.connection.IConnectionAdvisor; import org.simantics.g2d.diagram.DiagramHints; import org.simantics.g2d.diagram.DiagramUtils; import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.diagram.handler.PickContext; import org.simantics.g2d.diagram.handler.Topology.Terminal; import org.simantics.g2d.diagram.participant.ElementPainter; import org.simantics.g2d.diagram.participant.TerminalPainter; @@ -70,6 +73,7 @@ import org.simantics.g2d.element.IElementClassProvider; import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd; import org.simantics.g2d.element.handler.SceneGraph; import org.simantics.g2d.element.handler.TerminalTopology; +import org.simantics.g2d.element.handler.impl.BranchPointTerminal; import org.simantics.g2d.element.impl.Element; import org.simantics.g2d.elementclass.BranchPoint; import org.simantics.g2d.elementclass.BranchPoint.Direction; @@ -77,8 +81,8 @@ import org.simantics.g2d.elementclass.FlagClass; import org.simantics.g2d.elementclass.FlagHandler; import org.simantics.g2d.participant.RenderingQualityInteractor; import org.simantics.g2d.participant.TransformUtil; +import org.simantics.g2d.utils.geom.DirectionSet; import org.simantics.modeling.ModelingResources; -import org.simantics.scenegraph.INode; import org.simantics.scenegraph.g2d.G2DParentNode; import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler; import org.simantics.scenegraph.g2d.events.KeyEvent; @@ -101,6 +105,8 @@ import org.simantics.utils.logging.TimeLogger; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.ExceptionUtils; +import gnu.trove.map.hash.THashMap; + /** * A basic tool for making connection on diagrams. * @@ -141,6 +147,9 @@ public class ConnectTool2 extends AbstractMode { @Dependency protected PointerInteractor pi; + @Dependency + protected PickContext pickContext; + /** * Start element terminal of the connection. null if connection * was started from a flag or a branch point. @@ -269,6 +278,8 @@ public class ConnectTool2 extends AbstractMode { protected G2DParentNode endFlagNode; + private RouteGraphTarget lastRouteGraphTarget; + /** * @param startTerminal * @param mouseId @@ -387,9 +398,9 @@ public class ConnectTool2 extends AbstractMode { ShapeNode pathNode = ghostNode.getOrCreateNode("path", ShapeNode.class); pathNode.setColor(new Color(160, 0, 0)); - pathNode.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, - new float[] { 5f, 2f }, 0)); - pathNode.setScaleStroke(true); + pathNode.setStroke(new BasicStroke(0.1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, + new float[] { 0.5f, 0.2f }, 0)); + pathNode.setScaleStroke(false); pathNode.setZIndex(0); G2DParentNode points = ghostNode.getOrCreateNode("points", G2DParentNode.class); @@ -443,105 +454,18 @@ public class ConnectTool2 extends AbstractMode { ControlPoint begin = controlPoints.getFirst(); ControlPoint end = controlPoints.getLast(); - + RouteGraph routeGraph = new RouteGraph(); RouteTerminal a = addControlPoint(routeGraph, begin); RouteTerminal b = addControlPoint(routeGraph, end); routeGraph.link(a, b); - - // Route connection segments separately - /*Router2 router = ElementUtils.getHintOrDefault(diagram, DiagramHints.ROUTE_ALGORITHM, TrivialRouter2.INSTANCE); - final List segments = toSegments(controlPoints); - //System.out.println("controlpoints: " + controlPoints); - //System.out.println("segments: " + segments); - router.route(new IConnection() { - @Override - public Collection getSegments() { - return segments; - } - - @Override - public Connector getBegin(Object seg) { - return getConnector(((Segment) seg).begin); - } - - @Override - public Connector getEnd(Object seg) { - return getConnector(((Segment) seg).end); - } - - private Connector getConnector(ControlPoint cp) { - Connector c = new Connector(); - c.x = cp.getPosition().getX(); - c.y = cp.getPosition().getY(); - - TerminalInfo ti = cp.getAttachedTerminal(); - if (ti != null && (ti == startFlag || ti != endFlag)) { - //System.out.println("CP1: " + cp); - c.parentObstacle = DiagramUtils.getObstacleShape(ti.e); - ConnectionDirectionUtil.determineAllowedDirections(c); - } else { - //System.out.println("CP2: " + cp); - c.parentObstacle = GeometryUtils.transformRectangle(AffineTransform.getTranslateInstance(c.x, c.y), - BranchPointClass.DEFAULT_IMAGE2.getBounds()); - c.allowedDirections = toAllowedDirections(cp.getDirection()); - } - - return c; - } - @Override - public void setPath(Object seg, Path2D path) { - ((Segment) seg).path = (Path2D) path.clone(); - } - - private int toAllowedDirections(BranchPoint.Direction direction) { - switch (direction) { - case Any: - return 0xf; - case Horizontal: - return Constants.EAST_FLAG | Constants.WEST_FLAG; - case Vertical: - return Constants.NORTH_FLAG | Constants.SOUTH_FLAG; - default: - throw new IllegalArgumentException("unrecognized direction: " + direction); - } - } - }); - - // Combine the routed paths - Path2D path = new Path2D.Double(); - for (Segment seg : segments) { - //System.out.println("SEG: " + seg); - if (seg.path != null) - path.append(seg.path.getPathIterator(null), true); - }*/ - Path2D path = routeGraph.getPath2D(); // Create scene graph to visualize the connection. ShapeNode pathNode = ghostNode.getOrCreateNode("path", ShapeNode.class); pathNode.setShape(path); - G2DParentNode points = ghostNode.getOrCreateNode("points", G2DParentNode.class); - HashSet unusedChildren = new HashSet(points.getNodes()); - int i = 0; - for (ControlPoint cp : controlPoints) { - if (cp.isAttachedToTerminal()) - continue; - - String id = String.valueOf(i); - BranchPointNode bpn = points.getOrCreateNode(id, BranchPointNode.class); - bpn.setDegree(2); - bpn.setDirection((byte) cp.getDirection().ordinal()); - bpn.setTransform(AffineTransform.getTranslateInstance(cp.getPosition().getX(), cp.getPosition().getY())); - - ++i; - unusedChildren.remove(bpn); - } - for (INode unusedChild : unusedChildren) - points.removeNode(unusedChild); - setDirty(); } @@ -668,12 +592,48 @@ public class ConnectTool2 extends AbstractMode { // Make sure that we are ending with a flag if ALT is pressed // and no end terminal is defined. - endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me)); - - updateSG(); + if (!endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me))) + updateSG(); return false; } } + } else { + RouteGraphTarget cp = RouteGraphConnectTool.pickRouteGraphConnection( + diagram, + pi.getCanvasPickShape(me.controlPosition), + pi.getPickDistance()); + if (cp != null) { + // Remove branch point highlight from previously picked route graph. + if (lastRouteGraphTarget != null && cp.getNode() != lastRouteGraphTarget.getNode()) + cp.getNode().showBranchPoint(null); + lastRouteGraphTarget = cp; + + // Validate connection before visualizing connectability + Point2D isectPos = cp.getIntersectionPosition(); + TerminalInfo ti = TerminalInfo.create( + isectPos, + cp.getElement(), + BranchPointTerminal.existingTerminal( + isectPos, + DirectionSet.ANY, + BranchPointNode.SHAPE), + BranchPointNode.SHAPE); + Pair canConnect = canConnect(ti.e, ti.t); + if (canConnect != null) { + connectionJudgment = canConnect.first; + controlPoints.getLast().setPosition(ti.posDia).setAttachedToTerminal(ti); + endTerminal = ti; + cp.getNode().showBranchPoint(isectPos); + if (!endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me))) + updateSG(); + return false; + } + } else { + if (lastRouteGraphTarget != null) { + lastRouteGraphTarget.getNode().showBranchPoint(null); + lastRouteGraphTarget = null; + } + } } connectionJudgment = null; @@ -705,9 +665,8 @@ public class ConnectTool2 extends AbstractMode { // Make sure that we are ending with a flag if ALT is pressed and no end // terminal is defined. - endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me)); - - updateSG(); + if (!endWithoutTerminal(lastMouseCanvasPos, shouldEndWithFlag(me))) + updateSG(); return false; } @@ -729,8 +688,13 @@ public class ConnectTool2 extends AbstractMode { if (snapAdvisor != null) snapAdvisor.snap(mouseCanvasPos); - // Clicked on an allowed end terminal. End connection & end mode. - if (isEndTerminalDefined()) { + if (lastRouteGraphTarget != null) { + lastRouteGraphTarget.getNode().showBranchPoint(null); + attachToConnection(); + remove(); + return true; + } else if (isEndTerminalDefined()) { + // Clicked on an allowed end terminal. End connection & end mode. createConnection(); remove(); return true; @@ -772,6 +736,53 @@ public class ConnectTool2 extends AbstractMode { return false; } + private void attachToConnection() { + ConnectionJudgement judgment = this.connectionJudgment; + if (judgment == null) { + ErrorLogger.defaultLogError("Cannot attach to connection, no judgment available on connection validity", null); + return; + } + + ConnectionBuilder builder = new ConnectionBuilder(this.diagram); + RouteGraph before = lastRouteGraphTarget.getNode().getRouteGraph(); + THashMap copyMap = new THashMap<>(); + RouteGraph after = before.copy(copyMap); + + RouteLine attachTo = (RouteLine) copyMap.get(lastRouteGraphTarget.getLine()); + after.makePersistent(attachTo); + for (RouteLine line : after.getAllLines()) { + if (!line.isTransient() && line.isHorizontal() == attachTo.isHorizontal() + && line.getPosition() == attachTo.getPosition()) { + attachTo = line; + break; + } + } + RouteLine attachToLine = attachTo; + RouteGraphDelta delta = new RouteGraphDelta(before, after); + + Simantics.getSession().asyncRequest(new WriteRequest() { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); + Resource connection = ElementUtils.getObject(endTerminal.e); + if (!delta.isEmpty()) { + new RouteGraphConnection(graph, connection).synchronize(graph, before, after, delta); + } + Resource line = RouteGraphConnection.deserialize(graph, attachToLine.getData()); + Deque cps = new ArrayDeque<>(); + for (Iterator iterator = controlPoints.descendingIterator(); iterator.hasNext();) + cps.add(iterator.next()); + builder.attachToRouteGraph(graph, judgment, connection, line, cps, startTerminal, FlagClass.Type.In); + } + }, new Callback() { + @Override + public void run(DatabaseException parameter) { + if (parameter != null) + ExceptionUtils.logAndShowError(parameter); + } + }); + } + protected boolean cancelPreviousBend() { if (!routePointsAllowed()) return false; @@ -912,10 +923,16 @@ public class ConnectTool2 extends AbstractMode { return endFlag != null; } - protected void endWithoutTerminal(Point2D mousePos, boolean altDown) { + /** + * @param mousePos + * @param altDown + * @return true if updateSG was executed, false + * otherwise + */ + protected boolean endWithoutTerminal(Point2D mousePos, boolean altDown) { // Just go with branch points if flags are not allowed. if (!createFlags) - return; + return false; boolean endTerminalDefined = isEndTerminalDefined(); @@ -931,6 +948,7 @@ public class ConnectTool2 extends AbstractMode { setHint(TerminalPainter.TERMINAL_HOVER_STRATEGY, terminalHoverStrategy); updateSG(); + return true; } } else { if (isEndingInFlag()) { @@ -954,8 +972,10 @@ public class ConnectTool2 extends AbstractMode { setHint(TerminalPainter.TERMINAL_HOVER_STRATEGY, terminalHoverStrategy); updateSG(); + return true; } } + return false; } protected void createConnection() { diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java index 1fcf074cd..b36961f87 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionBuilder.java @@ -475,7 +475,8 @@ public class ConnectionBuilder { Resource attachToConnection, Resource attachToLine, Deque controlPoints, - TerminalInfo endTerminal) + TerminalInfo endTerminal, + FlagClass.Type flagType) throws DatabaseException { initializeResources(graph); @@ -502,9 +503,10 @@ public class ConnectionBuilder { if (endTerminal != null) { endConnector = createConnectorForNode(graph, attachToConnection, endTerminal, EdgeEnd.End, judgment); } else if (createFlags) { - IElement endFlag = createFlag(graph, attachToConnection, EdgeEnd.End, controlPoints.getLast(), FlagClass.Type.Out, null); + EdgeEnd end = flagType == FlagClass.Type.In ? EdgeEnd.Begin : EdgeEnd.End; + IElement endFlag = createFlag(graph, attachToConnection, end, controlPoints.getLast(), flagType, null); endConnector = createConnectorForNode(graph, attachToConnection, (Resource) ElementUtils.getObject(endFlag), - ElementUtils.getSingleTerminal(endFlag), EdgeEnd.End, judgment); + ElementUtils.getSingleTerminal(endFlag), end, judgment); } cu.connect(attachToLine, endConnector.getConnector()); diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/RouteGraphConnectTool.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/RouteGraphConnectTool.java index af1f48f5d..57f5cd490 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/RouteGraphConnectTool.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/RouteGraphConnectTool.java @@ -763,7 +763,7 @@ public class RouteGraphConnectTool extends AbstractMode { new RouteGraphConnection(graph, connection).synchronize(graph, rgs.first, rgs.second, rgs.third); } Resource attachToLine = RouteGraphConnection.deserialize(graph, attachedToRouteLine.getData()); - builder.attachToRouteGraph(graph, judgment, connection, attachToLine, controlPoints, endTerminal); + builder.attachToRouteGraph(graph, judgment, connection, attachToLine, controlPoints, endTerminal, FlagClass.Type.Out); } }, new Callback() { @Override diff --git a/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java b/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java index bb85be21f..c4b83aa99 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java +++ b/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java @@ -1,10 +1,12 @@ package org.simantics.event.util; +import java.util.List; import java.util.UUID; import org.simantics.databoard.Bindings; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.PossibleTypedParent; import org.simantics.db.exception.DatabaseException; import org.simantics.event.ontology.EventResource; import org.simantics.layer0.Layer0; @@ -25,5 +27,46 @@ public class EventUtils { graph.claimLiteral(log, EVENT.HasModificationCounter, 0, Bindings.INTEGER); return log; } - + + /** + * Bumps the modification counter value of the event log of the specified + * events using {@link #bumpModificationCounter(WriteGraph, Resource)}. + *

+ * The code assumes that all events are from the same log. + * + * @param graph + * @param forLogOfEvents + * @throws DatabaseException + */ + public static void bumpModificationCounter(WriteGraph graph, List forLogOfEvents) throws DatabaseException { + EventResource EVENT = EventResource.getInstance(graph); + for (Resource event : forLogOfEvents) { + Resource log = graph.syncRequest(new PossibleTypedParent(event, EVENT.EventLog)); + if (log != null) { + bumpModificationCounter(graph, log); + return; + } + } + } + + /** + * Bumps the modification counter of the specified event log by 1. + * + * @param graph + * @param eventLog + * @return new modification counter value + * @throws DatabaseException + */ + public static int bumpModificationCounter(WriteGraph graph, Resource eventLog) throws DatabaseException { + EventResource EVENT = EventResource.getInstance(graph); + Resource counter = graph.getPossibleObject(eventLog, EVENT.HasModificationCounter); + if (counter != null) { + Integer c = graph.getValue(counter, Bindings.INTEGER); + c = c == null ? 1 : c+1; + graph.claimValue(counter, c, Bindings.INTEGER); + return c; + } + return 0; + } + } diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/contribution/ProjectEventsRule.java b/bundles/org.simantics.event/src/org/simantics/event/view/contribution/ProjectEventsRule.java index e6e59966c..9b9ea8bfe 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/view/contribution/ProjectEventsRule.java +++ b/bundles/org.simantics.event/src/org/simantics/event/view/contribution/ProjectEventsRule.java @@ -116,20 +116,25 @@ public enum ProjectEventsRule implements ChildRule { if (!showHiddenEvents && graph.hasStatement(event, EVENT.Hidden)) continue; + boolean isReturnEvent = hideReturnEvents || showOnlyActiveEvents + ? graph.hasStatement(event, EVENT.ReturnEvent) : false; + + // Skip all return events if thus preferred. + if (hideReturnEvents && isReturnEvent) { + continue; + } + + // Skip all return events and starting events that have been returned, + // if thus preferred. Also skip events that are defined non-returnable. if (showOnlyActiveEvents - && (graph.hasStatement(event, EVENT.Returns) + && (isReturnEvent + || graph.hasStatement(event, EVENT.Returns) || graph.hasStatement(event, EVENT.ReturnedBy) || graph.hasStatement(event, EVENT.NoReturn))) { continue; } - // Skip return events if thus preferred. - if (hideReturnEvents && graph.hasStatement(event, EVENT.ReturnEvent)) { - if (graph.getPossibleObject(event, EVENT.Returns) != null) - continue; - } - // Filter by event type severity Resource eventType = graph.getPossibleObject(event, EVENT.Event_type); if (eventType != null) { diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/Hide.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/Hide.java deleted file mode 100644 index 778c5fb1a..000000000 --- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/Hide.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.event.view.handler; - -import org.simantics.event.ontology.EventResource; - - -/** - * @author Tuukka Lehtonen - */ -public class Hide extends PreferenceHandler { - - public Hide() { - super("experiments", EventResource.URIs.Hidden, true); - } - -} diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/MenuActions.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/MenuActions.java index ddd70fb7f..9b125ed44 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/MenuActions.java +++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/MenuActions.java @@ -24,6 +24,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.SelectionHints; import org.simantics.event.Activator; import org.simantics.event.ontology.EventResource; +import org.simantics.event.util.EventUtils; import org.simantics.ui.contribution.DynamicMenuContribution; import org.simantics.ui.workbench.action.PerformDefaultAction; import org.simantics.utils.ui.ISelectionUtils; @@ -147,13 +148,17 @@ public class MenuActions extends DynamicMenuContribution { } private IAction hideAction(List input) { - return tagAction("Hide", Activator.HIDE_ICON, EventResource.URIs.Hidden, true, input); + return contentChangingTagAction("Hide", Activator.HIDE_ICON, EventResource.URIs.Hidden, true, input); } private IAction tagAction(String label, ImageDescriptor image, String tagURI, boolean tag, List input) { return new TagAction(label, image, VG_EXPERIMENTS, tagURI, tag, input); } + private IAction contentChangingTagAction(String label, ImageDescriptor image, String tagURI, boolean tag, List input) { + return new ContentChangingTagAction(label, image, VG_EXPERIMENTS, tagURI, tag, input); + } + private IAction setBaseline(Resource eventLog, Resource event) { return new SetBaseline(VG_EXPERIMENTS, eventLog, event); } @@ -169,6 +174,17 @@ public class MenuActions extends DynamicMenuContribution { return new PerformDefaultAction(title, null, input); } + private static class ContentChangingTagAction extends TagAction { + public ContentChangingTagAction(String label, ImageDescriptor image, String virtualGraphId, String tagURI, boolean tag, List input) { + super(label, image, virtualGraphId, tagURI, tag, input); + } + + @Override + public void postTagWrite(WriteGraph graph) throws DatabaseException { + EventUtils.bumpModificationCounter(graph, resources); + } + } + private static class ToClipboardAction extends Action { private String text; diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/TagAction.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/TagAction.java index 0de441539..3491e29f0 100644 --- a/bundles/org.simantics.event/src/org/simantics/event/view/handler/TagAction.java +++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/TagAction.java @@ -22,7 +22,7 @@ public class TagAction extends Action { private final String virtualGraphId; private final String tagURI; private final boolean tag; - private final List resources; + protected final List resources; /** * @param label diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/pointertool/TerminalUtil.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/pointertool/TerminalUtil.java index a28cfa563..409af79d6 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/pointertool/TerminalUtil.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/pointertool/TerminalUtil.java @@ -78,6 +78,17 @@ public class TerminalUtil { .append(']'); return sb.toString(); } + + public static TerminalInfo create(Point2D p, IElement e, Terminal t, Shape terminalShape) { + AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY()); + TerminalInfo ti = new TerminalInfo(); + ti.e = e; + ti.t = t; + ti.posElem = at; + ti.posDia = at; + ti.shape = terminalShape; + return ti; + } } private static final Rectangle2D POINT_PICK_SHAPE = new Rectangle2D.Double(0, 0, 0.001, 0.001); diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/BranchPointTerminal.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/BranchPointTerminal.java index bce157dd5..3ad4a9f75 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/BranchPointTerminal.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/BranchPointTerminal.java @@ -13,6 +13,7 @@ package org.simantics.g2d.element.handler.impl; import java.awt.Shape; import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; import org.simantics.g2d.utils.geom.DirectionSet; @@ -39,4 +40,8 @@ public class BranchPointTerminal extends ObjectTerminal { return new BranchPointTerminal(EXISTING_BRANCH_POINT_DATA, transform, ds, shape); } + public static BranchPointTerminal existingTerminal(Point2D p, DirectionSet ds, Shape shape) { + return existingTerminal(AffineTransform.getTranslateInstance(p.getX(), p.getY()), ds, shape); + } + } \ No newline at end of file diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RouteGraphNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RouteGraphNode.java index 34b1a635d..e231476ac 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RouteGraphNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/connection/RouteGraphNode.java @@ -11,8 +11,6 @@ *******************************************************************************/ package org.simantics.scenegraph.g2d.nodes.connection; -import gnu.trove.map.hash.THashMap; - import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; @@ -31,7 +29,6 @@ import java.util.Map; import org.simantics.diagram.connection.RouteGraph; import org.simantics.diagram.connection.RouteLine; import org.simantics.diagram.connection.RouteLink; -import org.simantics.diagram.connection.RoutePoint; import org.simantics.diagram.connection.RouteTerminal; import org.simantics.diagram.connection.actions.IAction; import org.simantics.diagram.connection.actions.IReconnectAction; @@ -69,6 +66,8 @@ import org.simantics.scenegraph.utils.GeometryUtils; import org.simantics.scenegraph.utils.InitValueSupport; import org.simantics.scenegraph.utils.NodeUtil; +import gnu.trove.map.hash.THashMap; + /** * @author Tuukka Lehtonen */ @@ -312,6 +311,10 @@ public class RouteGraphNode extends G2DNode implements ISelectionPainterNode, In } } + public void showBranchPoint(Point2D p) { + newBranchPointPosition = p; + } + @Override public void init() { super.init(); diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/modelingRules/StandardModelingRules.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/modelingRules/StandardModelingRules.java index a45edf0ee..c79602c1b 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/modelingRules/StandardModelingRules.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/modelingRules/StandardModelingRules.java @@ -199,6 +199,8 @@ public class StandardModelingRules extends AbstractModelingRules { boolean legal = true; for (Resource constraint : g.getObjects(connectionType, STR.HasConnectionConstraint)) { IConnectionConstraint cc = g.adapt(constraint, IConnectionConstraint.class); + if(Policy.DEBUG_STANDARD_MODELING_RULES) + System.out.println("Checking " + cc.getClass().getSimpleName()); switch(cc.isLegal(g, terminals)) { case ILLEGAL: if(Policy.DEBUG_STANDARD_MODELING_RULES)