org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest Java Examples

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest. 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: StateCompartmentCreationEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Command getCreateCommand(CreateViewRequest request) {
	StateEditPart parent = (StateEditPart) getHost().getParent();
	BooleanValueStyle isInline = GMFNotationUtil.getBooleanValueStyle(parent.getNotationView(),
			DiagramPartitioningUtil.INLINE_STYLE);
	if (isInline != null && !isInline.isBooleanValue())
		return UnexecutableCommand.INSTANCE;

	List<? extends ViewDescriptor> viewDescriptors = request.getViewDescriptors();
	for (ViewDescriptor viewDescriptor : viewDescriptors) {
		String semanticHint = viewDescriptor.getSemanticHint();
		if (ViewType.NOTE.equals(semanticHint) || ViewType.NOTEATTACHMENT.equals(semanticHint)
				|| ViewType.TEXT.equals(semanticHint)) {
			return UnexecutableCommand.INSTANCE;
		}
	}
	return super.getCreateCommand(request);
}
 
Example #2
Source File: CompartmentChildCreationEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Command getCreateCommand(CreateViewRequest request) {
	TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
	.getEditingDomain();
	CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
			editingDomain, DiagramUIMessages.AddCommand_Label);

	Iterator<?> descriptors = request.getViewDescriptors().iterator();

	while (descriptors.hasNext()) {
		CreateViewRequest.ViewDescriptor descriptor =
			(CreateViewRequest.ViewDescriptor)descriptors.next();

		CreateCommand createCommand =
			new CompartmentChildCreateCommand(editingDomain,
					descriptor, 
					(View)(getHost().getModel()), getFeedbackIndexFor(request));

		cc.compose(createCommand);
	}
	return new ICommandProxy(cc.reduce());
}
 
Example #3
Source File: CrossflowCreateShortcutDecorationsCommand.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	for (Iterator it = myDescriptors.iterator(); it.hasNext();) {
		CreateViewRequest.ViewDescriptor nextDescriptor = (CreateViewRequest.ViewDescriptor) it.next();
		View view = (View) nextDescriptor.getAdapter(View.class);
		if (view != null && view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
			EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
			shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$
			shortcutAnnotation.getDetails().put("modelID", WorkflowEditPart.MODEL_ID); //$NON-NLS-1$
			view.getEAnnotations().add(shortcutAnnotation);
		}
	}
	return CommandResult.newOKCommandResult();
}
 
Example #4
Source File: GMFTools.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param node
 * @param type
 * @return
 */
public static Node createNode(final GraphicalEditPart node, IElementType type) {
    CreateViewRequest boundaryRequest = CreateViewRequestFactory.getCreateShapeRequest(type,
            node.getDiagramPreferencesHint());
    Command command = node.getCommand(boundaryRequest);

    final IDiagramEditDomain diagramEditDomain = node.getDiagramEditDomain();
    diagramEditDomain.getDiagramCommandStack().execute(command);

    IAdaptable targetAdapter = (IAdaptable) ((List<?>) boundaryRequest.getNewObject()).get(0);
    Node newNode = (Node) targetAdapter.getAdapter(EObject.class);
    return newNode;
}
 
Example #5
Source File: CrossflowCreateShortcutDecorationsCommand.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
* @generated
*/
public CrossflowCreateShortcutDecorationsCommand(TransactionalEditingDomain editingDomain, View parentView,
		CreateViewRequest.ViewDescriptor viewDescriptor) {
	this(editingDomain, parentView, Collections.singletonList(viewDescriptor));
}
 
Example #6
Source File: CompartmentLayoutEditPolicy.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected Command getCreateCommand(CreateRequest request) {
	if (request instanceof CreateViewAndElementRequest) {

		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
				.getEditingDomain();
		CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
				editingDomain, DiagramUIMessages.AddCommand_Label);

		Iterator<?> descriptors = ((CreateViewRequest) request)
				.getViewDescriptors().iterator();

		while (descriptors.hasNext()) {
			CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors
					.next();

			int feedBackIndex = getFeedbackIndexFor(request);

			// obtain CreateElementRequest and add initial region feedback
			// index to request map. This index is needed to add the
			// semantic element at the correct listIndex
			CreateElementRequest createElementRequest = (CreateElementRequest) ((CreateViewAndElementRequest) request)
					.getViewAndElementDescriptor()
					.getCreateElementRequestAdapter()
					.getAdapter(CreateElementRequest.class);

			if (createElementRequest != null) {
				createElementRequest.getParameters().put(
						RequestParameterKeys.RegionFeedbackIndex,
						feedBackIndex);
			}

			CreateCommand createCommand = new CompartmentChildCreateCommand(
					editingDomain, descriptor,
					(View) (getHost().getModel()), feedBackIndex);

			cc.compose(createCommand);
		}
		return new ICommandProxy(cc.reduce());
	}

	return null;
}