01: /*
02: * Created on Sep 29, 2004
03: *
04: * @author ctaylor
05: *
06: */
07: package com.pk.script.ui;
08:
09: import java.util.List;
10:
11: import javax.swing.table.AbstractTableModel;
12:
13: import com.pk.script.ScriptCommand;
14:
15: /**
16: * @author ctaylor
17: *
18: */
19: public class CommandTableModel extends AbstractTableModel {
20:
21: /**
22: *
23: */
24: private static final long serialVersionUID = 9135226937966427291L;
25: private String columnNames[] = { "Command", "Status", "Run" };
26: private CommandTablePanel commandTablePanel;
27:
28: /**
29: *
30: */
31: public CommandTableModel(CommandTablePanel argCommandTablePanel) {
32: super ();
33: commandTablePanel = argCommandTablePanel;
34: }
35:
36: /* (non-Javadoc)
37: * @see javax.swing.table.TableModel#getColumnCount()
38: */
39: public int getColumnCount() {
40: return columnNames.length;
41: }
42:
43: /* (non-Javadoc)
44: * @see javax.swing.table.TableModel#getRowCount()
45: */
46: public int getRowCount() {
47: if (getCommands() != null) {
48: return getCommands().size();
49: }
50: return 0;
51: }
52:
53: /* (non-Javadoc)
54: * @see javax.swing.table.TableModel#getValueAt(int, int)
55: */
56: public Object getValueAt(int row, int column) {
57: ScriptCommand scriptCommand = (ScriptCommand) getCommands()
58: .get(row);
59: if (column == 0) {
60: return scriptCommand.getDisplayCommand();
61: } else if (column == 1) {
62: return scriptCommand.getStatus();
63: } else {
64: if (scriptCommand.isRun())
65: return "Yes";
66: return "No";
67: }
68: }
69:
70: /* (non-Javadoc)
71: * @see javax.swing.table.TableModel#getColumnName(int)
72: */
73: public String getColumnName(int arg0) {
74: return columnNames[arg0];
75: }
76:
77: /**
78: * @return Returns the commands.
79: */
80: public List getCommands() {
81: return commandTablePanel.getCommands();
82: }
83: }
|