You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by lello <rb...@gmail.com> on 2010/12/01 09:05:22 UTC

Re: TableView selectedRowChanged

Thanks again for the help.
However, when I subclass the row editor:

public class myRowEditor extends TableViewRowEditor {

	@Override
	public boolean keyPressed(int keyCode, Keyboard.KeyLocation kl) {
		boolean consumed = false;
		System.out.println("key pressed");
		if (keyCode == Keyboard.KeyCode.KEYPAD_DOWN || keyCode ==
Keyboard.KeyCode.KEYPAD_UP) {
			close(true);
			consumed = true;
		}
		return consumed;
	}
}

and change the bxml accordingly:

<rowEditor>
  <mycode:myRowEditor>
...
</mycode:myRowEditor>
</rowEditor>

I get the following serialization error:
org.apache.pivot.serialization.SerializationException: Property elements
cannot have a namespace prefix.
        at
org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:767)
        at
org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:435)
        at
org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:614)
        at
org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:568)
        at
org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:534)

My namespace is properly added to the xml file, so I don't understand where
is the problem.

-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p1997629.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by Greg Brown <gk...@verizon.net>.
OK, that's good.  :-)

On Dec 2, 2010, at 1:32 PM, lello wrote:

> 
> Ops, sorry Greg, I forgot the transition in the bxml file.
> If I turn if off then it works.
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2007532.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Ops, sorry Greg, I forgot the transition in the bxml file.
If I turn if off then it works.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2007532.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by Greg Brown <gk...@verizon.net>.
Did you turn off the transition?

On Dec 2, 2010, at 11:45 AM, lello wrote:

> 
> Just tried the new version. My code doesn't work anymore.
> Even if I call endEdit(true) a subsequent call to isEditing() returns true
> again, and I get an error.
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2006935.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Just tried the new version. My code doesn't work anymore.
Even if I call endEdit(true) a subsequent call to isEditing() returns true
again, and I get an error.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2006935.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by Greg Brown <gk...@verizon.net>.
I just refactored the code a bit. After giving it some thought, I think that the beginEdit(), endEdit(), and isEditing() model is cleaner. Without endEdit() and isEditing(), a caller would have no way to programmatically perform these operations without casting. This means that the caller would have to know specifically which editor is in use, which isn't good.

FYI, I reverted the changes that allow TableViewRowEditor to gracefully handle the case when it is already editing and is asked to begin editing another row. I'd like to think a little more about the best way to handle this within the new API. Would you mind updating your code to work with the latest API and let me know what kind of behavior you see? That would be very helpful.

Thanks,
Greg

On Dec 2, 2010, at 1:33 AM, lello wrote:

> 
> Yes, that's the behaviour I mean. I tried you suggestion but it doesn't seem
> to give the expected result.
> 
> I am starting to think that the idea of the immediate flag suggested by Greg
> in the other thread would be a better solution for the user.
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2004375.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Yes, that's the behaviour I mean. I tried you suggestion but it doesn't seem
to give the expected result.

I am starting to think that the idea of the immediate flag suggested by Greg
in the other thread would be a better solution for the user.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2004375.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by Greg Brown <gk...@verizon.net>.
We consume that event intentionally so that it doesn't reach the table view.

I'm still thinking through this - I don't really love the current design and I'm thinking that maybe it would be better to have beginEdit(), endEdit(), and isEditing(). Not sure yet.

G

On Dec 1, 2010, at 5:06 PM, Chris Bartlett wrote:

> Do you mean that you have to wait for the row editor slide effect to finish before you can select another row?
> 
> If so, try commenting out line 97 of org.apache.pivot.wtk.content TableViewRowEditor 
>      consumed = true;
> (in the ContainerMouseListener#mouseDown() method)
> 
> Does that give you the behaviour you want?
> 
> Chris
> 
> 
> On 2 December 2010 03:57, lello <rb...@gmail.com> wrote:
> 
> Greg, just checked you update.
> It works fine for me without any effect.
> With an effect on (horizontal_slide) it has one issue. When I first select a
> row with the mouse then the I can see the slide effect. However, when I
> double click (or just single click) with the mouse on a new row, the
> previous editor is disabled but no new editor shows up, and I have to wait a
> bit then click again, then the roweditor is there.
> 
> For my application it works, as I am not using the effect anymore.
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2002063.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
> 


Re: TableView selectedRowChanged

Posted by Chris Bartlett <cb...@gmail.com>.
Do you mean that you have to wait for the row editor slide effect to finish
before you can select another row?

If so, try commenting out line 97 of org.apache.pivot.wtk.content
TableViewRowEditor
     consumed = true;
(in the ContainerMouseListener#mouseDown() method)

Does that give you the behaviour you want?

Chris


On 2 December 2010 03:57, lello <rb...@gmail.com> wrote:

>
> Greg, just checked you update.
> It works fine for me without any effect.
> With an effect on (horizontal_slide) it has one issue. When I first select
> a
> row with the mouse then the I can see the slide effect. However, when I
> double click (or just single click) with the mouse on a new row, the
> previous editor is disabled but no new editor shows up, and I have to wait
> a
> bit then click again, then the roweditor is there.
>
> For my application it works, as I am not using the effect anymore.
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2002063.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Greg, just checked you update.
It works fine for me without any effect.
With an effect on (horizontal_slide) it has one issue. When I first select a
row with the mouse then the I can see the slide effect. However, when I
double click (or just single click) with the mouse on a new row, the
previous editor is disabled but no new editor shows up, and I have to wait a
bit then click again, then the roweditor is there.

For my application it works, as I am not using the effect anymore.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2002063.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by Greg Brown <gk...@verizon.net>.
Lello,
I just checked in an update that should allow your app to work as you described. Please let me know if you run into any additional issues.
G

On Dec 1, 2010, at 1:09 PM, Greg Brown wrote:

> Since you have confirmed that disabling the transition resolves the issue, I don't think the sample code will be necessary. I'll try to put out a fix for your issue this afternoon.
> 
> On Dec 1, 2010, at 12:46 PM, Chris Bartlett wrote:
> 
>> Greg started another thread titled 'Editor transitions' which is discusses how to address this issue.  Please have a look at that (and feel free to contribute).
>> It is probably best to wait and see what comes of that before taking the time to create an example.  It looks like the RowEditor API might change again and I don't want to make extra work for you.
>> 
>> Chris
>> 
>> On 2 December 2010 00:33, lello <rb...@gmail.com> wrote:
>> 
>> Before I try to write some whort example I can confirm you that the error is
>> there only when I use a transition effect.
>> Indeed, when I implement keyPressed in my rowEditor even if I send a close()
>> command the editing is still taking place, I can check this using
>> isEditing() which returns true even after a close(). When there is no
>> transition effect isEditing() returns false after close(), and theJust to
>> let  code works.
>> (In any case, the code posted above is not correct, I cannot call
>> getTableView() after close(), what I do is just to select the row and then
>> selectedRowChanged() close the editor.
>> --
>> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2000611.html
>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>> 
> 


Re: TableView selectedRowChanged

Posted by Greg Brown <gk...@verizon.net>.
Since you have confirmed that disabling the transition resolves the issue, I don't think the sample code will be necessary. I'll try to put out a fix for your issue this afternoon.

On Dec 1, 2010, at 12:46 PM, Chris Bartlett wrote:

> Greg started another thread titled 'Editor transitions' which is discusses how to address this issue.  Please have a look at that (and feel free to contribute).
> It is probably best to wait and see what comes of that before taking the time to create an example.  It looks like the RowEditor API might change again and I don't want to make extra work for you.
> 
> Chris
> 
> On 2 December 2010 00:33, lello <rb...@gmail.com> wrote:
> 
> Before I try to write some whort example I can confirm you that the error is
> there only when I use a transition effect.
> Indeed, when I implement keyPressed in my rowEditor even if I send a close()
> command the editing is still taking place, I can check this using
> isEditing() which returns true even after a close(). When there is no
> transition effect isEditing() returns false after close(), and theJust to
> let  code works.
> (In any case, the code posted above is not correct, I cannot call
> getTableView() after close(), what I do is just to select the row and then
> selectedRowChanged() close the editor.
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2000611.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
> 


Re: TableView selectedRowChanged

Posted by Chris Bartlett <cb...@gmail.com>.
Greg started another thread titled 'Editor transitions' which is discusses
how to address this issue.  Please have a look at that (and feel free to
contribute).
It is probably best to wait and see what comes of that before taking the
time to create an example.  It looks like the RowEditor API might change
again and I don't want to make extra work for you.

Chris

On 2 December 2010 00:33, lello <rb...@gmail.com> wrote:

>
> Before I try to write some whort example I can confirm you that the error
> is
> there only when I use a transition effect.
> Indeed, when I implement keyPressed in my rowEditor even if I send a
> close()
> command the editing is still taking place, I can check this using
> isEditing() which returns true even after a close(). When there is no
> transition effect isEditing() returns false after close(), and theJust to
> let  code works.
> (In any case, the code posted above is not correct, I cannot call
> getTableView() after close(), what I do is just to select the row and then
> selectedRowChanged() close the editor.
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2000611.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Before I try to write some whort example I can confirm you that the error is
there only when I use a transition effect.
Indeed, when I implement keyPressed in my rowEditor even if I send a close()
command the editing is still taking place, I can check this using
isEditing() which returns true even after a close(). When there is no
transition effect isEditing() returns false after close(), and theJust to
let  code works.
(In any case, the code posted above is not correct, I cannot call
getTableView() after close(), what I do is just to select the row and then
selectedRowChanged() close the editor.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p2000611.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by Chris Bartlett <cb...@gmail.com>.
The stack trace suggests that the row editor is still being launched (via
the TableViewRowEditor.beginEdit() method) before the row editor window has
removed the ContainerMouseListener which is added in
TableViewRowEditor.open().

Are you using edit effects?  If so, do you still see the issue if you
disable the effects?  (My guess is it might still occur, but much less
frequently)

Can you please try to post a simple, complete example demonstrating the
problem? (Please refer to http://sscce.org for some useful guidelines.)
Just a simple GUI such as a Window containing a TableView and any relevant
custom code.  Feel free to base your example on any example or test code
from Pivot's own codebase.

Chris

On 1 December 2010 15:50, lello <rb...@gmail.com> wrote:

>
> Well...kind of working, I needed to press twice the down key, so I rewrote
> the keyPressed as
>
>
> public class MyRowEditor extends TableViewRowEditor {
>
>        @Override
>        public boolean keyPressed(int keyCode, Keyboard.KeyLocation kl) {
>                boolean consumed = false;
>                System.out.println("key pressed");
>                //if (keyCode == Keyboard.KeyCode.KEYPAD_DOWN || keyCode ==
> Keyboard.KeyCode.KEYPAD_UP) {
>                 if (keyCode == Keyboard.KeyCode.DOWN) {
>                        System.out.println("Down pressed");
>                        close(true);
>                        consumed = true;
>                        int index = getTableView().getSelectedIndex();
>                        getTableView().setSelectedIndex(index+1);
>                } else if (keyCode == Keyboard.KeyCode.UP) {
>                        System.out.println("UP pressed");
>                        close(true);
>                        consumed = true;
>                        int index = getTableView().getSelectedIndex();
>                        getTableView().setSelectedIndex(index-1);
>                }
>                return consumed;
>        }
> }
>
> I have also overridden the selectedRowChanged() method to check for
> isEditing and endEdit(), however, I still get the initial error:
>
> Duplicate listener
> org.apache.pivot.wtk.content.TableViewRowEditor$1@10ade7e
> added to org.apache.pivot.wtk.Container$ContainerMouseListenerList@956254
> 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:301)
>         at org.apache.pivot.wtk.Window.open(Window.java:585)
>        at
>
> org.apache.pivot.wtk.content.TableViewRowEditor.beginEdit(TableViewRowEditor.java:182)
>
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p1997773.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Well...kind of working, I needed to press twice the down key, so I rewrote
the keyPressed as


public class MyRowEditor extends TableViewRowEditor {

	@Override
	public boolean keyPressed(int keyCode, Keyboard.KeyLocation kl) {
		boolean consumed = false;
		System.out.println("key pressed");
		//if (keyCode == Keyboard.KeyCode.KEYPAD_DOWN || keyCode ==
Keyboard.KeyCode.KEYPAD_UP) {
		if (keyCode == Keyboard.KeyCode.DOWN) {
			System.out.println("Down pressed");
			close(true);
			consumed = true;
			int index = getTableView().getSelectedIndex();
			getTableView().setSelectedIndex(index+1);
		} else if (keyCode == Keyboard.KeyCode.UP) {
			System.out.println("UP pressed");
			close(true);
			consumed = true;
			int index = getTableView().getSelectedIndex();
			getTableView().setSelectedIndex(index-1);
		}
		return consumed;
	}
}

I have also overridden the selectedRowChanged() method to check for
isEditing and endEdit(), however, I still get the initial error: 

Duplicate listener org.apache.pivot.wtk.content.TableViewRowEditor$1@10ade7e
added to org.apache.pivot.wtk.Container$ContainerMouseListenerList@956254
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:301)
        at org.apache.pivot.wtk.Window.open(Window.java:585)
        at
org.apache.pivot.wtk.content.TableViewRowEditor.beginEdit(TableViewRowEditor.java:182)


-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p1997773.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: TableView selectedRowChanged

Posted by lello <rb...@gmail.com>.
Never mind, I realized the problem was with the capital letter, I renamed
myRowEditor to MyRowEditor and now it works.
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/TableView-selectedRowChanged-tp1992938p1997698.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.