Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Tableviewer & IObservable
Tableviewer & IObservable [message #695343] Mon, 11 July 2011 14:34 Go to next message
Markus Stutz is currently offline Markus Stutz
Messages: 22
Registered: September 2010
Location: Switzerland
Junior Member
Hi all

In my Application I use a TableViewer which should be updated if I edit something inside of the table.

How in this sample: (My code is realy based on these sample)

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.java?view=markup

But now, if I edit something inside the table will be the value saved in my object, but if I go out of the editing part will be no update on the table.

Is there one important thing which I have forget to implement?


Thank you and cheers,
Markus


Cheers,
Markus

[Updated on: Mon, 11 July 2011 14:34]

Report message to a moderator

Re: Tableviewer & IObservable [message #696261 is a reply to message #695343] Wed, 13 July 2011 15:08 Go to previous message
Matthew Hall is currently offline Matthew Hall
Messages: 368
Registered: July 2009
Senior Member
In order for changes to your bean to show up, you must be implementing
the JavaBean specification for bound properties:

public class Person {
private String name;

public String getName() { return name; }

public void setName(String name) {
propertySupport.firePropertyChange("name",
this.name, // old value
this.name = name); // new value
}

// what follows is boilerplate to make your class conform to JavaBean
// specification. To keep it simple you can put this in a common
// superclass and have your beans extend from that.

private PropertyChangeSupport propertySupport =
new PropertyChangeSupport(this);

public void addPropertyChangeListener(
PropertyChangeListener listener) {
propertySupport.addPropertyChangeListener(listener);
}

public void removePropertyChangeListener(
PropertyChangeListener listener) {
propertySupport.removePropertyChangeListener(listener);
}

public void addPropertyChangeListener(
String name, PropertyChangeListener listener) {
propertySupport.addPropertyChangeListener(name, listener);
}

public void removePropertyChangeListener(
String name, PropertyChangeListener listener) {
propertySupport.removePropertyChangeListener(name, listener);
}
}

Note also that you have to use BeansObservables/BeanProperties to
observe these. PojoObservables/PojoProperties assume you are not
implementing the JavaBean specification, and will not try to listen for
change notifications.

Matthew

On 07/11/2011 08:34 AM, forums-noreply@eclipse.org wrote:
> Hi all
>
> In my Application I use a TableViewer which should be updated if I edit
> something inside of the table.
> How in this sample: (My code is realy based on these sample)
>
> http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.java?view=markup
>
>
> But now, if I edit something inside the table will be the value saved in
> my object, but if I go out of the editing part will be no update on the
> table.
> Is there one important thing which I have forget to implement?
Previous Topic:where to get snippets for WindowManager?
Next Topic:Resizing toolbar buttons in a view.
Goto Forum:
  


Current Time: Wed Sep 17 15:45:33 GMT 2014

Powered by FUDForum. Page generated in 0.05353 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software