/plugins/LaTeXTools/tags/release-0-5-4/uk/co/antroy/latextools/options/LaTeXOptionPane.java

# · Java · 168 lines · 119 code · 21 blank · 28 comment · 0 complexity · d4fc7e6e6601de969be60de90c83ad25 MD5 · raw file

  1. /*
  2. * LaTeXOptionPane.java - General options.
  3. *
  4. * Copyright (C) 2002 Anthony Roy
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. package uk.co.antroy.latextools.options;
  21. //{{{ Imports
  22. import java.awt.GridBagLayout;
  23. import java.awt.GridLayout;
  24. import javax.swing.BoxLayout;
  25. import javax.swing.JCheckBox;
  26. import javax.swing.JLabel;
  27. import javax.swing.JPanel;
  28. import javax.swing.JTextField;
  29. import org.gjt.sp.jedit.AbstractOptionPane;
  30. import org.gjt.sp.jedit.jEdit;
  31. //}}}
  32. public class LaTeXOptionPane
  33. extends AbstractOptionPane {
  34. //~ Instance/static variables .............................................
  35. private JTextField compileCommandField;
  36. private JTextField compileExtField;
  37. private JTextField compileShowErrorsSwitch;
  38. private JTextField bibtexCommandField;
  39. private JTextField viewerCommandField;
  40. private JTextField viewerExtField;
  41. private JTextField classpathField;
  42. private JCheckBox compileDetach;
  43. private JCheckBox cStyleErrors;
  44. private JCheckBox bibtexDetach;
  45. private JCheckBox viewerDetach;
  46. //~ Constructors ..........................................................
  47. public LaTeXOptionPane() {
  48. super("general");
  49. }
  50. //~ Methods ...............................................................
  51. protected void _init() {
  52. initGeneral();
  53. }
  54. protected void _save() {
  55. saveGeneral();
  56. }
  57. private void initGeneral() {
  58. addComponent(new JLabel("<html><h3>Compilation Options"));
  59. compileCommandField = new JTextField(30);
  60. compileCommandField.setText(jEdit.getProperty("latex.compile.command"));
  61. JPanel p1 = new JPanel();
  62. p1.add(new JLabel("Default Compile Command"));
  63. p1.add(compileCommandField);
  64. compileExtField = new JTextField(8);
  65. compileExtField.setText(jEdit.getProperty("latex.compile.ext"));
  66. JPanel p2 = new JPanel();
  67. p2.add(new JLabel("Default Compile Extension"));
  68. p2.add(compileExtField);
  69. compileDetach = new JCheckBox("Detach Compilation Process?");
  70. compileDetach.getModel().setSelected(jEdit.getBooleanProperty(
  71. "latex.compile.detach"));
  72. cStyleErrors = new JCheckBox("Show Errors in Error List? (Passes a switch to latex - see the Latex error style switch)");
  73. cStyleErrors.getModel().setSelected(jEdit.getBooleanProperty(
  74. "latex.compile.parse-errors"));
  75. compileShowErrorsSwitch = new JTextField(30);
  76. compileShowErrorsSwitch.setText(jEdit.getProperty("latex.compile.c-errors"));
  77. String showErrTooltip = "Passed to latex; use -c-style-errors for MiKTeX"
  78. +" and -file-line-error-style for linux distributions";
  79. compileShowErrorsSwitch.setToolTipText(showErrTooltip);
  80. JPanel pShowErr1 = new JPanel();
  81. pShowErr1.add(new JLabel("Latex error style switch"));
  82. pShowErr1.add(compileShowErrorsSwitch);
  83. JLabel showErrDetailLabel = new JLabel("\t("+showErrTooltip+")");
  84. /*JPanel pShowErr2 = new JPanel();
  85. pShowErr2.setLayout(new BoxLayout(pShowErr2,BoxLayout.Y_AXIS));
  86. pShowErr2.add(pShowErr1);
  87. pShowErr2.add(showErrDetailLabel);*/
  88. addComponent(p1);
  89. addComponent(p2);
  90. addComponent(compileDetach);
  91. addComponent(cStyleErrors);
  92. addComponent(pShowErr1);
  93. addComponent(showErrDetailLabel);
  94. bibtexCommandField = new JTextField(30);
  95. bibtexCommandField.setText(jEdit.getProperty("latex.bibtex.command"));
  96. JPanel pbib = new JPanel();
  97. pbib.add(new JLabel("Default BibTeX Command"));
  98. pbib.add(bibtexCommandField);
  99. bibtexDetach = new JCheckBox("Detach BibTeX Process?");
  100. bibtexDetach.getModel().setSelected(jEdit.getBooleanProperty(
  101. "latex.bibtex.detach"));
  102. addComponent(pbib);
  103. addComponent(bibtexDetach);
  104. addComponent(new JLabel("<html><h3>Viewer Options"));
  105. viewerCommandField = new JTextField(30);
  106. viewerCommandField.setText(jEdit.getProperty(
  107. "latex.viewoutput.command"));
  108. JPanel p3 = new JPanel();
  109. p3.add(new JLabel("Default Viewer Command"));
  110. p3.add(viewerCommandField);
  111. viewerExtField = new JTextField(30);
  112. viewerExtField.setText(jEdit.getProperty("latex.viewoutput.ext"));
  113. JPanel p4 = new JPanel();
  114. p4.add(new JLabel("Default Viewer Extension"));
  115. p4.add(viewerExtField);
  116. viewerDetach = new JCheckBox("Detach Viewer Process?");
  117. viewerDetach.getModel().setSelected(jEdit.getBooleanProperty(
  118. "latex.viewoutput.detach"));
  119. addComponent(p3);
  120. addComponent(p4);
  121. addComponent(viewerDetach);
  122. addComponent(new JLabel("<html><h3>Classpath Options"));
  123. addComponent(new JLabel("Provide a semi-colon delimited list of directories to search for imports:"));
  124. classpathField = new JTextField(30);
  125. classpathField.setText(jEdit.getProperty("latex.classpath.dirs"));
  126. addComponent(classpathField);
  127. }
  128. private void saveGeneral() {
  129. jEdit.setProperty("latex.compile.command",
  130. compileCommandField.getText());
  131. jEdit.setProperty("latex.compile.ext", compileExtField.getText());
  132. jEdit.setBooleanProperty("latex.compile.detach",
  133. compileDetach.getModel().isSelected());
  134. jEdit.setProperty("latex.bibtex.command", bibtexCommandField.getText());
  135. jEdit.setBooleanProperty("latex.bibtex.detach",
  136. bibtexDetach.getModel().isSelected());
  137. jEdit.setBooleanProperty("latex.compile.parse-errors",
  138. cStyleErrors.getModel().isSelected());
  139. jEdit.setProperty("latex.viewoutput.command",
  140. viewerCommandField.getText());
  141. jEdit.setProperty("latex.viewoutput.ext", viewerExtField.getText());
  142. jEdit.setBooleanProperty("latex.viewoutput.detach",
  143. viewerDetach.getModel().isSelected());
  144. jEdit.setProperty("latex.classpath.dirs", classpathField.getText());
  145. jEdit.setProperty("latex.compile.c-errors", compileShowErrorsSwitch.getText());
  146. }
  147. }