Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Extend ObservableMapCellLabelProvider - Documentation?
Extend ObservableMapCellLabelProvider - Documentation? [message #4638] Wed, 13 May 2009 12:19 Go to next message
Lars Bischoff is currently offline Lars BischoffFriend
Messages: 13
Registered: July 2009
Junior Member
Hello,

I successfully bound my datamodel to my UI (table) and vice versa,
according to the following snippet:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.e xamples.databinding/src/org/eclipse/jface/examples/databindi ng/snippets/Snippet032TableViewerColumnEditing.java?view=co

My model is backed by an array that consists of Row-objects, whereas
each Row-object consists of several String- and int-attributes,
according to the table's columns. The problem is now that if such an
int-attribute is empty, the UI displays a 0 instead of nothing, since 0
is the default value.
For this purpose I'd like to extend ObservableMapCellLabelProvider and
override the method(s) that are responsible for this. For a "usual"
ColumnLabelProvider it would look similar to this:

----- snip -----

@Override
public String getText(Object element) {
Row row = (Row) element;
switch(columnIndex) {
case 0:
if(row.getColumn(0).getValue() == 0)
return "";
}
}

----- snap -----

Unfortunately I am not able to find any documentation about the class
ObservableMapCellLabelProvider to ascertain which methods need to be
overridden.

Best regards,
Lars
Re: Extend ObservableMapCellLabelProvider - Documentation? [message #4915 is a reply to message #4638] Thu, 14 May 2009 08:31 Go to previous messageGo to next message
Lars Bischoff is currently offline Lars BischoffFriend
Messages: 13
Registered: July 2009
Junior Member
Hello,

I figured it out myself now!
I browsed the Sources of Eclipse and noticed that i need a mix made of
50% ObservableMapCellLabelProvider and 50% ColumnLabelProvider.
Both have the same superclass, CellLabelProvider, but
ColumnLabelProvider additionally implements some interfaces.
For this purpose I ObservableMapCellLabelProvider and implemented the
interfaces that are implemented by ColumnLabelProvider.
It looks like the following now:

public class MHRObservableMapCellLabelProvider extends
ObservableMapCellLabelProvider implements IFontProvider,
IColorProvider, ILabelProvider {
..
..
..

}

Maybe this is helpful for someone else! :-)

HTH,
Lars



Lars Bischoff schrieb:
> Hello,
>
> I successfully bound my datamodel to my UI (table) and vice versa,
> according to the following snippet:
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.e xamples.databinding/src/org/eclipse/jface/examples/databindi ng/snippets/Snippet032TableViewerColumnEditing.java?view=co
>
>
> My model is backed by an array that consists of Row-objects, whereas
> each Row-object consists of several String- and int-attributes,
> according to the table's columns. The problem is now that if such an
> int-attribute is empty, the UI displays a 0 instead of nothing, since 0
> is the default value.
> For this purpose I'd like to extend ObservableMapCellLabelProvider and
> override the method(s) that are responsible for this. For a "usual"
> ColumnLabelProvider it would look similar to this:
>
> ----- snip -----
>
> @Override
> public String getText(Object element) {
> Row row = (Row) element;
> switch(columnIndex) {
> case 0:
> if(row.getColumn(0).getValue() == 0)
> return "";
> }
> }
>
> ----- snap -----
>
> Unfortunately I am not able to find any documentation about the class
> ObservableMapCellLabelProvider to ascertain which methods need to be
> overridden.
>
> Best regards,
> Lars
Re: Extend ObservableMapCellLabelProvider - Documentation? [message #6064 is a reply to message #4638] Fri, 15 May 2009 17:25 Go to previous message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Hi Lars,

For ObservableMapCellLabelProvider, I would recommend overriding
update(ViewerCell). In fact, that's what the JavaDoc says:

"A label provider based on one or more observable maps that track attributes
that this label provider uses for display. The default behavior is to
display the first attribute's value. Clients may customize by subclassing
and overriding update(ViewerCell)."

Boris

"Lars Bischoff" <molehillrocker@googlemail.com> wrote in message
news:guedss$l9v$1@build.eclipse.org...
> Hello,
>
> I successfully bound my datamodel to my UI (table) and vice versa,
> according to the following snippet:
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.e xamples.databinding/src/org/eclipse/jface/examples/databindi ng/snippets/Snippet032TableViewerColumnEditing.java?view=co
>
> My model is backed by an array that consists of Row-objects, whereas each
> Row-object consists of several String- and int-attributes, according to
> the table's columns. The problem is now that if such an int-attribute is
> empty, the UI displays a 0 instead of nothing, since 0 is the default
> value.
> For this purpose I'd like to extend ObservableMapCellLabelProvider and
> override the method(s) that are responsible for this. For a "usual"
> ColumnLabelProvider it would look similar to this:
>
> ----- snip -----
>
> @Override
> public String getText(Object element) {
> Row row = (Row) element;
> switch(columnIndex) {
> case 0:
> if(row.getColumn(0).getValue() == 0)
> return "";
> }
> }
>
> ----- snap -----
>
> Unfortunately I am not able to find any documentation about the class
> ObservableMapCellLabelProvider to ascertain which methods need to be
> overridden.
>
> Best regards,
> Lars
Previous Topic:Re: Jump into first cell of Table
Next Topic:Re: CCombo updates in Eclipse 3.4.
Goto Forum:
  


Current Time: Thu Apr 25 20:31:46 GMT 2024

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

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

Back to the top