Search in sources :

Example 1 with NewElementCommand

use of com.archimatetool.editor.views.tree.commands.NewElementCommand 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;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) NewDiagramCommand(com.archimatetool.editor.views.tree.commands.NewDiagramCommand) Command(org.eclipse.gef.commands.Command) NewElementCommand(com.archimatetool.editor.views.tree.commands.NewElementCommand) NewElementCommand(com.archimatetool.editor.views.tree.commands.NewElementCommand) IArchimateElement(com.archimatetool.model.IArchimateElement)

Aggregations

NewDiagramCommand (com.archimatetool.editor.views.tree.commands.NewDiagramCommand)1 NewElementCommand (com.archimatetool.editor.views.tree.commands.NewElementCommand)1 IArchimateElement (com.archimatetool.model.IArchimateElement)1 Command (org.eclipse.gef.commands.Command)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1