001: /*
002: * PluginOptions.java - Plugin options dialog
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 2003 Slava Pestov
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package org.gjt.sp.jedit.options;
024:
025: //{{{ Imports
026: import java.awt.Dialog;
027: import java.awt.Frame;
028: import org.gjt.sp.jedit.gui.OptionsDialog;
029: import org.gjt.sp.jedit.options.*;
030: import org.gjt.sp.jedit.*;
031: import org.gjt.sp.util.Log;
032:
033: //}}}
034:
035: public class PluginOptions extends OptionsDialog {
036: //{{{ PluginOptions constructor
037: public PluginOptions(Frame frame) {
038: super (frame, "plugin-options", jEdit
039: .getProperty("plugin-options.last"));
040: } //}}}
041:
042: //{{{ PluginOptions constructor
043: public PluginOptions(Frame frame, String pane) {
044: super (frame, "plugin-options", pane);
045: } //}}}
046:
047: //{{{ PluginOptions constructor
048: public PluginOptions(Dialog dialog) {
049: super (dialog, "plugin-options", jEdit
050: .getProperty("plugin-options.last"));
051: } //}}}
052:
053: //{{{ PluginOptions constructor
054: public PluginOptions(Dialog dialog, String pane) {
055: super (dialog, "plugin-options", pane);
056: } //}}}
057:
058: //{{{ createOptionTreeModel() method
059: protected OptionTreeModel createOptionTreeModel() {
060: OptionTreeModel paneTreeModel = new OptionTreeModel();
061: OptionGroup rootGroup = (OptionGroup) paneTreeModel.getRoot();
062:
063: // initialize the Plugins branch of the options tree
064: pluginsGroup = new OptionGroup("plugins");
065: pluginsGroup.setSort(true);
066:
067: // Query plugins for option panes
068: EditPlugin[] plugins = jEdit.getPlugins();
069: for (int i = 0; i < plugins.length; i++) {
070: EditPlugin ep = plugins[i];
071: if (ep instanceof EditPlugin.Broken)
072: continue;
073:
074: String className = ep.getClassName();
075: if (jEdit.getProperty("plugin." + className + ".activate") == null) {
076: // Old API
077: try {
078: ep.createOptionPanes(this );
079: } catch (Throwable t) {
080: Log
081: .log(Log.ERROR, ep,
082: "Error creating option pane");
083: Log.log(Log.ERROR, ep, t);
084: }
085: } else {
086: String optionPane = jEdit.getProperty("plugin."
087: + className + ".option-pane");
088: if (optionPane != null)
089: pluginsGroup.addOptionPane(optionPane);
090: else {
091: String options = jEdit.getProperty("plugin."
092: + className + ".option-group");
093: if (options != null) {
094: pluginsGroup.addOptionGroup(new OptionGroup(
095: "plugin." + className, jEdit
096: .getProperty("plugin."
097: + className + ".name"),
098: options));
099: }
100: }
101: }
102: }
103:
104: // only add the Plugins branch if there are OptionPanes
105: if (pluginsGroup.getMemberCount() == 0)
106: pluginsGroup.addOptionPane(new NoPluginsPane());
107:
108: rootGroup.addOptionGroup(pluginsGroup);
109:
110: return paneTreeModel;
111: } //}}}
112:
113: //{{{ getDefaultGroup() method
114: protected OptionGroup getDefaultGroup() {
115: return pluginsGroup;
116: } //}}}
117:
118: //{{{ Private members
119: private OptionGroup pluginsGroup;
120:
121: //}}}
122:
123: //{{{ NoPluginsPane class
124: public static class NoPluginsPane extends AbstractOptionPane {
125: public NoPluginsPane() {
126: super ("no-plugins");
127: }
128: } //}}}
129: }
|