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

/bundles/plugins-trunk/InfoViewer/infoviewer/InfoViewerOptionPane2.java

#
Java | 238 lines | 166 code | 35 blank | 37 comment | 3 complexity | 98651f538b0298a47170e45bfcf664f0 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. * InfoViewerOptionPane2.java - second InfoViewer options panel
  3. * Copyright (C) 2001 Dirk Moebius
  4. *
  5. * :tabSize=4:indentSize=4:noTabs=true: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 infoviewer;
  22. import java.awt.GridLayout;
  23. import java.awt.event.ActionEvent;
  24. import java.awt.event.ActionListener;
  25. import java.util.Hashtable;
  26. import javax.swing.Box;
  27. import javax.swing.JCheckBox;
  28. import javax.swing.JLabel;
  29. import javax.swing.JPanel;
  30. import javax.swing.JSlider;
  31. import javax.swing.JTextField;
  32. import org.gjt.sp.jedit.AbstractOptionPane;
  33. import org.gjt.sp.jedit.jEdit;
  34. public class InfoViewerOptionPane2 extends AbstractOptionPane implements ActionListener {
  35. private static final long serialVersionUID = 8785488835232627553L;
  36. public InfoViewerOptionPane2() {
  37. super("internalBrowser");
  38. }
  39. public void _init() {
  40. // "Appearance"
  41. addSeparator("options.infoviewer.appearance.label");
  42. // "Show ..."
  43. showFloatingMenu = new JCheckBox(
  44. jEdit.getProperty("options.infoviewer.appearance.floating.showMenu"),
  45. jEdit.getBooleanProperty("infoviewer.appearance.floating.showMenu"));
  46. showFloatingToolbar = new JCheckBox(
  47. jEdit.getProperty("options.infoviewer.appearance.floating.showToolbar"),
  48. jEdit.getBooleanProperty("infoviewer.appearance.floating.showToolbar"));
  49. showFloatingAddressbar = new JCheckBox(
  50. jEdit.getProperty("options.infoviewer.appearance.floating.showAddressbar"),
  51. jEdit.getBooleanProperty("infoviewer.appearance.floating.showAddressbar"));
  52. showFloatingStatusbar = new JCheckBox(
  53. jEdit.getProperty("options.infoviewer.appearance.floating.showStatusbar"),
  54. jEdit.getBooleanProperty("infoviewer.appearance.floating.showStatusbar"));
  55. showDockedMenu = new JCheckBox(
  56. jEdit.getProperty("options.infoviewer.appearance.docked.showMenu"),
  57. jEdit.getBooleanProperty("infoviewer.appearance.docked.showMenu"));
  58. showDockedToolbar = new JCheckBox(
  59. jEdit.getProperty("options.infoviewer.appearance.docked.showToolbar"),
  60. jEdit.getBooleanProperty("infoviewer.appearance.docked.showToolbar"));
  61. showDockedAddressbar = new JCheckBox(
  62. jEdit.getProperty("options.infoviewer.appearance.docked.showAddressbar"),
  63. jEdit.getBooleanProperty("infoviewer.appearance.docked.showAddressbar"));
  64. showDockedStatusbar = new JCheckBox(
  65. jEdit.getProperty("options.infoviewer.appearance.docked.showStatusbar"),
  66. jEdit.getBooleanProperty("infoviewer.appearance.docked.showStatusbar"));
  67. JPanel appearance = new JPanel(new GridLayout(0,2));
  68. appearance.add(new JLabel(jEdit.getProperty("options.infoviewer.appearance.floating.label")));
  69. appearance.add(new JLabel(jEdit.getProperty("options.infoviewer.appearance.docked.label")));
  70. appearance.add(showFloatingMenu);
  71. appearance.add(showDockedMenu);
  72. appearance.add(showFloatingToolbar);
  73. appearance.add(showDockedToolbar);
  74. appearance.add(showFloatingAddressbar);
  75. appearance.add(showDockedAddressbar);
  76. appearance.add(showFloatingStatusbar);
  77. appearance.add(showDockedStatusbar);
  78. addComponent(appearance);
  79. // "Homepage:"
  80. restorePreviousPage = new JCheckBox(
  81. jEdit.getProperty("options.infoviewer.restorePreviousPage"),
  82. jEdit.getBooleanProperty("infoviewer.restorePreviousPage"));
  83. restorePreviousPage.addActionListener(this);
  84. tHome = new JTextField(jEdit.getProperty("infoviewer.homepage"), 30);
  85. Box bHome = Box.createHorizontalBox();
  86. bHome.add(new JLabel(jEdit.getProperty("options.infoviewer.homepage")));
  87. bHome.add(tHome);
  88. addComponent(Box.createVerticalStrut(10));
  89. addComponent(bHome);
  90. addComponent(restorePreviousPage);
  91. // "Auto-Update"
  92. addComponent(Box.createVerticalStrut(15));
  93. addSeparator("options.infoviewer.autoupdate.label");
  94. autoUpdate = new JCheckBox(
  95. jEdit.getProperty("options.infoviewer.autoupdate"),
  96. jEdit.getBooleanProperty("infoviewer.autoupdate"));
  97. autoUpdate.addActionListener(this);
  98. autoUpdateOnSwitch = new JCheckBox(
  99. jEdit.getProperty("options.infoviewer.autoupdate.onSwitch"),
  100. jEdit.getBooleanProperty("infoviewer.autoupdate.onSwitch"));
  101. autoUpdateOnSave = new JCheckBox(
  102. jEdit.getProperty("options.infoviewer.autoupdate.onSave"),
  103. jEdit.getBooleanProperty("infoviewer.autoupdate.onSave"));
  104. autoUpdateOnChange = new JCheckBox(
  105. jEdit.getProperty("options.infoviewer.autoupdate.onChange"),
  106. jEdit.getBooleanProperty("infoviewer.autoupdate.onChange"));
  107. autoUpdateOnChange.addActionListener(this);
  108. autoUpdatePeriodically = new JCheckBox(
  109. jEdit.getProperty("options.infoviewer.autoupdate.periodically"),
  110. jEdit.getBooleanProperty("infoviewer.autoupdate.periodically"));
  111. autoUpdatePeriodically.addActionListener(this);
  112. int delayOnChange;
  113. try { delayOnChange = Integer.parseInt(jEdit.getProperty("infoviewer.autoupdate.onChange.delay")); }
  114. catch(NumberFormatException nf) { delayOnChange = 3000; }
  115. delayOnChange = Math.min(Math.max(delayOnChange, 1000), 5000);
  116. autoUpdateDelayOnChange = new JSlider(1000, 5000, delayOnChange);
  117. Hashtable labelTable = new Hashtable();
  118. for(int i = 1000; i <= 5000; i += 1000)
  119. labelTable.put(new Integer(i), new JLabel(String.valueOf((double)i / 1000.0)));
  120. autoUpdateDelayOnChange.setLabelTable(labelTable);
  121. autoUpdateDelayOnChange.setPaintLabels(true);
  122. autoUpdateDelayOnChange.setMajorTickSpacing(1000);
  123. autoUpdateDelayOnChange.setMinorTickSpacing(100);
  124. autoUpdateDelayOnChange.setPaintTicks(true);
  125. autoUpdateDelayOnChange.setSnapToTicks(true);
  126. int delayPeriodically;
  127. try { delayPeriodically = Integer.parseInt(jEdit.getProperty("infoviewer.autoupdate.periodically.delay")) / 1000; }
  128. catch(NumberFormatException nf) { delayPeriodically = 20; }
  129. delayPeriodically = Math.min(Math.max(delayPeriodically, 10), 300);
  130. autoUpdateDelayPeriodically = new JSlider(10, 300, delayPeriodically);
  131. Hashtable labelTable2 = new Hashtable();
  132. labelTable2.put(new Integer(10), new JLabel("10"));
  133. for(int i = 50; i <= 300; i += 50)
  134. labelTable2.put(new Integer(i), new JLabel(String.valueOf(i)));
  135. autoUpdateDelayPeriodically.setLabelTable(labelTable2);
  136. autoUpdateDelayPeriodically.setPaintLabels(true);
  137. autoUpdateDelayPeriodically.setMinorTickSpacing(10);
  138. autoUpdateDelayPeriodically.setPaintTicks(true);
  139. addComponent(autoUpdate);
  140. addComponent(autoUpdateOnSwitch);
  141. addComponent(autoUpdateOnSave);
  142. //addComponent(autoUpdateOnChange); not yet...
  143. addComponent(autoUpdatePeriodically);
  144. //addComponent(jEdit.getProperty("options.infoviewer.autoupdate.onChange.delay"), autoUpdateDelayOnChange);
  145. addComponent(jEdit.getProperty("options.infoviewer.autoupdate.periodically.delay"), autoUpdateDelayPeriodically);
  146. // init:
  147. actionPerformed(null);
  148. }
  149. /**
  150. * Called when the options dialog's `OK' button is pressed.
  151. * This saves any properties saved in this option pane.
  152. */
  153. public void _save()
  154. {
  155. jEdit.setProperty("infoviewer.homepage", tHome.getText());
  156. jEdit.setBooleanProperty("infoviewer.appearance.floating.showMenu", showFloatingMenu.isSelected());
  157. jEdit.setBooleanProperty("infoviewer.appearance.floating.showToolbar", showFloatingToolbar.isSelected());
  158. jEdit.setBooleanProperty("infoviewer.appearance.floating.showAddressbar", showFloatingAddressbar.isSelected());
  159. jEdit.setBooleanProperty("infoviewer.appearance.floating.showStatusbar", showFloatingStatusbar.isSelected());
  160. jEdit.setBooleanProperty("infoviewer.appearance.docked.showMenu", showDockedMenu.isSelected());
  161. jEdit.setBooleanProperty("infoviewer.appearance.docked.showToolbar", showDockedToolbar.isSelected());
  162. jEdit.setBooleanProperty("infoviewer.appearance.docked.showAddressbar", showDockedAddressbar.isSelected());
  163. jEdit.setBooleanProperty("infoviewer.appearance.docked.showStatusbar", showDockedStatusbar.isSelected());
  164. jEdit.setBooleanProperty("infoviewer.autoupdate", autoUpdate.isSelected());
  165. jEdit.setBooleanProperty("infoviewer.autoupdate.onSwitch", autoUpdateOnSwitch.isSelected());
  166. jEdit.setBooleanProperty("infoviewer.restorePreviousPage", restorePreviousPage.isSelected());
  167. jEdit.setBooleanProperty("infoviewer.autoupdate.onSave", autoUpdateOnSave.isSelected());
  168. //jEdit.setBooleanProperty("infoviewer.autoupdate.onChange", autoUpdateOnChange.isSelected());
  169. jEdit.setBooleanProperty("infoviewer.autoupdate.periodically", autoUpdatePeriodically.isSelected());
  170. jEdit.setProperty("infoviewer.autoupdate.onChange.delay", String.valueOf(autoUpdateDelayOnChange.getValue()));
  171. jEdit.setProperty("infoviewer.autoupdate.periodically.delay", String.valueOf(autoUpdateDelayPeriodically.getValue() * 1000));
  172. }
  173. /**
  174. * Called when one of the radio buttons is clicked.
  175. */
  176. public void actionPerformed(ActionEvent e)
  177. {
  178. tHome.setEnabled(!restorePreviousPage.isSelected());
  179. autoUpdateOnSwitch.setEnabled(autoUpdate.isSelected());
  180. autoUpdateOnSave.setEnabled(autoUpdate.isSelected());
  181. //autoUpdateOnChange.setEnabled(autoUpdate.isSelected());
  182. autoUpdatePeriodically.setEnabled(autoUpdate.isSelected());
  183. //autoUpdateDelayOnChange.setEnabled(autoUpdate.isSelected() && autoUpdateOnChange.isSelected());
  184. autoUpdateDelayPeriodically.setEnabled(autoUpdate.isSelected() && autoUpdatePeriodically.isSelected());
  185. }
  186. private JTextField tHome;
  187. private JCheckBox showFloatingMenu;
  188. private JCheckBox showFloatingToolbar;
  189. private JCheckBox showFloatingAddressbar;
  190. private JCheckBox showFloatingStatusbar;
  191. private JCheckBox showDockedMenu;
  192. private JCheckBox showDockedToolbar;
  193. private JCheckBox showDockedAddressbar;
  194. private JCheckBox showDockedStatusbar;
  195. private JCheckBox autoUpdate;
  196. private JCheckBox restorePreviousPage;
  197. private JCheckBox autoUpdateOnSwitch;
  198. private JCheckBox autoUpdateOnSave;
  199. private JCheckBox autoUpdateOnChange;
  200. private JCheckBox autoUpdatePeriodically;
  201. private JSlider autoUpdateDelayOnChange;
  202. private JSlider autoUpdateDelayPeriodically;
  203. }