home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / edtplug / classes / netscape / plugin / composer / Plugin.java < prev    next >
Encoding:
Java Source  |  1998-04-08  |  5.8 KB  |  127 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. package netscape.plugin.composer;
  20.  
  21. import java.io.IOException;
  22. import java.util.ResourceBundle;
  23.  
  24. /** Plugins allow arbitrary transformations of the composer's current document.
  25.  * All composer plugins descend from this class. When the user invokes a plugin,
  26.  * the plugin's perform method is called with the current document. The plugin
  27.  * can then examine the existing document and modify it.
  28.  *
  29.  * Plugins are like Applet or Application, in that they are the main class of your
  30.  * mini appication. This is where the flow of control transfers from the editor to
  31.  * you.
  32.  *
  33.  * Your plugin is instantiated when the first composer window is opened, and is
  34.  * deleted when the application exits.
  35.  *
  36.  * The document can change arbitrarily between calls to perform. You may even be
  37.  * given two different documents on two successive calls to perform.
  38.  *<p>
  39.  * Categories are used in the user interface to collect plugins into groups that
  40.  * are meaningful to users. You can use your own category to put all of your
  41.  * product's plugins into one category. Or, you can place your plugins into
  42.  * several categories. It's up to you.
  43.  *
  44.  * <p>Packageing Plugins
  45.  * <p>To package your plugin, create an uncompressed zip file with the file name
  46.  * cpXXX.zip, where XXX can be anything you want. (It has to be unique, so use
  47.  * your company name, or the plugin name, or something like that.)
  48.  * Put all your classes into that .zip file. At the top level of the .zip archive,
  49.  * add a file called "netscape_plugin_composer.ini".
  50.  * <p> Format of the "netscape_plugin_composer.ini" file.
  51.  * <p> It is in standard java "Properties" file format.
  52.  * The following properties are 'well known', and are used by the composer plugin
  53.  * framework:
  54.  * <pre>
  55.  * netscape.plugin.composer.factory - a single classname of a Factory class.
  56.  * netscape.plugin.composer.classes - a colon-seperated list of the classnames of
  57.  *     the plugins in this archive.
  58.  * netscape.plugin.composer.eventHandlers - a colon-seperated list of the classnames
  59.  *     of the plugins in this archive to execute when an event happens. See Document
  60.  *     for a list of the standard events.
  61.  * </pre>
  62.  * <p> Your plugin's class name should be listed as the value of the netscape.plugin.composer.classes
  63.  * property. You can place several plugins in the same plugin file. All the plugin names should be
  64.  * listed in the netscape.plugin.composer.classes property.
  65.  * <p> Alternatively, you can use a factory class to create your plugins at runtime.
  66.  * <p>Installing the Plugin
  67.  * <p> Put that .zip file in the Netscape Plugins directory (or a subdirectory.) Then restart the
  68.  * Composer application.
  69.  * @see netscape.plugin.composer.Factory
  70.  * @see netscape.plugin.composer.Document
  71.  *
  72.  */
  73. public class Plugin {
  74.     /** The default constructor for a Plugin. If you have a default constructor, it must be public.
  75.      * so that your plugin can be instantiated by name. (Also, your plugin class must be a public
  76.      * class so that it can be instantiated by name.)
  77.      */
  78.     public Plugin() {}
  79.  
  80.     /** Get the human readable name of the plugin. Defaults to the name of the plugin class. This
  81.      * text will show up as the text of a menu item.
  82.      * @return the human readable name of the plugin.
  83.      */
  84.     public String getName()
  85.     {
  86.         return getClass().getName();
  87.     }
  88.  
  89.     /** Get the human readable category text of the plugin. Defaults to the name of the plugin class. This
  90.      * text will show up as the title of a menu that contains the plugin. If several plugins use the
  91.      * same category, they will all show up in the same menu.
  92.      * @return the human readable category of the plugin.
  93.      */
  94.     public String getCategory()
  95.     {
  96.         return getClass().getName();
  97.     }
  98.  
  99.     /** Get the human readable hint text for the plugin. This is a one-sentence description of
  100.      * what the plugin does. Defaults to the name of the plugin class. This text will
  101.      * show up in the status line as the user moves the mouse over the plug-in's menu item.
  102.      * @return the human readable hint for the plugin.
  103.      */
  104.     public String getHint()
  105.     {
  106.         return getClass().getName();
  107.     }
  108.  
  109.     /** Execute the plugin.
  110.      * Override this method to perform the bulk of your work.
  111.      * This is where your plugin gets the text out of the document, analyzes it, interacts
  112.      * with the user, and modifies the text of the document.
  113.      * <p>
  114.      * The rest of the composer user interface is held in a modal state while your plugin
  115.      * is executing. So either finish quickly, or display a progress dialog, or otherwise
  116.      * let the user know what's going on.
  117.      * <p>
  118.      * By default this method returns false.
  119.      * @param document the current document.
  120.      * @return true if the changes to the document should be permenent. False if the
  121.      * changes should be cancled. (Return false if the user Cancels the operation.)
  122.      */
  123.     public boolean perform(Document document) throws IOException {
  124.         return false;
  125.     }
  126. }
  127.