Lello-
I have renamed edit() to beginEdit() and added endEdit() and isEditing() 
methods to the editor interfaces. In your listener, before calling beginEdit(), 
check for isEditing() - if it returns true, you can call endEdit(true) to 
cancel the edit. Let me know if this does not resolve the problem you are 
seeing.
G

On Nov 30, 2010, at 11:14 AM, Greg Brown wrote:

> I'm not surprised that you ran into some issues, but I do think that the new 
> interfaces will be easier to work with in the long run. I actually considered 
> adding isEditing() and cancelEdit() when I first updated the interfaces, but 
> at the time they didn't seem necessary. Sounds like they are, though - I'll 
> try to get them in sometime later today.
> 
> 
> On Nov 30, 2010, at 11:07 AM, Chris Bartlett wrote:
> 
>> Greg,
>> 
>> I haven't fully taken in the recent changes, so perhaps it is a little early 
>> for me to comment, but my gut reaction is that the inclusion of 2 methods 
>> you mention would make things easier.  I ended up adding similar 
>> functionality to meet my requirements, so others may well need them too.
>> 
>> When I first synced with svn and picked up the row editor changes, it took 
>> quite a bit of hacking around to achieve what i had previously done with the 
>> old interface & listeners.  
>> 
>> My code was not in a great state as it was my first attempt at combining 
>> non-standard row editing and data binding and was in the middle of a partial 
>> refactoring that was interrupted for 7 weeks.  This may very well be the 
>> reason I struggled, and have nothing to do with the row editor changes.
>> 
>> I plan go back to that code in the next few days to clean it up and try to 
>> identify any issues or discrepancies between the new & old row editing 
>> functionality.
>> 
>> 
>> Chris
>> 
>> On 30 November 2010 22:49, Greg Brown <[email protected]> wrote:
>> Sounds about right. We can probably fix this by restoring the boolean 
>> isEditing() method to the editor interfaces. We might also need to add an 
>> endEdit() method that takes a boolean (representing whether the operation 
>> was cancelled or not). In that case, we might want to rename edit() to 
>> beginEdit().
>> 
>> On Nov 30, 2010, at 10:41 AM, Chris Bartlett wrote:
>> 
>>> Firstly, I must state that I have only briefly examined the recent row 
>>> editing changes, so apologies if any of the below text is inaccurate.
>>> 
>>> 
>>> A quick look suggests that the problem is due to the row editor being open 
>>> when another call to RowEditor#edit(TableView, int, int) is made.
>>> That attempts to open the TableViewRowEditor and add a 
>>> ContainerMouseListener, but one is already there.
>>> The pre-existing ContainerMouseListeners would normally be removed in the 
>>> TableViewRowEditor#close(boolean) method.
>>> 
>>> I imagine that you are more likely to see this problem if you are using an 
>>> edit effect as this will prolong the time taken for the row editor window 
>>> to close.
>>> 
>>> I assume that you are using the provided 
>>> org.apache.pivot.wtk.content.TableViewRowEditor class for your RowEditor? 
>>> This extends Window, so you if you have a reference to it, you should be 
>>> able to call Window#isOpen() to first check to see if the editor is still 
>>> open, and avoid opening another one.
>>> You could also explicitly call the Window#close() or Window#close(boolean)  
>>> methods and wait for the window to close before opening the row editor on 
>>> another row.
>>> You may find it useful to register a WindowStateListener on the 
>>> TableViewRowEditor to better track and control window closing.
>>> 
>>> 
>>> When trying to replicate this with the (unchanged) 
>>> org.apache.pivot.tests.TableViewTest2 class from trunk, I was also able to 
>>> produce another exception by rapidly left-clicking in the TableView.
>>> 
>>> java.lang.IndexOutOfBoundsException: index -1 out of bounds.
>>> at 
>>> org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
>>> at org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
>>> at org.apache.pivot.wtk.TablePane$Row.get(TablePane.java:263)
>>> at 
>>> org.apache.pivot.wtk.content.TableViewRowEditor$3.selectedIndexChanged(TableViewRowEditor.java:134)
>>> at 
>>> org.apache.pivot.wtk.CardPane$CardPaneListenerList.selectedIndexChanged(CardPane.java:52)
>>> at org.apache.pivot.wtk.CardPane.setSelectedIndex(CardPane.java:93)
>>> at 
>>> org.apache.pivot.wtk.skin.CardPaneSkin$1.transitionCompleted(CardPaneSkin.java:717)
>>> at org.apache.pivot.wtk.effects.Transition$1.run(Transition.java:52)
>>> at 
>>> org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1474)
>>> at java.awt.event.InvocationEvent.dispatch(Unknown Source)
>>> at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>>> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>>> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>> at java.awt.EventDispatchThread.run(Unknown Source)
>>> 
>>> 
>>> Regards,
>>> 
>>> Chris
>>> 
>>> On 30 November 2010 21:33, lello <[email protected]> wrote:
>>> 
>>> Hi all,
>>> 
>>> I have been trying to implement a tableview in which the row editor is
>>> called every time a row is selected (no need for a double click).
>>> The code I used is the following:
>>> 
>>> myTableView.getTableViewSelectionListeners().add(new
>>> TableViewSelectionListener.Adapter() {
>>>                        @Override
>>>                        public void selectedRowChanged(TableView tv, Object 
>>> o) {
>>>                                int row = tv.getSelectedIndex();
>>>                                tv.getRowEditor().edit(tv, row, 0);
>>>                        }
>>> 
>>>                }
>>>                );
>>> 
>>> The code seems to work. Indeed the row editor is called when I move with the
>>> cursor on the row.
>>> However, when I move "too fast", i get the following error:
>>> 
>>> Duplicate listener org.apache.pivot.wtk.content.tableviewrowedito...@d2f5f1
>>> added to org.apache.pivot.wtk.container$containermouselistenerl...@10c276
>>> java.lang.IllegalArgumentException: Component already has a parent.
>>>        at org.apache.pivot.wtk.TablePane$Row.insert(TablePane.java:199)
>>>        at org.apache.pivot.wtk.TablePane$Row.add(TablePane.java:187)
>>>        at
>>> org.apache.pivot.wtk.content.TableViewRowEditor.open(TableViewRowEditor.java:291)
>>>        at org.apache.pivot.wtk.Window.open(Window.java:585)
>>>        at
>>> org.apache.pivot.wtk.content.TableViewRowEditor.edit(TableViewRowEditor.java:182)
>>> 
>>> Any help is appreciated,
>>> Lello
>>> --
>>> View this message in context: 
>>> http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p1992938.html
>>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>>> 
>> 
>> 
> 

Reply via email to