org.eclipse.gef.commands.Command Java Examples
The following examples show how to use
org.eclipse.gef.commands.Command.
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: ERDiagramBendpointEditPolicy.java From erflute with Apache License 2.0 | 6 votes |
@Override protected Command getCreateBendpointCommand(BendpointRequest bendpointrequest) { final AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) getHost(); final WalkerConnection connection = (WalkerConnection) connectionEditPart.getModel(); if (connection.getSourceWalker() == connection.getTargetWalker()) { return null; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final CreateBendpointCommand createBendpointCommand = new CreateBendpointCommand(connection, point.x, point.y, bendpointrequest.getIndex()); return createBendpointCommand; }
Example #2
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 #3
Source File: ERDiagramAlignmentAction.java From ermasterr with Apache License 2.0 | 6 votes |
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 #4
Source File: ElementsManagerUtils.java From txtUML with Eclipse Public License 1.0 | 6 votes |
/** * Calls the {@link DropObjectsRequest} on an EditPart. * @param EP - The EditPart that is to be added to * @param diagramElements - The Elements that are to be added */ @SuppressWarnings("unchecked") public static void addElementsToEditPart(EditPart EP, Collection<? extends Element> diagramElements) { List<Element> diagramElementsList; if(!(diagramElements instanceof List<?>)){ diagramElementsList = (List<Element>) createList(diagramElements); }else{ diagramElementsList = (List<Element>) diagramElements; } if(!diagramElementsList.isEmpty()){ DropObjectsRequest dropObjectsRequest = new DropObjectsRequest(); dropObjectsRequest.setObjects(diagramElementsList); dropObjectsRequest.setLocation(new Point(0,0)); Command commandDrop = EP.getCommand(dropObjectsRequest); if (commandDrop != null){ commandDrop.execute(); } } }
Example #5
Source File: ChangeBackgroundColorAction.java From ermasterr with Apache License 2.0 | 6 votes |
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 #6
Source File: ERDiagramLayoutEditPolicy.java From erflute with Apache License 2.0 | 6 votes |
@Override public Command getCommand(Request request) { if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_PLACE_TABLE.equals(request.getType())) { final DirectEditRequest editRequest = (DirectEditRequest) request; final Object feature = editRequest.getDirectEditFeature(); if (feature instanceof ERTable) { final ERTable ertable = (ERTable) feature; return new PlaceTableCommand(ertable); } if (feature instanceof List) { @SuppressWarnings("unchecked") final List<ERTable> list = (List<ERTable>) feature; return new PlaceTableCommand(list); } } return super.getCommand(request); }
Example #7
Source File: ERDiagramAlignmentAction.java From ermasterr with Apache License 2.0 | 5 votes |
/** * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled() */ @Override protected boolean calculateEnabled() { operationSet = null; final Command cmd = createAlignmentCommand(); if (cmd == null) return false; return cmd.canExecute(); }
Example #8
Source File: NonInterruptingBoundaryTimerEventItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Returns command to reorient EClass based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { switch (getVisualID(req)) { case SequenceFlowEditPart.VISUAL_ID: return getGEFWrapper(new SequenceFlowReorientCommand(req)); case TextAnnotationAttachmentEditPart.VISUAL_ID: return getGEFWrapper(new TextAnnotationAttachmentReorientCommand(req)); } return super.getReorientRelationshipCommand(req); }
Example #9
Source File: BoundaryMessageEvent2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Returns command to reorient EClass based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { switch (getVisualID(req)) { case SequenceFlowEditPart.VISUAL_ID: return getGEFWrapper(new SequenceFlowReorientCommand(req)); case MessageFlowEditPart.VISUAL_ID: return getGEFWrapper(new MessageFlowReorientCommand(req)); case TextAnnotationAttachmentEditPart.VISUAL_ID: return getGEFWrapper(new TextAnnotationAttachmentReorientCommand(req)); } return super.getReorientRelationshipCommand(req); }
Example #10
Source File: EndTerminatedEventItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Returns command to reorient EClass based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { switch (getVisualID(req)) { case SequenceFlowEditPart.VISUAL_ID: return getGEFWrapper(new SequenceFlowReorientCommand(req)); case TextAnnotationAttachmentEditPart.VISUAL_ID: return getGEFWrapper(new TextAnnotationAttachmentReorientCommand(req)); } return super.getReorientRelationshipCommand(req); }
Example #11
Source File: TransitionExpressionComponentEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected Command createDeleteSemanticCommand(GroupRequest deleteRequest) { SetRequest request = new SetRequest(getHost().resolveSemanticElement(), SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION, null); SetValueCommand result = new SetValueCommand(request); return new ICommandProxy(result); }
Example #12
Source File: InclusiveGatewayItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return null; } return null; }
Example #13
Source File: LaneItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return null; } return null; }
Example #14
Source File: StartEventItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Returns command to reorient EClass based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { switch (getVisualID(req)) { case SequenceFlowEditPart.VISUAL_ID: return getGEFWrapper(new SequenceFlowReorientCommand(req)); case TextAnnotationAttachmentEditPart.VISUAL_ID: return getGEFWrapper(new TextAnnotationAttachmentReorientCommand(req)); } return super.getReorientRelationshipCommand(req); }
Example #15
Source File: EndMessageEvent2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.MessageFlow_4002 == req.getElementType()) { return getGEFWrapper(new MessageFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return null; } return null; }
Example #16
Source File: BoundaryMessageEvent2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.MessageFlow_4002 == req.getElementType()) { return null; } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return null; } return null; }
Example #17
Source File: CommitmentTaskItemSemanticEditPolicy.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * Returns command to reorient EReference based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) { switch (getVisualID(req)) { case StreamInputOfEditPart.VISUAL_ID: return getGEFWrapper(new StreamInputOfReorientCommand(req)); case TaskOutputEditPart.VISUAL_ID: return getGEFWrapper(new TaskOutputReorientCommand(req)); } return super.getReorientReferenceRelationshipCommand(req); }
Example #18
Source File: TopicItemSemanticEditPolicy.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (CrossflowElementTypes.StreamType_4001 == req.getElementType()) { return getGEFWrapper(new StreamTypeCreateCommand(req, req.getSource(), req.getTarget())); } if (CrossflowElementTypes.StreamInputOf_4005 == req.getElementType()) { return getGEFWrapper(new StreamInputOfCreateCommand(req, req.getSource(), req.getTarget())); } if (CrossflowElementTypes.TaskOutput_4003 == req.getElementType()) { return null; } return null; }
Example #19
Source File: ServiceTaskItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Returns command to reorient EClass based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) { switch (getVisualID(req)) { case SequenceFlowEditPart.VISUAL_ID: return getGEFWrapper(new SequenceFlowReorientCommand(req)); case TextAnnotationAttachmentEditPart.VISUAL_ID: return getGEFWrapper(new TextAnnotationAttachmentReorientCommand(req)); } return super.getReorientRelationshipCommand(req); }
Example #20
Source File: SourceItemSemanticEditPolicy.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (CrossflowElementTypes.StreamInputOf_4005 == req.getElementType()) { return null; } if (CrossflowElementTypes.TaskOutput_4003 == req.getElementType()) { return getGEFWrapper(new TaskOutputCreateCommand(req, req.getSource(), req.getTarget())); } return null; }
Example #21
Source File: CommitmentTaskItemSemanticEditPolicy.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (CrossflowElementTypes.StreamInputOf_4005 == req.getElementType()) { return null; } if (CrossflowElementTypes.TaskOutput_4003 == req.getElementType()) { return getGEFWrapper(new TaskOutputCreateCommand(req, req.getSource(), req.getTarget())); } return null; }
Example #22
Source File: StartSignalEvent2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return null; } return null; }
Example #23
Source File: IntermediateCatchMessageEvent2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.MessageFlow_4002 == req.getElementType()) { return null; } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return null; } return null; }
Example #24
Source File: InclusiveGateway2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return getGEFWrapper(new TextAnnotationAttachmentCreateCommand(req, req.getSource(), req.getTarget())); } return null; }
Example #25
Source File: CustomFeedbackXYLayoutPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Override in order to change the location if a figure overrides another */ @Override protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) { final Rectangle newBounds = (Rectangle) constraint; final View shapeView = (View) child.getModel(); final TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); return new ICommandProxy(new OverlapSetBoundsCommand(editingDomain, (GraphicalEditPart) child, getHost(), new EObjectAdapter(shapeView), newBounds)); }
Example #26
Source File: RegionEditPart.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE); installEditPolicy(EditPolicy.LAYOUT_ROLE, new ConstrainedToolbarLayoutEditPolicy() { @Override protected Command getAutoSizeCommand(Request request) { return UnexecutableCommand.INSTANCE; } }); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PreferredSizeHandlerEditPolicy()); }
Example #27
Source File: SinkItemSemanticEditPolicy.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * Returns command to reorient EReference based link. New link target or source * should be the domain model element associated with this node. * * @generated */ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) { switch (getVisualID(req)) { case StreamInputOfEditPart.VISUAL_ID: return getGEFWrapper(new StreamInputOfReorientCommand(req)); case TaskOutputEditPart.VISUAL_ID: return getGEFWrapper(new TaskOutputReorientCommand(req)); } return super.getReorientReferenceRelationshipCommand(req); }
Example #28
Source File: XORGatewayItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return getGEFWrapper(new SequenceFlowCreateCommand(req, req.getSource(), req.getTarget())); } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return getGEFWrapper(new TextAnnotationAttachmentCreateCommand(req, req.getSource(), req.getTarget())); } return null; }
Example #29
Source File: IntermediateErrorCatchEvent6ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) { if (ProcessElementTypes.SequenceFlow_4001 == req.getElementType()) { return null; } if (ProcessElementTypes.TextAnnotationAttachment_4003 == req.getElementType()) { return getGEFWrapper(new TextAnnotationAttachmentCreateCommand(req, req.getSource(), req.getTarget())); } return null; }
Example #30
Source File: NodeElementGraphicalNodeEditPolicy.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Command getConnectionCompleteCommand( CreateConnectionRequest request) { AbstractCreateConnectionCommand command = (AbstractCreateConnectionCommand) request .getStartCommand(); NodeElementEditPart targetEditPart = (NodeElementEditPart) request .getTargetEditPart(); if (command instanceof AbstractCreateRelationCommand) { if (!(targetEditPart instanceof TableViewEditPart)) { return null; } } String validatedMessage = command.validate(); if (validatedMessage != null) { Activator.showErrorDialog(validatedMessage); return null; } command.setTarget(targetEditPart); if (!command.canExecute()) { return null; } return command; }