Java Code Examples for org.eclipse.gmf.runtime.notation.View#getEAnnotation()

The following examples show how to use org.eclipse.gmf.runtime.notation.View#getEAnnotation() . 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: Field3ItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example 2
Source File: LanguageItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example 3
Source File: ParameterItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example 4
Source File: Field2ItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example 5
Source File: FieldItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}
	return getGEFWrapper(cmd.reduce());
}
 
Example 6
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public static void setTreeNodesPositionAnnotation(List<View> viewElements) {
	if (viewElements != null) {
		for (int index = 0; index < viewElements.size(); index++) {
			final View view = viewElements.get(index);
			EAnnotation xmiIdAnnotation = view
					.getEAnnotation(TREE_LAYOUT_ANNOTATION);
			if (xmiIdAnnotation == null) {
				xmiIdAnnotation = EcoreFactory.eINSTANCE
						.createEAnnotation();
				xmiIdAnnotation.setSource(TREE_LAYOUT_ANNOTATION);
			}
			xmiIdAnnotation.getDetails().put(TREE_NODE_POSITION,
					Integer.toString(index));
			xmiIdAnnotation.setEModelElement(view);
		}
	}
}
 
Example 7
Source File: SubProcessEventItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example 8
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 9
Source File: LaneItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example 10
Source File: SubProcessEvent2ItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example 11
Source File: PoolItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	View view = (View) getHost().getModel();
	CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
	cmd.setTransactionNestingEnabled(false);
	for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
		Edge incomingLink = (Edge) it.next();
		if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) {
			DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
			cmd.add(new DestroyElementCommand(r));
			cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
			continue;
		}
	}
	EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
	if (annotation == null) {
		// there are indirectly referenced children, need extra commands: false
		addDestroyChildNodesCommand(cmd);
		addDestroyShortcutsCommand(cmd, view);
		// delete host element
		cmd.add(new DestroyElementCommand(req));
	} else {
		cmd.add(new DeleteCommand(getEditingDomain(), view));
	}

	final EObject pool = req.getElementToDestroy();
	if (pool instanceof Pool) {
		for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) {
			if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) {
				cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false)));
			}
		}
	}

	return getGEFWrapper(cmd.reduce());
}
 
Example 12
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public static void setTreeNodeParentAnnotation(View child, View parent) {
	EAnnotation xmiIdAnnotation = child
			.getEAnnotation(TREE_LAYOUT_ANNOTATION);
	if (xmiIdAnnotation == null) {
		xmiIdAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
		xmiIdAnnotation.setSource(TREE_LAYOUT_ANNOTATION);
	}
	xmiIdAnnotation.getDetails().put(TREE_NODE_PARENT_URI,
			parent.eResource().getURIFragment(parent));
	xmiIdAnnotation.setEModelElement(child);
}
 
Example 13
Source File: TreeLayoutUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the parent view of a tree node from the parent view annotation.
 * 
 * @param editPart
 * @return
 */
public static View getTreeNodeParentView(View view) {
	final EAnnotation xmiIdAnnotation = view
			.getEAnnotation(TREE_LAYOUT_ANNOTATION);
	if (xmiIdAnnotation != null) {
		return (View) view.eResource().getEObject(
				xmiIdAnnotation.getDetails().get(TREE_NODE_PARENT_URI));
	}
	return null;
}
 
Example 14
Source File: CrossflowNavigatorContentProvider.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @generated
 */
private Collection<CrossflowNavigatorItem> getForeignShortcuts(Diagram diagram, Object parent) {
	LinkedList<View> result = new LinkedList<View>();
	for (Iterator<View> it = diagram.getChildren().iterator(); it.hasNext();) {
		View nextView = it.next();
		if (!isOwnView(nextView) && nextView.getEAnnotation("Shortcut") != null) { //$NON-NLS-1$
			result.add(nextView);
		}
	}
	return createNavigatorItems(result, parent, false);
}
 
Example 15
Source File: CrossflowShortcutsDecoratorProvider.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public void createDecorators(IDecoratorTarget decoratorTarget) {
	View view = (View) decoratorTarget.getAdapter(View.class);
	if (view != null) {
		EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
		if (annotation != null) {
			decoratorTarget.installDecorator(SHORTCUTS_DECORATOR_ID, new ShortcutsDecorator(decoratorTarget));
		}
	}
}
 
Example 16
Source File: CrossflowShortcutPropertyTester.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public boolean test(Object receiver, String method, Object[] args, Object expectedValue) {
	if (false == receiver instanceof View) {
		return false;
	}
	View view = (View) receiver;
	if (SHORTCUT_PROPERTY.equals(method)) {
		EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
		if (annotation != null) {
			return WorkflowEditPart.MODEL_ID.equals(annotation.getDetails().get("modelID")); //$NON-NLS-1$
		}
	}
	return false;
}
 
Example 17
Source File: WorkflowCanonicalEditPolicy.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
* @generated
*/
protected static boolean isShortcut(View view) {
	return view.getEAnnotation("Shortcut") != null; //$NON-NLS-1$
}