/plugins/Sessions/tags/sessions_1_2_3/sessions/SessionsOptionPane.java

# · Java · 162 lines · 106 code · 32 blank · 24 comment · 3 complexity · a1bf519572b6f6b38422f7be953bc626 MD5 · raw file

  1. /*
  2. * SessionsOptionPane.java - plugin options pane for Sessions plugin
  3. * Copyright (c) 2000,2001 Dirk Moebius
  4. *
  5. * :tabSize=4:indentSize=4:noTabs=false:maxLineLen=0:
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. package sessions;
  22. import java.awt.event.ActionEvent;
  23. import java.awt.event.ActionListener;
  24. import javax.swing.ButtonGroup;
  25. import javax.swing.JCheckBox;
  26. import javax.swing.JRadioButton;
  27. import org.gjt.sp.jedit.jEdit;
  28. import org.gjt.sp.jedit.AbstractOptionPane;
  29. /**
  30. * This is the option pane that jEdit displays for Session plugin's options.
  31. */
  32. public class SessionsOptionPane extends AbstractOptionPane implements ActionListener
  33. {
  34. private JCheckBox bAutoSave;
  35. private JCheckBox bCloseAll;
  36. private JCheckBox bShowToolBar;
  37. private JRadioButton bShowBelowToolBar;
  38. private JRadioButton bShowJEditToolBar;
  39. private JRadioButton bShowInsideBufferList;
  40. private JCheckBox bShowTitle;
  41. private JCheckBox bChangeFSBDirectory;
  42. private JCheckBox bShowSessionNameInTitleBar;
  43. private JCheckBox bShowSessionPrefixInTitleBar;
  44. public SessionsOptionPane()
  45. {
  46. super("sessions");
  47. }
  48. public void _init()
  49. {
  50. bAutoSave = new JCheckBox(
  51. jEdit.getProperty("options.sessions.switcher.autoSave"),
  52. jEdit.getBooleanProperty("sessions.switcher.autoSave", true)
  53. );
  54. bCloseAll = new JCheckBox(
  55. jEdit.getProperty("options.sessions.switcher.closeAll"),
  56. jEdit.getBooleanProperty("sessions.switcher.closeAll", true)
  57. );
  58. bShowToolBar = new JCheckBox(
  59. jEdit.getProperty("options.sessions.switcher.showToolBar"),
  60. jEdit.getBooleanProperty("sessions.switcher.showToolBar", false)
  61. );
  62. bShowToolBar.addActionListener(this);
  63. boolean showJEditToolBar = jEdit.getBooleanProperty("sessions.switcher.showJEditToolBar", false);
  64. boolean showInsideBufferList = jEdit.getBooleanProperty("sessions.switcher.showInsideBufferList", false);
  65. boolean showBelowToolBar = !(showJEditToolBar || showInsideBufferList);
  66. bShowJEditToolBar = new JRadioButton(jEdit.getProperty("options.sessions.switcher.showJEditToolBar"), showJEditToolBar);
  67. bShowJEditToolBar.setEnabled(bShowToolBar.isSelected());
  68. bShowInsideBufferList = new JRadioButton(jEdit.getProperty("options.sessions.switcher.showInsideBufferList"), showInsideBufferList);
  69. bShowInsideBufferList.setEnabled(bShowToolBar.isSelected() && isBufferListAvailable());
  70. bShowBelowToolBar = new JRadioButton(jEdit.getProperty("options.sessions.switcher.showBelowToolBar"), showBelowToolBar);
  71. bShowBelowToolBar.setEnabled(bShowToolBar.isSelected());
  72. ButtonGroup group = new ButtonGroup();
  73. group.add(bShowJEditToolBar);
  74. group.add(bShowInsideBufferList);
  75. group.add(bShowBelowToolBar);
  76. bShowTitle = new JCheckBox(
  77. jEdit.getProperty("options.sessions.switcher.showTitle"),
  78. jEdit.getBooleanProperty("sessions.switcher.showTitle", true)
  79. );
  80. bShowTitle.setEnabled(bShowToolBar.isSelected());
  81. bChangeFSBDirectory = new JCheckBox(
  82. jEdit.getProperty("options.sessions.switcher.changeFSBDirectory"),
  83. jEdit.getBooleanProperty("sessions.switcher.changeFSBDirectory", false)
  84. );
  85. bShowSessionNameInTitleBar = new JCheckBox(
  86. jEdit.getProperty("options.sessions.switcher.showSessionNameInTitleBar"),
  87. jEdit.getBooleanProperty("sessions.switcher.showSessionNameInTitleBar", true)
  88. );
  89. bShowSessionNameInTitleBar.addActionListener(this);
  90. bShowSessionPrefixInTitleBar = new JCheckBox(
  91. jEdit.getProperty("options.sessions.switcher.showSessionPrefixInTitleBar"),
  92. jEdit.getBooleanProperty("sessions.switcher.showSessionPrefixInTitleBar", true)
  93. );
  94. addComponent(bAutoSave);
  95. addComponent(bCloseAll);
  96. addComponent(bShowToolBar);
  97. addComponent(" ", bShowBelowToolBar);
  98. addComponent(" ", bShowJEditToolBar);
  99. addComponent(" ", bShowInsideBufferList);
  100. addComponent(" ", bShowTitle);
  101. addComponent(bChangeFSBDirectory);
  102. addComponent(bShowSessionNameInTitleBar);
  103. addComponent(" ", bShowSessionPrefixInTitleBar);
  104. }
  105. public void _save()
  106. {
  107. jEdit.setBooleanProperty("sessions.switcher.autoSave", bAutoSave.isSelected());
  108. jEdit.setBooleanProperty("sessions.switcher.closeAll", bCloseAll.isSelected());
  109. jEdit.setBooleanProperty("sessions.switcher.showToolBar", bShowToolBar.isSelected());
  110. jEdit.setBooleanProperty("sessions.switcher.showJEditToolBar", bShowJEditToolBar.isSelected());
  111. jEdit.setBooleanProperty("sessions.switcher.showInsideBufferList", bShowInsideBufferList.isSelected());
  112. jEdit.setBooleanProperty("sessions.switcher.showTitle", bShowTitle.isSelected());
  113. jEdit.setBooleanProperty("sessions.switcher.changeFSBDirectory", bChangeFSBDirectory.isSelected());
  114. jEdit.setBooleanProperty("sessions.switcher.showSessionNameInTitleBar", bShowSessionNameInTitleBar.isSelected());
  115. jEdit.setBooleanProperty("sessions.switcher.showSessionPrefixInTitleBar", bShowSessionPrefixInTitleBar.isSelected());
  116. }
  117. public void actionPerformed(ActionEvent e)
  118. {
  119. bShowBelowToolBar.setEnabled(bShowToolBar.isSelected());
  120. bShowJEditToolBar.setEnabled(bShowToolBar.isSelected());
  121. bShowInsideBufferList.setEnabled(bShowToolBar.isSelected() && isBufferListAvailable());
  122. bShowTitle.setEnabled(bShowToolBar.isSelected());
  123. bShowSessionPrefixInTitleBar.setEnabled(bShowSessionNameInTitleBar.isSelected());
  124. }
  125. private boolean isBufferListAvailable()
  126. {
  127. // FIXME: is it sufficient to check only first view?!?
  128. return SessionsPlugin.isBufferListAvailable(jEdit.getFirstView());
  129. }
  130. }