use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramModelConnectionSection method createRouterTypeControl.
private void createRouterTypeControl(Composite parent) {
// Label
createLabel(parent, Messages.DiagramModelConnectionSection_0, ITabbedLayoutConstants.BIG_LABEL_WIDTH, SWT.CENTER);
// Combo
fComboRouterType = new Combo(parent, SWT.READ_ONLY);
fComboRouterType.setItems(comboItems);
fComboRouterType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
CompoundCommand result = new CompoundCommand();
for (EObject dm : getEObjects()) {
if (isAlive(dm)) {
Command cmd = new ConnectionRouterTypeCommand((IDiagramModel) dm, ConnectionRouterAction.CONNECTION_ROUTER_TYPES.get(fComboRouterType.getSelectionIndex()));
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
});
GridData gd = new GridData(SWT.NONE, SWT.NONE, true, false);
gd.minimumWidth = ITabbedLayoutConstants.COMBO_WIDTH;
fComboRouterType.setLayoutData(gd);
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class CopySnapshot method translateToAbsolute.
/**
* Translate an objects x,y position to absolute co-ordinates
* @param object
* @param pt
*/
private void translateToAbsolute(IDiagramModelObject object, Point pt) {
if (object.eContainer() instanceof IDiagramModelContainer && !(object.eContainer() instanceof IDiagramModel)) {
IDiagramModelObject parent = (IDiagramModelObject) object.eContainer();
pt.performTranslate(parent.getBounds().getX(), parent.getBounds().getY());
translateToAbsolute(parent, pt);
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DeleteFromModelAction method run.
@Override
public void run() {
List<?> selection = getSelectedObjects();
List<IArchimateConcept> archimateConcepts = new ArrayList<IArchimateConcept>();
List<IDiagramModelComponent> diagramObjects = new ArrayList<IDiagramModelComponent>();
// Gather Model elements, relations
for (Object object : selection) {
if (object instanceof EditPart) {
Object model = ((EditPart) object).getModel();
if (model instanceof IDiagramModelArchimateObject) {
IArchimateElement element = ((IDiagramModelArchimateObject) model).getArchimateElement();
if (!archimateConcepts.contains(element)) {
archimateConcepts.add(element);
}
// Element's relationships
for (IArchimateRelationship relation : ArchimateModelUtils.getAllRelationshipsForConcept(element)) {
if (!archimateConcepts.contains(relation)) {
archimateConcepts.add(relation);
}
// Relation's relationships
for (IArchimateRelationship r : ArchimateModelUtils.getAllRelationshipsForConcept(relation)) {
if (!archimateConcepts.contains(r)) {
archimateConcepts.add(r);
}
}
}
} else if (model instanceof IDiagramModelArchimateConnection) {
IArchimateRelationship relation = ((IDiagramModelArchimateConnection) model).getArchimateRelationship();
if (!archimateConcepts.contains(relation)) {
archimateConcepts.add(relation);
}
// Relation's relationships
for (IArchimateRelationship r : ArchimateModelUtils.getAllRelationshipsForConcept(relation)) {
if (!archimateConcepts.contains(r)) {
archimateConcepts.add(r);
}
}
}
}
}
// Gather referenced diagram objects
for (IArchimateConcept archimateConcept : archimateConcepts) {
for (IDiagramModel diagramModel : archimateConcept.getArchimateModel().getDiagramModels()) {
for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, archimateConcept)) {
diagramObjects.add(dc);
}
}
}
// Check whether any of these concepts are referenced in other diagrams
if (hasMoreThanOneReference(archimateConcepts, diagramObjects)) {
if (!MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.DeleteFromModelAction_0, Messages.DeleteFromModelAction_1 + // $NON-NLS-1$
"\n\n" + Messages.DeleteFromModelAction_2)) {
return;
}
}
// Create commands
CompoundCommand compoundCommand = new NonNotifyingCompoundCommand(TEXT);
for (IArchimateConcept archimateConcept : archimateConcepts) {
if (archimateConcept instanceof IArchimateElement) {
Command cmd = new DeleteArchimateElementCommand((IArchimateElement) archimateConcept);
compoundCommand.add(cmd);
} else if (archimateConcept instanceof IArchimateRelationship) {
Command cmd = new DeleteArchimateRelationshipCommand((IArchimateRelationship) archimateConcept);
compoundCommand.add(cmd);
}
}
for (IDiagramModelComponent dc : diagramObjects) {
if (dc instanceof IDiagramModelObject) {
Command cmd = DiagramCommandFactory.createDeleteDiagramObjectCommand((IDiagramModelObject) dc);
compoundCommand.add(cmd);
} else if (dc instanceof IDiagramModelConnection) {
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand((IDiagramModelConnection) dc);
compoundCommand.add(cmd);
}
}
execute(compoundCommand);
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramEditorInputFactory method saveState.
/**
* Saves the state of the given diagram editor input into the given memento.
*
* @param memento the storage area for element state
* @param input the diagram editor input
*/
public static void saveState(IMemento memento, DiagramEditorInput input) {
IDiagramModel diagramModel = input.getDiagramModel();
if (diagramModel != null && diagramModel.getArchimateModel() != null) {
memento.putString(TAG_VIEW_ID, diagramModel.getId());
String name = diagramModel.getName();
if (name != null) {
memento.putString(TAG_VIEW_NAME, name);
}
File file = diagramModel.getArchimateModel().getFile();
if (file != null) {
memento.putString(TAG_VIEW_FILE, file.getAbsolutePath());
}
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class DiagramEditorInputFactory method createElement.
@Override
public IAdaptable createElement(IMemento memento) {
String viewID = memento.getString(TAG_VIEW_ID);
String fileName = memento.getString(TAG_VIEW_FILE);
String viewName = memento.getString(TAG_VIEW_NAME);
if (viewID != null && fileName != null) {
File file = new File(fileName);
for (IArchimateModel model : IEditorModelManager.INSTANCE.getModels()) {
if (file.equals(model.getFile())) {
for (IDiagramModel diagramModel : model.getDiagramModels()) {
if (viewID.equals(diagramModel.getId())) {
return new DiagramEditorInput(diagramModel);
}
}
}
}
}
// Cannot find it, must have been removed from file
return new NullDiagramEditorInput(fileName, viewName);
}
Aggregations