1 19 20 package org.netbeans.modules.subversion.client; 21 22 import java.awt.BorderLayout ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import javax.swing.JButton ; 26 import javax.swing.JComponent ; 27 import javax.swing.JLabel ; 28 import javax.swing.JPanel ; 29 import javax.swing.SwingUtilities ; 30 import org.netbeans.api.progress.ProgressHandle; 31 import org.netbeans.api.progress.ProgressHandleFactory; 32 import org.netbeans.modules.subversion.ui.wizards.repositorystep.RepositoryStep; 33 import org.openide.util.Cancellable; 34 35 39 public abstract class WizardStepProgressSupport extends SvnProgressSupport implements Runnable , Cancellable { 40 41 private JPanel progressComponent; 42 private JLabel progressLabel; 43 private JPanel panel; 44 45 public WizardStepProgressSupport(JPanel panel) { 46 this.panel = panel; 47 48 49 } 50 51 public void performInCurrentThread(String displayName) { 52 setDisplayName(displayName); 53 performIntern(); 54 } 55 56 public abstract void setEditable(boolean bl); 57 58 public void startProgress() { 59 SwingUtilities.invokeLater(new Runnable () { 60 public void run() { 61 ProgressHandle progress = getProgressHandle(); JComponent bar = ProgressHandleFactory.createProgressComponent(progress); 63 JButton stopButton = new JButton (org.openide.util.NbBundle.getMessage(RepositoryStep.class, "BK2022")); stopButton.addActionListener(new ActionListener () { 65 public void actionPerformed(ActionEvent e) { 66 cancel(); 67 } 68 }); 69 progressComponent = new JPanel (); 70 progressComponent.setLayout(new BorderLayout (6, 0)); 71 progressLabel = new JLabel (); 72 progressLabel.setText(getDisplayName()); 73 progressComponent.add(progressLabel, BorderLayout.NORTH); 74 progressComponent.add(bar, BorderLayout.CENTER); 75 progressComponent.add(stopButton, BorderLayout.LINE_END); 76 WizardStepProgressSupport.super.startProgress(); 77 panel.setVisible(true); 78 panel.add(progressComponent, BorderLayout.SOUTH); 79 panel.revalidate(); 80 } 81 }); 82 } 83 84 protected void finnishProgress() { 85 SwingUtilities.invokeLater(new Runnable () { 86 public void run() { 87 WizardStepProgressSupport.super.finnishProgress(); 88 panel.remove(progressComponent); 89 panel.revalidate(); 90 panel.repaint(); 91 panel.setVisible(false); 92 setEditable(true); 93 } 94 }); 95 } 96 97 public void setDisplayName(String displayName) { 98 if(progressLabel != null) { 99 progressLabel.setText(displayName); 100 } 101 super.setDisplayName(displayName); 102 } 103 104 } 105 | Popular Tags |