2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* Progress bar used for monitoring the state-saving and loading process. |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
* TODO To change the template for this generated file go to |
2 |
26 Feb 07 |
jari |
* Window - Preferences - Java - Code Style - Code Templates |
2 |
26 Feb 07 |
jari |
6 |
*/ |
2 |
26 Feb 07 |
jari |
7 |
package org.tigr.microarray.mev.persistence; |
2 |
26 Feb 07 |
jari |
8 |
|
2 |
26 Feb 07 |
jari |
9 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
10 |
import java.awt.*; |
2 |
26 Feb 07 |
jari |
11 |
import java.awt.event.*; |
2 |
26 Feb 07 |
jari |
12 |
import javax.swing.*; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import org.tigr.microarray.mev.MultipleArrayViewer; |
2 |
26 Feb 07 |
jari |
15 |
import org.tigr.microarray.mev.action.ActionManager; |
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
/** |
2 |
26 Feb 07 |
jari |
* @author eleanora |
2 |
26 Feb 07 |
jari |
19 |
* |
2 |
26 Feb 07 |
jari |
* TODO To change the template for this generated type comment go to |
2 |
26 Feb 07 |
jari |
* Window - Preferences - Java - Code Style - Code Templates |
2 |
26 Feb 07 |
jari |
22 |
*/ |
2 |
26 Feb 07 |
jari |
//public class StateSavingProgressPanel extends JPanel implements ActionListener { |
2 |
26 Feb 07 |
jari |
24 |
public class StateSavingProgressPanel extends JFrame implements ActionListener { |
2 |
26 Feb 07 |
jari |
25 |
|
2 |
26 Feb 07 |
jari |
26 |
private JProgressBar progressBar; |
2 |
26 Feb 07 |
jari |
// private JButton cancelButton; |
2 |
26 Feb 07 |
jari |
28 |
MultipleArrayViewer mav; |
2 |
26 Feb 07 |
jari |
29 |
JPanel progressPanel; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
public StateSavingProgressPanel(String initialMessage, MultipleArrayViewer mav) { |
2 |
26 Feb 07 |
jari |
32 |
setTitle(initialMessage); |
2 |
26 Feb 07 |
jari |
33 |
this.mav = mav; |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
progressPanel = new JPanel(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
36 |
progressPanel.setPreferredSize(new Dimension(350, 80)); |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
progressBar = new JProgressBar(0, 100); |
2 |
26 Feb 07 |
jari |
39 |
progressBar.setValue(0); |
2 |
26 Feb 07 |
jari |
40 |
progressBar.setStringPainted(true); |
2 |
26 Feb 07 |
jari |
41 |
progressBar.setPreferredSize(new Dimension(310, 30)); |
2 |
26 Feb 07 |
jari |
42 |
|
2 |
26 Feb 07 |
jari |
// cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
// cancelButton.setActionCommand("cancel"); |
2 |
26 Feb 07 |
jari |
// cancelButton.addActionListener(this); |
2 |
26 Feb 07 |
jari |
// cancelButton.setPreferredSize(new Dimension(70, 30)); |
2 |
26 Feb 07 |
jari |
47 |
|
2 |
26 Feb 07 |
jari |
48 |
progressPanel.add(progressBar, BorderLayout.PAGE_START); |
2 |
26 Feb 07 |
jari |
// progressPanel.add(cancelButton, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
50 |
progressPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
setContentPane(progressPanel); |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
progressPanel.setOpaque(true); |
2 |
26 Feb 07 |
jari |
55 |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
56 |
pack(); |
2 |
26 Feb 07 |
jari |
57 |
setVisible(true); |
2 |
26 Feb 07 |
jari |
58 |
} |
2 |
26 Feb 07 |
jari |
59 |
|
2 |
26 Feb 07 |
jari |
60 |
public void update(String message){ |
2 |
26 Feb 07 |
jari |
61 |
progressBar.setString(message); |
2 |
26 Feb 07 |
jari |
62 |
progressBar.setValue(progressBar.getMinimum()); |
2 |
26 Feb 07 |
jari |
63 |
} |
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
public void increment(){ |
2 |
26 Feb 07 |
jari |
66 |
progressBar.setValue(progressBar.getValue() + 1); |
2 |
26 Feb 07 |
jari |
67 |
} |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
public void setMaximum(int i){ |
2 |
26 Feb 07 |
jari |
70 |
progressBar.setMaximum(i); |
2 |
26 Feb 07 |
jari |
71 |
} |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
public int getMaximum(){ |
2 |
26 Feb 07 |
jari |
74 |
return progressBar.getMaximum(); |
2 |
26 Feb 07 |
jari |
75 |
} |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
public void setValue(int i){ |
2 |
26 Feb 07 |
jari |
78 |
progressBar.setValue(i); |
2 |
26 Feb 07 |
jari |
79 |
} |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
public void setIndeterminate(boolean b){ |
2 |
26 Feb 07 |
jari |
82 |
progressBar.setIndeterminate(b); |
2 |
26 Feb 07 |
jari |
83 |
} |
2 |
26 Feb 07 |
jari |
84 |
|
2 |
26 Feb 07 |
jari |
85 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
86 |
String command = evt.getActionCommand(); |
2 |
26 Feb 07 |
jari |
87 |
if (command.equals("cancel")) { |
2 |
26 Feb 07 |
jari |
88 |
mav.cancelLoadState(); |
2 |
26 Feb 07 |
jari |
89 |
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
2 |
26 Feb 07 |
jari |
90 |
progressBar.setIndeterminate(true); |
2 |
26 Feb 07 |
jari |
91 |
progressBar.setString("Cleaning Up..."); |
2 |
26 Feb 07 |
jari |
92 |
} |
2 |
26 Feb 07 |
jari |
93 |
} |
2 |
26 Feb 07 |
jari |
94 |
public void onClose(){ |
2 |
26 Feb 07 |
jari |
95 |
mav.cancelLoadState(); |
2 |
26 Feb 07 |
jari |
96 |
} |
2 |
26 Feb 07 |
jari |
97 |
} |
2 |
26 Feb 07 |
jari |
98 |
|