1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional.ide;
  18. import java.awt.BorderLayout;
  19. import java.awt.Button;
  20. import java.awt.Choice;
  21. import java.awt.Dialog;
  22. import java.awt.FileDialog;
  23. import java.awt.FlowLayout;
  24. import java.awt.Font;
  25. import java.awt.Frame;
  26. import java.awt.GridBagConstraints;
  27. import java.awt.GridBagLayout;
  28. import java.awt.Insets;
  29. import java.awt.Label;
  30. import java.awt.List;
  31. import java.awt.Menu;
  32. import java.awt.MenuBar;
  33. import java.awt.MenuItem;
  34. import java.awt.Panel;
  35. import java.awt.SystemColor;
  36. import java.awt.TextArea;
  37. import java.awt.TextField;
  38. import java.awt.Toolkit;
  39. import java.awt.event.ActionEvent;
  40. import java.awt.event.ActionListener;
  41. import java.awt.event.ItemEvent;
  42. import java.awt.event.ItemListener;
  43. import java.awt.event.TextEvent;
  44. import java.awt.event.TextListener;
  45. import java.awt.event.WindowEvent;
  46. import java.awt.event.WindowListener;
  47. import java.beans.PropertyChangeListener;
  48. import java.util.Vector;
  49. import org.apache.tools.ant.BuildEvent;
  50. import org.apache.tools.ant.BuildException;
  51. import org.apache.tools.ant.BuildListener;
  52. import org.apache.tools.ant.Project;
  53. import org.apache.tools.ant.util.DateUtils;
  54. import org.apache.tools.ant.util.StringUtils;
  55. /**
  56. * This is a simple grafical user interface to provide the information needed
  57. * by ANT and to start the build-process within IBM VisualAge for Java.
  58. * <p>
  59. * I was using AWT to make it independent from the JDK-version. Please don't
  60. * ask me for a Swing-version:I am very familiar with Swing and I really think
  61. * that it's not necessary for such a simple gui!
  62. * <p>
  63. * It is completely developed in VAJ using the visual composition editor.
  64. * About 90% of the code is generated by VAJ,
  65. * but in fact I did a lot of <i>code-beautification</i> ;-).
  66. * <p>
  67. * @version 1.0 h
  68. */
  69. public class VAJAntToolGUI extends Frame {
  70. /**
  71. * Members
  72. */
  73. private VAJBuildLogger logger = new VAJBuildLogger();
  74. private static final String lineSeparator = "\r\n";
  75. private PrivateEventHandler iEventHandler = new PrivateEventHandler();
  76. /**
  77. * Members of the main-window
  78. */
  79. // main model
  80. private VAJBuildInfo iBuildInfo = null;
  81. // Menue
  82. private MenuBar iAntMakeMenuBar = null;
  83. private Menu iFileMenu = null;
  84. private MenuItem iSaveMenuItem = null;
  85. private MenuItem iMenuSeparator = null;
  86. private MenuItem iShowLogMenuItem = null;
  87. private Menu iHelpMenu = null;
  88. private MenuItem iAboutMenuItem = null;
  89. // Container
  90. private Panel iContentsPane = null;
  91. private Panel iOptionenPanel = null;
  92. private Panel iCommandButtonPanel = null;
  93. // Project name
  94. private Label iProjectLabel = null;
  95. private Label iProjectText = null;
  96. // XML-file
  97. private Label iBuildFileLabel = null;
  98. private TextField iBuildFileTextField = null;
  99. private boolean iConnPtoP2Aligning = false;
  100. private Button iBrowseButton = null;
  101. private FileDialog iFileDialog = null;
  102. // Options
  103. private Choice iMessageOutputLevelChoice = null;
  104. private Label iMessageOutputLevelLabel = null;
  105. private Label iTargetLabel = null;
  106. private List iTargetList = null;
  107. // Command-buttons
  108. private Button iBuildButton = null;
  109. private Button iReloadButton = null;
  110. private Button iCloseButton = null;
  111. /**
  112. * log-Window
  113. */
  114. // Container
  115. private Frame iMessageFrame = null;
  116. private Panel iMessageCommandPanel = null;
  117. private Panel iMessageContentPanel = null;
  118. // Components
  119. private TextArea iMessageTextArea = null;
  120. private Button iMessageOkButton = null;
  121. private Button iMessageClearLogButton = null;
  122. /**
  123. * About-dialog
  124. */
  125. // Container
  126. private Dialog iAboutDialog = null;
  127. private Panel iAboutDialogContentPanel = null;
  128. private Panel iAboutInfoPanel = null;
  129. private Panel iAboutCommandPanel = null;
  130. // Labels
  131. private Label iAboutTitleLabel = null;
  132. private Label iAboutDevLabel = null;
  133. private Label iAboutContactLabel = null;
  134. // Buttons
  135. private Button iAboutOkButton = null;
  136. /**
  137. * This internal BuildLogger, to be honest, is just a BuildListener.
  138. * It does nearly the same as the DefaultLogger, but uses the Loggin-Window for output.
  139. */
  140. private class VAJBuildLogger implements BuildListener {
  141. private long startTime = System.currentTimeMillis();
  142. /**
  143. * VAJBuildLogger constructor comment.
  144. */
  145. public VAJBuildLogger() {
  146. super();
  147. }
  148. /**
  149. * Fired after the last target has finished. This event
  150. * will still be thrown if an error occurred during the build.
  151. *
  152. * @see BuildEvent#getException()
  153. */
  154. public void buildFinished(BuildEvent event) {
  155. getStopButton().setEnabled(false);
  156. getBuildButton().setEnabled(true);
  157. getBuildButton().requestFocus();
  158. Throwable error = event.getException();
  159. if (error == null) {
  160. getMessageTextArea().append(lineSeparator + "BUILD SUCCESSFUL");
  161. } else {
  162. logException(error);
  163. }
  164. getMessageTextArea().append(lineSeparator + "Total time: "
  165. + DateUtils.formatElapsedTime(System.currentTimeMillis() - startTime));
  166. }
  167. /**
  168. * Outputs an exception.
  169. */
  170. public void logException(Throwable error) {
  171. getMessageTextArea().append(lineSeparator + "BUILD FAILED" + lineSeparator);
  172. if (error instanceof BuildException) {
  173. getMessageTextArea().append(error.toString());
  174. Throwable nested = ((BuildException) error).getException();
  175. if (nested != null) {
  176. nested.printStackTrace(System.err);
  177. }
  178. } else {
  179. error.printStackTrace(System.err);
  180. }
  181. }
  182. /**
  183. * Fired before any targets are started.
  184. */
  185. public void buildStarted(BuildEvent event) {
  186. getStopButton().setEnabled(true);
  187. getBuildButton().setEnabled(false);
  188. getStopButton().requestFocus();
  189. startTime = System.currentTimeMillis();
  190. getMessageTextArea().append(lineSeparator);
  191. }
  192. /**
  193. * Fired whenever a message is logged.
  194. *
  195. * @see BuildEvent#getMessage()
  196. * @see BuildEvent#getPriority()
  197. */
  198. public void messageLogged(BuildEvent event) {
  199. if (event.getPriority() <= getBuildInfo().getOutputMessageLevel()) {
  200. String msg = "";
  201. if (event.getTask() != null) {
  202. msg = "[" + event.getTask().getTaskName() + "] ";
  203. }
  204. getMessageTextArea().append(lineSeparator + msg + event.getMessage());
  205. }
  206. }
  207. /**
  208. * Fired when a target has finished. This event will
  209. * still be thrown if an error occurred during the build.
  210. *
  211. * @see BuildEvent#getException()
  212. */
  213. public void targetFinished(BuildEvent event) {
  214. }
  215. /**
  216. * Fired when a target is started.
  217. *
  218. * @see BuildEvent#getTarget()
  219. */
  220. public void targetStarted(BuildEvent event) {
  221. if (getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO) {
  222. getMessageTextArea().append(lineSeparator + event.getTarget().getName() + ":");
  223. }
  224. }
  225. /**
  226. * Fired when a task has finished. This event will still
  227. * be throw if an error occurred during the build.
  228. *
  229. * @see BuildEvent#getException()
  230. */
  231. public void taskFinished(BuildEvent event) {
  232. }
  233. /**
  234. * Fired when a task is started.
  235. *
  236. * @see BuildEvent#getTask()
  237. */
  238. public void taskStarted(BuildEvent event) {
  239. }
  240. }
  241. /**
  242. * Eventhandler to handle all AWT-events
  243. */
  244. private class PrivateEventHandler
  245. implements ActionListener, ItemListener, TextListener,
  246. WindowListener, PropertyChangeListener {
  247. /**
  248. * ActionListener method
  249. */
  250. public void actionPerformed(ActionEvent e) {
  251. try {
  252. /* #### Main App-Frame #### */
  253. // browse XML-File with filechooser
  254. if (e.getSource() == VAJAntToolGUI.this.getBrowseButton()) {
  255. getFileDialog().setDirectory(getBuildFileTextField().getText().substring(0, getBuildFileTextField().getText().lastIndexOf('\\') + 1));
  256. getFileDialog().setFile("*.xml");
  257. getFileDialog().show();
  258. if (!getFileDialog().getFile().equals("")) {
  259. getBuildFileTextField().setText(getFileDialog().getDirectory()
  260. + getFileDialog().getFile());
  261. }
  262. }
  263. // dispose and exit application
  264. if (e.getSource() == VAJAntToolGUI.this.getCloseButton()) {
  265. dispose();
  266. System.exit(0);
  267. }
  268. // start build-process
  269. if (e.getSource() == VAJAntToolGUI.this.getBuildButton()) {
  270. executeTarget();
  271. }
  272. if (e.getSource() == VAJAntToolGUI.this.getStopButton()) {
  273. getBuildInfo().cancelBuild();
  274. }
  275. if (e.getSource() == VAJAntToolGUI.this.getReloadButton()) {
  276. try {
  277. getBuildInfo().updateTargetList();
  278. fillList();
  279. } catch (Throwable fileNotFound) {
  280. handleException(fileNotFound);
  281. getTargetList().removeAll();
  282. getBuildButton().setEnabled(false);
  283. }
  284. }
  285. // MenuItems
  286. if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem()) {
  287. saveBuildInfo();
  288. }
  289. if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem()) {
  290. getAboutDialog().show();
  291. }
  292. if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem()) {
  293. getMessageFrame().show();
  294. }
  295. /* #### About dialog #### */
  296. if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton()) {
  297. getAboutDialog().dispose();
  298. }
  299. /* #### Log frame #### */
  300. if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) {
  301. getMessageFrame().dispose();
  302. }
  303. if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton()) {
  304. getMessageTextArea().setText("");
  305. }
  306. if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) {
  307. getMessageFrame().dispose();
  308. }
  309. } catch (Throwable exc) {
  310. handleException(exc);
  311. }
  312. }
  313. /**
  314. * ItemListener method
  315. */
  316. public void itemStateChanged(ItemEvent e) {
  317. try {
  318. if (e.getSource() == VAJAntToolGUI.this.getTargetList()) {
  319. getBuildButton().setEnabled(true);
  320. }
  321. if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice()) {
  322. getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex());
  323. }
  324. if (e.getSource() == VAJAntToolGUI.this.getTargetList()) {
  325. getBuildInfo().setTarget(getTargetList().getSelectedItem());
  326. }
  327. } catch (Throwable exc) {
  328. handleException(exc);
  329. }
  330. }
  331. /**
  332. * PropertyChangeListener method
  333. */
  334. public void propertyChange(java.beans.PropertyChangeEvent evt) {
  335. if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo()
  336. && (evt.getPropertyName().equals("projectName"))) {
  337. connectProjectNameToLabel();
  338. }
  339. if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo()
  340. && (evt.getPropertyName().equals("buildFileName"))) {
  341. connectBuildFileNameToTextField();
  342. }
  343. }
  344. /**
  345. * TextListener method
  346. */
  347. public void textValueChanged(TextEvent e) {
  348. if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField()) {
  349. connectTextFieldToBuildFileName();
  350. }
  351. }
  352. /**
  353. * WindowListener methods
  354. */
  355. public void windowClosing(WindowEvent e) {
  356. try {
  357. if (e.getSource() == VAJAntToolGUI.this) {
  358. dispose();
  359. System.exit(0);
  360. }
  361. if (e.getSource() == VAJAntToolGUI.this.getAboutDialog()) {
  362. getAboutDialog().dispose();
  363. }
  364. if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) {
  365. getMessageFrame().dispose();
  366. }
  367. } catch (Throwable exc) {
  368. handleException(exc);
  369. }
  370. }
  371. public void windowActivated(WindowEvent e) {
  372. }
  373. public void windowClosed(WindowEvent e) {
  374. }
  375. public void windowDeactivated(WindowEvent e) {
  376. }
  377. public void windowDeiconified(WindowEvent e) {
  378. }
  379. public void windowIconified(WindowEvent e) {
  380. }
  381. public void windowOpened(WindowEvent e) {
  382. }
  383. }
  384. /**
  385. * AntMake default-constructor.
  386. */
  387. private VAJAntToolGUI() {
  388. super();
  389. initialize();
  390. }
  391. /**
  392. * AntMake constructor called by VAJAntTool integration.
  393. * @param newBuildInfo VAJBuildInfo
  394. */
  395. public VAJAntToolGUI(VAJBuildInfo newBuildInfo) {
  396. super();
  397. setBuildInfo(newBuildInfo);
  398. initialize();
  399. }
  400. /**
  401. * This method is used to center dialogs.
  402. */
  403. public static void centerDialog(Dialog dialog) {
  404. dialog.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (dialog.getSize().width / 2), (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (dialog.getSize().height / 2));
  405. }
  406. /**
  407. * connectBuildFileNameToTextField: (BuildInfo.buildFileName <--> BuildFileTextField.text)
  408. */
  409. private void connectBuildFileNameToTextField() {
  410. /* Set the target from the source */
  411. try {
  412. if (iConnPtoP2Aligning == false) {
  413. iConnPtoP2Aligning = true;
  414. if ((getBuildInfo() != null)) {
  415. getBuildFileTextField().setText(getBuildInfo().getBuildFileName());
  416. }
  417. iConnPtoP2Aligning = false;
  418. }
  419. } catch (Throwable iExc) {
  420. iConnPtoP2Aligning = false;
  421. handleException(iExc);
  422. }
  423. }
  424. /**
  425. * connectProjectNameToLabel: (BuildInfo.vajProjectName <--> ProjectText.text)
  426. */
  427. private void connectProjectNameToLabel() {
  428. /* Set the target from the source */
  429. try {
  430. if ((getBuildInfo() != null)) {
  431. getProjectText().setText(getBuildInfo().getVAJProjectName());
  432. }
  433. } catch (Throwable iExc) {
  434. handleException(iExc);
  435. }
  436. }
  437. /**
  438. * connectTextFieldToBuildFileName: (BuildInfo.buildFileName <--> BuildFileTextField.text)
  439. */
  440. private void connectTextFieldToBuildFileName() {
  441. /* Set the source from the target */
  442. try {
  443. if (iConnPtoP2Aligning == false) {
  444. iConnPtoP2Aligning = true;
  445. if ((getBuildInfo() != null)) {
  446. getBuildInfo().setBuildFileName(getBuildFileTextField().getText());
  447. }
  448. iConnPtoP2Aligning = false;
  449. }
  450. } catch (Throwable iExc) {
  451. iConnPtoP2Aligning = false;
  452. handleException(iExc);
  453. }
  454. }
  455. /**
  456. * external build of a .jar-file
  457. */
  458. private void executeTarget() {
  459. try {
  460. getMessageFrame().show();
  461. getBuildInfo().executeProject(logger);
  462. } catch (Throwable exc) {
  463. logger.logException(exc);
  464. }
  465. return;
  466. }
  467. /**
  468. * Fills the taget-list with project-targets
  469. */
  470. private void fillList() {
  471. getTargetList().removeAll();
  472. Vector targets = getBuildInfo().getProjectTargets();
  473. for (int i = 0; i < targets.size(); i++) {
  474. getTargetList().add(targets.elementAt(i).toString());
  475. }
  476. getTargetList().select(iBuildInfo.getProjectTargets().indexOf(iBuildInfo.getTarget()));
  477. if (getTargetList().getSelectedIndex() >= 0) {
  478. getBuildButton().setEnabled(true);
  479. }
  480. }
  481. /**
  482. * Return the AboutCommandPanel property value.
  483. * @return java.awt.Panel
  484. */
  485. private Panel getAboutCommandPanel() {
  486. if (iAboutCommandPanel == null) {
  487. try {
  488. iAboutCommandPanel = new Panel();
  489. iAboutCommandPanel.setName("AboutCommandPanel");
  490. iAboutCommandPanel.setLayout(new java.awt.FlowLayout());
  491. getAboutCommandPanel().add(getAboutOkButton(), getAboutOkButton().getName());
  492. } catch (Throwable iExc) {
  493. handleException(iExc);
  494. }
  495. }
  496. return iAboutCommandPanel;
  497. }
  498. /**
  499. * Return the AboutContactLabel property value.
  500. * @return java.awt.Label
  501. */
  502. private Label getAboutContactLabel() {
  503. if (iAboutContactLabel == null) {
  504. try {
  505. iAboutContactLabel = new Label();
  506. iAboutContactLabel.setName("AboutContactLabel");
  507. iAboutContactLabel.setAlignment(java.awt.Label.CENTER);
  508. iAboutContactLabel.setText("contact: wolf.siberski@tui.de or "
  509. + "christoph.wilhelms@tui.de");
  510. } catch (Throwable iExc) {
  511. handleException(iExc);
  512. }
  513. }
  514. return iAboutContactLabel;
  515. }
  516. /**
  517. * Return the AboutDevLabel property value.
  518. * @return java.awt.Label
  519. */
  520. private Label getAboutDevLabel() {
  521. if (iAboutDevLabel == null) {
  522. try {
  523. iAboutDevLabel = new Label();
  524. iAboutDevLabel.setName("AboutDevLabel");
  525. iAboutDevLabel.setAlignment(java.awt.Label.CENTER);
  526. iAboutDevLabel.setText("developed by Wolf Siberski & Christoph Wilhelms");
  527. } catch (Throwable iExc) {
  528. handleException(iExc);
  529. }
  530. }
  531. return iAboutDevLabel;
  532. }
  533. /**
  534. * Return the AboutDialog property value.
  535. * @return java.awt.Dialog
  536. */
  537. private Dialog getAboutDialog() {
  538. if (iAboutDialog == null) {
  539. try {
  540. iAboutDialog = new Dialog(this);
  541. iAboutDialog.setName("AboutDialog");
  542. iAboutDialog.setResizable(false);
  543. iAboutDialog.setLayout(new java.awt.BorderLayout());
  544. iAboutDialog.setBounds(550, 14, 383, 142);
  545. iAboutDialog.setModal(true);
  546. iAboutDialog.setTitle("About...");
  547. getAboutDialog().add(getAboutDialogContentPanel(), "Center");
  548. iAboutDialog.pack();
  549. centerDialog(iAboutDialog);
  550. } catch (Throwable iExc) {
  551. handleException(iExc);
  552. }
  553. }
  554. return iAboutDialog;
  555. }
  556. /**
  557. * Return the AboutDialogContentPanel property value.
  558. * @return java.awt.Panel
  559. */
  560. private Panel getAboutDialogContentPanel() {
  561. if (iAboutDialogContentPanel == null) {
  562. try {
  563. iAboutDialogContentPanel = new Panel();
  564. iAboutDialogContentPanel.setName("AboutDialogContentPanel");
  565. iAboutDialogContentPanel.setLayout(new java.awt.BorderLayout());
  566. getAboutDialogContentPanel().add(getAboutCommandPanel(), "South");
  567. getAboutDialogContentPanel().add(getAboutInfoPanel(), "Center");
  568. } catch (Throwable iExc) {
  569. handleException(iExc);
  570. }
  571. }
  572. return iAboutDialogContentPanel;
  573. }
  574. /**
  575. * Return the AboutInfoPanel property value.
  576. * @return java.awt.Panel
  577. */
  578. private Panel getAboutInfoPanel() {
  579. if (iAboutInfoPanel == null) {
  580. try {
  581. iAboutInfoPanel = new Panel();
  582. iAboutInfoPanel.setName("AboutInfoPanel");
  583. iAboutInfoPanel.setLayout(new GridBagLayout());
  584. GridBagConstraints constraintsAboutTitleLabel = new GridBagConstraints();
  585. constraintsAboutTitleLabel.gridx = 0; constraintsAboutTitleLabel.gridy = 0;
  586. constraintsAboutTitleLabel.fill = GridBagConstraints.HORIZONTAL;
  587. constraintsAboutTitleLabel.weightx = 1.0;
  588. constraintsAboutTitleLabel.weighty = 1.0;
  589. constraintsAboutTitleLabel.insets = new Insets(4, 0, 4, 0);
  590. getAboutInfoPanel().add(getAboutTitleLabel(), constraintsAboutTitleLabel);
  591. GridBagConstraints constraintsAboutDevLabel = new GridBagConstraints();
  592. constraintsAboutDevLabel.gridx = 0; constraintsAboutDevLabel.gridy = 1;
  593. constraintsAboutDevLabel.fill = GridBagConstraints.HORIZONTAL;
  594. constraintsAboutDevLabel.weightx = 1.0;
  595. constraintsAboutDevLabel.insets = new Insets(4, 0, 0, 0);
  596. getAboutInfoPanel().add(getAboutDevLabel(), constraintsAboutDevLabel);
  597. GridBagConstraints constraintsAboutContactLabel = new GridBagConstraints();
  598. constraintsAboutContactLabel.gridx = 0; constraintsAboutContactLabel.gridy = 2;
  599. constraintsAboutContactLabel.fill = GridBagConstraints.HORIZONTAL;
  600. constraintsAboutContactLabel.weightx = 1.0;
  601. constraintsAboutContactLabel.insets = new Insets(2, 0, 4, 0);
  602. getAboutInfoPanel().add(getAboutContactLabel(), constraintsAboutContactLabel);
  603. } catch (Throwable iExc) {
  604. handleException(iExc);
  605. }
  606. }
  607. return iAboutInfoPanel;
  608. }
  609. /**
  610. * Return the AboutMenuItem property value.
  611. * @return java.awt.MenuItem
  612. */
  613. private MenuItem getAboutMenuItem() {
  614. if (iAboutMenuItem == null) {
  615. try {
  616. iAboutMenuItem = new MenuItem();
  617. iAboutMenuItem.setLabel("About...");
  618. } catch (Throwable iExc) {
  619. handleException(iExc);
  620. }
  621. }
  622. return iAboutMenuItem;
  623. }
  624. /**
  625. * Return the AboutOkButton property value.
  626. * @return java.awt.Button
  627. */
  628. private Button getAboutOkButton() {
  629. if (iAboutOkButton == null) {
  630. try {
  631. iAboutOkButton = new Button();
  632. iAboutOkButton.setName("AboutOkButton");
  633. iAboutOkButton.setLabel("OK");
  634. } catch (Throwable iExc) {
  635. handleException(iExc);
  636. }
  637. }
  638. return iAboutOkButton;
  639. }
  640. /**
  641. * Return the AboutTitleLabel property value.
  642. * @return java.awt.Label
  643. */
  644. private Label getAboutTitleLabel() {
  645. if (iAboutTitleLabel == null) {
  646. try {
  647. iAboutTitleLabel = new Label();
  648. iAboutTitleLabel.setName("AboutTitleLabel");
  649. iAboutTitleLabel.setFont(new Font("Arial", 1, 12));
  650. iAboutTitleLabel.setAlignment(Label.CENTER);
  651. iAboutTitleLabel.setText("Ant VisualAge for Java Tool-Integration");
  652. } catch (Throwable iExc) {
  653. handleException(iExc);
  654. }
  655. }
  656. return iAboutTitleLabel;
  657. }
  658. /**
  659. * Return the AntMakeMenuBar property value.
  660. * @return java.awt.MenuBar
  661. */
  662. private MenuBar getAntMakeMenuBar() {
  663. if (iAntMakeMenuBar == null) {
  664. try {
  665. iAntMakeMenuBar = new MenuBar();
  666. iAntMakeMenuBar.add(getFileMenu());
  667. iAntMakeMenuBar.add(getHelpMenu());
  668. } catch (Throwable iExc) {
  669. handleException(iExc);
  670. }
  671. }
  672. return iAntMakeMenuBar;
  673. }
  674. /**
  675. * Return the BrowseButton property value.
  676. * @return Button
  677. */
  678. private Button getBrowseButton() {
  679. if (iBrowseButton == null) {
  680. try {
  681. iBrowseButton = new Button();
  682. iBrowseButton.setName("BrowseButton");
  683. iBrowseButton.setLabel("...");
  684. } catch (Throwable iExc) {
  685. handleException(iExc);
  686. }
  687. }
  688. return iBrowseButton;
  689. }
  690. /**
  691. * Return the BuildButton property value.
  692. * @return java.awt.Button
  693. */
  694. private Button getBuildButton() {
  695. if (iBuildButton == null) {
  696. try {
  697. iBuildButton = new Button();
  698. iBuildButton.setName("BuildButton");
  699. iBuildButton.setLabel("Execute");
  700. } catch (Throwable iExc) {
  701. handleException(iExc);
  702. }
  703. }
  704. return iBuildButton;
  705. }
  706. /**
  707. * Return the BuildFileLabel property value.
  708. * @return java.awt.Label
  709. */
  710. private Label getBuildFileLabel() {
  711. if (iBuildFileLabel == null) {
  712. try {
  713. iBuildFileLabel = new Label();
  714. iBuildFileLabel.setName("BuildFileLabel");
  715. iBuildFileLabel.setText("Ant-Buildfile:");
  716. } catch (Throwable iExc) {
  717. handleException(iExc);
  718. }
  719. }
  720. return iBuildFileLabel;
  721. }
  722. /**
  723. * Return the BuildFileTextField property value.
  724. * @return java.awt.TextField
  725. */
  726. private TextField getBuildFileTextField() {
  727. if (iBuildFileTextField == null) {
  728. try {
  729. iBuildFileTextField = new TextField();
  730. iBuildFileTextField.setName("BuildFileTextField");
  731. iBuildFileTextField.setBackground(SystemColor.textHighlightText);
  732. } catch (Throwable iExc) {
  733. handleException(iExc);
  734. }
  735. }
  736. return iBuildFileTextField;
  737. }
  738. /**
  739. * Return the BuildInfo property value.
  740. * @return org.apache.tools.ant.taskdefs.optional.ide.VAJBuildInfo
  741. */
  742. private VAJBuildInfo getBuildInfo() {
  743. return iBuildInfo;
  744. }
  745. /**
  746. * Return the CloseButton property value.
  747. * @return java.awt.Button
  748. */
  749. private Button getCloseButton() {
  750. if (iCloseButton == null) {
  751. try {
  752. iCloseButton = new Button();
  753. iCloseButton.setName("CloseButton");
  754. iCloseButton.setLabel("Close");
  755. } catch (Throwable iExc) {
  756. handleException(iExc);
  757. }
  758. }
  759. return iCloseButton;
  760. }
  761. /**
  762. * Return the CommandButtonPanel property value.
  763. * @return java.awt.Panel
  764. */
  765. private Panel getCommandButtonPanel() {
  766. if (iCommandButtonPanel == null) {
  767. try {
  768. iCommandButtonPanel = new Panel();
  769. iCommandButtonPanel.setName("CommandButtonPanel");
  770. iCommandButtonPanel.setLayout(getCommandButtonPanelFlowLayout());
  771. iCommandButtonPanel.setBackground(SystemColor.control);
  772. iCommandButtonPanel.add(getReloadButton());
  773. iCommandButtonPanel.add(getBuildButton());
  774. iCommandButtonPanel.add(getStopButton());
  775. iCommandButtonPanel.add(getCloseButton());
  776. } catch (Throwable iExc) {
  777. handleException(iExc);
  778. }
  779. }
  780. return iCommandButtonPanel;
  781. }
  782. /**
  783. * Return the CommandButtonPanelFlowLayout property value.
  784. * @return java.awt.FlowLayout
  785. */
  786. private FlowLayout getCommandButtonPanelFlowLayout() {
  787. FlowLayout iCommandButtonPanelFlowLayout = null;
  788. try {
  789. /* Create part */
  790. iCommandButtonPanelFlowLayout = new FlowLayout();
  791. iCommandButtonPanelFlowLayout.setAlignment(FlowLayout.RIGHT);
  792. } catch (Throwable iExc) {
  793. handleException(iExc);
  794. }
  795. return iCommandButtonPanelFlowLayout;
  796. }
  797. /**
  798. * Return the ContentsPane property value.
  799. * @return java.awt.Panel
  800. */
  801. private Panel getContentsPane() {
  802. if (iContentsPane == null) {
  803. try {
  804. iContentsPane = new Panel();
  805. iContentsPane.setName("ContentsPane");
  806. iContentsPane.setLayout(new BorderLayout());
  807. getContentsPane().add(getCommandButtonPanel(), "South");
  808. getContentsPane().add(getOptionenPanel(), "Center");
  809. } catch (Throwable iExc) {
  810. handleException(iExc);
  811. }
  812. }
  813. return iContentsPane;
  814. }
  815. /**
  816. * Return the FileDialog property value.
  817. * @return java.awt.FileDialog
  818. */
  819. private FileDialog getFileDialog() {
  820. if (iFileDialog == null) {
  821. try {
  822. iFileDialog = new FileDialog(this);
  823. iFileDialog.setName("FileDialog");
  824. iFileDialog.setLayout(null);
  825. centerDialog(iFileDialog);
  826. } catch (Throwable iExc) {
  827. handleException(iExc);
  828. }
  829. }
  830. return iFileDialog;
  831. }
  832. /**
  833. * Return the FileMenu property value.
  834. * @return java.awt.Menu
  835. */
  836. private Menu getFileMenu() {
  837. if (iFileMenu == null) {
  838. try {
  839. iFileMenu = new Menu();
  840. iFileMenu.setLabel("File");
  841. iFileMenu.add(getSaveMenuItem());
  842. iFileMenu.add(getMenuSeparator());
  843. iFileMenu.add(getShowLogMenuItem());
  844. } catch (Throwable iExc) {
  845. handleException(iExc);
  846. }
  847. }
  848. return iFileMenu;
  849. }
  850. /**
  851. * Return the HelpMenu property value.
  852. * @return java.awt.Menu
  853. */
  854. private Menu getHelpMenu() {
  855. if (iHelpMenu == null) {
  856. try {
  857. iHelpMenu = new Menu();
  858. iHelpMenu.setLabel("Help");
  859. iHelpMenu.add(getAboutMenuItem());
  860. } catch (Throwable iExc) {
  861. handleException(iExc);
  862. }
  863. }
  864. return iHelpMenu;
  865. }
  866. /**
  867. * Return the MenuSeparator1 property value.
  868. * @return java.awt.MenuItem
  869. */
  870. private MenuItem getMenuSeparator() {
  871. if (iMenuSeparator == null) {
  872. try {
  873. iMenuSeparator = new MenuItem();
  874. iMenuSeparator.setLabel("-");
  875. } catch (Throwable iExc) {
  876. handleException(iExc);
  877. }
  878. }
  879. return iMenuSeparator;
  880. }
  881. /**
  882. * Return the MessageClearLogButton property value.
  883. * @return java.awt.Button
  884. */
  885. private Button getMessageClearLogButton() {
  886. if (iMessageClearLogButton == null) {
  887. try {
  888. iMessageClearLogButton = new Button();
  889. iMessageClearLogButton.setName("MessageClearLogButton");
  890. iMessageClearLogButton.setLabel("Clear Log");
  891. } catch (Throwable iExc) {
  892. handleException(iExc);
  893. }
  894. }
  895. return iMessageClearLogButton;
  896. }
  897. /**
  898. * Return the MessageCommandPanel property value.
  899. * @return java.awt.Panel
  900. */
  901. private Panel getMessageCommandPanel() {
  902. if (iMessageCommandPanel == null) {
  903. try {
  904. iMessageCommandPanel = new Panel();
  905. iMessageCommandPanel.setName("MessageCommandPanel");
  906. iMessageCommandPanel.setLayout(new FlowLayout());
  907. getMessageCommandPanel().add(getMessageClearLogButton(),
  908. getMessageClearLogButton().getName());
  909. getMessageCommandPanel().add(getMessageOkButton(),
  910. getMessageOkButton().getName());
  911. } catch (Throwable iExc) {
  912. handleException(iExc);
  913. }
  914. }
  915. return iMessageCommandPanel;
  916. }
  917. /**
  918. * Return the MessageContentPanel property value.
  919. * @return java.awt.Panel
  920. */
  921. private Panel getMessageContentPanel() {
  922. if (iMessageContentPanel == null) {
  923. try {
  924. iMessageContentPanel = new Panel();
  925. iMessageContentPanel.setName("MessageContentPanel");
  926. iMessageContentPanel.setLayout(new BorderLayout());
  927. iMessageContentPanel.setBackground(SystemColor.control);
  928. getMessageContentPanel().add(getMessageTextArea(), "Center");
  929. getMessageContentPanel().add(getMessageCommandPanel(), "South");
  930. } catch (Throwable iExc) {
  931. handleException(iExc);
  932. }
  933. }
  934. return iMessageContentPanel;
  935. }
  936. /**
  937. * Return the MessageFrame property value.
  938. * @return java.awt.Frame
  939. */
  940. private Frame getMessageFrame() {
  941. if (iMessageFrame == null) {
  942. try {
  943. iMessageFrame = new Frame();
  944. iMessageFrame.setName("MessageFrame");
  945. iMessageFrame.setLayout(new BorderLayout());
  946. iMessageFrame.setBounds(0, 0, 750, 250);
  947. iMessageFrame.setTitle("Message Log");
  948. iMessageFrame.add(getMessageContentPanel(), "Center");
  949. iMessageFrame.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2)
  950. - (iMessageFrame.getSize().width / 2),
  951. (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2));
  952. } catch (Throwable iExc) {
  953. handleException(iExc);
  954. }
  955. }
  956. return iMessageFrame;
  957. }
  958. /**
  959. * Return the MessageOkButton property value.
  960. * @return java.awt.Button
  961. */
  962. private Button getMessageOkButton() {
  963. if (iMessageOkButton == null) {
  964. try {
  965. iMessageOkButton = new Button();
  966. iMessageOkButton.setName("MessageOkButton");
  967. iMessageOkButton.setLabel("Close");
  968. } catch (Throwable iExc) {
  969. handleException(iExc);
  970. }
  971. }
  972. return iMessageOkButton;
  973. }
  974. /**
  975. * Return the MessageOutputLevelChoice property value.
  976. * @return java.awt.Choice
  977. */
  978. private Choice getMessageOutputLevelChoice() {
  979. if (iMessageOutputLevelChoice == null) {
  980. try {
  981. iMessageOutputLevelChoice = new Choice();
  982. iMessageOutputLevelChoice.setName("MessageOutputLevelChoice");
  983. iMessageOutputLevelChoice.add("Error");
  984. iMessageOutputLevelChoice.add("Warning");
  985. iMessageOutputLevelChoice.add("Info");
  986. iMessageOutputLevelChoice.add("Verbose");
  987. iMessageOutputLevelChoice.add("Debug");
  988. iMessageOutputLevelChoice.select(2);
  989. } catch (Throwable iExc) {
  990. handleException(iExc);
  991. }
  992. }
  993. return iMessageOutputLevelChoice;
  994. }
  995. /**
  996. * Return the MessageOutputLevelLabel property value.
  997. * @return java.awt.Label
  998. */
  999. private Label getMessageOutputLevelLabel() {
  1000. if (iMessageOutputLevelLabel == null) {
  1001. try {
  1002. iMessageOutputLevelLabel = new Label();
  1003. iMessageOutputLevelLabel.setName("MessageOutputLevelLabel");
  1004. iMessageOutputLevelLabel.setText("Message Level:");
  1005. } catch (Throwable iExc) {
  1006. handleException(iExc);
  1007. }
  1008. }
  1009. return iMessageOutputLevelLabel;
  1010. }
  1011. /**
  1012. * Return the MessageTextArea property value.
  1013. * @return java.awt.TextArea
  1014. */
  1015. private TextArea getMessageTextArea() {
  1016. if (iMessageTextArea == null) {
  1017. try {
  1018. iMessageTextArea = new TextArea();
  1019. iMessageTextArea.setName("MessageTextArea");
  1020. iMessageTextArea.setFont(new Font("monospaced", 0, 12));
  1021. iMessageTextArea.setText("");
  1022. iMessageTextArea.setEditable(false);
  1023. iMessageTextArea.setEnabled(true);
  1024. } catch (Throwable iExc) {
  1025. handleException(iExc);
  1026. }
  1027. }
  1028. return iMessageTextArea;
  1029. }
  1030. /**
  1031. * Return the Panel1 property value.
  1032. * @return java.awt.Panel
  1033. */
  1034. private Panel getOptionenPanel() {
  1035. if (iOptionenPanel == null) {
  1036. try {
  1037. iOptionenPanel = new Panel();
  1038. iOptionenPanel.setName("OptionenPanel");
  1039. iOptionenPanel.setLayout(new GridBagLayout());
  1040. iOptionenPanel.setBackground(SystemColor.control);
  1041. GridBagConstraints constraintsProjectLabel = new GridBagConstraints();
  1042. constraintsProjectLabel.gridx = 0; constraintsProjectLabel.gridy = 0;
  1043. constraintsProjectLabel.anchor = GridBagConstraints.WEST;
  1044. constraintsProjectLabel.insets = new Insets(4, 4, 4, 4);
  1045. getOptionenPanel().add(getProjectLabel(), constraintsProjectLabel);
  1046. GridBagConstraints constraintsBuildFileLabel = new GridBagConstraints();
  1047. constraintsBuildFileLabel.gridx = 0; constraintsBuildFileLabel.gridy = 1;
  1048. constraintsBuildFileLabel.anchor = GridBagConstraints.WEST;
  1049. constraintsBuildFileLabel.insets = new Insets(4, 4, 4, 4);
  1050. getOptionenPanel().add(getBuildFileLabel(), constraintsBuildFileLabel);
  1051. GridBagConstraints constraintsTargetLabel = new GridBagConstraints();
  1052. constraintsTargetLabel.gridx = 0; constraintsTargetLabel.gridy = 2;
  1053. constraintsTargetLabel.anchor = GridBagConstraints.NORTHWEST;
  1054. constraintsTargetLabel.insets = new Insets(4, 4, 4, 4);
  1055. getOptionenPanel().add(getTargetLabel(), constraintsTargetLabel);
  1056. GridBagConstraints constraintsProjectText = new GridBagConstraints();
  1057. constraintsProjectText.gridx = 1; constraintsProjectText.gridy = 0;
  1058. constraintsProjectText.gridwidth = 2;
  1059. constraintsProjectText.fill = GridBagConstraints.HORIZONTAL;
  1060. constraintsProjectText.anchor = GridBagConstraints.WEST;
  1061. constraintsProjectText.insets = new Insets(4, 4, 4, 4);
  1062. getOptionenPanel().add(getProjectText(), constraintsProjectText);
  1063. GridBagConstraints constraintsBuildFileTextField = new GridBagConstraints();
  1064. constraintsBuildFileTextField.gridx = 1; constraintsBuildFileTextField.gridy = 1;
  1065. constraintsBuildFileTextField.fill = GridBagConstraints.HORIZONTAL;
  1066. constraintsBuildFileTextField.anchor = GridBagConstraints.WEST;
  1067. constraintsBuildFileTextField.weightx = 1.0;
  1068. constraintsBuildFileTextField.insets = new Insets(4, 4, 4, 4);
  1069. getOptionenPanel().add(getBuildFileTextField(), constraintsBuildFileTextField);
  1070. GridBagConstraints constraintsBrowseButton = new GridBagConstraints();
  1071. constraintsBrowseButton.gridx = 2; constraintsBrowseButton.gridy = 1;
  1072. constraintsBrowseButton.insets = new Insets(4, 4, 4, 4);
  1073. getOptionenPanel().add(getBrowseButton(), constraintsBrowseButton);
  1074. GridBagConstraints constraintsTargetList = new GridBagConstraints();
  1075. constraintsTargetList.gridx = 1; constraintsTargetList.gridy = 2;
  1076. constraintsTargetList.gridheight = 2;
  1077. constraintsTargetList.fill = GridBagConstraints.BOTH;
  1078. constraintsTargetList.weightx = 1.0;
  1079. constraintsTargetList.weighty = 1.0;
  1080. constraintsTargetList.insets = new Insets(4, 4, 4, 4);
  1081. getOptionenPanel().add(getTargetList(), constraintsTargetList);
  1082. GridBagConstraints constraintsMessageOutputLevelLabel
  1083. = new GridBagConstraints();
  1084. constraintsMessageOutputLevelLabel.gridx = 0;
  1085. constraintsMessageOutputLevelLabel.gridy = 4;
  1086. constraintsMessageOutputLevelLabel.anchor = GridBagConstraints.WEST;
  1087. constraintsMessageOutputLevelLabel.insets = new Insets(4, 4, 4, 4);
  1088. getOptionenPanel().add(getMessageOutputLevelLabel(),
  1089. constraintsMessageOutputLevelLabel);
  1090. GridBagConstraints constraintsMessageOutputLevelChoice
  1091. = new GridBagConstraints();
  1092. constraintsMessageOutputLevelChoice.gridx = 1;
  1093. constraintsMessageOutputLevelChoice.gridy = 4;
  1094. constraintsMessageOutputLevelChoice.fill = GridBagConstraints.HORIZONTAL;
  1095. constraintsMessageOutputLevelChoice.anchor = GridBagConstraints.WEST;
  1096. constraintsMessageOutputLevelChoice.weightx = 1.0;
  1097. constraintsMessageOutputLevelChoice.insets = new Insets(4, 4, 4, 4);
  1098. getOptionenPanel().add(getMessageOutputLevelChoice(),
  1099. constraintsMessageOutputLevelChoice);
  1100. } catch (Throwable iExc) {
  1101. handleException(iExc);
  1102. }
  1103. }
  1104. return iOptionenPanel;
  1105. }
  1106. /**
  1107. * Return the ProjectLabel property value.
  1108. * @return java.awt.Label
  1109. */
  1110. private Label getProjectLabel() {
  1111. if (iProjectLabel == null) {
  1112. try {
  1113. iProjectLabel = new Label();
  1114. iProjectLabel.setName("ProjectLabel");
  1115. iProjectLabel.setText("Projectname:");
  1116. } catch (Throwable iExc) {
  1117. handleException(iExc);
  1118. }
  1119. }
  1120. return iProjectLabel;
  1121. }
  1122. /**
  1123. * Return the ProjectText property value.
  1124. * @return java.awt.Label
  1125. */
  1126. private Label getProjectText() {
  1127. if (iProjectText == null) {
  1128. try {
  1129. iProjectText = new Label();
  1130. iProjectText.setName("ProjectText");
  1131. iProjectText.setText(" ");
  1132. } catch (Throwable iExc) {
  1133. handleException(iExc);
  1134. }
  1135. }
  1136. return iProjectText;
  1137. }
  1138. /**
  1139. * Return the ReloadButton property value.
  1140. * @return java.awt.Button
  1141. */
  1142. private Button getReloadButton() {
  1143. if (iReloadButton == null) {
  1144. try {
  1145. iReloadButton = new Button();
  1146. iReloadButton.setName("ReloadButton");
  1147. iReloadButton.setLabel("(Re)Load");
  1148. } catch (Throwable iExc) {
  1149. handleException(iExc);
  1150. }
  1151. }
  1152. return iReloadButton;
  1153. }
  1154. /**
  1155. * Return the SaveMenuItem property value.
  1156. * @return java.awt.MenuItem
  1157. */
  1158. private MenuItem getSaveMenuItem() {
  1159. if (iSaveMenuItem == null) {
  1160. try {
  1161. iSaveMenuItem = new MenuItem();
  1162. iSaveMenuItem.setLabel("Save BuildInfo To Repository");
  1163. } catch (Throwable iExc) {
  1164. handleException(iExc);
  1165. }
  1166. }
  1167. return iSaveMenuItem;
  1168. }
  1169. /**
  1170. * Return the ShowLogMenuItem property value.
  1171. * @return java.awt.MenuItem
  1172. */
  1173. private MenuItem getShowLogMenuItem() {
  1174. if (iShowLogMenuItem == null) {
  1175. try {
  1176. iShowLogMenuItem = new MenuItem();
  1177. iShowLogMenuItem.setLabel("Log");
  1178. } catch (Throwable iExc) {
  1179. handleException(iExc);
  1180. }
  1181. }
  1182. return iShowLogMenuItem;
  1183. }
  1184. /**
  1185. * Return the TargetLabel property value.
  1186. * @return java.awt.Label
  1187. */
  1188. private Label getTargetLabel() {
  1189. if (iTargetLabel == null) {
  1190. try {
  1191. iTargetLabel = new Label();
  1192. iTargetLabel.setName("TargetLabel");
  1193. iTargetLabel.setText("Target:");
  1194. iTargetLabel.setEnabled(true);
  1195. } catch (Throwable iExc) {
  1196. handleException(iExc);
  1197. }
  1198. }
  1199. return iTargetLabel;
  1200. }
  1201. /**
  1202. * Return the TargetList property value.
  1203. * @return java.awt.List
  1204. */
  1205. private List getTargetList() {
  1206. if (iTargetList == null) {
  1207. try {
  1208. iTargetList = new List();
  1209. iTargetList.setName("TargetList");
  1210. iTargetList.setEnabled(true);
  1211. } catch (Throwable iExc) {
  1212. handleException(iExc);
  1213. }
  1214. }
  1215. return iTargetList;
  1216. }
  1217. /**
  1218. * Called whenever the part throws an exception.
  1219. * @param exception Throwable
  1220. */
  1221. private void handleException(Throwable exception) {
  1222. // Write exceptions to the log-window
  1223. String trace = StringUtils.getStackTrace(exception);
  1224. getMessageTextArea().append(lineSeparator + lineSeparator + trace);
  1225. getMessageFrame().show();
  1226. }
  1227. /**
  1228. * Initializes connections
  1229. * @exception Exception The exception description.
  1230. */
  1231. private void initConnections() throws Exception {
  1232. this.addWindowListener(iEventHandler);
  1233. getBrowseButton().addActionListener(iEventHandler);
  1234. getCloseButton().addActionListener(iEventHandler);
  1235. getBuildButton().addActionListener(iEventHandler);
  1236. getStopButton().addActionListener(iEventHandler);
  1237. getSaveMenuItem().addActionListener(iEventHandler);
  1238. getAboutOkButton().addActionListener(iEventHandler);
  1239. getAboutMenuItem().addActionListener(iEventHandler);
  1240. getMessageOkButton().addActionListener(iEventHandler);
  1241. getMessageClearLogButton().addActionListener(iEventHandler);
  1242. getMessageOkButton().addActionListener(iEventHandler);
  1243. getShowLogMenuItem().addActionListener(iEventHandler);
  1244. getAboutDialog().addWindowListener(iEventHandler);
  1245. getMessageFrame().addWindowListener(iEventHandler);
  1246. getReloadButton().addActionListener(iEventHandler);
  1247. getTargetList().addItemListener(iEventHandler);
  1248. getMessageOutputLevelChoice().addItemListener(iEventHandler);
  1249. getBuildFileTextField().addTextListener(iEventHandler);
  1250. connectProjectNameToLabel();
  1251. connectBuildFileNameToTextField();
  1252. }
  1253. /**
  1254. * Initialize the class.
  1255. */
  1256. private void initialize() {
  1257. try {
  1258. setName("AntMake");
  1259. setMenuBar(getAntMakeMenuBar());
  1260. setLayout(new java.awt.BorderLayout());
  1261. setSize(389, 222);
  1262. setTitle("Ant VisualAge for Java Tool-Integration");
  1263. add(getContentsPane(), "Center");
  1264. initConnections();
  1265. } catch (Throwable iExc) {
  1266. handleException(iExc);
  1267. }
  1268. setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2)
  1269. - (getSize().width / 2),
  1270. (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2)
  1271. - (getSize().height));
  1272. if ((getTargetList().getItemCount() == 0) || (getTargetList().getSelectedIndex() < 0)) {
  1273. getBuildButton().setEnabled(false);
  1274. }
  1275. }
  1276. /**
  1277. * Saves the build-informations to repository
  1278. */
  1279. private void saveBuildInfo() {
  1280. try {
  1281. VAJAntTool.saveBuildData(getBuildInfo());
  1282. } catch (Throwable exc) {
  1283. // This Exception occurs when you try to write into a versioned project
  1284. handleException(exc);
  1285. }
  1286. return;
  1287. }
  1288. /**
  1289. * Set the BuildInfo to a new value.
  1290. * @param newValue org.apache.tools.ant.taskdefs.optional.vaj.VAJBuildInfo
  1291. */
  1292. private void setBuildInfo(VAJBuildInfo newValue) {
  1293. if (iBuildInfo != newValue) {
  1294. try {
  1295. /* Stop listening for events from the current object */
  1296. if (iBuildInfo != null) {
  1297. iBuildInfo.removePropertyChangeListener(iEventHandler);
  1298. }
  1299. iBuildInfo = newValue;
  1300. /* Listen for events from the new object */
  1301. if (iBuildInfo != null) {
  1302. iBuildInfo.addPropertyChangeListener(iEventHandler);
  1303. }
  1304. connectProjectNameToLabel();
  1305. connectBuildFileNameToTextField();
  1306. // Select the log-level given by BuildInfo
  1307. getMessageOutputLevelChoice().select(iBuildInfo.getOutputMessageLevel());
  1308. fillList();
  1309. // BuildInfo can conly be saved to a VAJ project if tool API
  1310. // is called via the projects context-menu
  1311. if ((iBuildInfo.getVAJProjectName() == null)
  1312. || (iBuildInfo.getVAJProjectName().equals(""))) {
  1313. getSaveMenuItem().setEnabled(false);
  1314. }
  1315. } catch (Throwable iExc) {
  1316. handleException(iExc);
  1317. }
  1318. }
  1319. }
  1320. private Button iStopButton = null;
  1321. /**
  1322. * Return the StopButton property value.
  1323. * @return java.awt.Button
  1324. */
  1325. private Button getStopButton() {
  1326. if (iStopButton == null) {
  1327. try {
  1328. iStopButton = new Button();
  1329. iStopButton.setName("StopButton");
  1330. iStopButton.setLabel("Stop");
  1331. iStopButton.setEnabled(false);
  1332. } catch (Throwable iExc) {
  1333. handleException(iExc);
  1334. }
  1335. }
  1336. return iStopButton;
  1337. }
  1338. }