1
package org.apache.tools.ant.taskdefs.optional.ide;
4
* The Apache Software License, Version 1.1
6
* Copyright (c) 1999 The Apache Software Foundation. All rights
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
16
* 2. Redistributions in binary form must reproduce the above copyright
17
* notice, this list of conditions and the following disclaimer in
18
* the documentation and/or other materials provided with the
21
* 3. The end-user documentation included with the redistribution, if
22
* any, must include the following acknowlegement:
23
* "This product includes software developed by the
24
* Apache Software Foundation (http://www.apache.org/)."
25
* Alternately, this acknowlegement may appear in the software itself,
26
* if and wherever such third-party acknowlegements normally appear.
28
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
29
* Foundation" must not be used to endorse or promote products derived
30
* from this software without prior written permission. For written
31
* permission, please contact apache@apache.org.
33
* 5. Products derived from this software may not be called "Apache"
34
* nor may "Apache" appear in their names without prior written
35
* permission of the Apache Group.
37
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49
* ====================================================================
51
* This software consists of voluntary contributions made by many
52
* individuals on behalf of the Apache Software Foundation. For more
53
* information on the Apache Software Foundation, please see
54
* <http://www.apache.org/>.
57
import java.util.Vector;
58
import java.awt.Frame;
59
import java.awt.Dialog;
60
import java.awt.Panel;
61
import java.awt.MenuBar;
63
import java.awt.MenuItem;
64
import java.awt.Label;
65
import java.awt.TextField;
66
import java.awt.TextArea;
68
import java.awt.Choice;
69
import java.awt.Button;
70
import java.awt.FileDialog;
71
import java.awt.FlowLayout;
72
import java.awt.BorderLayout;
73
import java.awt.GridBagLayout;
74
import java.awt.GridBagConstraints;
75
import java.awt.Insets;
76
import java.awt.Toolkit;
78
import java.awt.SystemColor;
79
import java.awt.event.ActionListener;
80
import java.awt.event.ItemListener;
81
import java.awt.event.TextListener;
82
import java.awt.event.WindowListener;
83
import java.awt.event.ActionEvent;
84
import java.awt.event.ItemEvent;
85
import java.awt.event.TextEvent;
86
import java.awt.event.WindowEvent;
87
import java.beans.PropertyChangeListener;
88
import org.apache.tools.ant.Main;
89
import org.apache.tools.ant.BuildException;
90
import org.apache.tools.ant.BuildListener;
91
import org.apache.tools.ant.BuildEvent;
92
import org.apache.tools.ant.Project;
95
* This is a simple grafical user interface to provide the information needed by ANT and
96
* to start the build-process within IBM VisualAge for Java.
98
* I was using AWT to make it independent from the JDK-version. Please don't ask me for a Swing-version:
99
* I am very familiar with Swing and I really think that it's not necessary for such a simple gui!
101
* It is completely developed in VAJ using the visual composition editor. About 90% of the code is generated by VAJ,
102
* but in fact I did a lot of <i>code-beautification</i> ;-).
105
* @author: Christoph Wilhelms, TUI Infotec GmbH
107
public class VAJAntToolGUI extends Frame {
111
private VAJBuildLogger logger = new VAJBuildLogger();
112
private String lineSeparator = "\r\n";
113
private PrivateEventHandler iEventHandler = new PrivateEventHandler();
116
* Members of the main-window
119
private VAJBuildInfo iBuildInfo = null;
121
private MenuBar iAntMakeMenuBar = null;
122
private Menu iFileMenu = null;
123
private MenuItem iSaveMenuItem = null;
124
private MenuItem iMenuSeparator = null;
125
private MenuItem iShowLogMenuItem = null;
126
private Menu iHelpMenu = null;
127
private MenuItem iAboutMenuItem = null;
129
private Panel iContentsPane = null;
130
private Panel iOptionenPanel = null;
131
private Panel iCommandButtonPanel = null;
132
private FlowLayout iCommandButtonPanelFlowLayout = null;
134
private Label iProjectLabel = null;
135
private Label iProjectText = null;
137
private Label iBuildFileLabel = null;
138
private TextField iBuildFileTextField = null;
139
private boolean iConnPtoP2Aligning = false;
140
private Button iBrowseButton = null;
141
private FileDialog iFileDialog = null;
143
private Choice iMessageOutputLevelChoice = null;
144
private Label iMessageOutputLevelLabel = null;
145
private Label iTargetLabel = null;
146
private List iTargetList = null;
148
private Button iBuildButton = null;
149
private Button iReloadButton = null;
150
private Button iCloseButton = null;
155
private Frame iMessageFrame = null;
156
private Panel iMessageCommandPanel = null;
157
private Panel iMessageContentPanel = null;
159
private TextArea iMessageTextArea = null;
160
private Button iMessageOkButton = null;
161
private Button iMessageClearLogButton = null;
166
private Dialog iAboutDialog = null;
167
private Panel iAboutDialogContentPanel = null;
168
private Panel iAboutInfoPanel = null;
169
private Panel iAboutCommandPanel = null;
171
private Label iAboutTitleLabel = null;
172
private Label iAboutDevLabel = null;
173
private Label iAboutContactLabel = null;
175
private Button iAboutOkButton = null;
178
* This internal BuildLogger, to be honest, is just a BuildListener.
179
* It does nearly the same as the DefaultLogger, but uses the Loggin-Window for output.
181
private class VAJBuildLogger implements BuildListener {
182
private long startTime = System.currentTimeMillis();
185
* VAJBuildLogger constructor comment.
187
public VAJBuildLogger() {
192
* Fired after the last target has finished. This event
193
* will still be thrown if an error occured during the build.
195
* @see BuildEvent#getException()
197
public void buildFinished(BuildEvent event) {
198
Throwable error = event.getException();
201
getMessageTextArea().append(lineSeparator + "BUILD SUCCESSFUL");
204
getMessageTextArea().append(lineSeparator + "BUILD FAILED" + lineSeparator);
206
if (error instanceof BuildException) {
207
getMessageTextArea().append(error.toString());
209
Throwable nested = ((BuildException)error).getException();
210
if (nested != null) {
211
nested.printStackTrace(System.err);
215
error.printStackTrace(System.err);
219
getMessageTextArea().append(lineSeparator + "Total time: " + formatTime(System.currentTimeMillis() - startTime));
223
* Fired before any targets are started.
225
public void buildStarted(BuildEvent event) {
226
startTime = System.currentTimeMillis();
227
getMessageTextArea().append(lineSeparator);
231
* Fired whenever a message is logged.
233
* @see BuildEvent#getMessage()
234
* @see BuildEvent#getPriority()
236
public void messageLogged(BuildEvent event) {
237
if (event.getPriority() <= getBuildInfo().getOutputMessageLevel()) {
239
if (event.getTask() != null)
240
msg = "[" + event.getTask().getTaskName() + "] ";
241
getMessageTextArea().append(lineSeparator + msg + event.getMessage());
246
* Fired when a target has finished. This event will
247
* still be thrown if an error occured during the build.
249
* @see BuildEvent#getException()
251
public void targetFinished(BuildEvent event) {
255
* Fired when a target is started.
257
* @see BuildEvent#getTarget()
259
public void targetStarted(BuildEvent event) {
260
if (getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO) {
261
getMessageTextArea().append(lineSeparator + event.getTarget().getName() + ":");
266
* Fired when a task has finished. This event will still
267
* be throw if an error occured during the build.
269
* @see BuildEvent#getException()
271
public void taskFinished(BuildEvent event) {
275
* Fired when a task is started.
277
* @see BuildEvent#getTask()
279
public void taskStarted(BuildEvent event) {
282
* Chris: HACK: remove when Ant-Refactoring is finished!
284
public void buildSuccessful() {
285
getMessageTextArea().append(lineSeparator + "BUILD SUCCESSFUL");
286
getMessageTextArea().append(lineSeparator + "Total time: " + formatTime(System.currentTimeMillis() - startTime));
289
* Chris: HACK: remove when Ant-Refactoring is finished!
291
public void buildFailed(Throwable exc) {
292
getMessageTextArea().append(lineSeparator + "BUILD FAILED" + lineSeparator);
294
if (exc instanceof BuildException) {
295
getMessageTextArea().append(exc.toString());
297
Throwable nested = ((BuildException)exc).getException();
298
if (nested != null) {
299
nested.printStackTrace(System.err);
303
exc.printStackTrace(System.err);
305
getMessageTextArea().append(lineSeparator + "Total time: " + formatTime(System.currentTimeMillis() - startTime));
310
* Eventhandler to handle all AWT-events
312
private class PrivateEventHandler implements ActionListener, ItemListener, TextListener, WindowListener, PropertyChangeListener {
314
* ActionListener method
316
public void actionPerformed(ActionEvent e) {
318
/* #### Main App-Frame #### */
319
// browse XML-File with filechooser
320
if (e.getSource() == VAJAntToolGUI.this.getBrowseButton()) {
321
getFileDialog().setDirectory(getBuildFileTextField().getText().substring(0, getBuildFileTextField().getText().lastIndexOf('\\') + 1));
322
getFileDialog().setFile("*.xml");
323
getFileDialog().show();
324
if (!getFileDialog().getFile().equals("") ) {
325
getBuildFileTextField().setText(getFileDialog().getDirectory() + getFileDialog().getFile());
328
// dispose and exit application
329
if (e.getSource() == VAJAntToolGUI.this.getCloseButton()) {
333
// start build-process
334
if (e.getSource() == VAJAntToolGUI.this.getBuildButton())
336
if (e.getSource() == VAJAntToolGUI.this.getReloadButton()) {
338
getBuildInfo().updateTargetList();
341
catch (Throwable fileNotFound) {
342
handleException(fileNotFound);
343
getTargetList().removeAll();
344
getBuildButton().setEnabled(false);
348
if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem())
350
if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem())
351
getAboutDialog().show();
352
if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem())
353
getMessageFrame().show();
354
/* #### About dialog #### */
355
if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton())
356
getAboutDialog().dispose();
357
/* #### Log frame #### */
358
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
359
getMessageFrame().dispose();
360
if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton())
361
getMessageTextArea().setText("");
362
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
363
getMessageFrame().dispose();
365
catch (Throwable exc) {
366
handleException(exc);
371
* ItemListener method
373
public void itemStateChanged(ItemEvent e) {
375
if (e.getSource() == VAJAntToolGUI.this.getTargetList())
376
getBuildButton().setEnabled(true);
377
if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice())
378
getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex());
379
if (e.getSource() == VAJAntToolGUI.this.getTargetList())
380
getBuildInfo().setTarget(getTargetList().getSelectedItem());
382
catch (Throwable exc) {
383
handleException(exc);
388
* PropertyChangeListener method
390
public void propertyChange(java.beans.PropertyChangeEvent evt) {
391
if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName")))
392
connectProjectNameToLabel();
393
if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName")))
394
connectBuildFileNameToTextField();
398
* TextListener method
400
public void textValueChanged(TextEvent e) {
401
if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField())
402
connectTextFieldToBuildFileName();
406
* WindowListener methods
408
public void windowClosing(WindowEvent e) {
410
if (e.getSource() == VAJAntToolGUI.this) {
414
if (e.getSource() == VAJAntToolGUI.this.getAboutDialog())
415
getAboutDialog().dispose();
416
if (e.getSource() == VAJAntToolGUI.this.getMessageFrame())
417
getMessageFrame().dispose();
419
catch (Throwable exc) {
420
handleException(exc);
423
public void windowActivated(WindowEvent e) {};
424
public void windowClosed(WindowEvent e) {};
425
public void windowDeactivated(WindowEvent e) {};
426
public void windowDeiconified(WindowEvent e) {};
427
public void windowIconified(WindowEvent e) {};
428
public void windowOpened(WindowEvent e) {};
432
* AntMake default-constructor.
434
private VAJAntToolGUI() {
439
* AntMake constructor called by VAJAntTool integration.
440
* @param buildInfo VAJBuildInfo
443
public VAJAntToolGUI(VAJBuildInfo newBuildInfo) {
445
setBuildInfo(newBuildInfo);
449
* This method is used to center dialogs.
451
public static void centerDialog(Dialog dialog) {
452
dialog.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (dialog.getSize().width / 2), (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (dialog.getSize().height / 2));
455
* connectBuildFileNameToTextField: (BuildInfo.buildFileName <--> BuildFileTextField.text)
457
private void connectBuildFileNameToTextField() {
458
/* Set the target from the source */
460
if (iConnPtoP2Aligning == false) {
461
iConnPtoP2Aligning = true;
462
if ((getBuildInfo() != null)) {
463
getBuildFileTextField().setText(getBuildInfo().getBuildFileName());
465
iConnPtoP2Aligning = false;
467
} catch (Throwable iExc) {
468
iConnPtoP2Aligning = false;
469
handleException(iExc);
473
* connectProjectNameToLabel: (BuildInfo.vajProjectName <--> ProjectText.text)
475
private void connectProjectNameToLabel() {
476
/* Set the target from the source */
478
if ((getBuildInfo() != null)) {
479
getProjectText().setText(getBuildInfo().getVAJProjectName());
481
} catch (Throwable iExc) {
482
handleException(iExc);
486
* connectTextFieldToBuildFileName: (BuildInfo.buildFileName <--> BuildFileTextField.text)
488
private void connectTextFieldToBuildFileName() {
489
/* Set the source from the target */
491
if (iConnPtoP2Aligning == false) {
492
iConnPtoP2Aligning = true;
493
if ((getBuildInfo() != null)) {
494
getBuildInfo().setBuildFileName(getBuildFileTextField().getText());
496
iConnPtoP2Aligning = false;
498
} catch (Throwable iExc) {
499
iConnPtoP2Aligning = false;
500
handleException(iExc);
504
* external build of a .jar-file
506
private void executeTarget() {
508
getMessageFrame().show();
509
// Chris: HACK: remove when Ant-Refactoring is finished!
510
logger.buildStarted(null);
511
getBuildInfo().executeProject(logger);
512
// Chris: HACK: remove when Ant-Refactoring is finished!
513
logger.buildSuccessful();
515
catch (Throwable exc) {
516
// We aren't interested in exceptions! All necessary information has been written to the logging-window!
517
// Unfortunately ANT-Refactoring isn't done yet!
518
// Chris: HACK: remove when Ant-Refactoring is finished!
519
logger.buildFailed( exc );
524
* Fills the taget-list with project-targets
526
private void fillList() {
527
getTargetList().removeAll();
528
Vector targets = getBuildInfo().getProjectTargets();
529
for (int i = 0;i < targets.size(); i++) {
530
getTargetList().add(targets.elementAt(i).toString());
532
getTargetList().select(iBuildInfo.getProjectTargets().indexOf(iBuildInfo.getTarget()));
533
if (getTargetList().getSelectedIndex() >= 0) {
534
getBuildButton().setEnabled(true);
538
* Copied from DefaultLogger to provide the same time-format.
540
public static String formatTime(long millis) {
541
long seconds = millis / 1000;
542
long minutes = seconds / 60;
545
return Long.toString(minutes) + " minute"
546
+ (minutes == 1 ? " " : "s ")
547
+ Long.toString(seconds%60) + " second"
548
+ (seconds%60 == 1 ? "" : "s");
551
return Long.toString(seconds) + " second"
552
+ (seconds%60 == 1 ? "" : "s");
556
* Return the AboutCommandPanel property value.
557
* @return java.awt.Panel
559
private Panel getAboutCommandPanel() {
560
if (iAboutCommandPanel == null) {
562
iAboutCommandPanel = new Panel();
563
iAboutCommandPanel.setName("AboutCommandPanel");
564
iAboutCommandPanel.setLayout(new java.awt.FlowLayout());
565
getAboutCommandPanel().add(getAboutOkButton(), getAboutOkButton().getName());
566
} catch (Throwable iExc) {
567
handleException(iExc);
570
return iAboutCommandPanel;
573
* Return the AboutContactLabel property value.
574
* @return java.awt.Label
576
private Label getAboutContactLabel() {
577
if (iAboutContactLabel == null) {
579
iAboutContactLabel = new Label();
580
iAboutContactLabel.setName("AboutContactLabel");
581
iAboutContactLabel.setAlignment(java.awt.Label.CENTER);
582
iAboutContactLabel.setText("contact: wolf.siberski@tui.de or christoph.wilhelms@tui.de");
583
} catch (Throwable iExc) {
584
handleException(iExc);
587
return iAboutContactLabel;
590
* Return the AboutDevLabel property value.
591
* @return java.awt.Label
593
private Label getAboutDevLabel() {
594
if (iAboutDevLabel == null) {
596
iAboutDevLabel = new Label();
597
iAboutDevLabel.setName("AboutDevLabel");
598
iAboutDevLabel.setAlignment(java.awt.Label.CENTER);
599
iAboutDevLabel.setText("developed by Wolf Siberski & Christoph Wilhelms");
600
} catch (Throwable iExc) {
601
handleException(iExc);
604
return iAboutDevLabel;
607
* Return the AboutDialog property value.
608
* @return java.awt.Dialog
610
private Dialog getAboutDialog() {
611
if (iAboutDialog == null) {
613
iAboutDialog = new Dialog(this);
614
iAboutDialog.setName("AboutDialog");
615
iAboutDialog.setResizable(false);
616
iAboutDialog.setLayout(new java.awt.BorderLayout());
617
iAboutDialog.setBounds(550, 14, 383, 142);
618
iAboutDialog.setModal(true);
619
iAboutDialog.setTitle("About...");
620
getAboutDialog().add(getAboutDialogContentPanel(), "Center");
622
centerDialog(iAboutDialog);
623
} catch (Throwable iExc) {
624
handleException(iExc);
630
* Return the AboutDialogContentPanel property value.
631
* @return java.awt.Panel
633
private Panel getAboutDialogContentPanel() {
634
if (iAboutDialogContentPanel == null) {
636
iAboutDialogContentPanel = new Panel();
637
iAboutDialogContentPanel.setName("AboutDialogContentPanel");
638
iAboutDialogContentPanel.setLayout(new java.awt.BorderLayout());
639
getAboutDialogContentPanel().add(getAboutCommandPanel(), "South");
640
getAboutDialogContentPanel().add(getAboutInfoPanel(), "Center");
641
} catch (Throwable iExc) {
642
handleException(iExc);
645
return iAboutDialogContentPanel;
648
* Return the AboutInfoPanel property value.
649
* @return java.awt.Panel
651
private Panel getAboutInfoPanel() {
652
if (iAboutInfoPanel == null) {
654
iAboutInfoPanel = new Panel();
655
iAboutInfoPanel.setName("AboutInfoPanel");
656
iAboutInfoPanel.setLayout(new GridBagLayout());
658
GridBagConstraints constraintsAboutTitleLabel = new GridBagConstraints();
659
constraintsAboutTitleLabel.gridx = 0; constraintsAboutTitleLabel.gridy = 0;
660
constraintsAboutTitleLabel.fill = GridBagConstraints.HORIZONTAL;
661
constraintsAboutTitleLabel.weightx = 1.0;
662
constraintsAboutTitleLabel.weighty = 1.0;
663
constraintsAboutTitleLabel.insets = new Insets(4, 0, 4, 0);
664
getAboutInfoPanel().add(getAboutTitleLabel(), constraintsAboutTitleLabel);
666
GridBagConstraints constraintsAboutDevLabel = new GridBagConstraints();
667
constraintsAboutDevLabel.gridx = 0; constraintsAboutDevLabel.gridy = 1;
668
constraintsAboutDevLabel.fill = GridBagConstraints.HORIZONTAL;
669
constraintsAboutDevLabel.weightx = 1.0;
670
constraintsAboutDevLabel.insets = new Insets(4, 0, 0, 0);
671
getAboutInfoPanel().add(getAboutDevLabel(), constraintsAboutDevLabel);
673
GridBagConstraints constraintsAboutContactLabel = new GridBagConstraints();
674
constraintsAboutContactLabel.gridx = 0; constraintsAboutContactLabel.gridy = 2;
675
constraintsAboutContactLabel.fill = GridBagConstraints.HORIZONTAL;
676
constraintsAboutContactLabel.weightx = 1.0;
677
constraintsAboutContactLabel.insets = new Insets(2, 0, 4, 0);
678
getAboutInfoPanel().add(getAboutContactLabel(), constraintsAboutContactLabel);
679
} catch (Throwable iExc) {
680
handleException(iExc);
683
return iAboutInfoPanel;
686
* Return the AboutMenuItem property value.
687
* @return java.awt.MenuItem
689
private MenuItem getAboutMenuItem() {
690
if (iAboutMenuItem == null) {
692
iAboutMenuItem = new MenuItem();
693
iAboutMenuItem.setLabel("About...");
694
} catch (Throwable iExc) {
695
handleException(iExc);
698
return iAboutMenuItem;
701
* Return the AboutOkButton property value.
702
* @return java.awt.Button
704
private Button getAboutOkButton() {
705
if (iAboutOkButton == null) {
707
iAboutOkButton = new Button();
708
iAboutOkButton.setName("AboutOkButton");
709
iAboutOkButton.setLabel("OK");
710
} catch (Throwable iExc) {
711
handleException(iExc);
714
return iAboutOkButton;
717
* Return the AboutTitleLabel property value.
718
* @return java.awt.Label
720
private Label getAboutTitleLabel() {
721
if (iAboutTitleLabel == null) {
723
iAboutTitleLabel = new Label();
724
iAboutTitleLabel.setName("AboutTitleLabel");
725
iAboutTitleLabel.setFont(new Font("Arial", 1, 12));
726
iAboutTitleLabel.setAlignment(Label.CENTER);
727
iAboutTitleLabel.setText("Ant VisualAge for Java Tool-Integration");
728
} catch (Throwable iExc) {
729
handleException(iExc);
732
return iAboutTitleLabel;
735
* Return the AntMakeMenuBar property value.
736
* @return java.awt.MenuBar
738
private MenuBar getAntMakeMenuBar() {
739
if (iAntMakeMenuBar == null) {
741
iAntMakeMenuBar = new MenuBar();
742
iAntMakeMenuBar.add(getFileMenu());
743
iAntMakeMenuBar.add(getHelpMenu());
744
} catch (Throwable iExc) {
745
handleException(iExc);
748
return iAntMakeMenuBar;
751
* Return the BrowseButton property value.
754
private Button getBrowseButton() {
755
if (iBrowseButton == null) {
757
iBrowseButton = new Button();
758
iBrowseButton.setName("BrowseButton");
759
iBrowseButton.setLabel("...");
760
} catch (Throwable iExc) {
761
handleException(iExc);
764
return iBrowseButton;
767
* Return the BuildButton property value.
768
* @return java.awt.Button
770
private Button getBuildButton() {
771
if (iBuildButton == null) {
773
iBuildButton = new Button();
774
iBuildButton.setName("BuildButton");
775
iBuildButton.setLabel("Build");
776
} catch (Throwable iExc) {
777
handleException(iExc);
783
* Return the BuildFileLabel property value.
784
* @return java.awt.Label
786
private Label getBuildFileLabel() {
787
if (iBuildFileLabel == null) {
789
iBuildFileLabel = new Label();
790
iBuildFileLabel.setName("BuildFileLabel");
791
iBuildFileLabel.setText("Ant-Buildfile:");
792
} catch (Throwable iExc) {
793
handleException(iExc);
796
return iBuildFileLabel;
799
* Return the BuildFileTextField property value.
800
* @return java.awt.TextField
802
private TextField getBuildFileTextField() {
803
if (iBuildFileTextField == null) {
805
iBuildFileTextField = new TextField();
806
iBuildFileTextField.setName("BuildFileTextField");
807
iBuildFileTextField.setBackground(SystemColor.textHighlightText);
808
} catch (Throwable iExc) {
809
handleException(iExc);
812
return iBuildFileTextField;
815
* Return the BuildInfo property value.
816
* @return org.apache.tools.ant.taskdefs.optional.ide.VAJBuildInfo
818
private VAJBuildInfo getBuildInfo() {
822
* Return the CloseButton property value.
823
* @return java.awt.Button
825
private Button getCloseButton() {
826
if (iCloseButton == null) {
828
iCloseButton = new Button();
829
iCloseButton.setName("CloseButton");
830
iCloseButton.setLabel("Close");
831
} catch (Throwable iExc) {
832
handleException(iExc);
838
* Return the CommandButtonPanel property value.
839
* @return java.awt.Panel
841
private Panel getCommandButtonPanel() {
842
if (iCommandButtonPanel == null) {
844
iCommandButtonPanel = new Panel();
845
iCommandButtonPanel.setName("CommandButtonPanel");
846
iCommandButtonPanel.setLayout(getCommandButtonPanelFlowLayout());
847
iCommandButtonPanel.setBackground(SystemColor.control);
848
iCommandButtonPanel.add(getReloadButton());
849
getCommandButtonPanel().add(getBuildButton(), getBuildButton().getName());
850
getCommandButtonPanel().add(getCloseButton(), getCloseButton().getName());
851
} catch (Throwable iExc) {
852
handleException(iExc);
855
return iCommandButtonPanel;
858
* Return the CommandButtonPanelFlowLayout property value.
859
* @return java.awt.FlowLayout
861
private FlowLayout getCommandButtonPanelFlowLayout() {
862
FlowLayout iCommandButtonPanelFlowLayout = null;
865
iCommandButtonPanelFlowLayout = new FlowLayout();
866
iCommandButtonPanelFlowLayout.setAlignment(FlowLayout.RIGHT);
867
} catch (Throwable iExc) {
868
handleException(iExc);
870
return iCommandButtonPanelFlowLayout;
873
* Return the ContentsPane property value.
874
* @return java.awt.Panel
876
private Panel getContentsPane() {
877
if (iContentsPane == null) {
879
iContentsPane = new Panel();
880
iContentsPane.setName("ContentsPane");
881
iContentsPane.setLayout(new BorderLayout());
882
getContentsPane().add(getCommandButtonPanel(), "South");
883
getContentsPane().add(getOptionenPanel(), "Center");
884
} catch (Throwable iExc) {
885
handleException(iExc);
888
return iContentsPane;
891
* Return the FileDialog property value.
892
* @return java.awt.FileDialog
894
private FileDialog getFileDialog() {
895
if (iFileDialog == null) {
897
iFileDialog = new FileDialog(this);
898
iFileDialog.setName("FileDialog");
899
iFileDialog.setLayout(null);
900
centerDialog(iFileDialog);
901
} catch (Throwable iExc) {
902
handleException(iExc);
908
* Return the FileMenu property value.
909
* @return java.awt.Menu
911
private Menu getFileMenu() {
912
if (iFileMenu == null) {
914
iFileMenu = new Menu();
915
iFileMenu.setLabel("File");
916
iFileMenu.add(getSaveMenuItem());
917
iFileMenu.add(getMenuSeparator());
918
iFileMenu.add(getShowLogMenuItem());
919
} catch (Throwable iExc) {
920
handleException(iExc);
926
* Return the HelpMenu property value.
927
* @return java.awt.Menu
929
private Menu getHelpMenu() {
930
if (iHelpMenu == null) {
932
iHelpMenu = new Menu();
933
iHelpMenu.setLabel("Help");
934
iHelpMenu.add(getAboutMenuItem());
935
} catch (Throwable iExc) {
936
handleException(iExc);
942
* Return the MenuSeparator1 property value.
943
* @return java.awt.MenuItem
945
private MenuItem getMenuSeparator() {
946
if (iMenuSeparator == null) {
948
iMenuSeparator = new MenuItem();
949
iMenuSeparator.setLabel("-");
950
} catch (Throwable iExc) {
951
handleException(iExc);
954
return iMenuSeparator;
957
* Return the MessageClearLogButton property value.
958
* @return java.awt.Button
960
private Button getMessageClearLogButton() {
961
if (iMessageClearLogButton == null) {
963
iMessageClearLogButton = new Button();
964
iMessageClearLogButton.setName("MessageClearLogButton");
965
iMessageClearLogButton.setLabel("Clear Log");
966
} catch (Throwable iExc) {
967
handleException(iExc);
970
return iMessageClearLogButton;
973
* Return the MessageCommandPanel property value.
974
* @return java.awt.Panel
976
private Panel getMessageCommandPanel() {
977
if (iMessageCommandPanel == null) {
979
iMessageCommandPanel = new Panel();
980
iMessageCommandPanel.setName("MessageCommandPanel");
981
iMessageCommandPanel.setLayout(new FlowLayout());
982
getMessageCommandPanel().add(getMessageClearLogButton(), getMessageClearLogButton().getName());
983
getMessageCommandPanel().add(getMessageOkButton(), getMessageOkButton().getName());
984
} catch (Throwable iExc) {
985
handleException(iExc);
988
return iMessageCommandPanel;
991
* Return the MessageContentPanel property value.
992
* @return java.awt.Panel
994
private Panel getMessageContentPanel() {
995
if (iMessageContentPanel == null) {
997
iMessageContentPanel = new Panel();
998
iMessageContentPanel.setName("MessageContentPanel");
999
iMessageContentPanel.setLayout(new BorderLayout());
1000
iMessageContentPanel.setBackground(SystemColor.control);
1001
getMessageContentPanel().add(getMessageTextArea(), "Center");
1002
getMessageContentPanel().add(getMessageCommandPanel(), "South");
1003
} catch (Throwable iExc) {
1004
handleException(iExc);
1007
return iMessageContentPanel;
1010
* Return the MessageFrame property value.
1011
* @return java.awt.Frame
1013
private Frame getMessageFrame() {
1014
if (iMessageFrame == null) {
1016
iMessageFrame = new Frame();
1017
iMessageFrame.setName("MessageFrame");
1018
iMessageFrame.setLayout(new BorderLayout());
1019
iMessageFrame.setBounds(0, 0, 750, 250);
1020
iMessageFrame.setTitle("Message Log");
1021
iMessageFrame.add(getMessageContentPanel(), "Center");
1022
iMessageFrame.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (iMessageFrame.getSize().width / 2), (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2));
1023
} catch (Throwable iExc) {
1024
handleException(iExc);
1027
return iMessageFrame;
1030
* Return the MessageOkButton property value.
1031
* @return java.awt.Button
1033
private Button getMessageOkButton() {
1034
if (iMessageOkButton == null) {
1036
iMessageOkButton = new Button();
1037
iMessageOkButton.setName("MessageOkButton");
1038
iMessageOkButton.setLabel("Close");
1039
} catch (Throwable iExc) {
1040
handleException(iExc);
1043
return iMessageOkButton;
1046
* Return the MessageOutputLevelChoice property value.
1047
* @return java.awt.Choice
1049
private Choice getMessageOutputLevelChoice() {
1050
if (iMessageOutputLevelChoice == null) {
1052
iMessageOutputLevelChoice = new Choice();
1053
iMessageOutputLevelChoice.setName("MessageOutputLevelChoice");
1054
iMessageOutputLevelChoice.add("Error");
1055
iMessageOutputLevelChoice.add("Warning");
1056
iMessageOutputLevelChoice.add("Info");
1057
iMessageOutputLevelChoice.add("Verbose");
1058
iMessageOutputLevelChoice.add("Debug");
1059
iMessageOutputLevelChoice.select(2);
1060
} catch (Throwable iExc) {
1061
handleException(iExc);
1064
return iMessageOutputLevelChoice;
1067
* Return the MessageOutputLevelLabel property value.
1068
* @return java.awt.Label
1070
private Label getMessageOutputLevelLabel() {
1071
if (iMessageOutputLevelLabel == null) {
1073
iMessageOutputLevelLabel = new Label();
1074
iMessageOutputLevelLabel.setName("MessageOutputLevelLabel");
1075
iMessageOutputLevelLabel.setText("Message Level:");
1076
} catch (Throwable iExc) {
1077
handleException(iExc);
1080
return iMessageOutputLevelLabel;
1083
* Return the MessageTextArea property value.
1084
* @return java.awt.TextArea
1086
private TextArea getMessageTextArea() {
1087
if (iMessageTextArea == null) {
1089
iMessageTextArea = new TextArea();
1090
iMessageTextArea.setName("MessageTextArea");
1091
iMessageTextArea.setFont(new Font("monospaced", 0, 12));
1092
iMessageTextArea.setText("");
1093
iMessageTextArea.setEditable(false);
1094
iMessageTextArea.setEnabled(true);
1095
} catch (Throwable iExc) {
1096
handleException(iExc);
1099
return iMessageTextArea;
1102
* Return the Panel1 property value.
1103
* @return java.awt.Panel
1105
private Panel getOptionenPanel() {
1106
if (iOptionenPanel == null) {
1108
iOptionenPanel = new Panel();
1109
iOptionenPanel.setName("OptionenPanel");
1110
iOptionenPanel.setLayout(new GridBagLayout());
1111
iOptionenPanel.setBackground(SystemColor.control);
1113
GridBagConstraints constraintsProjectLabel = new GridBagConstraints();
1114
constraintsProjectLabel.gridx = 0; constraintsProjectLabel.gridy = 0;
1115
constraintsProjectLabel.anchor = GridBagConstraints.WEST;
1116
constraintsProjectLabel.insets = new Insets(4, 4, 4, 4);
1117
getOptionenPanel().add(getProjectLabel(), constraintsProjectLabel);
1119
GridBagConstraints constraintsBuildFileLabel = new GridBagConstraints();
1120
constraintsBuildFileLabel.gridx = 0; constraintsBuildFileLabel.gridy = 1;
1121
constraintsBuildFileLabel.anchor = GridBagConstraints.WEST;
1122
constraintsBuildFileLabel.insets = new Insets(4, 4, 4, 4);
1123
getOptionenPanel().add(getBuildFileLabel(), constraintsBuildFileLabel);
1125
GridBagConstraints constraintsTargetLabel = new GridBagConstraints();
1126
constraintsTargetLabel.gridx = 0; constraintsTargetLabel.gridy = 2;
1127
constraintsTargetLabel.anchor = GridBagConstraints.NORTHWEST;
1128
constraintsTargetLabel.insets = new Insets(4, 4, 4, 4);
1129
getOptionenPanel().add(getTargetLabel(), constraintsTargetLabel);
1131
GridBagConstraints constraintsProjectText = new GridBagConstraints();
1132
constraintsProjectText.gridx = 1; constraintsProjectText.gridy = 0;
1133
constraintsProjectText.gridwidth = 2;
1134
constraintsProjectText.fill = GridBagConstraints.HORIZONTAL;
1135
constraintsProjectText.anchor = GridBagConstraints.WEST;
1136
constraintsProjectText.insets = new Insets(4, 4, 4, 4);
1137
getOptionenPanel().add(getProjectText(), constraintsProjectText);
1139
GridBagConstraints constraintsBuildFileTextField = new GridBagConstraints();
1140
constraintsBuildFileTextField.gridx = 1; constraintsBuildFileTextField.gridy = 1;
1141
constraintsBuildFileTextField.fill = GridBagConstraints.HORIZONTAL;
1142
constraintsBuildFileTextField.anchor = GridBagConstraints.WEST;
1143
constraintsBuildFileTextField.weightx = 1.0;
1144
constraintsBuildFileTextField.insets = new Insets(4, 4, 4, 4);
1145
getOptionenPanel().add(getBuildFileTextField(), constraintsBuildFileTextField);
1147
GridBagConstraints constraintsBrowseButton = new GridBagConstraints();
1148
constraintsBrowseButton.gridx = 2; constraintsBrowseButton.gridy = 1;
1149
constraintsBrowseButton.insets = new Insets(4, 4, 4, 4);
1150
getOptionenPanel().add(getBrowseButton(), constraintsBrowseButton);
1152
GridBagConstraints constraintsTargetList = new GridBagConstraints();
1153
constraintsTargetList.gridx = 1; constraintsTargetList.gridy = 2;
1154
constraintsTargetList.gridheight = 2;
1155
constraintsTargetList.fill = GridBagConstraints.BOTH;
1156
constraintsTargetList.weightx = 1.0;
1157
constraintsTargetList.weighty = 1.0;
1158
constraintsTargetList.insets = new Insets(4, 4, 4, 4);
1159
getOptionenPanel().add(getTargetList(), constraintsTargetList);
1161
GridBagConstraints constraintsMessageOutputLevelLabel = new GridBagConstraints();
1162
constraintsMessageOutputLevelLabel.gridx = 0; constraintsMessageOutputLevelLabel.gridy = 4;
1163
constraintsMessageOutputLevelLabel.anchor = GridBagConstraints.WEST;
1164
constraintsMessageOutputLevelLabel.insets = new Insets(4, 4, 4, 4);
1165
getOptionenPanel().add(getMessageOutputLevelLabel(), constraintsMessageOutputLevelLabel);
1167
GridBagConstraints constraintsMessageOutputLevelChoice = new GridBagConstraints();
1168
constraintsMessageOutputLevelChoice.gridx = 1; constraintsMessageOutputLevelChoice.gridy = 4;
1169
constraintsMessageOutputLevelChoice.fill = GridBagConstraints.HORIZONTAL;
1170
constraintsMessageOutputLevelChoice.anchor = GridBagConstraints.WEST;
1171
constraintsMessageOutputLevelChoice.weightx = 1.0;
1172
constraintsMessageOutputLevelChoice.insets = new Insets(4, 4, 4, 4);
1173
getOptionenPanel().add(getMessageOutputLevelChoice(), constraintsMessageOutputLevelChoice);
1174
} catch (Throwable iExc) {
1175
handleException(iExc);
1178
return iOptionenPanel;
1181
* Return the ProjectLabel property value.
1182
* @return java.awt.Label
1184
private Label getProjectLabel() {
1185
if (iProjectLabel == null) {
1187
iProjectLabel = new Label();
1188
iProjectLabel.setName("ProjectLabel");
1189
iProjectLabel.setText("Projectname:");
1190
} catch (Throwable iExc) {
1191
handleException(iExc);
1194
return iProjectLabel;
1197
* Return the ProjectText property value.
1198
* @return java.awt.Label
1200
private Label getProjectText() {
1201
if (iProjectText == null) {
1203
iProjectText = new Label();
1204
iProjectText.setName("ProjectText");
1205
iProjectText.setText(" ");
1206
} catch (Throwable iExc) {
1207
handleException(iExc);
1210
return iProjectText;
1213
* Return the ReloadButton property value.
1214
* @return java.awt.Button
1216
private Button getReloadButton() {
1217
if (iReloadButton == null) {
1219
iReloadButton = new Button();
1220
iReloadButton.setName("ReloadButton");
1221
iReloadButton.setLabel("(Re)Load");
1222
} catch (Throwable iExc) {
1223
handleException(iExc);
1226
return iReloadButton;
1229
* Return the SaveMenuItem property value.
1230
* @return java.awt.MenuItem
1232
private MenuItem getSaveMenuItem() {
1233
if (iSaveMenuItem == null) {
1235
iSaveMenuItem = new MenuItem();
1236
iSaveMenuItem.setLabel("Save BuildInfo To Repository");
1237
} catch (Throwable iExc) {
1238
handleException(iExc);
1241
return iSaveMenuItem;
1244
* Return the ShowLogMenuItem property value.
1245
* @return java.awt.MenuItem
1247
private MenuItem getShowLogMenuItem() {
1248
if (iShowLogMenuItem == null) {
1250
iShowLogMenuItem = new MenuItem();
1251
iShowLogMenuItem.setLabel("Log");
1252
} catch (Throwable iExc) {
1253
handleException(iExc);
1256
return iShowLogMenuItem;
1259
* Return the TargetLabel property value.
1260
* @return java.awt.Label
1262
private Label getTargetLabel() {
1263
if (iTargetLabel == null) {
1265
iTargetLabel = new Label();
1266
iTargetLabel.setName("TargetLabel");
1267
iTargetLabel.setText("Target:");
1268
iTargetLabel.setEnabled(true);
1269
} catch (Throwable iExc) {
1270
handleException(iExc);
1273
return iTargetLabel;
1276
* Return the TargetList property value.
1277
* @return java.awt.List
1279
private List getTargetList() {
1280
if (iTargetList == null) {
1282
iTargetList = new List();
1283
iTargetList.setName("TargetList");
1284
iTargetList.setEnabled(true);
1285
} catch (Throwable iExc) {
1286
handleException(iExc);
1292
* Called whenever the part throws an exception.
1293
* @param exception Throwable
1295
private void handleException(Throwable exception) {
1296
// Write exceptions to the log-window
1297
getMessageTextArea().append(lineSeparator + lineSeparator + exception.getMessage());
1298
getMessageFrame().show();
1302
* Initializes connections
1303
* @exception Exception The exception description.
1305
private void initConnections() throws Exception {
1306
this.addWindowListener(iEventHandler);
1307
getBrowseButton().addActionListener(iEventHandler);
1308
getCloseButton().addActionListener(iEventHandler);
1309
getBuildButton().addActionListener(iEventHandler);
1310
getSaveMenuItem().addActionListener(iEventHandler);
1311
getAboutOkButton().addActionListener(iEventHandler);
1312
getAboutMenuItem().addActionListener(iEventHandler);
1313
getMessageOkButton().addActionListener(iEventHandler);
1314
getMessageClearLogButton().addActionListener(iEventHandler);
1315
getMessageOkButton().addActionListener(iEventHandler);
1316
getShowLogMenuItem().addActionListener(iEventHandler);
1317
getAboutDialog().addWindowListener(iEventHandler);
1318
getMessageFrame().addWindowListener(iEventHandler);
1319
getReloadButton().addActionListener(iEventHandler);
1320
getTargetList().addItemListener(iEventHandler);
1321
getMessageOutputLevelChoice().addItemListener(iEventHandler);
1322
getBuildFileTextField().addTextListener(iEventHandler);
1323
connectProjectNameToLabel();
1324
connectBuildFileNameToTextField();
1327
* Initialize the class.
1329
private void initialize() {
1332
setMenuBar(getAntMakeMenuBar());
1333
setLayout(new java.awt.BorderLayout());
1335
setTitle("Ant VisualAge for Java Tool-Integration");
1336
add(getContentsPane(), "Center");
1338
} catch (Throwable iExc) {
1339
handleException(iExc);
1341
setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (getSize().width / 2), (java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (getSize().height));
1342
if ((getTargetList().getItemCount() == 0) || (getTargetList().getSelectedIndex() < 0)) {
1343
getBuildButton().setEnabled(false);
1347
* Saves the build-informations to repository
1349
private void saveBuildInfo() {
1351
VAJAntTool.saveBuildData(getBuildInfo());
1353
catch (Throwable exc) {
1354
// This Exception occurs when you try to write into a versioned project
1355
handleException( exc );
1360
* Set the BuildInfo to a new value.
1361
* @param newValue org.apache.tools.ant.taskdefs.optional.vaj.VAJBuildInfo
1363
private void setBuildInfo(VAJBuildInfo newValue) {
1364
if (iBuildInfo != newValue) {
1366
/* Stop listening for events from the current object */
1367
if (iBuildInfo != null) {
1368
iBuildInfo.removePropertyChangeListener(iEventHandler);
1370
iBuildInfo = newValue;
1372
/* Listen for events from the new object */
1373
if (iBuildInfo != null) {
1374
iBuildInfo.addPropertyChangeListener(iEventHandler);
1376
connectProjectNameToLabel();
1377
connectBuildFileNameToTextField();
1379
// Select the log-level given by BuildInfo
1380
getMessageOutputLevelChoice().select(iBuildInfo.getOutputMessageLevel());
1382
// BuildInfo can conly be saved to a VAJ project if tool API is called via the projects context-menu
1383
if ((iBuildInfo.getVAJProjectName() == null) || (iBuildInfo.getVAJProjectName().equals(""))) {
1384
getSaveMenuItem().setEnabled(false);
1386
} catch (Throwable iExc) {
1387
handleException(iExc);