compartment_deletion_fix [GMF Samples And Tutorials]
 
Table of Contents

Overview

By default, GMF strangely allows compartments to be deleted.

If we take the diagram editor built in the second tutorial, we can see that it is possible to delete a compartment by (as shown below) :

  • selecting the compartment
  • right clicking on it
  • choosing Delete form model in the popup menu

Fixes

To disable this possibility, we must edit the java class named XXXXCompartmentItemSemanticEditPolicy of the package xxx.diagram.edit.policies and add this method :

	protected Command getSemanticCommand(IEditCommandRequest request) {
		if (request instanceof DestroyRequest) {
			return null;
		}
		return super.getSemanticCommand(request);
	}

It is also possible to completely disable the Delete from model popup menu item by modyfing the method getDestroyElementCommand of the XXXBaseEditHelper of the package xxx.diagram.edit.helpers like this (but this is more restrictive than the previous solution) :

	/**
	 * @generated NOT
	 */
	protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
		return UnexecutableCommand.INSTANCE;
	}

Thank you

I hope that this material will be helpful for you. If you want to support it, your help is welcome :

 
compartment_deletion_fix.txt · Last modified: 2011/08/08 20:08 by jfbraz
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki