Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Using a Viewer with multiple views (Providers)
Using a Viewer with multiple views (Providers) [message #306691] Thu, 03 August 2006 11:01 Go to next message
Eclipse UserFriend
Originally posted by: dennis.rietmann.solnet.ch

Hi,

I want to use a (eg. Tree-)Viewer in a way that one can switch from one
view to another and back (to display different data but still using
only 1 Viewer). A view consists of the data set with setInput(), a
specific ContentProvider and LabelProvider.
When I trigger the switch (via button) sth. like the following code will
get executed:
if (...) {
/* switch from view 1 to view 2 */
treeViewer.setContentProvider(cp2);
treeViewer.setInput(data2);
treeViewer.setLabelProvider(lp2);
}
else {
/* switch from view 2 to view 1 */
treeViewer.setContentProvider(cp1);
treeViewer.setInput(data1);
treeViewer.setLabelProvider(lp1);
}
....
After _each_ setX() method the treeViewer triggers a refresh and calls
the Providers and some Listeners (like SelectionChangedListener).
Therefore I had to add a lot of ugly checks to determine if everything
is in place, but also performance-wise I think this is far from optimal.
So, my question is: Is there a better way to do this or how would you
improve this? I would appreciate any advice.

Thanks,
Dennis
Re: Using a Viewer with multiple views (Providers) [message #306714 is a reply to message #306691] Thu, 03 August 2006 13:54 Go to previous messageGo to next message
Eclipse UserFriend
Why not hiding and showing viewers instead of replacing content? I don't
think that there's a better way than you do it now.

Tom
Re: Using a Viewer with multiple views (Providers) [message #306735 is a reply to message #306714] Thu, 03 August 2006 18:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dennis.rietmann.solnet.ch

Hi Tom,

thanks for the hint, I'll probably use this and trigger a refresh after
switching.
Did you have something like the following in mind, or is there an easier
solution?

private void switchView() {
if (view == ...) {
treeViewer1.setVisible(false);
((GridData)treeViewer1.getLayoutData()).exclude = true;
treeViewer2.setVisible(true);
((GridData)treeViewer2.getLayoutData()).exclude = false;
treeViewer2.refresh();
view = ...
} else {
/* same stuff the other way around */
}

container.layout();

}

Dennis

Tom Schindl wrote:
> Why not hiding and showing viewers instead of replacing content? I don't
> think that there's a better way than you do it now.
>
> Tom
Re: Using a Viewer with multiple views (Providers) [message #306745 is a reply to message #306735] Fri, 04 August 2006 01:21 Go to previous message
Eclipse UserFriend
Yes. Maybe I'd do the refresh before making the dialog visible, hide the
first one.

Tom

Dennis schrieb:
> Hi Tom,
>
> thanks for the hint, I'll probably use this and trigger a refresh after
> switching.
> Did you have something like the following in mind, or is there an easier
> solution?
>
> private void switchView() {
> if (view == ...) {
> treeViewer1.setVisible(false);
> ((GridData)treeViewer1.getLayoutData()).exclude = true;
> treeViewer2.setVisible(true);
> ((GridData)treeViewer2.getLayoutData()).exclude = false;
> treeViewer2.refresh();
> view = ...
> } else {
> /* same stuff the other way around */
> }
>
> container.layout();
>
> }
>
> Dennis
>
> Tom Schindl wrote:
>> Why not hiding and showing viewers instead of replacing content? I don't
>> think that there's a better way than you do it now.
>>
>> Tom
Previous Topic:Re: Change TableViewer's Table at runtime
Next Topic:Trouble with branding launcher from PDE builder
Goto Forum:
  


Current Time: Sat May 10 12:52:36 EDT 2025

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

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

Back to the top