You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BuildOptionsPanel.java 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * ******************************************************************/
  13. package org.aspectj.ajde.ui.swing;
  14. import java.io.IOException;
  15. import javax.swing.border.Border;
  16. import javax.swing.border.TitledBorder;
  17. import org.aspectj.ajde.Ajde;
  18. import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
  19. import javax.swing.*;
  20. import java.awt.*;
  21. /**
  22. * @author Mik Kersten
  23. */
  24. public class BuildOptionsPanel extends OptionsPanel {
  25. // private static String INCREMENTAL_NOTE = "Please note that this release offers an early access integration of the incremental\n"
  26. // + "AspectJ compiler. The Document Outline View will fail to refresh correctly when\n"
  27. // + "incremental mode is enabled. Submit any other bugs at http://eclipse.org/aspectj";
  28. private static final long serialVersionUID = 5891996016897166802L;
  29. protected static final BuildOptionsPanel INSTANCE = new BuildOptionsPanel();
  30. // private ButtonGroup compilerMode_buttonGroup = new ButtonGroup();
  31. private TitledBorder titledBorder1;
  32. // private Border border3;
  33. // private Border border4;
  34. // private TitledBorder titledBorder2;
  35. // private Border border5;
  36. private Border border1;
  37. private Border border2;
  38. private JPanel jPanel3 = new JPanel();
  39. private BorderLayout borderLayout6 = new BorderLayout();
  40. private JPanel jPanel4 = new JPanel();
  41. private JPanel compileOptions_panel1 = new JPanel();
  42. private JPanel build_panel1 = new JPanel();
  43. // private JRadioButton normal_radioButton = new JRadioButton();
  44. // private JRadioButton strict_radioButton = new JRadioButton();
  45. // private JRadioButton lenient_radioButton = new JRadioButton();
  46. private BorderLayout borderLayout8 = new BorderLayout();
  47. private Box options_box1 = Box.createVerticalBox();
  48. private BorderLayout borderLayout5 = new BorderLayout();
  49. // private JTextField workingDir_field = new JTextField();
  50. private JPanel jPanel2 = new JPanel();
  51. private JPanel jPanel1 = new JPanel();
  52. private JPanel build_panel = new JPanel();
  53. private JTextField nonStandard_field = new JTextField();
  54. private JPanel compileOptions_panel = new JPanel();
  55. private JLabel workingDir_label = new JLabel();
  56. private JLabel nonStandard_label = new JLabel();
  57. private BorderLayout borderLayout4 = new BorderLayout();
  58. private BorderLayout borderLayout3 = new BorderLayout();
  59. private BorderLayout borderLayout2 = new BorderLayout();
  60. private Box fields_box = Box.createVerticalBox();
  61. private BorderLayout borderLayout1 = new BorderLayout();
  62. private BorderLayout borderLayout7 = new BorderLayout();
  63. Box options_box2 = Box.createVerticalBox();
  64. //JTextArea incrementalNote = new JTextArea();
  65. JLabel spacer_label = new JLabel();
  66. JCheckBox assertions_checkBox = new JCheckBox();
  67. JCheckBox oneFive_checkBox = new JCheckBox();
  68. Box options_box = Box.createVerticalBox();
  69. //JCheckBox incremental_checkBox = new JCheckBox();
  70. // JCheckBox useJavac_checkBox = new JCheckBox();
  71. // JCheckBox preprocess_checkBox = new JCheckBox();
  72. JLabel spacer_label1 = new JLabel();
  73. public BuildOptionsPanel() {
  74. try {
  75. jbInit();
  76. this.setName("AspectJ Build Options");
  77. // compilerMode_buttonGroup.add(normal_radioButton);
  78. // compilerMode_buttonGroup.add(strict_radioButton);
  79. // compilerMode_buttonGroup.add(lenient_radioButton);
  80. // preprocess_checkBox.setEnabled(false);
  81. // useJavac_checkBox.setEnabled(false);
  82. // workingDir_field.setEnabled(false);
  83. // workingDir_label.setEnabled(false);
  84. } catch (Exception e) {
  85. Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
  86. }
  87. }
  88. public void loadOptions() throws IOException {
  89. if (Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel() != null) {
  90. oneFive_checkBox.setSelected(
  91. Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_5)
  92. );
  93. }
  94. if (Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel() != null) {
  95. assertions_checkBox.setSelected(
  96. Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_4)
  97. );
  98. }
  99. // preprocess_checkBox.setSelected(
  100. // Ajde.getDefault().getBuildManager().getBuildOptions().getPreprocessMode()
  101. // );
  102. // useJavac_checkBox.setSelected(
  103. // Ajde.getDefault().getBuildManager().getBuildOptions().getUseJavacMode()
  104. // );
  105. // incremental_checkBox.setSelected(
  106. // Ajde.getDefault().getBuildManager().getBuildOptions().getIncrementalMode()
  107. // );
  108. nonStandard_field.setText(
  109. Ajde.getDefault().getBuildManager().getBuildOptions().getNonStandardOptions()
  110. );
  111. // workingDir_field.setText(
  112. // Ajde.getDefault().getBuildManager().getBuildOptions().getWorkingOutputPath()
  113. // );
  114. // if (Ajde.getDefault().getBuildManager().getBuildOptions().getStrictSpecMode()) {
  115. // strict_radioButton.setSelected(true);
  116. // } else if (Ajde.getDefault().getBuildManager().getBuildOptions().getLenientSpecMode()) {
  117. // lenient_radioButton.setSelected(true);
  118. // } else {
  119. // normal_radioButton.setSelected(true);
  120. // }
  121. }
  122. public void saveOptions() throws IOException {
  123. if (oneFive_checkBox.isSelected()) {
  124. AjdeUIManager.getDefault().getBuildOptions().setSourceCompatibilityLevel(CompilerOptions.VERSION_1_5);
  125. } else if (assertions_checkBox.isSelected()) {
  126. // AjdeUIManager.getDefault().getBuildOptions().setSourceOnePointFourMode(true);
  127. AjdeUIManager.getDefault().getBuildOptions().setSourceCompatibilityLevel(CompilerOptions.VERSION_1_4);
  128. } else {
  129. AjdeUIManager.getDefault().getBuildOptions().setSourceCompatibilityLevel(CompilerOptions.VERSION_1_3);
  130. }
  131. // AjdeUIManager.getDefault().getBuildOptions().setPreprocessMode(
  132. // preprocess_checkBox.isSelected()
  133. // );
  134. // AjdeUIManager.getDefault().getBuildOptions().setUseJavacMode(
  135. // useJavac_checkBox.isSelected()
  136. // );
  137. // AjdeUIManager.getDefault().getBuildOptions().setIncrementalMode(
  138. // incremental_checkBox.isSelected()
  139. // );
  140. AjdeUIManager.getDefault().getBuildOptions().setNonStandardOptions(
  141. nonStandard_field.getText()
  142. );
  143. // AjdeUIManager.getDefault().getBuildOptions().setWorkingDir(
  144. // workingDir_field.getText()
  145. // );
  146. // AjdeUIManager.getDefault().getBuildOptions().setStrictSpecMode(strict_radioButton.isSelected());
  147. // AjdeUIManager.getDefault().getBuildOptions().setLenientSpecMode(lenient_radioButton.isSelected());
  148. }
  149. public static BuildOptionsPanel getDefault() {
  150. return INSTANCE;
  151. }
  152. private void jbInit() throws Exception {
  153. titledBorder1 =
  154. new TitledBorder(
  155. BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)),
  156. "ajc Options");
  157. BorderFactory.createCompoundBorder(
  158. new TitledBorder(
  159. BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)),
  160. "ajc Options"),
  161. BorderFactory.createEmptyBorder(5, 5, 5, 5));
  162. BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158));
  163. // titledBorder2 =
  164. // new TitledBorder(
  165. // BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)),
  166. // "ajc Strictness Mode");
  167. // border5 =
  168. // BorderFactory.createCompoundBorder(
  169. // titledBorder2,
  170. // BorderFactory.createEmptyBorder(5, 5, 5, 5));
  171. // border1 =
  172. // BorderFactory.createCompoundBorder(
  173. // titledBorder2,
  174. // BorderFactory.createEmptyBorder(5, 5, 5, 5));
  175. border2 =
  176. BorderFactory.createCompoundBorder(
  177. titledBorder1,
  178. BorderFactory.createEmptyBorder(5, 5, 5, 5));
  179. titledBorder1.setTitle("ajc Options");
  180. titledBorder1.setTitleFont(new java.awt.Font("Dialog", 0, 11));
  181. // titledBorder2.setTitleFont(new java.awt.Font("Dialog", 0, 11));
  182. this.setLayout(borderLayout6);
  183. compileOptions_panel1.setLayout(borderLayout8);
  184. build_panel1.setLayout(borderLayout5);
  185. build_panel1.setFont(new java.awt.Font("Dialog", 0, 11));
  186. build_panel1.setBorder(border1);
  187. build_panel1.setMaximumSize(new Dimension(2147483647, 109));
  188. // normal_radioButton.setFont(new java.awt.Font("Dialog", 0, 11));
  189. // normal_radioButton.setText("Normal");
  190. // strict_radioButton.setText(
  191. // "Be extra strict in interpreting the Java specification");
  192. // strict_radioButton.setFont(new java.awt.Font("Dialog", 0, 11));
  193. // lenient_radioButton.setText(
  194. // "Be lenient in interpreting the Java specification");
  195. // lenient_radioButton.setFont(new java.awt.Font("Dialog", 0, 11));
  196. // workingDir_field.setFont(new java.awt.Font("SansSerif", 0, 11));
  197. // workingDir_field.setMinimumSize(new Dimension(200, 21));
  198. // workingDir_field.setPreferredSize(new Dimension(350, 21));
  199. jPanel2.setLayout(borderLayout3);
  200. jPanel1.setLayout(borderLayout2);
  201. build_panel.setLayout(borderLayout4);
  202. build_panel.setBorder(border2);
  203. nonStandard_field.setFont(new java.awt.Font("SansSerif", 0, 11));
  204. nonStandard_field.setMinimumSize(new Dimension(200, 21));
  205. nonStandard_field.setPreferredSize(new Dimension(350, 21));
  206. compileOptions_panel.setLayout(borderLayout1);
  207. nonStandard_label.setText("Other compiler options:");
  208. nonStandard_label.setFont(new java.awt.Font("Dialog", 0, 11));
  209. nonStandard_label.setPreferredSize(new Dimension(80, 16));
  210. nonStandard_label.setToolTipText("");
  211. jPanel3.setLayout(borderLayout7);
  212. workingDir_label.setFont(new java.awt.Font("Dialog", 0, 11));
  213. workingDir_label.setPreferredSize(new Dimension(80, 16));
  214. workingDir_label.setText("Working directory: ");
  215. // incrementalNote.setBackground(AjdeWidgetStyles.DEFAULT_BACKGROUND_COLOR);
  216. // incrementalNote.setFont(new java.awt.Font("Dialog", 0, 11));
  217. // incrementalNote.setEditable(false);
  218. // incrementalNote.setText(INCREMENTAL_NOTE);
  219. spacer_label.setText(" ");
  220. assertions_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  221. assertions_checkBox.setText("Java 1.4 source compatibility mode");
  222. oneFive_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  223. oneFive_checkBox.setText("Java 1.5 source compatibility mode");
  224. // incremental_checkBox.setText("Incremental compile");
  225. // incremental_checkBox.setToolTipText("Only recompile necessary sources.");
  226. // incremental_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  227. // useJavac_checkBox.setText("Use javac to generate .class files");
  228. // useJavac_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  229. // preprocess_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  230. // preprocess_checkBox.setToolTipText("");
  231. // preprocess_checkBox.setText("Only preprocess and generate .java source files");
  232. spacer_label1.setText(" ");
  233. // this.add(jPanel3, BorderLayout.NORTH);
  234. // jPanel2.add(workingDir_label, BorderLayout.CENTER);
  235. // jPanel2.add(workingDir_field, BorderLayout.EAST);
  236. compileOptions_panel.add(options_box2, BorderLayout.CENTER);
  237. //options_box2.add(incrementalNote, null);
  238. options_box2.add(spacer_label1, null);
  239. compileOptions_panel.add(options_box, BorderLayout.NORTH);
  240. options_box.add(assertions_checkBox, null);
  241. options_box.add(oneFive_checkBox, null);
  242. // options_box.add(preprocess_checkBox, null);
  243. // options_box.add(useJavac_checkBox, null);
  244. //options_box.add(incremental_checkBox, null);
  245. options_box.add(spacer_label, null);
  246. fields_box.add(jPanel1, null);
  247. fields_box.add(jPanel2, null);
  248. jPanel1.add(nonStandard_label, BorderLayout.CENTER);
  249. jPanel1.add(nonStandard_field, BorderLayout.EAST);
  250. compileOptions_panel.add(fields_box, BorderLayout.SOUTH);
  251. jPanel3.add(build_panel, BorderLayout.CENTER);
  252. build_panel.add(compileOptions_panel, BorderLayout.NORTH);
  253. jPanel3.add(build_panel1, BorderLayout.SOUTH);
  254. build_panel1.add(compileOptions_panel1, BorderLayout.NORTH);
  255. compileOptions_panel1.add(options_box1, BorderLayout.NORTH);
  256. // options_box1.add(normal_radioButton, null);
  257. // options_box1.add(lenient_radioButton, null);
  258. // options_box1.add(strict_radioButton, null);
  259. this.add(jPanel4, BorderLayout.CENTER);
  260. }
  261. }