Search in sources :

Example 11 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project tdi-studio-se by Talend.

the class BusinessReferenceConnectionEditPolicy method createDeleteSemanticCommand.

/**
     * @generated
     */
protected Command createDeleteSemanticCommand(GroupRequest deleteRequest) {
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    EditCommandRequestWrapper semReq = new EditCommandRequestWrapper(new DestroyElementRequest(editingDomain, false), deleteRequest.getExtendedData());
    Command semanticCmd = getHost().getCommand(semReq);
    if (semanticCmd != null && semanticCmd.canExecute()) {
        CompoundCommand cc = new CompoundCommand();
        cc.add(semanticCmd);
        return cc;
    }
    return null;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) DestroyElementRequest(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) DeleteCommand(org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) EditCommandRequestWrapper(org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 12 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project cubrid-manager by CUBRID.

the class DeleteAction method buildDeleteCommands.

public Command buildDeleteCommands(List<EditPart> parts) {
    if (parts == null || parts.size() == 0) {
        return null;
    }
    GroupRequest delRequest = new GroupRequest(RequestConstants.REQ_DELETE);
    delRequest.setEditParts(parts);
    CompoundCommand compCommands = new CompoundCommand(RequestConstants.REQ_DELETE);
    for (EditPart part : parts) {
        Command cmd = part.getCommand(delRequest);
        if (cmd != null) {
            compCommands.add(cmd);
        }
    }
    return compCommands;
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) EditPart(org.eclipse.gef.EditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 13 with CompoundCommand

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

the class ReconnectDiagramConnectionCommand method createBendPointsCommand.

/**
 * Adding a circular connection requires some bendpoints
 */
protected Command createBendPointsCommand() {
    // Only works for IDiagramModelObject as source and target objects not for connections
    if (!(fConnection.getSource() instanceof IDiagramModelObject) && !(fConnection.getTarget() instanceof IDiagramModelObject)) {
        return null;
    }
    IDiagramModelObject source = (IDiagramModelObject) fConnection.getSource();
    IDiagramModelObject target = (IDiagramModelObject) fConnection.getTarget();
    int width = source.getBounds().getWidth();
    if (width == -1) {
        width = 100;
    }
    int height = target.getBounds().getHeight();
    if (height == -1) {
        height = 60;
    }
    width = (int) Math.max(100, width * 0.6);
    height = (int) Math.max(60, height * 0.6);
    CompoundCommand result = new CompoundCommand();
    CreateBendpointCommand cmd = new CreateBendpointCommand();
    cmd.setDiagramModelConnection(fConnection);
    cmd.setRelativeDimensions(new Dimension(width, 0), new Dimension(width, 0));
    result.add(cmd);
    cmd = new CreateBendpointCommand();
    cmd.setDiagramModelConnection(fConnection);
    cmd.setRelativeDimensions(new Dimension(width, height), new Dimension(width, height));
    result.add(cmd);
    cmd = new CreateBendpointCommand();
    cmd.setDiagramModelConnection(fConnection);
    cmd.setRelativeDimensions(new Dimension(0, height), new Dimension(0, height));
    result.add(cmd);
    return result;
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Dimension(org.eclipse.draw2d.geometry.Dimension) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 14 with CompoundCommand

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

the class DuplicateCommandHandler method duplicate.

/**
 * Perform the duplicate command
 */
public void duplicate() {
    // Gather the elements to duplicate
    getElementsToDuplicate();
    // 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
    UIRequestManager.INSTANCE.fireRequest(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 15 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand 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)

Aggregations

CompoundCommand (org.eclipse.gef.commands.CompoundCommand)148 Command (org.eclipse.gef.commands.Command)63 EObject (org.eclipse.emf.ecore.EObject)28 ArrayList (java.util.ArrayList)23 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)22 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)17 List (java.util.List)16 EditPart (org.eclipse.gef.EditPart)16 IElementParameter (org.talend.core.model.process.IElementParameter)16 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)15 Node (org.talend.designer.core.ui.editor.nodes.Node)15 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)14 Point (org.eclipse.draw2d.geometry.Point)14 Rectangle (org.eclipse.draw2d.geometry.Rectangle)14 INode (org.talend.core.model.process.INode)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 RepositoryNode (org.talend.repository.model.RepositoryNode)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 ConnectionItem (org.talend.core.model.properties.ConnectionItem)12 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11