1 19 20 package org.netbeans.modules.autoupdate; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Component ; 24 import java.awt.Dialog ; 25 import java.awt.Font ; 26 import java.util.ResourceBundle ; 27 import javax.swing.JPanel ; 28 import javax.swing.SwingUtilities ; 29 import org.netbeans.api.progress.ProgressHandle; 30 import org.netbeans.api.progress.ProgressHandleFactory; 31 32 import org.openide.util.NbBundle; 33 34 class DownloadProgressPanel extends javax.swing.JPanel { 35 36 private static final String EMPTY_STRING = ""; 38 39 private Dialog dialog; 40 41 private String title; 42 43 static final long serialVersionUID =1986287669107010921L; 44 45 private Wizard.WizardPanel wizardPanel; 46 47 48 public DownloadProgressPanel(Wizard.WizardPanel wizardPanel) { 49 this.wizardPanel = wizardPanel; 50 putClientProperty("WizardPanel_contentSelectedIndex", new Integer (2)); setName(getBundle("LBL_Download")); 52 initComponents(); 53 54 partialLabel.setText (EMPTY_STRING); 55 overallLabel.setText (EMPTY_STRING); 56 extraLabel.setText (EMPTY_STRING); 57 58 getAccessibleContext().setAccessibleName(getBundle("LBL_Download")); 59 getAccessibleContext().setAccessibleDescription(getBundle("LBL_31")); 60 jTextArea1.getAccessibleContext().setAccessibleName(getBundle("ACS_31")); 61 jTextArea1.getAccessibleContext().setAccessibleDescription(getBundle("ACSD_31")); 62 } 63 64 65 public java.awt.Dimension getPreferredSize() { 66 return new java.awt.Dimension ( 350, super.getPreferredSize().height ); 67 } 68 69 74 private void initComponents() { 76 java.awt.GridBagConstraints gridBagConstraints; 77 78 jTextArea1 = new javax.swing.JTextArea (); 79 partialLabel = new javax.swing.JLabel (); 80 jPanel1 = new javax.swing.JPanel (); 81 jProgressBar1 = new javax.swing.JProgressBar (); 82 overallLabel = new javax.swing.JLabel (); 83 jPanel2 = new javax.swing.JPanel (); 84 jProgressBar2 = new javax.swing.JProgressBar (); 85 extraLabel = new javax.swing.JLabel (); 86 jButton1 = new javax.swing.JButton (); 87 88 setLayout(new java.awt.GridBagLayout ()); 89 90 jTextArea1.setBackground(partialLabel.getBackground()); 91 jTextArea1.setEditable(false); 92 jTextArea1.setFont(new Font ("Dialog", Font.PLAIN, jTextArea1.getFont().getSize())); 93 jTextArea1.setLineWrap(true); 94 jTextArea1.setText(getBundle("LBL_31")); 95 jTextArea1.setWrapStyleWord(true); 96 gridBagConstraints = new java.awt.GridBagConstraints (); 97 gridBagConstraints.gridx = 0; 98 gridBagConstraints.gridy = 0; 99 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 100 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 101 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 102 gridBagConstraints.weightx = 1.0; 103 add(jTextArea1, gridBagConstraints); 104 105 partialLabel.setLabelFor(jPanel1); 106 gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.gridx = 0; 108 gridBagConstraints.gridy = 1; 109 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 110 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 111 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 112 add(partialLabel, gridBagConstraints); 113 114 jPanel1.setLayout(new java.awt.BorderLayout ()); 115 116 jPanel1.setPreferredSize(new java.awt.Dimension (0, 20)); 117 jPanel1.add(jProgressBar1, java.awt.BorderLayout.CENTER); 118 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridx = 0; 121 gridBagConstraints.gridy = 2; 122 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 123 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 124 gridBagConstraints.insets = new java.awt.Insets (4, 0, 0, 0); 125 add(jPanel1, gridBagConstraints); 126 127 overallLabel.setLabelFor(jPanel2); 128 gridBagConstraints = new java.awt.GridBagConstraints (); 129 gridBagConstraints.gridx = 0; 130 gridBagConstraints.gridy = 3; 131 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 132 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 133 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 134 add(overallLabel, gridBagConstraints); 135 136 jPanel2.setLayout(new java.awt.BorderLayout ()); 137 138 jPanel2.setPreferredSize(new java.awt.Dimension (0, 20)); 139 jPanel2.add(jProgressBar2, java.awt.BorderLayout.CENTER); 140 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 0; 143 gridBagConstraints.gridy = 4; 144 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 145 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 146 gridBagConstraints.insets = new java.awt.Insets (4, 0, 0, 0); 147 add(jPanel2, gridBagConstraints); 148 149 extraLabel.setLabelFor(this); 150 org.openide.awt.Mnemonics.setLocalizedText(extraLabel, getBundle("LBL_32")); 151 gridBagConstraints = new java.awt.GridBagConstraints (); 152 gridBagConstraints.gridx = 0; 153 gridBagConstraints.gridy = 5; 154 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 155 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 156 gridBagConstraints.weighty = 1.0; 157 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 158 add(extraLabel, gridBagConstraints); 159 160 org.openide.awt.Mnemonics.setLocalizedText(jButton1, getBundle("BTN_Stop")); 161 jButton1.addActionListener(new java.awt.event.ActionListener () { 162 public void actionPerformed(java.awt.event.ActionEvent evt) { 163 jButton1ActionPerformed(evt); 164 } 165 }); 166 167 gridBagConstraints = new java.awt.GridBagConstraints (); 168 gridBagConstraints.gridx = 1; 169 gridBagConstraints.gridy = 5; 170 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 171 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 172 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; 173 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 174 add(jButton1, gridBagConstraints); 175 176 } 178 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { if (IncompleteDialog.showDialog() == IncompleteDialog.STOP) { 180 setExtraLabel (getBundle ("DownloadProgressPanel.jLabel1.Stop")); wizardPanel.end(false); 182 jButton1.setEnabled (false); 183 } 184 } 186 187 private javax.swing.JLabel extraLabel; 189 private javax.swing.JButton jButton1; 190 private javax.swing.JPanel jPanel1; 191 private javax.swing.JPanel jPanel2; 192 private javax.swing.JProgressBar jProgressBar1; 193 private javax.swing.JProgressBar jProgressBar2; 194 private javax.swing.JTextArea jTextArea1; 195 private javax.swing.JLabel overallLabel; 196 private javax.swing.JLabel partialLabel; 197 199 void setEnableStop(boolean enable) { 200 jButton1.setEnabled(enable); 201 } 202 203 205 void setPartialProgressComponent (ProgressHandle partial) { 206 final Component c = ProgressHandleFactory.createProgressComponent (partial); 207 SwingUtilities.invokeLater (new Runnable () { 208 public void run () { 209 plugProgressComponent (c, jPanel1); 210 } 211 }); 212 } 213 214 void setOverallProgressComponent (ProgressHandle overall) { 215 final Component c = ProgressHandleFactory.createProgressComponent (overall); 216 SwingUtilities.invokeLater (new Runnable () { 217 public void run () { 218 plugProgressComponent (c, jPanel2); 219 } 220 }); 221 } 222 223 private void plugProgressComponent (Component c, JPanel p) { 224 p.removeAll (); 225 p.add (c, BorderLayout.CENTER); 226 revalidate (); 227 } 228 229 230 public void close() { 231 dialog.setVisible( false ); 232 dialog.dispose(); 233 dialog = null; 234 } 235 236 public void setPartialLabel (String msg) { 238 partialLabel.setText (msg); 239 } 240 241 public void setOverallLabel (String msg) { 242 overallLabel.setText (msg); 243 } 244 245 public void setExtraLabel (String msg) { 246 extraLabel.setText (msg); 247 } 248 249 251 private static String getBundle( String key ) { 252 return NbBundle.getMessage( DownloadProgressPanel.class, key ); 253 } 254 } 255 | Popular Tags |