Java Code Examples for org.eclipse.gef.commands.CompoundCommand#unwrap()
The following examples show how to use
org.eclipse.gef.commands.CompoundCommand#unwrap() .
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: NoteDirectEditPolicy.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@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 2
Source File: HorizontalLineAction.java From erflute with Apache License 2.0 | 6 votes |
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 3
Source File: ColumnSelectionHandlesEditPolicy.java From erflute with Apache License 2.0 | 6 votes |
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 4
Source File: VerticalLineAction.java From ermaster-b with Apache License 2.0 | 6 votes |
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 5
Source File: ColumnSelectionHandlesEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
public static Command createMoveColumnGroupCommand(final DirectEditRequest editRequest, final TableView newTableView, final 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 Column 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 6
Source File: VerticalLineAction.java From erflute with Apache License 2.0 | 5 votes |
private Command alignToStart(int start, List<DiagramWalkerEditPart> list) { final CompoundCommand command = new CompoundCommand(); for (final DiagramWalkerEditPart editPart : list) { final DiagramWalker nodeElement = (DiagramWalker) editPart.getModel(); final MoveElementCommand moveCommand = new MoveElementCommand(getDiagram(), editPart.getFigure().getBounds(), nodeElement.getX(), start, nodeElement.getWidth(), nodeElement.getHeight(), nodeElement); command.add(moveCommand); } return command.unwrap(); }
Example 7
Source File: ReportFlowLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 5 votes |
protected Command getAddCommand( Request req ) { EditPart parent = getHost( ); ChangeBoundsRequest request = (ChangeBoundsRequest) req; List editParts = request.getEditParts( ); CompoundCommand command = new CompoundCommand( ); for ( int i = 0; i < editParts.size( ); i++ ) { EditPart child = (EditPart) editParts.get( i ); command.add( createAddCommand( parent, child, getInsertionReference( request ) ) ); } return command.unwrap( ); }
Example 8
Source File: ReportContainerEditPolicy.java From birt with Eclipse Public License 1.0 | 5 votes |
public Command getOrphanChildrenCommand( GroupRequest request ) { List parts = request.getEditParts( ); CompoundCommand result = new CompoundCommand( "Move in layout" );//$NON-NLS-1$ for ( int i = 0; i < parts.size( ); i++ ) { DeleteCommand command = new DeleteCommand( ( (EditPart) parts.get( i ) ).getModel( ) ); command.setClear( false ); result.add( command ); } return result.unwrap( ); }
Example 9
Source File: CustomResizableEditPolicyEx.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected Command getMoveCommand(final ChangeBoundsRequest request) { if (request.getEditParts() != null && !request.getEditParts().isEmpty() && request.getEditParts().get(0) instanceof CustomLaneEditPart) { return null;// DON'T MOVE A LANE } if (!request.getEditParts().isEmpty() && request.getEditParts().get(0) instanceof CustomSubProcessEvent2EditPart && checkOverlapOtherFigures(request) && request.getEditParts() != null) { return null; // DON'T MOVE A SUBPROCESS EVENT IF LOCATION NOT VALID } final CompoundCommand cc = new CompoundCommand("Move"); cc.add(super.getMoveCommand(request)); if (request.getEditParts() != null && !request.getEditParts().isEmpty()) { for (final Object ep : request.getEditParts()) { if (ep instanceof SubProcessEvent2EditPart) { for (final Object c : ((SubProcessEvent2EditPart) ep).getChildren()) { if (c instanceof CustomSubprocessEventCompartmentEditPart) { final ChangeBoundsRequest childRequest = new ChangeBoundsRequest(REQ_MOVE_CHILDREN); final List eps = new ArrayList(); for (final Object child : ((CustomSubprocessEventCompartmentEditPart) c).getChildren()) { eps.add(child); } childRequest.setEditParts(eps); childRequest.setMoveDelta(request.getMoveDelta()); final HashMap<Object, Object> map = new HashMap<Object, Object>(); map.put(MOVE_COMPARTMENT_CHILDREN, MOVE_COMPARTMENT_CHILDREN); childRequest.setExtendedData(map); if (!eps.isEmpty()) { cc.add(((CustomSubprocessEventCompartmentEditPart) c).getCommand(childRequest)); } } } } } } return cc.unwrap(); }
Example 10
Source File: ColumnSelectionHandlesEditPolicy.java From ermaster-b with Apache License 2.0 | 5 votes |
public static Command createMoveColumnGroupCommand( DirectEditRequest editRequest, TableView newTableView, int index) { ColumnGroup columnGroup = (ColumnGroup) ((Map) editRequest .getDirectEditFeature()) .get(ERDiagramTransferDragSourceListener.MOVE_COLUMN_GROUP_PARAM_GROUP); TableView oldTableView = (TableView) ((Map) editRequest .getDirectEditFeature()) .get(ERDiagramTransferDragSourceListener.MOVE_COLUMN_GROUP_PARAM_PARENT); if (newTableView == oldTableView) { return new ChangeColumnOrderCommand(newTableView, columnGroup, index); } CompoundCommand command = new CompoundCommand(); TableView copyOldTableView = oldTableView.copyData(); for (Column column : copyOldTableView.getColumns()) { if (column == columnGroup) { copyOldTableView.removeColumn(column); break; } } 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 11
Source File: HorizontalLineAction.java From ermasterr with Apache License 2.0 | 4 votes |
private Command alignToStart(final int start, final List<NodeElementEditPart> list) { final CompoundCommand command = new CompoundCommand(); final ERDiagram diagram = getDiagram(); for (final AbstractModelEditPart editPart : list) { final NodeElement nodeElement = (NodeElement) 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 12
Source File: CustomFeedbackXYLayoutPolicy.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * Override to compute position of Subprocess event children when changing parent */ @Override protected Command createAddCommand(final EditPart child, final Object constraint) { if (child instanceof CustomSubProcessEvent2EditPart && constraint instanceof Rectangle) { final Rectangle rect = (Rectangle) constraint; final CompoundCommand cmds = new CompoundCommand("Move Subprocesss Event"); ICommand boundsCommand = new SetBoundsCommand(((ShapeEditPart) child).getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View) child.getModel()), rect.getTopLeft()); cmds.add(new ICommandProxy(boundsCommand)); ShapeCompartmentEditPart compartment = null; for (final Object c : child.getChildren()) { if (c instanceof ShapeCompartmentEditPart) { compartment = (ShapeCompartmentEditPart) c; } } final Location origin = (Location) ((Node) child.getModel()).getLayoutConstraint(); for (final Object ep : compartment.getChildren()) { if (ep instanceof IGraphicalEditPart) { final Node view = (Node) ((IGraphicalEditPart) ep).getModel(); final Location loc = (Location) view.getLayoutConstraint(); final Point delta = new Point(loc.getX() - origin.getX(), loc.getY() - origin.getY()); final Point newLoc = new Point(rect.getTopLeft().x + delta.x, rect.getTopLeft().y + delta.y); boundsCommand = new SetBoundsCommand(((IGraphicalEditPart) ep).getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View) ((IGraphicalEditPart) ep).getModel()), newLoc); cmds.add(new ICommandProxy(boundsCommand)); } } return cmds.unwrap(); } else { return super.createAddCommand(child, constraint); } }
Example 13
Source File: HorizontalLineAction.java From ermaster-b with Apache License 2.0 | 4 votes |
private Command alignToStart(int start, List<NodeElementEditPart> list) { CompoundCommand command = new CompoundCommand(); ERDiagram diagram = this.getDiagram(); for (AbstractModelEditPart editPart : list) { NodeElement nodeElement = (NodeElement) editPart.getModel(); MoveElementCommand moveCommand = new MoveElementCommand(diagram, editPart.getFigure().getBounds(), start, nodeElement.getY(), nodeElement.getWidth(), nodeElement .getHeight(), nodeElement); command.add(moveCommand); } return command.unwrap(); }
Example 14
Source File: VerticalLineAction.java From ermasterr with Apache License 2.0 | 3 votes |
private Command alignToStart(final int start, final List<NodeElementEditPart> list) { final CompoundCommand command = new CompoundCommand(); for (final NodeElementEditPart editPart : list) { final NodeElement nodeElement = (NodeElement) editPart.getModel(); final MoveElementCommand moveCommand = new MoveElementCommand(getDiagram(), editPart.getFigure().getBounds(), nodeElement.getX(), start, nodeElement.getWidth(), nodeElement.getHeight(), nodeElement); command.add(moveCommand); } return command.unwrap(); }