PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Java | 149 lines | 81 code | 30 blank | 38 comment | 5 complexity | 734401ba4c992b8bd1738498fc5971bd 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. * InfoViewerOptionPane.java - InfoViewer options panel
  3. * Copyright (C) 1999-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.event.ActionEvent;
  23. import java.awt.event.ActionListener;
  24. import javax.swing.*;
  25. import org.gjt.sp.jedit.AbstractOptionPane;
  26. import org.gjt.sp.jedit.jEdit;
  27. public class InfoViewerOptionPane extends AbstractOptionPane implements ActionListener
  28. {
  29. private static final long serialVersionUID = -8581345434069856402L;
  30. public InfoViewerOptionPane()
  31. {
  32. super("chooseBrowser");
  33. }
  34. public void _init()
  35. {
  36. useForHelp = new JCheckBox(jEdit.getProperty("options.infoviewer.useforhelp.label"));
  37. useForHelp.setSelected(jEdit.getBooleanProperty("infoviewer.useforhelp"));
  38. addComponent(useForHelp);
  39. // "Choose Preferred Browser"
  40. addSeparator("options.infoviewer.browser.label");
  41. // "Internal (InfoViewer)"
  42. rbInternal = new JRadioButton(jEdit
  43. .getProperty("options.infoviewer.browser.internal"));
  44. rbInternal.addActionListener(this);
  45. addComponent(rbInternal);
  46. // "Class in classpath"
  47. rbClass = new JRadioButton(jEdit.getProperty("options.infoviewer.browser.class"));
  48. rbClass.addActionListener(this);
  49. addComponent(rbClass);
  50. // "Firefox"
  51. rbFirefox = new JRadioButton(jEdit
  52. .getProperty("options.infoviewer.browser.firefox"));
  53. rbFirefox.addActionListener(this);
  54. // addComponent(rbFirefox);
  55. // "External browser"
  56. rbOther = new JRadioButton(jEdit.getProperty("options.infoviewer.browser.other"));
  57. rbOther.addActionListener(this);
  58. addComponent(rbOther);
  59. ButtonGroup browserGroup = new ButtonGroup();
  60. browserGroup.add(rbInternal);
  61. browserGroup.add(rbClass);
  62. browserGroup.add(rbFirefox);
  63. browserGroup.add(rbOther);
  64. String browserType = jEdit.getProperty("infoviewer.browsertype");
  65. if ("firefox".equals(browserType))
  66. rbFirefox.setSelected(true);
  67. else if ("class".equals(browserType))
  68. rbClass.setSelected(true);
  69. else if ("external".equals(browserType))
  70. rbOther.setSelected(true);
  71. else
  72. rbInternal.setSelected(true);
  73. // "Browser settings:"
  74. addComponent(Box.createVerticalStrut(20));
  75. addSeparator("options.infoviewer.browser.settings.label");
  76. // "Class:"
  77. tClass = new JTextField(jEdit.getProperty("infoviewer.class"), 15);
  78. addComponent(jEdit.getProperty("options.infoviewer.browser.class.label"), tClass);
  79. // "Method:"
  80. tMethod = new JTextField(jEdit.getProperty("infoviewer.method"), 15);
  81. addComponent(jEdit.getProperty("options.infoviewer.browser.method.label"), tMethod);
  82. // "External browser command:"
  83. tBrowser = new JTextField(jEdit.getProperty("infoviewer.otherBrowser"), 15);
  84. addComponent(jEdit.getProperty("options.infoviewer.browser.other.label"), tBrowser);
  85. // init:
  86. actionPerformed(null);
  87. }
  88. /**
  89. * Called when the options dialog's `OK' button is pressed. This saves
  90. * any properties saved in this option pane.
  91. */
  92. public void _save()
  93. {
  94. jEdit.setProperty("infoviewer.browsertype", rbInternal.isSelected() ? "internal"
  95. : rbClass.isSelected() ? "class" : rbFirefox.isSelected() ? "firefox"
  96. : "external");
  97. jEdit.setBooleanProperty("infoviewer.useforhelp", useForHelp.isSelected());
  98. jEdit.setProperty("infoviewer.otherBrowser", tBrowser.getText());
  99. jEdit.setProperty("infoviewer.class", tClass.getText());
  100. jEdit.setProperty("infoviewer.method", tMethod.getText());
  101. }
  102. /**
  103. * Called when one of the radio buttons is clicked.
  104. */
  105. public void actionPerformed(ActionEvent e)
  106. {
  107. tClass.setEnabled(rbClass.isSelected());
  108. tMethod.setEnabled(rbClass.isSelected());
  109. tBrowser.setEnabled(rbOther.isSelected());
  110. }
  111. private JRadioButton rbInternal;
  112. private JRadioButton rbOther;
  113. private JRadioButton rbClass;
  114. private JRadioButton rbFirefox;
  115. private JCheckBox useForHelp;
  116. private JTextField tBrowser;
  117. private JTextField tClass;
  118. private JTextField tMethod;
  119. }