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

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/options/ViewOptionPane.java

#
Java | 172 lines | 123 code | 17 blank | 32 comment | 34 complexity | 6a1c6ec624554ec70ec519e939c711ca 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. * ViewOptionPane.java - Editor window options
  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. import javax.swing.border.*;
  24. import javax.swing.*;
  25. import java.awt.event.*;
  26. import java.awt.*;
  27. import java.io.*;
  28. import org.gjt.sp.jedit.*;
  29. import org.gjt.sp.util.Log;
  30. public class ViewOptionPane extends AbstractOptionPane
  31. {
  32. //{{{ ViewOptionPane constructor
  33. public ViewOptionPane()
  34. {
  35. super("view");
  36. } //}}}
  37. //{{{ _init() method
  38. protected void _init()
  39. {
  40. /* View dock layout */
  41. layoutIcon1 = GUIUtilities.loadIcon("dock_layout1.png");
  42. layoutIcon2 = GUIUtilities.loadIcon("dock_layout2.png");
  43. layoutIcon3 = GUIUtilities.loadIcon("dock_layout3.png");
  44. layoutIcon4 = GUIUtilities.loadIcon("dock_layout4.png");
  45. JPanel layoutPanel = new JPanel(new BorderLayout(12,12));
  46. if(jEdit.getBooleanProperty("view.docking.alternateLayout"))
  47. {
  48. layout = new JLabel(jEdit.getBooleanProperty(
  49. "view.toolbar.alternateLayout")
  50. ? layoutIcon4 : layoutIcon2);
  51. }
  52. else
  53. {
  54. layout = new JLabel(jEdit.getBooleanProperty(
  55. "view.toolbar.alternateLayout")
  56. ? layoutIcon3 : layoutIcon1);
  57. }
  58. layout.setBorder(new EmptyBorder(12,12,12,12));
  59. layoutPanel.add(BorderLayout.CENTER,layout);
  60. JPanel buttons = new JPanel(new GridLayout(2,1,12,12));
  61. buttons.setBorder(new EmptyBorder(0,12,12,12));
  62. buttons.add(alternateDockingLayout = new JButton(jEdit.getProperty(
  63. "options.view.alternateDockingLayout")));
  64. alternateDockingLayout.addActionListener(new ActionHandler());
  65. buttons.add(alternateToolBarLayout = new JButton(jEdit.getProperty(
  66. "options.view.alternateToolBarLayout")));
  67. alternateToolBarLayout.addActionListener(new ActionHandler());
  68. layoutPanel.add(BorderLayout.SOUTH,buttons);
  69. TitledBorder border = new TitledBorder(jEdit.getProperty(
  70. "options.view.viewLayout"));
  71. border.setTitleJustification(TitledBorder.CENTER);
  72. layoutPanel.setBorder(border);
  73. addComponent(layoutPanel);
  74. /* Show full path */
  75. showFullPath = new JCheckBox(jEdit.getProperty(
  76. "options.view.showFullPath"));
  77. showFullPath.setSelected(jEdit.getBooleanProperty(
  78. "view.showFullPath"));
  79. addComponent(showFullPath);
  80. /* Show search bar */
  81. showSearchbar = new JCheckBox(jEdit.getProperty(
  82. "options.view.showSearchbar"));
  83. showSearchbar.setSelected(jEdit.getBooleanProperty(
  84. "view.showSearchbar"));
  85. addComponent(showSearchbar);
  86. /* Beep on search auto wrap */
  87. beepOnSearchAutoWrap = new JCheckBox(jEdit.getProperty(
  88. "options.view.beepOnSearchAutoWrap"));
  89. beepOnSearchAutoWrap.setSelected(jEdit.getBooleanProperty(
  90. "search.beepOnSearchAutoWrap"));
  91. addComponent(beepOnSearchAutoWrap);
  92. /* Show buffer switcher */
  93. showBufferSwitcher = new JCheckBox(jEdit.getProperty(
  94. "options.view.showBufferSwitcher"));
  95. showBufferSwitcher.setSelected(jEdit.getBooleanProperty(
  96. "view.showBufferSwitcher"));
  97. addComponent(showBufferSwitcher);
  98. } //}}}
  99. //{{{ _save() method
  100. protected void _save()
  101. {
  102. jEdit.setBooleanProperty("view.docking.alternateLayout",
  103. layout.getIcon() == layoutIcon2
  104. || layout.getIcon() == layoutIcon4);
  105. jEdit.setBooleanProperty("view.toolbar.alternateLayout",
  106. layout.getIcon() == layoutIcon3
  107. || layout.getIcon() == layoutIcon4);
  108. jEdit.setBooleanProperty("view.showFullPath",showFullPath
  109. .isSelected());
  110. jEdit.setBooleanProperty("view.showSearchbar",showSearchbar
  111. .isSelected());
  112. jEdit.setBooleanProperty("search.beepOnSearchAutoWrap",beepOnSearchAutoWrap
  113. .isSelected());
  114. jEdit.setBooleanProperty("view.showBufferSwitcher",
  115. showBufferSwitcher.isSelected());
  116. } //}}}
  117. //{{{ Private members
  118. private JLabel layout;
  119. private Icon layoutIcon1, layoutIcon2, layoutIcon3, layoutIcon4;
  120. private JButton alternateDockingLayout, alternateToolBarLayout;
  121. private JCheckBox showFullPath;
  122. private JCheckBox showSearchbar;
  123. private JCheckBox beepOnSearchAutoWrap;
  124. private JCheckBox showBufferSwitcher;
  125. //}}}
  126. //{{{ ActionHandler class
  127. class ActionHandler implements ActionListener
  128. {
  129. public void actionPerformed(ActionEvent evt)
  130. {
  131. if(evt.getSource() == alternateDockingLayout)
  132. {
  133. if(layout.getIcon() == layoutIcon1)
  134. layout.setIcon(layoutIcon2);
  135. else if(layout.getIcon() == layoutIcon2)
  136. layout.setIcon(layoutIcon1);
  137. else if(layout.getIcon() == layoutIcon3)
  138. layout.setIcon(layoutIcon4);
  139. else if(layout.getIcon() == layoutIcon4)
  140. layout.setIcon(layoutIcon3);
  141. }
  142. else if(evt.getSource() == alternateToolBarLayout)
  143. {
  144. if(layout.getIcon() == layoutIcon1)
  145. layout.setIcon(layoutIcon3);
  146. else if(layout.getIcon() == layoutIcon3)
  147. layout.setIcon(layoutIcon1);
  148. else if(layout.getIcon() == layoutIcon2)
  149. layout.setIcon(layoutIcon4);
  150. else if(layout.getIcon() == layoutIcon4)
  151. layout.setIcon(layoutIcon2);
  152. }
  153. }
  154. } //}}}
  155. }