Search in sources :

Example 86 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project tmdmaker by tmdmaker.

the class SubsetCreateDialog method okPressed.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 */
@Override
protected void okPressed() {
    editedSubsetType = createEditedSubsetType();
    editedExceptNull = panel.isExceptNull();
    int partitionSelectionIndex = panel.getSelectedPartitionAttributeIndex();
    if (partitionSelectionIndex != -1) {
        editedPartitionAttribute = this.attributes.get(partitionSelectionIndex);
    }
    editedSubsetEntities = panel.getSubsetEntityList();
    deletedSubsetEntities = panel.getDeletedSubsetEntityList();
    ccommand = new CompoundCommand();
    addSubsetAddCommand();
    addSubsetTypeChangeCommand();
    addSubsetEntityRenameCommand();
    addSubsetDeleteCommand();
    super.okPressed();
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 87 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project tmdmaker by tmdmaker.

the class VirtualSupersetCreateAction method run.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    // アクション呼び出し時のマウスカーソル位置を取得。位置の微調整必要かも
    Point pos = getControlCursorLocation();
    List<AbstractEntityModel> selectedModels = getSelectedModelList();
    Diagram diagram = getDiagram();
    VirtualSuperset original = null;
    VirtualSupersetType aggregator = null;
    if (!selectedModels.isEmpty()) {
        original = getVirtualSuperset();
        if (original != null) {
            selectedModels.remove(original);
        }
    }
    VirtualSupersetCreateDialog dialog = new VirtualSupersetCreateDialog(getControl().getShell(), diagram, original, selectedModels);
    if (dialog.open() == Dialog.OK) {
        CompoundCommand ccommand = null;
        VirtualSuperset edited = dialog.getEditedValue();
        aggregator = dialog.getEditedAggregator();
        List<AbstractEntityModel> selection = dialog.getSelection();
        // みなしスーパーセット作成
        if (original == null) {
            if (selection.isEmpty()) {
                return;
            }
            ccommand = new CompoundCommand();
            ccommand.add(new VirtualSupersetCreateCommand(edited, selection, pos.x, pos.y));
            ccommand.add(new VirtualSupersetTypeChangeCommand(edited, aggregator.isApplyAttribute()));
        } else {
            ccommand = new VirtualSupersetEditCommand(original, edited, selection, aggregator.isApplyAttribute());
        }
        execute(ccommand);
    }
}
Also used : VirtualSupersetCreateCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetCreateCommand) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) VirtualSupersetCreateDialog(org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) VirtualSupersetTypeChangeCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetTypeChangeCommand) Point(org.eclipse.swt.graphics.Point) VirtualSupersetEditCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 88 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project tmdmaker by tmdmaker.

the class FileImportAction method getCreateCommands.

private Command getCreateCommands(List<AbstractEntityModel> list, Point p) {
    CompoundCommand ccommand = new CompoundCommand();
    Diagram diagram = (Diagram) viewer.getContents().getModel();
    int i = 0;
    for (AbstractEntityModel model : list) {
        EntityModelAddCommand c = new EntityModelAddCommand(diagram, p.x + i, p.y + i);
        i += 5;
        c.setModel(model);
        ccommand.add(c);
    }
    return ccommand.unwrap();
}
Also used : EntityModelAddCommand(org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand) Point(org.eclipse.draw2d.geometry.Point) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Diagram(org.tmdmaker.core.model.Diagram)

Example 89 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project jbosstools-base by jbosstools.

the class DefaultAlignmentAction method createAlignmentCommand.

private Command createAlignmentCommand() {
    AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN);
    request.setAlignmentRectangle(calculateAlignmentRectangle(request));
    request.setAlignment(alignment);
    List editparts = getOperationSet(request);
    if (editparts.size() < 2)
        return null;
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel(getText());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart editpart = (EditPart) editparts.get(i);
        command.add(editpart.getCommand(request));
    }
    return command;
}
Also used : AlignmentRequest(org.eclipse.gef.requests.AlignmentRequest) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) List(java.util.List) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 90 with CompoundCommand

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

the class SketchDNDEditPolicy method getDropCommand.

@Override
protected Command getDropCommand(DiagramDropRequest request) {
    if (!(request.getData() instanceof IStructuredSelection)) {
        return null;
    }
    // XY drop point
    Point pt = getDropLocation(request);
    // Origin
    int origin = pt.x;
    int x = pt.x;
    int y = pt.y;
    // Gather an actual list of elements dragged onto the container, omitting duplicates and anything already on the diagram
    Object[] objects = ((IStructuredSelection) request.getData()).toArray();
    List<IDiagramModel> list = getDiagramRefsToAdd(objects);
    // Compound Command
    CompoundCommand result = new CompoundCommand(Messages.SketchDNDEditPolicy_0);
    for (IDiagramModel diagramModel : list) {
        result.add(new AddDiagramModelReferenceCommand(getTargetContainer(), diagramModel, x, y));
        x += 150;
        if (x > origin + 400) {
            x = origin;
            y += 100;
        }
    }
    return result;
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Point(org.eclipse.draw2d.geometry.Point) AddDiagramModelReferenceCommand(com.archimatetool.editor.diagram.commands.AddDiagramModelReferenceCommand) Point(org.eclipse.draw2d.geometry.Point) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

CompoundCommand (org.eclipse.gef.commands.CompoundCommand)193 Command (org.eclipse.gef.commands.Command)86 EObject (org.eclipse.emf.ecore.EObject)40 ArrayList (java.util.ArrayList)28 EditPart (org.eclipse.gef.EditPart)28 List (java.util.List)24 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)18 Point (org.eclipse.draw2d.geometry.Point)16 IElementParameter (org.talend.core.model.process.IElementParameter)16 Combo (org.eclipse.swt.widgets.Combo)15 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 Rectangle (org.eclipse.draw2d.geometry.Rectangle)14 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)14 INode (org.talend.core.model.process.INode)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14