org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand Java Examples

The following examples show how to use org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand. 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: TypeItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
	View view = (View) getHost().getModel();
	for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
		Node node = (Node) nit.next();
		switch (CrossflowVisualIDRegistry.getVisualID(node)) {
		case TypeTypeFieldsCompartmentEditPart.VISUAL_ID:
			for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
				Node cnode = (Node) cit.next();
				switch (CrossflowVisualIDRegistry.getVisualID(cnode)) {
				case Field3EditPart.VISUAL_ID:
					cmd.add(new DestroyElementCommand(
							new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
					// don't need explicit deletion of cnode as parent's view deletion would clean child views as well 
					// cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
					break;
				}
			}
			break;
		}
	}
}
 
Example #2
Source File: MessageFlowFactory.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static void removeMessageFlow(TransactionalEditingDomain editingDomain, AbstractCatchMessageEvent target,
        DiagramEditPart dep) {

    EditPart ep = findEditPart(dep, target);
    CompositeCommand command = new CompositeCommand("Remove MessageFlows");

    for (Object connection : ((AbstractGraphicalEditPart) ep).getTargetConnections()) {
        if (connection instanceof MessageFlowEditPart) {
            MessageFlowEditPart connectionPart = (MessageFlowEditPart) connection;
            MessageFlow flow = (MessageFlow) connectionPart.resolveSemanticElement();
            SetCommand c = new SetCommand(editingDomain, flow.getTarget(),
                    ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT, null);
            editingDomain.getCommandStack().execute(c);
            command.add(new DeleteCommand(editingDomain, connectionPart.getPrimaryView()));
            DestroyElementRequest req = new DestroyElementRequest(editingDomain, flow, false);
            DestroyElementCommand rmComd = new DestroyElementCommand(req);
            command.add(rmComd);
        }
    }

    dep.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(command.reduce()));
    dep.getDiagramEditDomain().getDiagramCommandStack().flush();
    dep.refresh();
}
 
Example #3
Source File: RegionEditHelper.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ICommand getBasicDestroyElementCommand(final DestroyElementRequest req) {
	// Deletion is only allowed if subdiagrams are not opened in another
	// editor
	return new DestroyElementCommand(req) {
		@Override
		protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
			if (getElementToDestroy() instanceof State && getElementToDestroy().eResource() != null) {
				boolean success = DiagramPartitioningUtil.closeSubdiagramEditors((State) getElementToDestroy());
				if (success)
					return super.doExecute(monitor, info);
				else
					return Status.CANCEL_STATUS;
			}
			return super.doExecute(monitor, info);
		}
	};
}
 
Example #4
Source File: VertexEditHelper.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ICommand getDestroyDependentsCommand(DestroyDependentsRequest req) {
	
	Vertex elementToDestroy = (Vertex) req.getElementToDestroy();
	EList<Transition> incomingTransitions = elementToDestroy
			.getIncomingTransitions();
	if (incomingTransitions.size() != 0) {
		CompositeCommand compoundCommand = new CompositeCommand(
				"Delete vertex");
		for (Transition transition : incomingTransitions) {
			DestroyElementCommand destroyCommand = new DestroyElementCommand(
					new DestroyElementRequest(transition, false));
			compoundCommand.add(destroyCommand);
		}
		return compoundCommand;
	}
	return super.getDestroyDependentsCommand(req);
}
 
Example #5
Source File: ScriptedTaskItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
	View view = (View) getHost().getModel();
	for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
		Node node = (Node) nit.next();
		switch (CrossflowVisualIDRegistry.getVisualID(node)) {
		case ScriptedTaskScriptedTaskOutputVariablesCompartmentEditPart.VISUAL_ID:
			for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
				Node cnode = (Node) cit.next();
				switch (CrossflowVisualIDRegistry.getVisualID(cnode)) {
				case Field2EditPart.VISUAL_ID:
					cmd.add(new DestroyElementCommand(
							new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
					// don't need explicit deletion of cnode as parent's view deletion would clean child views as well 
					// cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
					break;
				}
			}
			break;
		}
	}
}
 
Example #6
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 #7
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 #8
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 #9
Source File: LanguageItemSemanticEditPolicy.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
	View view = (View) getHost().getModel();
	for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
		Node node = (Node) nit.next();
		switch (CrossflowVisualIDRegistry.getVisualID(node)) {
		case LanguageLanguageParametersCompartmentEditPart.VISUAL_ID:
			for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
				Node cnode = (Node) cit.next();
				switch (CrossflowVisualIDRegistry.getVisualID(cnode)) {
				case ParameterEditPart.VISUAL_ID:
					cmd.add(new DestroyElementCommand(
							new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
					// don't need explicit deletion of cnode as parent's view deletion would clean child views as well 
					// cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
					break;
				}
			}
			break;
		}
	}
}
 
Example #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
Source File: NotationClipboardOperationHelper.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public void destroy(EObject eObject) {
	DestroyElementCommand.destroy(eObject);
}
 
Example #17
Source File: MessageFlowItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	return getGEFWrapper(new DestroyElementCommand(req));
}
 
Example #18
Source File: SequenceFlowItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	return getGEFWrapper(new DestroyElementCommand(req));
}
 
Example #19
Source File: TextAnnotationAttachmentItemSemanticEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
	return getGEFWrapper(new DestroyElementCommand(req));
}