use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramModelReferenceEditPart method removeECoreAdapter.
@Override
protected void removeECoreAdapter() {
super.removeECoreAdapter();
// Unlisten to referenced model
IDiagramModel ref = ((IDiagramModelReference) getModel()).getReferencedModel();
if (ref != null) {
ref.eAdapters().remove(getECoreAdapter());
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramModelReferenceFigure method drawIcon.
/**
* Draw the icon
*/
protected void drawIcon(Graphics graphics) {
// Draw the icon depending on the diagramModelObject
IDiagramModel dm = ((IDiagramModelReference) getDiagramModelObject()).getReferencedModel();
IGraphicsIcon graphicsIcon = ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(dm);
if (graphicsIcon != null) {
graphicsIcon.drawIcon(graphics, getIconOrigin());
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class TreeModelViewActionFactory method getNewObjectActions.
/**
* @param selected
* @return A List (perhaps empty) of Actions for a given selected object
*/
public List<IAction> getNewObjectActions(Object selected) {
List<IAction> list = new ArrayList<IAction>();
// If we have selected a leaf object, go up to parent
if (selected instanceof IArchimateElement || selected instanceof IDiagramModel) {
selected = ((EObject) selected).eContainer();
}
// We want a folder
if (!(selected instanceof IFolder)) {
return list;
}
IFolder folder = (IFolder) selected;
// Find topmost folder type
IFolder f = folder;
while (f.eContainer() instanceof IFolder) {
f = (IFolder) f.eContainer();
}
switch(f.getType()) {
case STRATEGY:
for (EClass eClass : ArchimateModelUtils.getStrategyClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case BUSINESS:
for (EClass eClass : ArchimateModelUtils.getBusinessClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case APPLICATION:
for (EClass eClass : ArchimateModelUtils.getApplicationClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case MOTIVATION:
for (EClass eClass : ArchimateModelUtils.getMotivationClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case IMPLEMENTATION_MIGRATION:
for (EClass eClass : ArchimateModelUtils.getImplementationMigrationClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case TECHNOLOGY:
// Technology
for (EClass eClass : ArchimateModelUtils.getTechnologyClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
list.add(null);
// Physical
for (EClass eClass : ArchimateModelUtils.getPhysicalClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case OTHER:
// Grouping and Location
for (EClass eClass : ArchimateModelUtils.getOtherClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
list.add(null);
// Connectors
for (EClass eClass : ArchimateModelUtils.getConnectorClasses()) {
IAction action = createNewElementAction(folder, eClass);
list.add(action);
}
break;
case DIAGRAMS:
list.add(createNewArchimateDiagramAction(folder));
list.add(createNewSketchAction(folder));
break;
default:
break;
}
return list;
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DeleteCommandHandler method getElementsToDelete.
/**
* Create the list of objects to delete and check
* @return
*/
private void getElementsToDelete() {
// Actual elements to delete
fElementsToDelete = new ArrayList<Object>();
// First, gather up the list of Archimate objects to be deleted...
for (Object object : fSelectedObjects) {
if (canDelete(object)) {
addToList(object, fElementsToDelete);
addFolderChildElements(object);
addElementRelationships(object);
}
}
// Gather referenced diagram objects to be deleted checking that the parent diagram model is not also selected to be deleted
for (Object object : new ArrayList<>(fElementsToDelete)) {
// Archimate Components
if (object instanceof IArchimateConcept) {
IArchimateConcept archimateConcept = (IArchimateConcept) object;
for (IDiagramModel diagramModel : archimateConcept.getArchimateModel().getDiagramModels()) {
// Check diagram model is not selected to be deleted - no point in deleting any of its children
if (!fElementsToDelete.contains(diagramModel)) {
for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, archimateConcept)) {
addToList(dc, fElementsToDelete);
}
}
}
}
// Diagram Models and their references
if (object instanceof IDiagramModel) {
IDiagramModel diagramModelDeleted = (IDiagramModel) object;
for (IDiagramModel diagramModel : diagramModelDeleted.getArchimateModel().getDiagramModels()) {
// is there one?
List<IDiagramModelReference> list = DiagramModelUtils.findDiagramModelReferences(diagramModel, diagramModelDeleted);
fElementsToDelete.addAll(list);
}
}
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DuplicateCommandHandler method createCommands.
private void createCommands() {
for (Object object : fElementsToDuplicate) {
CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
if (compoundCommand == null) {
// sanity check
// $NON-NLS-1$
System.err.println("Could not get CompoundCommand in " + getClass());
continue;
}
if (object instanceof IDiagramModel) {
Command cmd = new DuplicateDiagramModelCommand((IDiagramModel) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateElement) {
Command cmd = new DuplicateElementCommand((IArchimateElement) object);
compoundCommand.add(cmd);
}
}
}
Aggregations