org.eclipse.gmf.runtime.common.core.command.CommandResult Java Examples

The following examples show how to use org.eclipse.gmf.runtime.common.core.command.CommandResult. 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: ToggleSubRegionLayoutCommand.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Executes the command that switches the subregion layout orientation.
 */
@SuppressWarnings("unchecked")
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {
	BooleanValueStyle style = GMFNotationUtil.getBooleanValueStyle(
			view, StateViewFactory.ALIGNMENT_ORIENTATION);
	if (style == null) {
		style = NotationFactory.eINSTANCE.createBooleanValueStyle();
		style.setBooleanValue(true);
		style.setName(StateViewFactory.ALIGNMENT_ORIENTATION);
		view.getStyles().add(style);
	} else {
		style.setBooleanValue(!style.isBooleanValue());
	}
	return CommandResult.newOKCommandResult(view);
}
 
Example #2
Source File: OpenDiagramEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	try {
		Diagram diagram = getDiagramToOpen();
		if (diagram == null) {
			diagram = intializeNewDiagram();
		}
		URI uri = EcoreUtil.getURI(diagram);
		String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
		IEditorInput editorInput = new URIEditorInput(uri, editorName);
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
		page.openEditor(editorInput, getEditorID());
		return CommandResult.newOKCommandResult();
	} catch (Exception ex) {
		throw new ExecutionException("Can't open diagram", ex);
	}
}
 
Example #3
Source File: MessageFlowCreateCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	if (!canExecute()) {
		throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
	}

	MessageFlow newElement = ProcessFactory.eINSTANCE.createMessageFlow();
	getContainer().getMessageConnections().add(newElement);
	newElement.setSource(getSource());
	newElement.setTarget(getTarget());
	ElementInitializers.getInstance().init_MessageFlow_4002(newElement);
	doConfigure(newElement, monitor, info);
	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);

}
 
Example #4
Source File: FixStateContentSizesCommand.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info){
	View state = (View) stateEditPart.getModel();
   	View stateLabel = (View) state.getChildren().get(0);
	View stateCompartment = CustomStateEditPart.getStateCompartmentView(state);

	addLayoutConstraintForAllChildren(state);
	
	Zone.setHeight(stateLabel, STATELABEL_HEIGHT);
	Zone.setHeight(stateCompartment, Zone.getWidth(state)-STATELABEL_HEIGHT);
	
	Zone.setWidth(stateLabel, Zone.getWidth(state));
	Zone.setWidth(stateCompartment, Zone.getWidth(state));
	
	if (stateCompartment.getChildren().size() == 1) {
		// we need to resize the region
		View defaultRegion = (View) stateCompartment.getChildren().get(0);
		Zone.setWidth(defaultRegion, Zone.getWidth(stateCompartment));
		Zone.setHeight(defaultRegion, Zone.getHeight(stateCompartment));
	}
	return CommandResult.newOKCommandResult();
}
 
Example #5
Source File: SequenceFlowCreateCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	if (!canExecute()) {
		throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
	}

	SequenceFlow newElement = ProcessFactory.eINSTANCE.createSequenceFlow();
	getContainer().getConnections().add(newElement);
	newElement.setSource(getSource());
	newElement.setTarget(getTarget());
	ElementInitializers.getInstance().init_SequenceFlow_4001(newElement);
	doConfigure(newElement, monitor, info);
	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);

}
 
Example #6
Source File: CustomCutCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(
		IProgressMonitor progressMonitor, IAdaptable info)
		throws ExecutionException {
	
	Clipboard.setToCopyEditParts(toCopyElement);
	TransactionalEditingDomain domain = (TransactionalEditingDomain) AdapterFactoryEditingDomain.getEditingDomainFor(toCopyElement);
	domain.getCommandStack().execute(new RecordingCommand(domain) {
		protected void doExecute() {
			for (IGraphicalEditPart part : toCopyElement) {
				EcoreUtil.delete(part.resolveSemanticElement());
			}
		}
	});		
	
	return CommandResult.newOKCommandResult();
}
 
Example #7
Source File: CompartmentChildCreateCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {

	View view =
		ViewService.getInstance().createView(
				viewDescriptor.getViewKind(),
				viewDescriptor.getElementAdapter(),
				containerView,
				viewDescriptor.getSemanticHint(),
				index,
				viewDescriptor.isPersisted(),
				viewDescriptor.getPreferencesHint());
	Assert.isNotNull(view, "failed to create a view"); //$NON-NLS-1$
	viewDescriptor.setView(view);

	return CommandResult.newOKCommandResult(viewDescriptor);
}
 
Example #8
Source File: DiagramElementsModifier.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
public static void repositionConnectionLabels(DiagramEditPart diagep,
		List<GraphicalEditPart> elements) {
	for (EditPart editpart : elements) {
		GraphicalEditPart ep = ((GraphicalEditPart) editpart);
		@SuppressWarnings("unchecked")
		List<ConnectionNodeEditPart> connections = ep.getSourceConnections();
		for (ConnectionNodeEditPart connection : connections) {
			@SuppressWarnings("unchecked")
			List<GraphicalEditPart> labels = connection.getChildren();
			for (GraphicalEditPart label : labels) {
				List<Class<?>> decorationTypes = Arrays.asList(AssociationNameEditPart.class,
						AssociationMultiplicityTargetEditPart.class, AssociationMultiplicitySourceEditPart.class);

				String commandName = "RepositioningLabels";

				if (isInstanceOfAny(label, decorationTypes)) {
					ICommand cmd = new AbstractTransactionalCommand(diagep.getEditingDomain(), commandName, null) {
						@Override
						protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
								throws ExecutionException {
							CSSDecorationNodeImpl v = ((CSSDecorationNodeImpl) label.getModel());

							Location LC = (Location) v.getLayoutConstraint();
							LC.setX(0);
							LC.setY(0);
							return CommandResult.newOKCommandResult();
						}
					};

					try {
						cmd.execute(new NullProgressMonitor(), null);
					} catch (ExecutionException e) {
						Logger.sys.warn("Could not execute command " + cmd + " (" + commandName + ")");
					}
				}
			}
		}
	}
}
 
Example #9
Source File: ServiceTaskCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	ServiceTask newElement = ProcessFactory.eINSTANCE.createServiceTask();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_ServiceTask_2027(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #10
Source File: TextAnnotationAttachmentCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	if (!canExecute()) {
		throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
	}

	TextAnnotationAttachment newElement = ProcessFactory.eINSTANCE.createTextAnnotationAttachment();
	getContainer().getTextAnnotationAttachment().add(newElement);
	newElement.setSource(getSource());
	newElement.setTarget(getTarget());
	doConfigure(newElement, monitor, info);
	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);

}
 
Example #11
Source File: InsertElementOnSequenceFlowCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CommandResult doRedoWithResult(final IProgressMonitor progressMonitor,
        final IAdaptable info) throws ExecutionException {
    if (creationCommand != null && creationCommand.canExecute()) {
        creationCommand.execute();
    }
    return doExecuteWithResult(progressMonitor, info);
}
 
Example #12
Source File: BoundarySignalEvent2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	BoundarySignalEvent newElement = ProcessFactory.eINSTANCE.createBoundarySignalEvent();

	Activity owner = (Activity) getElementToEdit();
	owner.getBoundaryIntermediateEvents().add(newElement);

	ElementInitializers.getInstance().init_BoundarySignalEvent_3053(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #13
Source File: SendTask2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	SendTask newElement = ProcessFactory.eINSTANCE.createSendTask();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_SendTask_3025(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #14
Source File: ExtractAsCallActivityHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
    DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    ExtractAsCallActivityTransactionalCommand command = new ExtractAsCallActivityTransactionalCommand(editor);
    OperationHistoryFactory.getOperationHistory().execute(command, null, null);
    CommandResult commandResult = command.getCommandResult();
    if (!commandResult.getStatus().isOK()) {
        MessageDialog.openError(editor.getSite().getShell(), Messages.extractSubprocessError, commandResult.getStatus().getMessage());
    }
    return commandResult.getStatus();
}
 
Example #15
Source File: EndTerminatedEvent2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	EndTerminatedEvent newElement = ProcessFactory.eINSTANCE.createEndTerminatedEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_EndTerminatedEvent_3062(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #16
Source File: XORGatewayCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	XORGateway newElement = ProcessFactory.eINSTANCE.createXORGateway();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_XORGateway_2008(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #17
Source File: EndErrorEvent2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	EndErrorEvent newElement = ProcessFactory.eINSTANCE.createEndErrorEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_EndErrorEvent_3050(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #18
Source File: ANDGateway2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	ANDGateway newElement = ProcessFactory.eINSTANCE.createANDGateway();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_ANDGateway_3009(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #19
Source File: IntermediateCatchMessageEventCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	IntermediateCatchMessageEvent newElement = ProcessFactory.eINSTANCE.createIntermediateCatchMessageEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_IntermediateCatchMessageEvent_2013(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #20
Source File: BoundaryMessageEventCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	BoundaryMessageEvent newElement = ProcessFactory.eINSTANCE.createBoundaryMessageEvent();

	Activity owner = (Activity) getElementToEdit();
	owner.getBoundaryIntermediateEvents().add(newElement);

	ElementInitializers.getInstance().init_BoundaryMessageEvent_3035(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #21
Source File: Activity2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	Activity newElement = ProcessFactory.eINSTANCE.createActivity();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_Activity_3006(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #22
Source File: EventCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	Event newElement = ProcessFactory.eINSTANCE.createEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #23
Source File: ScriptTask2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	ScriptTask newElement = ProcessFactory.eINSTANCE.createScriptTask();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_ScriptTask_3028(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #24
Source File: UpdateAnnotationsOnMoveCommand.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {

	final View parentView = TreeLayoutUtil.getTreeNodeParentView(editPart
			.getNotationView());

	if (parentView != null) {
		final IGraphicalEditPart parentEditPart = (IGraphicalEditPart) editPart
				.findEditPart(editPart.getParent(), parentView.getElement());
		if (parentEditPart != null) {
			final List<IGraphicalEditPart> treeChildren = new ArrayList<IGraphicalEditPart>(

			TreeLayoutUtil.getOrderedTreeChildren(parentEditPart));
			if (!treeChildren.isEmpty()) {
				final int oldPos = treeChildren.indexOf(editPart);
				final int newPos = layoutConstraint.getTreeInnerRankIndex();

				if (newPos != -1) {
					if (oldPos != newPos) {
						final IGraphicalEditPart element = treeChildren
								.get(oldPos);
						treeChildren.remove(oldPos);
						treeChildren.add(newPos, element);
						TreeLayoutUtil
								.setTreeNodesPositionAnnotation(TreeLayoutUtil
										.getViews(treeChildren));
					}
				}
				return CommandResult.newOKCommandResult();
			}

		}
	}
	return CommandResult
			.newErrorCommandResult("Parent view or parent edit part not found!");
}
 
Example #25
Source File: MoveDataCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {

	for (Data data : datas) {

		if (data.isTransient()) {
			data.setTransient(false);// transient data not supported on
										// process
		}
		boolean exists = false;
		for (Data d : target.getData()) {
			if (d.getName().equals(data.getName())) {
				exists = true;
			}
		}
		if (!exists) {
			container.getData().remove(data);
			target.getData().add(data);
		} else {
			dataNotMoved.add(data);
		}
	}
	if (dataNotMoved.isEmpty()) {
		return CommandResult.newOKCommandResult();
	} else {
		return CommandResult.newWarningCommandResult("Some Data cannot be moved", dataNotMoved);
	}
}
 
Example #26
Source File: IntermediateCatchTimerEventCreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	IntermediateCatchTimerEvent newElement = ProcessFactory.eINSTANCE.createIntermediateCatchTimerEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_IntermediateCatchTimerEvent_2017(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #27
Source File: CompartmentRepositionEObjectCommand.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public CommandResult doExecuteWithResult(IProgressMonitor progressMonitor,
		IAdaptable info) throws ExecutionException {
	CommandResult rs = super.doExecuteWithResult(progressMonitor, info);

	EditPart compartment = childToMove.getParent();

	ViewUtil.repositionChildAt((View) compartment.getModel(),
			(View) childToMove.getModel(), newIndex);
	compartment.refresh();

	return rs;
}
 
Example #28
Source File: RemoveDataTypeCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {

	//GroovyDocumentUtil.deleteGroovyType(toRemoveData);
	removeReferences(container);
	removeReferencesInChildren(container);
	((AbstractProcess)container).getDatatypes().remove(toRemoveData);
	
	return CommandResult.newOKCommandResult();
}
 
Example #29
Source File: IntermediateErrorCatchEvent2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	IntermediateErrorCatchEvent newElement = ProcessFactory.eINSTANCE.createIntermediateErrorCatchEvent();

	Activity owner = (Activity) getElementToEdit();
	owner.getBoundaryIntermediateEvents().add(newElement);

	ElementInitializers.getInstance().init_IntermediateErrorCatchEvent_3029(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example #30
Source File: StartSignalEvent2CreateCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	StartSignalEvent newElement = ProcessFactory.eINSTANCE.createStartSignalEvent();

	Container owner = (Container) getElementToEdit();
	owner.getElements().add(newElement);

	ElementInitializers.getInstance().init_StartSignalEvent_3023(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}