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

Bug 363592

Summary: Need DojoDialogLib function to prompt user for a string value
Product: z_Archived Reporter: Will Smythe <smythew>
Component: EDTAssignee: lu lu <lulu>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: chenzhh, hjiyong, mayunf, svihovec
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 366284    
Bug Blocks:    
Attachments:
Description Flags
Prototype code
none
prompt user with a string value input dialog
none
Use get/setUserData to replace get/setAttributes and array
lulu: review?
Updated DojoDialogLib with fixes
none
Provide more functions and cope with cancel action
none
Refine based on the latest version lulu: review?

Description Will Smythe CLA 2011-11-11 10:27:12 EST
Prompting a user for a string is a common need in GUI applications. DojoDialogLib should have a simple function for doing this. The alternative is forcing developers to code their own dialog with text field, which is not necessarily hard, but is definitely harder than a simple function call. 

I prototyped this and have attached the code. See DojoDialogLib.promptForValue
Comment 1 Will Smythe CLA 2011-11-11 10:27:33 EST
Created attachment 206854 [details]
Prototype code
Comment 2 Tony Chen CLA 2011-11-14 00:52:23 EST
I did a quick testing of DojoDialogLib.promptForValue in attached file. My callback function did not get the text input. the value argument is a null in callback. 

I would suggest we put this to 1.0 so that we can have more testing for this.
Comment 3 Will Smythe CLA 2012-01-31 08:12:35 EST
Adding this comment to remind whoever implements this enhancement that it depends on Bug 366284 - Need ability to set arbitrary data on a widget.
Comment 4 lu lu CLA 2012-02-09 02:12:49 EST
Created attachment 210774 [details]
prompt user with a string value input dialog

Hi Will,

I add a patch and test it on local env, it has realized that prompt a dialog to input string value, but a bit puzzled with your comment 4, not sure if the implementation can meet the enhancement, can you help to take a look at it?  Thanks.
Comment 5 lu lu CLA 2012-02-13 09:14:57 EST
Created attachment 210911 [details]
Use get/setUserData to replace get/setAttributes and array

Use get/setUserData to replace set/getAttributes and arrays.

And this enh depends on another bug 371333.
Comment 6 Huang Ji Yong CLA 2012-02-13 21:51:28 EST
Reviewed and committed.
Comment 7 lu lu CLA 2012-02-14 02:00:40 EST
Ji Yong has helped to review and deliver this enh, Thanks. Mark this enh as resolved.
Comment 8 Will Smythe CLA 2012-02-21 10:49:07 EST
Reopening. The Cancel button behaves identically to the OK button, meaning the value in the prompt field is passed to the callback function regardless if OK or Cancel is clicked.

One idea is to allow the string value in the delegate to be declared as nullable. If the user presses Cancel, the callback will get called, but the value will be null. E.g.

delegate promptSupplied(value String? in, e Event in) returns (boolean)

.. and then add code in DojoDialogLib.promptButtonClick to handle the case where the Cancel button is clicked:

	callback promptSupplied = promptField.getUserData();
	if (buttonDict.functionId == ID_CANCEL)
		hide = callback(null, e);
	else
		hide = callback(promptField.text, e);			
	end
Comment 9 Will Smythe CLA 2012-02-21 11:15:58 EST
I made the change and confirmed it works. See attached file. I also made a few other, necessary changes:

1) Pressing ENTER or ESC triggers the OK and Cancel buttons, respectively

2) Made the "title" variable nullable in the function declaration for the various "showXXX" functions. This will save the developer for calling RuiLib.getTitle() themselves

3) Fixed broken image links (this has probably been broken for awhile)
Comment 10 Brian Svihovec CLA 2012-02-21 11:16:14 EST
Deferring to I3 for final resolution.
Comment 11 Will Smythe CLA 2012-02-21 11:16:27 EST
Created attachment 211340 [details]
Updated DojoDialogLib with fixes
Comment 12 lu lu CLA 2012-02-22 05:39:01 EST
Created attachment 211390 [details]
Provide more functions and cope with cancel action

Hi Will,

I tested the changes in local env, I assume if we should enlarge the influence when Press ENTER or ESC buttons, otherwise, those hot keys can be triggered only if focus on prompt field, so move OnKeyDown event to table widget, like this:

*****************************************************************************
   From:   promptField DojoTextField { width = "300px", style = "max-width: 500px", onKeyDown ::= promptFieldKeyDown };
   To:     table Widget { tagName = "table", children = [ body ], style = "max-width: 500px", onKeyDown ::= tableKeyDown };
*****************************************************************************

I attach the patch, please help to review. Thanks.
Comment 13 lu lu CLA 2012-02-28 04:58:13 EST
Has been tested on IE/Chrome/FF.

Hi JiYong, Can you help to commit this? Thanks.
Comment 14 lu lu CLA 2012-02-28 05:40:33 EST
Created attachment 211718 [details]
Refine based on the latest version
Comment 15 Huang Ji Yong CLA 2012-02-28 20:26:39 EST
Committed
Comment 16 lu lu CLA 2012-02-29 09:17:45 EST
Done. Thanks.
Comment 17 Lisa Lasher CLA 2012-03-30 18:36:24 EDT
close