Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: medi/swing/frame/Volume2DbStatus.java


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