Java Code Examples for org.eclipse.gmf.runtime.common.core.command.CommandResult#newOKCommandResult()

The following examples show how to use org.eclipse.gmf.runtime.common.core.command.CommandResult#newOKCommandResult() . 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: SaveDiagramResourceCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
    if (content instanceof MainProcess) {
        if (!resource.getContents().isEmpty()) {
            resource.getContents().remove(0);
        }
        resource.getContents().add(0, (MainProcess) content);
    } else if (content instanceof Diagram) {
        if (resource.getContents().size() > 1) {
            resource.getContents().remove(1);
        }
        resource.getContents().add(1, (EObject) content);
    } else if (content instanceof Collection) {
        final Collection<EObject> collectionsOfContents = (Collection<EObject>) content;
        resource.getContents().addAll(collectionsOfContents);
    }
    return CommandResult.newOKCommandResult(resource);
}
 
Example 2
Source File: OverlapSetBoundsCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
    if (adapter == null) {
        return CommandResult.newErrorCommandResult("SetBoundsCommand: viewAdapter does not adapt to IView.class");
    }
    final View view = (View) adapter.getAdapter(View.class);
    final Point location = bounds.getLocation();
    if (location != null) {
        Point newLoc = location.getCopy();
        if (FiguresHelper.AVOID_OVERLAP_ENABLE) {
            newLoc = findValidLocation(newLoc);
            if (!newLoc.equals(handleMargins(newLoc))) { //Still overlapping
                return CommandResult.newCancelledCommandResult();
            }
        }
        ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLocation_X(), Integer.valueOf(newLoc.x));
        ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLocation_Y(), Integer.valueOf(newLoc.y));
    }
    final Dimension size = bounds.getSize();
    if (size != null) {
        ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getSize_Width(), Integer.valueOf(size.width));
        ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getSize_Height(), Integer.valueOf(size.height));
    }
    return CommandResult.newOKCommandResult();
}
 
Example 3
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 4
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 5
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 6
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 7
Source File: ANDGatewayCreateCommand.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_2009(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 8
Source File: InclusiveGatewayCreateCommand.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 {
	InclusiveGateway newElement = ProcessFactory.eINSTANCE.createInclusiveGateway();

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

	ElementInitializers.getInstance().init_InclusiveGateway_2030(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 9
Source File: XORGateway2CreateCommand.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_3008(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 10
Source File: BoundarySignalEventCreateCommand.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_3052(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 11
Source File: EndSignalEvent2CreateCommand.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 {
	EndSignalEvent newElement = ProcessFactory.eINSTANCE.createEndSignalEvent();

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

	ElementInitializers.getInstance().init_EndSignalEvent_3020(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 12
Source File: InclusiveGateway2CreateCommand.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 {
	InclusiveGateway newElement = ProcessFactory.eINSTANCE.createInclusiveGateway();

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

	ElementInitializers.getInstance().init_InclusiveGateway_3051(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 13
Source File: InitializeTreeNodeAnnotationsCommand.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 {
	if (CommandUtil.executeUndoableOperation(
			annotateElements(TreeLayoutUtil
					.getOrderedTreeChildren(treeRootNodeEditPart))).isOK()) {
		return CommandResult.newOKCommandResult();
	}
	return CommandResult.newErrorCommandResult(new ExecutionException(
			"Error while annotating model elements!"));
}
 
Example 14
Source File: Task2CreateCommand.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 {
	Task newElement = ProcessFactory.eINSTANCE.createTask();

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

	ElementInitializers.getInstance().init_Task_3005(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 15
Source File: EndTerminatedEventCreateCommand.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_2035(newElement);

	doConfigure(newElement, monitor, info);

	((CreateElementRequest) getRequest()).setNewElement(newElement);
	return CommandResult.newOKCommandResult(newElement);
}
 
Example 16
Source File: ChangeConnectorContainerCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private CommandResult doCopyConnectors() {
    for (final Connector connector : connectorsToMove) {
        final Set<String> existingNames = new HashSet<String>();
        for (final Connector c : target.getConnectors()) {
            existingNames.add(c.getName());
        }
        final Connector connectorCopy = EcoreUtil.copy(connector);
        final String name = NamingUtils.generateNewName(existingNames, connectorCopy.getName(), 1);
        connectorCopy.setName(name);
        connectorCopy.setEvent(connectorEvent);
        target.getConnectors().add(connectorCopy);
    }
    return CommandResult.newOKCommandResult();
}
 
Example 17
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 18
Source File: RemoveDataCommand.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 (Object item : toRemoveData) {
		Data data = (Data)item;
		container.getData().remove(data);
	}
	return CommandResult.newOKCommandResult();
}
 
Example 19
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 20
Source File: TaskOutputReorientCommand.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
* @generated
*/
protected CommandResult reorientTarget() throws ExecutionException {
	getOldSource().getOutput().remove(getOldTarget());
	getOldSource().getOutput().add(getNewTarget());
	return CommandResult.newOKCommandResult(referenceOwner);
}