You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by prophe <au...@cargosoft.ru> on 2011/09/29 11:37:53 UTC

rowUpdated event

Hi! rowUpdated event fires when the data in row hasn't been updated. I open
row editor, and then close it without any modifications, but rowUpdated
event is fired. Any solution how to listen row data changes? I need to
manage state of my button (save) if row data before editor open are
different from the data after editor is close. Only in this case!

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3378807.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by prophe <au...@cargosoft.ru>.
Yes, I've done so! Thank you!

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3382248.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by Greg Brown <gk...@verizon.net>.
You could probably extend the default editor and override beginEdit() to create a copy of the item. Then in endEdit() you could perform an equality check on the previous and current versions of the item to see if the data actually changed.

But that seems like overkill. Is there any reason you can't simply rely on the update event?

On Sep 30, 2011, at 3:40 AM, prophe wrote:

> if the user presses Escape  - the editor won't call update() it's true. But
> when click outside of editor  the editor will call update() this is code of
> editor:
> 
>        @Override
>        public boolean mouseDown(Container container, Mouse.Button button,
> int x, int y) {
>            Display display = (Display)container;
>            Window window = (Window)display.getComponentAt(x, y);
> 
>            boolean consumed;
>            if (window != TableViewRowEditor.this
>                && (window == null || !isOwner(window))) {
>                endEdit(true);
>                consumed = (getEditEffect() != null);
>            } else {
>                consumed = false;
>            }
> 
>            return consumed;
>        }
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3381693.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: rowUpdated event

Posted by prophe <au...@cargosoft.ru>.
entEdit(true)

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3381695.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by prophe <au...@cargosoft.ru>.
if the user presses Escape  - the editor won't call update() it's true. But
when click outside of editor  the editor will call update() this is code of
editor:

        @Override
        public boolean mouseDown(Container container, Mouse.Button button,
int x, int y) {
            Display display = (Display)container;
            Window window = (Window)display.getComponentAt(x, y);

            boolean consumed;
            if (window != TableViewRowEditor.this
                && (window == null || !isOwner(window))) {
                endEdit(true);
                consumed = (getEditEffect() != null);
            } else {
                consumed = false;
            }

            return consumed;
        }

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3381693.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by Greg Brown <gk...@verizon.net>.
As I recall, the editor won't call update() on the list if the user presses Escape or otherwise cancels the edit. As a result, the update event won't be fired.

On Sep 29, 2011, at 9:46 AM, prophe wrote:

> But then how can I know is data has been changed after editor close? Or the
> row has the same data as before editor has been opened?
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3379298.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: rowUpdated event

Posted by prophe <au...@cargosoft.ru>.
But then how can I know is data has been changed after editor close? Or the
row has the same data as before editor has been opened?

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3379298.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by Greg Brown <gk...@verizon.net>.
The change event shouldn't be fired unless *something* has changed. So you shouldn't need to compare them (in other words, no change event = no change).

On Sep 29, 2011, at 9:17 AM, prophe wrote:

> But when I change item previous and current are equals = changed item. How
> can I compare them?
> Have I implemented  write listener?
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3379220.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: rowUpdated event

Posted by prophe <au...@cargosoft.ru>.
But when I change item previous and current are equals = changed item. How
can I compare them?
Have I implemented  write listener?

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3379220.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by Greg Brown <gk...@verizon.net>.
The item's properties may have changed even if the item itself did not. An updated event is still fired in this case.

On Sep 29, 2011, at 8:58 AM, prophe wrote:

> I try to listen list item:
> 
>        		tableDataListener = new  ListListener.Adapter() {
>        			
>        			@Override
>        			public void itemUpdated(List list, int index, Object
> previousItem) {
>        				tableViewRowChangeListeners.rowDataChanged(GridView.this,
> previousItem, index);
>        				System.out.println(previousItem);
>        			}
>        		};
> But previous (not changed) item always equals current(changed) item. What is
> wrong?
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3379169.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: rowUpdated event

Posted by prophe <au...@cargosoft.ru>.
I try to listen list item:

        		tableDataListener = new  ListListener.Adapter() {
        			
        			@Override
        			public void itemUpdated(List list, int index, Object
previousItem) {
        				tableViewRowChangeListeners.rowDataChanged(GridView.this,
previousItem, index);
        				System.out.println(previousItem);
        			}
        		};
But previous (not changed) item always equals current(changed) item. What is
wrong?

-----
Thank you!
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3379169.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: rowUpdated event

Posted by Greg Brown <gk...@verizon.net>.
You should be able to listen to the model data directly (i.e. listen for List change events).

On Sep 29, 2011, at 5:37 AM, prophe wrote:

> Hi! rowUpdated event fires when the data in row hasn't been updated. I open
> row editor, and then close it without any modifications, but rowUpdated
> event is fired. Any solution how to listen row data changes? I need to
> manage state of my button (save) if row data before editor open are
> different from the data after editor is close. Only in this case!
> 
> -----
> Thank you!
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/rowUpdated-event-tp3378807p3378807.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.