KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > rubyproject > gems > GemProgressPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.ruby.rubyproject.gems;
20
21 import javax.swing.JTextArea JavaDoc;
22
23 /**
24  *
25  * @author Tor Norbye
26  */

27 public class GemProgressPanel extends javax.swing.JPanel JavaDoc {
28     /** Creates new form GemProgressPanel */
29     public GemProgressPanel(String JavaDoc message) {
30         initComponents();
31         messageLabel.setText(message);
32         //detailsPanel.remove(detailsScrollPane);
33
}
34     
35     public JTextArea JavaDoc getOutputArea() {
36         return outputArea;
37     }
38     
39     public void done(String JavaDoc message) {
40         messageLabel.setText(message);
41         progressBar.setIndeterminate(false);
42         progressBar.getModel().setValue(progressBar.getModel().getMaximum());
43     }
44     
45     
46     /** This method is called from within the constructor to
47      * initialize the form.
48      * WARNING: Do NOT modify this code. The content of this method is
49      * always regenerated by the Form Editor.
50      */

51     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
52
private void initComponents() {
53
54         messageLabel = new javax.swing.JLabel JavaDoc();
55         javax.swing.JSeparator JavaDoc separator = new javax.swing.JSeparator JavaDoc();
56         outputToggle = new javax.swing.JCheckBox JavaDoc();
57         progressBar = new javax.swing.JProgressBar JavaDoc();
58         detailsPanel = new javax.swing.JPanel JavaDoc();
59         detailsScrollPane = new javax.swing.JScrollPane JavaDoc();
60         outputArea = new javax.swing.JTextArea JavaDoc();
61
62         messageLabel.setText(org.openide.util.NbBundle.getMessage(GemProgressPanel.class, "GemProgressPanel.messageLabel.text")); // NOI18N
63

64         outputToggle.setSelected(true);
65         outputToggle.setText(org.openide.util.NbBundle.getMessage(GemProgressPanel.class, "GemProgressPanel.outputToggle.text")); // NOI18N
66
outputToggle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
67         outputToggle.setEnabled(false);
68         outputToggle.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
69         outputToggle.addActionListener(new java.awt.event.ActionListener JavaDoc() {
70             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
71                 outputToggleActionPerformed(evt);
72             }
73         });
74
75         progressBar.setIndeterminate(true);
76
77         detailsPanel.setLayout(new java.awt.BorderLayout JavaDoc());
78
79         outputArea.setColumns(20);
80         outputArea.setEditable(false);
81         outputArea.setRows(6);
82         detailsScrollPane.setViewportView(outputArea);
83
84         detailsPanel.add(detailsScrollPane, java.awt.BorderLayout.CENTER);
85
86         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
87         this.setLayout(layout);
88         layout.setHorizontalGroup(
89             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
90             .add(layout.createSequentialGroup()
91                 .addContainerGap()
92                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
93                     .add(layout.createSequentialGroup()
94                         .add(messageLabel)
95                         .addContainerGap(385, Short.MAX_VALUE))
96                     .add(layout.createSequentialGroup()
97                         .add(progressBar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
98                         .add(22, 22, 22))
99                     .add(layout.createSequentialGroup()
100                         .add(outputToggle)
101                         .addContainerGap(281, Short.MAX_VALUE))
102                     .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
103                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
104                             .add(org.jdesktop.layout.GroupLayout.LEADING, detailsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
105                             .add(separator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE))
106                         .addContainerGap())))
107         );
108         layout.setVerticalGroup(
109             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
110             .add(layout.createSequentialGroup()
111                 .addContainerGap()
112                 .add(messageLabel)
113                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
114                 .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
115                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
116                 .add(separator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
117                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
118                 .add(outputToggle)
119                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
120                 .add(detailsPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
121                 .addContainerGap())
122         );
123     }// </editor-fold>//GEN-END:initComponents
124

125 private void outputToggleActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_outputToggleActionPerformed
126
// if (outputToggle.isSelected() != outputArea.isVisible()) {
127
if (outputToggle.isSelected()) {
128             detailsPanel.add(detailsScrollPane, java.awt.BorderLayout.CENTER);
129         } else {
130             detailsPanel.remove(detailsScrollPane);
131         }
132         detailsPanel.invalidate();
133         invalidate();
134         revalidate();
135         validate();
136         repaint();
137 // }
138
}//GEN-LAST:event_outputToggleActionPerformed
139

140     
141     // Variables declaration - do not modify//GEN-BEGIN:variables
142
private javax.swing.JPanel JavaDoc detailsPanel;
143     private javax.swing.JScrollPane JavaDoc detailsScrollPane;
144     private javax.swing.JLabel JavaDoc messageLabel;
145     private javax.swing.JTextArea JavaDoc outputArea;
146     private javax.swing.JCheckBox JavaDoc outputToggle;
147     private javax.swing.JProgressBar JavaDoc progressBar;
148     // End of variables declaration//GEN-END:variables
149

150 }
151
Popular Tags