root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / gui / command / MyModel.java @ 24962
History | View | Annotate | Download (857 Bytes)
1 |
package com.iver.cit.gvsig.gui.command; |
---|---|
2 |
|
3 |
import javax.swing.table.AbstractTableModel; |
4 |
|
5 |
import org.gvsig.tools.undo.command.Command; |
6 |
|
7 |
|
8 |
public class MyModel extends AbstractTableModel{ |
9 |
private CommandsRecord cr;
|
10 |
|
11 |
public MyModel(CommandsRecord cr) {
|
12 |
this.cr=cr;
|
13 |
} |
14 |
public int getPos() { |
15 |
return cr.getPointer();
|
16 |
} |
17 |
public int getColumnCount() { |
18 |
return 1; |
19 |
} |
20 |
public int getRowCount() { |
21 |
return cr.size();
|
22 |
} |
23 |
public Object getValueAt(int i, int j) { |
24 |
Command[] undos=(Command[])cr.getUndoCommands().toArray(new Command[0]); |
25 |
Command[] redos=(Command[])cr.getRedoCommands().toArray(new Command[0]); |
26 |
if (i<undos.length){
|
27 |
//System.out.println("undo i=" + i + " index=" + (undos.length-1-i));
|
28 |
return undos[undos.length-1-i]; |
29 |
}else{
|
30 |
//System.out.println("redo i=" + i + " index=" + (i-undos.length));
|
31 |
return redos[i-undos.length];
|
32 |
} |
33 |
} |
34 |
} |