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

Bug 305365

Summary: [variables] Allow for editable value different from the current formatted value.
Product: [Tools] CDT Reporter: David Dubrow <david.dubrow>
Component: cdt-debug-dsfAssignee: David Dubrow <david.dubrow>
Status: RESOLVED FIXED QA Contact: Pawel Piech <pawel.1.piech>
Severity: enhancement    
Priority: P3 CC: cdtdoug, david.dubrow, ed.swartz, ken.ryall, pawel.1.piech
Version: 7.0Flags: pawel.1.piech: review+
Target Milestone: 7.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
additional changes
none
new patch pawel.1.piech: iplog-

Description David Dubrow CLA 2010-03-10 12:19:22 EST
I would like to propose an API change for DSF before it goes final in M6, even if we don't fully hook up the implementation by M6.

The issue is this. Right now when a cell editor is initialized in the variables (or expressions) view (VariableCellModifier.getValue()), the same code is used to initialize the cell editor (SyncVariableDataAccess.getFormattedValue() ultimately calling into FormattedValueDMData.getFormattedValue()) as is used to populate the value when not in edit mode. I think the API should allow for a different value to be used for editing.

Separating the formatted value from the "editable" value would allow implementations that have custom formatters for values to offer a prompt to the user that makes more sense for editing than the one displayed for just viewing the value.

JDT, for example, will display a String value like this:
"My String" (id=1011)
when not in edit mode, but will initialize the cell editor with this:
My String
for editing.

I propose we add this to IFormattedValues.FormattedValueDMData where the getFormattedValue() API already exists. Possibly an additional getEditableValue() call, unless some other place seems more appropriate.
Comment 1 Pawel Piech CLA 2010-03-10 12:30:52 EST
I like this idea.  Would it be enough to simply create a new format ID (.e.g. EDITABLE), and the UI would use this format, if available, to populate the editor?

I don't think we have to rush it for M6 because of the API freeze.  We can still make API changes beyond M6 we just need to go through a little more process.
Comment 2 David Dubrow CLA 2010-03-10 12:52:58 EST
(In reply to comment #1)
> I like this idea.  Would it be enough to simply create a new format ID (.e.g.
> EDITABLE), and the UI would use this format, if available, to populate the
> editor?

It seems that this is just a little less flexible than a first class API because it wouldn't allow for different editable values that respected the current format ID.

> I don't think we have to rush it for M6 because of the API freeze.  We can
> still make API changes beyond M6 we just need to go through a little more
> process.

Ok. I just wanted to make sure we got it in time for Helios. :)
Comment 3 Pawel Piech CLA 2010-03-10 13:49:48 EST
(In reply to comment #2)
> It seems that this is just a little less flexible than a first class API
> because it wouldn't allow for different editable values that respected the
> current format ID.

Good point.  It seems that I missed something though, did you propose a new API already?
Comment 4 David Dubrow CLA 2010-03-10 14:08:06 EST
(In reply to comment #3)
> (In reply to comment #2)
> > It seems that this is just a little less flexible than a first class API
> > because it wouldn't allow for different editable values that respected the
> > current format ID.
> 
> Good point.  It seems that I missed something though, did you propose a new API
> already?

I proposed adding a new method to IFormattedValues.FormattedValueDMData

getEditableValue()
Comment 5 Pawel Piech CLA 2010-03-10 16:58:25 EST
(In reply to comment #4)
> I proposed adding a new method to IFormattedValues.FormattedValueDMData
> 
> getEditableValue()
Ah, thank you that wasn't obvious to me.  In that case go for it ;-)
Comment 6 David Dubrow CLA 2010-03-13 10:01:16 EST
Committed to HEAD
Comment 7 David Dubrow CLA 2010-03-13 13:32:38 EST
Doug, I just committed this change this morning. Is it in time for M6?
Comment 8 Pawel Piech CLA 2010-03-15 11:43:55 EDT
David, thank you for the fix.  For future reference please attach the fix patch to the bug and request a review from one of the other committers as per our bug policy (http://wiki.eclipse.org/CDT/Bugs#Reviewing).

For this specific fix, I have a couple of requests:

1) Add an API backward compatible constructor for GetFormattedValueValueQuery.

2) For consistency, remove FormattedValueDMData.setEditableValue() and add a constructor which takes it as a parameter instead.

3) Make SyncVariableDataAccess.getValue() private since its redundant.
Comment 9 David Dubrow CLA 2010-03-15 12:30:15 EDT
Created attachment 162070 [details]
additional changes

(In reply to comment #8)
> David, thank you for the fix.  For future reference please attach the fix patch
> to the bug and request a review from one of the other committers as per our bug
> policy (http://wiki.eclipse.org/CDT/Bugs#Reviewing).

I was going to post a patch to this bugzilla, and then I thought I would miss the M6 deadline (which I think I may have missed anyway). Not trying to excuse myself, but I kept trying to work on this and was getting pulled away with other tasks. Sorry! :(

> 
> For this specific fix, I have a couple of requests:
> 
> 1) Add an API backward compatible constructor for GetFormattedValueValueQuery.

Ah, yes. It is also API.

> 
> 2) For consistency, remove FormattedValueDMData.setEditableValue() and add a
> constructor which takes it as a parameter instead.

I guess I was trying to allow for the editable value to be set after the object was created. I guess I can add the new constructor and leave the setter?

> 
> 3) Make SyncVariableDataAccess.getValue() private since its redundant.

No problem.
Comment 10 Pawel Piech CLA 2010-03-15 12:36:47 EDT
(In reply to comment #9)
> I was going to post a patch to this bugzilla, and then I thought I would miss
> the M6 deadline (which I think I may have missed anyway). Not trying to excuse
> myself, but I kept trying to work on this and was getting pulled away with
> other tasks. Sorry! :(
No problem, I just wanted to make sure you're aware of the process.

> I guess I was trying to allow for the editable value to be set after the object
> was created. I guess I can add the new constructor and leave the setter?
The down side of this is that it open the object to possible race conditions.  The DM data object is meant to be thread safe, so if you make it so it's not immutable, you'll also need to add synchronization.
Comment 11 David Dubrow CLA 2010-03-15 13:57:29 EDT
Created attachment 162089 [details]
new patch

(In reply to comment #10)
> The down side of this is that it open the object to possible race conditions. 
> The DM data object is meant to be thread safe, so if you make it so it's not
> immutable, you'll also need to add synchronization.

Ok. I;ll take out the setter. No sense adding more complexity to this, especially that I don't actually have a use-case that requires the setter. ;)

Let me know if I can commit this. I think I've addressed all your concerns. :)
Comment 12 Pawel Piech CLA 2010-03-15 14:42:00 EDT
(In reply to comment #11)
> Let me know if I can commit this. I think I've addressed all your concerns. :)

Looks good to me.  Thanks!