1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00
cdt/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProject.html

105 lines
7.2 KiB
HTML
Executable file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2002, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<LINK REL="STYLESHEET" HREF="../../book.css" TYPE="text/css">
<title>Creating a Plug-in Project</title>
</head>
<body>
<h1>Creating a Plug-in Project</h1>
<p>To use any Eclipse extension point, including those defined by the Remote System Explorer, you must first create a plug-in project using the plug-in development environment (PDE), which you will do shortly. At its simplest, a plug-in project requires a <tt>MANIFEST.MF</tt> file describing the plugin and its dependencies and, if extending the workbench a <samp>plugin.xml</samp> file identifying the extension points being implemented, and a set of Java classes implementing those extension points. There is usually also a plug-in class file that is used as the overall manager of the project, and point of integration that other classes can rely on.</p>
<p><i>If you already have a plugin project, you will need to update it slightly to make it extend SystemBasePlugin and add the few methods it requires. You may wish to examine these steps to see what methods to add. The Eclipse environment will keep your classpaths and plugin dependecies in sync for you.</i></p>
<p>Eclipse supplies a number of plug-in project templates, which generate a number of project files that illustrate examples of various Eclipse extension points. While you are free to pick one of these, or indeed start with any existing plug-in project if you have one, in the RSE tutorials everything is created by hand so as to keep focused on the RSE-required classes and files.</p>
<p>The following tutorial uses numbered steps to indicate where you are required to do something as you follow along.</p>
<h2>Step By Step: Creating an RSE Plug-in Project</h2>
<ol>
<li>Select <b>File-&gt;New-&gt;Project.</b></li>
<li>In the dialog box select the <b>Plug-in Project</b> wizard. Click <b>Next &gt;</b>.
<br><img src="pdeProj_1.png">
</li>
<li>In the first page of the wizard enter <b>&quot;RSESamples&quot;</b> for the project name (without the quotes). Click <b>Next &gt;</b>.
<br><img src="pdeProj_wiz_page1.png">
</li>
<li>In the second page of the wizard enter your company for the <b>Plug-in Provider</b>, change the <b>Activator</b> to be "rsesamples.RSESamplesPlugin", and click <b>Next &gt;</b>.
<br><img src="pdeProj_wiz_page2.png">
</li>
<li>In the third page of the wizard uncheck the "Create a plug-in using one of the templates" checkbox and click <b>Finish</b>.
<br><img src="pdeProj_wiz_page3.png">
</li>
<li>Your new plugin project is created and visible in the Package Explorer of the Plug-in Development perspective. Your new plugin properties are also open in the plug-in editor.</li>
<li>Go to the dependencies tab of the plug-in editor and add the following plugins to the list:
<ul>
<li>org.eclipse.core.resources</li>
<li>org.eclipse.rse.ui</li>
<li>org.eclipse.rse.services</li>
<li>org.eclipse.rse.files.ui</li>
<li>org.eclipse.rse.shells.ui</li>
<li>org.eclipse.rse.subsystems.files.core</li>
<li>org.eclipse.rse.subsystems.shells.core</li>
</ul>
</li>
<li>Now go to the MANIFEST.MF tab of the plugin properties.
This shows the source for the MANIFEST.MF file associated with this plugin.
Change the Bundle-SymbolicName line adding a singleton:=true directive.
<pre><code>
Bundle-SymbolicName:RSESamples;singleton:=true
</code></pre>
This allows us to add extensions to the plugin at a later point.
Save the plugin properties and close the editor.
</li>
<li>
Right-click on the RSESamples project and create a plugin.xml file.
Normally this would be created if you used a template to create your plugin.
We will use this file to add extensions to RSE but for now it will just be a skeleton with the following contents:
<pre><code>
&lt;plugin&gt;
&lt;/plugin&gt;
</code></pre>
Add the lines above to the empty plugin.xml file and save it.
</li>
<li>Expand the <b>src</b> folder, then the <b>rsesamples</b> package folder, and double-click on <samp><b>RSESamplesPlugin.java</b></samp> to edit this class.
Change it as described below. Reference the source <a href="RSESamplesPlugin.html">here</a> for the details.
<ul>
<li>Extend SystemBasePlugin instead of AbstractUIPlugin</li>
<li>Add the declaration for resourceBundle</li>
<li>Add the declaration for messageFile</li>
<li>Invoke the superclass constructor from this constructor</li>
<li>Add the initializeImageRegistry() method</li>
<li>Add the getMessageFile() method</li>
<li>Add the getResourceBundle() method</li>
<li>Add the static getWorkspace() method</li>
<li>Add the static getResourceString(String) method</li>
<li>Add the static getPluginMessageFile() method</li>
<li>Add the static getPluginMessage(String) method</li>
</ul>
</li>
<li>Create the project's resources file for translatable strings: right-click on the <b>RSESamples</b> project and select <b>New-&gt;File</b> to open the <b>New File</b> wizard. Enter <samp><b>rseSamplesResources.properties</b></samp> for the file name, as was specified in the call to <samp>loadResourceBundle</samp> in the plug-in class's constructor. Press <b>Finish</b> to create the file. You will populate as you go through the tutorials, so for now just <i>close</i> the editor opened for the file.</li>
<li>Create the project's RSE-style messages file for translatable messages: right-click on the <b>RSESamples</b> project and select <b>New-&gt;File</b> to get the <b>New File</b> wizard. Enter <samp><b>rseSamplesMessages.xml</b></samp> for the file name, as was specified in the call to <samp>loadMessageFile</samp> in the plug-in class's constructor. Press <b>Finish</b> to create the file. You will see the XML editor open for the new file. Press the <b>Source</b> tab at the bottom of the editor, and enter the following lines (so that you can add messages to the file later on):
<pre><code>
&lt;?xml version=&quot;1.0&quot; encoding='UTF-8'?&gt;
&lt;!DOCTYPE MessageFile SYSTEM &quot;../org.eclipse.rse.ui/messageFile.dtd&quot;&gt;
&lt;!-- This is a message file used by SystemMessage and SystemMessageDialog --&gt;
&lt;<b>MessageFile</b> Version=&quot;1.0&quot;&gt;
&lt;<b>Component</b> Name=&quot;RSE Samples&quot; Abbr=&quot;RSS&quot;&gt;
&lt;<b>Subcomponent</b> Name=&quot;General&quot; Abbr=&quot;G&quot;&gt;
&lt;<b>MessageList</b>&gt;
&lt;<b>Message</b> ID=&quot;1001&quot; Indicator=&quot;E&quot;&gt;
&lt;<b>LevelOne</b>&gt;Sample message&lt;/<b>LevelOne</b>&gt;
&lt;<b>LevelTwo</b>&gt;This is a sample with one substitution variable: %1&lt;/<b>LevelTwo</b>&gt;
&lt;/<b>Message</b>&gt;
&lt;/<b>MessageList</b>&gt;
&lt;/<b>Subcomponent</b>&gt;
&lt;/<b>Component</b>&gt;
&lt;/<b>MessageFile</b>&gt;
</code></pre>
Save and close the file.
</li>
<li>Your plugin is created and you are ready to go. Now you only need to add the code to implement the extension points.
</li>
</ol>
</body>
</html>