01: /*
02: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
03: * for visualizing and manipulating spatial features with geometry and attributes.
04: *
05: * Copyright (C) 2003 Vivid Solutions
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: *
21: * For more information, contact:
22: *
23: * Vivid Solutions
24: * Suite #1A
25: * 2328 Government Street
26: * Victoria BC V8T 5G5
27: * Canada
28: *
29: * (250)385-6040
30: * www.vividsolutions.com
31: */
32:
33: package com.vividsolutions.jump.workbench.plugin;
34:
35: import com.vividsolutions.jump.task.TaskMonitor;
36:
37: /**
38: * A long-running PlugIn that keeps the GUI responsive (but only partially so,
39: * as a modal progress dialog will be in the way).
40: * <P>
41: * First, #execute is called on the AWT event dispatch thread (the "GUI
42: * thread"). Here, the user can be prompted with a dialog.
43: * <P>
44: * Then, #run(TaskMonitor) is called, on a new thread. Here, a long operation
45: * can be performed. The TaskMonitor can be used to report progress (messages
46: * will appear on a modal progress dialog). Because the thread is not the GUI
47: * thread, the GUI will remain responsive.
48: * <P>
49: * Thus, to run a PlugIn on a separate thread with progress reporting:
50: * <UL>
51: * <LI>implement ThreadedPlugIn
52: * <LI>put any GUI prompting in #execute. If the user chooses to cancel,
53: * return false.
54: * <LI>put the time-consuming task in #run(TaskMonitor)
55: * <LI>add the ThreadedPlugIn using FeatureInstaller
56: * </UL>
57: */
58: public interface ThreadedPlugIn extends PlugIn {
59: /**
60: * Runs the task. This method will be executed in a separate thread, so that
61: * the GUI remains responsive (but only partially so, as a modal progress
62: * dialog will be in the way). Don't call GUI classes in this method as it is not
63: * executed on the GUI thread.
64: * @param monitor context to which this task can report its progress and
65: * check whether a party has requested its cancellation
66: */
67: public void run(TaskMonitor monitor, PlugInContext context)
68: throws Exception;
69: }
|