Revision 4338
trunk/frameworks/_fwAndami/src/com/iver/andami/PluginServices.java | ||
---|---|---|
50 | 50 |
import java.util.PropertyResourceBundle; |
51 | 51 |
import java.util.ResourceBundle; |
52 | 52 |
|
53 |
import javax.swing.ProgressMonitor; |
|
53 | 54 |
import javax.swing.SwingUtilities; |
55 |
import javax.swing.Timer; |
|
54 | 56 |
|
55 | 57 |
import org.apache.log4j.Logger; |
56 | 58 |
|
... | ... | |
63 | 65 |
import com.iver.andami.ui.mdiFrame.MainFrame; |
64 | 66 |
import com.iver.andami.ui.mdiManager.MDIManager; |
65 | 67 |
import com.iver.utiles.XMLEntity; |
68 |
import com.iver.utiles.swing.threads.MonitorableTask; |
|
69 |
import com.iver.utiles.swing.threads.TaskMonitorTimerListener; |
|
66 | 70 |
|
67 | 71 |
|
68 | 72 |
/** |
... | ... | |
335 | 339 |
|
336 | 340 |
return t; |
337 | 341 |
} |
342 |
|
|
343 |
public static void cancelableBackgroundExecution(final MonitorableTask task){ |
|
344 |
final com.iver.utiles.swing.threads.SwingWorker worker = new com.iver.utiles.swing.threads.SwingWorker() { |
|
345 |
public Object construct() { |
|
346 |
try { |
|
347 |
task.run(); |
|
348 |
return task; |
|
349 |
} catch (Exception e) { |
|
350 |
NotificationManager.addError(null, e); |
|
351 |
} |
|
352 |
return null; |
|
353 |
} |
|
354 |
}; |
|
355 |
|
|
356 |
Component mainFrame = (Component)PluginServices.getMainFrame(); |
|
357 |
ProgressMonitor progressMonitor = new ProgressMonitor(mainFrame, |
|
358 |
task.getStatusMessage(), |
|
359 |
task.getNote(), |
|
360 |
task.getInitialStep(), |
|
361 |
task.getFinishStep()); |
|
362 |
progressMonitor.setProgress(0); |
|
363 |
int delay = 500; |
|
364 |
progressMonitor.setMillisToDecideToPopup(delay); |
|
365 |
TaskMonitorTimerListener timerListener = |
|
366 |
new TaskMonitorTimerListener(progressMonitor, task); |
|
367 |
Timer timer = new Timer(delay, timerListener); |
|
368 |
timerListener.setTimer(timer); |
|
369 |
worker.start(); |
|
370 |
timer.start(); |
|
371 |
} |
|
338 | 372 |
|
339 | 373 |
public static void closeApplication(){ |
340 | 374 |
Launcher.closeApplication(); |
Also available in: Unified diff