diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/RSESamplesPlugin.html b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/RSESamplesPlugin.html index 8a48717f16c..c5f37e115be 100755 --- a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/RSESamplesPlugin.html +++ b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/RSESamplesPlugin.html @@ -12,14 +12,14 @@

RSESamplesPlugin Class


-package samples;
+

+package rsesamples;
 
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Platform;
 import org.eclipse.rse.services.clientserver.messages.SystemMessage;
 import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
 import org.eclipse.rse.ui.SystemBasePlugin;
@@ -28,114 +28,146 @@ import org.osgi.framework.BundleContext;
 /**
  * The activator class controls the plug-in life cycle
  */
-public class RSESamplesPlugin extends SystemBasePlugin  {
+public class RSESamplesPlugin extends SystemBasePlugin {
 
-	//The shared instance.
+	// The plug-in ID
+	public static final String PLUGIN_ID = "RSESamples";
+
+	// The shared instance
 	private static RSESamplesPlugin plugin;
-
-	//Resource bundle.
+	
+	// ResourceBundle
 	private ResourceBundle resourceBundle = null;
-	private static SystemMessageFile messageFile = null;
+	
+	// Message file
+	private SystemMessageFile messageFile = null;
 	
 	/**
-	 * The constructor.
+	 * The constructor
 	 */
 	public RSESamplesPlugin() {
 		super();
 	}
 
-	/**
-	 * This method is called upon plug-in activation
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
 	 */
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
-		plugin = this;
-		messageFile = getMessageFile("rseSamplesMessages.xml");
+		plugin = this;
 	}
 
-	/**
-	 * This method is called when the plug-in is stopped
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
 	 */
 	public void stop(BundleContext context) throws Exception {
-		plugin = null;
-		resourceBundle = null;
+		plugin = null;
 		super.stop(context);
 	}
-
-	/**
-	 * Returns the shared instance.
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.rse.ui.SystemBasePlugin#initializeImageRegistry()
 	 */
-	public static RSESamplesPlugin getDefault() {
-		return plugin;
-	}
-
+	protected void initializeImageRegistry() {
+	}
+	
 	/**
-	 * Returns the workspace instance.
+	 * Retrieves the string resource bundle associated with this plugin.
+	 * @return the ResourceBundle or null if the bundle could not be loaded.
 	 */
-	public static IWorkspace getWorkspace() {
-		return ResourcesPlugin.getWorkspace();
-	}
-
-	/**
-	 * Returns the string from the plugin's resource bundle,
-	 * or 'key' if not found.
-	 */
-	public static String getResourceString(String key) {
-		ResourceBundle bundle= RSESamplesPlugin.getDefault().getResourceBundle();
+	public ResourceBundle getResourceBundle() {
 		try {
-			return (bundle != null) ? bundle.getString(key) : key;
+			if (resourceBundle == null) {
+				resourceBundle = ResourceBundle.getBundle("rseSamplesResources.properties");
+			}
 		} catch (MissingResourceException e) {
-			return key;
-		}
-	}
-
-	/**
-	 * Returns the plugin's resource bundle,
-	 */
-	public ResourceBundle getResourceBundle() {
-		try {
-			if (resourceBundle == null)
-				resourceBundle = ResourceBundle.getBundle("samples.rseSamplesResources");
-		} catch (MissingResourceException x) {
-			resourceBundle = null;
+			SystemBasePlugin.logError("Missing rseSamplesResources.properties", e);
 		}
 		return resourceBundle;
-	}
-
-	/**
-	 * Initialize the image registry by declaring all of the required graphics.
-	 */
-	protected void initializeImageRegistry()
-	{
 	}
 
 	/**
-	 * Load a message file for this plugin.
-	 * @param messageFileName - the name of the message xml file. Will look for it in this plugin's install folder.
-	 * @return a message file object containing the parsed contents of the message file, or null if not found.
+	 * Retrieves the SystemMessageFile associated with this plugin.
+	 * @return the SystemMessageFile or null if the message file 
+	 * could not be loaded.
 	 */
-	public SystemMessageFile getMessageFile(String messageFileName)
-	{
-		return loadMessageFile(getBundle(), messageFileName);  	
-	}	
-
-	/**
-	 * Return our message file
-	 */
-	public static SystemMessageFile getPluginMessageFile()
-	{
+	public SystemMessageFile getMessageFile() {
+		if (messageFile == null) {
+			messageFile = loadMessageFile(this.getBundle(), "rseSamplesMessages.xml"); //$NON-NLS-1$
+		}
 		return messageFile;
-	}  
+	}
 
 	/**
-	 * Retrieve a message from this plugin's message file
+	 * Retrieves the singleton workspace for this workbench.
+	 * This is a convenience method, fully equivalent to 
+	 * ResourcesPlugin.getWorkspace().
+	 * @return the singleton workspace
 	 */
-	public static SystemMessage getPluginMessage(String msgId)
-	{
-		return getMessage(messageFile, msgId);
-	}
+	public static IWorkspace getWorkspace() {
+		return ResourcesPlugin.getWorkspace();
+	}
+	
+	/**
+	 * Retrieve a string from the plugin's resource bundle.
+	 * @param key the key to the string
+	 * @return the retrieved string or the key if the string could not be
+	 * found or the bundle could not be loaded.
+	 */
+	public static String getResourceString(String key) {
+		String result = null;
+		ResourceBundle bundle = RSESamplesPlugin.getDefault().getResourceBundle();
+		if (bundle != null) {
+			try {
+				result = bundle.getString(key);
+			} catch (MissingResourceException e) {
+				SystemBasePlugin.logError("Missing key in bundle", e);
+			}
+		}
+		if (result == null) {
+			result = key;
+		}
+		return result;
+	}
+	
+	/**
+	 * Retrieve the SystemMessageFile for this plugin.
+	 * @return the SystemMessageFile or null if the message file
+	 * could not be loaded.
+	 */
+	public static SystemMessageFile getPluginMessageFile() {
+		return RSESamplesPlugin.getDefault().getMessageFile();
+	}
+	
+	/**
+	 * Retrieve a SystemMessage from the message file for this 
+	 * plugin given its message id.
+	 * @param messageId the message id to retrieve
+	 * @return the retrieved SystemMessage or null if the message
+	 * was not found in the message file or the message file
+	 * could not be loaded.
+	 */
+	public static SystemMessage getPluginMessage(String messageId) {
+		SystemMessage message = null;
+		SystemMessageFile messageFile = getPluginMessageFile();
+		if (messageFile != null) {
+			message = messageFile.getMessage(messageId); 
+		}
+		return message;
+	}
+	
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static RSESamplesPlugin getDefault() {
+		return plugin;
+	}
+
 }
-
-

+
diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_1.gif b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_1.gif deleted file mode 100755 index 717f78de831..00000000000 Binary files a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_1.gif and /dev/null differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_1.png b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_1.png new file mode 100755 index 00000000000..8831ebad994 Binary files /dev/null and b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_1.png differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page1.gif b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page1.gif deleted file mode 100755 index e4fdfff8d32..00000000000 Binary files a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page1.gif and /dev/null differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page1.png b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page1.png new file mode 100755 index 00000000000..0e6f3fe93e0 Binary files /dev/null and b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page1.png differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page2.png b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page2.png new file mode 100755 index 00000000000..2f7fa753775 Binary files /dev/null and b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page2.png differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page3.gif b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page3.gif deleted file mode 100755 index 5c42bae1bad..00000000000 Binary files a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page3.gif and /dev/null differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page3.png b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page3.png new file mode 100755 index 00000000000..1ea6e43f2dc Binary files /dev/null and b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page3.png differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page4.gif b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page4.gif deleted file mode 100755 index 8bbc87bd968..00000000000 Binary files a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProj_wiz_page4.gif and /dev/null differ diff --git a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProject.html b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProject.html index fd07da1a741..301b4287859 100755 --- a/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProject.html +++ b/rse/doc/org.eclipse.rse.doc.isv/guide/tutorial/pdeProject.html @@ -1,45 +1,66 @@ - + - + Creating a Plug-in Project - -

Creating a Plug-in Project

-

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 MANIFEST.MF file describing the plugin and its dependencies and, if extending the workbench a plugin.xml 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.

-

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.

-

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.

-

The following tutorial uses numbered steps to indicate where you are required to do something as you follow along.

-

Step By Step: Creating an RSE Plug-in Project

-
    -
  1. Select File->New->Project. -
  2. On the left of the dialog box, select Plug-in Development category, and on the right, select the Plug-in Project wizard. Press Next >. -
  3. In the first page of the wizard (Plug-in Project Name), enter "RSESamples" for the project name (without the quotes). Press Next >. -
  4. In the second page of the wizard (Plug-in Project Structure), just take the defaults, and press Next >. -
  5. In the third page of the wizard (Plug-in Code Generators), select "Default Plug-in Structure", and press Next >. -
  6. In the fourth page of the wizard (Simple Plug-in Content), enter your company for the Provider Name, and press Finish. -
  7. Your new plugin project is created and visible in the Package Explorer of the Plug-in Development perspective. Your new plugin.xml file is also open in the plug-in editor. Close this editor, as you will not be using it in this tutorial. - -
  8. Select the plugin.xml file, right click and select Open. Go to the dependencies tab and add the following plugins to the list: - -
  9. Expand the src folder, then the RSESamples package folder, and double-click on RSESamplesPlugin.java to edit this class to make it look like this. - -
  10. Create the project's resources file for translatable strings: right-click on the RSESamples project and select New->File to open the New File wizard. Enter rseSamplesResources.properties for the file name, as was specified in the call to loadResourceBundle in the plug-in class's constructor. Press Finish to create the file. You will populate as you go through the tutorials, so for now just close the editor opened for the file. - -
  11. Create the project's RSE-style messages file for translatable messages: right-click on the RSESamples project and select New->File to get the New File wizard. Enter rseSamplesMessages.xml for the file name, as was specified in the call to loadMessageFile in the plug-in class's constructor. Press Finish to create the file. You will see the XML editor open for the new file. Press the Source tab at the bottom of the editor, and enter the following lines (so that you can add messages to the file later on): -
    
    +
    +

    Creating a Plug-in Project

    +

    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 MANIFEST.MF file describing the plugin and its dependencies and, if extending the workbench a plugin.xml 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.

    +

    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.

    +

    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.

    +

    The following tutorial uses numbered steps to indicate where you are required to do something as you follow along.

    +

    Step By Step: Creating an RSE Plug-in Project

    +
      +
    1. Select File->New->Project.
    2. +
    3. In the dialog box select the Plug-in Project wizard. Click Next >. +
      +
    4. +
    5. In the first page of the wizard enter "RSESamples" for the project name (without the quotes). Click Next >. +
      +
    6. +
    7. In the second page of the wizard enter your company for the Plug-in Provider, change the Activator to be "rsesamples.RSESamplesPlugin", and click Next >. +
      +
    8. +
    9. In the third page of the wizard uncheck the "Create a plug-in using one of the templates" checkbox and click Finish. +
      +
    10. +
    11. Your new plugin project is created and visible in the Package Explorer of the Plug-in Development perspective. Your new plugin.xml file is also open in the plug-in editor.
    12. +
    13. Go to the dependencies tab of the plug-in editor and add the following plugins to the list: +
        +
      • org.eclipse.core.resources
      • +
      • org.eclipse.rse.ui
      • +
      • org.eclipse.rse.services
      • +
      • org.eclipse.rse.files.ui
      • +
      • org.eclipse.rse.shells.ui
      • +
      • org.eclipse.rse.subsystems.files.core
      • +
      • org.eclipse.rse.subsystems.shells.core
      • +
      +Save the plugin.xml file.
    14. +
    15. Expand the src folder, then the rsesamples package folder, and double-click on RSESamplesPlugin.java to edit this class. +Change it as described below. Reference the source here for the details. +
        +
      • Extend SystemBasePlugin instead of AbstractUIPlugin
      • +
      • Add the declaration for resourceBundle
      • +
      • Add the declaration for messageFile
      • +
      • Invoke the superclass constructor from this constructor
      • +
      • Add the initializeImageRegistry() method
      • +
      • Add the getMessageFile() method
      • +
      • Add the getResourceBundle() method
      • +
      • Add the static getWorkspace() method
      • +
      • Add the static getResourceString(String) method
      • +
      • Add the static getPluginMessageFile() method
      • +
      • Add the static getPluginMessage(String) method
      • +
      +
    16. +
    17. Create the project's resources file for translatable strings: right-click on the RSESamples project and select New->File to open the New File wizard. Enter rseSamplesResources.properties for the file name, as was specified in the call to loadResourceBundle in the plug-in class's constructor. Press Finish to create the file. You will populate as you go through the tutorials, so for now just close the editor opened for the file.
    18. +
    19. Create the project's RSE-style messages file for translatable messages: right-click on the RSESamples project and select New->File to get the New File wizard. Enter rseSamplesMessages.xml for the file name, as was specified in the call to loadMessageFile in the plug-in class's constructor. Press Finish to create the file. You will see the XML editor open for the new file. Press the Source tab at the bottom of the editor, and enter the following lines (so that you can add messages to the file later on): +
      
       <?xml version="1.0" encoding='UTF-8'?>
       <!DOCTYPE MessageFile SYSTEM "../org.eclipse.rse.ui/messageFile.dtd">
       <!-- This is a message file used by SystemMessage and SystemMessageDialog -->
      @@ -49,16 +70,17 @@
                       <MessageList>
                           <Message ID="1001" Indicator="E">
                                 <LevelOne>Sample message</LevelOne>		
      -                          <LevelTwo>This is a sample with one substution variable: %1</LevelTwo>
      +                          <LevelTwo>This is a sample with one substitution variable: %1</LevelTwo>
                           </Message>
                       </MessageList>
                 </Subcomponent>
            </Component>
       </MessageFile>
       
      - Save and close the file. -
    20. That's it! Your plugin is created and you are ready to go. Now you only need to add code, to implement the extension points. -
    - - +Save and close the file. +
  12. +
  13. Your plugin is created and you are ready to go. Now you only need to add the code to implement the extension points. +
  14. +
+