/** {@inheritDoc} */ @Override public EditPart getTargetEditPart(Request request) { if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_COLUMN_GROUP.equals(request.getType()) || ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN_GROUP.equals( request.getType())) { DirectEditRequest editRequest = (DirectEditRequest) request; TableView tableView = (TableView) this.getHost().getModel(); ColumnGroup columnGroup = (ColumnGroup) ((Map) editRequest.getDirectEditFeature()).get("group"); if (!tableView.getColumns().contains(columnGroup)) { return getHost(); } } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_WORD.equals( request.getType())) { return getHost(); } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN.equals( request.getType())) { return getHost(); } return super.getTargetEditPart(request); }
public void showTargetFeedback(Request request) { if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_ADD) || request.getType().equals(RequestConstants.REQ_CLONE) || request.getType().equals(RequestConstants.REQ_CONNECTION_START) || request.getType().equals(RequestConstants.REQ_CONNECTION_END) || request.getType().equals(RequestConstants.REQ_CREATE)) showHighlight(); }
public EditPart getTargetEditPart(Request request) { if (REQ_CREATE.equals(request.getType())) { return null; } else if (RequestConstants.REQ_AUTOSIZE.equals(request.getType())) { return getHost(); } return super.getTargetEditPart(request); }
/** @see org.eclipse.gef.EditPolicy#getCommand(Request) */ public Command getCommand(Request req) { if (req.getType().equals(REQ_MOVE_CHILDREN)) return getMoveChildrenCommand((ChangeBoundsRequest) req); if (req.getType().equals(REQ_ADD)) return getAddCommand((ChangeBoundsRequest) req); if (req.getType().equals(REQ_CREATE)) return getCreateCommand((CreateRequest) req); return null; }
@Override public EditPart getTargetEditPart(Request request) { if (request == null || request.getType() == null) { return null; } return request.getType().equals(RequestConstants.REQ_SELECTION_HOVER) ? getHost() : null; }
@Override public void performRequest(Request req) { if (req.getType() == RequestConstants.REQ_DIRECT_EDIT && !isLocked()) { createDirectEditManager().show(); } else if (req.getType() == RequestConstants.REQ_OPEN) { // Show Properties view showPropertiesView(); } }
/** Avoid request of Re-Size and Move for pipeline procedures */ public Command getCommand(Request request) { if (RequestConstants.REQ_MOVE.equals(request.getType()) || RequestConstants.REQ_RESIZE.equals(request.getType())) { return new Command() { public boolean canExecute() { return false; } }; } return super.getCommand(request); }
@Override public void showTargetFeedback(Request request) { if (request.getType().equals(RequestConstants.REQ_MOVE) || request.getType().equals(RequestConstants.REQ_ADD) || request.getType().equals(RequestConstants.REQ_RECONNECT_SOURCE) || request.getType().equals(RequestConstants.REQ_RECONNECT_TARGET) || request.getType().equals(RequestConstants.REQ_CONNECTION_START) || request.getType().equals(RequestConstants.REQ_CONNECTION_END) || request.getType().equals(RequestConstants.REQ_CREATE) || request.getType().equals(DiagramDropRequest.REQ_DIAGRAM_DROP)) { getContainerFigure().showTargetFeedback(); } }
/** {@inheritDoc} */ @Override public Command getCommand(Request request) { try { if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_COLUMN_GROUP.equals( request.getType())) { DirectEditRequest editRequest = (DirectEditRequest) request; TableView tableView = (TableView) this.getHost().getModel(); ColumnGroup columnGroup = (ColumnGroup) ((Map) editRequest.getDirectEditFeature()).get("group"); if (!tableView.getColumns().contains(columnGroup)) { return new AddColumnGroupCommand( tableView, columnGroup, this.getColumnIndex(editRequest)); } } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_ADD_WORD.equals( request.getType())) { DirectEditRequest editRequest = (DirectEditRequest) request; TableView table = (TableView) this.getHost().getModel(); Word word = (Word) editRequest.getDirectEditFeature(); return new AddWordCommand(table, word, this.getColumnIndex(editRequest)); } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN.equals( request.getType())) { DirectEditRequest editRequest = (DirectEditRequest) request; return ColumnSelectionHandlesEditPolicy.createMoveColumnCommand( editRequest, this.getHost().getViewer(), (TableView) this.getHost().getModel(), this.getColumnIndex(editRequest)); } else if (ERDiagramTransferDragSourceListener.REQUEST_TYPE_MOVE_COLUMN_GROUP.equals( request.getType())) { DirectEditRequest editRequest = (DirectEditRequest) request; return ColumnSelectionHandlesEditPolicy.createMoveColumnGroupCommand( editRequest, (TableView) this.getHost().getModel(), this.getColumnIndex(editRequest)); } } catch (Exception e) { Activator.showExceptionDialog(e); } return super.getCommand(request); }
@Override public Command getCommand(Request request) { if (request.getType().equals(RequestConstants.REQ_DELETE)) { return UnexecutableCommand.INSTANCE; } return super.getCommand(request); }
@Override public EditPart getTargetEditPart(Request request) { EditPart ep = super.getTargetEditPart(request); if (ep != null) return ep; if (REQ_DIRECT_EDIT.equals(request.getType())) return getHost(); return null; }
public void performRequest(Request request) { if (RequestConstants.REQ_DIRECT_EDIT.equals(request.getType())) { performDirectEdit(); } else { super.performRequest(request); } }
/** * Returns a <code>Command</code> which sets the label's offset to its original position. * * @param request the request * @return the command */ @Override public Command getCommand(Request request) { if (RequestConstants.REQ_SNAP_BACK.equals(request.getType())) { View view = (View) getHost().getModel(); // YT - Use a snap back hint that takes into account the diagram // and parent view type. String hint = getSnapBackHint(view); Point offset = LabelEditPart.getSnapBackPosition(hint); if (offset == null) { return null; } TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); ICommand moveCommand = new SetBoundsCommand( editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(view), offset); return new ICommandProxy(moveCommand); } return null; }
@Override public Command getCommand(Request request) { if (RequestConstants.REQ_SEMANTIC_WRAPPER.equals(request.getType())) { return getSemanticCommand(((EditCommandRequestWrapper) request).getEditCommandRequest()); } return null; }
/** @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request) */ public void performRequest(Request request) { if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) { if (request instanceof DirectEditRequest && !directEditHitTest(((DirectEditRequest) request).getLocation().getCopy())) return; performDirectEdit(); } }
/** * Returns a composite command with the given initial command and the RegionContainer specific * auto-size commands to propagate the auto-size to the regions. * * @param request the initial request * @param autoSizeCommand the initial command * @return a composite command with the initial command and the region container specific * additional commands. */ protected Command getRegionContainerAutoSizeCommand(Request request, Command autoSizeCommand) { IDiagramElementEditPart host = (IDiagramElementEditPart) getHost(); TransactionalEditingDomain domain = host.getEditingDomain(); CompositeTransactionalCommand ctc = new CompositeTransactionalCommand( domain, Messages.RegionContainerResizableEditPolicy_regionContainerAutoSizeCommandLabel); ctc.add(new CommandProxy(autoSizeCommand)); Command regionContainerAutoSizeCommand = new ICommandProxy(ctc); // Propagate the auto-size request to the regions. Request req = new Request(); req.setType(request.getType()); req.getExtendedData().put(REGION_AUTO_SIZE_PROPAGATOR, host); Object object = request.getExtendedData().get(REGION_AUTO_SIZE_PROPAGATOR); for (EditPart regionPart : getRegionParts()) { if (object != regionPart) { ctc.add(new CommandProxy(regionPart.getCommand(req))); } } ctc.add( CommandFactory.createICommand( domain, new RegionContainerUpdateLayoutOperation((Node) host.getModel()))); return regionContainerAutoSizeCommand; }
/** * @see * org.eclipse.gmf.runtime.diagram.ui.editpolicies.PropertyHandlerEditPolicy#getCommand(org.eclipse.gef.Request) * @param request * @return */ @Override public Command getCommand(Request request) { if (request.getType().equals(ShowHideCompartmentRequest.SHOW_HIDE_COMPARTMENT)) { ShowHideCompartmentRequest req = (ShowHideCompartmentRequest) request; return getShowHideCompartmentCommand(req); } return null; }
@Override public void performRequest(Request request) { if (request.getType() == REQ_DIRECT_EDIT) { performDirectEdit(); } else { super.performRequest(request); } }
/** @see org.eclipse.gef.EditPart#understandsRequest(org.eclipse.gef.Request) */ public boolean understandsRequest(Request req) { if (req.getType().equals(RequestConstants.REQ_DELETE)) return true; if (req instanceof AddOperationDefRequest) return true; else if (req instanceof AddValueMembertDefRequest) return true; else if (req instanceof AddAttributeDefRequest) return true; else { return super.understandsRequest(req); } }
/* * (non-Javadoc) * * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#showTargetFeedback(org.eclipse.gef.Request) */ public void showTargetFeedback(Request request) { if (request instanceof DropRequest && request.getType() == ItemCreationRequest.REQ_ITEM_CREATION) { super.showTargetFeedback(request); if (getHost() instanceof GraphicalEditPart) { ExposeHelper exposeHelper = new ExposeHelper(getViewer(getHost())); exposeHelper.adjustVertical(((DropRequest) request).getLocation()); } } }
/** @see org.eclipse.gef.EditPart#getCommand(org.eclipse.gef.Request) */ public Command getCommand(Request request) { if (request.getType().equals(RequestConstants.REQ_DELETE)) return new DeleteNodeCommand( (Node) getModelNode(), ((Node) getModelNode()).getView(), ((Node) getModel()).getContained()); if (request instanceof AddOperationDefRequest) return new AddOperationDefCommand(); else if (request instanceof AddValueMembertDefRequest) return new AddValueMemberDefCommand(); else if (request instanceof AddAttributeDefRequest) return new AddAttributeDefCommand(); else return super.getCommand(request); }
@Override public void performRequest(Request req) { if (req.getType().equals(RequestConstants.REQ_OPEN)) { try { PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .showView("org.eclipse.ui.views.PropertySheet"); } catch (PartInitException e) { throw new RuntimeException(e); } } }
/** @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request) */ public void performRequest(Request req) { if (req.getType().equals(REQ_OPEN) && (getModel() instanceof Relationship)) { Relationship model = (Relationship) getModel(); RelationshipPropertiesInputDialog dialog = new RelationshipPropertiesInputDialog( new Shell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL, model); dialog.open(); // Effettuo il refresh della selezione setSelected(SELECTED); } }
/** * Returns the host EditPart when appropriate. Targeting is done by checking if the mouse is * clearly over the host's TreeItem. * * @see org.eclipse.gef.EditPolicy#getTargetEditPart(Request) */ public EditPart getTargetEditPart(Request req) { if (req.getType().equals(REQ_ADD) || req.getType().equals(REQ_MOVE) || req.getType().equals(REQ_CREATE)) { DropRequest drop = (DropRequest) req; Point where = new Point(drop.getLocation().x, drop.getLocation().y); Widget widget = ((TreeEditPart) getHost()).getWidget(); if (widget instanceof Tree) return getHost(); TreeItem treeitem = (TreeItem) widget; Rectangle bounds = treeitem.getBounds(); int fudge = bounds.height / 5; Rectangle inner = new Rectangle( bounds.x, bounds.y + fudge, bounds.width, bounds.height - (treeitem.getExpanded() ? 0 : fudge * 2)); // Point is either outside the Treeitem, or inside the inner Rect. if (!bounds.contains(where) || inner.contains(where)) return getHost(); } return null; }
/** * @see * org.eclipse.gmf.runtime.diagram.ui.editpolicies.PropertyHandlerEditPolicy#getCommand(org.eclipse.gef.Request) * @param request * @return */ @Override public Command getCommand(Request request) { if (request.getType().equals(ShowHideElementsRequest.SHOW_HIDE_ELEMENTS)) { ShowHideElementsRequest req = (ShowHideElementsRequest) request; if (req.getHidedEditPart() != null) { return getDestroyViewCommand(req.getHidedEditPart()); } else if (req.getContainer() != null && req.getSemanticElement() != null) { return getCreateViewCommand( req.getContainer(), req.getSemanticElement(), req.getLocation()); } } return null; }
/** * @see * org.eclipse.gef.editpolicies.AbstractEditPolicy#understandsRequest(org.eclipse.gef.Request) * @param req * @return */ @Override public boolean understandsRequest(Request req) { Object type = req.getType(); if (REQ_MOVE.equals(type) || REQ_RESIZE.equals(type)) { // Correct mistake(also fix bug: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417375) return true; } else if (getHost() instanceof AbstractMessageEditPart) { return REQ_RECONNECT_SOURCE.equals(type) || REQ_RECONNECT_TARGET.equals(type) || REQ_CREATE_BENDPOINT.equals(type) || REQ_MOVE_BENDPOINT.equals(type); } return false; }
@Override public void performRequest(Request request) { if (request.getType().equals(RequestConstants.REQ_OPEN)) { try { if (this.getModel() instanceof TableControlModel) { performRequestOpen(); } } catch (Exception e) { e.printStackTrace(); } } }
/** * Returns a command for graphical delete (with local conditions also deleted). * * @see org.eclipse.gef.EditPolicy#getCommand(Request) * @return the command or null */ @Override public Command getCommand(Request request) { if (RequestConstants.REQ_DELETE.equals(request.getType())) { if (request instanceof GroupRequest) { // List of parts from the request is not up to date. Consider the host only. List<?> parts = Collections.singletonList(getHost()); ((GroupRequest) request).setEditParts(getHost()); // inspect the list of parts to add linked local conditions List<EditPart> partsToAdd = getListOfLinkedLocalConditionsParts(parts); ((GroupRequest) request).getEditParts().addAll(partsToAdd); return getDeleteCommand((GroupRequest) request); } } return null; }
/** * Handle the double-click to edit the association * * @see org.eclipse.gef.EditPart#performRequest(org.eclipse.gef.Request) */ public void performRequest(Request request) { Association association = (Association) Utils.getElement(getGraphEdge()); if (request.getType() == RequestConstants.REQ_OPEN) { AssociationEditDialog associationDlg = new AssociationEditDialog(association, ModelerPlugin.getActiveWorkbenchShell()); if (associationDlg.open() == Window.OK) { AssociationUpdateCommand command = new AssociationUpdateCommand(association, associationDlg.getAssociationData()); getViewer().getEditDomain().getCommandStack().execute(command); refreshEdgeObjects(); } } else { super.performRequest(request); } }
/** {@inheritDoc} */ @Override public void performRequest(Request request) { Relation relation = (Relation) this.getModel(); if (request.getType().equals(RequestConstants.REQ_OPEN)) { Relation copy = relation.copy(); RelationDialog dialog = new RelationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), copy); if (dialog.open() == IDialogConstants.OK_ID) { ChangeRelationPropertyCommand command = new ChangeRelationPropertyCommand(relation, copy); this.execute(command); } } super.performRequest(request); }