blob: 6cce0c8e07a0247d9e6953664b43c5f066d1cb25 [file] [log] [blame]
package org.eclipse.stem.ui.grapheditor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.stem.core.graph.Edge;
import org.eclipse.stem.core.graph.EdgeLabel;
import org.eclipse.stem.definitions.edges.MigrationEdgeLabel;
import org.eclipse.stem.definitions.labels.CommonBorderRelationshipLabel;
import org.eclipse.stem.definitions.labels.CommonBorderRelationshipLabelValue;
import org.eclipse.stem.definitions.labels.RelativePhysicalRelationshipLabel;
import org.eclipse.stem.definitions.edges.MigrationEdge;
public class ConnectionData
{
Edge edge;
URI nodeAURI;
URI nodeBURI;
URI edgeURI;
EdgeLabel edgeLabel;
String edgeTitle;
String edgeIdentifier;
String edgePopulation;
ConnectionData(Edge edge, URI nodeAURI, URI nodeBURI, URI edgeURI, EdgeLabel edgeLabel, String edgeTitle, String edgeIdentifier, String edgePopulation)
{
this(edge, nodeAURI, nodeBURI, edgeURI, edgeLabel, edgeTitle, edgeIdentifier );
this.edgePopulation = edgePopulation;
}
ConnectionData(Edge edge, URI nodeAURI, URI nodeBURI, URI edgeURI, EdgeLabel edgeLabel, String edgeTitle, String edgeIdentifier)
{
this.edge = edge;
this.nodeAURI = nodeAURI;
this.nodeBURI = nodeBURI;
this.edgeURI = edgeURI;
this.edgeLabel = edgeLabel;
this.edgeIdentifier = edgeIdentifier;
this.edgeTitle = edgeTitle;
}
URI getNodeAURI()
{
return this.nodeAURI;
}
URI getNodeBURI()
{
return this.nodeBURI;
}
URI getEdgeURI()
{
return this.edgeURI;
}
EdgeLabel getEdgeLabel()
{
return this.edgeLabel;
}
int getEdgeLabelType()
{
if (this.edgeLabel instanceof MigrationEdgeLabel)
return GraphDefs.MIGRATION_EDGE;
if (this.edgeLabel instanceof RelativePhysicalRelationshipLabel)
return GraphDefs.CONTAINMENT_EDGE;
if (this.edgeLabel instanceof CommonBorderRelationshipLabel)
return GraphDefs.COMMON_BORDER_EDGE;
return GraphDefs.UNDEFINED;
}
String getEdgeIdentifier()
{
return this.edgeIdentifier;
}
String getEdgeTitle()
{
return this.edgeTitle;
}
void setEdgeLabelValue(String value)
{
switch (this.getEdgeLabelType())
{
case GraphDefs.MIGRATION_EDGE:
double newRate;
try {
newRate = Double.parseDouble(value);
} catch (NumberFormatException ex){
newRate = ((MigrationEdgeLabel)this.edgeLabel).getCurrentValue().getMigrationRate();
}
((MigrationEdgeLabel)this.edgeLabel).getCurrentValue().setMigrationRate(newRate);
break;
case GraphDefs.COMMON_BORDER_EDGE:
double newBorderLength;
try {
newBorderLength = Double.parseDouble(value);
} catch (NumberFormatException ex){
newBorderLength = ((CommonBorderRelationshipLabelValue)this.edgeLabel).getBorderLength();
}
CommonBorderRelationshipLabel cbrl = (CommonBorderRelationshipLabel) this.edgeLabel;
((CommonBorderRelationshipLabelValue)cbrl.getCurrentValue()).setBorderLength(newBorderLength);
break;
}
}
void setEdgePopulation(String value)
{
switch (this.getEdgeLabelType())
{
case GraphDefs.MIGRATION_EDGE: this.edgePopulation = value;
((MigrationEdge)this.edge).setPopulationIdentifier(value); break;
}
}
String getEdgePopulation()
{
return this.edgePopulation;
// ..
}
void setEdgeTitle(String edgeTitle)
{
this.edgeTitle = edgeTitle;
this.edge.getDublinCore().setTitle(edgeTitle);
}
void setNodeAURI(String nodeAURI)
{
this.nodeAURI = URI.createURI(nodeAURI);
}
void setNodeBURI(String nodeBURI)
{
this.nodeBURI = URI.createURI(nodeBURI);
}
void setEdgeURI(String edgeURI)
{
this.edgeURI = URI.createURI(edgeURI);
}
}