svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / data / commands / CommandCollection.java @ 21296
History | View | Annotate | Download (1.22 KB)
1 |
package org.gvsig.data.commands; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
public class CommandCollection extends AbstractCommand{ |
6 |
ArrayList commands=new ArrayList(); |
7 |
public boolean isEmpty() { |
8 |
return commands.size()==0; |
9 |
} |
10 |
/**
|
11 |
* @throws EditionCommandException
|
12 |
* @see com.iver.cit.gvsig.fmap.edition.Command#undo()
|
13 |
*/
|
14 |
public void undo() { |
15 |
for(int i=commands.size()-1;i>=0;i--){ |
16 |
((Command)commands.get(i)).undo(); |
17 |
} |
18 |
} |
19 |
|
20 |
/**
|
21 |
* @throws EditionCommandException
|
22 |
* @see com.iver.cit.gvsig.fmap.edition.Command#redo()
|
23 |
*/
|
24 |
public void redo() { |
25 |
for (int i=0;i<commands.size();i++){ |
26 |
((Command)commands.get(i)).redo(); |
27 |
} |
28 |
} |
29 |
public void add(Command c){ |
30 |
commands.add(c); |
31 |
} |
32 |
|
33 |
public String getType() { |
34 |
if (commands.size() == 0) |
35 |
return null; |
36 |
ArrayList types=new ArrayList(3); |
37 |
for (int i=0;i<commands.size();i++) { |
38 |
String type=((Command)commands.get(i)).getType();
|
39 |
if (!types.contains(type))
|
40 |
types.add(type); |
41 |
} |
42 |
String type=""; |
43 |
type=(String)types.get(0); |
44 |
for (int i=1;i<types.size();i++) { |
45 |
type=type+"-"+(String)types.get(i); |
46 |
} |
47 |
return type;
|
48 |
} |
49 |
public void execute() { |
50 |
for (int i=0;i<commands.size();i++){ |
51 |
((Command)commands.get(i)).execute(); |
52 |
} |
53 |
} |
54 |
} |