use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ArchimateDiagramModelFactory method getNewObject.
public Object getNewObject() {
if (fTemplate == null) {
return null;
}
Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
// Connection created from Relationship Template
if (object instanceof IArchimateRelationship) {
return createDiagramModelArchimateConnection((IArchimateRelationship) object);
} else // Archimate Diagram Object created from Archimate Element Template
if (object instanceof IArchimateElement) {
IArchimateElement element = (IArchimateElement) object;
element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
return createDiagramModelArchimateObject(element);
} else // Group
if (object instanceof IDiagramModelGroup) {
IDiagramModelGroup group = (IDiagramModelGroup) object;
group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
ColorFactory.setDefaultColors(group);
((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
} else // Note
if (object instanceof IDiagramModelNote) {
ColorFactory.setDefaultColors((IDiagramModelObject) object);
((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
} else // Connection
if (object instanceof IDiagramModelConnection) {
ColorFactory.setDefaultColors((IDiagramModelConnection) object);
}
return object;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ArchimateRelationship method getCopy.
@Override
public EObject getCopy() {
IArchimateRelationship copy = (IArchimateRelationship) super.getCopy();
// Clear source and target. This will also clear connected components' references to this
copy.setSource(null);
copy.setTarget(null);
return copy;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class DiagramModelArchimateConnection method addArchimateConceptToModel.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public void addArchimateConceptToModel(IFolder parent) {
IArchimateRelationship relationship = getArchimateRelationship();
if (relationship != null && relationship.eContainer() != null) {
// $NON-NLS-1$
throw new IllegalArgumentException("Relationship already has parent folder");
}
// If parent is null use default folder
if (parent == null) {
parent = getDiagramModel().getArchimateModel().getDefaultFolderForObject(relationship);
}
if (relationship != null) {
parent.getElements().add(relationship);
relationship.reconnect();
}
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class InvalidRelationsChecker method findInvalidRelations.
// Invalid Relations
List<IIssue> findInvalidRelations() {
List<IIssue> issues = new ArrayList<IIssue>();
for (IArchimateRelationship relation : fRelations) {
boolean valid = ArchimateModelUtils.isValidRelationship(relation.getSource(), relation.getTarget(), relation.eClass());
if (!valid) {
String className = ArchiLabelProvider.INSTANCE.getDefaultName(relation.eClass());
String description = NLS.bind(fDescription, new Object[] { className, ArchiLabelProvider.INSTANCE.getLabel(relation.getSource()), ArchiLabelProvider.INSTANCE.getLabel(relation.getTarget()) });
String explanation = NLS.bind(fExplanation, new Object[] { className, ArchiLabelProvider.INSTANCE.getDefaultName(relation.getSource().eClass()), ArchiLabelProvider.INSTANCE.getDefaultName(relation.getTarget().eClass()) });
IIssue issue = new ErrorType(fName, description, explanation, relation);
issues.add(issue);
}
}
return issues;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class NestedElementsChecker method isNestedWithoutValidRelation.
boolean isNestedWithoutValidRelation(IDiagramModelArchimateObject parent, IDiagramModelArchimateObject child) {
IArchimateElement parentElement = parent.getArchimateElement();
IArchimateElement childElement = child.getArchimateElement();
// Ignore nested Junctions
if (childElement instanceof IJunction) {
return false;
}
// Specialization relationship goes the other way around
for (IArchimateRelationship relation : parentElement.getTargetRelationships()) {
if (relation.getSource() == childElement) {
if (relation instanceof ISpecializationRelationship) {
return false;
}
}
}
// Other relationships
for (IArchimateRelationship relation : parentElement.getSourceRelationships()) {
if (relation.getTarget() == childElement) {
if (relation instanceof ICompositionRelationship || relation instanceof IAggregationRelationship || relation instanceof IAssignmentRelationship || relation instanceof IRealizationRelationship || relation instanceof IAccessRelationship) {
return false;
}
}
}
return true;
}
Aggregations