Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add dynamic tabs in tabbed property view of eclipse

I am trying to create a tabbed property view as per given article : The Eclipse Tabbed Properties View

As per article, org.eclipse.ui.views.properties.tabbed.propertyTabs extension point can be used to add new tabs.

<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
      <propertyTabs contributorId="mview.views.SampleView">
         <propertyTab
            category="sample"
               id="mview.ButtonTab"
            label="Button"/>
         <propertyTab
            afterTab="mview.ButtonTab"
            category="sample"
               id="mview.AdvancedTab"
            label="Advanced"/>
      </propertyTabs>
   </extension>

However in my case the tabs of property view vary depending on the item selected in view. So I have to add the tabs dynamically into extension depening on the item selected.

Please suggest how to do so.

Update: One of the way to do so (I am not sure if its adviced) is using IExtensionRegistry.addContribution() method. Here I provided an inputstream object containing desired extension details. This added tabs to property view at run time. However with change in selection of item in list viewer, the property view is not updated. Please suggest if this is the right approach to do so.

like image 975
V_M Avatar asked Mar 06 '12 08:03

V_M


2 Answers

Ok, I got the solution Its a two step process. Using this one can dyanamically add tabs (and their sections):

Step 1: Associate a tab descriptor provider with the view.

Add an extension point - org.eclipse.ui.views.properties.tabbed.propertyContributor to the view (if not already added). In the propertyContributor section, add a class for tabDescriptorProvider item. This class will implement ITabDescriptorProvider interface.

Step 2: Provide Tabs and Sections:

TabDescriptor provider will return array of TabDescriptors when its getTabDescriptor() method is called. Each TabDescriptor return a list of SectionDecriptors and each SectionDescriptor is linked to a Section. Finally it is the Section class that contains widgets to be displayed on screen. Each widget in Section class has a modify listner which updates the properties of selected items.

like image 156
V_M Avatar answered Nov 18 '22 13:11

V_M


While the answer from Viral may not match the specific needs of the OP, the provided answer is likely acceptable to many.

If a tab does not have any sections to display, the default TabbedPropertySheetPage will not show that tab. Thus, if the problem domain is specified in terms of IFilter implementing classes, "dynamic" tabs may be achieved.

Tabs will be added or be removed as the selection changes depending upon whether any sections are present. A visible tab may have one or more sections present on it, and the number of sections on a visible tab may change from selection to selection.

As I came across this page with the same basic issue, I was a bit disappointed that I would need to intervene in the way the OP suggested. After some experimentation, I was able to achieve what I needed purely through the IFilter approach as suggested by Viral.

like image 1
KevinO Avatar answered Nov 18 '22 12:11

KevinO