/jEdit/tags/jedit-4-0-pre3/org/gjt/sp/jedit/EditPlugin.java
Java | 179 lines | 78 code | 23 blank | 78 comment | 2 complexity | 63d795164bb2e15ad65359b5ce4ff1b3 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /*
- * EditPlugin.java - Interface all plugins must implement
- * Copyright (C) 1999, 2000 Slava Pestov
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- package org.gjt.sp.jedit;
- import java.util.Vector;
- import org.gjt.sp.jedit.gui.OptionsDialog;
- /**
- * The interface between jEdit and a plugin.
- *
- * @author Slava Pestov
- * @version $Id: EditPlugin.java 3825 2001-10-02 13:54:14Z spestov $
- * @since jEdit 2.1pre1
- */
- public abstract class EditPlugin
- {
- /**
- * Returns the plugin's class name.
- *
- * @since jEdit 2.5pre3
- */
- public String getClassName()
- {
- return getClass().getName();
- }
- /**
- * Method called by jEdit to initialize the plugin.
- * Actions and edit modes should be registered here, along
- * with any EditBus paraphinalia.
- * @since jEdit 2.1pre1
- */
- public void start() {}
- /**
- * Method called by jEdit before exiting. Usually, nothing
- * needs to be done here.
- * @since jEdit 2.1pre1
- */
- public void stop() {}
- /**
- * Method called every time a view is created to set up the
- * Plugins menu. Menus and menu items should be loaded using the
- * methods in the GUIUtilities class, and added to the vector.
- * @param menuItems Add menus and menu items here
- *
- * @see GUIUtilities#loadMenu(String)
- * @see GUIUtilities#loadMenuItem(String)
- *
- * @since jEdit 2.6pre5
- */
- public void createMenuItems(Vector menuItems) {}
- /**
- * Method called every time the plugin options dialog box is
- * displayed. Any option panes created by the plugin should be
- * added here.
- * @param optionsDialog The plugin options dialog box
- *
- * @see OptionPane
- * @see OptionsDialog#addOptionPane(OptionPane)
- *
- * @since jEdit 2.1pre1
- */
- public void createOptionPanes(OptionsDialog optionsDialog) {}
- /**
- * Returns the JAR file containing this plugin.
- * @since jEdit 3.1pre5
- */
- public EditPlugin.JAR getJAR()
- {
- return jar;
- }
- /**
- * A placeholder for a plugin that didn't load.
- */
- public static class Broken extends EditPlugin
- {
- public String getClassName()
- {
- return clazz;
- }
- // package-private members
- Broken(String clazz)
- {
- this.clazz = clazz;
- }
- // private members
- private String clazz;
- }
- /**
- * A JAR file.
- */
- public static class JAR
- {
- public String getPath()
- {
- return path;
- }
- public JARClassLoader getClassLoader()
- {
- return classLoader;
- }
- public ActionSet getActions()
- {
- return actions;
- }
- public void addPlugin(EditPlugin plugin)
- {
- plugin.jar = JAR.this;
- plugin.start();
- if(plugin instanceof EBPlugin)
- EditBus.addToBus((EBPlugin)plugin);
- plugins.addElement(plugin);
- }
- public EditPlugin[] getPlugins()
- {
- EditPlugin[] array = new EditPlugin[plugins.size()];
- plugins.copyInto(array);
- return array;
- }
- public JAR(String path, JARClassLoader classLoader)
- {
- this.path = path;
- this.classLoader = classLoader;
- plugins = new Vector();
- actions = new ActionSet();
- }
- // package-private members
- void getPlugins(Vector vector)
- {
- for(int i = 0; i < plugins.size(); i++)
- {
- vector.addElement(plugins.elementAt(i));
- }
- }
- // private members
- private String path;
- private JARClassLoader classLoader;
- private Vector plugins;
- private ActionSet actions;
- }
- // private members
- private EditPlugin.JAR jar;
- }