DZone Forums
Go Back   DZone Forums > Community > Tools & IDEs > Eclipse
Reload this Page Tabbed Properties: sharing selection among views
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
epz epz is offline
Member
 
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Jul 2009
Default Tabbed Properties: sharing selection among views - 07-29-2009, 03:30 PM

The problem:
Finding a mechanism to keep the same Tabbed Properties view for more than one active view without fighting Eclipse.

Use case example:
Consider 3 views: one that provides a meaningful selection (a tree view for example), one that does not (a graph or a chart associated with the selected item), and a tabbed properties view for the selected item. The chart and the properties need to be visible simultaneously.

Navigating the tree produces the expected results: both other views change accordingly. However, once the tree view becomes inactive (click on the chart) the properties change to "Properties are not available"

Details:
For the views to stay consistent the adapter for IPropertySheetPage.class key from both views needs to be (or refer to) the same instance of TabbedPropertySheetPage. Merely instantiating a new TabbedPropertySheetPage with the same contributor is not sufficient because each instance will keep its own tab selection state, which can result in tab selection changing depending on which view (tree or chart) is active.

Returning the same (cached) instance of TabbedPropertySheetPage from getAdapter() more than once breaks the code because init() and createControl() get called on the adapter every time it's returned.

TabbedPropertySheetPage does not have a shallow clone() that could be a potential solution, depending of course on how clone() is implemented. TabbedPropertySheetPage is not Cloneable at all.

A kludge:
Here is an implementation of getAdapter() method for the tree and for the chart that does the trick, but has a distinct taste of fighting the workbench:

Tree:
private TabbedPropertySheetPage properties;

public TabbedPropertySheetPage getProperties() {
return properties;
}

public Object getAdapter(Class key) {
if (key == IPropertySheetPage.class) {
properties = new TabbedPropertySheetPage(this) {
boolean initialized = false;
public void init(IPageSite site) {
if (!initialized) {
super.init(site);
}
}

public void createControl(Composite parent) {
if (!initialized) {
super.createControl(parent);
initialized = true;
}
}
};
return properties;
}
return super.getAdapter(key);
}

Chart:
public Object getAdapter(Class key) {
if (key == IPropertySheetPage.class) {
return getTreeViewOneWayOrAnother().getProperties();
}
return super.getAdapter(key);
}

Question:
Is there an Eclipse idiom that would accomplish the same thing in a more graceful way?

Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sharing workspace in eclipse brimstedt Eclipse 12 10-10-2009 09:47 AM
How to modify/add new properties in VE? gnarang Eclipse 0 04-13-2009 02:53 AM
How do I make an IFolderLayout area always visible even if the views are closed? tanalyw Eclipse 0 01-22-2009 02:40 AM
No tables/views/procedures viewable from MySQL? secristrc NetBeans 0 10-28-2008 01:36 AM
Views in new perspective don't show up. kaprasanna Eclipse 0 07-25-2008 07:07 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com