use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project tdi-studio-se by Talend.
the class BusinessItemDragDropEditPolicy method getDropObjectsCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy#getDropObjectsCommand(org.eclipse.gmf
* .runtime.diagram.ui.requests.DropObjectsRequest)
*/
@Override
public Command getDropObjectsCommand(DropObjectsRequest dropObjectsRequest) {
BusinessItem businessItem = new ElementHelper().getElement(getHost());
if (businessItem != null) {
CreateAssignmentCommand createAssignmentCommand = new CreateAssignmentCommand(((IGraphicalEditPart) getHost()).getEditingDomain());
createAssignmentCommand.setBusinessItem(businessItem);
createAssignmentCommand.setItems(dropObjectsRequest.getObjects());
return new ICommandProxy(createAssignmentCommand);
}
return UnexecutableCommand.INSTANCE;
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project tdi-studio-se by Talend.
the class BusinessProcessCanonicalEditPolicy method refreshSemantic.
/**
* @generated
*/
protected void refreshSemantic() {
List createdViews = new LinkedList();
createdViews.addAll(refreshSemanticChildren());
List createdConnectionViews = new LinkedList();
createdConnectionViews.addAll(refreshSemanticConnections());
createdConnectionViews.addAll(refreshConnections());
if (createdViews.size() > 1) {
// perform a layout of the container
DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
executeCommand(new ICommandProxy(layoutCmd));
}
createdViews.addAll(createdConnectionViews);
makeViewsImmutable(createdViews);
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project tdi-studio-se by Talend.
the class BusinessBaseItemSemanticEditPolicy method getSemanticCommand.
/**
* @generated
*/
protected Command getSemanticCommand(IEditCommandRequest request) {
IEditCommandRequest completedRequest = completeRequest(request);
Object editHelperContext = completedRequest.getEditHelperContext();
if (editHelperContext instanceof View || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) {
// no semantic commands are provided for pure design elements
return null;
}
if (editHelperContext == null) {
editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel());
}
IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext);
if (elementType == ElementTypeRegistry.getInstance().getType("org.eclipse.gmf.runtime.emf.type.core.default")) {
//$NON-NLS-1$
elementType = null;
}
Command epCommand = getSemanticCommandSwitch(completedRequest);
if (epCommand != null) {
ICommand command = epCommand instanceof ICommandProxy ? ((ICommandProxy) epCommand).getICommand() : new CommandProxy(epCommand);
completedRequest.setParameter(BusinessBaseEditHelper.EDIT_POLICY_COMMAND, command);
}
Command ehCommand = null;
if (elementType != null) {
ICommand command = elementType.getEditCommand(completedRequest);
if (command != null) {
if (!(command instanceof CompositeTransactionalCommand)) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
command = new CompositeTransactionalCommand(editingDomain, null).compose(command);
}
ehCommand = new ICommandProxy(command);
}
}
boolean shouldProceed = true;
if (completedRequest instanceof DestroyRequest) {
shouldProceed = shouldProceed((DestroyRequest) completedRequest);
}
if (shouldProceed) {
if (completedRequest instanceof DestroyRequest) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
Command deleteViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View) getHost().getModel()));
ehCommand = ehCommand == null ? deleteViewCommand : ehCommand.chain(deleteViewCommand);
}
return ehCommand;
}
return null;
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.
the class CompartmentLayoutEditPolicy method createMoveChildCommand.
@Override
@SuppressWarnings("rawtypes")
protected Command createMoveChildCommand(EditPart child, EditPart after) {
int newIndex;
int displacement;
int childIndex = getHost().getChildren().indexOf(child);
int afterIndex = getHost().getChildren().indexOf(after);
if (afterIndex == -1) {
newIndex = getHost().getChildren().size() - 1;
displacement = newIndex - childIndex;
} else {
newIndex = afterIndex;
displacement = afterIndex - childIndex;
if (childIndex <= afterIndex) {
newIndex--;
displacement--;
}
}
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
RepositionEObjectCommand command = new CompartmentRepositionEObjectCommand(child, editingDomain, "", (EList) ((View) child.getParent().getModel()).getElement().eGet(feature), ((View) child.getModel()).getElement(), displacement, newIndex);
eraseLayoutTargetFeedback(null);
return new ICommandProxy(command);
}
use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.
the class TreeLayoutEditPolicy method getCreateCommand.
@Override
protected Command getCreateCommand(CreateRequest request) {
final CompoundCommand cmd = new CompoundCommand();
cmd.add(super.getCreateCommand(request));
if (request instanceof CreateViewAndElementRequest) {
final CreateViewAndElementRequest req = (CreateViewAndElementRequest) request;
if (shouldUpdateAnnotationsOnCreation(req)) {
cmd.add(new ICommandProxy(new UpdateAnnotationsOnCreationCommand(getHost().getEditingDomain(), req)));
}
}
return cmd;
}
Aggregations