/** @generated */ protected Command getSemanticCommand(IEditCommandRequest request) { IEditCommandRequest completedRequest = completeRequest(request); Object editHelperContext = completedRequest.getEditHelperContext(); if (editHelperContext instanceof View || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) { // no semantic commands are provided for pure design elements return null; } if (editHelperContext == null) { editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel()); } IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext); if (elementType == ElementTypeRegistry.getInstance() .getType("org.eclipse.gmf.runtime.emf.type.core.default")) { // $NON-NLS-1$ elementType = null; } Command semanticCommand = getSemanticCommandSwitch(completedRequest); if (elementType != null) { if (semanticCommand != null) { ICommand command = semanticCommand instanceof ICommandProxy ? ((ICommandProxy) semanticCommand).getICommand() : new CommandProxy(semanticCommand); completedRequest.setParameter( FlowDesigner.diagram.edit.helpers.FlowDesignerBaseEditHelper.EDIT_POLICY_COMMAND, command); } ICommand command = elementType.getEditCommand(completedRequest); if (command != null) { if (!(command instanceof CompositeTransactionalCommand)) { TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); command = new CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command); } semanticCommand = new ICommandProxy(command); } } boolean shouldProceed = true; if (completedRequest instanceof DestroyRequest) { shouldProceed = shouldProceed((DestroyRequest) completedRequest); } if (shouldProceed) { if (completedRequest instanceof DestroyRequest) { TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); Command deleteViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View) getHost().getModel())); semanticCommand = semanticCommand == null ? deleteViewCommand : semanticCommand.chain(deleteViewCommand); } return semanticCommand; } return null; }
/** @generated */ private Command getEditHelperCommand(IEditCommandRequest request, Command editPolicyCommand) { if (editPolicyCommand != null) { ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy) editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand); request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, command); } IElementType requestContextElementType = getContextElementType(request); request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, requestContextElementType); ICommand command = requestContextElementType.getEditCommand(request); request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, null); request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, null); if (command != null) { if (!(command instanceof CompositeTransactionalCommand)) { command = new CompositeTransactionalCommand(getEditingDomain(), command.getLabel()) .compose(command); } return new ICommandProxy(command); } return editPolicyCommand; }
/** * Constructor. * * @param gmfCommand the gmf command */ public GMFtoEMFCommandWrapper(ICommand gmfCommand) { super(gmfCommand.getLabel()); this.gmfCommand = gmfCommand; }
/* * (non-Javadoc) * * @see org.eclipse.emf.common.command.Command#getDescription() */ @Override public String getDescription() { return gmfCommand.getLabel(); }