Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Highlight the whole row in an editable Table
Highlight the whole row in an editable Table [message #140020] Fri, 10 July 2009 16:24 Go to next message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

This is a multi-part message in MIME format.
--------------020400020609070103020504
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

Hello everybody,
I am trying to achieve the following: I have a TableViewer with
TextCellEditors. My Task is to make the currently edited row visible by
setting an eye-catching background color to the whole row (not only the
currentliy selected cell).

I tried to solve this by using a custom FocusCellOwnerDrawHighlighter
(see [1]). This Highlighter remembers the color of a newly selected row
and then sets all cells left and right of the newly selected cell to the
highlight color (red (200, 20, 20) in the example). When the row is
left, the cells will be set back to the previously saved color (I am
using alternating background colors, that's why I can't simply set it to
white).

This solution works quite fine in RCP. To test it in RAP I have changed
the TableViewer tab of the controls demo to use the described
Highlighter (see [1]). This works also at a first glance. But when the
user changes the selected row very fast you can see that the whole line
is marked blue (probably the standard-selected-cell-blue) for a little
moment and sometimes the blue stays so that I end up with what is shown
in FocusHighlight.png.

Am I doing something wrong here? Has anybody an idea how this could be
stabilized? Ist this a bug?

Thanks for reading and I hope someone can help me...

Best Regards,
Bj
Re: Highlight the whole row in an editable Table [message #140098 is a reply to message #140020] Mon, 13 July 2009 07:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

Hello folks,
I had a little closer look at this problem. The firebug console shows
that changing the selected cell in a Tableviewer fires two events: one
for keyDown and one for widgetSelected (see attached
firebug_request.png). The responses to these two requests are shown in
firebug_response.png. The important part concerning my problem follow
(#ffffb3 is the color I use to highlight the current row):

Response to keyDown:
-----------------
[...]
var w = wm.findWidgetById( "w811" );
w.setCellBackgrounds( ["#ffffb3","#ffffb3"
,"#ffffb3","#316ac5","#ffffb3","#ffffb3","#ffffb3", "#ffffb3"]);
w.setCellForegrounds( [null,null,null,"#ffffff",null,null,null,null ]);
w.update();
var w = wm.findWidgetById( "w812" );
w.setCellBackgrounds("#316ac5","#316ac5","#316ac5","#316ac5 ","#316ac5",
"#316ac5","#316ac5","#316ac5"] );
w.setCellForegrounds([null,null,null,null,null,null,null,nul l])
[...]
-----------------

Here on the newly selected row ("w811") the correct backround highlight
is set. But on the "old" row ("w812") the blue background (#316ac5) is
set. Now the Response to widgetSelected:

-----------------
[...]
var w = wm.findWidgetById( "w812" );
w.setCellBackgrounds( [null,null,null,null,null,null,null,null]);
w.update();
[...]
-----------------

Here the previously set blue background on the "old" row is reset to null.

Now I wonder why the keyDown event first colors the left row in blue
while it is reset right afterwards in the widgetSelected handling. I am
rather new to RAP/Qooxdoo internals, so I can not really say if that
could be a bug, or if it is a wanted feature (which I just can not see
right now).

I would appreciate a little hint from someone more experienced in the
RAP internals.

Thanks in advance!

Regards
Björn

Björn Fischer schrieb:
> Hello everybody,
> I am trying to achieve the following: I have a TableViewer with
> TextCellEditors. My Task is to make the currently edited row visible by
> setting an eye-catching background color to the whole row (not only the
> currentliy selected cell).
>
> I tried to solve this by using a custom FocusCellOwnerDrawHighlighter
> (see [1]). This Highlighter remembers the color of a newly selected row
> and then sets all cells left and right of the newly selected cell to the
> highlight color (red (200, 20, 20) in the example). When the row is
> left, the cells will be set back to the previously saved color (I am
> using alternating background colors, that's why I can't simply set it to
> white).
>
> This solution works quite fine in RCP. To test it in RAP I have changed
> the TableViewer tab of the controls demo to use the described
> Highlighter (see [1]). This works also at a first glance. But when the
> user changes the selected row very fast you can see that the whole line
> is marked blue (probably the standard-selected-cell-blue) for a little
> moment and sometimes the blue stays so that I end up with what is shown
> in FocusHighlight.png.
>
> Am I doing something wrong here? Has anybody an idea how this could be
> stabilized? Ist this a bug?
>
> Thanks for reading and I hope someone can help me...
>
> Best Regards,
> Björn
>
> -------------------
> [1]: changes I made in TableViewerTab of the controls demo:
>
> [...]
>
> private static final class MyFocusCellOwnerDrawHighlighter extends
> FocusCellOwnerDrawHighlighter {
> Color lastRowColor = null;
>
> public MyFocusCellOwnerDrawHighlighter(ColumnViewer viewer) {
> super(viewer);
> }
>
> protected void focusCellChanged(ViewerCell newCell, ViewerCell
> oldCell) {
> Color bgHighlight = Graphics.getColor( 200, 20, 20 );
>
> // If row was not changed, only update the old cell to highlight color
> if (newCell != null && oldCell != null &&
> newCell.getElement() == oldCell.getElement()) {
> oldCell.setBackground(bgHighlight);
> }
>
> if (oldCell != null) {
> // Unhighlight the whole row of the old cell
> ViewerCell neighbor = oldCell.getNeighbor(ViewerCell.LEFT, true);
> while (neighbor != null) {
> neighbor.setBackground(lastRowColor);
> neighbor = neighbor.getNeighbor(ViewerCell.LEFT, true);
> }
> neighbor = oldCell.getNeighbor(ViewerCell.RIGHT, true);
> while (neighbor != null) {
> neighbor.setBackground(lastRowColor);
> neighbor = neighbor.getNeighbor(ViewerCell.RIGHT, true);
> }
> oldCell.setBackground(lastRowColor);
> }
>
> if (newCell != null) {
> lastRowColor = newCell.getBackground();
> // Highlight the whole row of the new cell
> ViewerCell neighbor = newCell.getNeighbor(ViewerCell.LEFT, true);
> while (neighbor != null) {
> neighbor.setBackground(bgHighlight);
> neighbor = neighbor.getNeighbor(ViewerCell.LEFT, true);
> }
> neighbor = newCell.getNeighbor(ViewerCell.RIGHT, true);
> while (neighbor != null) {
> neighbor.setBackground(bgHighlight);
> neighbor = neighbor.getNeighbor(ViewerCell.RIGHT, true);
> }
> }
> }
> }
>
> [...]
>
> FocusCellOwnerDrawHighlighter highlighter
> = new MyFocusCellOwnerDrawHighlighter( viewer );
>
> [...]
>
>
> ------------------------------------------------------------ ------------
>
Re: Highlight the whole row in an editable Table [message #140113 is a reply to message #140098] Mon, 13 July 2009 07:47 Go to previous message
Eclipse UserFriend
Originally posted by: bjoern.bjoernfischer.de

This is a multi-part message in MIME format.
--------------030604010404050209000802
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

.... and here the promised screenshots :-)

Bj
Previous Topic:Workaraund for missing keyBindings
Next Topic:Implementing Dowload Buttion In RAP Application
Goto Forum:
  


Current Time: Thu Apr 18 03:46:08 GMT 2024

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

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

Back to the top