blob: e4f3c6b65f927fc302fe7c040f2fcdf05c57172c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE>
A minimal plug-in
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H2>
A minimal plug-in</H2>
<P >
We all know what &quot;Hello World&quot; looks like in plain old Java without using any user interface frameworks or
other specialized libraries.</P>
<pre>
public class HelloWorld {
public static void main(String[] args) {
System.out.println(&quot;Hello World&quot;);
}
}
</pre>
<P >
What happens to this old standard in the context of the Eclipse platform? Instead of thinking of Hello World as a self-contained program, we recast it as an extension of the platform. Since we want to say hello to the world, we need to figure out how to extend the workbench to include our greeting.</P>
<P >
When we get deeper into the platform user interface components, we'll do an exhaustive review of the ways that you can extend and customize the workbench
UI. For now, let's start with one of the simplest workbench extensions - a view.&nbsp;</P>
<p>You can think of the workbench window as a frame that presents various visual
parts. These parts fall into two major categories: views and editors.&nbsp; We
will look at editors later.&nbsp; <b>Views</b>
provide information about some object that the user is working with in the
workbench. Views often change their content as the user selects different
objects in the workbench.</p>
<H3>
Hello world view</H3>
<P >
For our hello world plug-in, we will implement our own view to greet the user with &quot;Hello World.&quot;</P>
<P >
The plug-in <b>org.eclipse.ui.workbench</b> defines most of the public interfaces that make up the workbench
API. These interfaces can be found in the package <b><a href="../reference/api/org/eclipse/ui/package-summary.html"> org.eclipse.ui</a></b>
and its sub packages. Many of these interfaces have
default implementation classes that you can extend to provide simple modifications to the system. In our hello world example, we will extend a workbench view to provide a label that says hello.</P>
<P >
The interface of interest is <b><a href="../reference/api/org/eclipse/ui/IViewPart.html">IViewPart</a></b>, which defines the methods that must be implemented to contribute a view to the workbench. The class
<b><a href="../reference/api/org/eclipse/ui/part/ViewPart.html">ViewPart</a></b> provides a default implementation of this interface. In a nutshell, a view part is responsible for creating the widgets needed to show the view.</P>
<P > The standard views in the workbench often display some information about
an object that the user has selected or is navigating. Views update their contents
based on actions that occur in the workbench. In our case, we are just saying
hello, so our view implementation will be quite simple.</P>
<p>
Before jumping into the code, we need to make sure our environment is set up for plug-in development...
</p>
</BODY>
</HTML>