The Eclipse workbench contains a number of views, such as Outline, Navigator, Problems, Progress. The article represents how to create as simple Eclipse View (with example).

1    Plug-in

1.1    Plugin.xml

Create a plugin project and define plugin.xml file.
a. extension point
   The org.eclipse.ui plug-in defines a single extension point for view contribution: org.eclipse.ui.views.
b. category
   A category element is used to group a set of views within the Show View dialog.
c. view
   Define the basic attributes for the view: id, name, category, class and icon.

<plugin>

    <extension point= "org.eclipse.ui.views" >

      <category

           id = "org.eclipse.birt.chart.examples.view.category"

           name = "Charting Examples" >

      </category>

    

      <view

         id = "org.eclipse.birt.chart.examples.view.examplesview"

         name = "Examples View"

         category = "org.eclipse.birt.chart.examples.view.category"

         class = "org.eclipse.birt.chart.examples.view.ExamplesView"

          icon = "icons\obj16\chartselector.gif" />

   </extension>

</plugin>


1.2    Plugin class

ExamplesPlugin.java is the main plug-in class to be used in the desktop.  

public class ExamplesPlugin extends AbstractUIPlugin

{

private static ExamplesPlugin plugin ;

public ExamplesPlugin( )

            {

                super ( );

                plugin = this ;
            
}

}

 

2    Examples View

ExamplesView.java creates the view by inheriting all the behavior from ViewPart.java. All rendering happens inside createPartControl() method. The setFocus() method gives focus to this control. Both of these method will be called by the platform.  

public class ExamplesView extends ViewPart

{

      Examples instance = null ;

public void createPartControl(Composite parent)

{

instance = new Examples(parent);

instance .createGUI(parent);

}

public void dispose( )

{

                  instance .dispose();

                  instance = null ;

                  super .dispose();

}

             public void setFocus()

{

                  instance .focus();

}

}

       

3    Examples

The actual GUI creation process is placed in Examples.java  

public class Examples

{

                    public Example(Composite parent) { }

          publicvoidcreateGUI(Composite parent) {}

          public void setFocus() {}

}


      

4     ToolBar      
     Add toolbar contributions in ExamplesView.java as follows: 

final IActionBars actionBars = getViewSite().getActionBars();

IToolBarManager toolbarManager = actionBars.getToolBarManager();

 

Create toolbar in Examples.java, use an array (tools) to restore all information about tools (only applicable in STANDALONE):

private void createToolBar(Composite parent)

{

      ToolBar toolbar = new ToolBar (parent, SWT. NONE );

for ( int i = 0; i < tools . length ; i++)

{

  ToolItem item = addToolItem(toolbar, tool);

}

}

private ToolItem addToolItem( final ToolBar toolbar, tool)

{

          ToolItem item = new ToolItem (toolbar, SWT. PUSH );

          item.setText ( ...);

          item.setToolTipText( ...);

    item.setImage( ... );

}

 

Note: Some of information from Eclipse website: http://www.eclipse.org/