Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352963

Summary: ViewComponetEditPolicy should init the GroupRequestViaKeyBoard's ShowInformationDialog value in getDeleteCommand()
Product: [Modeling] GMF-Tooling Reporter: Tao LI <litaocdl>
Component: CoreAssignee: Project Inbox <gmp.gmf-tooling-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tao LI CLA 2011-07-25 00:35:04 EDT
Build Identifier: 2.3.0

We do support DeleteFromDiagramAction and DeleteFromModelAction for GMF diagram elements. Also we have preference value set which could popup a dialog to warning the user when deleting from diagram or deleting from model.
  For deleteFromDiagram Action, whether the warning dialog would only popup is depends on the the editpolicy registed into the editpart , if registed the componentEditPolicy , the getDeleteCommand() will check whether popup the warning dialog, if regist the ViewComponentEditPolicy, ViewComponentEditPolicy overwrite the getDeleteCommand() method so it will not popup the warning dialog. this could be understand and acceptable .
  But if in one diagram , some graphic element registed the ComponentEditPolicy, and reuse some graphic elements GMF provided which regist the ViewComponentEditPolicy. the problem will occur, Since The GroupRequestViaKeyBoard request is shared with these actions. When first delete a graphic element which regist the ViewComponentEditPolicy, durring the command execute, it set the ShowInformationDialog value of GroupRequestViaKeyBoard to true based on the value from preference set through the doRun() method of PromptingDeleteFromDiagramAction class . Then when invoke the context menu to a graphic element in diagram which regist ComponentEditPolicy, the popup dialog will popup before doing any action through createDeleteCommand() of ComponentEditPolicy. 

   So the suggested fix is 1. either in the doRun() method of PromptingDeleteFromDiagramAction 
	protected void doRun(IProgressMonitor progressMonitor) {
		Request req = getTargetRequest();
		boolean showInformationDialog = ((IPreferenceStore)  getPreferencesHint()
				.getPreferenceStore())
				.getBoolean(IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_DIAGRAM);
		((GroupRequestViaKeyboard) req)
				.setShowInformationDialog(showInformationDialog);
		super.doRun(progressMonitor);

      //Set the showInformationDialog value of GroupRequestViaKeyboard to false.
	}

2. Or in the ViewComponentEditPolicy when creating deleteCommand through GroupRequestViaKeyBoard, set the showInformationDialog value to false.

Reproducible: Always