Creating a Plugin

If you have other questions about these instructions, please send email to eclipse at BurdBrain.com.
  1. Choose Window-->Open Perspective-->Other.

    The Select Perspective dialog appears.

  2. Double-click Plug-in Development.

    The Plug-in Development perspective appears.

  3. Choose File-->New-->Plug-in Project.

    The Plug-in Project wizard appears.

  4. Type a name in the Project Name field.

    In this example, type scoreboard.

    WARNING: Be sure to start scoreboard with a lowercase letter s.

  5. Click Next.

    The Plug-in Project wizard's second page appears.

  6. Click Finish to accept the second page's defaults.

    The wizard disappears. The workbench's editor area displays the Plug-in Manifest editor. The manifest editor's Overview page is visible.

    The Plug-in Manifest editor gives you a graphical representation of the plugin.xml file's contents. (This plugin.xml file is a kind of "deployment descriptor" for your new Eclipse plugin.) You can see the plugin.xml file's text by selecting the editor's plugin.xml tab.

  7. Select the Extensions tab.

  8. Click Add.

    The New Extension dialog appears.

  9. Double-click org.eclipse.ui.views.

    The New Extension dialog disappears.

  10. Back in the Extensions tab, right-click the new org.eclipse.ui.views item. Then, in the resulting context menu, select New-->View.

    Eclipse creates a view with default name scoreboard.view1, and shows you the details on the right side of the editor page.

    The plugin.xml file reflects the changes you made.

  11. On Eclipse's main menu bar, choose File-->Save.

    Now it's time to create the plug-in's Java code.

  12. On the manifest editor's Extensions page, click the class*: link.

    The Java Attribute Editor appears.

  13. Click Finish to accept the Java Attribute Editor's defaults

    Eclipse creates a skeletal version of your new ViewPart1.java file.

  14. In the viewPart1.java file, replace the createPartControl method's body with the following text:
    Table table = new Table(parent, SWT.SINGLE);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    
    TableColumn column1 = new TableColumn(table, SWT.LEFT);
    TableColumn column2 = new TableColumn(table, SWT.LEFT);
    TableItem row1 = new TableItem(table, SWT.NONE);
    TableItem row2 = new TableItem(table, SWT.NONE);
    
    column1.setWidth(100);
    column1.setText("Home");
    column2.setWidth(100);
    column2.setText("Visitor");
    
    row1.setText(new String[] { "7", "3" });
    row2.setText(new String[] { "5", "11" });
    
    With the addition of this code, your program needs a few more import declarations.

  15. On the main menu bar, choose Source-->Organize Imports.

    The Organize Imports dialog appears.

  16. In the Organize Imports dialog, double-click org.eclipse.swt.widgets.TableColumn.

  17. On Eclipse's main menu bar, choose File-->Save All.

    Your plug-in is ready to run.

  18. On the Package Explorer's tree, select the scoreboard project's branch.

  19. On Eclipse's main menu bar, choose Run-->Run As-->Eclipse Application.

    A new version of the Eclipse workbench starts running.

  20. In the newly opened workbench, choose Window-->Show View-->Other.

    The Show View dialog appears.

  21. In the Show View dialog's tree, expand the Other branch. Then double-click scoreboard.view1.

    Your new view appears in the workbench's lower right area.