Add dynamic tabs in eclipse tab property view

I am trying to create a tabbed property view in accordance with this article: View Eclipse tab properties

According to the article, the 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 property tabs are displayed depending on the selected item. Therefore, I have to dynamically add tabs to the extension being added to the selected item.

Please suggest how to do this.

Update: One way to do this (I'm not sure I advised it) is using the IExtensionRegistry.addContribution () method. Here I presented an input stream object containing the required extension details. These are added tabs to the runtime view of properties. However, when you change the selection of an item in the list viewer, the property view is not updated. Please suggest if this is the right approach for this.

+4
source share
3 answers

Well, I got a solution to my two-step process. Using this, you can add dialogs (tabs) (and their sections):

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

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

Step 2. Provide tabs and sections:

The TabDescriptor provider will return an array of TabDescriptors when the getTabDescriptor () method is called. Each TabDescriptor returns a ListDecriptors list, and each SectionDescriptor is associated with a section. Finally, the Section class contains widgets that will be displayed on the screen. Each widget in the Section class has a modifier that updates the properties of the selected elements.

+4
source

Although the answer from Viral may not meet the specific needs of the OP, the answer provided is probably acceptable to many.

If the tab does not have any sections to display, by default TabbedPropertySheetPage will not display this tab. Thus, if the problem area is specified in terms of IFilter implementation classes, “dynamic” tabs can be achieved.

Tabs will be added or deleted as the selection changes depending on the presence of any sections. One or several sections may be present on the visible tab, and the number of sections on the visible tab may change from one choice to another.

When I came across this page with the same underlying problem, I was a little disappointed that I needed to intervene in the way the OP suggested. After some experimentation, I was able to achieve what I needed only with the IFilter approach proposed by Viral.

+1
source

The tutorial is available at http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html

You need to define a new YourPropertySection property derived from Abstract PropertySection . Also define a filter derived from IFilter and override the select method to return true only for the selected select type. Then, in the plugin.xml file, write an extension point that displays your PropertySection in the desired PropertyTab and also links your filter. Thus, this section and tab will only be displayed when your filter returns true.

0
source

Source: https://habr.com/ru/post/1399948/


All Articles