KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > options > PluginOptions


1 /*
2  * PluginOptions.java - Plugin options dialog
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 2003 Slava Pestov
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */

22
23 package org.gjt.sp.jedit.options;
24
25 //{{{ Imports
26
import java.awt.Dialog JavaDoc;
27 import java.awt.Frame JavaDoc;
28 import org.gjt.sp.jedit.gui.OptionsDialog;
29 import org.gjt.sp.jedit.options.*;
30 import org.gjt.sp.jedit.*;
31 import org.gjt.sp.util.Log;
32 //}}}
33

34 public class PluginOptions extends OptionsDialog
35 {
36     //{{{ PluginOptions constructor
37
public PluginOptions(Frame JavaDoc frame)
38     {
39         super(frame,"plugin-options",jEdit.getProperty("plugin-options.last"));
40     } //}}}
41

42     //{{{ PluginOptions constructor
43
public PluginOptions(Frame JavaDoc frame, String JavaDoc pane)
44     {
45         super(frame,"plugin-options",pane);
46     } //}}}
47

48     //{{{ PluginOptions constructor
49
public PluginOptions(Dialog JavaDoc dialog)
50     {
51         super(dialog,"plugin-options",jEdit.getProperty("plugin-options.last"));
52     } //}}}
53

54     //{{{ PluginOptions constructor
55
public PluginOptions(Dialog JavaDoc dialog, String JavaDoc pane)
56     {
57         super(dialog,"plugin-options",pane);
58     } //}}}
59

60     //{{{ createOptionTreeModel() method
61
protected OptionTreeModel createOptionTreeModel()
62     {
63         OptionTreeModel paneTreeModel = new OptionTreeModel();
64         OptionGroup rootGroup = (OptionGroup) paneTreeModel.getRoot();
65
66         // initialize the Plugins branch of the options tree
67
pluginsGroup = new OptionGroup("plugins");
68         pluginsGroup.setSort(true);
69
70         // Query plugins for option panes
71
EditPlugin[] plugins = jEdit.getPlugins();
72         for(int i = 0; i < plugins.length; i++)
73         {
74             EditPlugin ep = plugins[i];
75             if(ep instanceof EditPlugin.Broken)
76                 continue;
77
78             String JavaDoc className = ep.getClassName();
79             if(jEdit.getProperty("plugin." + className + ".activate") == null)
80             {
81                 // Old API
82
try
83                 {
84                     ep.createOptionPanes(this);
85                 }
86                 catch(Throwable JavaDoc t)
87                 {
88                     Log.log(Log.ERROR, ep,
89                         "Error creating option pane");
90                     Log.log(Log.ERROR, ep, t);
91                 }
92             }
93             else
94             {
95                 String JavaDoc optionPane = jEdit.getProperty(
96                     "plugin." + className + ".option-pane");
97                 if(optionPane != null)
98                     pluginsGroup.addOptionPane(optionPane);
99                 else
100                 {
101                     String JavaDoc options = jEdit.getProperty(
102                         "plugin." + className
103                         + ".option-group");
104                     if(options != null)
105                     {
106                         pluginsGroup.addOptionGroup(
107                             new OptionGroup(
108                             "plugin." + className,
109                             jEdit.getProperty("plugin."
110                             + className + ".name"),
111                             options)
112                         );
113                     }
114                 }
115             }
116         }
117
118         // only add the Plugins branch if there are OptionPanes
119
if (pluginsGroup.getMemberCount() == 0)
120             pluginsGroup.addOptionPane(new NoPluginsPane());
121
122         rootGroup.addOptionGroup(pluginsGroup);
123
124         return paneTreeModel;
125     } //}}}
126

127     //{{{ getDefaultGroup() method
128
protected OptionGroup getDefaultGroup()
129     {
130         return pluginsGroup;
131     } //}}}
132

133     //{{{ Private members
134
private OptionGroup pluginsGroup;
135     //}}}
136

137     //{{{ NoPluginsPane class
138
public static class NoPluginsPane extends AbstractOptionPane
139     {
140         public NoPluginsPane()
141         {
142             super("no-plugins");
143         }
144     } //}}}
145
}
146
Popular Tags