Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » DiagramEditor - Manage nodes and edges separatly
DiagramEditor - Manage nodes and edges separatly [message #722153] Sun, 04 September 2011 15:09 Go to next message
Nepomuk Seiler is currently offline Nepomuk Seiler
Messages: 88
Registered: December 2010

Currently I'm trying to extend my editor with a diagram page. My model is a graph consisting of nodes and edges. Both are managed in a ListProperty. I implemented everything like the architecture example, besides the root entity. The root entity manage both nodes and edges.

IDataProcessingUnit.class snippet (root entity, graph)
	/* === Nodes === */

	@Type(base = INode.class)
	@XmlListBinding(path = "nodes", mappings = { @XmlListBinding.Mapping(element = "node", type = INode.class) })
	@Label(standard = "Nodes")
	ListProperty PROP_NODES = new ListProperty(TYPE, "nodes");

	ModelElementList<INode> getNodes();

	/* === Edges === */

	@Type(base = IEdge.class)
	@XmlListBinding(path = "edges", mappings = { @XmlListBinding.Mapping(element = "edge", type = IEdge.class) })
	@Label(standard = "Edges")
	ListProperty PROP_EDGES = new ListProperty(TYPE, "edges");

	ModelElementList<IEdge> getEdges();

INode.class snippet
/* === Node ID === */

	@XmlBinding(path = "@id")
	@Label(standard = "id")
	ValueProperty PROP_ID = new ValueProperty(TYPE, "id");

	Value<String> getId();

	void setId(String value);

	/* === Edges === */
        //I try to reference to the root path here!
	@Type(base = IEdge.class)
	@XmlListBinding(path = "/edges", mappings = { @XmlListBinding.Mapping(element = "edge", type = IEdge.class) })
	@Label(standard = "Edges")
	ListProperty PROP_EDGES = new ListProperty(TYPE, "edges");

	ModelElementList<IEdge> getEdges();

IEdge.class snippet

/* === Edge ID === */

	@Reference( target = INode.class )
	@Service( impl = NodeReferenceService.class )
	@XmlBinding(path = "@edgeId")
	@Label(standard = "EdgeId")
	ValueProperty PROP_EDGE_ID = new ValueProperty(TYPE, "edgeId");

	Value<String> getEdgeId();

	void setEdgeId(String value);

	/* === Source ID === */

	@XmlBinding(path = "@sourceId")
	@Label(standard = "SourceId")
        @PossibleValues( property = "/nodes/id" )
	ValueProperty PROP_SOURCE_ID = new ValueProperty(TYPE, "sourceId");

	Value<String> getSourceId();

	void setSourceID(String value);
	/* === Target ID === */

	@XmlBinding(path = "@targetId")
	@Label(standard = "TargetId")
	@PossibleValues( property = "/nodes/id" )
	ValueProperty PROP_TARGET_ID = new ValueProperty(TYPE, "targetId");

	Value<String> getTargetId();

	void setTargetID(String value);

If I create edges via the MasterDetailPage my xml-model looks right:

<?xml version="1.0" encoding="UTF-8"?>
<DataProcessingUnit name="myFirstDPU">
        <node id="Node1" />
        <node id="Node2" />
        <edge edgeId="e1" sourceId="Node1" targetId="Node2"/>

However if I use the Graphiti editor, it looks like:

<?xml version="1.0" encoding="UTF-8"?>
<DataProcessingUnit name="myFirstDPU">
        <node factoryId="fac1" id="Node1" type="processor" >
                <edge edgeId="Node2"></edge>
        <node factoryId="fac2" id="Node2" type="loader"/>

He only adds the edge in the Graphiti-Editor if I reference edgeIdas Endpoint2. If not, nothing is added.

Is it possible to reference a higher path in the xml-tree from a lower entity?

Re: DiagramEditor - Manage nodes and edges separatly [message #722159 is a reply to message #722153] Sun, 04 September 2011 15:58 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 937
Registered: July 2009
Senior Member
You have a list of edges defined twice. Once at the root of the model and again inside the node element. Those are two styles of edge representation. You typically want one or the other. If you look at the map sample, you will see how to implement either option... IMap.Routes (top-level) and IDestination.RailwayRoutes (part of node).

- Konstantin
Previous Topic:Dynamic combobox content generated out of the model
Next Topic:Re-scheduling Sapphire 0.3.1 release
Goto Forum:

Current Time: Sat Jul 26 15:27:25 EDT 2014

Powered by FUDForum. Page generated in 0.11203 seconds