Source code: medi/swing/Volume2DbStatus.java
1 /*
2 * Volume2DbStatus.java
3 *
4 * Created on 21 luglio 2002, 11.22
5 */
6
7 package medi.swing;
8
9 import medi.base.util.Volume2Db;
10
11 /** It is a frame that shows status information abount volume-scanning-process.
12 * Information is refreshed every second.
13 * @author Antonio Petrelli
14 * @version 0.1.0
15 */
16 public class Volume2DbStatus extends javax.swing.JFrame implements Runnable {
17
18 /** Creates new form Volume2DbStatus */
19 public Volume2DbStatus() {
20 statusFrameThread = null;
21 initComponents();
22 }
23
24 /** Sets the action to display.
25 * @param ac The action.
26 */
27 public synchronized void setAction(String ac) {
28 action = ac;
29 }
30
31 /** Sets the scanned volume name.
32 * @param sv The scanned volume name.
33 */
34 public synchronized void setScannedVolume(String sv) {
35 scannedVolume = sv;
36 }
37
38 /** Sets the mount point to display.
39 * @param mp The mount point.
40 */
41 public synchronized void setMountPoint(String mp) {
42 mountPoint = mp;
43 }
44
45 /** Sets the current directory to display.
46 * @param cd The current directory.
47 */
48 public synchronized void setCurrentDirectory(String cd) {
49 currentDirectory = cd;
50 }
51
52 /** Sets the current file to display.
53 * @param cf The current file.
54 */
55 public synchronized void setCurrentFile (String cf) {
56 currentFile = cf;
57 }
58
59 /** Controls whether the "stop" button is enabled or not.
60 * @param enable <CODE>true</CODE>: the stop button will be enabled;
61 * <CODE>false</CODE>: the stop button will be disabled.
62 */
63 public void setStopButtonEnabled (boolean enable) {
64 butStop.setEnabled(enable);
65 }
66
67 /** Sets the scanner to be used.
68 * @param pScanner The scanner.
69 */
70 public void setScanner(Volume2Db pScanner) {
71 scanner = pScanner;
72 }
73
74 /** Starts the thread.
75 */
76 public void start() {
77 if (statusFrameThread == null) {
78 statusFrameThread = new Thread(this, java.util.ResourceBundle.getBundle("res/MediBundle").getString("Status_frame"));
79 statusFrameThread.start();
80 }
81 }
82
83 /** Stops the thread.
84 */
85 public void stop() {
86 statusFrameThread = null;
87 }
88
89 /** Thread's run method.
90 */
91 public void run() {
92 Thread curThread;
93
94 curThread = Thread.currentThread();
95 while (curThread == statusFrameThread) {
96 try {
97 Thread.sleep(1000);
98 }
99 catch (InterruptedException e) {
100 }
101 lblActionValue.setText(action);
102 lblScannedVolumeValue.setText(scannedVolume);
103 lblMountPointValue.setText(mountPoint);
104 lblCurrentDirectoryValue.setText(currentDirectory);
105 lblCurrentFileValue.setText(currentFile);
106 }
107 }
108
109 /** This method is called from within the constructor to
110 * initialize the form.
111 * WARNING: Do NOT modify this code. The content of this method is
112 * always regenerated by the Form Editor.
113 */
114 private void initComponents() {//GEN-BEGIN:initComponents
115 lblScannedVolume = new javax.swing.JLabel();
116 lblMountPoint = new javax.swing.JLabel();
117 lblCurrentDirectory = new javax.swing.JLabel();
118 lblCurrentFile = new javax.swing.JLabel();
119 lblScannedVolumeValue = new javax.swing.JLabel();
120 lblMountPointValue = new javax.swing.JLabel();
121 lblCurrentDirectoryValue = new javax.swing.JLabel();
122 lblCurrentFileValue = new javax.swing.JLabel();
123 lblFakeLabel = new javax.swing.JLabel();
124 lblAction = new javax.swing.JLabel();
125 lblActionValue = new javax.swing.JLabel();
126 butStop = new javax.swing.JButton();
127
128 getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
129
130 setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
131 setTitle(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Volume_scanning_status"));
132 addWindowListener(new java.awt.event.WindowAdapter() {
133 public void windowClosing(java.awt.event.WindowEvent evt) {
134 exitForm(evt);
135 }
136 });
137
138 lblScannedVolume.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Scanned_volume:"));
139 getContentPane().add(lblScannedVolume, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1));
140
141 lblMountPoint.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Mount_point:"));
142 getContentPane().add(lblMountPoint, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, -1, -1));
143
144 lblCurrentDirectory.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Current_directory:"));
145 getContentPane().add(lblCurrentDirectory, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, -1, -1));
146
147 lblCurrentFile.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Current_file:"));
148 getContentPane().add(lblCurrentFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1, -1));
149
150 lblScannedVolumeValue.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("This_label_will_change"));
151 getContentPane().add(lblScannedVolumeValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 50, -1, -1));
152
153 lblMountPointValue.setText("This label will change");
154 getContentPane().add(lblMountPointValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 80, -1, -1));
155
156 lblCurrentDirectoryValue.setText("This label will change");
157 getContentPane().add(lblCurrentDirectoryValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 110, -1, -1));
158
159 lblCurrentFileValue.setText("This label will change");
160 getContentPane().add(lblCurrentFileValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 140, -1, -1));
161
162 getContentPane().add(lblFakeLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 200, -1, -1));
163
164 lblAction.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Action:"));
165 getContentPane().add(lblAction, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, -1, -1));
166
167 lblActionValue.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("This_label_will_change"));
168 getContentPane().add(lblActionValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 20, -1, -1));
169
170 butStop.setText(java.util.ResourceBundle.getBundle("res/MediBundle").getString("Stop"));
171 butStop.addActionListener(new java.awt.event.ActionListener() {
172 public void actionPerformed(java.awt.event.ActionEvent evt) {
173 butStopActionPerformed(evt);
174 }
175 });
176
177 getContentPane().add(butStop, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 180, 110, -1));
178
179 pack();
180 }//GEN-END:initComponents
181
182 private void butStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butStopActionPerformed
183 // Add your handling code here:
184 scanner.stopScan();
185 }//GEN-LAST:event_butStopActionPerformed
186
187 /** Exit the Application */
188 private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
189 }//GEN-LAST:event_exitForm
190
191
192 // Variables declaration - do not modify//GEN-BEGIN:variables
193 private javax.swing.JLabel lblCurrentFile;
194 private javax.swing.JLabel lblScannedVolumeValue;
195 private javax.swing.JLabel lblCurrentFileValue;
196 private javax.swing.JLabel lblMountPointValue;
197 private javax.swing.JButton butStop;
198 private javax.swing.JLabel lblScannedVolume;
199 private javax.swing.JLabel lblMountPoint;
200 private javax.swing.JLabel lblAction;
201 private javax.swing.JLabel lblCurrentDirectory;
202 private javax.swing.JLabel lblFakeLabel;
203 private javax.swing.JLabel lblCurrentDirectoryValue;
204 private javax.swing.JLabel lblActionValue;
205 // End of variables declaration//GEN-END:variables
206
207 private Thread statusFrameThread;
208 private String action, scannedVolume, mountPoint, currentDirectory,
209 currentFile;
210 private Volume2Db scanner;
211 }