KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > command > CompoundCommand


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2006.
14
//
15
//All Rights Reserved.
16

17 package org.columba.core.command;
18
19 import java.util.List JavaDoc;
20 import java.util.Vector JavaDoc;
21
22 import org.columba.api.command.ICommand;
23 import org.columba.api.command.IWorkerStatusController;
24
25 /**
26  * Special type of {@link Command}which is used for a set of different
27  * commands.
28  *
29  * @author tstich, fdietz
30  */

31 public class CompoundCommand extends Command {
32     protected List JavaDoc<ICommand> commandList;
33
34     /**
35      * Constructor for CompoundCommand. Caution : Never use this command with
36      * Virtual Folders!
37      */

38     public CompoundCommand() {
39         super(null);
40         commandList = new Vector JavaDoc<ICommand>();
41
42         priority = Command.NORMAL_PRIORITY;
43         commandType = Command.NORMAL_OPERATION;
44     }
45
46     public void add(ICommand c) {
47         commandList.add(c);
48     }
49
50     /**
51      * @see org.columba.api.command.Command#execute(Worker)
52      * @param worker
53      * @throws Exception
54      */

55     @Override JavaDoc
56     public void execute(IWorkerStatusController worker) throws Exception JavaDoc {
57         for (ICommand _command : commandList) {
58             _command.execute(worker);
59         }
60     }
61
62     /**
63      * @see org.columba.api.command.Command#canBeProcessed()
64      * @return result
65      */

66     @Override JavaDoc
67     public boolean canBeProcessed() {
68         boolean result = true;
69         for (ICommand _command : commandList) {
70             result &= _command.canBeProcessed();
71         }
72
73         if (!result) {
74             releaseAllFolderLocks();
75         }
76         return result;
77     }
78
79     /**
80      * @see org.columba.api.command.Command#releaseAllFolderLocks()
81      */

82     @Override JavaDoc
83     public void releaseAllFolderLocks() {
84         for (ICommand _command : commandList) {
85             _command.releaseAllFolderLocks();
86         }
87     }
88
89     /**
90      *
91      * @throws Exception
92      * @see org.columba.api.command.Command#updateGUI()
93      */

94     @Override JavaDoc
95     public void updateGUI() throws Exception JavaDoc {
96         for (ICommand _command : commandList) {
97             _command.updateGUI();
98         }
99     }
100 }
Popular Tags