Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » TreeTableRidget: Bind model to modifiable value
TreeTableRidget: Bind model to modifiable value [message #538670] Tue, 08 June 2010 11:40 Go to next message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
Hi,

i need to bind a TreeTableRidget to a global modifiable value. So far changes on that value doesn't force a change in the TreeTable automatically. Only if reassign the binding after the value has changed, the TreeTable displays the new value.

Isn't there a way to bind the TreeTableRidget to an modifiable value like e.g. ITableRidget.bindToModel(IObservableList, ...)?

thanks, matthias
Re: TreeTableRidget: Bind model to modifiable value [message #538683 is a reply to message #538670] Tue, 08 June 2010 12:14 Go to previous messageGo to next message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
Am 08.06.10 13:40, schrieb Matthias:
> Hi,
>
> i need to bind a TreeTableRidget to a global modifiable value. So far
> changes on that value doesn't force a change in the TreeTable
> automatically. Only if reassign the binding after the value has changed,
> the TreeTable displays the new value.
> Isn't there a way to bind the TreeTableRidget to an modifiable value
> like e.g. ITableRidget.bindToModel(IObservableList, ...)?
>
> thanks, matthias
>
In general in Riena changes in the model are only promoted to the widget either when you bind or by invoking the method
updateFromModel on the ridget. Its the same for all ridgets and its also true for the TreeTableRidget.

So when you finished updating the model, call updateFromModel on the ridget and that should be it.

christian
Re: TreeTableRidget: Bind model to modifiable value [message #538707 is a reply to message #538683] Tue, 08 June 2010 13:11 Go to previous messageGo to next message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
then i did something wrong with the binding:
input = createInput();
tree.bindToModel(input, MyTreeNode.class, MyTreeNode.PROPERTY_CHILDREN, MyTreeNode.PROPERTY_PARENT, columnPropertyNames, columnHeaders);


The thing is that createInput() creates a new array of TreeNodes out of my model structure. And because this new array has another id, it can't be bound. Am i right?
Re: TreeTableRidget: Bind model to modifiable value [message #538877 is a reply to message #538707] Tue, 08 June 2010 21:01 Go to previous messageGo to next message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Matthias,

I don't really understand your question... I think it would be best to post a standalone snippet showing your problem. Or at least an exception or error message.

Thanks,
Elias.


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Re: TreeTableRidget: Bind model to modifiable value [message #538935 is a reply to message #538877] Wed, 09 June 2010 07:15 Go to previous messageGo to next message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
ok, i extended the SnippetTreeTableRidget001

with the function
private WordNode[] createTreeInput2() {
	WordNode root = new WordNode("Words");
	WordNode aTowns = new WordNode(root, "Z");
	new WordNode(aTowns, "Zurich"); //$NON-NLS-1$
	return new WordNode[] { root };
}

and the possibility to update the model
Button button = new Button(shell, SWT.PUSH);
button.setText("Update Value");
IActionRidget actionRidget = (IActionRidget) SwtRidgetFactory.createRidget(button);
actionRidget.addListener(new IActionListener() {
	public void callback() {
		roots = createTreeInput2();
	}
});


If i press the button, the TableTree doesn't change, even when i call updateFromModel() manually.
In my understanding it doesn't work since the model isn't modified but recreated.

I don't know how to update the model (Object[]) without recreating it.

I hope that was clear Wink
Re: TreeTableRidget: Bind model to modifiable value [message #539663 is a reply to message #538935] Fri, 11 June 2010 18:16 Go to previous messageGo to next message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Matthias,

sorry, you can't to that this way... The ridget does not keep the array reference (bad style - breaks encapsulation) only the values in the array. So changing the array after you invoke bindToModel(...) has no effect.

You can either invoke r.bindToModel(...); r.updateFromModel() or better:

1. Invoke ridget.setRootsVisible(false)
2. The root you bind to should be a dummy node that returns the real roots as it's children
3. Change the values returned by the getChildren method of the root >> children are updated. No re-binding or update needed.

Hope this helps. If you need a snippet let me know.

Elias.


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Re: TreeTableRidget: Bind model to modifiable value [message #539952 is a reply to message #539663] Mon, 14 June 2010 11:40 Go to previous message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
Meanwhile i came to the same solution. I work with ExtendedTreeNodes which holds a reference to my value object. In a PropertyChangeListener i call:

public void propertyChange(PropertyChangeEvent evt) {
		updateRoot((ExtendedTreeNode) input[0]);
		tree.updateFromModel();
}

private void updateRoot(ExtendedTreeNode rootNode){
		MyVal mv = ValueManager.getInstance().getValue();
		rootNode.setReference(mv);
}

this works, thanks
Re: TreeTableRidget: Bind model to modifiable value [message #585739 is a reply to message #538683] Tue, 08 June 2010 13:11 Go to previous message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
then i did something wrong with the binding:

input = createInput();
tree.bindToModel(input, MyTreeNode.class, MyTreeNode.PROPERTY_CHILDREN, MyTreeNode.PROPERTY_PARENT, columnPropertyNames, columnHeaders);


The thing is that createInput() creates a new array of TreeNodes out of my model structure. And because this new array has another id, it can't be bound. Am i right?
Re: TreeTableRidget: Bind model to modifiable value [message #585745 is a reply to message #538707] Tue, 08 June 2010 21:01 Go to previous message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Matthias,

I don't really understand your question... I think it would be best to post a standalone snippet showing your problem. Or at least an exception or error message.

Thanks,
Elias.
--
Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Re: TreeTableRidget: Bind model to modifiable value [message #585753 is a reply to message #585745] Wed, 09 June 2010 07:15 Go to previous message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
ok, i extended the http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTreeTableRidget001.java?root=RT_Project&am p;view=co

with the function

private WordNode[] createTreeInput2() {
WordNode root = new WordNode("Words");
WordNode aTowns = new WordNode(root, "Z");
new WordNode(aTowns, "Zurich"); //$NON-NLS-1$
return new WordNode[] { root };
}

and the possibility to update the model

Button button = new Button(shell, SWT.PUSH);
button.setText("Update Value");
IActionRidget actionRidget = (IActionRidget) SwtRidgetFactory.createRidget(button);
actionRidget.addListener(new IActionListener() {
public void callback() {
roots = createTreeInput2();
}
});


If i press the button, the TableTree doesn't change, even when i call updateFromModel() manually.
In my understanding it doesn't work since the model isn't modified but recreated.

I don't know how to update the model (Object[]) without recreating it.

I hope that was clear ;)
Re: TreeTableRidget: Bind model to modifiable value [message #585808 is a reply to message #585753] Fri, 11 June 2010 18:16 Go to previous message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 26
Registered: July 2009
Junior Member
Hi Matthias,

sorry, you can't to that this way... The ridget does not keep the array reference (bad style - breaks encapsulation) only the values in the array. So changing the array after you invoke bindToModel(...) has no effect.

You can either invoke r.bindToModel(...); r.updateFromModel() or better:

1. Invoke ridget.setRootsVisible(false)
2. The root you bind to should be a dummy node that returns the real roots as it's children
3. Change the values returned by the getChildren method of the root >> children are updated. No re-binding or update needed.

Hope this helps. If you need a snippet let me know.

Elias.
--
Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis


Elias Volanakis | http://eclipsesource.com
elias (AT) eclipsesource.com | @evolanakis
Re: TreeTableRidget: Bind model to modifiable value [message #585835 is a reply to message #585808] Mon, 14 June 2010 11:40 Go to previous message
Matthias is currently offline MatthiasFriend
Messages: 52
Registered: September 2009
Member
Meanwhile i came to the same solution. I work with ExtendedTreeNodes which holds a reference to my value object. In a PropertyChangeListener i call:


public void propertyChange(PropertyChangeEvent evt) {
updateRoot((ExtendedTreeNode) input[0]);
tree.updateFromModel();
}

private void updateRoot(ExtendedTreeNode rootNode){
MyVal mv = ValueManager.getInstance().getValue();
rootNode.setReference(mv);
}

this works, thanks
Previous Topic:Data Communication failes - sometimes
Next Topic:Possible problem on MacOSX Cocoa
Goto Forum:
  


Current Time: Tue Mar 19 14:02:12 GMT 2024

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

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

Back to the top