PageRenderTime 38ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/options/PluginOptions.java

#
Java | 131 lines | 80 code | 16 blank | 35 comment | 10 complexity | cd60a68b4623fae28867d00251b51c2c 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
  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. package org.gjt.sp.jedit.options;
  23. //{{{ Imports
  24. import java.awt.Dialog;
  25. import java.awt.Frame;
  26. import org.gjt.sp.jedit.gui.OptionsDialog;
  27. import org.gjt.sp.jedit.options.*;
  28. import org.gjt.sp.jedit.*;
  29. import org.gjt.sp.util.Log;
  30. //}}}
  31. public class PluginOptions extends OptionsDialog
  32. {
  33. //{{{ PluginOptions constructor
  34. public PluginOptions(Frame frame)
  35. {
  36. super(frame,"plugin-options",jEdit.getProperty("plugin-options.last"));
  37. } //}}}
  38. //{{{ PluginOptions constructor
  39. public PluginOptions(Frame frame, String pane)
  40. {
  41. super(frame,"plugin-options",pane);
  42. } //}}}
  43. //{{{ PluginOptions constructor
  44. public PluginOptions(Dialog dialog)
  45. {
  46. super(dialog,"plugin-options",jEdit.getProperty("plugin-options.last"));
  47. } //}}}
  48. //{{{ PluginOptions constructor
  49. public PluginOptions(Dialog dialog, String pane)
  50. {
  51. super(dialog,"plugin-options",pane);
  52. } //}}}
  53. //{{{ createOptionTreeModel() method
  54. protected OptionTreeModel createOptionTreeModel()
  55. {
  56. OptionTreeModel paneTreeModel = new OptionTreeModel();
  57. OptionGroup rootGroup = (OptionGroup) paneTreeModel.getRoot();
  58. // initialize the Plugins branch of the options tree
  59. pluginsGroup = new OptionGroup("plugins");
  60. pluginsGroup.setSort(true);
  61. // Query plugins for option panes
  62. EditPlugin[] plugins = jEdit.getPlugins();
  63. for(int i = 0; i < plugins.length; i++)
  64. {
  65. EditPlugin ep = plugins[i];
  66. if(ep instanceof EditPlugin.Broken)
  67. continue;
  68. String className = ep.getClassName();
  69. if (jEdit.getProperty("plugin." + className + ".activate") != null)
  70. {
  71. String optionPane = jEdit.getProperty(
  72. "plugin." + className + ".option-pane");
  73. if(optionPane != null)
  74. pluginsGroup.addOptionPane(optionPane);
  75. else
  76. {
  77. String options = jEdit.getProperty(
  78. "plugin." + className
  79. + ".option-group");
  80. if(options != null)
  81. {
  82. pluginsGroup.addOptionGroup(
  83. new OptionGroup(
  84. "plugin." + className,
  85. jEdit.getProperty("plugin."
  86. + className + ".name"),
  87. options)
  88. );
  89. }
  90. }
  91. }
  92. }
  93. // only add the Plugins branch if there are OptionPanes
  94. if (pluginsGroup.getMemberCount() == 0)
  95. pluginsGroup.addOptionPane(new NoPluginsPane());
  96. rootGroup.addOptionGroup(pluginsGroup);
  97. return paneTreeModel;
  98. } //}}}
  99. //{{{ getDefaultGroup() method
  100. protected OptionGroup getDefaultGroup()
  101. {
  102. return pluginsGroup;
  103. } //}}}
  104. //{{{ Private members
  105. private OptionGroup pluginsGroup;
  106. //}}}
  107. //{{{ NoPluginsPane class
  108. public static class NoPluginsPane extends AbstractOptionPane
  109. {
  110. public NoPluginsPane()
  111. {
  112. super("no-plugins");
  113. }
  114. } //}}}
  115. }