| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> |
| <HEAD> |
| <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> |
| Installing and running the plug-in |
| </TITLE> |
| |
| <link rel="stylesheet" type="text/css" HREF="../book.css"> |
| </HEAD> |
| <BODY BGCOLOR="#ffffff"> |
| <H2> |
| Installing and running the plug-in</H2> |
| <P > |
| Let's put everything together so that we can run our new plug-in. </P> |
| <P > First, we need to compile our classes into a jar called <b>helloworld.jar</b>. |
| Why? Because that's where we told the platform our plug-in could be found. You |
| can do this by selecting the project, choosing <b>File > Export</b> and exporting |
| your generated class file to a <b>JAR File</b>. </P> |
| <P > Next, we install the plug-in into a directory underneath the platform's plug-in |
| directory. This directory corresponds to our plug-in id, which must be unique. |
| The standard practice for plug-in directory names is to use the plug-in's fully |
| qualified id, including the dots. In this case, we need to create a directory |
| named <b>org.eclipse.examples.helloworld</b> inside the platform's plug-in directory. |
| (The plug-in directory is named <b>plugins</b> and is typically located underneath |
| the main directory where you installed the platform.) We copy the <b> helloworld.jar</b> |
| and the <b> plugin.xml</b> to this new directory. (You can export the |
| <b>plugin.xml</b> to the file system using the <b>File > Export</b> wizard |
| with destination type <strong>File system</strong>.) </P> |
| <P > |
| <img src="images/helloinstall.gif" alt="" border="0" width="592" height="454"> </P> |
| <P >If you are currently running the workbench, you will need to shut it down |
| and restart it. When the platform starts, it assembles a list of all of the plug-ins installed in the system, called the plug-in registry. This registry keeps track of plug-ins and the extension points that they contribute. |
| Restarting the workbench will cause it to find your new plug-in.</P> |
| <P >(Note: We are installing our plug-in and launching the workbench ourselves to show |
| exactly how plug-ins are installed and found in the platform. The PDE |
| plug-in automates much of this process by introducing a special launcher that |
| launches a self-hosted workbench. We are ignoring this for now to keep |
| things simple.) </P> |
| <P > How do we run the plug-in? We can see all of the views that have been |
| contributed by plug-ins using the <b>Window >Show View</b> menu.</P> |
| |
| <img src="images/perspectivemenu.gif" alt="" border="0" width="425" height="349"> |
| <P > |
| This menu shows us what views are available for the current perspective. You can see all of the views that are contributed to the platform (regardless of perspective) by selecting |
| <b>Other...</b>. This will display a list of view categories and the views available under each category. </P> |
| <P > |
| The workbench creates the full list of views by using the plug-in registry to |
| find all the plug-ins that have provided extensions for the |
| <a href="../reference/extension-points/org_eclipse_ui_views.html"><b> org.eclipse.ui.views</b></a> extension point. </P> |
| |
| <img src="images/showview.gif" alt="Show View dialog with Hello entry" border="0" width="297" height="422"> |
| <P > |
| There we are! The view called "Hello Greetings" has been added to the <b> Show View</b> window underneath our category "Hello." The labels for our category and view were obtained from the extension point configuration markup in the |
| <b>plugin.xml</b>. </P> |
| <P ><i><b> |
| Up to this point, we still have not run our plug-in code! </b></i>The |
| declarations in the <b>plugin.xml </b>(which can be |
| accessed via the plug-in registry) are enough for the workbench to know that there is a view called "Hello View" available in the "Hello" category. It knows what class implements the view. But none of our code will be run until we decide to |
| show the view.</P> |
| <P > |
| If we choose the "Hello Greetings' view from the <b> Show View</b> list, the |
| workbench will |
| activate our plug-in, instantiate and initialize our view class, and show the |
| new view in the workbench along with all of the other views. Now our code is running. </P> |
| |
| <img src="images/workbenchwithhello.gif" alt="Workbench with Hello World view" border="0" width="584" height="444"> |
| <P > |
| There it is, our first plug-in! We'll cover more specifics about UI classes and extension points later on.</P> |
| |
| <p><a href="../hglegal.htm"><img border="0" src="../ngibmcpy.gif" alt="Copyright IBM Corporation and others 2000, 2003." border="0" width="324" height="14"></a></p> |
| |
| </BODY> |
| </HTML> |