KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.opensymphony.workflow.designer.model;
2
3 import com.opensymphony.workflow.loader.ConditionDescriptor;
4 import com.opensymphony.workflow.loader.PaletteDescriptor;
5 import com.opensymphony.workflow.loader.ConfigConditionDescriptor;
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 ConditionsTableModel extends ListTableModel
15 {
16   private String JavaDoc[] header = new String JavaDoc[]{ResourceManager.getString("name"), ResourceManager.getString("type")};
17   private WorkflowGraphModel graphModel;
18   private int type;
19   public static final int JOIN = 1;
20   public static final int PERMISSION = 2;
21   public static final int RESULT = 3;
22
23   public int getType()
24   {
25     return type;
26   }
27
28   public void setType(int type)
29   {
30     this.type = type;
31   }
32
33   public WorkflowGraphModel getGraphModel()
34   {
35     return graphModel;
36   }
37
38   public void setGraphModel(WorkflowGraphModel graphModel)
39   {
40     this.graphModel = graphModel;
41   }
42
43   public boolean isCellEditable(int rowIndex, int columnIndex)
44   {
45     return false;
46   }
47
48   public int getColumnCount()
49   {
50     return header.length;
51   }
52
53   public String JavaDoc getColumnName(int column)
54   {
55     return header[column];
56   }
57
58   public Class JavaDoc getColumnClass(int columnIndex)
59   {
60     return String JavaDoc.class;
61   }
62
63   public Object JavaDoc getValueAt(int rowIndex, int columnIndex)
64   {
65     ConditionDescriptor condition = (ConditionDescriptor)list.get(rowIndex);
66     PaletteDescriptor palette = graphModel.getPalette();
67     switch(columnIndex)
68     {
69       case 0:
70         ConfigConditionDescriptor descriptor = null;
71         switch(type)
72         {
73           case JOIN:
74             descriptor = palette.getJoinCondition(condition.getName());
75             break;
76           case PERMISSION:
77             descriptor = palette.getPermissionCondition(condition.getName());
78             break;
79           case RESULT:
80             descriptor = palette.getResultCondition(condition.getName());
81             break;
82         }
83         return descriptor!=null && descriptor.getDisplayName()!=null ? descriptor.getDisplayName() : ResourceManager.getString("unknown");
84       case 1:
85         return condition.getType();
86     }
87     return null;
88   }
89 }
90
Popular Tags