use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class TreeSelectionSynchroniser method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (isDispatching) {
return;
}
fLastEvent = event;
if (!Preferences.doLinkView() || !fDoSync) {
return;
}
isDispatching = true;
ISelection selection = event.getSelection();
Object source = event.getSource();
// Selection from Diagram Editor, so update the Tree if it is showing
if (source instanceof GraphicalViewer && fTreeView != null) {
List<Object> list = new ArrayList<Object>();
for (Object o : ((IStructuredSelection) selection).toArray()) {
if (o instanceof EditPart) {
Object model = ((EditPart) o).getModel();
// Archimate concept
if (model instanceof IDiagramModelArchimateComponent) {
model = ((IDiagramModelArchimateComponent) model).getArchimateConcept();
list.add(model);
} else // Diagram model
if (model instanceof IDiagramModel) {
list.add(model);
}
}
}
// Select in tree
fTreeView.getViewer().setSelection(new StructuredSelection(list), true);
} else // Archimate objects selection from Tree View, so update any Archimate Diagram Editors
if (source instanceof TreeViewer) {
List<IArchimateConcept> list = new ArrayList<IArchimateConcept>();
// Archimate elements
for (Object o : ((IStructuredSelection) selection).toArray()) {
if (o instanceof IArchimateConcept) {
list.add((IArchimateConcept) o);
}
}
// Select these in the Diagram Editors
for (IDiagramModelEditor diagramEditor : fDiagramEditors) {
if (diagramEditor instanceof IArchimateDiagramEditor) {
((IArchimateDiagramEditor) diagramEditor).selectArchimateConcepts(list.toArray(new IArchimateConcept[list.size()]));
}
}
}
isDispatching = false;
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class TreeModelViewActionFactory method createNewArchimateDiagramAction.
private IAction createNewArchimateDiagramAction(final IFolder folder) {
IAction action = new Action(Messages.TreeModelViewActionFactory_0) {
@Override
public void run() {
// Create a new Diagram Model, set its name
IDiagramModel diagramModel = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
diagramModel.setName(Messages.TreeModelViewActionFactory_1);
// Execute Command
Command cmd = new NewDiagramCommand(folder, diagramModel, Messages.TreeModelViewActionFactory_1);
CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
commandStack.execute(cmd);
}
};
action.setImageDescriptor(IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_DIAGRAM));
return action;
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DeleteCommandHandler method createCommands.
/**
* Create the Delete Commands
*/
private void createCommands() {
/*
* We need to ensure that the Delete Diagram Model Commands are called first in order to close
* any open diagram editors before removing their models from parent folders.
*/
for (Object object : fElementsToDelete) {
if (object instanceof IDiagramModel) {
CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
if (compoundCommand != null) {
Command cmd = new DeleteDiagramModelCommand((IDiagramModel) object);
compoundCommand.add(cmd);
} else {
// $NON-NLS-1$
System.err.println("Could not get CompoundCommand in " + getClass());
}
}
}
/*
* Then the other types
*/
for (Object object : fElementsToDelete) {
if (object instanceof IDiagramModel) {
// already done
continue;
}
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 IFolder) {
Command cmd = new DeleteFolderCommand((IFolder) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateElement) {
Command cmd = new DeleteArchimateElementCommand((IArchimateElement) object);
compoundCommand.add(cmd);
} else if (object instanceof IArchimateRelationship) {
Command cmd = new DeleteArchimateRelationshipCommand((IArchimateRelationship) object);
compoundCommand.add(cmd);
} else if (object instanceof IDiagramModelObject) {
Command cmd = DiagramCommandFactory.createDeleteDiagramObjectCommand((IDiagramModelObject) object);
compoundCommand.add(cmd);
} else if (object instanceof IDiagramModelConnection) {
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand((IDiagramModelConnection) object);
compoundCommand.add(cmd);
}
}
}
Aggregations