1 package com.loribel.commons.abstraction;
2
3 import java.awt.*;
4
5 /***
6 * Abstraction of a long action stared by swing components.
7 * Method doBefore() and doAfter execute in the Swing Thread.
8 * Generaly we use other thread to do doAction().
9 * See {@link com.loribel.commons.gui.demo.gui.action.GB_LongActionUtils} to use this abstraction.
10 *
11 * @author Gregory Borelli
12 */
13 public interface GB_LongAction
14 {
15 /***
16 * This method must be called before doAction() in the Swing Thread.
17 * This metod must return true if action must be made.
18 * If this method returns false, action is canceled,
19 * and methods doAction() and doAfter() will not be called.
20 * @param a_parent the parent to use for Dalogs.
21 */
22 boolean doBefore(
23 Component a_parent);
24
25 /***
26 * The long action to execute.
27 * This method must be called into an otehr thread than the Swing thread.
28 * @return Object
29 */
30 Object doAction()
31 throws Exception;
32
33 /***
34 * This method must be called after method doAction() in the Swing thread.
35 * @param a_parent the parent to use for Dalogs.
36 * @param a_value Object value returned by doAction(). If error occured into doAction(), value is null.
37 */
38 void doAfter(
39 Component a_parent,
40 Object a_value);
41
42 /***
43 * Returns the name of action.
44 */
45
46 }