001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.compapp.projects.wizard;
021:
022: import java.awt.GridBagConstraints;
023: import java.awt.GridBagLayout;
024: import java.awt.LayoutManager;
025: import javax.swing.JComponent;
026: import javax.swing.JLabel;
027: import javax.swing.JPanel;
028:
029: /**
030: * Panel template used by {@link ProgressDialogFactory}.
031: *
032: * @see org.netbeans.modules.compapp.projects.wizard.ProgressDialogFactory
033: *
034: * @author Tientien Li
035: */
036: class ProgressPanel extends JPanel {
037:
038: /** Creates new form ProgressPanel */
039: ProgressPanel(final JComponent progressBar) {
040:
041: initComponents();
042: embed(progressBar);
043: }
044:
045: /** This method is called from within the constructor to
046: * initialize the form.
047: * WARNING: Do NOT modify this code. The content of this method is
048: * always regenerated by the Form Editor.
049: */
050: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
051: private void initComponents() {
052: java.awt.GridBagConstraints gridBagConstraints;
053:
054: panelProgressTracking = new javax.swing.JPanel();
055: panelVisualProgress = new javax.swing.JPanel();
056: labelProgressDetail = new javax.swing.JLabel();
057: progressBar = new javax.swing.JProgressBar();
058:
059: setLayout(new java.awt.GridBagLayout());
060:
061: panelProgressTracking.setLayout(new java.awt.GridBagLayout());
062:
063: panelVisualProgress.setLayout(new java.awt.GridBagLayout());
064:
065: labelProgressDetail.setMinimumSize(new java.awt.Dimension(300,
066: 14));
067: labelProgressDetail.setPreferredSize(new java.awt.Dimension(
068: 300, 14));
069: gridBagConstraints = new java.awt.GridBagConstraints();
070: gridBagConstraints.gridx = 0;
071: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
072: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
073: gridBagConstraints.weightx = 1.0;
074: gridBagConstraints.insets = new java.awt.Insets(8, 4, 4, 4);
075: panelVisualProgress
076: .add(labelProgressDetail, gridBagConstraints);
077:
078: gridBagConstraints = new java.awt.GridBagConstraints();
079: gridBagConstraints.gridx = 0;
080: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
081: gridBagConstraints.weightx = 1.0;
082: gridBagConstraints.insets = new java.awt.Insets(4, 4, 8, 4);
083: panelVisualProgress.add(progressBar, gridBagConstraints);
084:
085: gridBagConstraints = new java.awt.GridBagConstraints();
086: gridBagConstraints.gridx = 0;
087: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
088: gridBagConstraints.weightx = 1.0;
089: gridBagConstraints.insets = new java.awt.Insets(4, 10, 4, 10);
090: panelProgressTracking.add(panelVisualProgress,
091: gridBagConstraints);
092:
093: gridBagConstraints = new java.awt.GridBagConstraints();
094: gridBagConstraints.gridx = 0;
095: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
096: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
097: gridBagConstraints.weightx = 1.0;
098: gridBagConstraints.weighty = 1.0;
099: add(panelProgressTracking, gridBagConstraints);
100:
101: }// </editor-fold>//GEN-END:initComponents
102:
103: private void embed(JComponent actualProgressBar) {
104: LayoutManager layout = panelVisualProgress.getLayout();
105: if (layout instanceof GridBagLayout) {
106: GridBagLayout gbl = (GridBagLayout) layout;
107: GridBagConstraints cons = gbl.getConstraints(progressBar);
108: panelVisualProgress.add(actualProgressBar, cons);
109: panelVisualProgress.remove(progressBar);
110: validate();
111: } else {
112: throw new RuntimeException(
113: "Internal error: expected GridBagLayout for panelVisualProgress, "
114: + "found " + layout.getClass().getName());
115: }
116: }
117:
118: JLabel getMessageComponent() {
119: return labelProgressDetail;
120: }
121:
122: // Variables declaration - do not modify//GEN-BEGIN:variables
123: private javax.swing.JLabel labelProgressDetail;
124: private javax.swing.JPanel panelProgressTracking;
125: private javax.swing.JPanel panelVisualProgress;
126: private javax.swing.JProgressBar progressBar;
127: // End of variables declaration//GEN-END:variables
128:
129: }
|