001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2006.
014: //
015: //All Rights Reserved.
016:
017: package org.columba.core.command;
018:
019: import java.util.List;
020: import java.util.Vector;
021:
022: import org.columba.api.command.ICommand;
023: import org.columba.api.command.IWorkerStatusController;
024:
025: /**
026: * Special type of {@link Command}which is used for a set of different
027: * commands.
028: *
029: * @author tstich, fdietz
030: */
031: public class CompoundCommand extends Command {
032: protected List<ICommand> commandList;
033:
034: /**
035: * Constructor for CompoundCommand. Caution : Never use this command with
036: * Virtual Folders!
037: */
038: public CompoundCommand() {
039: super (null);
040: commandList = new Vector<ICommand>();
041:
042: priority = Command.NORMAL_PRIORITY;
043: commandType = Command.NORMAL_OPERATION;
044: }
045:
046: public void add(ICommand c) {
047: commandList.add(c);
048: }
049:
050: /**
051: * @see org.columba.api.command.Command#execute(Worker)
052: * @param worker
053: * @throws Exception
054: */
055: @Override
056: public void execute(IWorkerStatusController worker)
057: throws Exception {
058: for (ICommand _command : commandList) {
059: _command.execute(worker);
060: }
061: }
062:
063: /**
064: * @see org.columba.api.command.Command#canBeProcessed()
065: * @return result
066: */
067: @Override
068: public boolean canBeProcessed() {
069: boolean result = true;
070: for (ICommand _command : commandList) {
071: result &= _command.canBeProcessed();
072: }
073:
074: if (!result) {
075: releaseAllFolderLocks();
076: }
077: return result;
078: }
079:
080: /**
081: * @see org.columba.api.command.Command#releaseAllFolderLocks()
082: */
083: @Override
084: public void releaseAllFolderLocks() {
085: for (ICommand _command : commandList) {
086: _command.releaseAllFolderLocks();
087: }
088: }
089:
090: /**
091: *
092: * @throws Exception
093: * @see org.columba.api.command.Command#updateGUI()
094: */
095: @Override
096: public void updateGUI() throws Exception {
097: for (ICommand _command : commandList) {
098: _command.updateGUI();
099: }
100: }
101: }
|