Home » Eclipse Projects » JFace » How to update TreeViewer?
How to update TreeViewer? [message #637337] |
Fri, 05 November 2010 07:02 |
|
Hey all,
i have a TreeViewer where multiple lines can be highlighted. I realised the highlight by overriding the getBackground() method of the corresponding LabelProvider.
Now i have the following problem: One or more lines are highlighted and now the user wants to edit a value, therefore he clicks into a cell which works fine, but now i want that my highlights disappear. This is not the case, because the Treeviewer is not redrawn.
My first idea was to add a SelectionListener to the Treeviewer, and call refresh() when a new line is selected, anyway this doesn´t work because then the CellEditor won´t be activated. Calling redraw() and update on the tree also doesn´t work.
Does anyone have an idea, what i could do? How can i force my Treeviewer to repaint, without loosing the Activation of my CellEditor?
Thanks alot,
Thomas
|
|
|
Re: How to update TreeViewer? [message #637361 is a reply to message #637337] |
Fri, 05 November 2010 08:26 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Yes - refresh cancels the editing.
2 Things:
* you could try update() instead
* you could call refresh and start the editing process afterwards
manually
Tom
Am 05.11.10 08:02, schrieb T. Wilhelm:
> Hey all,
>
> i have a TreeViewer where multiple lines can be highlighted. I realised
> the highlight by overriding the getBackground() method of the
> corresponding LabelProvider.
> Now i have the following problem: One or more lines are highlighted and
> now the user wants to edit a value, therefore he clicks into a cell
> which works fine, but now i want that my highlights disappear. This is
> not the case, because the Treeviewer is not redrawn.
> My first idea was to add a SelectionListener to the Treeviewer, and call
> refresh() when a new line is selected, anyway this doesn´t work because
> then the CellEditor won´t be activated. Calling redraw() and update on
> the tree also doesn´t work.
> Does anyone have an idea, what i could do? How can i force my Treeviewer
> to repaint, without loosing the Activation of my CellEditor?
>
> Thanks alot,
>
> Thomas
|
|
|
Re: How to update TreeViewer? [message #637362 is a reply to message #637337] |
Fri, 05 November 2010 08:27 |
Ed Merks Messages: 33136 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060306080108010800000205
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Thomas,
You need to call methods like to tell the viewer to consult the label
provider for changes
public void update(Object element, String[] properties)
T. Wilhelm wrote:
> Hey all,
>
> i have a TreeViewer where multiple lines can be highlighted. I
> realised the highlight by overriding the getBackground() method of the
> corresponding LabelProvider.
> Now i have the following problem: One or more lines are highlighted
> and now the user wants to edit a value, therefore he clicks into a
> cell which works fine, but now i want that my highlights disappear.
> This is not the case, because the Treeviewer is not redrawn.
> My first idea was to add a SelectionListener to the Treeviewer, and
> call refresh() when a new line is selected, anyway this doesn´t work
> because then the CellEditor won´t be activated. Calling redraw() and
> update on the tree also doesn´t work.
> Does anyone have an idea, what i could do? How can i force my
> Treeviewer to repaint, without loosing the Activation of my CellEditor?
>
> Thanks alot,
>
> Thomas
--------------060306080108010800000205
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thomas,<br>
<br>
You need to call methods like to tell the viewer to consult the label
provider for changes<br>
<blockquote> public void update(Object element, String[] properties)<br>
</blockquote>
<br>
T. Wilhelm wrote:
<blockquote cite="mid:ib09ve$rsu$1@news.eclipse.org" type="cite">Hey
all,
<br>
<br>
i have a TreeViewer where multiple lines can be highlighted. I realised
the highlight by overriding the getBackground() method of the
corresponding LabelProvider. <br>
Now i have the following problem: One or more lines are highlighted and
now the user wants to edit a value, therefore he clicks into a cell
which works fine, but now i want that my highlights disappear. This is
not the case, because the Treeviewer is not redrawn. <br>
My first idea was to add a SelectionListener to the Treeviewer, and
call refresh() when a new line is selected, anyway this doesn´t work
because then the CellEditor won´t be activated. Calling redraw() and
update on the tree also doesn´t work. <br>
Does anyone have an idea, what i could do? How can i force my
Treeviewer to repaint, without loosing the Activation of my CellEditor?
<br>
<br>
Thanks alot,
<br>
<br>
Thomas
<br>
</blockquote>
</body>
</html>
--------------060306080108010800000205--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to update TreeViewer? [message #637367 is a reply to message #637337] |
Fri, 05 November 2010 09:26 |
|
Hi Tom,
back from the Eclipse Summit?
Update doesn´t works in that case, also update on the label provider like Ed mentioned didn´t work, but your second hint works. I registered a mouse listener, refresh my Treeviewer and then call editElement().
I hoped there is another solution, but it works, and this is the most important thing
Have a nice weekend
Thomas
|
|
|
Goto Forum:
Current Time: Fri Apr 19 02:11:22 GMT 2024
Powered by FUDForum. Page generated in 0.01882 seconds
|