use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class AbstractFilteredEditPart method getFilteredModelChildren.
protected List<?> getFilteredModelChildren() {
if (getModel() instanceof IDiagramModelContainer) {
List<IDiagramModelObject> originalList = ((IDiagramModelContainer) getModel()).getChildren();
IChildEditPartFilter[] filters = getRootEditPartFilterProvider().getEditPartFilters(IChildEditPartFilter.class);
if (filters != null) {
List<IDiagramModelObject> filteredList = new ArrayList<IDiagramModelObject>();
for (IDiagramModelObject object : originalList) {
boolean add = true;
for (IChildEditPartFilter filter : filters) {
add = filter.isChildElementVisible(this, object);
if (!add) {
// no point in trying the next filter
break;
}
}
if (add) {
filteredList.add(object);
}
}
return filteredList;
}
return originalList;
}
return Collections.EMPTY_LIST;
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class GenerateViewCommand method createDiagramModel.
private IArchimateDiagramModel createDiagramModel() {
// New Diagram
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
dm.setName(fViewName);
dm.setViewpoint(fViewpoint.getID());
fParentFolder = fSelectedElements.get(0).getArchimateModel().getDefaultFolderForObject(dm);
fParentFolder.getElements().add(dm);
int x = 20;
int y = 20;
getElementsToAdd();
for (IArchimateElement element : fSelectedElements) {
createDiagramNode(element, dm, x, y);
y += 100;
}
x = 170;
y = 20;
for (IArchimateElement element : fAddedElements) {
if (!fSelectedElements.contains(element)) {
createDiagramNode(element, dm, x, y);
y += 80;
if (y > 700) {
y = 20;
x += 150;
}
}
}
// Add connections between elements first
for (IDiagramModelObject dmoSource : dm.getChildren()) {
IArchimateElement elementSource = ((IDiagramModelArchimateObject) dmoSource).getArchimateElement();
for (IArchimateRelationship relation : elementSource.getSourceRelationships()) {
for (IDiagramModelObject dmoTarget : dm.getChildren()) {
IArchimateElement elementTarget = ((IDiagramModelArchimateObject) dmoTarget).getArchimateElement();
// Don't add connections that are not connected to the main elements if option is set
if (!fAddAllConnections && !(fSelectedElements.contains(elementSource)) && !(fSelectedElements.contains(elementTarget))) {
continue;
}
if (relation.getTarget() == elementTarget) {
// Create connection
IDiagramModelArchimateConnection newConnection = ArchimateDiagramModelFactory.createDiagramModelArchimateConnection(relation);
newConnection.connect(dmoSource, dmoTarget);
}
}
}
}
// Add connections to connections
for (Iterator<EObject> iter1 = dm.eAllContents(); iter1.hasNext(); ) {
EObject eObject1 = iter1.next();
if (eObject1 instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateConnection connection = (IDiagramModelArchimateConnection) eObject1;
for (IDiagramModelObject dmo : dm.getChildren()) {
IArchimateElement element = ((IDiagramModelArchimateObject) dmo).getArchimateElement();
for (IArchimateRelationship relation : connection.getArchimateRelationship().getSourceRelationships()) {
if (relation.getTarget() == element) {
IDiagramModelArchimateConnection newConnection = ArchimateDiagramModelFactory.createDiagramModelArchimateConnection(relation);
newConnection.connect(connection, dmo);
}
}
for (IArchimateRelationship relation : connection.getArchimateRelationship().getTargetRelationships()) {
if (relation.getSource() == element) {
IDiagramModelArchimateConnection newConnection = ArchimateDiagramModelFactory.createDiagramModelArchimateConnection(relation);
newConnection.connect(dmo, connection);
}
}
}
}
}
return dm;
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class OpacitySection method update.
@Override
protected void update() {
if (fIsExecutingCommand) {
return;
}
IDiagramModelObject lastSelected = (IDiagramModelObject) getFirstSelectedObject();
fSpinner.setSelection(lastSelected.getAlpha());
fSpinner.setEnabled(!isLocked(lastSelected));
}
use of com.archimatetool.model.IDiagramModelObject in project archi by archimatetool.
the class DiagramModelObjectTests method testGetCopy.
@Override
@Test
public void testGetCopy() {
super.testGetCopy();
IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
conn.connect(object, object);
object.addConnection(conn);
assertTrue(object.getSourceConnections().contains(conn));
assertTrue(object.getTargetConnections().contains(conn));
IBounds bounds = IArchimateFactory.eINSTANCE.createBounds(2, 4, 6, 8);
object.setBounds(bounds);
IDiagramModelObject copy = (IDiagramModelObject) object.getCopy();
assertNotSame(object, copy);
assertTrue(copy.getSourceConnections().isEmpty());
assertTrue(copy.getTargetConnections().isEmpty());
assertNotSame(bounds, copy.getBounds());
assertEquals(bounds.getX(), copy.getBounds().getX());
assertEquals(bounds.getY(), copy.getBounds().getY());
assertEquals(bounds.getWidth(), copy.getBounds().getWidth());
assertEquals(bounds.getHeight(), copy.getBounds().getHeight());
}
use of com.archimatetool.model.IDiagramModelObject 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);
}
}
}
Aggregations