KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > swing > BuildProgressPanel


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26 package org.aspectj.ajde.ui.swing;
27    
28 import javax.swing.*;
29 import java.awt.*;
30 import java.awt.event.*;
31
32 import org.aspectj.ajde.BuildProgressMonitor;
33 import org.aspectj.ajde.Ajde;
34
35 /**
36  * @author Mik Kersten
37  */

38 class BuildProgressPanel extends JPanel {
39
40     private static final int MAX_VAL = 100;
41     //private JDialog dialog = null;
42

43     BorderLayout borderLayout1 = new BorderLayout();
44     JPanel cancel_panel = new JPanel();
45     JButton cancel_button = new JButton();
46     JPanel jPanel2 = new JPanel();
47     JLabel progress_label = new JLabel();
48     JLabel configFile_label = new JLabel();
49     BorderLayout borderLayout3 = new BorderLayout();
50     JPanel jPanel1 = new JPanel();
51     JProgressBar compile_progressBar = new JProgressBar();
52
53     /**
54      * @param maxVal the value to which value to which the progress bar will
55      * count up to (in seconds)
56      */

57     public BuildProgressPanel() {
58         try {
59             jbInit();
60             compile_progressBar.setMaximum(MAX_VAL);
61         } catch (Exception JavaDoc e) {
62             throw new RuntimeException JavaDoc(e.toString());
63         }
64     }
65
66 // public void start() {
67
// dialog =
68
// new JDialog(TopManager.INSTANCE.getRootFrame(), "ajc Build Progress", false);
69
// // progressDialog = new CompileProgressPanel();
70
// dialog.setContentPane(this);
71
// dialog.setSize(500, 110);
72
// dialog.setLocationRelativeTo(TopManager.INSTANCE.getRootFrame());
73
// dialog.setVisible(true);
74
// }
75

76     public void setProgressText(String JavaDoc text) {
77         progress_label.setText(" " + text);
78     }
79
80     public void setConfigFile(String JavaDoc configFile) {
81         configFile_label.setText(" Build configuration: " + configFile);
82     }
83
84     /**
85      * Jumps the progress bar <CODE>newVal</CODE> seconds ahead.
86      */

87     public void setProgressBarVal(int newVal) {
88         compile_progressBar.setValue(newVal);
89     }
90
91     public void setProgressBarMax(int maxVal) {
92         compile_progressBar.setMaximum(maxVal);
93     }
94
95     public int getProgressBarMax() {
96         return compile_progressBar.getMaximum();
97     }
98
99     /**
100      * Makes the progress bar move one second ahead.
101      */

102     public void incrementProgressBarVal() {
103         int newVal = compile_progressBar.getValue() + 1;
104         compile_progressBar.setValue(newVal);
105     }
106
107     /**
108      * Jumps the progress bar to the end.
109      */

110     public void finish() {
111         compile_progressBar.setValue(compile_progressBar.getMaximum());
112     }
113
114     private void jbInit() throws Exception JavaDoc {
115         this.setLayout(borderLayout1);
116         cancel_button.setFont(new java.awt.Font JavaDoc("Dialog", 0, 11));
117         cancel_button.setText("Cancel");
118         cancel_button.addActionListener(new java.awt.event.ActionListener JavaDoc() {
119             public void actionPerformed(ActionEvent e) {
120                 cancel_button_actionPerformed(e);
121             }
122         });
123         progress_label.setFont(new java.awt.Font JavaDoc("Dialog", 0, 11));
124         progress_label.setText("");
125         jPanel2.setPreferredSize(new Dimension(360, 24));
126         jPanel2.setLayout(borderLayout3);
127         configFile_label.setFont(new java.awt.Font JavaDoc("Dialog", 0, 11));
128         configFile_label.setText("");
129         compile_progressBar.setPreferredSize(new Dimension(330, 14));
130         this.add(cancel_panel, BorderLayout.SOUTH);
131         cancel_panel.add(cancel_button, null);
132         this.add(jPanel2, BorderLayout.CENTER);
133         jPanel2.add(configFile_label, BorderLayout.NORTH);
134         jPanel2.add(progress_label, BorderLayout.SOUTH);
135         jPanel2.add(jPanel1, BorderLayout.CENTER);
136         jPanel1.add(compile_progressBar, null);
137     }
138
139     void cancel_button_actionPerformed(ActionEvent e) {
140         Ajde.getDefault().getBuildManager().abortBuild();
141     }
142 }
Popular Tags