Revision 721 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/undo/command/impl/CompoundCommand.java
CompoundCommand.java | ||
---|---|---|
39 | 39 |
if (isEmpty()) { |
40 | 40 |
return UPDATE; |
41 | 41 |
} else { |
42 |
return ((Command) commands.get(0)).getType(); |
|
42 |
int adds = getCount(INSERT); |
|
43 |
int dels = getCount(DELETE); |
|
44 |
if (adds > 0 && dels == 0) { |
|
45 |
return INSERT; |
|
46 |
} else { |
|
47 |
if (adds == 0 && dels > 0) { |
|
48 |
return DELETE; |
|
49 |
} else { |
|
50 |
/* |
|
51 |
* mix or other thing |
|
52 |
*/ |
|
53 |
return UPDATE; |
|
54 |
} |
|
55 |
} |
|
43 | 56 |
} |
44 | 57 |
} |
58 |
|
|
59 |
/** |
|
60 |
* count commands of given type |
|
61 |
* |
|
62 |
* @param insert |
|
63 |
* @return |
|
64 |
*/ |
|
65 |
private int getCount(int ty) { |
|
66 |
if (commands == null || commands.size() == 0) { |
|
67 |
return 0; |
|
68 |
} else { |
|
69 |
int resp = 0; |
|
70 |
for (int i=0; i<commands.size(); i++) { |
|
71 |
if (((Command) commands.get(i)).getType() == ty) { |
|
72 |
resp++; |
|
73 |
} |
|
74 |
} |
|
75 |
return resp; |
|
76 |
} |
|
77 |
} |
|
45 | 78 |
} |
Also available in: Unified diff