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 Common Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/cpl-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. protected static final BuildOptionsPanel INSTANCE = new BuildOptionsPanel();
  29. // private ButtonGroup compilerMode_buttonGroup = new ButtonGroup();
  30. private TitledBorder titledBorder1;
  31. private Border border3;
  32. private Border border4;
  33. // private TitledBorder titledBorder2;
  34. // private Border border5;
  35. private Border border1;
  36. private Border border2;
  37. private JPanel jPanel3 = new JPanel();
  38. private BorderLayout borderLayout6 = new BorderLayout();
  39. private JPanel jPanel4 = new JPanel();
  40. private JPanel compileOptions_panel1 = new JPanel();
  41. private JPanel build_panel1 = new JPanel();
  42. // private JRadioButton normal_radioButton = new JRadioButton();
  43. // private JRadioButton strict_radioButton = new JRadioButton();
  44. // private JRadioButton lenient_radioButton = new JRadioButton();
  45. private BorderLayout borderLayout8 = new BorderLayout();
  46. private Box options_box1 = Box.createVerticalBox();
  47. private BorderLayout borderLayout5 = new BorderLayout();
  48. private JTextField workingDir_field = new JTextField();
  49. private JPanel jPanel2 = new JPanel();
  50. private JPanel jPanel1 = new JPanel();
  51. private JPanel build_panel = new JPanel();
  52. private JTextField nonStandard_field = new JTextField();
  53. private JPanel compileOptions_panel = new JPanel();
  54. private JLabel workingDir_label = new JLabel();
  55. private JLabel nonStandard_label = new JLabel();
  56. private BorderLayout borderLayout4 = new BorderLayout();
  57. private BorderLayout borderLayout3 = new BorderLayout();
  58. private BorderLayout borderLayout2 = new BorderLayout();
  59. private Box fields_box = Box.createVerticalBox();
  60. private BorderLayout borderLayout1 = new BorderLayout();
  61. private BorderLayout borderLayout7 = new BorderLayout();
  62. Box options_box2 = Box.createVerticalBox();
  63. JTextArea incrementalNote = new JTextArea();
  64. JLabel spacer_label = new JLabel();
  65. JCheckBox assertions_checkBox = new JCheckBox();
  66. JCheckBox oneFive_checkBox = new JCheckBox();
  67. Box options_box = Box.createVerticalBox();
  68. JCheckBox incremental_checkBox = new JCheckBox();
  69. JCheckBox useJavac_checkBox = new JCheckBox();
  70. JCheckBox preprocess_checkBox = new JCheckBox();
  71. JLabel spacer_label1 = new JLabel();
  72. public BuildOptionsPanel() {
  73. try {
  74. jbInit();
  75. this.setName("AspectJ Build Options");
  76. // compilerMode_buttonGroup.add(normal_radioButton);
  77. // compilerMode_buttonGroup.add(strict_radioButton);
  78. // compilerMode_buttonGroup.add(lenient_radioButton);
  79. preprocess_checkBox.setEnabled(false);
  80. useJavac_checkBox.setEnabled(false);
  81. workingDir_field.setEnabled(false);
  82. workingDir_label.setEnabled(false);
  83. } catch (Exception e) {
  84. Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
  85. }
  86. }
  87. public void loadOptions() throws IOException {
  88. if (Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel() != null) {
  89. oneFive_checkBox.setSelected(
  90. Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_5)
  91. );
  92. }
  93. if (Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel() != null) {
  94. assertions_checkBox.setSelected(
  95. Ajde.getDefault().getBuildManager().getBuildOptions().getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_4)
  96. );
  97. }
  98. preprocess_checkBox.setSelected(
  99. Ajde.getDefault().getBuildManager().getBuildOptions().getPreprocessMode()
  100. );
  101. useJavac_checkBox.setSelected(
  102. Ajde.getDefault().getBuildManager().getBuildOptions().getUseJavacMode()
  103. );
  104. incremental_checkBox.setSelected(
  105. Ajde.getDefault().getBuildManager().getBuildOptions().getIncrementalMode()
  106. );
  107. nonStandard_field.setText(
  108. Ajde.getDefault().getBuildManager().getBuildOptions().getNonStandardOptions()
  109. );
  110. workingDir_field.setText(
  111. Ajde.getDefault().getBuildManager().getBuildOptions().getWorkingOutputPath()
  112. );
  113. // if (Ajde.getDefault().getBuildManager().getBuildOptions().getStrictSpecMode()) {
  114. // strict_radioButton.setSelected(true);
  115. // } else if (Ajde.getDefault().getBuildManager().getBuildOptions().getLenientSpecMode()) {
  116. // lenient_radioButton.setSelected(true);
  117. // } else {
  118. // normal_radioButton.setSelected(true);
  119. // }
  120. }
  121. public void saveOptions() throws IOException {
  122. if (oneFive_checkBox.isSelected()) {
  123. AjdeUIManager.getDefault().getBuildOptions().setSourceCompatibilityLevel(CompilerOptions.VERSION_1_5);
  124. } else if (assertions_checkBox.isSelected()) {
  125. AjdeUIManager.getDefault().getBuildOptions().setSourceOnePointFourMode(true);
  126. AjdeUIManager.getDefault().getBuildOptions().setSourceCompatibilityLevel(CompilerOptions.VERSION_1_4);
  127. } else {
  128. AjdeUIManager.getDefault().getBuildOptions().setSourceCompatibilityLevel(CompilerOptions.VERSION_1_3);
  129. }
  130. AjdeUIManager.getDefault().getBuildOptions().setPreprocessMode(
  131. preprocess_checkBox.isSelected()
  132. );
  133. AjdeUIManager.getDefault().getBuildOptions().setUseJavacMode(
  134. useJavac_checkBox.isSelected()
  135. );
  136. AjdeUIManager.getDefault().getBuildOptions().setIncrementalMode(
  137. incremental_checkBox.isSelected()
  138. );
  139. AjdeUIManager.getDefault().getBuildOptions().setNonStandardOptions(
  140. nonStandard_field.getText()
  141. );
  142. AjdeUIManager.getDefault().getBuildOptions().setWorkingDir(
  143. workingDir_field.getText()
  144. );
  145. // AjdeUIManager.getDefault().getBuildOptions().setStrictSpecMode(strict_radioButton.isSelected());
  146. // AjdeUIManager.getDefault().getBuildOptions().setLenientSpecMode(lenient_radioButton.isSelected());
  147. }
  148. public static BuildOptionsPanel getDefault() {
  149. return INSTANCE;
  150. }
  151. private void jbInit() throws Exception {
  152. titledBorder1 =
  153. new TitledBorder(
  154. BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)),
  155. "ajc Options");
  156. border3 =
  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. border4 =
  163. BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158));
  164. // titledBorder2 =
  165. // new TitledBorder(
  166. // BorderFactory.createEtchedBorder(Color.white, new Color(156, 156, 158)),
  167. // "ajc Strictness Mode");
  168. // border5 =
  169. // BorderFactory.createCompoundBorder(
  170. // titledBorder2,
  171. // BorderFactory.createEmptyBorder(5, 5, 5, 5));
  172. // border1 =
  173. // BorderFactory.createCompoundBorder(
  174. // titledBorder2,
  175. // BorderFactory.createEmptyBorder(5, 5, 5, 5));
  176. border2 =
  177. BorderFactory.createCompoundBorder(
  178. titledBorder1,
  179. BorderFactory.createEmptyBorder(5, 5, 5, 5));
  180. titledBorder1.setTitle("ajc Options");
  181. titledBorder1.setTitleFont(new java.awt.Font("Dialog", 0, 11));
  182. // titledBorder2.setTitleFont(new java.awt.Font("Dialog", 0, 11));
  183. this.setLayout(borderLayout6);
  184. compileOptions_panel1.setLayout(borderLayout8);
  185. build_panel1.setLayout(borderLayout5);
  186. build_panel1.setFont(new java.awt.Font("Dialog", 0, 11));
  187. build_panel1.setBorder(border1);
  188. build_panel1.setMaximumSize(new Dimension(2147483647, 109));
  189. // normal_radioButton.setFont(new java.awt.Font("Dialog", 0, 11));
  190. // normal_radioButton.setText("Normal");
  191. // strict_radioButton.setText(
  192. // "Be extra strict in interpreting the Java specification");
  193. // strict_radioButton.setFont(new java.awt.Font("Dialog", 0, 11));
  194. // lenient_radioButton.setText(
  195. // "Be lenient in interpreting the Java specification");
  196. // lenient_radioButton.setFont(new java.awt.Font("Dialog", 0, 11));
  197. workingDir_field.setFont(new java.awt.Font("SansSerif", 0, 11));
  198. workingDir_field.setMinimumSize(new Dimension(200, 21));
  199. workingDir_field.setPreferredSize(new Dimension(350, 21));
  200. jPanel2.setLayout(borderLayout3);
  201. jPanel1.setLayout(borderLayout2);
  202. build_panel.setLayout(borderLayout4);
  203. build_panel.setBorder(border2);
  204. nonStandard_field.setFont(new java.awt.Font("SansSerif", 0, 11));
  205. nonStandard_field.setMinimumSize(new Dimension(200, 21));
  206. nonStandard_field.setPreferredSize(new Dimension(350, 21));
  207. compileOptions_panel.setLayout(borderLayout1);
  208. nonStandard_label.setText("Other compiler options:");
  209. nonStandard_label.setFont(new java.awt.Font("Dialog", 0, 11));
  210. nonStandard_label.setPreferredSize(new Dimension(80, 16));
  211. nonStandard_label.setToolTipText("");
  212. jPanel3.setLayout(borderLayout7);
  213. workingDir_label.setFont(new java.awt.Font("Dialog", 0, 11));
  214. workingDir_label.setPreferredSize(new Dimension(80, 16));
  215. workingDir_label.setText("Working directory: ");
  216. incrementalNote.setBackground(AjdeWidgetStyles.DEFAULT_BACKGROUND_COLOR);
  217. incrementalNote.setFont(new java.awt.Font("Dialog", 0, 11));
  218. incrementalNote.setEditable(false);
  219. incrementalNote.setText(INCREMENTAL_NOTE);
  220. spacer_label.setText(" ");
  221. assertions_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  222. assertions_checkBox.setText("Java 1.4 source compatibility mode");
  223. oneFive_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  224. oneFive_checkBox.setText("Java 1.5 source compatibility mode");
  225. incremental_checkBox.setText("Incremental compile");
  226. incremental_checkBox.setToolTipText("Only recompile necessary sources.");
  227. incremental_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  228. useJavac_checkBox.setText("Use javac to generate .class files");
  229. useJavac_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  230. preprocess_checkBox.setFont(new java.awt.Font("Dialog", 0, 11));
  231. preprocess_checkBox.setToolTipText("");
  232. preprocess_checkBox.setText("Only preprocess and generate .java source files");
  233. spacer_label1.setText(" ");
  234. this.add(jPanel3, BorderLayout.NORTH);
  235. jPanel2.add(workingDir_label, BorderLayout.CENTER);
  236. jPanel2.add(workingDir_field, BorderLayout.EAST);
  237. compileOptions_panel.add(options_box2, BorderLayout.CENTER);
  238. options_box2.add(incrementalNote, null);
  239. options_box2.add(spacer_label1, null);
  240. compileOptions_panel.add(options_box, BorderLayout.NORTH);
  241. options_box.add(assertions_checkBox, null);
  242. options_box.add(oneFive_checkBox, null);
  243. options_box.add(preprocess_checkBox, null);
  244. options_box.add(useJavac_checkBox, null);
  245. options_box.add(incremental_checkBox, null);
  246. options_box.add(spacer_label, null);
  247. fields_box.add(jPanel1, null);
  248. fields_box.add(jPanel2, null);
  249. jPanel1.add(nonStandard_label, BorderLayout.CENTER);
  250. jPanel1.add(nonStandard_field, BorderLayout.EAST);
  251. compileOptions_panel.add(fields_box, BorderLayout.SOUTH);
  252. jPanel3.add(build_panel, BorderLayout.CENTER);
  253. build_panel.add(compileOptions_panel, BorderLayout.NORTH);
  254. jPanel3.add(build_panel1, BorderLayout.SOUTH);
  255. build_panel1.add(compileOptions_panel1, BorderLayout.NORTH);
  256. compileOptions_panel1.add(options_box1, BorderLayout.NORTH);
  257. // options_box1.add(normal_radioButton, null);
  258. // options_box1.add(lenient_radioButton, null);
  259. // options_box1.add(strict_radioButton, null);
  260. this.add(jPanel4, BorderLayout.CENTER);
  261. }
  262. }