import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.profile.ProfileKeys;
import org.simantics.diagram.profile.StyleBase;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.diagram.handler.DataElementMap;
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
+import org.simantics.scenegraph.profile.DataNodeMap;
import org.simantics.scenegraph.profile.EvaluationContext;
/**
}
@Override
- public void applyStyleForNode(EvaluationContext observer, INode node, Boolean result) {
- SingleElementNode n = (SingleElementNode) node;
- n.setVisible(false);
- n.setHidden(true);
+ public void applyStyleForItem(EvaluationContext evaluationContext, DataNodeMap map, Object item, Boolean value) {
+ INode node = map.getNode(item);
+ if (node == null) {
+ evaluationContext.update();
+ return;
+ }
+
+ IDiagram diagram = evaluationContext.getConstant(ProfileKeys.DIAGRAM);
+ DataElementMap emap = diagram.getDiagramClass().getSingleItem(DataElementMap.class);
+ IElement element = emap.getElement(diagram, item);
+ if (element == null)
+ return;
+
+ hideElements(evaluationContext, diagram, element, node);
}
@Override
- protected void cleanupStyleForNode(EvaluationContext evaluationContext, INode node) {
- SingleElementNode n = (SingleElementNode) node;
- n.setVisible(true);
- n.setHidden(false);
+ protected void cleanupStyleForItem(EvaluationContext evaluationContext, DataNodeMap map, Object item) {
+ IDiagram diagram = evaluationContext.getConstant(ProfileKeys.DIAGRAM);
+ DataElementMap emap = diagram.getDiagramClass().getSingleItem(DataElementMap.class);
+
+ INode node = map.getNode(item);
+ if (node == null)
+ return;
+ IElement element = emap.getElement(diagram, item);
+ if (element == null)
+ return;
+
+ showElements(diagram, element, node);
+ }
+
+ protected void hideElements(EvaluationContext evaluationContext, IDiagram diagram, IElement element, INode node) {
+ setVisibility(element, node, false);
+ }
+
+ protected void showElements(IDiagram diagram, IElement element, INode node) {
+ setVisibility(element, node, true);
+ }
+
+ protected void setVisibility(IElement element, INode node, boolean visible) {
+ if (element != null)
+ ElementUtils.setHidden(element, !visible);
+ if (node instanceof SingleElementNode) {
+ ((SingleElementNode) node).setHidden(!visible);
+ }
}
@Override