PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/Console/console/options/ToolBarOptionPane.java

#
Java | 113 lines | 61 code | 22 blank | 30 comment | 2 complexity | 5c06cafee9b545042341c20b1fca6c1a 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. * ToolBarOptionPane
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2005 Alan Ezust
  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 console.options;
  23. // {{{ imports
  24. import java.awt.GridLayout;
  25. import java.util.TreeMap;
  26. import javax.swing.JCheckBox;
  27. import javax.swing.JPanel;
  28. import org.gjt.sp.jedit.AbstractOptionPane;
  29. import org.gjt.sp.jedit.ActionSet;
  30. import org.gjt.sp.jedit.EditAction;
  31. import org.gjt.sp.jedit.jEdit;
  32. import console.ConsolePlugin;
  33. import console.commando.CommandoCommand;
  34. import console.commando.CommandoToolBar;
  35. // }}}
  36. public class ToolBarOptionPane extends AbstractOptionPane
  37. {
  38. // {{{ public ToolBarOptionPane()
  39. public ToolBarOptionPane()
  40. {
  41. super("console.toolbar");
  42. }
  43. // }}}
  44. // {{{ public void _init()
  45. protected void _init()
  46. {
  47. addComponent(enabledCheckBox = new JCheckBox(jEdit
  48. .getProperty("options.console.general.commando.toolbar")));
  49. enabledCheckBox.getModel().setSelected(
  50. jEdit.getBooleanProperty("commando.toolbar.enabled"));
  51. createButtons();
  52. }
  53. // }}}
  54. // {{{ protected void createButtons()
  55. protected void createButtons()
  56. {
  57. checkBoxes.clear();
  58. ActionSet allActions = ConsolePlugin.getAllCommands();
  59. GridLayout glayout = new GridLayout(0, 3);
  60. addSeparator("options.console.toolbar.buttons");
  61. JPanel buttonPanel = new JPanel();
  62. buttonPanel.setLayout(glayout);
  63. for (EditAction ea : allActions.getActions())
  64. {
  65. CommandoCommand cc = (CommandoCommand) ea;
  66. String label = cc.getShortLabel();
  67. JCheckBox cb = new JCheckBox(label);
  68. boolean selected = jEdit.getBooleanProperty("commando.visible." + label,
  69. true);
  70. cb.setSelected(selected);
  71. checkBoxes.put(label, cb);
  72. buttonPanel.add(cb);
  73. }
  74. addComponent(buttonPanel);
  75. } // }}}
  76. // {{{ protected void _save()
  77. protected void _save()
  78. {
  79. jEdit.setBooleanProperty("commando.toolbar.enabled", enabledCheckBox.isSelected());
  80. for (JCheckBox cb : checkBoxes.values())
  81. {
  82. jEdit.setBooleanProperty("commando.visible." + cb.getText(), cb
  83. .isSelected());
  84. }
  85. jEdit.saveSettings();
  86. CommandoToolBar.init();
  87. }
  88. // }}}
  89. private JCheckBox enabledCheckBox;
  90. TreeMap<String, JCheckBox> checkBoxes = new TreeMap<String, JCheckBox>();
  91. }