use of org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest 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.emf.type.core.requests.DestroyRequest in project statecharts by Yakindu.
the class StatechartTextEditPart method createDefaultEditPolicies.
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
// Disables deletion of the text compartment view if additional elements
// are selected too
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new SemanticEditPolicy() {
@Override
protected boolean shouldProceed(DestroyRequest destroyRequest) {
return false;
}
});
// Disables deletion of the text compartment view via keyboard
installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy());
removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PreferredSizeHandlerEditPolicy() {
@Override
protected IFigure getPreferredSizeFigure() {
return getChildBySemanticHint(SemanticHints.STATECHART_NAME).getFigure();
}
});
}
Aggregations