01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.source.Query;
04: import jimm.util.I18N;
05: import java.util.Collection;
06: import java.util.ArrayList;
07: import java.util.Iterator;
08:
09: /**
10: * A command for changing a field's table join.
11: *
12: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
13: */
14: public class TableJoinCommand extends CommandAdapter {
15:
16: protected Query query;
17: protected Collection newJoins;
18: protected Collection origJoins;
19:
20: public TableJoinCommand(Query query, Collection joins) {
21: super (I18N.get("TableJoinCommand.name"));
22: this .query = query;
23:
24: origJoins = new ArrayList();
25: for (Iterator iter = query.joins(); iter.hasNext();)
26: origJoins.add(iter.next());
27:
28: newJoins = joins;
29: }
30:
31: public void perform() {
32: query.clearJoins();
33: query.addAllJoins(newJoins);
34: }
35:
36: public void undo() {
37: query.clearJoins();
38: query.addAllJoins(origJoins);
39: }
40:
41: }
|