use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetSource_Relationship.
@Test
public void testGetSource_Relationship() {
IArchimateRelationship inputElement = (IArchimateRelationship) tm.getObjectByID("460");
IArchimateElement expected = (IArchimateElement) tm.getObjectByID("409");
Object source = provider.getSource(inputElement);
assertEquals(expected, source);
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ZestViewerContentProviderTests method testGetDestination_Element.
@Test
public void testGetDestination_Element() {
IArchimateElement inputElement = (IArchimateElement) tm.getObjectByID("521");
Object destination = provider.getDestination(inputElement);
assertNull(destination);
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class CSVImporter method createElementFromRecord.
/**
* Create an Archimate Element from a given CSVRecord
*/
private void createElementFromRecord(CSVRecord csvRecord) throws CSVParseException {
// ID
String id = csvRecord.get(0);
if (!StringUtils.isSet(id)) {
id = generateID();
} else {
checkIDForInvalidCharacters(id);
}
// Class type
String type = csvRecord.get(1);
EClass eClass = (EClass) IArchimatePackage.eINSTANCE.getEClassifier(type);
// Can only be Archimate element type
if (!isArchimateElementEClass(eClass)) {
throw new CSVParseException(Messages.CSVImporter_3);
}
String name = normalise(csvRecord.get(2));
String documentation = csvRecord.get(3);
// Is the element already in the model?
IArchimateElement element = (IArchimateElement) findArchimateConceptInModel(id, eClass);
// Yes it is, so update values
if (element != null) {
storeUpdatedConceptFeature(element, IArchimatePackage.Literals.NAMEABLE__NAME, name);
storeUpdatedConceptFeature(element, IArchimatePackage.Literals.DOCUMENTABLE__DOCUMENTATION, documentation);
} else // No, create a new element
{
element = (IArchimateElement) IArchimateFactory.eINSTANCE.create(eClass);
element.setId(id);
element.setName(name);
element.setDocumentation(documentation);
newConcepts.put(id, element);
}
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class AbstractModelView method getDiagramElementsToUpdate.
/**
* Find all elements contained in Diagram or Diagram objects including any child objects
*/
private void getDiagramElementsToUpdate(List<Object> list, IDiagramModelContainer container) {
// ArchiMate element
if (container instanceof IDiagramModelArchimateObject) {
IArchimateElement element = ((IDiagramModelArchimateObject) container).getArchimateElement();
if (!list.contains(element)) {
list.add(element);
getRelationshipsToUpdate(list, element);
}
}
// Children
for (IDiagramModelObject child : container.getChildren()) {
if (child instanceof IDiagramModelContainer) {
getDiagramElementsToUpdate(list, (IDiagramModelContainer) child);
}
}
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class AbstractModelView method getElementsToUpdateFromNotification.
/**
* @return All the tree element nodes that may need updating when a change occurs
*/
protected List<Object> getElementsToUpdateFromNotification(Notification msg) {
int type = msg.getEventType();
Object element = null;
if (type == Notification.REMOVE) {
element = msg.getOldValue();
} else if (type == Notification.ADD) {
element = msg.getNewValue();
} else if (type == Notification.SET) {
element = msg.getNotifier();
}
List<Object> list = new ArrayList<Object>();
// If it's a diagram object or a diagram dig in and treat it separately
if (element instanceof IDiagramModelContainer) {
getDiagramElementsToUpdate(list, (IDiagramModelContainer) element);
return list;
}
// If it's a diagram connection get the relationship
if (element instanceof IDiagramModelArchimateConnection) {
element = ((IDiagramModelArchimateConnection) element).getArchimateRelationship();
}
// Got either a folder, a relationship or an element
if (element != null) {
if (!list.contains(element)) {
list.add(element);
}
// If an element, also add any attached relationships
if (element instanceof IArchimateElement) {
getRelationshipsToUpdate(list, (IArchimateElement) element);
}
}
return list;
}
Aggregations