1 17 18 package org.apache.tools.ant.taskdefs.optional.ide; 19 20 21 import java.awt.BorderLayout ; 22 import java.awt.Button ; 23 import java.awt.Choice ; 24 import java.awt.Dialog ; 25 import java.awt.FileDialog ; 26 import java.awt.FlowLayout ; 27 import java.awt.Font ; 28 import java.awt.Frame ; 29 import java.awt.GridBagConstraints ; 30 import java.awt.GridBagLayout ; 31 import java.awt.Insets ; 32 import java.awt.Label ; 33 import java.awt.List ; 34 import java.awt.Menu ; 35 import java.awt.MenuBar ; 36 import java.awt.MenuItem ; 37 import java.awt.Panel ; 38 import java.awt.SystemColor ; 39 import java.awt.TextArea ; 40 import java.awt.TextField ; 41 import java.awt.Toolkit ; 42 import java.awt.event.ActionEvent ; 43 import java.awt.event.ActionListener ; 44 import java.awt.event.ItemEvent ; 45 import java.awt.event.ItemListener ; 46 import java.awt.event.TextEvent ; 47 import java.awt.event.TextListener ; 48 import java.awt.event.WindowEvent ; 49 import java.awt.event.WindowListener ; 50 import java.beans.PropertyChangeListener ; 51 import java.util.Vector ; 52 import org.apache.tools.ant.BuildEvent; 53 import org.apache.tools.ant.BuildException; 54 import org.apache.tools.ant.BuildListener; 55 import org.apache.tools.ant.Project; 56 import org.apache.tools.ant.util.DateUtils; 57 import org.apache.tools.ant.util.StringUtils; 58 59 73 public class VAJAntToolGUI extends Frame { 74 77 private VAJBuildLogger logger = new VAJBuildLogger(); 78 private static final String lineSeparator = "\r\n"; 79 private PrivateEventHandler iEventHandler = new PrivateEventHandler(); 80 81 84 private VAJBuildInfo iBuildInfo = null; 86 private MenuBar iAntMakeMenuBar = null; 88 private Menu iFileMenu = null; 89 private MenuItem iSaveMenuItem = null; 90 private MenuItem iMenuSeparator = null; 91 private MenuItem iShowLogMenuItem = null; 92 private Menu iHelpMenu = null; 93 private MenuItem iAboutMenuItem = null; 94 private Panel iContentsPane = null; 96 private Panel iOptionenPanel = null; 97 private Panel iCommandButtonPanel = null; 98 private Label iProjectLabel = null; 100 private Label iProjectText = null; 101 private Label iBuildFileLabel = null; 103 private TextField iBuildFileTextField = null; 104 private boolean iConnPtoP2Aligning = false; 105 private Button iBrowseButton = null; 106 private FileDialog iFileDialog = null; 107 private Choice iMessageOutputLevelChoice = null; 109 private Label iMessageOutputLevelLabel = null; 110 private Label iTargetLabel = null; 111 private List iTargetList = null; 112 private Button iBuildButton = null; 114 private Button iReloadButton = null; 115 private Button iCloseButton = null; 116 119 private Frame iMessageFrame = null; 121 private Panel iMessageCommandPanel = null; 122 private Panel iMessageContentPanel = null; 123 private TextArea iMessageTextArea = null; 125 private Button iMessageOkButton = null; 126 private Button iMessageClearLogButton = null; 127 130 private Dialog iAboutDialog = null; 132 private Panel iAboutDialogContentPanel = null; 133 private Panel iAboutInfoPanel = null; 134 private Panel iAboutCommandPanel = null; 135 private Label iAboutTitleLabel = null; 137 private Label iAboutDevLabel = null; 138 private Label iAboutContactLabel = null; 139 private Button iAboutOkButton = null; 141 142 146 private class VAJBuildLogger implements BuildListener { 147 private long startTime = System.currentTimeMillis(); 148 149 152 public VAJBuildLogger() { 153 super(); 154 } 155 156 162 public void buildFinished(BuildEvent event) { 163 getStopButton().setEnabled(false); 164 getBuildButton().setEnabled(true); 165 getBuildButton().requestFocus(); 166 167 Throwable error = event.getException(); 168 169 if (error == null) { 170 getMessageTextArea().append(lineSeparator + "BUILD SUCCESSFUL"); 171 } else { 172 logException(error); 173 } 174 175 getMessageTextArea().append(lineSeparator + "Total time: " 176 + DateUtils.formatElapsedTime(System.currentTimeMillis() - startTime)); 177 } 178 179 180 183 public void logException(Throwable error) { 184 getMessageTextArea().append(lineSeparator + "BUILD FAILED" + lineSeparator); 185 186 if (error instanceof BuildException) { 187 getMessageTextArea().append(error.toString()); 188 189 Throwable nested = ((BuildException) error).getException(); 190 if (nested != null) { 191 nested.printStackTrace(System.err); 192 } 193 } else { 194 error.printStackTrace(System.err); 195 } 196 } 197 198 201 public void buildStarted(BuildEvent event) { 202 getStopButton().setEnabled(true); 203 getBuildButton().setEnabled(false); 204 getStopButton().requestFocus(); 205 206 startTime = System.currentTimeMillis(); 207 getMessageTextArea().append(lineSeparator); 208 } 209 210 216 public void messageLogged(BuildEvent event) { 217 if (event.getPriority() <= getBuildInfo().getOutputMessageLevel()) { 218 String msg = ""; 219 if (event.getTask() != null) { 220 msg = "[" + event.getTask().getTaskName() + "] "; 221 } 222 getMessageTextArea().append(lineSeparator + msg + event.getMessage()); 223 } 224 } 225 226 232 public void targetFinished(BuildEvent event) { 233 } 234 235 240 public void targetStarted(BuildEvent event) { 241 if (getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO) { 242 getMessageTextArea().append(lineSeparator + event.getTarget().getName() + ":"); 243 } 244 } 245 246 252 public void taskFinished(BuildEvent event) { 253 } 254 255 260 public void taskStarted(BuildEvent event) { 261 } 262 } 263 264 267 private class PrivateEventHandler 268 implements ActionListener , ItemListener , TextListener , 269 WindowListener , PropertyChangeListener { 270 273 public void actionPerformed(ActionEvent e) { 274 try { 275 276 if (e.getSource() == VAJAntToolGUI.this.getBrowseButton()) { 278 getFileDialog().setDirectory(getBuildFileTextField().getText().substring(0, getBuildFileTextField().getText().lastIndexOf('\\') + 1)); 279 getFileDialog().setFile("*.xml"); 280 getFileDialog().show(); 281 if (!getFileDialog().getFile().equals("")) { 282 getBuildFileTextField().setText(getFileDialog().getDirectory() 283 + getFileDialog().getFile()); 284 } 285 } 286 if (e.getSource() == VAJAntToolGUI.this.getCloseButton()) { 288 dispose(); 289 System.exit(0); 290 } 291 if (e.getSource() == VAJAntToolGUI.this.getBuildButton()) { 293 executeTarget(); 294 } 295 if (e.getSource() == VAJAntToolGUI.this.getStopButton()) { 296 getBuildInfo().cancelBuild(); 297 } 298 if (e.getSource() == VAJAntToolGUI.this.getReloadButton()) { 299 try { 300 getBuildInfo().updateTargetList(); 301 fillList(); 302 } catch (Throwable fileNotFound) { 303 handleException(fileNotFound); 304 getTargetList().removeAll(); 305 getBuildButton().setEnabled(false); 306 } 307 } 308 if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem()) { 310 saveBuildInfo(); 311 } 312 if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem()) { 313 getAboutDialog().show(); 314 } 315 if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem()) { 316 getMessageFrame().show(); 317 } 318 319 if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton()) { 320 getAboutDialog().dispose(); 321 } 322 323 if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) { 324 getMessageFrame().dispose(); 325 } 326 if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton()) { 327 getMessageTextArea().setText(""); 328 } 329 if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) { 330 getMessageFrame().dispose(); 331 } 332 } catch (Throwable exc) { 333 handleException(exc); 334 } 335 } 336 337 340 public void itemStateChanged(ItemEvent e) { 341 try { 342 if (e.getSource() == VAJAntToolGUI.this.getTargetList()) { 343 getBuildButton().setEnabled(true); 344 } 345 if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice()) { 346 getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex()); 347 } 348 if (e.getSource() == VAJAntToolGUI.this.getTargetList()) { 349 getBuildInfo().setTarget(getTargetList().getSelectedItem()); 350 } 351 } catch (Throwable exc) { 352 handleException(exc); 353 } 354 } 355 356 359 public void propertyChange(java.beans.PropertyChangeEvent evt) { 360 if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() 361 && (evt.getPropertyName().equals("projectName"))) { 362 connectProjectNameToLabel(); 363 } 364 if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() 365 && (evt.getPropertyName().equals("buildFileName"))) { 366 connectBuildFileNameToTextField(); 367 } 368 } 369 370 373 public void textValueChanged(TextEvent e) { 374 if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField()) { 375 connectTextFieldToBuildFileName(); 376 } 377 } 378 379 382 public void windowClosing(WindowEvent e) { 383 try { 384 if (e.getSource() == VAJAntToolGUI.this) { 385 dispose(); 386 System.exit(0); 387 } 388 if (e.getSource() == VAJAntToolGUI.this.getAboutDialog()) { 389 getAboutDialog().dispose(); 390 } 391 if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) { 392 getMessageFrame().dispose(); 393 } 394 } catch (Throwable exc) { 395 handleException(exc); 396 } 397 } 398 public void windowActivated(WindowEvent e) { 399 } 400 public void windowClosed(WindowEvent e) { 401 } 402 public void windowDeactivated(WindowEvent e) { 403 } 404 public void windowDeiconified(WindowEvent e) { 405 } 406 public void windowIconified(WindowEvent e) { 407 } 408 public void windowOpened(WindowEvent e) { 409 } 410 } 411 412 415 private VAJAntToolGUI() { 416 super(); 417 initialize(); 418 } 419 423 public VAJAntToolGUI(VAJBuildInfo newBuildInfo) { 424 super(); 425 setBuildInfo(newBuildInfo); 426 initialize(); 427 } 428 431 public static void centerDialog(Dialog dialog) { 432 dialog.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (dialog.getSize().width / 2), (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (dialog.getSize().height / 2)); 433 } 434 437 private void connectBuildFileNameToTextField() { 438 439 try { 440 if (iConnPtoP2Aligning == false) { 441 iConnPtoP2Aligning = true; 442 if ((getBuildInfo() != null)) { 443 getBuildFileTextField().setText(getBuildInfo().getBuildFileName()); 444 } 445 iConnPtoP2Aligning = false; 446 } 447 } catch (Throwable iExc) { 448 iConnPtoP2Aligning = false; 449 handleException(iExc); 450 } 451 } 452 455 private void connectProjectNameToLabel() { 456 457 try { 458 if ((getBuildInfo() != null)) { 459 getProjectText().setText(getBuildInfo().getVAJProjectName()); 460 } 461 } catch (Throwable iExc) { 462 handleException(iExc); 463 } 464 } 465 468 private void connectTextFieldToBuildFileName() { 469 470 try { 471 if (iConnPtoP2Aligning == false) { 472 iConnPtoP2Aligning = true; 473 if ((getBuildInfo() != null)) { 474 getBuildInfo().setBuildFileName(getBuildFileTextField().getText()); 475 } 476 iConnPtoP2Aligning = false; 477 } 478 } catch (Throwable iExc) { 479 iConnPtoP2Aligning = false; 480 handleException(iExc); 481 } 482 } 483 486 private void executeTarget() { 487 try { 488 getMessageFrame().show(); 489 getBuildInfo().executeProject(logger); 490 } catch (Throwable exc) { 491 logger.logException(exc); 492 } 493 return; 494 } 495 498 private void fillList() { 499 getTargetList().removeAll(); 500 Vector targets = getBuildInfo().getProjectTargets(); 501 for (int i = 0; i < targets.size(); i++) { 502 getTargetList().add(targets.elementAt(i).toString()); 503 } 504 getTargetList().select(iBuildInfo.getProjectTargets().indexOf(iBuildInfo.getTarget())); 505 if (getTargetList().getSelectedIndex() >= 0) { 506 getBuildButton().setEnabled(true); 507 } 508 } 509 510 514 private Panel getAboutCommandPanel() { 515 if (iAboutCommandPanel == null) { 516 try { 517 iAboutCommandPanel = new Panel (); 518 iAboutCommandPanel.setName("AboutCommandPanel"); 519 iAboutCommandPanel.setLayout(new java.awt.FlowLayout ()); 520 getAboutCommandPanel().add(getAboutOkButton(), getAboutOkButton().getName()); 521 } catch (Throwable iExc) { 522 handleException(iExc); 523 } 524 } 525 return iAboutCommandPanel; 526 } 527 531 private Label getAboutContactLabel() { 532 if (iAboutContactLabel == null) { 533 try { 534 iAboutContactLabel = new Label (); 535 iAboutContactLabel.setName("AboutContactLabel"); 536 iAboutContactLabel.setAlignment(java.awt.Label.CENTER); 537 iAboutContactLabel.setText("contact: wolf.siberski@tui.de or " 538 + "christoph.wilhelms@tui.de"); 539 } catch (Throwable iExc) { 540 handleException(iExc); 541 } 542 } 543 return iAboutContactLabel; 544 } 545 549 private Label getAboutDevLabel() { 550 if (iAboutDevLabel == null) { 551 try { 552 iAboutDevLabel = new Label (); 553 iAboutDevLabel.setName("AboutDevLabel"); 554 iAboutDevLabel.setAlignment(java.awt.Label.CENTER); 555 iAboutDevLabel.setText("developed by Wolf Siberski & Christoph Wilhelms"); 556 } catch (Throwable iExc) { 557 handleException(iExc); 558 } 559 } 560 return iAboutDevLabel; 561 } 562 566 private Dialog getAboutDialog() { 567 if (iAboutDialog == null) { 568 try { 569 iAboutDialog = new Dialog (this); 570 iAboutDialog.setName("AboutDialog"); 571 iAboutDialog.setResizable(false); 572 iAboutDialog.setLayout(new java.awt.BorderLayout ()); 573 iAboutDialog.setBounds(550, 14, 383, 142); 574 iAboutDialog.setModal(true); 575 iAboutDialog.setTitle("About..."); 576 getAboutDialog().add(getAboutDialogContentPanel(), "Center"); 577 iAboutDialog.pack(); 578 centerDialog(iAboutDialog); 579 } catch (Throwable iExc) { 580 handleException(iExc); 581 } 582 } 583 return iAboutDialog; 584 } 585 589 private Panel getAboutDialogContentPanel() { 590 if (iAboutDialogContentPanel == null) { 591 try { 592 iAboutDialogContentPanel = new Panel (); 593 iAboutDialogContentPanel.setName("AboutDialogContentPanel"); 594 iAboutDialogContentPanel.setLayout(new java.awt.BorderLayout ()); 595 getAboutDialogContentPanel().add(getAboutCommandPanel(), "South"); 596 getAboutDialogContentPanel().add(getAboutInfoPanel(), "Center"); 597 } catch (Throwable iExc) { 598 handleException(iExc); 599 } 600 } 601 return iAboutDialogContentPanel; 602 } 603 607 private Panel getAboutInfoPanel() { 608 if (iAboutInfoPanel == null) { 609 try { 610 iAboutInfoPanel = new Panel (); 611 iAboutInfoPanel.setName("AboutInfoPanel"); 612 iAboutInfoPanel.setLayout(new GridBagLayout ()); 613 614 GridBagConstraints constraintsAboutTitleLabel = new GridBagConstraints (); 615 constraintsAboutTitleLabel.gridx = 0; constraintsAboutTitleLabel.gridy = 0; 616 constraintsAboutTitleLabel.fill = GridBagConstraints.HORIZONTAL; 617 constraintsAboutTitleLabel.weightx = 1.0; 618 constraintsAboutTitleLabel.weighty = 1.0; 619 constraintsAboutTitleLabel.insets = new Insets (4, 0, 4, 0); 620 getAboutInfoPanel().add(getAboutTitleLabel(), constraintsAboutTitleLabel); 621 622 GridBagConstraints constraintsAboutDevLabel = new GridBagConstraints (); 623 constraintsAboutDevLabel.gridx = 0; constraintsAboutDevLabel.gridy = 1; 624 constraintsAboutDevLabel.fill = GridBagConstraints.HORIZONTAL; 625 constraintsAboutDevLabel.weightx = 1.0; 626 constraintsAboutDevLabel.insets = new Insets (4, 0, 0, 0); 627 getAboutInfoPanel().add(getAboutDevLabel(), constraintsAboutDevLabel); 628 629 GridBagConstraints constraintsAboutContactLabel = new GridBagConstraints (); 630 constraintsAboutContactLabel.gridx = 0; constraintsAboutContactLabel.gridy = 2; 631 constraintsAboutContactLabel.fill = GridBagConstraints.HORIZONTAL; 632 constraintsAboutContactLabel.weightx = 1.0; 633 constraintsAboutContactLabel.insets = new Insets (2, 0, 4, 0); 634 getAboutInfoPanel().add(getAboutContactLabel(), constraintsAboutContactLabel); 635 } catch (Throwable iExc) { 636 handleException(iExc); 637 } 638 } 639 return iAboutInfoPanel; 640 } 641 645 private MenuItem getAboutMenuItem() { 646 if (iAboutMenuItem == null) { 647 try { 648 iAboutMenuItem = new MenuItem (); 649 iAboutMenuItem.setLabel("About..."); 650 } catch (Throwable iExc) { 651 handleException(iExc); 652 } 653 } 654 return iAboutMenuItem; 655 } 656 660 private Button getAboutOkButton() { 661 if (iAboutOkButton == null) { 662 try { 663 iAboutOkButton = new Button (); 664 iAboutOkButton.setName("AboutOkButton"); 665 iAboutOkButton.setLabel("OK"); 666 } catch (Throwable iExc) { 667 handleException(iExc); 668 } 669 } 670 return iAboutOkButton; 671 } 672 676 private Label getAboutTitleLabel() { 677 if (iAboutTitleLabel == null) { 678 try { 679 iAboutTitleLabel = new Label (); 680 iAboutTitleLabel.setName("AboutTitleLabel"); 681 iAboutTitleLabel.setFont(new Font ("Arial", 1, 12)); 682 iAboutTitleLabel.setAlignment(Label.CENTER); 683 iAboutTitleLabel.setText("Ant VisualAge for Java Tool-Integration"); 684 } catch (Throwable iExc) { 685 handleException(iExc); 686 } 687 } 688 return iAboutTitleLabel; 689 } 690 694 private MenuBar getAntMakeMenuBar() { 695 if (iAntMakeMenuBar == null) { 696 try { 697 iAntMakeMenuBar = new MenuBar (); 698 iAntMakeMenuBar.add(getFileMenu()); 699 iAntMakeMenuBar.add(getHelpMenu()); 700 } catch (Throwable iExc) { 701 handleException(iExc); 702 } 703 } 704 return iAntMakeMenuBar; 705 } 706 710 private Button getBrowseButton() { 711 if (iBrowseButton == null) { 712 try { 713 iBrowseButton = new Button (); 714 iBrowseButton.setName("BrowseButton"); 715 iBrowseButton.setLabel("..."); 716 } catch (Throwable iExc) { 717 handleException(iExc); 718 } 719 } 720 return iBrowseButton; 721 } 722 726 private Button getBuildButton() { 727 if (iBuildButton == null) { 728 try { 729 iBuildButton = new Button (); 730 iBuildButton.setName("BuildButton"); 731 iBuildButton.setLabel("Execute"); 732 } catch (Throwable iExc) { 733 handleException(iExc); 734 } 735 } 736 return iBuildButton; 737 } 738 742 private Label getBuildFileLabel() { 743 if (iBuildFileLabel == null) { 744 try { 745 iBuildFileLabel = new Label (); 746 iBuildFileLabel.setName("BuildFileLabel"); 747 iBuildFileLabel.setText("Ant-Buildfile:"); 748 } catch (Throwable iExc) { 749 handleException(iExc); 750 } 751 } 752 return iBuildFileLabel; 753 } 754 758 private TextField getBuildFileTextField() { 759 if (iBuildFileTextField == null) { 760 try { 761 iBuildFileTextField = new TextField (); 762 iBuildFileTextField.setName("BuildFileTextField"); 763 iBuildFileTextField.setBackground(SystemColor.textHighlightText); 764 } catch (Throwable iExc) { 765 handleException(iExc); 766 } 767 } 768 return iBuildFileTextField; 769 } 770 774 private VAJBuildInfo getBuildInfo() { 775 return iBuildInfo; 776 } 777 781 private Button getCloseButton() { 782 if (iCloseButton == null) { 783 try { 784 iCloseButton = new Button (); 785 iCloseButton.setName("CloseButton"); 786 iCloseButton.setLabel("Close"); 787 } catch (Throwable iExc) { 788 handleException(iExc); 789 } 790 } 791 return iCloseButton; 792 } 793 797 private Panel getCommandButtonPanel() { 798 if (iCommandButtonPanel == null) { 799 try { 800 iCommandButtonPanel = new Panel (); 801 iCommandButtonPanel.setName("CommandButtonPanel"); 802 iCommandButtonPanel.setLayout(getCommandButtonPanelFlowLayout()); 803 iCommandButtonPanel.setBackground(SystemColor.control); 804 iCommandButtonPanel.add(getReloadButton()); 805 iCommandButtonPanel.add(getBuildButton()); 806 iCommandButtonPanel.add(getStopButton()); 807 iCommandButtonPanel.add(getCloseButton()); 808 } catch (Throwable iExc) { 809 handleException(iExc); 810 } 811 } 812 return iCommandButtonPanel; 813 } 814 818 private FlowLayout getCommandButtonPanelFlowLayout() { 819 FlowLayout iCommandButtonPanelFlowLayout = null; 820 try { 821 822 iCommandButtonPanelFlowLayout = new FlowLayout (); 823 iCommandButtonPanelFlowLayout.setAlignment(FlowLayout.RIGHT); 824 } catch (Throwable iExc) { 825 handleException(iExc); 826 } 827 return iCommandButtonPanelFlowLayout; 828 } 829 833 private Panel getContentsPane() { 834 if (iContentsPane == null) { 835 try { 836 iContentsPane = new Panel (); 837 iContentsPane.setName("ContentsPane"); 838 iContentsPane.setLayout(new BorderLayout ()); 839 getContentsPane().add(getCommandButtonPanel(), "South"); 840 getContentsPane().add(getOptionenPanel(), "Center"); 841 } catch (Throwable iExc) { 842 handleException(iExc); 843 } 844 } 845 return iContentsPane; 846 } 847 851 private FileDialog getFileDialog() { 852 if (iFileDialog == null) { 853 try { 854 iFileDialog = new FileDialog (this); 855 iFileDialog.setName("FileDialog"); 856 iFileDialog.setLayout(null); 857 centerDialog(iFileDialog); 858 } catch (Throwable iExc) { 859 handleException(iExc); 860 } 861 } 862 return iFileDialog; 863 } 864 868 private Menu getFileMenu() { 869 if (iFileMenu == null) { 870 try { 871 iFileMenu = new Menu (); 872 iFileMenu.setLabel("File"); 873 iFileMenu.add(getSaveMenuItem()); 874 iFileMenu.add(getMenuSeparator()); 875 iFileMenu.add(getShowLogMenuItem()); 876 } catch (Throwable iExc) { 877 handleException(iExc); 878 } 879 } 880 return iFileMenu; 881 } 882 886 private Menu getHelpMenu() { 887 if (iHelpMenu == null) { 888 try { 889 iHelpMenu = new Menu (); 890 iHelpMenu.setLabel("Help"); 891 iHelpMenu.add(getAboutMenuItem()); 892 } catch (Throwable iExc) { 893 handleException(iExc); 894 } 895 } 896 return iHelpMenu; 897 } 898 902 private MenuItem getMenuSeparator() { 903 if (iMenuSeparator == null) { 904 try { 905 iMenuSeparator = new MenuItem (); 906 iMenuSeparator.setLabel("-"); 907 } catch (Throwable iExc) { 908 handleException(iExc); 909 } 910 } 911 return iMenuSeparator; 912 } 913 917 private Button getMessageClearLogButton() { 918 if (iMessageClearLogButton == null) { 919 try { 920 iMessageClearLogButton = new Button (); 921 iMessageClearLogButton.setName("MessageClearLogButton"); 922 iMessageClearLogButton.setLabel("Clear Log"); 923 } catch (Throwable iExc) { 924 handleException(iExc); 925 } 926 } 927 return iMessageClearLogButton; 928 } 929 933 private Panel getMessageCommandPanel() { 934 if (iMessageCommandPanel == null) { 935 try { 936 iMessageCommandPanel = new Panel (); 937 iMessageCommandPanel.setName("MessageCommandPanel"); 938 iMessageCommandPanel.setLayout(new FlowLayout ()); 939 getMessageCommandPanel().add(getMessageClearLogButton(), 940 getMessageClearLogButton().getName()); 941 getMessageCommandPanel().add(getMessageOkButton(), 942 getMessageOkButton().getName()); 943 } catch (Throwable iExc) { 944 handleException(iExc); 945 } 946 } 947 return iMessageCommandPanel; 948 } 949 953 private Panel getMessageContentPanel() { 954 if (iMessageContentPanel == null) { 955 try { 956 iMessageContentPanel = new Panel (); 957 iMessageContentPanel.setName("MessageContentPanel"); 958 iMessageContentPanel.setLayout(new BorderLayout ()); 959 iMessageContentPanel.setBackground(SystemColor.control); 960 getMessageContentPanel().add(getMessageTextArea(), "Center"); 961 getMessageContentPanel().add(getMessageCommandPanel(), "South"); 962 } catch (Throwable iExc) { 963 handleException(iExc); 964 } 965 } 966 return iMessageContentPanel; 967 } 968 972 private Frame getMessageFrame() { 973 if (iMessageFrame == null) { 974 try { 975 iMessageFrame = new Frame (); 976 iMessageFrame.setName("MessageFrame"); 977 iMessageFrame.setLayout(new BorderLayout ()); 978 iMessageFrame.setBounds(0, 0, 750, 250); 979 iMessageFrame.setTitle("Message Log"); 980 iMessageFrame.add(getMessageContentPanel(), "Center"); 981 iMessageFrame.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) 982 - (iMessageFrame.getSize().width / 2), 983 (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2)); 984 } catch (Throwable iExc) { 985 handleException(iExc); 986 } 987 } 988 return iMessageFrame; 989 } 990 994 private Button getMessageOkButton() { 995 if (iMessageOkButton == null) { 996 try { 997 iMessageOkButton = new Button (); 998 iMessageOkButton.setName("MessageOkButton"); 999 iMessageOkButton.setLabel("Close"); 1000 } catch (Throwable iExc) { 1001 handleException(iExc); 1002 } 1003 } 1004 return iMessageOkButton; 1005 } 1006 1010 private Choice getMessageOutputLevelChoice() { 1011 if (iMessageOutputLevelChoice == null) { 1012 try { 1013 iMessageOutputLevelChoice = new Choice (); 1014 iMessageOutputLevelChoice.setName("MessageOutputLevelChoice"); 1015 iMessageOutputLevelChoice.add("Error"); 1016 iMessageOutputLevelChoice.add("Warning"); 1017 iMessageOutputLevelChoice.add("Info"); 1018 iMessageOutputLevelChoice.add("Verbose"); 1019 iMessageOutputLevelChoice.add("Debug"); 1020 iMessageOutputLevelChoice.select(2); 1021 } catch (Throwable iExc) { 1022 handleException(iExc); 1023 } 1024 } 1025 return iMessageOutputLevelChoice; 1026 } 1027 1031 private Label getMessageOutputLevelLabel() { 1032 if (iMessageOutputLevelLabel == null) { 1033 try { 1034 iMessageOutputLevelLabel = new Label (); 1035 iMessageOutputLevelLabel.setName("MessageOutputLevelLabel"); 1036 iMessageOutputLevelLabel.setText("Message Level:"); 1037 } catch (Throwable iExc) { 1038 handleException(iExc); 1039 } 1040 } 1041 return iMessageOutputLevelLabel; 1042 } 1043 1047 private TextArea getMessageTextArea() { 1048 if (iMessageTextArea == null) { 1049 try { 1050 iMessageTextArea = new TextArea (); 1051 iMessageTextArea.setName("MessageTextArea"); 1052 iMessageTextArea.setFont(new Font ("monospaced", 0, 12)); 1053 iMessageTextArea.setText(""); 1054 iMessageTextArea.setEditable(false); 1055 iMessageTextArea.setEnabled(true); 1056 } catch (Throwable iExc) { 1057 handleException(iExc); 1058 } 1059 } 1060 return iMessageTextArea; 1061 } 1062 1066 private Panel getOptionenPanel() { 1067 if (iOptionenPanel == null) { 1068 try { 1069 iOptionenPanel = new Panel (); 1070 iOptionenPanel.setName("OptionenPanel"); 1071 iOptionenPanel.setLayout(new GridBagLayout ()); 1072 iOptionenPanel.setBackground(SystemColor.control); 1073 1074 GridBagConstraints constraintsProjectLabel = new GridBagConstraints (); 1075 constraintsProjectLabel.gridx = 0; constraintsProjectLabel.gridy = 0; 1076 constraintsProjectLabel.anchor = GridBagConstraints.WEST; 1077 constraintsProjectLabel.insets = new Insets (4, 4, 4, 4); 1078 getOptionenPanel().add(getProjectLabel(), constraintsProjectLabel); 1079 1080 GridBagConstraints constraintsBuildFileLabel = new GridBagConstraints (); 1081 constraintsBuildFileLabel.gridx = 0; constraintsBuildFileLabel.gridy = 1; 1082 constraintsBuildFileLabel.anchor = GridBagConstraints.WEST; 1083 constraintsBuildFileLabel.insets = new Insets (4, 4, 4, 4); 1084 getOptionenPanel().add(getBuildFileLabel(), constraintsBuildFileLabel); 1085 1086 GridBagConstraints constraintsTargetLabel = new GridBagConstraints (); 1087 constraintsTargetLabel.gridx = 0; constraintsTargetLabel.gridy = 2; 1088 constraintsTargetLabel.anchor = GridBagConstraints.NORTHWEST; 1089 constraintsTargetLabel.insets = new Insets (4, 4, 4, 4); 1090 getOptionenPanel().add(getTargetLabel(), constraintsTargetLabel); 1091 1092 GridBagConstraints constraintsProjectText = new GridBagConstraints (); 1093 constraintsProjectText.gridx = 1; constraintsProjectText.gridy = 0; 1094 constraintsProjectText.gridwidth = 2; 1095 constraintsProjectText.fill = GridBagConstraints.HORIZONTAL; 1096 constraintsProjectText.anchor = GridBagConstraints.WEST; 1097 constraintsProjectText.insets = new Insets (4, 4, 4, 4); 1098 getOptionenPanel().add(getProjectText(), constraintsProjectText); 1099 1100 GridBagConstraints constraintsBuildFileTextField = new GridBagConstraints (); 1101 constraintsBuildFileTextField.gridx = 1; constraintsBuildFileTextField.gridy = 1; 1102 constraintsBuildFileTextField.fill = GridBagConstraints.HORIZONTAL; 1103 constraintsBuildFileTextField.anchor = GridBagConstraints.WEST; 1104 constraintsBuildFileTextField.weightx = 1.0; 1105 constraintsBuildFileTextField.insets = new Insets (4, 4, 4, 4); 1106 getOptionenPanel().add(getBuildFileTextField(), constraintsBuildFileTextField); 1107 1108 GridBagConstraints constraintsBrowseButton = new GridBagConstraints (); 1109 constraintsBrowseButton.gridx = 2; constraintsBrowseButton.gridy = 1; 1110 constraintsBrowseButton.insets = new Insets (4, 4, 4, 4); 1111 getOptionenPanel().add(getBrowseButton(), constraintsBrowseButton); 1112 1113 GridBagConstraints constraintsTargetList = new GridBagConstraints (); 1114 constraintsTargetList.gridx = 1; constraintsTargetList.gridy = 2; 1115 constraintsTargetList.gridheight = 2; 1116 constraintsTargetList.fill = GridBagConstraints.BOTH; 1117 constraintsTargetList.weightx = 1.0; 1118 constraintsTargetList.weighty = 1.0; 1119 constraintsTargetList.insets = new Insets (4, 4, 4, 4); 1120 getOptionenPanel().add(getTargetList(), constraintsTargetList); 1121 1122 GridBagConstraints constraintsMessageOutputLevelLabel 1123 = new GridBagConstraints (); 1124 constraintsMessageOutputLevelLabel.gridx = 0; 1125 constraintsMessageOutputLevelLabel.gridy = 4; 1126 constraintsMessageOutputLevelLabel.anchor = GridBagConstraints.WEST; 1127 constraintsMessageOutputLevelLabel.insets = new Insets (4, 4, 4, 4); 1128 getOptionenPanel().add(getMessageOutputLevelLabel(), 1129 constraintsMessageOutputLevelLabel); 1130 1131 GridBagConstraints constraintsMessageOutputLevelChoice 1132 = new GridBagConstraints (); 1133 constraintsMessageOutputLevelChoice.gridx = 1; 1134 constraintsMessageOutputLevelChoice.gridy = 4; 1135 constraintsMessageOutputLevelChoice.fill = GridBagConstraints.HORIZONTAL; 1136 constraintsMessageOutputLevelChoice.anchor = GridBagConstraints.WEST; 1137 constraintsMessageOutputLevelChoice.weightx = 1.0; 1138 constraintsMessageOutputLevelChoice.insets = new Insets (4, 4, 4, 4); 1139 getOptionenPanel().add(getMessageOutputLevelChoice(), 1140 constraintsMessageOutputLevelChoice); 1141 } catch (Throwable iExc) { 1142 handleException(iExc); 1143 } 1144 } 1145 return iOptionenPanel; 1146 } 1147 1151 private Label getProjectLabel() { 1152 if (iProjectLabel == null) { 1153 try { 1154 iProjectLabel = new Label (); 1155 iProjectLabel.setName("ProjectLabel"); 1156 iProjectLabel.setText("Projectname:"); 1157 } catch (Throwable iExc) { 1158 handleException(iExc); 1159 } 1160 } 1161 return iProjectLabel; 1162 } 1163 1167 private Label getProjectText() { 1168 if (iProjectText == null) { 1169 try { 1170 iProjectText = new Label (); 1171 iProjectText.setName("ProjectText"); 1172 iProjectText.setText(" "); 1173 } catch (Throwable iExc) { 1174 handleException(iExc); 1175 } 1176 } 1177 return iProjectText; 1178 } 1179 1183 private Button getReloadButton() { 1184 if (iReloadButton == null) { 1185 try { 1186 iReloadButton = new Button (); 1187 iReloadButton.setName("ReloadButton"); 1188 iReloadButton.setLabel("(Re)Load"); 1189 } catch (Throwable iExc) { 1190 handleException(iExc); 1191 } 1192 } 1193 return iReloadButton; 1194 } 1195 1199 private MenuItem getSaveMenuItem() { 1200 if (iSaveMenuItem == null) { 1201 try { 1202 iSaveMenuItem = new MenuItem (); 1203 iSaveMenuItem.setLabel("Save BuildInfo To Repository"); 1204 } catch (Throwable iExc) { 1205 handleException(iExc); 1206 } 1207 } 1208 return iSaveMenuItem; 1209 } 1210 1214 private MenuItem getShowLogMenuItem() { 1215 if (iShowLogMenuItem == null) { 1216 try { 1217 iShowLogMenuItem = new MenuItem (); 1218 iShowLogMenuItem.setLabel("Log"); 1219 } catch (Throwable iExc) { 1220 handleException(iExc); 1221 } 1222 } 1223 return iShowLogMenuItem; 1224 } 1225 1229 private Label getTargetLabel() { 1230 if (iTargetLabel == null) { 1231 try { 1232 iTargetLabel = new Label (); 1233 iTargetLabel.setName("TargetLabel"); 1234 iTargetLabel.setText("Target:"); 1235 iTargetLabel.setEnabled(true); 1236 } catch (Throwable iExc) { 1237 handleException(iExc); 1238 } 1239 } 1240 return iTargetLabel; 1241 } 1242 1246 private List getTargetList() { 1247 if (iTargetList == null) { 1248 try { 1249 iTargetList = new List (); 1250 iTargetList.setName("TargetList"); 1251 iTargetList.setEnabled(true); 1252 } catch (Throwable iExc) { 1253 handleException(iExc); 1254 } 1255 } 1256 return iTargetList; 1257 } 1258 1262 private void handleException(Throwable exception) { 1263 String trace = StringUtils.getStackTrace(exception); 1265 1266 getMessageTextArea().append(lineSeparator + lineSeparator + trace); 1267 getMessageFrame().show(); 1268 1269 } 1270 1274 private void initConnections() throws Exception { 1275 this.addWindowListener(iEventHandler); 1276 getBrowseButton().addActionListener(iEventHandler); 1277 getCloseButton().addActionListener(iEventHandler); 1278 getBuildButton().addActionListener(iEventHandler); 1279 getStopButton().addActionListener(iEventHandler); 1280 getSaveMenuItem().addActionListener(iEventHandler); 1281 getAboutOkButton().addActionListener(iEventHandler); 1282 getAboutMenuItem().addActionListener(iEventHandler); 1283 getMessageOkButton().addActionListener(iEventHandler); 1284 getMessageClearLogButton().addActionListener(iEventHandler); 1285 getMessageOkButton().addActionListener(iEventHandler); 1286 getShowLogMenuItem().addActionListener(iEventHandler); 1287 getAboutDialog().addWindowListener(iEventHandler); 1288 getMessageFrame().addWindowListener(iEventHandler); 1289 getReloadButton().addActionListener(iEventHandler); 1290 getTargetList().addItemListener(iEventHandler); 1291 getMessageOutputLevelChoice().addItemListener(iEventHandler); 1292 getBuildFileTextField().addTextListener(iEventHandler); 1293 connectProjectNameToLabel(); 1294 connectBuildFileNameToTextField(); 1295 } 1296 1299 private void initialize() { 1300 try { 1301 setName("AntMake"); 1302 setMenuBar(getAntMakeMenuBar()); 1303 setLayout(new java.awt.BorderLayout ()); 1304 setSize(389, 222); 1305 setTitle("Ant VisualAge for Java Tool-Integration"); 1306 add(getContentsPane(), "Center"); 1307 initConnections(); 1308 } catch (Throwable iExc) { 1309 handleException(iExc); 1310 } 1311 setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) 1312 - (getSize().width / 2), 1313 (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) 1314 - (getSize().height)); 1315 if ((getTargetList().getItemCount() == 0) || (getTargetList().getSelectedIndex() < 0)) { 1316 getBuildButton().setEnabled(false); 1317 } 1318 } 1319 1322 private void saveBuildInfo() { 1323 try { 1324 VAJAntTool.saveBuildData(getBuildInfo()); 1325 } catch (Throwable exc) { 1326 handleException(exc); 1328 } 1329 return; 1330 } 1331 1335 private void setBuildInfo(VAJBuildInfo newValue) { 1336 if (iBuildInfo != newValue) { 1337 try { 1338 1339 if (iBuildInfo != null) { 1340 iBuildInfo.removePropertyChangeListener(iEventHandler); 1341 } 1342 iBuildInfo = newValue; 1343 1344 1345 if (iBuildInfo != null) { 1346 iBuildInfo.addPropertyChangeListener(iEventHandler); 1347 } 1348 connectProjectNameToLabel(); 1349 connectBuildFileNameToTextField(); 1350 1351 getMessageOutputLevelChoice().select(iBuildInfo.getOutputMessageLevel()); 1353 fillList(); 1354 if ((iBuildInfo.getVAJProjectName() == null) 1357 || (iBuildInfo.getVAJProjectName().equals(""))) { 1358 getSaveMenuItem().setEnabled(false); 1359 } 1360 } catch (Throwable iExc) { 1361 handleException(iExc); 1362 } 1363 } 1364 } 1365 1366 private Button iStopButton = null; 1367 1368 1372 private Button getStopButton() { 1373 if (iStopButton == null) { 1374 try { 1375 iStopButton = new Button (); 1376 iStopButton.setName("StopButton"); 1377 iStopButton.setLabel("Stop"); 1378 iStopButton.setEnabled(false); 1379 } catch (Throwable iExc) { 1380 handleException(iExc); 1381 } 1382 } 1383 return iStopButton; 1384 } 1385} 1386 | Popular Tags |