KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > designer > model > ActionsTableModel


1 package com.opensymphony.workflow.designer.model;
2
3 import com.opensymphony.workflow.loader.ActionDescriptor;
4 import com.opensymphony.workflow.designer.ResourceManager;
5
6 /**
7  * @author Hani Suleiman (hani@formicary.net)
8  * Date: May 20, 2003
9  * Time: 11:04:16 AM
10  */

11 public class ActionsTableModel extends ListTableModel
12 {
13   private String JavaDoc[] header = new String JavaDoc[]{ResourceManager.getString("id"), ResourceManager.getString("name"),
14                                          ResourceManager.getString("view"), ResourceManager.getString("auto")};
15
16   public ActionsTableModel()
17   {
18   }
19
20   public boolean isCellEditable(int rowIndex, int columnIndex)
21   {
22     return columnIndex!=0;
23   }
24
25   public int getColumnCount()
26   {
27     return header.length;
28   }
29
30   public void setValueAt(Object JavaDoc aValue, int rowIndex, int columnIndex)
31   {
32     ActionDescriptor action = (ActionDescriptor)list.get(rowIndex);
33     switch(columnIndex)
34     {
35       case 0:
36         if(aValue!=null)
37         action.setId(((Integer JavaDoc)aValue).intValue());
38         break;
39       case 1:
40         if(aValue!=null)
41           action.setName(aValue.toString());
42         break;
43       case 2:
44         action.setView(aValue!=null ? aValue.toString() : null);
45         break;
46       case 3:
47         action.setAutoExecute(((Boolean JavaDoc)aValue).booleanValue());
48         break;
49     }
50   }
51
52   public String JavaDoc getColumnName(int column)
53   {
54     return header[column];
55   }
56
57   public Class JavaDoc getColumnClass(int columnIndex)
58   {
59     switch(columnIndex)
60     {
61       case 0:
62         return Integer JavaDoc.class;
63       case 1:
64       case 2:
65         return String JavaDoc.class;
66       case 3:
67         return Boolean JavaDoc.class;
68       default:
69         return String JavaDoc.class;
70     }
71   }
72
73   public Object JavaDoc getValueAt(int rowIndex, int columnIndex)
74   {
75     ActionDescriptor action = (ActionDescriptor)list.get(rowIndex);
76     switch(columnIndex)
77     {
78       case 0:
79         return new Integer JavaDoc(action.getId());
80       case 1:
81         return action.getName();
82       case 2:
83         return action.getView()!=null ? action.getView() : "";
84       case 3:
85         return action.getAutoExecute() ? Boolean.TRUE : Boolean.FALSE;
86       default:
87         return "";
88     }
89   }
90 }
91
Popular Tags