use of com.archimatetool.model.IInfluenceRelationship in project archi by archimatetool.
the class CSVImporter method createPropertyFromRecord.
/**
* Create a Property from a given CSVRecord
*/
private void createPropertyFromRecord(CSVRecord csvRecord) throws CSVParseException {
// ID
String id = csvRecord.get(0);
if (!StringUtils.isSet(id)) {
throw new CSVParseException(Messages.CSVImporter_6);
} else {
checkIDForInvalidCharacters(id);
}
// Find referenced concept in newly created list
IProperties propertiesObject = newConcepts.get(id);
// Not found, check if it's referencing an existing element in the model
if (propertiesObject == null) {
EObject eObject = ArchimateModelUtils.getObjectByID(fModel, id);
if (eObject instanceof IProperties) {
propertiesObject = (IProperties) eObject;
}
}
// Not found, check if it's referencing the model
if (propertiesObject == null && id.equals(modelID)) {
propertiesObject = fModel;
}
// Not found at all
if (propertiesObject == null) {
throw new CSVParseException(Messages.CSVImporter_7 + id);
}
String key = normalise(csvRecord.get(1));
String value = normalise(csvRecord.get(2));
// Special properties for relationship attributes
if (INFLUENCE_STRENGTH.equals(key) && propertiesObject instanceof IInfluenceRelationship) {
storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH, value);
return;
} else if (ACCESS_TYPE.equals(key) && propertiesObject instanceof IAccessRelationship) {
int newvalue = ACCESS_TYPES.indexOf(value);
storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.ACCESS_RELATIONSHIP__ACCESS_TYPE, newvalue);
return;
}
// Is there already a property with this key?
IProperty property = getProperty(propertiesObject, key);
if (property != null) {
updatedProperties.put(property, value);
} else // No, create new one
{
property = IArchimateFactory.eINSTANCE.createProperty();
property.setKey(key);
property.setValue(value);
newProperties.put(property, propertiesObject);
}
}
use of com.archimatetool.model.IInfluenceRelationship in project archi by archimatetool.
the class ZestViewerLabelProvider method selfStyleConnection.
// ========================================================================================
// ISelfStyleProvider
// ========================================================================================
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
connection.setLineWidth(0);
connection.setTooltip(getTooltip(element));
connection.setLineColor(ColorConstants.black);
connection.setText(getText(element));
PolylineConnection conn = (PolylineConnection) connection.getConnectionFigure();
if (element instanceof ISpecializationRelationship) {
conn.setTargetDecoration(SpecializationConnectionFigure.createFigureTargetDecoration());
} else if (element instanceof ICompositionRelationship) {
conn.setSourceDecoration(CompositionConnectionFigure.createFigureSourceDecoration());
} else if (element instanceof IAggregationRelationship) {
conn.setSourceDecoration(AggregationConnectionFigure.createFigureSourceDecoration());
} else if (element instanceof IAssignmentRelationship) {
conn.setSourceDecoration(AssignmentConnectionFigure.createFigureSourceDecoration());
conn.setTargetDecoration(AssignmentConnectionFigure.createFigureTargetDecoration());
} else if (element instanceof IRealizationRelationship) {
conn.setTargetDecoration(RealizationConnectionFigure.createFigureTargetDecoration());
connection.setLineStyle(SWT.LINE_CUSTOM);
conn.setLineDash(new float[] { 2 });
} else if (element instanceof ITriggeringRelationship) {
conn.setTargetDecoration(TriggeringConnectionFigure.createFigureTargetDecoration());
} else if (element instanceof IFlowRelationship) {
conn.setTargetDecoration(FlowConnectionFigure.createFigureTargetDecoration());
connection.setLineStyle(SWT.LINE_CUSTOM);
conn.setLineDash(new float[] { 6, 3 });
} else if (element instanceof IServingRelationship) {
conn.setTargetDecoration(ServingConnectionFigure.createFigureTargetDecoration());
} else if (element instanceof IAccessRelationship) {
switch(((IAccessRelationship) element).getAccessType()) {
case IAccessRelationship.WRITE_ACCESS:
default:
conn.setSourceDecoration(null);
// arrow at target endpoint
conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration());
break;
case IAccessRelationship.READ_ACCESS:
// arrow at source endpoint
conn.setSourceDecoration(AccessConnectionFigure.createFigureTargetDecoration());
conn.setTargetDecoration(null);
break;
case IAccessRelationship.UNSPECIFIED_ACCESS:
// no arrows
conn.setSourceDecoration(null);
conn.setTargetDecoration(null);
break;
case IAccessRelationship.READ_WRITE_ACCESS:
// both arrows
conn.setSourceDecoration(AccessConnectionFigure.createFigureTargetDecoration());
conn.setTargetDecoration(AccessConnectionFigure.createFigureTargetDecoration());
break;
}
connection.setLineStyle(SWT.LINE_CUSTOM);
conn.setLineDash(new float[] { 2 });
} else if (element instanceof IInfluenceRelationship) {
conn.setTargetDecoration(InfluenceConnectionFigure.createFigureTargetDecoration());
connection.setLineStyle(SWT.LINE_CUSTOM);
conn.setLineDash(new float[] { 6, 3 });
}
conn.setAntialias(SWT.ON);
}
use of com.archimatetool.model.IInfluenceRelationship in project archi by archimatetool.
the class InfluenceConnectionFigure method setConnectionText.
@Override
protected void setConnectionText() {
IInfluenceRelationship rel = (IInfluenceRelationship) getModelConnection().getArchimateRelationship();
// $NON-NLS-1$
getConnectionLabel().setText(getModelConnection().getName() + " " + rel.getStrength());
}
use of com.archimatetool.model.IInfluenceRelationship in project archi by archimatetool.
the class AllArchimateRelationshipTypeTests method testGetInfluence_Strength.
@Test
public void testGetInfluence_Strength() {
// Only Influence type
Assume.assumeTrue(relationship instanceof IInfluenceRelationship);
IInfluenceRelationship aRelationship = (IInfluenceRelationship) relationship;
assertEquals("", aRelationship.getStrength());
aRelationship.setStrength("++");
assertEquals("++", aRelationship.getStrength());
}
Aggregations