javaeclipse-pluginswtjface

Eclipse JFace how to dynamically add SWT view


My view (Show Result) is defined in plugin.xml. Which is working as expected when I run the plugin Show Result widget is getting displayed. Now I want to load the view dynamically based on results. Such as for each result it should load the new Show Result (e.g Show Results1, Show Results2 etc) widget. Any suggestion on how it can be achieved?

<view
    allowMultiple="true"
    class="com.eclipse.plugin.MyResultView"
    icon="icons/res.png"
    id="view1"
    name="Show Results"
    restorable="true">
</view>

Solution

  • If you want to show multiple instances of the same view use the

    IViewPart showView(String viewId, String secondaryId, int mode);
    

    method of IWorkbenchPage. The view needs to be defined with allowMultiple="true" in the plugin.xml.

    The secondaryId is a arbitrary string that distinguishes the views, it can have any value (except it should not contain a :).

    To set the name of the view call the ViewPart.setPartName(String name) method in the view part.