/** @generated */ protected void doConfigure(Assign newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { IElementType elementType = ((CreateElementRequest) getRequest()).getElementType(); ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext()); configureRequest.addParameters(getRequest().getParameters()); ICommand configureCommand = elementType.getEditCommand(configureRequest); if (configureCommand != null && configureCommand.canExecute()) { configureCommand.execute(monitor, info); } }
/** Creates regions for {@link State}s created with the Composite/Orthogonal State tool. */ @Override protected ICommand getConfigureCommand(ConfigureRequest req) { if (StatechartElementTypes.COMPOSITE_STATE.equals(req.getTypeToConfigure())) { return createCompositeStateCommand(req); } else if (StatechartElementTypes.ORTHOGONAL_STATE.equals(req.getTypeToConfigure())) { return createOrthogonalState(req); } else if (StatechartElementTypes.SUBMACHINE_STATE.equals(req.getTypeToConfigure())) { return createSubmachineStateCommand(req); } return null; }
/** @generated */ protected void doConfigure( ScopeToCompositeActionMapping newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { IElementType elementType = ((CreateElementRequest) getRequest()).getElementType(); ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext()); configureRequest.addParameters(getRequest().getParameters()); configureRequest.setParameter(CreateRelationshipRequest.SOURCE, getSource()); configureRequest.setParameter(CreateRelationshipRequest.TARGET, getTarget()); ICommand configureCommand = elementType.getEditCommand(configureRequest); if (configureCommand != null && configureCommand.canExecute()) { configureCommand.execute(monitor, info); } }
private ICommand createCompositeStateCommand(ConfigureRequest req) { Region region = SGraphFactory.eINSTANCE.createRegion(); region.setName("r1"); return new SetValueCommand( new SetRequest( req.getElementToConfigure(), SGraphPackage.Literals.STATE__SUB_REGIONS, region)); }
private ICommand createSubmachineStateCommand(ConfigureRequest req) { SelectSubmachineDialog dialog = new SelectSubmachineDialog(new Shell(), req.getElementToConfigure().eResource()); dialog.setElements(new Object[] {req.getElementToConfigure()}); if (Dialog.OK == dialog.open()) { QualifiedName selectedSubmachine = dialog.getSelectedSubmachine(); if (selectedSubmachine != null) { return new SetValueCommand( new SetRequest( req.getElementToConfigure(), SGraphPackage.Literals.STATE__SUBSTATECHART_ID, selectedSubmachine.toString())); } } return null; }
private ICommand createOrthogonalState(ConfigureRequest req) { Region region = SGraphFactory.eINSTANCE.createRegion(); region.setName("r1"); Region region2 = SGraphFactory.eINSTANCE.createRegion(); region2.setName("r2"); return new SetValueCommand( new SetRequest( req.getElementToConfigure(), SGraphPackage.Literals.STATE__SUB_REGIONS, com.google.common.collect.Lists.newArrayList(region, region2))); }
/** {@inheritDoc} */ @Override public ICommand create(ConfigureRequest request) { ICommand configureCommand = null; Shell shell = Display.getDefault().getActiveShell(); // Start dialog to identify the new part type Property part = (Property) request.getElementToConfigure(); Package partPkg = part.getNearestPackage(); CreateOrSelectBlockPropertyTypeDialog dialog = new CreateOrSelectBlockPropertyTypeDialog(shell, partPkg); dialog.open(); if (dialog.getReturnCode() == Window.OK) { final ICommand typeCreationCommand = dialog.getNewTypeCreateCommand(); final Type partType = (Type) dialog.getExistingType(); // Abort if type creation command exists but is not executable if ((typeCreationCommand != null) && (!typeCreationCommand.canExecute())) { return cancelCommand(request); } else { configureCommand = CompositeCommand.compose(configureCommand, typeCreationCommand); } // Create the configure command that will set the part type ICommand setTypeCommand = new ConfigureElementCommand(request) { @Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { Property part = (Property) getElementToEdit(); if (partType != null) { part.setType(partType); } else { Type newType = (Type) GMFCommandUtils.getCommandEObjectResult(typeCreationCommand); part.setType(newType); } return CommandResult.newOKCommandResult(part); } }; configureCommand = CompositeCommand.compose(configureCommand, setTypeCommand); return configureCommand; } return cancelCommand(request); }