/plugins/JCompiler/tags/jcompiler_1_1_2/jcompiler/options/JCompilerOptionPaneGeneral.java

# · Java · 187 lines · 121 code · 31 blank · 35 comment · 20 complexity · 2847a8d1c0d9fe4f97bacee8dd87b60d MD5 · raw file

  1. /*
  2. * JCompilerOptionPaneGeneral.java - plugin options pane for JCompiler - general options
  3. * (c) 1999, 2000 Kevin A. Burton and Aziz Sharif
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package jcompiler.options;
  20. import javax.swing.*;
  21. import javax.swing.event.*;
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.io.*;
  25. import java.util.*;
  26. import org.gjt.sp.jedit.*;
  27. import org.gjt.sp.jedit.gui.*;
  28. import buildtools.VariableGridLayout;
  29. /**
  30. * This is the option pane that jEdit displays for JCompiler's General
  31. * plugin options.
  32. */
  33. public class JCompilerOptionPaneGeneral extends AbstractOptionPane
  34. {
  35. private JCheckBox showCommandLine;
  36. private JCheckBox parseAccentChar;
  37. private JRadioButton saveCurrentOnCompile;
  38. private JRadioButton saveNotOnCompile;
  39. private JRadioButton saveAllOnCompile;
  40. private JRadioButton saveAskOnCompile;
  41. private JRadioButton saveCurrentOnPkgCompile;
  42. private JRadioButton saveNotOnPkgCompile;
  43. private JRadioButton saveAllOnPkgCompile;
  44. private JRadioButton saveAskOnPkgCompile;
  45. private JTextField regexp;
  46. private JTextField regexpFilename;
  47. private JTextField regexpLineNo;
  48. private JTextField regexpMessage;
  49. private JTextField regexpWarning;
  50. public JCompilerOptionPaneGeneral() {
  51. super("jcompiler.general");
  52. }
  53. public void _init() {
  54. // "Show command line"
  55. showCommandLine = new JCheckBox(jEdit.getProperty("options.jcompiler.showcommandline"));
  56. showCommandLine.setSelected(jEdit.getBooleanProperty("jcompiler.showcommandline", false));
  57. addComponent(showCommandLine);
  58. addComponent(Box.createVerticalStrut(15));
  59. // ========== Autosave options ==========
  60. // "When compiling file..."
  61. JLabel whenCompilingFile = new JLabel(jEdit.getProperty("options.jcompiler.autosave.compile"));
  62. // Radio buttons: "Save current buffer/Save all buffers/Don't save/Ask"
  63. saveCurrentOnCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.current"));
  64. saveAllOnCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.all"));
  65. saveNotOnCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.not"));
  66. saveAskOnCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.ask"));
  67. ButtonGroup group1 = new ButtonGroup();
  68. group1.add(saveCurrentOnCompile);
  69. group1.add(saveAllOnCompile);
  70. group1.add(saveNotOnCompile);
  71. group1.add(saveAskOnCompile);
  72. String s = jEdit.getProperty("jcompiler.javacompile.autosave", "no");
  73. if ("ask".equals(s))
  74. saveAskOnCompile.setSelected(true);
  75. else if ("current".equals(s))
  76. saveCurrentOnCompile.setSelected(true);
  77. else if ("all".equals(s))
  78. saveAllOnCompile.setSelected(true);
  79. else
  80. saveNotOnCompile.setSelected(true);
  81. // "When building a package..."
  82. JLabel whenBuildingPackage = new JLabel(jEdit.getProperty("options.jcompiler.autosave.compilepkg"));
  83. // Radio buttons: "Save current buffer/Save all buffers/Don't save/Ask"
  84. saveCurrentOnPkgCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.current"));
  85. saveAllOnPkgCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.all"));
  86. saveNotOnPkgCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.not"));
  87. saveAskOnPkgCompile = new JRadioButton(jEdit.getProperty("options.jcompiler.autosave.ask"));
  88. ButtonGroup group2 = new ButtonGroup();
  89. group2.add(saveCurrentOnPkgCompile);
  90. group2.add(saveAllOnPkgCompile);
  91. group2.add(saveNotOnPkgCompile);
  92. group2.add(saveAskOnPkgCompile);
  93. s = jEdit.getProperty("jcompiler.javapkgcompile.autosave", "no");
  94. if ("ask".equals(s))
  95. saveAskOnPkgCompile.setSelected(true);
  96. else if ("current".equals(s))
  97. saveCurrentOnPkgCompile.setSelected(true);
  98. else if ("all".equals(s))
  99. saveAllOnPkgCompile.setSelected(true);
  100. else
  101. saveNotOnPkgCompile.setSelected(true);
  102. JPanel saveOptions = new JPanel(new VariableGridLayout(VariableGridLayout.FIXED_NUM_COLUMNS, 2, 30, 0));
  103. saveOptions.add(whenCompilingFile);
  104. saveOptions.add(whenBuildingPackage);
  105. saveOptions.add(saveCurrentOnCompile);
  106. saveOptions.add(saveCurrentOnPkgCompile);
  107. saveOptions.add(saveAllOnCompile);
  108. saveOptions.add(saveAllOnPkgCompile);
  109. saveOptions.add(saveNotOnCompile);
  110. saveOptions.add(saveNotOnPkgCompile);
  111. saveOptions.add(saveAskOnCompile);
  112. saveOptions.add(saveAskOnPkgCompile);
  113. addComponent(saveOptions);
  114. addComponent(Box.createVerticalStrut(15));
  115. // ========== Error parsing options ==========
  116. addSeparator("options.jcompiler.sep.errorparsing");
  117. // "Regexp for errors:"
  118. regexp = new JTextField(jEdit.getProperty("jcompiler.regexp"));
  119. addComponent(jEdit.getProperty("options.jcompiler.regexp"), regexp);
  120. // "Filename at:"
  121. regexpFilename = new JTextField(jEdit.getProperty("jcompiler.regexp.filename"));
  122. addComponent(jEdit.getProperty("options.jcompiler.regexp.filename"), regexpFilename);
  123. // "Line number at:"
  124. regexpLineNo = new JTextField(jEdit.getProperty("jcompiler.regexp.lineno"));
  125. addComponent(jEdit.getProperty("options.jcompiler.regexp.lineno"), regexpLineNo);
  126. // "Message at:"
  127. regexpMessage = new JTextField(jEdit.getProperty("jcompiler.regexp.message"));
  128. addComponent(jEdit.getProperty("options.jcompiler.regexp.message"), regexpMessage);
  129. // "Regexp for warnings:"
  130. regexpWarning = new JTextField(jEdit.getProperty("jcompiler.regexp.warning"));
  131. addComponent(jEdit.getProperty("options.jcompiler.regexp.warning"), regexpWarning);
  132. // "Parse errors for '^' column indicator"
  133. parseAccentChar = new JCheckBox(jEdit.getProperty("options.jcompiler.parseaccentchar"));
  134. parseAccentChar.setSelected(jEdit.getBooleanProperty("jcompiler.parseaccentchar", true));
  135. addComponent(parseAccentChar);
  136. }
  137. public void _save() {
  138. jEdit.setBooleanProperty("jcompiler.showcommandline", showCommandLine.isSelected());
  139. jEdit.setBooleanProperty("jcompiler.parseaccentchar", parseAccentChar.isSelected());
  140. jEdit.setProperty("jcompiler.regexp", regexp.getText());
  141. jEdit.setProperty("jcompiler.regexp.filename", regexpFilename.getText());
  142. jEdit.setProperty("jcompiler.regexp.lineno", regexpLineNo.getText());
  143. jEdit.setProperty("jcompiler.regexp.message", regexpMessage.getText());
  144. jEdit.setProperty("jcompiler.regexp.warning", regexpWarning.getText());
  145. String s1 = "no";
  146. if (saveAskOnCompile.isSelected()) s1 = "ask";
  147. else if (saveCurrentOnCompile.isSelected()) s1 = "current";
  148. else if (saveAllOnCompile.isSelected()) s1 = "all";
  149. jEdit.setProperty("jcompiler.javacompile.autosave", s1);
  150. String s2 = "no";
  151. if (saveAskOnPkgCompile.isSelected()) s2 = "ask";
  152. else if (saveCurrentOnPkgCompile.isSelected()) s2 = "current";
  153. else if (saveAllOnPkgCompile.isSelected()) s2 = "all";
  154. jEdit.setProperty("jcompiler.javapkgcompile.autosave", s2);
  155. }
  156. }