27 |
27 |
*
|
28 |
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
29 |
29 |
* of the Valencian Government (CIT)
|
30 |
|
*
|
|
30 |
*
|
31 |
31 |
* This program is free software; you can redistribute it and/or
|
32 |
32 |
* modify it under the terms of the GNU General Public License
|
33 |
33 |
* as published by the Free Software Foundation; either version 2
|
34 |
34 |
* of the License, or (at your option) any later version.
|
35 |
|
*
|
|
35 |
*
|
36 |
36 |
* This program is distributed in the hope that it will be useful,
|
37 |
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
38 |
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
39 |
39 |
* GNU General Public License for more details.
|
40 |
|
*
|
|
40 |
*
|
41 |
41 |
* You should have received a copy of the GNU General Public License
|
42 |
42 |
* along with this program; if not, write to the Free Software
|
43 |
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
44 |
44 |
* MA 02110-1301, USA.
|
45 |
|
*
|
|
45 |
*
|
46 |
46 |
*/
|
47 |
47 |
|
48 |
48 |
import java.awt.event.WindowAdapter;
|
... | ... | |
82 |
82 |
private boolean askOnCancel = true;
|
83 |
83 |
private ArrayList<IncrementableListener> actionCommandListeners = new ArrayList<IncrementableListener>();
|
84 |
84 |
private boolean bDoCallListeners = true;
|
85 |
|
|
|
85 |
|
86 |
86 |
/**
|
87 |
87 |
* Constructor del IncrementableTask.
|
88 |
88 |
* @param incrementable
|
|
89 |
* @param dialog
|
89 |
90 |
*/
|
90 |
91 |
public IncrementableTask(IIncrementable incrementable, ProgressPanel dialog) {
|
91 |
92 |
iIncrementable = incrementable;
|
92 |
93 |
progressPanel = dialog;
|
93 |
94 |
configureProgressPanel();
|
94 |
95 |
}
|
95 |
|
|
|
96 |
|
96 |
97 |
/**
|
97 |
98 |
* Constructor del IncrementableTask.
|
98 |
99 |
* @param incrementable
|
... | ... | |
117 |
118 |
public void stop() {
|
118 |
119 |
ended = true;
|
119 |
120 |
}
|
120 |
|
|
|
121 |
|
121 |
122 |
/**
|
122 |
123 |
* Este thread va leyendo el porcentaje hasta que se completa el histograma.
|
123 |
124 |
*/
|
... | ... | |
137 |
138 |
} catch (InterruptedException e) {
|
138 |
139 |
}
|
139 |
140 |
}
|
140 |
|
|
|
141 |
|
141 |
142 |
// Forces to refresh the log with the last changes
|
142 |
143 |
getProgressPanel().setLog(iIncrementable.getLog());
|
143 |
144 |
}
|
... | ... | |
160 |
161 |
progressPanel = null;
|
161 |
162 |
blinker = null;
|
162 |
163 |
}
|
163 |
|
|
|
164 |
|
164 |
165 |
/**
|
165 |
166 |
* Ocultar la ventana
|
166 |
167 |
*/
|
... | ... | |
199 |
200 |
}
|
200 |
201 |
return progressPanel;
|
201 |
202 |
}
|
202 |
|
|
|
203 |
|
203 |
204 |
protected void configureProgressPanel() {
|
204 |
205 |
getProgressPanel().setAlwaysOnTop(true);
|
205 |
206 |
getProgressPanel().addButtonPressedListener(this);
|
206 |
|
|
|
207 |
|
207 |
208 |
// Must ask if user wants to cancel the process, avoid closing the dialog
|
208 |
209 |
getProgressPanel().setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE );
|
209 |
210 |
getProgressPanel().addWindowListener(new WindowAdapter() {
|
210 |
211 |
public void windowClosing(WindowEvent e) {
|
211 |
212 |
// Simulates an event like the produced pressing the cancel button of the associated progress panel
|
212 |
|
actionButtonPressed(new ButtonsPanelEvent(getProgressPanel(), IButtonsPanel.BUTTON_CANCEL));
|
|
213 |
actionButtonPressed(new ButtonsPanelEvent(getProgressPanel(), IButtonsPanel.BUTTON_CANCEL));
|
213 |
214 |
}
|
214 |
215 |
});
|
215 |
216 |
}
|
... | ... | |
286 |
287 |
JOptionPane.showMessageDialog(null, Messages.getText("Failed_pausing_the_process"), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE);
|
287 |
288 |
}
|
288 |
289 |
}
|
289 |
|
|
|
290 |
|
290 |
291 |
/* Asks user to cancel or not the process */
|
291 |
292 |
cancelled = false;
|
292 |
293 |
String string1 = Messages.getText("Yes");
|
... | ... | |
354 |
355 |
}
|
355 |
356 |
|
356 |
357 |
/**
|
|
358 |
* @return Buttons panel
|
357 |
359 |
* @see ProgressPanel#getButtonsPanel()
|
358 |
360 |
*/
|
359 |
361 |
public IButtonsPanel getButtonsPanel() {
|