KickJava   Java API By Example, From Geeks To Geeks.

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


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

14 public class FunctionsTableModel extends ListTableModel
15 {
16   private String JavaDoc[] header = new String JavaDoc[]{ResourceManager.getString("name"), ResourceManager.getString("type")};
17   private WorkflowGraphModel graphModel;
18
19   public WorkflowGraphModel getGraphModel()
20   {
21     return graphModel;
22   }
23
24   public void setGraphModel(WorkflowGraphModel graphModel)
25   {
26     this.graphModel = graphModel;
27   }
28
29   public boolean isCellEditable(int rowIndex, int columnIndex)
30   {
31     return false;
32   }
33
34   public void setValueAt(Object JavaDoc aValue, int rowIndex, int columnIndex)
35   {
36     FunctionDescriptor function = (FunctionDescriptor)list.get(rowIndex);
37     switch(columnIndex)
38     {
39       case 0:
40         if(aValue != null)
41           function.setName(aValue.toString());
42         break;
43       case 1:
44         if(aValue != null)
45           function.setType(aValue.toString());
46         break;
47     }
48   }
49
50   public int getColumnCount()
51   {
52     return header.length;
53   }
54
55   public String JavaDoc getColumnName(int column)
56   {
57     return header[column];
58   }
59
60   public Class JavaDoc getColumnClass(int columnIndex)
61   {
62     return String JavaDoc.class;
63   }
64
65   public Object JavaDoc getValueAt(int rowIndex, int columnIndex)
66   {
67     FunctionDescriptor function = (FunctionDescriptor)list.get(rowIndex);
68     PaletteDescriptor palette = graphModel.getPalette();
69     ConfigFunctionDescriptor config = palette.getPrefunction(function.getName());
70     switch(columnIndex)
71     {
72       case 0:
73         String JavaDoc name = config!=null && config.getDisplayName()!=null ? config.getDisplayName() : ResourceManager.getString("unknown");
74         return name;
75       case 1:
76         return function.getType();
77       default:
78         return "";
79     }
80   }
81 }
82
Popular Tags