samer@0
|
1 /*
|
samer@0
|
2 * Agent.java
|
samer@0
|
3 *
|
samer@0
|
4 * Copyright (c) 2000, Samer Abdallah, King's College London.
|
samer@0
|
5 * All rights reserved.
|
samer@0
|
6 *
|
samer@0
|
7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
|
samer@0
|
8 * without even the implied warranty of MERCHANTABILITY or
|
samer@0
|
9 * FITNESS FOR A PARTICULAR PURPOSE.
|
samer@0
|
10 */
|
samer@0
|
11
|
samer@0
|
12 package samer.core;
|
samer@0
|
13
|
samer@0
|
14 /**
|
samer@0
|
15 An Agent is something that can handle commands.
|
samer@0
|
16 It can also optionally report which commands it
|
samer@0
|
17 can handle so that they can be exposed in some
|
samer@0
|
18 way, eg buttons or a menu.
|
samer@0
|
19 */
|
samer@0
|
20
|
samer@0
|
21 public interface Agent
|
samer@0
|
22 {
|
samer@0
|
23 /**
|
samer@0
|
24 Bad interface name, I know, but a Registry is
|
samer@0
|
25 supplied to an agent so that it can report
|
samer@0
|
26 which commands it handles. The implementation
|
samer@0
|
27 of the Registry can do whatever it likes with
|
samer@0
|
28 the names: compile a list, create buttons or a
|
samer@0
|
29 menu, or just ignore them.
|
samer@0
|
30
|
samer@0
|
31 <p>May eventually want to be able to supply
|
samer@0
|
32 more information abdut a command, so that we
|
samer@0
|
33 can, eg, put an icon on a toolbar or have a
|
samer@0
|
34 tool tip
|
samer@0
|
35 */
|
samer@0
|
36
|
samer@0
|
37 public interface Registry {
|
samer@0
|
38 Registry add( String name);
|
samer@0
|
39
|
samer@0
|
40 /**
|
samer@0
|
41 The second form of add, with a boolean
|
samer@0
|
42 second argument suggests that the command expects
|
samer@0
|
43 a boolean argument and can thus be associated
|
samer@0
|
44 with a checkbox or check menu item.
|
samer@0
|
45 */
|
samer@0
|
46
|
samer@0
|
47 Registry add( String name, boolean initialValue);
|
samer@0
|
48
|
samer@0
|
49 /**
|
samer@0
|
50 This means that the following commands reported
|
samer@0
|
51 to add() are to be directed to a different Agent
|
samer@0
|
52 */
|
samer@0
|
53
|
samer@0
|
54 void setTarget(Agent a);
|
samer@0
|
55
|
samer@0
|
56 /** this means start a new group */
|
samer@0
|
57 void group();
|
samer@0
|
58 }
|
samer@0
|
59
|
samer@0
|
60 /** Implementations can use the Registry to report which
|
samer@0
|
61 commands they respond to */
|
samer@0
|
62 void getCommands(Registry r);
|
samer@0
|
63
|
samer@0
|
64 /** This must do what the named command says using the given Environment
|
samer@0
|
65 for parameters or supplimentary data. */
|
samer@0
|
66 void execute( String name, Environment env) throws Exception;
|
samer@0
|
67 }
|