/** * 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; }
/** * Understands RequestConstants.REQ_SNAP_BACK request types * * @param request * @return boolean */ @Override public boolean understandsRequest(Request request) { return RequestConstants.REQ_SNAP_BACK.equals(request.getType()); }