org.eclipse.gef.commands.CompoundCommand Java Examples

The following examples show how to use org.eclipse.gef.commands.CompoundCommand. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeleteWithoutUpdateAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public Command createDeleteCommand(@SuppressWarnings("rawtypes") List objects) {
    final Command command = super.createDeleteCommand(objects);

    if (command == null) {
        return null;
    }

    if (command instanceof CompoundCommand) {
        final CompoundCommand compoundCommand = (CompoundCommand) command;
        if (compoundCommand.getCommands().isEmpty()) {
            return null;
        }
    }

    final EditPart editPart = part.getGraphicalViewer().getContents();
    final ERDiagram diagram = ERModelUtil.getDiagram(editPart);

    return new WithoutUpdateCommandWrapper(command, diagram);
}
 
Example #2
Source File: AbstractBaseSelectionAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
protected void execute(Event event) {
	GraphicalViewer viewer = this.getGraphicalViewer();

	List<Command> commandList = new ArrayList<Command>();

	for (Object object : viewer.getSelectedEditParts()) {
		List<Command> subCommandList = this.getCommand((EditPart) object,
				event);
		commandList.addAll(subCommandList);
	}

	if (!commandList.isEmpty()) {
		CompoundCommand compoundCommand = new CompoundCommand();
		for (Command command : commandList) {
			compoundCommand.add(command);
		}

		this.execute(compoundCommand);
	}
}
 
Example #3
Source File: ERTableEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequestOpen() {
    final ERTable table = (ERTable) getModel();
    final ERDiagram diagram = getDiagram();

    final ERTable copyTable = table.copyData();

    final TableDialog dialog = new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable);

    if (dialog.open() == IDialogConstants.OK_ID) {
        final CompoundCommand command = createChangeTablePropertyCommand(diagram, table, copyTable);

        executeCommand(command.unwrap());
    }
}
 
Example #4
Source File: NoteDirectEditPolicy.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getDirectEditCommand(final DirectEditRequest request) {
    final CompoundCommand command = new CompoundCommand();

    final String text = (String) request.getCellEditor().getValue();

    final Note note = (Note) getHost().getModel();
    final NoteEditCommand noteEditCommand = new NoteEditCommand(note, text);
    command.add(noteEditCommand);

    final MoveElementCommand autoResizeCommand = new MoveElementCommand((ERDiagram) getHost().getRoot().getContents().getModel(), getHostFigure().getBounds(), note.getX(), note.getY(), -1, -1, note);
    command.add(autoResizeCommand);

    return command.unwrap();
}
 
Example #5
Source File: ViewEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequestOpen() {
	View view = (View) this.getModel();
	ERDiagram diagram = this.getDiagram();

	View copyView = view.copyData();

	ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench()
			.getActiveWorkbenchWindow().getShell(), this.getViewer(),
			copyView, diagram.getDiagramContents().getGroups());

	if (dialog.open() == IDialogConstants.OK_ID) {
		CompoundCommand command = createChangeViewPropertyCommand(diagram,
				view, copyView);

		this.executeCommand(command.unwrap());
	}
}
 
Example #6
Source File: TableOutlineEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(Request request) {
	ERTable table = (ERTable) this.getModel();
	ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel();

	if (request.getType().equals(RequestConstants.REQ_OPEN)) {
		ERTable copyTable = table.copyData();

		TableDialog dialog = new TableDialog(PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getShell(), this.getViewer(),
				copyTable, diagram.getDiagramContents().getGroups());

		if (dialog.open() == IDialogConstants.OK_ID) {
			CompoundCommand command = ERTableEditPart
					.createChangeTablePropertyCommand(diagram, table,
							copyTable);

			this.execute(command.unwrap());
		}
	}

	super.performRequest(request);
}
 
Example #7
Source File: ViewEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequestOpen() {
    final View view = (View) getModel();
    final ERDiagram diagram = getDiagram();

    final View copyView = view.copyData();

    final ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyView);

    if (dialog.open() == IDialogConstants.OK_ID) {
        final CompoundCommand command = createChangeViewPropertyCommand(diagram, view, copyView);

        executeCommand(command.unwrap());
    }
}
 
Example #8
Source File: TableOutlineEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(final Request request) {
    final ERTable table = (ERTable) getModel();
    final ERDiagram diagram = (ERDiagram) getRoot().getContents().getModel();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final ERTable copyTable = table.copyData();

        final TableDialog dialog = new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable);

        if (dialog.open() == IDialogConstants.OK_ID) {
            final CompoundCommand command = ERTableEditPart.createChangeTablePropertyCommand(diagram, table, copyTable);

            execute(command.unwrap());
        }
    }

    super.performRequest(request);
}
 
Example #9
Source File: ViewOutlineEditPart.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(final Request request) {
    final View view = (View) getModel();
    final ERDiagram diagram = (ERDiagram) getRoot().getContents().getModel();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final View copyView = view.copyData();

        final ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyView);

        if (dialog.open() == IDialogConstants.OK_ID) {
            final CompoundCommand command = ViewEditPart.createChangeViewPropertyCommand(diagram, view, copyView);

            execute(command.unwrap());
        }
    }

    super.performRequest(request);
}
 
Example #10
Source File: AbstractBaseSelectionAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
protected void execute(final Event event) {
    final GraphicalViewer viewer = getGraphicalViewer();

    final List<Command> commandList = new ArrayList<Command>();

    for (final Object object : viewer.getSelectedEditParts()) {
        final List<Command> subCommandList = getCommand((EditPart) object, event);
        commandList.addAll(subCommandList);
    }

    if (!commandList.isEmpty()) {
        final CompoundCommand compoundCommand = new CompoundCommand();
        for (final Command command : commandList) {
            compoundCommand.add(command);
        }

        this.execute(compoundCommand);
    }
}
 
Example #11
Source File: ERDiagramAlignmentAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private Command createAlignmentCommand() {
    final AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN);
    request.setAlignmentRectangle(calculateAlignmentRectangle(request));
    request.setAlignment(alignment);
    final List editparts = getOperationSet(request);
    if (editparts.size() < 2)
        return null;

    final CompoundCommand command = new CompoundCommand();
    command.setDebugLabel(getText());
    for (int i = 0; i < editparts.size(); i++) {
        final EditPart editpart = (EditPart) editparts.get(i);
        command.add(editpart.getCommand(request));
    }
    return command;
}
 
Example #12
Source File: ERTableEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequestOpen() {
	ERTable table = (ERTable) this.getModel();
	ERDiagram diagram = this.getDiagram();

	ERTable copyTable = table.copyData();

	TableDialog dialog = new TableDialog(PlatformUI.getWorkbench()
			.getActiveWorkbenchWindow().getShell(), this.getViewer(),
			copyTable, diagram.getDiagramContents().getGroups());

	if (dialog.open() == IDialogConstants.OK_ID) {
		CompoundCommand command = createChangeTablePropertyCommand(diagram,
				table, copyTable);

		this.executeCommand(command.unwrap());
	}
}
 
Example #13
Source File: ChangeBackgroundColorAction.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private Command createCommand(final List objects, final RGB rgb) {
    if (objects.isEmpty()) {
        return null;
    }

    if (!(objects.get(0) instanceof GraphicalEditPart)) {
        return null;
    }

    final CompoundCommand command = new CompoundCommand();

    for (int i = 0; i < objects.size(); i++) {
        final GraphicalEditPart part = (GraphicalEditPart) objects.get(i);
        final Object modelObject = part.getModel();

        if (modelObject instanceof ViewableModel) {
            command.add(new ChangeBackgroundColorCommand((ViewableModel) modelObject, rgb.red, rgb.green, rgb.blue));

        } else if (modelObject instanceof ConnectionElement) {
            command.add(new ChangeConnectionColorCommand((ConnectionElement) modelObject, rgb.red, rgb.green, rgb.blue));

        }
    }

    return command;
}
 
Example #14
Source File: ViewOutlineEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performRequest(Request request) {
	View view = (View) this.getModel();
	ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel();

	if (request.getType().equals(RequestConstants.REQ_OPEN)) {
		View copyView = view.copyData();

		ViewDialog dialog = new ViewDialog(PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getShell(), this.getViewer(),
				copyView, diagram.getDiagramContents().getGroups());

		if (dialog.open() == IDialogConstants.OK_ID) {
			CompoundCommand command = ViewEditPart
					.createChangeViewPropertyCommand(diagram, view,
							copyView);

			this.execute(command.unwrap());
		}
	}

	super.performRequest(request);
}
 
Example #15
Source File: ERDiagramAlignmentAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: VerticalLineAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private Command alignToStart(int start, List<NodeElementEditPart> list) {
	CompoundCommand command = new CompoundCommand();

	for (NodeElementEditPart editPart : list) {
		NodeElement nodeElement = (NodeElement) editPart.getModel();

		MoveElementCommand moveCommand = new MoveElementCommand(this
				.getDiagram(), editPart.getFigure().getBounds(),
				nodeElement.getX(), start, nodeElement.getWidth(),
				nodeElement.getHeight(), nodeElement);

		command.add(moveCommand);
	}

	return command.unwrap();
}
 
Example #17
Source File: ChangeBackgroundColorAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private Command createCommand(List objects, RGB rgb) {
	if (objects.isEmpty()) {
		return null;
	}

	if (!(objects.get(0) instanceof GraphicalEditPart)) {
		return null;
	}

	CompoundCommand command = new CompoundCommand();

	for (int i = 0; i < objects.size(); i++) {
		GraphicalEditPart part = (GraphicalEditPart) objects.get(i);
		command.add(new ChangeBackgroundColorCommand((ViewableModel) part
				.getModel(), rgb.red, rgb.green, rgb.blue));
	}

	return command;
}
 
Example #18
Source File: HorizontalLineAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
private Command alignToStart(int start, List<DiagramWalkerEditPart> list) {
    final CompoundCommand command = new CompoundCommand();

    final ERDiagram diagram = getDiagram();

    for (final AbstractModelEditPart editPart : list) {
        final DiagramWalker nodeElement = (DiagramWalker) editPart.getModel();

        final MoveElementCommand moveCommand =
                new MoveElementCommand(diagram, editPart.getFigure().getBounds(), start, nodeElement.getY(), nodeElement.getWidth(),
                        nodeElement.getHeight(), nodeElement);

        command.add(moveCommand);
    }

    return command.unwrap();
}
 
Example #19
Source File: ERDiagramAlignmentAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
private Command createAlignmentCommand() {
    final AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN);
    request.setAlignmentRectangle(calculateAlignmentRectangle(request));
    request.setAlignment(alignment);
    final List<?> editparts = getOperationSet(request);
    if (editparts.size() < 2)
        return null;

    final CompoundCommand command = new CompoundCommand();
    command.setDebugLabel(getText());
    for (int i = 0; i < editparts.size(); i++) {
        final EditPart editpart = (EditPart) editparts.get(i);
        command.add(editpart.getCommand(request));
    }
    return command;
}
 
Example #20
Source File: AbstractBaseSelectionAction.java    From erflute with Apache License 2.0 6 votes vote down vote up
protected void execute(Event event) {
    final GraphicalViewer viewer = getGraphicalViewer();

    final List<Command> commandList = new ArrayList<>();

    for (final Object object : viewer.getSelectedEditParts()) {
        final List<Command> subCommandList = getCommand((EditPart) object, event);
        commandList.addAll(subCommandList);
    }

    if (!commandList.isEmpty()) {
        final CompoundCommand compoundCommand = new CompoundCommand();
        for (final Command command : commandList) {
            compoundCommand.add(command);
        }

        execute(compoundCommand);
    }
}
 
Example #21
Source File: ViewOutlineEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void performRequest(Request request) {
    final ERView view = (ERView) getModel();
    final ERDiagram diagram = getDiagram();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final ERView copyView = view.copyData();

        final ViewDialog dialog =
                new ViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyView, diagram
                        .getDiagramContents().getColumnGroupSet());

        if (dialog.open() == IDialogConstants.OK_ID) {
            final CompoundCommand command = ViewEditPart.createChangeViewPropertyCommand(diagram, view, copyView);

            execute(command.unwrap());
        }
    }

    super.performRequest(request);
}
 
Example #22
Source File: TableOutlineEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void performRequest(Request request) {
    final ERTable table = getModel();
    final ERDiagram diagram = getDiagram();
    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
        final ERTable copyTable = table.copyData();

        final TableDialog dialog =
                new TableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getViewer(), copyTable, diagram
                        .getDiagramContents().getColumnGroupSet());

        if (dialog.open() == IDialogConstants.OK_ID) {
            final CompoundCommand command = ERTableEditPart.createChangeTablePropertyCommand(diagram, table, copyTable);
            execute(command.unwrap());
        }
    }

    super.performRequest(request);
}
 
Example #23
Source File: EditExcelAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private Command createCommand(List objects) {
	if (objects.isEmpty()) {
		return null;
	}

	if (!(objects.get(0) instanceof GraphicalEditPart)) {
		return null;
	}

	CompoundCommand command = new CompoundCommand();

	for (int i = 0; i < objects.size(); i++) {
		GraphicalEditPart part = (GraphicalEditPart) objects.get(i);
		command.add(new EditExcelCommand((ViewableModel) part.getModel()));
	}

	return command;
}
 
Example #24
Source File: DeleteWithoutUpdateAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Command createDeleteCommand(List objects) {
	Command command = super.createDeleteCommand(objects);

	if (command == null) {
		return null;
	}

	if (command instanceof CompoundCommand) {
		CompoundCommand compoundCommand = (CompoundCommand) command;
		if (compoundCommand.getCommands().isEmpty()) {
			return null;
		}
	}

	EditPart editPart = part.getGraphicalViewer().getContents();
	ERDiagram diagram = ERModelUtil.getDiagram(editPart);

	return new WithoutUpdateCommandWrapper(command, diagram);
}
 
Example #25
Source File: ColumnSelectionHandlesEditPolicy.java    From erflute with Apache License 2.0 6 votes vote down vote up
public static Command createMoveColumnGroupCommand(DirectEditRequest editRequest, TableView newTableView, int index) {
    final ColumnGroup columnGroup =
            (ColumnGroup) ((Map<?, ?>) editRequest.getDirectEditFeature())
                    .get(ERDiagramTransferDragSourceListener.MOVE_COLUMN_GROUP_PARAM_GROUP);
    final TableView oldTableView =
            (TableView) ((Map<?, ?>) editRequest.getDirectEditFeature())
                    .get(ERDiagramTransferDragSourceListener.MOVE_COLUMN_GROUP_PARAM_PARENT);
    if (newTableView == oldTableView) {
        return new ChangeColumnOrderCommand(newTableView, columnGroup, index);
    }
    final CompoundCommand command = new CompoundCommand();
    final TableView copyOldTableView = oldTableView.copyData();
    for (final ERColumn column : copyOldTableView.getColumns()) {
        if (column == columnGroup) {
            copyOldTableView.removeColumn(column);
            break;
        }
    }
    final ChangeTableViewPropertyCommand sourceTableCommand = new ChangeTableViewPropertyCommand(oldTableView, copyOldTableView);
    command.add(sourceTableCommand);
    if (!newTableView.getColumns().contains(columnGroup)) {
        command.add(new AddColumnGroupCommand(newTableView, columnGroup, index));
    }
    return command.unwrap();
}
 
Example #26
Source File: DragEditPartsTrackerExWithoutCopyWithModKeyPressed.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void executeCurrentCommand() {
	if(getOperationSet().size() > 1){
		FiguresHelper.AVOID_OVERLAP_ENABLE = false ;
		super.executeCurrentCommand();
		FiguresHelper.AVOID_OVERLAP_ENABLE = true ;
		CompoundCommand cc = new CompoundCommand("Check Overlap") ;
		for(Object ep : getOperationSet()){
			if(ep instanceof IGraphicalEditPart){
				IGraphicalEditPart gep = (IGraphicalEditPart) ep ;
				Location loc = (Location) ((Node) ((IGraphicalEditPart) ep).getNotationView()).getLayoutConstraint() ;
				Point oldLoc = new Point(loc.getX(), loc.getY()) ;
				Point newLoc = FiguresHelper.handleCompartmentMargin(gep, loc.getX(), loc.getY(),(gep.resolveSemanticElement() instanceof SubProcessEvent)) ;
				if((newLoc.x != 0 && newLoc.y != 0) && !newLoc.equals(oldLoc)){
					cc.add(new ICommandProxy(new SetBoundsCommand(gep.getEditingDomain(), "Check Overlap", new EObjectAdapter(gep.getNotationView()),newLoc))) ;
				}
			}
		}
		executeCommand(cc) ;
	}else{
		super.executeCurrentCommand() ;
	}
}
 
Example #27
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void executeCurrentCommand() {
	FiguresHelper.AVOID_OVERLAP_ENABLE = false ;
	super.executeCurrentCommand();
	FiguresHelper.AVOID_OVERLAP_ENABLE = true ;
	CompoundCommand cc = new CompoundCommand("Check Overlap") ;
	for(IGraphicalEditPart ep : _movingShapes){
		 Location loc = (Location) ((Node) ep.getNotationView()).getLayoutConstraint() ;
Point oldLoc = new Point(loc.getX(), loc.getY()) ;
Point newLoc = FiguresHelper.handleCompartmentMargin(ep, loc.getX(), loc.getY(),(ep.resolveSemanticElement() instanceof SubProcessEvent)) ;
if((newLoc.x != 0 && newLoc.y != 0) && !newLoc.equals(oldLoc)){
 cc.add(new ICommandProxy(new SetBoundsCommand(_container.getEditingDomain(), "Check Overlap", new EObjectAdapter(ep.getNotationView()),newLoc))) ;
}
	}
	executeCommand(cc) ;
}
 
Example #28
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());
	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}
 
Example #29
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void executeCurrentCommand() {
 FiguresHelper.AVOID_OVERLAP_ENABLE = false ;
 super.executeCurrentCommand();
 FiguresHelper.AVOID_OVERLAP_ENABLE = true ;
 CompoundCommand cc = new CompoundCommand("Check Overlap") ;
 for(IGraphicalEditPart ep : _movingShapes){
	 Location loc = (Location) ((Node) ep.getNotationView()).getLayoutConstraint() ;
	 Point oldLoc = new Point(loc.getX(), loc.getY()) ;
	 Point newLoc = FiguresHelper.handleCompartmentMargin(ep, loc.getX(), loc.getY(),(ep.resolveSemanticElement() instanceof SubProcessEvent)) ;
	 if((newLoc.x != 0 && newLoc.y != 0) && !newLoc.equals(oldLoc)){
		 cc.add(new ICommandProxy(new SetBoundsCommand(_container.getEditingDomain(), "Check Overlap", new EObjectAdapter(ep.getNotationView()),newLoc))) ;
	 }
 }
 executeCommand(cc) ;
}
 
Example #30
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());

	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}