Search in sources :

Example 36 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.

the class GenerateViewAction method run.

@Override
public void run() {
    List<IArchimateElement> selected = getValidSelectedObjects(getSelection());
    if (!selected.isEmpty()) {
        GenerateViewCommand command = new GenerateViewCommand(selected);
        if (command.openDialog(Display.getCurrent().getActiveShell())) {
            CommandStack commandStack = (CommandStack) ((IAdapter) selected.get(0)).getAdapter(CommandStack.class);
            commandStack.execute(command);
        }
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IArchimateElement(com.archimatetool.model.IArchimateElement) GenerateViewCommand(com.archimatetool.editor.tools.GenerateViewCommand)

Example 37 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.

the class DuplicateCommandHandler method duplicate.

/**
 * Perform the duplicate command
 */
public void duplicate() {
    // Create the Commands
    createCommands();
    // Execute the Commands on the CommandStack(s) - there could be more than one if more than one model open in the Tree
    for (Entry<CommandStack, CompoundCommand> entry : fCommandMap.entrySet()) {
        entry.getKey().execute(entry.getValue());
    }
    // Select new objects in Tree asyncronously
    UIRequestManager.INSTANCE.fireRequestAsync(new TreeSelectionRequest(this, new StructuredSelection(fNewObjects), true));
    dispose();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) TreeSelectionRequest(com.archimatetool.editor.views.tree.TreeSelectionRequest) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Example 38 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.

the class DuplicateCommandHandler method getCompoundCommand.

/**
 * Get, and if need be create, a CompoundCommand to which to add the object to be duplicated command
 */
private CompoundCommand getCompoundCommand(IAdapter object) {
    // Get the Command Stack registered to the object
    CommandStack stack = (CommandStack) object.getAdapter(CommandStack.class);
    if (stack == null) {
        // $NON-NLS-1$
        System.err.println("CommandStack was null in " + getClass());
        return null;
    }
    // Now get or create a Compound Command
    CompoundCommand compoundCommand = fCommandMap.get(stack);
    if (compoundCommand == null) {
        compoundCommand = new NonNotifyingCompoundCommand(Messages.DuplicateCommandHandler_1);
        fCommandMap.put(stack, compoundCommand);
    }
    return compoundCommand;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Example 39 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.

the class SortFolderAction method run.

@Override
public void run() {
    Object selected = getSelection().getFirstElement();
    if (selected instanceof IFolder) {
        IFolder folder = (IFolder) selected;
        Command cmd = new SortFolderCommand(folder);
        CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
        commandStack.execute(cmd);
    }
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) SortFolderCommand(com.archimatetool.editor.views.tree.commands.SortFolderCommand) Command(org.eclipse.gef.commands.Command) SortFolderCommand(com.archimatetool.editor.views.tree.commands.SortFolderCommand) IFolder(com.archimatetool.model.IFolder)

Example 40 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project archi by archimatetool.

the class TreeModelViewActionFactory method createNewSketchAction.

private IAction createNewSketchAction(final IFolder folder) {
    IAction action = new Action(Messages.TreeModelViewActionFactory_2) {

        @Override
        public void run() {
            // Create a new Diagram Model, set its name
            ISketchModel sketchModel = IArchimateFactory.eINSTANCE.createSketchModel();
            sketchModel.setName(Messages.TreeModelViewActionFactory_3);
            // Defaults
            int defaultBackground = ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.SKETCH_DEFAULT_BACKGROUND);
            sketchModel.setBackground(defaultBackground);
            // Execute Command
            Command cmd = new NewDiagramCommand(folder, sketchModel, Messages.TreeModelViewActionFactory_3);
            CommandStack commandStack = (CommandStack) folder.getAdapter(CommandStack.class);
            commandStack.execute(cmd);
        }
    };
    action.setImageDescriptor(IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_SKETCH));
    return action;
}
Also used : NewDiagramCommand(com.archimatetool.editor.views.tree.commands.NewDiagramCommand) 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) NewFolderCommand(com.archimatetool.editor.views.tree.commands.NewFolderCommand) Command(org.eclipse.gef.commands.Command) NewElementCommand(com.archimatetool.editor.views.tree.commands.NewElementCommand) ISketchModel(com.archimatetool.model.ISketchModel)

Aggregations

CommandStack (org.eclipse.gef.commands.CommandStack)105 Command (org.eclipse.gef.commands.Command)32 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)13 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)13 IArchimateModel (com.archimatetool.model.IArchimateModel)12 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)12 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)12 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)10 EditPart (org.eclipse.gef.EditPart)10 INode (org.talend.core.model.process.INode)10 Node (org.talend.designer.core.ui.editor.nodes.Node)9 IEntity (org.whole.lang.model.IEntity)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 PersistenceException (org.talend.commons.exception.PersistenceException)8 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)7 IFolder (com.archimatetool.model.IFolder)6 IOException (java.io.IOException)6 IEditorPart (org.eclipse.ui.IEditorPart)6