import org.simantics.g2d.element.IElement;
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.TerminalTopology;
import org.simantics.g2d.element.impl.Element;
public ElementClass substitute(IDiagram d, ElementClass ec) {
if (d != diagram)
throw new IllegalArgumentException("specified diagram does not have this SubstituteElementClass handler");
-
- // If the element class is our own, there's no point in creating
- // a copy of it.
- if (ec.contains(elementLayerListener))
- return ec;
-
- List<ElementHandler> all = ec.getAll();
- List<ElementHandler> result = new ArrayList<ElementHandler>(all.size());
- for (ElementHandler eh : all) {
- if (eh instanceof ElementLayerListenerImpl)
- result.add(elementLayerListener);
- else
- result.add(eh);
- }
- return ElementClass.compile(result, false).setId(ec.getId());
+ // Nothing to substitute here
+ return ec;
}
}
* 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
}
}
+ @Override
+ public void flush() {
+ modificationQueue.flush();
+ }
+
void changeTag(IElement e, Resource tag, boolean set) {
Object object = e.getHint(ElementHints.KEY_OBJECT);
Resource tagged = null;
if (tagged == null)
return;
- modificationQueue.async(new TagChange(tagged, tag, set), null);
+ modificationQueue.offer(new TagChange(tagged, tag, set), null);
}
};
d.setHint(DiagramHints.KEY_LAYERS, layers);
d.setHint(DiagramHints.KEY_LAYERS_EDITOR, layers);
+ d.setHint(DiagramHints.KEY_ELEMENT_LAYER_LISTENER, elementLayerListener);
d.addCompositionVetoListener(diagramListener);
d.addCompositionListener(diagramListener);