X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fflag%2FAbstractFlagType.java;h=a11c10319bcc1cb269511f819547d6893cd84a91;hp=0f1a96563348b196f46bbab138d7d65c34cfe3a7;hb=bd5bc6e45f700e755b61bd112631796631330ecb;hpb=7684baeb8bc7963700676af20db6f4a860581e46 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);