use of com.archimatetool.model.IDiagramModelContainer in project archi by archimatetool.
the class BasicContainerEditPolicy method getOrphanChildrenCommand.
/*
* This allows us to drag parts from a parent container to another.
* This is the "remove" counterpart to the "add" Command created in DiagramLayoutPolicy.createAddCommand(EditPart, Object);
*
* If you don't want a part to be removed, return null here.
*/
@Override
public Command getOrphanChildrenCommand(GroupRequest request) {
CompoundCommand result = new CompoundCommand(Messages.BasicContainerEditPolicy_0);
IDiagramModelContainer parent = (IDiagramModelContainer) getHost().getModel();
for (Object o : request.getEditParts()) {
EditPart editPart = (EditPart) o;
IDiagramModelObject child = (IDiagramModelObject) editPart.getModel();
result.add(new RemoveObjectCommand(parent, child));
}
return result;
}
use of com.archimatetool.model.IDiagramModelContainer in project archi by archimatetool.
the class DiagramLayoutPolicy method createAddCommand.
/*
* This allows us to drag parts from a parent container to another.
* This is the "add" counterpart to the "remove" Command created in BasicContainerEditPolicy.getOrphanChildrenCommand(GroupRequest);
*
* If you don't want a part to be added, return null here.
*/
@Override
protected AddObjectCommand createAddCommand(ChangeBoundsRequest request, EditPart childEditPart, Object constraint) {
IDiagramModelContainer parent = (IDiagramModelContainer) getHost().getModel();
IDiagramModelObject child = (IDiagramModelObject) childEditPart.getModel();
// Keep within box
Rectangle bounds = (Rectangle) constraint;
if (bounds.x < 0) {
bounds.x = 0;
}
if (bounds.y < 0) {
bounds.y = 0;
}
return new AddObjectCommand(parent, child, bounds);
}
use of com.archimatetool.model.IDiagramModelContainer 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.IDiagramModelContainer 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.IDiagramModelContainer 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