1 package com.opensymphony.workflow.designer.model; 2 3 import com.opensymphony.workflow.loader.ActionDescriptor; 4 import com.opensymphony.workflow.designer.ResourceManager; 5 6 11 public class ActionsTableModel extends ListTableModel 12 { 13 private String [] header = new String []{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 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 )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 )aValue).booleanValue()); 48 break; 49 } 50 } 51 52 public String getColumnName(int column) 53 { 54 return header[column]; 55 } 56 57 public Class getColumnClass(int columnIndex) 58 { 59 switch(columnIndex) 60 { 61 case 0: 62 return Integer .class; 63 case 1: 64 case 2: 65 return String .class; 66 case 3: 67 return Boolean .class; 68 default: 69 return String .class; 70 } 71 } 72 73 public Object getValueAt(int rowIndex, int columnIndex) 74 { 75 ActionDescriptor action = (ActionDescriptor)list.get(rowIndex); 76 switch(columnIndex) 77 { 78 case 0: 79 return new Integer (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 |