PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/org/gjt/sp/jedit/options/PluginOptions.java

#
Java | 145 lines | 93 code | 16 blank | 36 comment | 10 complexity | bc29e93351d511b93dafee5d87e2780e 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. // Old API
  72. try
  73. {
  74. ep.createOptionPanes(this);
  75. }
  76. catch(Throwable t)
  77. {
  78. Log.log(Log.ERROR, ep,
  79. "Error creating option pane");
  80. Log.log(Log.ERROR, ep, t);
  81. }
  82. }
  83. else
  84. {
  85. String optionPane = jEdit.getProperty(
  86. "plugin." + className + ".option-pane");
  87. if(optionPane != null)
  88. pluginsGroup.addOptionPane(optionPane);
  89. else
  90. {
  91. String options = jEdit.getProperty(
  92. "plugin." + className
  93. + ".option-group");
  94. if(options != null)
  95. {
  96. pluginsGroup.addOptionGroup(
  97. new OptionGroup(
  98. "plugin." + className,
  99. jEdit.getProperty("plugin."
  100. + className + ".name"),
  101. options)
  102. );
  103. }
  104. }
  105. }
  106. }
  107. // only add the Plugins branch if there are OptionPanes
  108. if (pluginsGroup.getMemberCount() == 0)
  109. pluginsGroup.addOptionPane(new NoPluginsPane());
  110. rootGroup.addOptionGroup(pluginsGroup);
  111. return paneTreeModel;
  112. } //}}}
  113. //{{{ getDefaultGroup() method
  114. protected OptionGroup getDefaultGroup()
  115. {
  116. return pluginsGroup;
  117. } //}}}
  118. //{{{ Private members
  119. private OptionGroup pluginsGroup;
  120. //}}}
  121. //{{{ NoPluginsPane class
  122. static class NoPluginsPane extends AbstractOptionPane
  123. {
  124. public NoPluginsPane()
  125. {
  126. super("no-plugins");
  127. }
  128. } //}}}
  129. }