use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class TreeModelViewActionFactory method createNewElementAction.
private IAction createNewElementAction(final IFolder folder, final EClass eClass) {
IAction action = new Action(ArchiLabelProvider.INSTANCE.getDefaultName(eClass)) {
@Override
public void run() {
// Create a new Archimate Element, set its name
IArchimateElement element = (IArchimateElement) IArchimateFactory.eINSTANCE.create(eClass);
element.setName(getText());
// Execute Command
Command cmd = new NewElementCommand(folder, element);
CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
commandStack.execute(cmd);
}
};
action.setImageDescriptor(ArchiLabelProvider.INSTANCE.getImageDescriptor(eClass));
return action;
}
use of com.archimatetool.model.IArchimateElement 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