Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Databinding]Binding map to computed value
[Databinding]Binding map to computed value [message #776609] Sun, 08 January 2012 22:32 Go to next message
Tankut Koray is currently offline Tankut KorayFriend
Messages: 49
Registered: July 2009
Member
Hi,

I am using ComputedValue to bind a textbox to a single computed value.

Now I am trying to bind a taleviewer and I want to bind a column to a computed value. I want it automatically updated when values that are used in calculation are updated. (like in computedvalue)

Should I override ComputedObservableMap and use it? Or is there another way to do it? Are there any examples of using ComputedObservableMap?

Thanks in advance,
Tankut
Re: [Databinding]Binding map to computed value [message #776787 is a reply to message #776609] Mon, 09 January 2012 09:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 08.01.12 23:32, schrieb Tankut Koray:
> Hi,
>
> I am using ComputedValue to bind a textbox to a single computed value.
>
> Now I am trying to bind a taleviewer and I want to bind a column to a
> computed value. I want it automatically updated when values that are
> used in calculation are updated. (like in computedvalue)
>
> Should I override ComputedObservableMap and use it? Or is there another
> way to do it? Are there any examples of using ComputedObservableMap?
> Thanks in advance,
> Tankut

You should not use an ComputedValue for this but better use an
ObservableMapCellLabelProvider and construct the text from multiple sources.

My databinding tutorial [1] containst an example (ProjectComittersPart)
where the text displayed in a column is made up of 2 values. The sources
are in the EMF-Git-Repo.

Tom

[1]http://tomsondev.bestsolution.at/2009/06/27/galileo-emf-databinding-part-5/
Re: [Databinding]Binding map to computed value [message #776798 is a reply to message #776787] Mon, 09 January 2012 09:38 Go to previous messageGo to next message
Tankut Koray is currently offline Tankut KorayFriend
Messages: 49
Registered: July 2009
Member
Hi Tom,

Using a observablemapcellprovider is what I am doing right now. But it is not updating its value when objects that I use to.generate the text are updated. But automatic update happened in computedvalue or computedlist usages in oother places.
Re: [Databinding]Binding map to computed value [message #776810 is a reply to message #776798] Mon, 09 January 2012 09:54 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

A computed value consits of 2 or more observed values. So why can't you
simply createn IObservableMap for both of them and then do the
calculation inside your CellLabelProvider method.

My understanding of your code is like this using sum as an example:


ComputedValue {
private IObservableValue a = EMFProperties.value("a").observe(o);
private IObservableValue b = EMFProperties.value("b").observe(o);

Object computeValue() {
return (Integer)a.getValue() + (Integer)b.getValue();
}
}

So for a viewer you'd create also those two observables:

IObservableMap[] map = new IObservableMap[] {
EMFProperties.value("a").observeDetail(set), // v1 in col 0
EMFProperties.value("b").observeDetail(set), // v2 in col 0
....
}

ObservableMapCellLabelProvider(map) {
update(ViewerCell cell) {
if( cell.getIndex() == 0 ) {
cell.setText( (Integer)attributeMaps[0].get(cell.getElement()) +
(Integer)attributeMaps[1].get(cell.getElement())
);
}
...

}
}



Tom

Am 09.01.12 10:38, schrieb Tankut Koray:
> Hi Tom,
>
> Using a observablemapcellprovider is what I am doing right now. But it
> is not updating its value when objects that I use to.generate the text
> are updated. But automatic update happened in computedvalue or
> computedlist usages in oother places.
Previous Topic:Creating generic data types
Next Topic:[EMF/OAD/BIRT] Odd behavior using OCL to interrogate an EMF model
Goto Forum:
  


Current Time: Thu Apr 25 09:12:04 GMT 2024

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

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

Back to the top