1 19 package org.netbeans.modules.ruby.rubyproject.gems; 20 21 import javax.swing.JTextArea ; 22 23 27 public class GemProgressPanel extends javax.swing.JPanel { 28 29 public GemProgressPanel(String message) { 30 initComponents(); 31 messageLabel.setText(message); 32 } 34 35 public JTextArea getOutputArea() { 36 return outputArea; 37 } 38 39 public void done(String message) { 40 messageLabel.setText(message); 41 progressBar.setIndeterminate(false); 42 progressBar.getModel().setValue(progressBar.getModel().getMaximum()); 43 } 44 45 46 51 private void initComponents() { 53 54 messageLabel = new javax.swing.JLabel (); 55 javax.swing.JSeparator separator = new javax.swing.JSeparator (); 56 outputToggle = new javax.swing.JCheckBox (); 57 progressBar = new javax.swing.JProgressBar (); 58 detailsPanel = new javax.swing.JPanel (); 59 detailsScrollPane = new javax.swing.JScrollPane (); 60 outputArea = new javax.swing.JTextArea (); 61 62 messageLabel.setText(org.openide.util.NbBundle.getMessage(GemProgressPanel.class, "GemProgressPanel.messageLabel.text")); 64 outputToggle.setSelected(true); 65 outputToggle.setText(org.openide.util.NbBundle.getMessage(GemProgressPanel.class, "GemProgressPanel.outputToggle.text")); outputToggle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 67 outputToggle.setEnabled(false); 68 outputToggle.setMargin(new java.awt.Insets (0, 0, 0, 0)); 69 outputToggle.addActionListener(new java.awt.event.ActionListener () { 70 public void actionPerformed(java.awt.event.ActionEvent evt) { 71 outputToggleActionPerformed(evt); 72 } 73 }); 74 75 progressBar.setIndeterminate(true); 76 77 detailsPanel.setLayout(new java.awt.BorderLayout ()); 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 } 125 private void outputToggleActionPerformed(java.awt.event.ActionEvent evt) { 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 } 140 141 private javax.swing.JPanel detailsPanel; 143 private javax.swing.JScrollPane detailsScrollPane; 144 private javax.swing.JLabel messageLabel; 145 private javax.swing.JTextArea outputArea; 146 private javax.swing.JCheckBox outputToggle; 147 private javax.swing.JProgressBar progressBar; 148 150 } 151 | Popular Tags |