Extend ObservableMapCellLabelProvider - Documentation? [message #4638] |
Wed, 13 May 2009 08:19  |
Eclipse User |
|
|
|
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 04:31   |
Eclipse User |
|
|
|
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 13:25  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04467 seconds