]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "NatTable based Graph Explorer styling fixes"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 17 Jun 2020 21:01:10 +0000 (21:01 +0000)
committerGerrit Code Review <gerrit2@simantics>
Wed, 17 Jun 2020 21:01:10 +0000 (21:01 +0000)
20 files changed:
bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/graph/ReadGraphImpl.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/SessionGarbageCollection.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java
bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdapterRegistry2.java
bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/GraphObject2.java
bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ThisResource2.java
bundles/org.simantics.diagram/plugin.xml
bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectionCrossingsParticipant.java
bundles/org.simantics.diagram/src/org/simantics/diagram/participant/CopyAsSVGParticipant.java [new file with mode: 0644]
bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java [new file with mode: 0644]
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/command/Commands.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/LinkNode.java
bundles/org.simantics.simulation/src/org/simantics/simulation/history/HistoryUtil.java
bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java
bundles/org.simantics.tests.modelled.ui/scl/Simantics/TestsUI.scl
bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/TestsUIUtils.java

index 1e4b5cbac508623fff9fd9d5017043818ce1ee42..52be328eb87ea5de7d9b58fed20e1fe53439f727 100644 (file)
@@ -70,7 +70,7 @@ public class MainProgram implements Runnable, Closeable {
                this.updateSchedules = new ArrayList[CLUSTER_THREADS];
                for(int i=0;i<clusterUpdateThreads.length;i++) {
                        clusterUpdateThreads[i] = Executors.newSingleThreadExecutor(new ClusterThreadFactory("Cluster Updater " + (i+1), false));
-                       updateSchedules[i] = new ArrayList<ClusterUpdateOperation>();
+                       updateSchedules[i] = new ArrayList<>();
                }
        }
 
@@ -93,11 +93,13 @@ public class MainProgram implements Runnable, Closeable {
 
                try {
 
+                       TreeMap<ClusterUID, List<ClusterUpdateOperation>> updates = new TreeMap<>(clusterComparator);
+
                        main:
                        while(alive) {
 
-                               TreeMap<ClusterUID, List<ClusterUpdateOperation>> updates = new TreeMap<ClusterUID, List<ClusterUpdateOperation>>(clusterComparator);
-
+                               if (!updates.isEmpty())
+                                       updates.clear();
                                operationQueue.pumpUpdates(updates);
 
                                if(updates.isEmpty()) {
@@ -165,6 +167,9 @@ public class MainProgram implements Runnable, Closeable {
                for(int i=0;i<CLUSTER_THREADS;i++)
                        updateSchedules[i].clear();
 
+               if (updates.isEmpty())
+                       return;
+
                final Semaphore s = new Semaphore(0);
 
                for(Map.Entry<ClusterUID, List<ClusterUpdateOperation>> entry : updates.entrySet()) {
index cc15c1eac9111e063369cadd9c7167b3c843b4a9..5d4852c0d7822efe1f88ef70a1a7eb6a941cb272 100644 (file)
@@ -50,6 +50,7 @@ import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.ExternalValueSupport;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.RelationContext;
+import org.simantics.db.RelationInfo;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.Statement;
@@ -1849,8 +1850,35 @@ public class ReadGraphImpl implements AsyncReadGraph {
 
                try {
 
-                       Collection<Resource> objects = getObjects(subject, relation);
-                       return !objects.isEmpty();
+                       SyncReadProcedure<RelationInfo> procedure = new SyncReadProcedure<RelationInfo>();
+                       processor.forRelationInfo(this, relation, procedure);
+                       Collection<Resource> predicates = getPredicates(subject);
+                       
+                       if(procedure.result.isFinal) {
+                               
+                               return predicates.contains(relation);
+                               
+                       } else if (procedure.result.isFunctional) {
+
+                               try {
+                                       int result = processor.getSingleObject(this, subject, relation);
+                                       return result != 0;
+                               } catch (ManyObjectsForFunctionalRelationException e) {
+                                       return true;
+                               } catch (DatabaseException e) {
+                                       throw new ServiceException(e);
+                               }
+                               
+                       } else {
+
+                               for(Resource predicate : getPredicates(subject)) {
+                                       if(isSubrelationOf(predicate, relation))
+                                               return true;
+                               }
+                               
+                       }
+                       
+                       return false;
 
                } catch (ServiceException e) {
 
index c168e22860b25dba84ff1b715376c4a878effcfb..c48ec36309e601cf885f9b8125f16f7e79c579f8 100644 (file)
@@ -76,7 +76,18 @@ public class SessionGarbageCollection {
         QueryControl qc = graph.getService(QueryControl.class);
         ClusterControl cc = graph.getService(ClusterControl.class);
         _monitor.beginTask("Collect clusters", IProgressMonitor.UNKNOWN);
-        cc.gc(graph, clusterTarget);
+        //cc.gc(graph, clusterTarget);
+        if(clusterTarget == -1) {
+            int used = cc.used();
+            //System.err.println("session gc, cluster use = " + used);
+            int baseline = 32*(1<<20);
+            if(used > baseline) {
+                int dynamicTarget = (int)(0.95 * (used-baseline)) + baseline;
+                cc.gc(graph, dynamicTarget);
+            }
+        } else {
+            cc.gc(graph, clusterTarget);
+        }
         _monitor.beginTask("Collect queries", IProgressMonitor.UNKNOWN);
         qc.gc(graph, allowedTimeInMs);
     }
index 200e9e3c14f573478c4c50c2a3809266d77c5602..efb644acd78330df99bd86c305a1d21e73646ea7 100644 (file)
@@ -526,10 +526,11 @@ public final class ClusterTable implements IClusterTable {
                 ArrayList<CollectorCluster> toRelease = new ArrayList<CollectorCluster>();
 
                 for (CollectorCluster cluster : support.getResidentClusters()) {
-                    target -= support.getClusterSize(cluster);
-                    if (target > 0) {
-                        toRelease.add(cluster);
-                    } else {
+                    toRelease.add(cluster);
+                    long clusterSize = support.getClusterSize(cluster);
+                    //System.err.println("release cluster with " + (clusterSize/1024) + " kiB - " + cluster);
+                    target -= clusterSize;
+                    if (target <= 0) {
                         break;
                     }
                 }
index 0db80b1b4f5cb48044709875cf3b821aabca4278..e9b59023fbb28130c45a14782805e3cdb4b864af 100644 (file)
@@ -237,9 +237,9 @@ public class AdapterRegistry2 {
                 NamedNodeMap attr = n.getAttributes();
                 IDynamicAdapter2 da = null;
                 if(n.getNodeName().equals("this"))
-                    da = new ThisResource2();
+                    da = ThisResource2.INSTANCE;
                 else if(n.getNodeName().equals("graph"))
-                    da = new GraphObject2();
+                    da = GraphObject2.INSTANCE;
                 else if(n.getNodeName().equals("bundle")) {
                     String bundleId = null;
                     Node fc = n.getFirstChild();
index e8f171b8ca02a170268d4270e442ed3655ffad9d..8a2db578f6488debda2a66fa3d1719c6772cca10 100644 (file)
@@ -15,6 +15,8 @@ import org.simantics.db.ReadGraph;
 
 public class GraphObject2 implements IDynamicAdapter2 {
 
+       public static final IDynamicAdapter2 INSTANCE = new GraphObject2();
+
        @Override
        public Class<?> getType() {
                return ReadGraph.class;
index 24001ee0ae90840a5333a3c2665a098b92f42f23..bacf3adee83f92185c46572121f751e0a8e67de7 100644 (file)
@@ -16,6 +16,8 @@ import org.simantics.db.ReadGraph;
 
 public class ThisResource2 implements IDynamicAdapter2 {
 
+       public static IDynamicAdapter2 INSTANCE = new ThisResource2();
+
        @Override
        public Class<?> getType() {
                return Resource.class;
index ef8a32516069d795ecda3a4966b99afdcdc576ba..b6a591201d43430f00172cd30bed16c956390343 100644 (file)
             </with>
          </activeWhen>
       </handler>
+      <handler
+            class="org.simantics.diagram.handler.CanvasCommandDelegate"
+            commandId="copyAsSVG">
+         <activeWhen>
+            <reference definitionId="org.simantics.modeling.ui.diagram.active" />
+         </activeWhen>
+      </handler>
       <handler
             class="org.simantics.diagram.handler.CanvasCommandDelegate"
             commandId="org.eclipse.ui.edit.rename">
index 10949ca655c059b74559e2ab2885f80f3aaf1f25..c02f68de672b9550da3f8391c2daee7d181dc973 100644 (file)
@@ -30,7 +30,7 @@ import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.ui.ErrorLogger;
 
 public class ConnectionCrossingsParticipant extends AbstractDiagramParticipant {
-    private static final String CONNECTION_CROSSINGS_NODE_KEY = "connection-crossings";
+    public static final String CONNECTION_CROSSINGS_NODE_KEY = "connection-crossings";
 
     private ConnectionCrossingsNode ccNode;
     private final ConnectionCrossings crossings = new ConnectionCrossings();
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/CopyAsSVGParticipant.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/CopyAsSVGParticipant.java
new file mode 100644 (file)
index 0000000..b91c2bb
--- /dev/null
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
+ * 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.diagram.participant;
+
+import java.awt.Font;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.batik.dom.GenericDOMImplementation;
+import org.apache.batik.svggen.SVGGeneratorContext;
+import org.apache.batik.svggen.SVGGeneratorContext.GraphicContextDefaults;
+import org.apache.batik.svggen.SVGGraphics2D;
+import org.apache.batik.svggen.SVGGraphics2DIOException;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.simantics.diagram.elements.TextNode;
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
+import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;
+import org.simantics.g2d.diagram.participant.Selection;
+import org.simantics.g2d.element.ElementHints;
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.g2d.G2DSceneGraph;
+import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
+import org.simantics.scenegraph.g2d.events.command.CommandEvent;
+import org.simantics.scenegraph.g2d.events.command.Commands;
+import org.simantics.scenegraph.g2d.nodes.LinkNode;
+import org.simantics.scenegraph.g2d.nodes.SelectionNode;
+import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
+import org.simantics.scenegraph.g2d.nodes.connection.RouteGraphNode;
+import org.simantics.scenegraph.utils.NodeMapper;
+import org.simantics.scenegraph.utils.NodeUtil;
+import org.simantics.utils.ui.ErrorLogger;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class CopyAsSVGParticipant extends AbstractDiagramParticipant {
+
+    @Dependency
+    protected Selection sel;
+
+    @EventHandler(priority = 0)
+    public boolean handleCommand(CommandEvent e) {
+        if (e.command.equals(Commands.COPY_AS_SVG)) {
+            Set<IElement> ss = sel.getSelection(0);
+            copyAsSVG(getContext(), ss);
+            return true;
+        }
+        return false;
+    }
+
+    private static void copyAsSVG(ICanvasContext canvasContext, Set<IElement> elements) {
+        G2DSceneGraph sg = canvasContext.getSceneGraph();
+        NodeMapper clipboardNodeMapper = new NodeMapper();
+        List<G2DNode> selectionRenderingDisabledNodes = new ArrayList<G2DNode>();
+        SingleElementNode clipboardNode = sg.addNode("svg-clipboard-temp", SingleElementNode.class); 
+
+        try {
+            for (IElement e : elements) {
+                INode node = e.getHint(ElementHints.KEY_SG_NODE);
+                if (node != null) {
+                    // Don't render selection. Selection rendering could be a global rendering hint that is adhered by nodes!  
+                    for(RouteGraphNode n : NodeUtil.collectNodes(node, RouteGraphNode.class)) {
+                        n.setIgnoreSelection(true);
+                        selectionRenderingDisabledNodes.add(n);
+                    }
+                    for(SelectionNode n : NodeUtil.collectNodes(node, SelectionNode.class)) {
+                        n.setIgnore(true);
+                        selectionRenderingDisabledNodes.add(n);
+                    }
+                    for(TextNode n : NodeUtil.collectNodes(node, TextNode.class)) {
+                        n.setShowSelection(false);
+                        selectionRenderingDisabledNodes.add(n);
+                    }
+
+                    String nodeId = clipboardNodeMapper.add(node);
+                    LinkNode delegate = clipboardNode.addNode(ElementUtils.generateNodeId(e), LinkNode.class);
+                    delegate.setDelegateId( nodeId );
+                }
+            }
+
+            DOMImplementation domImpl =  GenericDOMImplementation.getDOMImplementation();
+
+            String svgNS = "http://www.w3.org/2000/svg";
+            Document document = domImpl.createDocument(svgNS, "svg", null);
+
+            GraphicContextDefaults gcDefaults = new GraphicContextDefaults();
+            SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
+            Map<java.awt.RenderingHints.Key, Object> hintMap = new HashMap<java.awt.RenderingHints.Key, Object>();
+
+            hintMap.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+            hintMap.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+            hintMap.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+            hintMap.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+            hintMap.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+
+            gcDefaults.setRenderingHints(new RenderingHints(hintMap));
+            gcDefaults.setFont(Font.decode(null));
+            ctx.setGraphicContextDefaults(gcDefaults);
+
+            SVGGraphics2D svgG2D = new SVGGraphics2D(ctx, false);
+
+            StringWriter writer = new StringWriter();
+
+            // Track connection crossings manually since we will render only the clipboard node.
+            sg.getNode(ConnectionCrossingsParticipant.CONNECTION_CROSSINGS_NODE_KEY).render(svgG2D);
+            clipboardNode.render(svgG2D);
+
+            Element root = svgG2D.getRoot();
+
+            Rectangle2D bounds = clipboardNode.getBoundsInLocal(true);
+            if (bounds != null) {
+                root.setAttributeNS(null, "viewBox", bounds.getMinX() + " " + bounds.getMinY() + " " + bounds.getWidth() + " " + bounds.getHeight()); 
+                root.setAttributeNS(null, "height", Double.toString(bounds.getHeight()));
+                root.setAttributeNS(null, "width", Double.toString(bounds.getWidth()));
+            }
+
+            try {
+                svgG2D.stream(root, writer, false, false);
+            } catch (SVGGraphics2DIOException e1) {
+                ErrorLogger.defaultLogError("Failed to copy the diagram selection as SVG." , e1);
+            }
+
+            byte[] svgContent = writer.toString().getBytes(StandardCharsets.UTF_8);
+
+            Display.getDefault().asyncExec(new Runnable() {
+                @Override
+                public void run() {
+                    Clipboard cb = new Clipboard(Display.getCurrent());
+                    cb.setContents(new byte[][] {svgContent}, 
+                            new Transfer[] {
+                                SVGTransfer.getInstance()
+                            }
+                    );
+                }
+            });
+
+        } finally {
+            clipboardNode.removeNodes();
+            clipboardNodeMapper.clear();
+            clipboardNode.remove();
+
+            // Restore the selection rendering state for changed nodes.
+            for (G2DNode n : selectionRenderingDisabledNodes) {
+                if (n instanceof RouteGraphNode) {
+                    ((RouteGraphNode) n).setIgnoreSelection(false);
+                } else if (n instanceof SelectionNode) {
+                    ((SelectionNode)n).setIgnore(false);
+                } else if (n instanceof TextNode) {
+                    ((TextNode)n).setShowSelection(true);
+                }
+            }
+        }
+    }
+}
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/SVGTransfer.java
new file mode 100644 (file)
index 0000000..539e22e
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2020 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:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.participant;
+
+import java.nio.charset.StandardCharsets;
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+
+public class SVGTransfer extends ByteArrayTransfer {
+    private static SVGTransfer instance = new SVGTransfer();
+    private static final String TYPE_NAME = "image/svg+xml";
+    private static final int TYPE_ID = registerType(TYPE_NAME);
+
+    public static byte[] formatContent(String svg) {
+        return svg.getBytes(StandardCharsets.UTF_8);
+    }
+
+    public static SVGTransfer getInstance () {
+        return instance;
+    }
+
+    @Override
+    protected int[] getTypeIds(){
+        return new int[] {TYPE_ID};
+    }
+
+    @Override
+    protected String[] getTypeNames(){
+        return new String[] {TYPE_NAME};
+    }
+}
\ No newline at end of file
index 489ebd6c700a65a6dd7e70dcf8a42d6c9e93a2eb..88d85cfbf6581dc996205ffdf0204d4e8e444e51 100644 (file)
@@ -69,6 +69,7 @@ import org.simantics.diagram.handler.SimpleElementTransformHandler;
 import org.simantics.diagram.layer.ILayersViewPage;
 import org.simantics.diagram.participant.ConnectionCrossingsParticipant;
 import org.simantics.diagram.participant.ContextUtil;
+import org.simantics.diagram.participant.CopyAsSVGParticipant;
 import org.simantics.diagram.participant.PointerInteractor2;
 import org.simantics.diagram.participant.SGFocusParticipant;
 import org.simantics.diagram.query.DiagramRequests;
@@ -332,6 +333,7 @@ public class DiagramViewer
         //ctx.add(new TooltipParticipant());
         ctx.add(new TerminalTooltipParticipant());
         ctx.add(new ConnectionCrossingsParticipant(getInputResource()));
+        ctx.add(new CopyAsSVGParticipant());
     }
 
     protected void addPainterParticipants(ICanvasContext ctx) {
index decf3356c68b1b72864f738ac1d6ac57b6fb1ea3..dc9d9d1bef72f88c590167b14acc666edf33d19b 100644 (file)
@@ -111,8 +111,8 @@ public class DiagramViewerLoadJob extends DatabaseJob {
                         });
                         END(task);
                     } catch (Throwable t) {
-                        viewer = null;
                         LOGGER.error("Failed to complete loading of diagram {} in the canvas thread", viewer.diagramResource, t);
+                        viewer = null;
                     }
                 }
             });
index af8c5630dc84c88c46c350b07c540ee9926e9ae6..a752e9253eedf1149b1d6860fe8e2586ffdaf539 100644 (file)
@@ -349,11 +349,12 @@ public class G2DParentNode extends ParentNode<IG2DNode> implements IG2DNode, Ini
         Rectangle2D bounds = null;
         while(it.hasNext()) {
             IG2DNode node = it.next();
-            Rectangle2D b = node.getBounds();
+            Rectangle2D b = node.getBoundsInLocal(ignoreNulls);
             if(b == null && !ignoreNulls)
                 return null;
             if(b != null) {
                 if(!GeometryUtils.isUndefinedRectangle(b)) {
+                    b = node.localToParent(b);
                     if(bounds == null) {
                         bounds = b.getFrame();
                     } else {
index ce52912a5612f019a49eba3d533a2fc8f3b3d6ab..89de18835282e8150dbaa61eeb18c7c03c9461b7 100644 (file)
@@ -107,6 +107,7 @@ public class Commands {
 
     public static final Command FOCUS_TOOLTIP = new Command("focusTooltip");
 
+    public static final Command COPY_AS_SVG = new Command("copyAsSVG");
     
     public static Command showPopup(Point2D atControlPosition) {
         return new ShowPopup(atControlPosition);
index 50d50ecd2f3fe48e2d8b9f894149c7585880bd13..aa570d6aa21144d3ea4dfd6eb9f2dd7d255de93e 100644 (file)
@@ -131,6 +131,11 @@ public class LinkNode extends StateMaskNode {
 
     @Override
     public Rectangle2D getBoundsInLocal() {
+        return getBoundsInLocal(false);
+    }
+    
+    @Override
+    public Rectangle2D getBoundsInLocal(boolean ignoreNulls) {
         // Safety against cyclic cases.
         if (hasFlags(IN_GET_BOUNDS))
             return new Rectangle2D.Double();
@@ -141,7 +146,7 @@ public class LinkNode extends StateMaskNode {
 
         setFlags(IN_GET_BOUNDS);
         try {
-            Rectangle2D bounds = n.getBoundsInLocal();
+            Rectangle2D bounds = n.getBoundsInLocal(ignoreNulls);
             if (transform != null && !transform.isIdentity())
                 bounds = transform.createTransformedShape(bounds).getBounds2D();
             return bounds;
index 343adefc8686fc2053b6c4b41e9167d0e937372d..6719cf63b2f138d119b4470403c2b21629a2b6ed 100644 (file)
@@ -664,7 +664,7 @@ public class HistoryUtil {
         */
        public static HistoryImportResult importHistoryArchive(HistoryManager history, Path path) throws IOException, HistoryException {
                HistoryImportResult result = new HistoryImportResult();
-               try (RandomAccessBinary rab = new BinaryFile(path.toFile())) {
+               try (RandomAccessBinary rab = new BinaryFile(path.toFile(), "r")) {
                        importHistoryArchive(history, rab, result);
                        return result;
                } catch (IOException e) {
index e43007637ac5ca616a89f33b3cc3f62247ad8fea..e9bb272d3d4442d07184c2bed0437a63f67a5562 100644 (file)
@@ -635,8 +635,8 @@ public class Functions {
 
                @Override
                public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-                       
-                       Resource type = context.getPossibleType(graph);
+                       StructuralResource2 STR = StructuralResource2.getInstance(graph);
+                       Resource type = context.getPossibleType(graph, STR.Component);
                        if(type == null) return null;
                        
                        StructuralComponentClass clazz = StructuralComponentClass.get(graph, type);
@@ -653,7 +653,6 @@ public class Functions {
                }
                return map;
                        } else if (StructuralComponentClass.DEFINED.equals(clazz)) {
-                               StructuralResource2 STR = StructuralResource2.getInstance(graph);
                                Resource def = graph.getSingleObject(type, STR.IsDefinedBy);
                 Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(def), TransientCacheListener.instance());
                 return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, children, map);
index 0b99fe784fa2239470ef3f93f80b59f5e2ae6bcf..169f37e2a369c6cc93eb086e210ed40cf79746d9 100644 (file)
@@ -7,7 +7,7 @@ createSTSTestAction res = do
 
 importJava "org.simantics.tests.modelled.ui.TestsUIUtils" where
     runSTSTestAction :: Resource -> <Proc> ()
-    ignoreSTSTestAction :: [Resource] -> <Proc> ()
+    ignoreSTSTestAction :: Resource -> <Proc> ()
     
 createSTSSuiteAction :: Resource -> <Proc> ()
 createSTSSuiteAction res = do
index b24f445e23c985e317f652f628e435a0135a3b53..648d48969456e2c74064255fc01bc6fd7daa954e 100644 (file)
@@ -1,7 +1,6 @@
 package org.simantics.tests.modelled.ui;
 
 import java.io.IOException;
-import java.util.List;
 
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.simantics.Simantics;
@@ -27,15 +26,13 @@ public class TestsUIUtils {
         view.execute();
     }
     
-    public static void ignoreSTSTestAction(List<Resource> tests) throws DatabaseException {
+    public static void ignoreSTSTestAction(Resource test) throws DatabaseException {
         Simantics.getSession().syncRequest(new Write() {
             
             @Override
             public void perform(WriteGraph graph) throws DatabaseException {
                 TestsResource TESTS = TestsResource.getInstance(graph);
-                for (Resource test : tests) {
-                    graph.claimLiteral(test, TESTS.ignore, true, Bindings.BOOLEAN);
-                }
+                graph.claimLiteral(test, TESTS.ignore, true, Bindings.BOOLEAN);
             }
         });
     }