Eclipse Plugins are extension of third party functionalities made available within the Eclipse IDE. Standard plugins like CVS, ANT etc are already available within Eclipse. Eclipse SDK provides a Plugin Developer Environment (PDE) for ease of plugin development. Plugins can be created as perspectives or views

  1.1 View

View is a visual component which can be hooked into an eclipse workbench. To create a view within eclipse, a subclass of org.eclipse.ui.part.ViewPart should be created first. Then the view should be included into the workbench by editing the plugin.xml

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

<category name="Sample View" id="com.adhi.views">

</category>

<view name="Sample Tool View" icon="icons/sample.gif" category="com.adhi.views"
class="com.adhi.SampleToolView" id=”com.adhi.SampleToolView”>

</view>

</extension>

The following method need to be implemented for the ViewPart subclass

public class OrthogonalView extends ViewPart implements IStructuredContentProvider , ITableLabelProvider

{

public void createPartControl(Composite parent)

{

//place code to create all the controls of the view

//initialize all the GUI components with in the view

}

To populate the mrnus, create actions and include them into the MenuManager

Action exitAction = new Action()

{

public void run()

{

try

{

getSite().getPage().hideView(sampleToolsView);

}

catch(Throwable t)

{

t.printStackTrace();

}

}

};

exitAction.setText(“Exit”);

exitAction.setToolTipText(“Exit”);

IActionBars bars = getViewSite().getActionBars();

bars.getMenuManager().add(exitAction);

1.2  Perspective

Perspective is a collection of views, which organizes views in a particular way. To create a perspective, create
a class that implements IPerspectiveFactory and implement the method createInitialLayout.

public class OatsPerspective implements IPerspectiveFactory

{

public void createInitialLayout(IPageLayout layout)

{

defineActions(layout);

defineLayout(layout);

}

then include the perspective into the workbench by modifying the plugin.xml

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

<perspective

name="Sample Tool"

class="com.adhi.SamplePerspective"

id="com.adhi.Tool">

</perspective>

</extension>

1.3  Dialogs

Application Dialogs can be created by extending org.eclipse.jface.dialogs.Dialog and implementing the method
createDialogArea.

protected Control createDialogArea(Composite parent)

{

Composite composite = (Composite)super.createDialogArea(parent);

createTableViewer(composite);

return composite;

}

The createDialogArea method is used for creating the Dialog GUI components apart from the OK and Cancel button. The method is called everytine the open method is called on the dialog

1.4  Preference Page

Preference for views and perspectives can be setup using the preference pages. Preference pages are created by
creating a subclass of PreferencePage and implementing its CreateContents methods

protected Control createContents(Composite parent)

{

Composite prefComposite = new Composite(parent, SWT.NONE);

Label urlLabel = new Label(prefComposite, SWT.LEFT);

urlLabel.setText(EclipseJIRAConstants.URL);

urlLabel.setBounds(10, 10, 75, 20);

urlText = new Text(prefComposite, SWT.BORDER);

urlText.setBounds(100, 10, 300, 20);

initializeValues();

return prefComposite;

}

Then the prefence page can be viewd in the workbench by modifyting the plugin.xml

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

<page

name="Sample"

class="com.adhi.pref.SamplePreferencePage"

id="com.adhi.pref.SamplePreferencePage">

</page>

</extension>