01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.ui;
16:
17: import org.eclipse.core.runtime.IProgressMonitor;
18: import org.eclipse.ui.IWorkbench;
19:
20: /**
21: * Encapsulates a task that needs to be run at shutdown but before the workbench has been shutdown.
22: * It can be submitted to the {@link ShutdownTaskList}.
23: * Methods are NOT called in the Display thread.
24: *
25: * @author Jesse
26: * @since 1.1.0
27: */
28: public interface PreShutdownTask {
29:
30: /**
31: * Called before shutdown is complete. if !forced then the shutdown can be cancelled if false is returned.
32: *
33: * @param monitor monitor for showing progress of task. The beginTask method will set the task name but the number of steps is ignored.
34: * @param workbench workbench that is shutting down
35: * @param forced if the shutdown is forced. If it is forced then shutdown cannot be cancelled
36: * @return true if shutdown is permitted or false if not. ignored if forced==true.
37: * @throws Exception if an exception is thrown it will be passed to {@link #handlePreShutdownException(Throwable, boolean)}
38: */
39: boolean preShutdown(IProgressMonitor monitor, IWorkbench workbench,
40: boolean forced) throws Exception;
41:
42: /**
43: * called if {@link #preShutdown(IProgressMonitor, IWorkbench, boolean)} throws an exception.
44: *
45: * @param t the exception.
46: * @param forced if the shutdown is forced. If it is forced then shutdown cannot be cancelled
47: * @return true if shutdown is permitted or false if not. ignored if forced==true.
48: */
49: boolean handlePreShutdownException(Throwable t, boolean forced);
50:
51: /**
52: * Returns the number of steps {@link #preShutdown(IProgressMonitor, IWorkbench, boolean)} will use.
53: * This is called only once just before all shutdown tasks are run.
54: *
55: * @return the number of steps {@link #preShutdown(IProgressMonitor, IWorkbench, boolean)} will use.
56: */
57: int getProgressMonitorSteps();
58:
59: }
|