01: package com.opensymphony.workflow.designer.model;
02:
03: import com.opensymphony.workflow.loader.AbstractDescriptor;
04: import com.opensymphony.workflow.loader.ConditionDescriptor;
05: import com.opensymphony.workflow.loader.ConditionsDescriptor;
06: import com.opensymphony.workflow.loader.PaletteDescriptor;
07: import com.opensymphony.workflow.loader.ConfigConditionDescriptor;
08: import com.opensymphony.workflow.designer.ResourceManager;
09: import com.opensymphony.workflow.designer.WorkflowGraphModel;
10:
11: /**
12: * @author Hani Suleiman (hani@formicary.net)
13: * Date: May 20, 2003
14: * Time: 11:04:16 AM
15: */
16: public class ConditionsTableModel extends ListTableModel {
17: private String[] header = new String[] {
18: ResourceManager.getString("name"),
19: ResourceManager.getString("type") };
20: private WorkflowGraphModel graphModel;
21: private int type;
22: public static final int JOIN = 1;
23: public static final int PERMISSION = 2;
24: public static final int RESULT = 3;
25:
26: public int getType() {
27: return type;
28: }
29:
30: public void setType(int type) {
31: this .type = type;
32: }
33:
34: public WorkflowGraphModel getGraphModel() {
35: return graphModel;
36: }
37:
38: public void setGraphModel(WorkflowGraphModel graphModel) {
39: this .graphModel = graphModel;
40: }
41:
42: public boolean isCellEditable(int rowIndex, int columnIndex) {
43: return false;
44: }
45:
46: public int getColumnCount() {
47: return header.length;
48: }
49:
50: public String getColumnName(int column) {
51: return header[column];
52: }
53:
54: public Class getColumnClass(int columnIndex) {
55: return String.class;
56: }
57:
58: public Object getValueAt(int rowIndex, int columnIndex) {
59: AbstractDescriptor dd = (AbstractDescriptor) list.get(rowIndex);
60: if (dd instanceof ConditionsDescriptor)
61: return null;
62:
63: ConditionDescriptor condition = (ConditionDescriptor) list
64: .get(rowIndex);
65: PaletteDescriptor palette = graphModel.getPalette();
66: switch (columnIndex) {
67: case 0:
68: ConfigConditionDescriptor descriptor = null;
69: switch (type) {
70: case JOIN:
71: descriptor = palette.getJoinCondition(condition
72: .getName());
73: break;
74: case PERMISSION:
75: descriptor = palette.getPermissionCondition(condition
76: .getName());
77: break;
78: case RESULT:
79: descriptor = palette.getResultCondition(condition
80: .getName());
81: break;
82: }
83: return descriptor != null
84: && descriptor.getDisplayName() != null ? descriptor
85: .getDisplayName() : ResourceManager
86: .getString("unknown");
87: case 1:
88: return condition.getType();
89: }
90: return null;
91: }
92: }
|