Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Problem with selection of widget in tableviewer
Problem with selection of widget in tableviewer [message #328466] Mon, 26 May 2008 08:21 Go to next message
Eclipse UserFriend
Originally posted by: MeLene3.gmail.com

Hi,

I've added a Link-widget to a table (tableViewer). When I press the link I
need too no which row (FULL_SELECTION on table) was pressed in the table.
The tableViewer.getSelection() is not updated when I press the link. How
can I find which row the link is related to?

I can switch to another widget in the table if someone has a better
suggestion.But I do want to add the widget to each row in the table.

Thanks
-Lene
Re: Problem with selection of widget in tableviewer [message #328473 is a reply to message #328466] Mon, 26 May 2008 09:21 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I'd say use StyledTextLabelProvider (you'll need 3.4) which uses owner
draw and draw a text that looks like a link :-). Afterwards register a
MouseListener on the Table and calculate if the link is pressed.

If you are on 3.3 you'll need to use an OwnerDrawLabelProvider instead
and to all the hard work your own.

You can find example for all the mentioned stuff at:
http://wiki.eclipse.org/JFaceSnippets

Tom



Lene schrieb:
> Hi,
>
> I've added a Link-widget to a table (tableViewer). When I press the link
> I need too no which row (FULL_SELECTION on table) was pressed in the
> table. The tableViewer.getSelection() is not updated when I press the
> link. How can I find which row the link is related to?
> I can switch to another widget in the table if someone has a better
> suggestion.But I do want to add the widget to each row in the table.
> Thanks
> -Lene
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Problem with selection of widget in tableviewer [message #328685 is a reply to message #328473] Mon, 02 June 2008 08:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: MeLene3.gmail.com

Hi

I've upgraded for eclipse 3.4.

The problem is that I'm already using the ObservableMapLabelProvider
because of the data binding. Of these reason I can't see how I can use
this StyledCellLabelProvider. Do you have another suggestion?

-Lene
Re: Problem with selection of widget in tableviewer [message #328688 is a reply to message #328685] Mon, 02 June 2008 09:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
It's quite easy to copy the logic from the ObservableMapLabelProvider
into a CellLabelProvider (StyledCellLabelProvider is a subclass from it).

You can take a look how I did this with ColumnLabelProvider by looking
at
http://publicsvn.bestsolution.at/repos/java/at.bestsolution. dataforms/trunk/src/at/bestsolution/dataforms/util/viewers/

Tom


Lene schrieb:
> Hi
>
> I've upgraded for eclipse 3.4.
> The problem is that I'm already using the ObservableMapLabelProvider
> because of the data binding. Of these reason I can't see how I can use
> this StyledCellLabelProvider. Do you have another suggestion?
> -Lene
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Problem with selection of widget in tableviewer [message #328691 is a reply to message #328688] Mon, 02 June 2008 10:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: MeLene3.gmail.com

Thanks for the tip.
I've now copied the logic from the ObservableMapLabelProvider:

private static class LinkLabelProvider extends StyledCellLabelProvider
implements ILabelProvider, ITableLabelProvider {...}

But the problem is that I never reach my update()-method. The reason is
the CellLabelProvider.createViewerLabelProvider().

static CellLabelProvider createViewerLabelProvider(ColumnViewer viewer,
IBaseLabelProvider labelProvider) {
boolean noColumnTreeViewer = viewer instanceof AbstractTreeViewer &&
viewer.doGetColumnCount() == 0;

if (!noColumnTreeViewer
&& (labelProvider instanceof ITableLabelProvider
|| labelProvider instanceof ITableColorProvider
|| labelProvider instanceof ITableFontProvider))
return new TableColumnViewerLabelProvider(labelProvider);
if (labelProvider instanceof CellLabelProvider)
return (CellLabelProvider) labelProvider;
return new WrappedViewerLabelProvider(labelProvider);
}

This method checks if the labelProvider is instance of the
ITableLabelProvider and if so returns a TableColumnViewerLabelProvider.

Will it not be a problem that I want to run the update() for both the
ObservableMap and for the StyledCell? The Observable map will map the
first 4 columns and the 5 and last column will have a link spesfic for
this column.

-Lene

Tom Schindl wrote:

> It's quite easy to copy the logic from the ObservableMapLabelProvider
> into a CellLabelProvider (StyledCellLabelProvider is a subclass from it).

> You can take a look how I did this with ColumnLabelProvider by looking
> at
>
http://publicsvn.bestsolution.at/repos/java/at.bestsolution. dataforms/trunk/src/at/bestsolution/dataforms/util/viewers/

> Tom


> Lene schrieb:
>> Hi
>>
>> I've upgraded for eclipse 3.4.
>> The problem is that I'm already using the ObservableMapLabelProvider
>> because of the data binding. Of these reason I can't see how I can use
>> this StyledCellLabelProvider. Do you have another suggestion?
>> -Lene
>>
Re: Problem with selection of widget in tableviewer [message #328692 is a reply to message #328691] Mon, 02 June 2008 10:26 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please take a look how to use CellLabelProviders appropiately[1]. You
should NOT implement ITable*-Interfaces but assign the LabelProvider to
every column in your system!

This will solve many many headaches you'll have with ITable*-Interfaces

Tom

[1] http://wiki.eclipse.org/JFaceSnippets#Snippet024TableViewerE xploreNewAPI

Lene schrieb:
> Thanks for the tip. I've now copied the logic from the
> ObservableMapLabelProvider:
> private static class LinkLabelProvider extends StyledCellLabelProvider
> implements ILabelProvider, ITableLabelProvider {...}
>
> But the problem is that I never reach my update()-method. The reason is
> the CellLabelProvider.createViewerLabelProvider().
> static CellLabelProvider createViewerLabelProvider(ColumnViewer viewer,
> IBaseLabelProvider labelProvider) {
> boolean noColumnTreeViewer = viewer instanceof AbstractTreeViewer &&
> viewer.doGetColumnCount() == 0;
>
> if (!noColumnTreeViewer
> && (labelProvider instanceof ITableLabelProvider
> || labelProvider instanceof ITableColorProvider ||
> labelProvider instanceof ITableFontProvider))
> return new TableColumnViewerLabelProvider(labelProvider);
> if (labelProvider instanceof CellLabelProvider)
> return (CellLabelProvider) labelProvider;
> return new WrappedViewerLabelProvider(labelProvider);
> }
>
> This method checks if the labelProvider is instance of the
> ITableLabelProvider and if so returns a TableColumnViewerLabelProvider.
> Will it not be a problem that I want to run the update() for both the
> ObservableMap and for the StyledCell? The Observable map will map the
> first 4 columns and the 5 and last column will have a link spesfic for
> this column.
> -Lene
>
> Tom Schindl wrote:
>
>> It's quite easy to copy the logic from the ObservableMapLabelProvider
>> into a CellLabelProvider (StyledCellLabelProvider is a subclass from it).
>
>> You can take a look how I did this with ColumnLabelProvider by looking at
> http://publicsvn.bestsolution.at/repos/java/at.bestsolution. dataforms/trunk/src/at/bestsolution/dataforms/util/viewers/
>
>
>> Tom
>
>
>> Lene schrieb:
>>> Hi
>>>
>>> I've upgraded for eclipse 3.4.
>>> The problem is that I'm already using the ObservableMapLabelProvider
>>> because of the data binding. Of these reason I can't see how I can
>>> use this StyledCellLabelProvider. Do you have another suggestion?
>>> -Lene
>>>
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Combining Wizards
Next Topic:RC2 can't access update manager
Goto Forum:
  


Current Time: Mon Jul 29 22:26:48 GMT 2024

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

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

Back to the top