This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 205112 - OutlineView with editable combobox inline editor doesn't accept value unless "TAB" is pressed
Summary: OutlineView with editable combobox inline editor doesn't accept value unless ...
Status: REOPENED
Alias: None
Product: platform
Classification: Unclassified
Component: Outline&TreeTable (show other bugs)
Version: 7.0.1
Hardware: PC All
: P3 normal with 1 vote (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-14 19:01 UTC by gbivins
Modified: 2011-12-12 15:20 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
editable combobox in outline view (18.59 KB, application/zip)
2011-11-14 19:01 UTC, gbivins
Details
updated project which demonstrates issue/descrepancy in inplaceeditor javadocs (17.47 KB, application/x-zip-compressed)
2011-11-16 18:05 UTC, gbivins
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gbivins 2011-11-14 19:01:04 UTC
Created attachment 113200 [details]
editable combobox in outline view

If you use an editable combobox as an inplace editor in an outlineview,the combobox doesn't appear to "accept" the changes
unless the tab key is pressed. I tried debugging this but ran into some discrepancies in the documentation and
the tutorials.

For instance the javadocs 
(http://bits.netbeans.org/dev/javadoc/org-openide-explorer/org/openide/explorer/propertysheet/InplaceEditor.html)

for InplaceEditor state that:
"In no cases should an instance of InplaceEditor attempt to directly update the value of the represented property or property editor. If the property should be updated, ensure that getValue() will return the correct value, and fire the action command COMMAND_SUCCESS. Implementations should also not assume that because one of these events has been fired, that therefore the property editor has been updated with the new value. Components that display inplace editors are responsible for the timing of and policy for updates to the represented properties. Inplace editors merely display the contents of a property editor, provide a way for the user to edit that value, and notify the infrastructure when the user has made a change."

However all tutorials/examples that use an inplace editor, specifically the combobox edit the value directly. 

In any case, I thought there'd be some way to trigger a commit or issue that COMMAND_SUCCESS from the action listener attached to the combobox but I couldn't get it to work (most of that API is hidden in the EditableDisplayer class).

Am I missing something here? Seems like hitting the "enter" key (or selecting something from the combobox, should accept the value and issue "commit". Is that not the case?

I've attached a project that opens an OutlineView with a combobox editor in the "City" column. It demonstrates that manipulating the property in this column is not accepted unless the tab key is pressed.
Comment 1 Martin Entlicher 2011-11-16 14:43:08 UTC
I'm sorry, but I do not probably understand what this issue is really about.
The ComboBox is editable, therefore you see the cursor as long as it has the focus. Try to create a JComboBox component and you'll see it.
As soon as you pick some value, it's immediately propagated as a property change. I've verified that.
Comment 2 gbivins 2011-11-16 18:05:01 UTC
Created attachment 113270 [details]
updated project which demonstrates issue/descrepancy in inplaceeditor javadocs

Note that this example doesn't set the values on the underlying property as per the javadocs for the inplaceeditor.
Comment 3 gbivins 2011-11-16 18:08:03 UTC
Comment on attachment 113270 [details]
updated project which demonstrates issue/descrepancy in inplaceeditor javadocs

Correct. The bug is that there is a descrepancy in the inplaceeditor javadocs and the examples/tutorials on how to implement an inplaceeditor. 
According to the javadocs, an inplaceeditor should not set the values for the underlying property. I changed the example module to behave this way and the value is not accepted unless the tab button is pressed.
Comment 4 gbivins 2011-12-08 16:19:37 UTC
Martin, did you get a chance to reproduce the bug with the updated project I attached?
Comment 5 Geertjan Wielenga 2011-12-12 06:48:44 UTC
I am looking at your project right now. But I don't understand the problem. Can you explain the discrepancy between the docs you're referring to? And then also what the problem is with the sample you attached?
Comment 6 Geertjan Wielenga 2011-12-12 06:51:35 UTC
Does this help you:

http://forums.netbeans.org/post-79653.html
Comment 7 gbivins 2011-12-12 15:18:24 UTC
(In reply to comment #5)
> I am looking at your project right now. But I don't understand the problem. Can
> you explain the discrepancy between the docs you're referring to? And then also
> what the problem is with the sample you attached?

Basically, what is the proper way to update the value represented by the property?
The docs say that :

"In no cases should an instance of InplaceEditor attempt to directly update the value of the represented property or property editor. If the property should be updated, ensure that getValue() will return the correct value, and fire the action command COMMAND_SUCCESS. Implementations should also not assume that because one of these events has been fired, that therefore the property editor has been updated with the new value. Components that display inplace editors are responsible for the timing of and policy for updates to the represented properties. Inplace editors merely display the contents of a property editor, provide a way for the user to edit that value, and notify the infrastructure when the user has made a change."

This a about the fifth a paragraph down on the javadoc for the inplace editor.  The problem is, if I implement things as the javadocs say, the combobox never accepts the value and propagates changes because the COMMAND_SUCCESS action command isn't fired.

The current workaround is to do exactly what the javadocs say not to do, ie set the value of the underlying property directly.
Comment 8 gbivins 2011-12-12 15:20:38 UTC
This shows that we must set the value directly to get things to work
[code]
protected void processKeyEvent(KeyEvent e) { 
                if (e.getKeyCode() == 10 || e.getKeyCode() == 9) { 
                    try { 
                        myProperty.setValue(getText()); 
                    } catch (Exception ex) { 
                      
                    } 
                } 
                super.processKeyEvent(e); 
            } 
[/code]
(In reply to comment #6)
> Does this help you:
> 
> http://forums.netbeans.org/post-79653.html