</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
*******************************************************************************/
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;
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;
}
@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
*******************************************************************************/
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;
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;
}
@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>() {
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>() {
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;
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
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;
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);
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;
// 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());
}
* 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
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;
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 {
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;
// 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;
}
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.
# 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.
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() {
public Resource getFocusable() {
return tags.get(PROP_FOCUSABLE);
}
+
+ public boolean isActive() {
+ return active;
+ }
public ILayer getILayer() {
return new SimpleLayer(name);
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
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;
*/
LayerListener layerListener = new LayerListener();
+ boolean disposed = false;
+
public GraphLayerManager(ReadGraph graph, IModificationQueue modificationQueue, Resource diagram) {
this.modificationQueue = modificationQueue;
this.diagram = diagram;
}
}
layers.clear();
+ disposed = true;
}
Resource getDiagramResource() {
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)
* 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);
// 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);
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 {
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);
+ }
+ }
}
}
--- /dev/null
+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;
+ }
+
+}
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;
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;
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)) {
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)) {
// 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() {
}
} 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);
+ }
+ });
}
}
}
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);
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);
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;
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 )) {
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
*******************************************************************************/
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;
@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;
@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;
@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;
@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;
@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)) {
@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)) {
TextImpl.INSTANCE,
FlagTerminalTopology.DEFAULT,
FlagSceneGraph.INSTANCE,
- DEFAULT_STATIC_SYMBOL
+ DEFAULT_STATIC_SYMBOL,
+ SimpleElementLayers.INSTANCE
).setId(FlagClass.class.getSimpleName());
public static ElementClass create(Terminal terminal) {
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;
ConnectionSelectionOutline.INSTANCE,
ConnectionHandlerImpl.INSTANCE,
ConnectionSceneGraph.INSTANCE,
- //SimpleElementLayers.INSTANCE,
+ SimpleElementLayers.INSTANCE,
// Exists only loading connection visuals through ConnectionVisualsLoader
ConfigurableEdgeVisuals.DEFAULT,
boolean getIgnoreFocusSettings();
boolean getIgnoreVisibilitySettings();
+ void addLayersListener(ILayersListener listener);
+ void removeLayersListener(ILayersListener listener);
+
+ public interface ILayersListener {
+ void changed();
+ }
}
*******************************************************************************/
package org.simantics.g2d.layers;
+import java.util.Set;
/**
* @author Antti Villberg
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);
void activate(ILayer layer);
void deactivate(ILayer layer);
+ void update(Set<ILayer> allLayers, Set<ILayer> visibleLayers);
}
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.simantics.utils.strings.AlphanumComparator;
+
/**
* @author Antti Villberg
*/
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());
}
};
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;
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
synchronized (this) {
visibleSnapshot = null;
}
- for (ILayersEditorListener listener : listeners) {
+ for (ILayersListener listener : layersListeners) {
+ listener.changed();
+ }
+ for (ILayersEditorListener listener : layerEditorListeners) {
listener.layerDeactivated(layer);
}
}
synchronized (this) {
visibleSnapshot = null;
}
- for (ILayersEditorListener listener : listeners) {
+ for (ILayersListener listener : layersListeners) {
+ listener.changed();
+ }
+ for (ILayersEditorListener listener : layerEditorListeners) {
listener.layerActivated(layer);
}
}
synchronized (this) {
allSnapshot = null;
}
- for (ILayersEditorListener listener : listeners) {
+ for (ILayersListener listener : layersListeners) {
+ listener.changed();
+ }
+ for (ILayersEditorListener listener : layerEditorListeners) {
listener.layerAdded(layer);
}
}
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
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);
}
}
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);
}
}
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;
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() };
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;
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))
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
}
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);
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
}
});
- 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
});
- 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
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;
for(ILayer layer : layers.getVisibleLayers()) {
viewer.setSubtreeChecked(layer, true);
}
+
+ composite.layout();
}
@Override
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.
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) {
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;
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;
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;
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.
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) {
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)
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;
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;
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
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;
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.
</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