]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Bringing layers back to life
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 24 Jun 2020 12:33:13 +0000 (15:33 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Wed, 29 Jul 2020 15:16:13 +0000 (18:16 +0300)
Change-Id: I72ff3880f41994c4760d3cccfd9368883f85e6af

36 files changed:
bundles/org.simantics.diagram/plugin.xml
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionRequest.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionRequest2.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementFactory.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ElementFactoryUtil.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/FlagClassFactory.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/GraphToDiagramSynchronizer.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphConnectionClassFactory.java
bundles/org.simantics.diagram/src/org/simantics/diagram/content/ConnectionUtil.java
bundles/org.simantics.diagram/src/org/simantics/diagram/layer/LayersView.java
bundles/org.simantics.diagram/src/org/simantics/diagram/layer/messages.properties
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/layer/GraphLayer.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/layer/GraphLayerManager.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/layer/GraphLayerUtil.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/layer/LayersSpec.java [new file with mode: 0644]
bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java
bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/Selection.java
bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/ElementLayers.java
bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/SimpleElementLayers.java
bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/FlagClass.java
bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/RouteGraphConnectionClass.java
bundles/org.simantics.g2d/src/org/simantics/g2d/layers/ILayers.java
bundles/org.simantics.g2d/src/org/simantics/g2d/layers/ILayersEditor.java
bundles/org.simantics.g2d/src/org/simantics/g2d/layers/SimpleLayers.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SetFocusabilityContribution.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/MonitorClassFactory2.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramLayersPage.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/Messages.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/PlainDiagramViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/SheetViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/WikiDiagramViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/e4/DiagramViewer.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/messages.properties
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/symbolEditor/SymbolViewer.java
releng/org.simantics.desktop.rcp.product/simantics-desktop.product

index b6a591201d43430f00172cd30bed16c956390343..fca5d19c1c60784775969569b63c32e1a1283d9a 100644 (file)
          </description>
       </view>
       -->
-      <!--
+
       <view
             category="org.simantics.diagram.views"
             class="org.simantics.diagram.layer.LayersView"
             icon="icons/layers.png"
             id="org.simantics.diagram.layers"
-            name="Roles">
+            name="Layers">
          <description>
             A view for editing diagram layers.
          </description>
       </view>
-      -->
+
    </extension>
 
  <extension
index cd9080f1219b34fd36a6a604d4387e50fa35511a..af2a8da33f49471fba8ec2ca8d52f87be05989ad 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.diagram.adapter;
 
+import java.util.List;
+
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.primitiverequest.Adapter;
@@ -20,6 +22,7 @@ import org.simantics.db.procedure.Listener;
 import org.simantics.diagram.synchronization.ErrorHandler;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.diagram.handler.SubstituteElementClass;
 import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.IElement;
 
@@ -77,8 +80,14 @@ public class ConnectionRequest extends BaseRequest2<Resource, IElement> {
                             }
 
                             @Override
-                            public void execute(AsyncReadGraph graph, final ElementClass ec) {
-
+                            public void execute(AsyncReadGraph graph, ElementClass mutableClazz) {
+
+                                List<SubstituteElementClass> substitutes = diagram.getDiagramClass().getItemsByClass(SubstituteElementClass.class);
+                                for (SubstituteElementClass subs : substitutes) {
+                                    mutableClazz = subs.substitute(diagram, mutableClazz);
+                                }
+                                final ElementClass ec = mutableClazz;
+                               
                                 graph.asyncRequest(new SpawnRequest(canvas, ec, data), new TransientCacheAsyncListener<IElement>() {
 
                                     @Override
index 36a01b54c641a0e1a6a67dac6dd2fbec481aad7e..a19bc3dad141921dae5a46e67277e611406c672a 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.diagram.adapter;
 
+import java.util.List;
+
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.primitiverequest.Adapter;
@@ -19,6 +21,7 @@ import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.diagram.synchronization.ErrorHandler;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.diagram.handler.SubstituteElementClass;
 import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.IElement;
 import org.simantics.scl.runtime.tuple.Tuple3;
@@ -75,7 +78,13 @@ public class ConnectionRequest2 extends BaseRequest2<Resource, Tuple3> {
                             }
 
                             @Override
-                            public void execute(AsyncReadGraph graph, final ElementClass ec) {
+                            public void execute(AsyncReadGraph graph, ElementClass mutableClazz) {
+
+                                List<SubstituteElementClass> substitutes = diagram.getDiagramClass().getItemsByClass(SubstituteElementClass.class);
+                                for (SubstituteElementClass subs : substitutes) {
+                                    mutableClazz = subs.substitute(diagram, mutableClazz);
+                                }
+                                final ElementClass ec = mutableClazz;
 
                                 graph.asyncRequest(new SpawnRequest(canvas, ec, data), new TransientCacheAsyncListener<IElement>() {
 
index 10855496becc36fce003acafba8e0cac4fb3489a..d58f383e2aea334eabb88a62f9c242661e5b6b44 100644 (file)
@@ -270,7 +270,8 @@ public class DefinedElementFactory extends ElementFactoryAdapter {
 
         ElementFactoryUtil.readParameters(graph, element, e);
 
-        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 1);
+        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 2);
+        ElementFactoryUtil.loadLayersForElement(graph, diagram, e, element, guard);
         ElementFactoryUtil.readTransform(graph, element, e, guard);
 
 //        graph.asyncRequest(new SafeName(resource), new ProcedureAdapter<String>() {
index f05667cb6882b73f6faab486473f9ec836e9e98d..e8163cd9cc6c903a6779da8b3ae8ccd34161d6b3 100644 (file)
@@ -32,7 +32,7 @@ import org.simantics.g2d.diagram.DiagramHints;
 import org.simantics.g2d.diagram.IDiagram;
 import org.simantics.g2d.element.ElementUtils;
 import org.simantics.g2d.element.IElement;
-import org.simantics.g2d.layers.ILayersEditor;
+import org.simantics.g2d.layers.ILayers;
 import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -118,7 +118,7 @@ public class ElementFactoryUtil {
 
     public static void loadLayersForElement(AsyncReadGraph graph, GraphLayerManager layerManager, IDiagram diagram, IElement e, Resource element,
             AsyncProcedure<IElement> callback) {
-        final ILayersEditor layers = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);
+        final ILayers layers = diagram.getHint(DiagramHints.KEY_LAYERS);
         if (layers != null)
             layerManager.loadLayersForElement(graph, layers, e, element, callback);
         else
index 56c2ceef42ae172e53f5aae6624e568bd9f23d13..94acc5116451a805d3e67cbf42f21809e47a9a46 100644 (file)
@@ -33,6 +33,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper;
 import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.common.request.TernaryRead;
 import org.simantics.db.common.request.WriteRequest;
@@ -103,6 +104,14 @@ public class FlagClassFactory extends SyncElementFactory {
         procedure.execute(graph, createFlagClass(DIA.Flag, DIA.Flag_Terminal));
     }
 
+    @Override
+    public void load(AsyncReadGraph graph, final ICanvasContext canvas, final IDiagram diagram,
+            final Resource elementResource, final IElement element, final AsyncProcedure<IElement> procedure) {
+        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 2);
+        super.load(graph, canvas, diagram, elementResource, element, guard);
+        ElementFactoryUtil.loadLayersForElement(graph, diagram, element, elementResource, guard);
+    }
+
     @Override
     public void load(ReadGraph g, ICanvasContext canvas, IDiagram diagram, Resource flag, IElement e) throws DatabaseException {
         Layer0 l0 = g.getService(Layer0.class);
index 37471eb3a1186fa8dc1c993e7d0f267f178a5f91..14b9f148a1baa1d8f5fe1ab320d40e0370ccc202 100644 (file)
@@ -129,6 +129,7 @@ import org.simantics.g2d.element.IElementClassProvider;
 import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd;
 import org.simantics.g2d.element.handler.ElementHandler;
 import org.simantics.g2d.element.handler.ElementLayerListener;
+import org.simantics.g2d.element.handler.ElementLayers;
 import org.simantics.g2d.element.handler.TerminalTopology;
 import org.simantics.g2d.element.impl.Element;
 import org.simantics.g2d.layers.ILayer;
@@ -768,16 +769,14 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
 
             // If the element class is our own, there's no point in creating
             // a copy of it.
-            if (ec.contains(elementLayerListener))
-                return ec;
+            /*if (ec.contains(elementLayerListener))
+                return ec;*/
 
             List<ElementHandler> all = ec.getAll();
-            List<ElementHandler> result = new ArrayList<ElementHandler>(all.size());
+            List<ElementHandler> result = new ArrayList<ElementHandler>(all);
             for (ElementHandler eh : all) {
-                if (eh instanceof ElementLayerListenerImpl)
+                if (eh instanceof ElementLayers)
                     result.add(elementLayerListener);
-                else
-                    result.add(eh);
             }
             return ElementClass.compile(result, false).setId(ec.getId());
         }
@@ -1173,7 +1172,7 @@ public class GraphToDiagramSynchronizer extends AbstractDisposable implements ID
      * A common handler for all elements that is used to listen to changes in
      * element visibility and focusability on diagram layers.
      */
-    class ElementLayerListenerImpl implements ElementLayerListener {
+    public class ElementLayerListenerImpl implements ElementLayerListener {
         private static final long serialVersionUID = -3410052116598828129L;
 
         @Override
index 4e15608a61e0e4da754eea6f9b1d5c3628ade90b..82d24938005c2e542c8eda10422bf9112291c6f5 100644 (file)
@@ -21,6 +21,7 @@ import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
+import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.diagram.adapter.RouteGraphUtils.BackendConnection;
@@ -89,6 +90,14 @@ public class RouteGraphConnectionClassFactory extends SyncElementFactory {
         return DIA.Connection;
     }
 
+    @Override
+    public void load(AsyncReadGraph graph, final ICanvasContext canvas, final IDiagram diagram,
+            final Resource elementResource, final IElement element, final AsyncProcedure<IElement> procedure) {
+        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 2);
+        super.load(graph, canvas, diagram, elementResource, element, guard);
+        ElementFactoryUtil.loadLayersForElement(graph, diagram, element, elementResource, guard);
+    }
+
     @Override
     public void load(ReadGraph graph, ICanvasContext canvas, IDiagram diagram, final Resource connection,
             IElement element) throws DatabaseException {
index 3bcb26de77ce2d492c3a18958ea8f64e73c152f3..c96b8fb94174e8411f5f4404fd4dd62526719741 100644 (file)
@@ -42,6 +42,7 @@ import org.simantics.diagram.connection.ConnectionSegmentEnd;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.diagram.synchronization.graph.BasicResources;
 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
+import org.simantics.diagram.synchronization.graph.layer.GraphLayerUtil;
 import org.simantics.g2d.connection.handler.ConnectionHandler;
 import org.simantics.g2d.diagram.handler.PickRequest.PickFilter;
 import org.simantics.g2d.diagram.handler.Topology.Terminal;
@@ -117,6 +118,7 @@ public final class ConnectionUtil {
         // often it is visually the expected result.
         OrderedSetUtils.addFirst(g, composite, connection);
         g.claim(composite, br.L0.ConsistsOf, br.L0.PartOf, connection);
+        GraphLayerUtil.addToVisibleLayers(g, connection, composite);
         return connection;
     }
 
index f7a9ccb1f68d2fc1b560bbed88ca9310346ceb1c..32a8d0f721caeb902d3c19656210a02affbdffce 100644 (file)
@@ -169,6 +169,15 @@ public class LayersView extends PageBookView implements ISelectionProvider, ISel
        public void partBroughtToTop(IWorkbenchPart part) {
                partActivated(part);
        }
+       
+    // Dirty hack to ensure that a new Page will be created if the previous one has been disposed due to disposal of AWTChassis 
+    protected PageRec getPageRec(IWorkbenchPart part) {
+        PageRec rec = super.getPageRec(part);
+        if (rec == null || rec.page == null || rec.page.getControl() == null || rec.page.getControl().isDisposed()) 
+            return null;
+        else
+            return rec;
+    }
 
        /* (non-Javadoc)
         * Method declared on ISelectionProvider.
index 32d02a7179c5dc965da87550d018973b83ad0f11..f2600a97355d7dc5522cb57693c84550ff1a7ed1 100644 (file)
@@ -9,7 +9,7 @@
 # Contributors:
 #     VTT Technical Research Centre of Finland - initial API and implementation
 ###############################################################################
-LayersView_noLayers=No roles available.
+LayersView_noLayers=No layers available.
 LayersView_noProfiles=No profiles available.
 GroupsView_noGroups=No groups available.
 StylesView_noStyles=No styles available.
index 33df689be4014e48665683f1f59209cc22c1b011..2f25b84a93dadd73b91a537e0e29b0832deb9d87 100644 (file)
@@ -32,16 +32,19 @@ public class GraphLayer {
 
     private final Resource layer;
     
+    private boolean active;
+    
     private final Map<String, Resource> tags;
 
-    public GraphLayer(String name, Resource layer, Map<String, Resource> tags) {
+    public GraphLayer(String name, Resource layer, Map<String, Resource> tags, boolean active) {
         this.name = name;
         this.layer = layer;
         this.tags = tags;
+        this.active = active;
     }
 
     public GraphLayer withName(String name) {
-        return new GraphLayer(name, layer, tags);
+        return new GraphLayer(name, layer, tags, active);
     }
 
     public String getName() {
@@ -59,6 +62,10 @@ public class GraphLayer {
     public Resource getFocusable() {
         return tags.get(PROP_FOCUSABLE);
     }
+    
+    public boolean isActive() {
+        return active;
+    }
 
     public ILayer getILayer() {
         return new SimpleLayer(name);
@@ -73,4 +80,44 @@ public class GraphLayer {
             consumer.accept(r);
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (active ? 1231 : 1237);
+        result = prime * result + ((layer == null) ? 0 : layer.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((tags == null) ? 0 : tags.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        GraphLayer other = (GraphLayer) obj;
+        if (active != other.active)
+            return false;
+        if (layer == null) {
+            if (other.layer != null)
+                return false;
+        } else if (!layer.equals(other.layer))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (tags == null) {
+            if (other.tags != null)
+                return false;
+        } else if (!tags.equals(other.tags))
+            return false;
+        return true;
+    }
+
 }
\ No newline at end of file
index e92ce1b41da779df96b1d08359241a7b959fa6b1..79e79a2174033c7cf67fe3b2a21f4eac294b0bdd 100644 (file)
@@ -25,10 +25,12 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
+import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.exception.CancelTransactionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ServiceException;
 import org.simantics.db.procedure.AsyncProcedure;
+import org.simantics.db.procedure.Listener;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.diagram.synchronization.IModificationQueue;
 import org.simantics.diagram.synchronization.ModificationAdapter;
@@ -131,6 +133,8 @@ public class GraphLayerManager {
      */
     LayerListener                     layerListener = new LayerListener();
 
+    boolean disposed = false;
+
     public GraphLayerManager(ReadGraph graph, IModificationQueue modificationQueue, Resource diagram) {
         this.modificationQueue = modificationQueue;
         this.diagram = diagram;
@@ -145,6 +149,7 @@ public class GraphLayerManager {
             }
         }
         layers.clear();
+        disposed = true;
     }
 
     Resource getDiagramResource() {
@@ -295,69 +300,96 @@ public class GraphLayerManager {
 
     public ILayersEditor loadLayers(IDiagram diagram, ReadGraph g, Resource diagramResource) throws DatabaseException {
         
-        SimpleLayers result = new SimpleLayers();
-        ConcurrentMap<String, GraphLayer> newLayers = new ConcurrentHashMap<String, GraphLayer>();
-
+        layerEditor = new SimpleLayers();
+        layerEditor.addLayerEditorListener(layerListener);
+        
         String[] fixed = diagram.getHint(DiagramHints.KEY_FIXED_LAYERS);
-        if (fixed != null) {
 
-//            for (String name : fixed) {
-//                SimpleLayer l = new SimpleLayer(name);
-//                result.addLayer(l);
-//                result.activate(l);
-//            }
+        g.syncRequest(new ResourceRead<LayersSpec>(diagramResource) {
 
-            // We need to put GraphLayer to newLayers so...
-            for (Resource layer : g.getObjects(diagramResource, dia.HasLayer)) {
-                IGraphLayerUtil layerUtil = g.adapt(g.getSingleObject(layer, Layer0.getInstance(g).InstanceOf), IGraphLayerUtil.class);
-                
-                GraphLayer gl = layerUtil.loadLayer(g, layer);
-                for (String name : fixed) {
-                    if (name.equals(gl.getName())) {
-                        ILayer l = gl.getILayer();
-                        newLayers.put(gl.getName(), gl);
-                        result.addLayer(l);
-                        result.activate(l);
-                    }
+            @Override
+            public LayersSpec perform(ReadGraph g) throws DatabaseException {
+                Collection<GraphLayer> gls = new ArrayList<>();
+                for (Resource layer : g.getObjects(resource, dia.HasLayer)) {
+                    IGraphLayerUtil layerUtil = g.adapt(g.getSingleObject(layer, Layer0.getInstance(g).InstanceOf), IGraphLayerUtil.class);
+                    GraphLayer gl = layerUtil.loadLayer(g, layer);
+                    gls.add(gl);
                 }
+                return new LayersSpec(gls);
             }
+            
+        }, new Listener<LayersSpec>() {
 
-        } else {
+            @Override
+            public void execute(LayersSpec layersSpec) {
+                ConcurrentMap<String, GraphLayer> newLayers = new ConcurrentHashMap<String, GraphLayer>();
+                Set<ILayer> visibleLayers = new HashSet<>();
+                Set<ILayer> allLayers = new HashSet<>();
+                
+                if (fixed != null) {
+                    for (GraphLayer gl : layersSpec.getGraphLayers()) {
+                        for (String name : fixed) {
+                            if (name.equals(gl.getName())) {
+                                ILayer l = gl.getILayer();
+                                newLayers.put(gl.getName(), gl);
+                                allLayers.add(l);
+                                visibleLayers.add(l);
+                            }
+                        }  
+                    }
+                    
+                } else {
 
-            if (DEBUG_LAYERS)
-                System.out.println("Loading layers");
+                    if (DEBUG_LAYERS)
+                        System.out.println("Loading layers");
+
+                    for (GraphLayer gl : layersSpec.getGraphLayers()) {
+                        ILayer l = gl.getILayer();
 
-            for (Resource layer : g.getObjects(diagramResource, dia.HasLayer)) {
-                IGraphLayerUtil layerUtil = g.adapt(g.getSingleObject(layer, Layer0.getInstance(g).InstanceOf), IGraphLayerUtil.class);
-                GraphLayer gl = layerUtil.loadLayer(g, layer);
-                ILayer l = gl.getILayer();
+                        newLayers.put(gl.getName(), gl);
+
+                        if (DEBUG_LAYERS)
+                            System.out.println("    Loaded " + (gl.isActive() ? "active" : "inactive") + " layer '" + gl.getName() + "'");
 
-                newLayers.put(gl.getName(), gl);
-                result.addLayer(l);
+                        if (l instanceof IEditableLayer)
+                            ((IEditableLayer) l).addLayerListener(layerListener);
 
-                Boolean active = g.getPossibleRelatedValue(layer, dia.IsActive);
-                if (active == null)
-                    active = Boolean.FALSE;
+                        allLayers.add(l);
+                        if (gl.isActive())
+                            visibleLayers.add(l);
+                        
+                    }
+                }
+                // Show all and focus all by default if there are no layers
+                
+                
+                if (newLayers.isEmpty()) {
+                    layerEditor.setIgnoreVisibilitySettings(true);
+                    layerEditor.setIgnoreFocusSettings(true);
+                }
 
                 if (DEBUG_LAYERS)
-                    System.out.println("    Loaded " + (active ? "active" : "inactive") + " layer '" + gl.getName() + "'");
+                    System.out.println("Loaded " + newLayers.size() + " layers");
 
-                if (l instanceof IEditableLayer)
-                    ((IEditableLayer) l).addLayerListener(layerListener);
-                if (active)
-                    result.activate(l);
+                layerEditor.update(allLayers, visibleLayers);
+                
+                layers = newLayers;
             }
 
-            if (DEBUG_LAYERS)
-                System.out.println("Loaded " + newLayers.size() + " layers");
+            @Override
+            public void exception(Throwable t) {
+                t.printStackTrace();
+            }
 
-        }
+            @Override
+            public boolean isDisposed() {
+                return disposed;
+            }
+            
+        });
 
-        this.layers = newLayers;
-        this.layerEditor = result;
-        this.layerEditor.addListener(layerListener);
 
-        return result;
+        return layerEditor;
     }
 
     public void loadLayersForElement(ReadGraph graph, ILayersEditor layersEditor, IElement e, Resource element)
@@ -406,7 +438,7 @@ public class GraphLayerManager {
      *        many times depending on how many errors occur during layer loading
      * @throws DatabaseException
      */
-    public void loadLayersForElement(AsyncReadGraph graph, ILayersEditor layersEditor, final IElement e,
+    public void loadLayersForElement(AsyncReadGraph graph, ILayers layers2, final IElement e,
             Resource element, final AsyncProcedure<IElement> callback) {
         if (DEBUG_LAYERS)
             System.out.println("Loading layers for element " + element + " - " + e);
@@ -417,7 +449,7 @@ public class GraphLayerManager {
         // NOTE: must not set layer hints into element until the layer sets have
         // been properly loaded.
 
-        Set<ILayer> allLayers = layersEditor.getLayers();
+        Set<ILayer> allLayers = layers2.getLayers();
         if (allLayers.isEmpty()) {
             e.setHint(ElementHints.KEY_VISIBLE_LAYERS, visible);
             e.setHint(ElementHints.KEY_FOCUS_LAYERS, focusable);
index 370345f4f2ac87cf1b8fcdf90315e6dac78bf3b1..43b7fe117f605f6688957715bfb52fe80387cbba 100644 (file)
@@ -59,7 +59,7 @@ public final class GraphLayerUtil implements IGraphLayerUtil {
         properties.put(GraphLayer.PROP_FOCUSABLE, focusableTag);
         properties.put(GraphLayer.PROP_VISIBLE, visibleTag);
         
-        return new GraphLayer(layerName, layer, properties);
+        return new GraphLayer(layerName, layer, properties, active);
     }
 
     public static Resource newTag(WriteGraph graph, Layer0 L0, Resource baseTag) throws DatabaseException {
@@ -80,12 +80,25 @@ public final class GraphLayerUtil implements IGraphLayerUtil {
         String name = graph.getRelatedValue(layer, L0.HasName);
         Resource visible = graph.getSingleObject(layer, DIA.HasVisibleTag);
         Resource focusable = graph.getSingleObject(layer, DIA.HasFocusableTag);
-        
+        boolean active = graph.getRelatedValue(layer, DIA.IsActive);
         Map<String, Resource> properties = new HashMap<>();
         properties.put(GraphLayer.PROP_FOCUSABLE, focusable);
         properties.put(GraphLayer.PROP_VISIBLE, visible);
 
-        return new GraphLayer(name, layer, properties);
+        return new GraphLayer(name, layer, properties, active);
+    }
+    
+    public static void addToVisibleLayers(WriteGraph graph, Resource element, Resource diagram) throws DatabaseException {
+        DiagramResource DIA = DiagramResource.getInstance(graph);
+        for (Resource layer : graph.getObjects(diagram, DIA.HasLayer)) {
+            boolean active = graph.getRelatedValue(layer, DIA.IsActive);
+            if (active) {
+                Resource visibleTag = graph.getSingleObject(layer, DIA.HasVisibleTag);
+                Resource focusableTag = graph.getSingleObject(layer, DIA.HasFocusableTag);
+                graph.claim(element, visibleTag, element);
+                graph.claim(element, focusableTag, element);
+            }
+        }
     }
 
 }
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/layer/LayersSpec.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/layer/LayersSpec.java
new file mode 100644 (file)
index 0000000..42bd7cc
--- /dev/null
@@ -0,0 +1,41 @@
+package org.simantics.diagram.synchronization.graph.layer;
+
+import java.util.Collection;
+
+public class LayersSpec {
+    private Collection<GraphLayer> graphLayers;
+
+    public LayersSpec(Collection<GraphLayer> gls) {
+        this.graphLayers = gls;
+    }
+
+    public Collection<GraphLayer> getGraphLayers() {
+        return graphLayers;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((graphLayers == null) ? 0 : graphLayers.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        LayersSpec other = (LayersSpec) obj;
+        if (graphLayers == null) {
+            if (other.graphLayers != null)
+                return false;
+        } else if (!graphLayers.equals(other.graphLayers))
+            return false;
+        return true;
+    }
+
+}
index 9134c1729ac161c7ec4d9bcb927880da9612b8dd..a8fee9582aa61e520faa86d5c122ca06f8b284cb 100644 (file)
@@ -61,6 +61,7 @@ import org.simantics.g2d.element.handler.BendsHandler;
 import org.simantics.g2d.element.handler.Children;
 import org.simantics.g2d.element.handler.Children.ChildEvent;
 import org.simantics.g2d.element.handler.Children.ChildListener;
+import org.simantics.g2d.element.handler.ElementLayers;
 import org.simantics.g2d.element.handler.FillColor;
 import org.simantics.g2d.element.handler.Outline;
 import org.simantics.g2d.element.handler.OutlineColorSpec;
@@ -71,9 +72,9 @@ import org.simantics.g2d.element.handler.SelectionSpecification;
 import org.simantics.g2d.element.handler.StrokeSpec;
 import org.simantics.g2d.element.handler.TerminalTopology;
 import org.simantics.g2d.element.handler.Transform;
-import org.simantics.g2d.layers.ILayer;
+import org.simantics.g2d.layers.ILayers;
+import org.simantics.g2d.layers.ILayers.ILayersListener;
 import org.simantics.g2d.layers.ILayersEditor;
-import org.simantics.g2d.layers.ILayersEditor.ILayersEditorListener;
 import org.simantics.g2d.participant.TransformUtil;
 import org.simantics.g2d.scenegraph.SceneGraphConstants;
 import org.simantics.g2d.utils.ElementNodeBridge;
@@ -213,9 +214,9 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
             oldValue.removeKeyHintListener(Hints.KEY_DIRTY, diagramHintListener);
             oldValue.removeKeyHintListener(Hints.KEY_DISABLE_PAINTING, diagramHintListener);
 
-            ILayersEditor layers = oldValue.getHint(DiagramHints.KEY_LAYERS_EDITOR);
+            ILayers layers = oldValue.getHint(DiagramHints.KEY_LAYERS);
             if (layers != null) {
-                layers.removeListener(layersListener);
+                layers.removeLayersListener(layersListener);
             }
 
             for (TransactionContext tc : oldValue.getDiagramClass().getItemsByClass(TransactionContext.class)) {
@@ -237,9 +238,9 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
             newValue.addKeyHintListener(Hints.KEY_DISABLE_PAINTING, diagramHintListener);
             newValue.addKeyHintListener(Hints.KEY_DIRTY, diagramHintListener);
 
-            ILayersEditor layers = newValue.getHint(DiagramHints.KEY_LAYERS_EDITOR);
+            ILayers layers = newValue.getHint(DiagramHints.KEY_LAYERS);
             if (layers != null) {
-                layers.addListener(layersListener);
+                layers.addLayersListener(layersListener);
             }
 
             for (TransactionContext tc : newValue.getDiagramClass().getItemsByClass(TransactionContext.class)) {
@@ -302,41 +303,21 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
     // Layer configuration change listening and reaction logic
     // ------------------------------------------------------------------------
 
-    ILayersEditorListener layersListener = new ILayersEditorListener() {
-        private void layersChanged() {
+    ILayersListener layersListener = new ILayersListener() {
+        @Override
+        public void changed() {
             Object task = BEGIN("EP.layersChanged");
-            // Update visibility/focusability for each node only, do not reinitialize the graphics.
+            ICanvasContext ctx = getContext();
+            if(ctx != null) {
+                G2DSceneGraph sg = ctx.getSceneGraph();
+                if(sg != null) {
+                    ILayersEditor layers = diagram.getHint(DiagramHints.KEY_LAYERS);
+                    sg.setGlobalProperty(G2DSceneGraph.IGNORE_FOCUS, layers.getIgnoreFocusSettings());
+                }
+            }
             updateAllVisibility();
             END(task);
         }
-        @Override
-        public void layerRemoved(ILayer layer) {
-            layersChanged();
-        }
-        @Override
-        public void layerDeactivated(ILayer layer) {
-            layersChanged();
-        }
-        @Override
-        public void layerAdded(ILayer layer) {
-            layersChanged();
-        }
-        @Override
-        public void layerActivated(ILayer layer) {
-            layersChanged();
-        }
-        @Override
-        public void ignoreFocusChanged(boolean value) {
-               ICanvasContext ctx = getContext();
-               if(ctx == null) return;
-               G2DSceneGraph sg = ctx.getSceneGraph();
-               if(sg == null) return;
-               sg.setGlobalProperty(G2DSceneGraph.IGNORE_FOCUS, value);
-        }
-        @Override
-        public void ignoreVisibilityChanged(boolean value) {
-            layersChanged();
-        }
     };
 
     protected void updateAllVisibility() {
@@ -405,11 +386,17 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
                 }
             } else if (key == ElementHints.KEY_FOCUS_LAYERS || key == ElementHints.KEY_VISIBLE_LAYERS) {
                 if (sender instanceof IElement) {
-                    assert getContext().getThreadAccess().currentThreadAccess();
-                    IElement e = (IElement) sender;
-                    Object task = BEGIN("layers changed: " + e);
-                    update(e);
-                    END(task);
+                    getContext().getThreadAccess().asyncExec(new Runnable() {
+
+                        @Override
+                        public void run() {
+                            assert getContext().getThreadAccess().currentThreadAccess();
+                            IElement e = (IElement) sender;
+                            Object task = BEGIN("layers changed: " + e);
+                            update(e);
+                            END(task);
+                        }
+                    });
                 }
             }
         }
@@ -775,14 +762,6 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
             if (ElementUtils.isHidden(e))
                 return null;
 
-//            ElementClass ec = e.getElementClass();
-//            ILayers layers = diagram.getHint(DiagramHints.KEY_LAYERS);
-//            if (layers != null && !layers.getIgnoreVisibilitySettings()) {
-//                ElementLayers el = ec.getAtMostOneItemOfClass(ElementLayers.class);
-//                if (el != null && !el.isVisible(e, layers)) {
-//                    return null;
-//                }
-//            }
 
             // Update the node scene graph through SceneGraph handlers.
             List<SceneGraph> nodeHandlers = e.getElementClass().getItemsByClass(SceneGraph.class);
@@ -797,7 +776,16 @@ public class ElementPainter extends AbstractDiagramParticipant implements Compos
                 e.setHint(elementSgNodeKey, holder);
             }
             holder.setComposite(composite);
-            holder.setVisible(true);
+            boolean visible = true;
+            ElementClass ec = e.getElementClass();
+            ILayers layers = diagram.getHint(DiagramHints.KEY_LAYERS);
+            if (layers != null && !layers.getIgnoreVisibilitySettings()) {
+                ElementLayers el = ec.getAtMostOneItemOfClass(ElementLayers.class);
+                if (el != null && !el.isVisible(e, layers)) {
+                    visible = false;
+                }
+            }
+            holder.setVisible(visible);
 
             for (SceneGraph n : nodeHandlers) {
                 n.init(e, holder);
index c7aa7872da2a7e21d94f80ed4e411f4d91fa0c49..ebdbdfa74a714cf99eb424e14e44b5fa8423db4c 100644 (file)
@@ -16,14 +16,18 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import org.simantics.g2d.canvas.impl.AbstractCanvasParticipant;
 import org.simantics.g2d.diagram.DiagramHints;
 import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.element.ElementClass;
 import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.ElementLayers;
+import org.simantics.g2d.layers.ILayers;
 import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
 import org.simantics.scenegraph.g2d.events.command.CommandEvent;
 import org.simantics.scenegraph.g2d.events.command.Commands;
@@ -62,7 +66,7 @@ public class Selection extends AbstractCanvasParticipant {
         if (e.command.equals( Commands.SELECT_ALL )) {
             IDiagram d = getHint( DiagramHints.KEY_DIAGRAM );
             if (d==null) return true;
-            addAll(0, d.getElements());
+            addAll(0, filterSelectionByLayers(d, d.getElements()));
             return true;
         }
         if (e.command.equals( Commands.INVERT_SELECTION )) {
@@ -71,12 +75,28 @@ public class Selection extends AbstractCanvasParticipant {
             Set<IElement> current = getSelection(0);
             Set<IElement> inverted = new HashSet<IElement>(d.getElements());
             inverted.removeAll(current);
-            setSelection(0, inverted);
+            setSelection(0, filterSelectionByLayers(d, inverted));
             return true;
         }
         return false;
     }
 
+    private static Collection<IElement> filterSelectionByLayers(IDiagram diagram, Collection<IElement> elements) {
+        ILayers layers = diagram.getHint(DiagramHints.KEY_LAYERS);
+        if (layers != null && !layers.getIgnoreFocusSettings()) {
+            List<IElement> filteredElements = new ArrayList<IElement>();
+            for (IElement element : elements) {
+                ElementClass ec = element.getElementClass();
+                ElementLayers el = ec.getAtMostOneItemOfClass(ElementLayers.class);
+                if (el == null || el.isFocusable(element, layers)) {
+                    filteredElements.add(element);
+                }
+            }
+            return filteredElements;
+        } else {
+            return elements;
+        }
+    }
 
     /**
      * Get selection
index 650bc556fd51c7aee5e978766eac43ab19e705a1..9edf28d4128ec768fa4b1d88963905163a0babb7 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.g2d.element.handler;
 
+import java.util.Collection;
+
 import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.layers.ILayer;
 import org.simantics.g2d.layers.ILayers;
index e7d3dd4c4ae5d4feca5de762564f6e791a769fd5..d62e85b800f3ea77233d2e91f22d7797b5df5755 100644 (file)
@@ -33,10 +33,10 @@ public class SimpleElementLayers implements ElementLayers {
     @Override
     public boolean isVisible(IElement e, ILayers layers) {
 
-        assert(e != null);
-        assert(layers != null);
+        assert (e != null);
+        assert (layers != null);
 
-        Set<ILayer> elementLayers = (Set<ILayer>)e.getHint(ElementHints.KEY_VISIBLE_LAYERS);
+        Set<ILayer> elementLayers = (Set<ILayer>) e.getHint(ElementHints.KEY_VISIBLE_LAYERS);
         if (elementLayers == null)
             return true;
 
@@ -47,7 +47,7 @@ public class SimpleElementLayers implements ElementLayers {
     @Override
     public boolean isVisible(IElement e, ILayer layer) {
 
-        Set<ILayer> elementLayers = (Set<ILayer>)e.getHint(ElementHints.KEY_VISIBLE_LAYERS);
+        Set<ILayer> elementLayers = (Set<ILayer>) e.getHint(ElementHints.KEY_VISIBLE_LAYERS);
         if (elementLayers == null)
             return true;
 
@@ -62,10 +62,10 @@ public class SimpleElementLayers implements ElementLayers {
     @Override
     public boolean isFocusable(IElement e, ILayers layers) {
 
-        assert(e != null);
-        assert(layers != null);
+        assert (e != null);
+        assert (layers != null);
 
-        Set<ILayer> elementLayers = (Set<ILayer>)e.getHint(ElementHints.KEY_FOCUS_LAYERS);
+        Set<ILayer> elementLayers = (Set<ILayer>) e.getHint(ElementHints.KEY_FOCUS_LAYERS);
         if (elementLayers == null)
             return true;
 
@@ -76,7 +76,7 @@ public class SimpleElementLayers implements ElementLayers {
     @Override
     public boolean isFocusable(IElement e, ILayer layer) {
 
-        Set<ILayer> elementLayers = (Set<ILayer>)e.getHint(ElementHints.KEY_FOCUS_LAYERS);
+        Set<ILayer> elementLayers = (Set<ILayer>) e.getHint(ElementHints.KEY_FOCUS_LAYERS);
         if (elementLayers == null)
             return true;
 
@@ -87,12 +87,14 @@ public class SimpleElementLayers implements ElementLayers {
     @Override
     public boolean setVisibility(IElement e, ILayer layer, boolean value) {
 
-        Set<ILayer> elementLayers = (Set<ILayer>)e.getHint(ElementHints.KEY_VISIBLE_LAYERS);
+        Set<ILayer> elementLayers = (Set<ILayer>) e.getHint(ElementHints.KEY_VISIBLE_LAYERS);
         if (elementLayers == null)
             return false;
         boolean result;
-        if (value) result = elementLayers.add(layer);
-        else result = elementLayers.remove(layer);
+        if (value)
+            result = elementLayers.add(layer);
+        else
+            result = elementLayers.remove(layer);
 
         if (result) {
             for (ElementLayerListener ell : e.getElementClass().getItemsByClass(ElementLayerListener.class)) {
@@ -106,12 +108,14 @@ public class SimpleElementLayers implements ElementLayers {
     @Override
     public boolean setFocusability(IElement e, ILayer layer, boolean value) {
 
-        Set<ILayer> elementLayers = (Set<ILayer>)e.getHint(ElementHints.KEY_FOCUS_LAYERS);
+        Set<ILayer> elementLayers = (Set<ILayer>) e.getHint(ElementHints.KEY_FOCUS_LAYERS);
         if (elementLayers == null)
             return false;
         boolean result;
-        if(value) result = elementLayers.add(layer);
-        else result = elementLayers.remove(layer);
+        if (value)
+            result = elementLayers.add(layer);
+        else
+            result = elementLayers.remove(layer);
 
         if (result) {
             for (ElementLayerListener ell : e.getElementClass().getItemsByClass(ElementLayerListener.class)) {
index 7c60894bc9a9c85ec3ffd685c6ec3b32db8fb7d6..10dd267d6544f1b7b33c4fec26b13e9bc659d72b 100644 (file)
@@ -311,7 +311,8 @@ public class FlagClass {
                 TextImpl.INSTANCE,
                 FlagTerminalTopology.DEFAULT,
                 FlagSceneGraph.INSTANCE,
-                DEFAULT_STATIC_SYMBOL
+                DEFAULT_STATIC_SYMBOL,
+                SimpleElementLayers.INSTANCE
         ).setId(FlagClass.class.getSimpleName());
 
     public static ElementClass create(Terminal terminal) {
index 5aa435920a3ee2c0ca5ac4e54b4eff8b825fe575..8da74b64c621bfb11d693424b255547fd46dabf0 100644 (file)
@@ -35,6 +35,7 @@ import org.simantics.g2d.element.handler.SelectionOutline;
 import org.simantics.g2d.element.handler.impl.ConfigurableEdgeVisuals;
 import org.simantics.g2d.element.handler.impl.ConnectionSelectionOutline;
 import org.simantics.g2d.element.handler.impl.FillColorImpl;
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;
 import org.simantics.g2d.element.handler.impl.TextImpl;
 import org.simantics.g2d.elementclass.connection.EdgeClass.FixedTransform;
 import org.simantics.scenegraph.g2d.G2DParentNode;
@@ -70,7 +71,7 @@ public class RouteGraphConnectionClass {
                 ConnectionSelectionOutline.INSTANCE,
                 ConnectionHandlerImpl.INSTANCE,
                 ConnectionSceneGraph.INSTANCE,
-                //SimpleElementLayers.INSTANCE,
+                SimpleElementLayers.INSTANCE,
 
                 // Exists only loading connection visuals through ConnectionVisualsLoader
                 ConfigurableEdgeVisuals.DEFAULT,
index 618f155382c458acfd0a6e4147826a0d8f838d0b..72f25e7cbec6422ee74528e66e988d48c6d03c87 100644 (file)
@@ -25,4 +25,10 @@ public interface ILayers {
        boolean getIgnoreFocusSettings();
        boolean getIgnoreVisibilitySettings();
 
+    void addLayersListener(ILayersListener listener);
+    void removeLayersListener(ILayersListener listener);
+
+    public interface ILayersListener {
+        void changed();
+    }
 }
index a5c892b5bc5b41d566fc573ce5c1aeb3e16567d6..5113ac7775eb567a2d4e09dbd1900e365fffc4cb 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/
 package org.simantics.g2d.layers;
 
+import java.util.Set;
 
 /**
  * @author Antti Villberg
@@ -33,8 +34,8 @@ public interface ILayersEditor extends ILayers {
     void setIgnoreFocusSettings(boolean value);
     void setIgnoreVisibilitySettings(boolean value);
 
-    void addListener(ILayersEditorListener listener);
-    void removeListener(ILayersEditorListener listener);
+    void addLayerEditorListener(ILayersEditorListener listener);
+    void removeLayerEditorListener(ILayersEditorListener listener);
 
     void addLayer(ILayer layer);
     void removeLayer(ILayer layer);
@@ -42,4 +43,5 @@ public interface ILayersEditor extends ILayers {
     void activate(ILayer layer);
     void deactivate(ILayer layer);
 
+    void update(Set<ILayer> allLayers, Set<ILayer> visibleLayers);
 }
index f250449a41e5ea352198c5a097565ce35cb8a94d..43c52099cc86251b800298c9a4a4369bb52bff07 100644 (file)
@@ -17,6 +17,8 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import org.simantics.utils.strings.AlphanumComparator;
+
 /**
  * @author Antti Villberg
  */
@@ -25,7 +27,7 @@ public class SimpleLayers implements ILayersEditor {
     private static final Comparator<ILayer> LAYER_COMPARATOR = new Comparator<ILayer>() {
         @Override
         public int compare(ILayer o1, ILayer o2) {
-            return o1.getName().compareTo(o2.getName());
+            return AlphanumComparator.COMPARATOR.compare(o1.getName(), o2.getName());
         }
     };
 
@@ -35,7 +37,8 @@ public class SimpleLayers implements ILayersEditor {
     private Set<ILayer>                                 visible                  = new TreeSet<ILayer>(LAYER_COMPARATOR);
     private volatile Set<ILayer>                        visibleSnapshot;
 
-    private CopyOnWriteArrayList<ILayersEditorListener> listeners                = new CopyOnWriteArrayList<ILayersEditorListener>();
+    private CopyOnWriteArrayList<ILayersEditorListener> layerEditorListeners     = new CopyOnWriteArrayList<ILayersEditorListener>();
+    private CopyOnWriteArrayList<ILayersListener>       layersListeners          = new CopyOnWriteArrayList<ILayersListener>();
 
     private boolean                                     ignoreFocusSettings      = false;
 
@@ -50,8 +53,21 @@ public class SimpleLayers implements ILayersEditor {
             all.add(layer);
             visible.add(layer);
         }
-        allSnapshot = null;
-        visibleSnapshot = null;
+    }
+    
+    @Override
+    public void update(Set<ILayer> allLayers, Set<ILayer> visibleLayers) {
+        synchronized (this) {
+            all.clear();
+            all.addAll(allLayers);
+            visible.clear();
+            visible.addAll(visibleLayers);
+            allSnapshot = null;
+            visibleSnapshot = null;
+        }
+        for (ILayersListener listener : layersListeners) {
+            listener.changed();
+        }
     }
 
     @Override
@@ -105,7 +121,10 @@ public class SimpleLayers implements ILayersEditor {
             synchronized (this) {
                 visibleSnapshot = null;
             }
-            for (ILayersEditorListener listener : listeners) {
+            for (ILayersListener listener : layersListeners) {
+                listener.changed();
+            }
+            for (ILayersEditorListener listener : layerEditorListeners) {
                 listener.layerDeactivated(layer);
             }
         }
@@ -121,7 +140,10 @@ public class SimpleLayers implements ILayersEditor {
             synchronized (this) {
                 visibleSnapshot = null;
             }
-            for (ILayersEditorListener listener : listeners) {
+            for (ILayersListener listener : layersListeners) {
+                listener.changed();
+            }
+            for (ILayersEditorListener listener : layerEditorListeners) {
                 listener.layerActivated(layer);
             }
         }
@@ -137,7 +159,10 @@ public class SimpleLayers implements ILayersEditor {
             synchronized (this) {
                 allSnapshot = null;
             }
-            for (ILayersEditorListener listener : listeners) {
+            for (ILayersListener listener : layersListeners) {
+                listener.changed();
+            }
+            for (ILayersEditorListener listener : layerEditorListeners) {
                 listener.layerAdded(layer);
             }
         }
@@ -155,20 +180,33 @@ public class SimpleLayers implements ILayersEditor {
                 allSnapshot = null;
                 visibleSnapshot = null;
             }
-            for (ILayersEditorListener listener : listeners) {
+            for (ILayersListener listener : layersListeners) {
+                listener.changed();
+            }
+            for (ILayersEditorListener listener : layerEditorListeners) {
                 listener.layerRemoved(layer);
             }
         }
     }
 
     @Override
-    public void addListener(ILayersEditorListener listener) {
-        listeners.add(listener);
+    public void addLayerEditorListener(ILayersEditorListener listener) {
+        layerEditorListeners.add(listener);
     }
 
     @Override
-    public void removeListener(ILayersEditorListener listener) {
-        listeners.remove(listener);
+    public void removeLayerEditorListener(ILayersEditorListener listener) {
+        layerEditorListeners.remove(listener);
+    }
+
+    @Override
+    public void addLayersListener(ILayersListener listener) {
+        layersListeners.add(listener);
+    }
+
+    @Override
+    public void removeLayersListener(ILayersListener listener) {
+        layersListeners.remove(listener);
     }
 
     @Override
@@ -181,7 +219,10 @@ public class SimpleLayers implements ILayersEditor {
         boolean changed = ignoreFocusSettings != value;
         ignoreFocusSettings = value;
         if (changed) {
-            for (ILayersEditorListener listener : listeners) {
+            for (ILayersListener listener : layersListeners) {
+                listener.changed();
+            }
+            for (ILayersEditorListener listener : layerEditorListeners) {
                 listener.ignoreFocusChanged(value);
             }
         }
@@ -197,7 +238,10 @@ public class SimpleLayers implements ILayersEditor {
         boolean changed = ignoreVisibilitySettings != value;
         ignoreVisibilitySettings = value;
         if (changed) {
-            for (ILayersEditorListener listener : listeners) {
+            for (ILayersListener listener : layersListeners) {
+                listener.changed();
+            }
+            for (ILayersEditorListener listener : layerEditorListeners) {
                 listener.ignoreVisibilityChanged(value);
             }
         }
index 6441cdd4c1e280ff2135eeba19d89464e14b0303..306f98890bbfefd3ecb5756b7f491069cfd61efc 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.g2d.diagram.DiagramHints;
 import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.layers.ILayers;
 import org.simantics.g2d.layers.ILayersEditor;
 import org.simantics.modeling.ui.Activator;
 import org.simantics.modeling.ui.diagramEditor.DiagramEditor;
@@ -54,7 +55,7 @@ public class SetFocusabilityContribution extends DynamicMenuContribution impleme
             IDiagram diagram = (IDiagram) editor.getAdapter(IDiagram.class);
             if (diagram == null)
                 return NO_OBJECTS;
-            ILayersEditor le = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);
+            ILayers le = diagram.getHint(DiagramHints.KEY_LAYERS);
             if (le == null)
                 return NO_OBJECTS;
             return new Object[] { le, le.getIgnoreFocusSettings() };
index 75d3050b9cd91689c5d136ed82868bd20808fd5f..ab9eb2f946ba6eb84c940e8995e91d43266b8f10 100644 (file)
@@ -24,12 +24,14 @@ import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
+import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.util.EvaluatingListener;
 import org.simantics.db.layer0.util.EvaluatingListener.Evaluation;
 import org.simantics.db.layer0.variable.RVI;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.procedure.AsyncProcedure;
+import org.simantics.diagram.adapter.ElementFactoryUtil;
 import org.simantics.diagram.adapter.SyncElementFactory;
 import org.simantics.diagram.content.ConnectionUtil;
 import org.simantics.diagram.elements.MonitorClass;
@@ -94,6 +96,14 @@ public class MonitorClassFactory2 extends SyncElementFactory {
         procedure.execute(graph, createMonitorClass(elementType));
     }
 
+    @Override
+    public void load(AsyncReadGraph graph, final ICanvasContext canvas, final IDiagram diagram,
+            final Resource elementResource, final IElement element, final AsyncProcedure<IElement> procedure) {
+        GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 2);
+        super.load(graph, canvas, diagram, elementResource, element, guard);
+        ElementFactoryUtil.loadLayersForElement(graph, diagram, element, elementResource, guard);
+    }
+
     @Override
     public void load(ReadGraph graph, final ICanvasContext canvas, final IDiagram diagram, final Resource element, final IElement e) throws DatabaseException {
         if (!graph.hasStatement(element))
index 895c4bfa25e1afc89b97023ed5c99e36e903b99e..87e18ed8e3a9b7818edb33bed324e6cbe58b7dc2 100644 (file)
@@ -61,36 +61,36 @@ import org.simantics.g2d.element.handler.ElementLayers;
 import org.simantics.g2d.layers.IEditableLayer;
 import org.simantics.g2d.layers.ILayer;
 import org.simantics.g2d.layers.ILayers;
+import org.simantics.g2d.layers.ILayers.ILayersListener;
 import org.simantics.g2d.layers.ILayersEditor;
 import org.simantics.g2d.layers.SimpleLayer;
-import org.simantics.g2d.layers.ILayersEditor.ILayersEditorListener;
 import org.simantics.utils.datastructures.Arrays;
+import org.simantics.utils.datastructures.disposable.IDisposable;
+import org.simantics.utils.datastructures.disposable.IDisposeListener;
 import org.simantics.utils.datastructures.hints.HintListenerAdapter;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintListener;
 import org.simantics.utils.datastructures.hints.IHintObservable;
-import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.ui.ISelectionUtils;
 
 public class DiagramLayersPage extends Page implements ILayersViewPage {
 
-    private static final String TEXT_APPLY_FOCUS_SETTINGS = Messages.DiagramLayersPage_FocusActive;
-    private static final String TOOLTIP_APPLY_FOCUS_SETTINGS = Messages.DiagramLayersPage_FocusActiveTT;
     private static final String TEXT_IGNORE_FOCUS_SETTINGS = Messages.DiagramLayersPage_FocusAll;
     private static final String TOOLTIP_IGNORE_FOCUS_SETTINGS = Messages.DiagramLayersPage_FocusAllTT;
 
-    private static final String TEXT_APPLY_VISIBILITY_SETTINGS = Messages.DiagramLayersPage_ShowActive;
-    private static final String TOOLTIP_APPLY_VISIBILITY_SETTINGS = Messages.DiagramLayersPage_ShowActiveTT;
     private static final String TEXT_IGNORE_VISIBILITY_SETTINGS = Messages.DiagramLayersPage_ShowAll;
     private static final String TOOLTIP_IGNORE_VISIBILITY_SETTINGS = Messages.DiagramLayersPage_ShowAllTT;
 
     final private ICanvasContext context;
-    final private IDiagram diagram;
     private CheckboxTreeViewer viewer;
+    private Button ignoreVisibilityButton;
+    private Button ignoreFocusButton;
     private Composite composite;
     private TreeEditor editor;
 
     private Collection<IElement> elements = Collections.emptySet();
-
+    private ILayersEditor layers;
+    
     enum Attribute {
         Visible,
         Focusable
@@ -227,82 +227,128 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
         }
 
         private void redraw() {
-            viewer.getControl().getDisplay().asyncExec(new Runnable() {
+            if (viewer != null) {
+                viewer.getControl().getDisplay().asyncExec(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (viewer.getControl().isDisposed())
+                            return;
+                        viewer.getControl().redraw();
+                    }
+                });
+            }
+        }
+    };
+    
+    final private IDisposeListener contextDisposeListener = new IDisposeListener() {
+
+        @Override
+        public void onDisposed(IDisposable sender) {
+            if (getControl() != null) getControl().getDisplay().asyncExec(new Runnable() {
                 @Override
                 public void run() {
-                    if (viewer.getControl().isDisposed())
-                        return;
-                    viewer.getControl().redraw();
+                    dispose();
                 }
             });
         }
     };
 
-    public DiagramLayersPage(IDiagram diagram, ICanvasContext context) {
-
-        assert(diagram != null);
-
-        this.diagram = diagram;
+    public DiagramLayersPage(ICanvasContext context) {
         this.context = context;
 
         context.getDefaultHintContext().addKeyHintListener(Selection.SELECTION0, selectionListener);
+        context.addDisposeListener(contextDisposeListener);
     }
 
     @Override
     public void dispose() {
 
         context.getDefaultHintContext().removeKeyHintListener(Selection.SELECTION0, selectionListener);
-
+        context.removeDisposeListener(contextDisposeListener);
+        if (layers != null && layersListener != null) {
+            layers.removeLayersListener(layersListener);
+            layersListener = null;
+        }
         super.dispose();
 
     }
 
     @Override
     public void createControl(Composite parent) {
-
-        final ILayersEditor layers = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);
-        layers.addListener(new ILayersEditorListener() {
-
+        composite = new Composite(parent, SWT.NONE);
+        GridLayoutFactory.fillDefaults().numColumns(4).applyTo(composite);
+        
+        IDiagram diagram = context.getDefaultHintContext().getHint(DiagramHints.KEY_DIAGRAM);
+        if (diagram != null) onDiagramSet(diagram);
+        context.getDefaultHintContext().addKeyHintListener(DiagramHints.KEY_DIAGRAM, new IHintListener() {
             @Override
-            public void layerRemoved(ILayer layer) {
-                scheduleRefresh();
+            public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
+                IDiagram diagram = (IDiagram)newValue;
+                onDiagramSet(diagram);
             }
 
             @Override
-            public void layerAdded(ILayer layer) {
-                scheduleRefresh();
+            public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {
             }
 
-            @Override
-            public void layerActivated(ILayer layer) {
-                scheduleRefresh();
-            }
+        });
+    }
+    
+    private void onDiagramSet(IDiagram diagram) {
+        if (diagram != null) {
+            layers = diagram.getHint(DiagramHints.KEY_LAYERS_EDITOR);
+            if (layers != null) initialize(layers, diagram);
+            diagram.addKeyHintListener(DiagramHints.KEY_LAYERS_EDITOR, new IHintListener() {
+                
+                
+                @Override
+                public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {
+                    if (newValue != null) {
+                        initialize(layers, diagram);
+                    }
+                }
+                @Override
+                public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {
+                    // TODO Auto-generated method stub
+                    System.out.println("REM");
+                }
 
-            @Override
-            public void layerDeactivated(ILayer layer) {
-                scheduleRefresh();
-            }
+            });
+        }
+    }
 
-            @Override
-            public void ignoreFocusChanged(boolean value) {
-            }
+    private void initialize(ILayersEditor layers, IDiagram diagram) {
+       composite.getDisplay().asyncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               initialize2(layers, diagram);
+                       }
+       });
+    }
 
-            @Override
-            public void ignoreVisibilityChanged(boolean value) {
-            }
+    private ILayersListener layersListener = new ILayersListener() {
 
-            void scheduleRefresh() {
-                viewer.getControl().getDisplay().asyncExec(new Runnable() {
-                    @Override
-                    public void run() {
-                        viewer.refresh();
-                    }
-                });
-            }
-        });
+        @Override
+        public void changed() {
+            scheduleRefresh();
+        }
 
-        composite = new Composite(parent, SWT.NONE);
-        GridLayoutFactory.fillDefaults().numColumns(4).applyTo(composite);
+        void scheduleRefresh() {
+            viewer.getControl().getDisplay().asyncExec(new Runnable() {
+                @Override
+                public void run() {
+                    viewer.refresh();
+                    ignoreVisibilityButton.setSelection(layers.getIgnoreVisibilitySettings());
+                    ignoreFocusButton.setSelection(layers.getIgnoreFocusSettings());
+                    if (!context.isDisposed())
+                        context.getContentContext().setDirty();
+                }
+            });
+        }
+    };
+
+    private void initialize2(ILayersEditor layers, IDiagram diagram) {
+        layers.addLayersListener(layersListener);
 
         Button addButton = new Button(composite, SWT.NONE);
         addButton.setText(Messages.DiagramLayersPage_New);
@@ -372,6 +418,15 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
                 if (selectIndex >= 0) {
                     viewer.getTree().select(all[selectIndex]);
                 }
+                context.getThreadAccess().asyncExec(new Runnable() {
+
+                    @Override
+                    public void run() {
+                        if(context.isDisposed()) return;
+                        context.getContentContext().setDirty();
+                    }
+
+                });
             }
 
             @Override
@@ -380,34 +435,15 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
             }
         });
 
-        String ignoreVisibilityText = TEXT_IGNORE_VISIBILITY_SETTINGS;
-        String ignoreVisibilityTooltip = TOOLTIP_IGNORE_VISIBILITY_SETTINGS;
-        boolean ignoreVisibility = layers.getIgnoreVisibilitySettings();
-        if (ignoreVisibility) {
-            ignoreVisibilityText = TEXT_APPLY_VISIBILITY_SETTINGS;
-            ignoreVisibilityTooltip = TOOLTIP_APPLY_VISIBILITY_SETTINGS;
-        }
-
-        final Button ignoreVisibilityButton = new Button(composite, SWT.NONE);
-        ignoreVisibilityButton.setText(ignoreVisibilityText);
-        ignoreVisibilityButton.setToolTipText(ignoreVisibilityTooltip);
+        ignoreVisibilityButton = new Button(composite, SWT.CHECK);
+        ignoreVisibilityButton.setText(TEXT_IGNORE_VISIBILITY_SETTINGS);
+        ignoreVisibilityButton.setToolTipText(TOOLTIP_IGNORE_VISIBILITY_SETTINGS);
+        ignoreVisibilityButton.setSelection(layers.getIgnoreVisibilitySettings());
         ignoreVisibilityButton.addSelectionListener(new SelectionListener() {
 
             @Override
             public void widgetSelected(SelectionEvent e) {
-                String ignoreText = TEXT_IGNORE_VISIBILITY_SETTINGS;
-                String ignoreTooltip= TOOLTIP_IGNORE_VISIBILITY_SETTINGS;
-                boolean ignore = layers.getIgnoreVisibilitySettings();
-                if(!ignore) {
-                    ignoreText = TEXT_APPLY_VISIBILITY_SETTINGS;
-                    ignoreTooltip = TOOLTIP_APPLY_VISIBILITY_SETTINGS;
-                    layers.setIgnoreVisibilitySettings(true);
-                } else {
-                    layers.setIgnoreVisibilitySettings(false);
-                }
-                ignoreVisibilityButton.setText(ignoreText);
-                ignoreVisibilityButton.setToolTipText(ignoreTooltip);
-                composite.layout();
+                layers.setIgnoreVisibilitySettings(!layers.getIgnoreVisibilitySettings());
                 context.getThreadAccess().asyncExec(new Runnable() {
 
                     @Override
@@ -426,34 +462,15 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
 
         });
 
-        String ignoreFocusText = TEXT_IGNORE_FOCUS_SETTINGS;
-        String ignoreFocusTooltip = TOOLTIP_IGNORE_FOCUS_SETTINGS;
-        boolean ignoreFocus = layers.getIgnoreFocusSettings();
-        if(ignoreFocus) {
-            ignoreFocusText = TEXT_APPLY_FOCUS_SETTINGS;
-            ignoreFocusTooltip = TOOLTIP_APPLY_FOCUS_SETTINGS;
-        }
-
-        final Button ignoreFocusButton = new Button(composite, SWT.NONE);
-        ignoreFocusButton.setText(ignoreFocusText);
-        ignoreFocusButton.setToolTipText(ignoreFocusTooltip);
+        ignoreFocusButton = new Button(composite, SWT.CHECK);
+        ignoreFocusButton.setText(TEXT_IGNORE_FOCUS_SETTINGS);
+        ignoreFocusButton.setToolTipText(TOOLTIP_IGNORE_FOCUS_SETTINGS);
+        ignoreFocusButton.setSelection(layers.getIgnoreFocusSettings());
         ignoreFocusButton.addSelectionListener(new SelectionListener() {
 
             @Override
             public void widgetSelected(SelectionEvent e) {
-                String ignoreText = TEXT_IGNORE_FOCUS_SETTINGS;
-                String ignoreTooltip = TOOLTIP_IGNORE_FOCUS_SETTINGS;
-                boolean ignore = layers.getIgnoreFocusSettings();
-                if(!ignore) {
-                    ignoreText = TEXT_APPLY_FOCUS_SETTINGS;
-                    ignoreTooltip = TOOLTIP_APPLY_FOCUS_SETTINGS;
-                    layers.setIgnoreFocusSettings(true);
-                } else {
-                    layers.setIgnoreFocusSettings(false);
-                }
-                ignoreFocusButton.setText(ignoreText);
-                ignoreFocusButton.setToolTipText(ignoreTooltip);
-                composite.layout();
+                layers.setIgnoreFocusSettings(!layers.getIgnoreFocusSettings());
                 context.getThreadAccess().asyncExec(new Runnable() {
 
                     @Override
@@ -519,16 +536,20 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
                     Tristate state = getJointAttribute(elements, lz[index], attribute);
 
                     Color color = null;
-                    switch (state) {
-                        case False:
-                            color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_RED);
-                            break;
-                        case True:
-                            color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_GREEN);
-                            break;
-                        case Both:
-                            color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_GRAY);
-                            break;
+                    if (state == null) {
+                        color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_GRAY);
+                    } else {
+                        switch (state) {
+                            case False:
+                                color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_RED);
+                                break;
+                            case True:
+                                color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_GREEN);
+                                break;
+                            case Both:
+                                color = viewer.getTree().getDisplay().getSystemColor(SWT.COLOR_GRAY);
+                                break;
+                        }
                     }
 
                     GC gc = event.gc;
@@ -707,6 +728,8 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
         for(ILayer layer : layers.getVisibleLayers()) {
             viewer.setSubtreeChecked(layer, true);
         }
+
+        composite.layout();
     }
 
     @Override
@@ -762,7 +785,7 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
                             IEditableLayer l = (IEditableLayer)layer;
                             l.setName(text.getText());
                             System.out.println("renamed layer to " + text.getText()); //$NON-NLS-1$
-                            viewer.refresh();
+                            //viewer.refresh();
                         }
 
                         //                                     // Item may be disposed if the tree gets reset after a previous editing.
@@ -810,7 +833,7 @@ public class DiagramLayersPage extends Page implements ILayersViewPage {
                                     IEditableLayer l = (IEditableLayer)layer;
                                     l.setName(text.getText());
                                     //System.out.println("renamed layer to " + text.getText());
-                                    viewer.refresh();
+                                    //viewer.refresh();
                                 }
                                 //                                     error = modifier.isValid(text.getText());
                                 //                                     if (error == null) {
index 88d85cfbf6581dc996205ffdf0204d4e8e444e51..fb5399ea01f46135ea5a5299ad99843d08ad14b5 100644 (file)
@@ -1043,7 +1043,7 @@ public class DiagramViewer
             return (T) new DiagramOutlinePage(sessionContextProvider, getResourceInput2());
         // Role view support
         if (adapter == ILayersViewPage.class)
-            return (T) new DiagramLayersPage(sourceDiagram, canvasContext);
+            return (T) new DiagramLayersPage(canvasContext);
         // Support external steering of the diagram canvas, zooming etc.
         if (adapter == ICanvasContext.class)
             return (T) canvasContext;
index 970fbc650dd4f32cc788506bc6e0235783cb0305..f80372ce0dadbc2e2174b2125ea049c7c502bc12 100644 (file)
@@ -5,8 +5,6 @@ import org.eclipse.osgi.util.NLS;
 public class Messages extends NLS {
        private static final String BUNDLE_NAME = "org.simantics.modeling.ui.diagramEditor.messages"; //$NON-NLS-1$
        public static String DiagramEditor_InvalidParameter;
-       public static String DiagramLayersPage_FocusActive;
-       public static String DiagramLayersPage_FocusActiveTT;
        public static String DiagramLayersPage_Focus;
        public static String DiagramLayersPage_FocusAll;
        public static String DiagramLayersPage_FocusAllTT;
@@ -17,8 +15,6 @@ public class Messages extends NLS {
        public static String DiagramLayersPage_RemoveTT;
        public static String DiagramLayersPage_Role;
        public static String DiagramLayersPage_SelectTT;
-       public static String DiagramLayersPage_ShowActive;
-       public static String DiagramLayersPage_ShowActiveTT;
        public static String DiagramLayersPage_Show;
        public static String DiagramLayersPage_ShowAll;
        public static String DiagramLayersPage_ShowAllTT;
index 3c5d4af6367b5138ef5b8a32feb5a6e398187a00..a5c95eac49686e1fd68edf9814980ff35915dd9c 100644 (file)
@@ -99,6 +99,14 @@ public class PlainDiagramViewer extends org.simantics.modeling.ui.diagramEditor.
                 return true;
             }
 
+            @Override
+            public void addLayersListener(ILayersListener listener) {
+            }
+
+            @Override
+            public void removeLayersListener(ILayersListener listener) {
+            }
+
         });
 
         // Disable roles (layers) by default in symbol editor to show everything.
index 22a1b59e4ec9a22d9d466b986c1bee0d9afa9631..02a317ce06f6c94de9cbe58702fdc732be2ca0f6 100644 (file)
@@ -658,7 +658,7 @@ public class SheetViewer extends EditorPart implements IResourceEditorPart2 {
         if (adapter == IContentOutlinePage.class)
             return (T) new DiagramOutlinePage(sessionContextProvider, getResourceInput2());
         if (adapter == ILayersViewPage.class)
-            return (T) new DiagramLayersPage(sourceDiagram, canvasContext);
+            return (T) new DiagramLayersPage(canvasContext);
         if (adapter == ICanvasContext.class)
             return (T) canvasContext;
         if (adapter == INode.class) {
index 47913a7e078403a2ed9f51c793eea91635b4aa5c..70436d13468b8b57183c329b5ccc2047696f41c8 100644 (file)
@@ -396,7 +396,7 @@ public class WikiDiagramViewer extends EditorPart implements IResourceEditorPart
         if (adapter == IContentOutlinePage.class)
             return new DiagramOutlinePage(sessionContextProvider, getResourceInput2());
         if (adapter == ILayersViewPage.class)
-            return new DiagramLayersPage(sourceDiagram, canvasContext);
+            return new DiagramLayersPage(canvasContext);
         if (adapter == ICanvasContext.class)
             return canvasContext;
         if (adapter == IDiagram.class)
index d0bf18b836a3521621fde2d93d04c735fcc05a23..2cbf334472ce3f9441c0f97b3c2b3d7a15a66d50 100644 (file)
@@ -148,7 +148,6 @@ import org.simantics.scenegraph.g2d.snap.GridSnapAdvisor;
 import org.simantics.scenegraph.utils.NodeUtil;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.structural2.modelingRules.IModelingRules;
-import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.jobs.SessionGarbageCollectorJob;
 import org.simantics.ui.workbench.IPropertyPage;
 import org.simantics.ui.workbench.IResourceEditorInput;
@@ -998,7 +997,7 @@ public class DiagramViewer
             return new DiagramOutlinePage(sessionContextProvider, getResourceEditorInput());
         // Role view support
         if (adapter == ILayersViewPage.class)
-            return new DiagramLayersPage(sourceDiagram, canvasContext);
+            return new DiagramLayersPage(canvasContext);
         // Support external steering of the diagram canvas, zooming etc.
         if (adapter == ICanvasContext.class)
             return canvasContext;
index 19052dac19bb515be2342d9e1736480373eea877..f4f9f0671da0cb1f0156b37a2a76c3a3e19d7124 100644 (file)
@@ -1,21 +1,17 @@
 DiagramEditor_InvalidParameter=Invalid parameter ''{0}''. Complete view argument: {1}
 DiagramLayersPage_Focus=Focus
-DiagramLayersPage_FocusActive=Focus Active
-DiagramLayersPage_FocusActiveTT=Only Focus Diagram Elements For Active Roles
 DiagramLayersPage_FocusAll=Focus All
-DiagramLayersPage_FocusAllTT=Focus All Diagram Elements Regardless Of Active Roles
-DiagramLayersPage_New=New
-DiagramLayersPage_NewRole=New Role
-DiagramLayersPage_NewTT=Create New Diagram Role
-DiagramLayersPage_Remove=Remove
-DiagramLayersPage_RemoveTT=Remove Selected Diagram Role
-DiagramLayersPage_Role=Role
+DiagramLayersPage_FocusAllTT=Focus All Diagram Elements Regardless Of Active Layers
+DiagramLayersPage_New=New Layer
+DiagramLayersPage_NewRole=New Layer
+DiagramLayersPage_NewTT=Create New Layer
+DiagramLayersPage_Remove=Remove Layer
+DiagramLayersPage_RemoveTT=Remove Selected Layer
+DiagramLayersPage_Role=Active Layers
 DiagramLayersPage_SelectTT=Selects the diagram to include in the exported document.
 DiagramLayersPage_Show=Show
-DiagramLayersPage_ShowActive=Show Active
-DiagramLayersPage_ShowActiveTT=Only Show Diagram Elements For Active Roles
 DiagramLayersPage_ShowAll=Show All
-DiagramLayersPage_ShowAllTT=Show All Diagram Elements Regardless Of Active Roles
+DiagramLayersPage_ShowAllTT=Show All Diagram Elements Regardless Of Active Layers
 DiagramViewer_FailedtoLoadModeled=Failed to load modeled browse contexts for property page, see exception for details.
 DiagramViewer_MonitorActivateMapping=Activate Mapping
 DiagramViewerActionContributor_ConnectMode=Connect Mode
index 150ccfe5248c4f9099ecc77da201a977bbfd0a1f..d27f91b93eb67c7dd8876a7517f3cc1095fc2197 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Set;
 import org.simantics.db.common.request.ParametrizedRead;
 import org.simantics.db.layer0.request.combinations.Combinators;
 import org.simantics.diagram.handler.CopyPasteStrategy;
-import org.simantics.diagram.handler.DefaultCopyPasteStrategy;
 import org.simantics.diagram.participant.PointerInteractor2;
 import org.simantics.g2d.canvas.ICanvasContext;
 import org.simantics.g2d.diagram.DiagramHints;
@@ -109,6 +108,14 @@ public class SymbolViewer extends org.simantics.modeling.ui.diagramEditor.Diagra
                 return true;
             }
 
+            @Override
+            public void addLayersListener(ILayersListener listener) {
+            }
+
+            @Override
+            public void removeLayersListener(ILayersListener listener) {
+            }
+
         });
 
         // Disable roles (layers) by default in symbol editor to show everything.
index 55b537f941a225baca3d92f82cbd40f170fd050f..1a4088c3b7e107ce680c089f3feae7a953c0c3bc 100644 (file)
    </configIni>\r
 \r
    <launcherArgs>\r
-      <programArgs>-fixerrors
--data
-@noDefault
--cssTheme
+      <programArgs>-fixerrors\r
+-data\r
+@noDefault\r
+-cssTheme\r
 org.eclipse.e4.ui.css.theme.e4_classic\r
       </programArgs>\r
-      <vmArgs>-ea
--Xmx500M
--Xshare:off
--Dorg.simantics.workbench.application.showFastViewBars=false
--Dorg.simantics.workbench.application.showPerspectiveBar=false
--Dorg.simantics.workbench.application.excludePerspectiveFromTitle=true
+      <vmArgs>-ea\r
+-Xmx500M\r
+-Xshare:off\r
+-Dorg.simantics.workbench.application.showFastViewBars=false\r
+-Dorg.simantics.workbench.application.showPerspectiveBar=false\r
+-Dorg.simantics.workbench.application.excludePerspectiveFromTitle=true\r
 -Declipse.workaround.bug467000=true\r
       </vmArgs>\r
       <vmArgsWin>-Dorg.osgi.framework.os.name=win32\r