~ubuntu-branches/ubuntu/raring/geotranz/raring

« back to all changes in this revision

Viewing changes to geotrans2/java_gui/geotrans/gui/ProgressDlg.java

  • Committer: Bazaar Package Importer
  • Author(s): Roberto Lumbreras
  • Date: 2008-10-17 14:43:09 UTC
  • Revision ID: james.westby@ubuntu.com-20081017144309-jb7uzfi1y1lvez8j
Tags: upstream-2.4.2
ImportĀ upstreamĀ versionĀ 2.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * ProgressDlg.java
 
4
 *
 
5
 * Created on April 9, 2001, 9:10 AM
 
6
 */
 
7
 
 
8
package geotrans.gui;
 
9
 
 
10
 
 
11
import geotrans.jni.JNIFiomeths;
 
12
import geotrans.jni.JNIStrtoval;
 
13
import geotrans.jni.GeotransError;
 
14
import geotrans.utility.Center;
 
15
 
 
16
 
 
17
/**
 
18
 *
 
19
 * @author  amyc
 
20
 * @version 
 
21
 */
 
22
public class ProgressDlg extends javax.swing.JDialog {
 
23
 
 
24
    JNIFiomeths jniFiomeths;
 
25
    
 
26
    /** Creates new form ProgressDlg */
 
27
    public ProgressDlg(javax.swing.JDialog parent, boolean modal, JNIFiomeths jni_Fiomeths) {
 
28
        super (parent, modal);
 
29
        jniFiomeths = jni_Fiomeths;
 
30
        initComponents ();
 
31
        numProcessedLabel.setVisible(false);
 
32
        numWarningsLabel.setVisible(false);
 
33
        numErrorsLabel.setVisible(false);
 
34
        elapsedTimeLabel.setVisible(false);
 
35
        pack ();
 
36
        new Center(parent, this);        
 
37
    }
 
38
 
 
39
    /** This method is called from within the constructor to
 
40
     * initialize the form.
 
41
     * WARNING: Do NOT modify this code. The content of this method is
 
42
     * always regenerated by the FormEditor.
 
43
     */
 
44
  // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
 
45
  private void initComponents() {
 
46
    java.awt.GridBagConstraints gridBagConstraints;
 
47
 
 
48
    buttonsPanel = new javax.swing.JPanel();
 
49
    startButton = new javax.swing.JButton();
 
50
    okButton = new javax.swing.JButton();
 
51
    cancelButton = new javax.swing.JButton();
 
52
    statusLabel = new javax.swing.JLabel();
 
53
    resultsPanel = new javax.swing.JPanel();
 
54
    numProcessedLabel = new javax.swing.JLabel();
 
55
    numWarningsLabel = new javax.swing.JLabel();
 
56
    numErrorsLabel = new javax.swing.JLabel();
 
57
    elapsedTimeLabel = new javax.swing.JLabel();
 
58
 
 
59
    setTitle("GEOTRANS File Processing");
 
60
    setResizable(false);
 
61
    addWindowListener(new java.awt.event.WindowAdapter() {
 
62
      public void windowClosing(java.awt.event.WindowEvent evt) {
 
63
        closeDialog(evt);
 
64
      }
 
65
    });
 
66
 
 
67
    buttonsPanel.setLayout(new java.awt.GridBagLayout());
 
68
 
 
69
    buttonsPanel.setPreferredSize(new java.awt.Dimension(274, 26));
 
70
    buttonsPanel.setMinimumSize(new java.awt.Dimension(274, 26));
 
71
    startButton.setPreferredSize(new java.awt.Dimension(76, 21));
 
72
    startButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
 
73
    startButton.setMnemonic(java.awt.event.KeyEvent.VK_S);
 
74
    startButton.setMaximumSize(new java.awt.Dimension(76, 21));
 
75
    startButton.setText("Start");
 
76
    startButton.setMinimumSize(new java.awt.Dimension(76, 21));
 
77
    startButton.addMouseListener(new java.awt.event.MouseAdapter() {
 
78
      public void mousePressed(java.awt.event.MouseEvent evt) {
 
79
        startButtonMousePressed(evt);
 
80
      }
 
81
      public void mouseReleased(java.awt.event.MouseEvent evt) {
 
82
        startButtonMouseReleased(evt);
 
83
      }
 
84
    });
 
85
 
 
86
    gridBagConstraints = new java.awt.GridBagConstraints();
 
87
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
 
88
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 4, 15);
 
89
    buttonsPanel.add(startButton, gridBagConstraints);
 
90
 
 
91
    okButton.setPreferredSize(new java.awt.Dimension(76, 21));
 
92
    okButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
 
93
    okButton.setMnemonic(java.awt.event.KeyEvent.VK_O);
 
94
    okButton.setMaximumSize(new java.awt.Dimension(76, 21));
 
95
    okButton.setText("OK");
 
96
    okButton.setMinimumSize(new java.awt.Dimension(76, 21));
 
97
    okButton.setEnabled(false);
 
98
    okButton.addActionListener(new java.awt.event.ActionListener() {
 
99
      public void actionPerformed(java.awt.event.ActionEvent evt) {
 
100
        okButtonActionPerformed(evt);
 
101
      }
 
102
    });
 
103
 
 
104
    gridBagConstraints = new java.awt.GridBagConstraints();
 
105
    gridBagConstraints.gridx = 1;
 
106
    gridBagConstraints.gridy = 0;
 
107
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
 
108
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 4, 15);
 
109
    buttonsPanel.add(okButton, gridBagConstraints);
 
110
 
 
111
    cancelButton.setPreferredSize(new java.awt.Dimension(76, 21));
 
112
    cancelButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
 
113
    cancelButton.setMnemonic(java.awt.event.KeyEvent.VK_C);
 
114
    cancelButton.setMaximumSize(new java.awt.Dimension(76, 21));
 
115
    cancelButton.setText("Cancel");
 
116
    cancelButton.setMinimumSize(new java.awt.Dimension(76, 21));
 
117
    cancelButton.addActionListener(new java.awt.event.ActionListener() {
 
118
      public void actionPerformed(java.awt.event.ActionEvent evt) {
 
119
        cancelButtonActionPerformed(evt);
 
120
      }
 
121
    });
 
122
 
 
123
    gridBagConstraints = new java.awt.GridBagConstraints();
 
124
    gridBagConstraints.gridx = 2;
 
125
    gridBagConstraints.gridy = 0;
 
126
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
 
127
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 4, 0);
 
128
    buttonsPanel.add(cancelButton, gridBagConstraints);
 
129
 
 
130
    getContentPane().add(buttonsPanel, java.awt.BorderLayout.SOUTH);
 
131
 
 
132
    statusLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 
133
    statusLabel.setText("Waiting");
 
134
    statusLabel.setMaximumSize(new java.awt.Dimension(35, 26));
 
135
    statusLabel.setMinimumSize(new java.awt.Dimension(35, 26));
 
136
    statusLabel.setPreferredSize(new java.awt.Dimension(35, 26));
 
137
    getContentPane().add(statusLabel, java.awt.BorderLayout.NORTH);
 
138
 
 
139
    resultsPanel.setLayout(new java.awt.GridBagLayout());
 
140
 
 
141
    resultsPanel.setPreferredSize(new java.awt.Dimension(274, 100));
 
142
    resultsPanel.setMinimumSize(new java.awt.Dimension(274, 100));
 
143
    numProcessedLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 
144
    numProcessedLabel.setText("Num Processed:");
 
145
    numProcessedLabel.setMaximumSize(new java.awt.Dimension(274, 16));
 
146
    numProcessedLabel.setMinimumSize(new java.awt.Dimension(274, 16));
 
147
    numProcessedLabel.setPreferredSize(new java.awt.Dimension(274, 16));
 
148
    resultsPanel.add(numProcessedLabel, new java.awt.GridBagConstraints());
 
149
 
 
150
    numWarningsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 
151
    numWarningsLabel.setText("Num Warnings:");
 
152
    gridBagConstraints = new java.awt.GridBagConstraints();
 
153
    gridBagConstraints.gridx = 0;
 
154
    gridBagConstraints.gridy = 1;
 
155
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
156
    resultsPanel.add(numWarningsLabel, gridBagConstraints);
 
157
 
 
158
    numErrorsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 
159
    numErrorsLabel.setText("Num Errors:");
 
160
    numErrorsLabel.setMaximumSize(new java.awt.Dimension(73, 16));
 
161
    numErrorsLabel.setMinimumSize(new java.awt.Dimension(73, 16));
 
162
    numErrorsLabel.setPreferredSize(new java.awt.Dimension(73, 16));
 
163
    gridBagConstraints = new java.awt.GridBagConstraints();
 
164
    gridBagConstraints.gridx = 0;
 
165
    gridBagConstraints.gridy = 2;
 
166
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
167
    resultsPanel.add(numErrorsLabel, gridBagConstraints);
 
168
 
 
169
    elapsedTimeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 
170
    elapsedTimeLabel.setText("Elapsed Time:");
 
171
    gridBagConstraints = new java.awt.GridBagConstraints();
 
172
    gridBagConstraints.gridx = 0;
 
173
    gridBagConstraints.gridy = 3;
 
174
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
175
    resultsPanel.add(elapsedTimeLabel, gridBagConstraints);
 
176
 
 
177
    getContentPane().add(resultsPanel, java.awt.BorderLayout.CENTER);
 
178
 
 
179
  }// </editor-fold>//GEN-END:initComponents
 
180
 
 
181
  private void startButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_startButtonMousePressed
 
182
    statusLabel.setText("In Progress");
 
183
    this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
 
184
    startButton.setEnabled(false);
 
185
    cancelButton.setEnabled(false);
 
186
  }//GEN-LAST:event_startButtonMousePressed
 
187
 
 
188
  private void startButtonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_startButtonMouseReleased
 
189
    long numProcessed = 0;
 
190
    long numErrors = 0;
 
191
    long numWarnings = 0;
 
192
//    double elapsedTime = 0;
 
193
    
 
194
    try
 
195
    {
 
196
        jniFiomeths.JNIConvertFile();
 
197
        statusLabel.setText("Completed");
 
198
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
 
199
        numProcessed = jniFiomeths.JNIGetNumProcessed();
 
200
        numProcessedLabel.setVisible(true);
 
201
        numProcessedLabel.setText("Number of coordinates processed = " + numProcessed);
 
202
        
 
203
        numWarnings = jniFiomeths.JNIGetNumWarnings();
 
204
        numWarningsLabel.setVisible(true);
 
205
        numWarningsLabel.setText("Number of warnings = " + numWarnings);
 
206
 
 
207
        numErrors = jniFiomeths.JNIGetNumErrors();
 
208
        numErrorsLabel.setVisible(true);
 
209
        numErrorsLabel.setText("Number of errors = " + numErrors);
 
210
        
 
211
     /*   elapsedTime = jniFiomeths.JNIGetElapsedTime();
 
212
        elapsedTimeLabel.setVisible(true);
 
213
        elapsedTimeLabel.setText("Elapsed Time = " + elapsedTime + "s");*/
 
214
        
 
215
        okButton.setEnabled(true);
 
216
    }
 
217
    catch(GeotransError e)
 
218
    {
 
219
        new JNIStrtoval().displayErrorMsg(this, e.getMessage());
 
220
        jniFiomeths.JNICloseInputFile();
 
221
        jniFiomeths.JNICloseOutputFile();
 
222
    }        
 
223
  }//GEN-LAST:event_startButtonMouseReleased
 
224
 
 
225
  private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
 
226
    setVisible( false );
 
227
    dispose();      
 
228
  }//GEN-LAST:event_okButtonActionPerformed
 
229
 
 
230
  private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
 
231
    setVisible( false );
 
232
    jniFiomeths.JNICloseInputFile();
 
233
    jniFiomeths.JNICloseOutputFile();
 
234
    dispose();      
 
235
  }//GEN-LAST:event_cancelButtonActionPerformed
 
236
 
 
237
    /** Closes the dialog */
 
238
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
 
239
        setVisible (false);
 
240
        jniFiomeths.JNICloseInputFile();
 
241
        jniFiomeths.JNICloseOutputFile();
 
242
        dispose ();
 
243
    }//GEN-LAST:event_closeDialog
 
244
 
 
245
    /**
 
246
    * @param args the command line arguments
 
247
    */
 
248
    public static void main (String args[]) {
 
249
        JNIFiomeths jni_Fiomeths = new JNIFiomeths();
 
250
        new ProgressDlg (new javax.swing.JDialog (), true, jni_Fiomeths).show ();
 
251
    }
 
252
 
 
253
 
 
254
  // Variables declaration - do not modify//GEN-BEGIN:variables
 
255
  private javax.swing.JPanel buttonsPanel;
 
256
  private javax.swing.JButton cancelButton;
 
257
  private javax.swing.JLabel elapsedTimeLabel;
 
258
  private javax.swing.JLabel numErrorsLabel;
 
259
  private javax.swing.JLabel numProcessedLabel;
 
260
  private javax.swing.JLabel numWarningsLabel;
 
261
  private javax.swing.JButton okButton;
 
262
  private javax.swing.JPanel resultsPanel;
 
263
  private javax.swing.JButton startButton;
 
264
  private javax.swing.JLabel statusLabel;
 
265
  // End of variables declaration//GEN-END:variables
 
266
 
 
267
}