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