01: package org.osbl.riskmanagement.gui.report;
02:
03: import org.wings.*;
04: import org.wings.session.SessionManager;
05: import org.wings.event.SMouseListener;
06: import org.wings.event.SMouseEvent;
07: import org.wings.table.SDefaultTableCellRenderer;
08: import org.wingx.XTreeTable;
09: import org.wingx.treetable.*;
10: import org.osbl.riskmanagement.gui.RiskManagementIcons;
11: import org.osbl.client.action.ActionProvider;
12: import org.osbl.client.wings.shell.Client;
13: import org.osbl.client.wings.action.ShowEditorAction;
14:
15: import java.util.Map;
16: import java.util.HashMap;
17:
18: public class RiskTreeTable extends SScrollPane {
19: RiskTreeTableModel treeTableModel;
20: XTreeTable treeTable;
21:
22: public RiskTreeTable() {
23: treeTableModel = new RiskTreeTableModel();
24: treeTable = new XTreeTable(treeTableModel);
25: treeTable.getColumnModel().getColumn(0).setCellRenderer(
26: new TreeColumnRenderer() {
27: public SComponent getTableCellRendererComponent(
28: STable table, Object value,
29: boolean selected, final int row,
30: final int col) {
31: SComponent component = super
32: .getTableCellRendererComponent(table,
33: value, selected, row, col);
34: if (treeTableModel.getNodeModel().get(row) instanceof RiskTreeTableNode) {
35: if (!(component.getStyle()
36: .indexOf(" link ") > 0)) {
37: component.setStyle(getStyle()
38: + " link ");
39: }
40: } else if (component.getStyle() != null) {
41: component.setStyle(component.getStyle()
42: .replaceAll(" link ", " "));
43: }
44: return component;
45: }
46: });
47: treeTable.getColumnModel().getColumn(5).setCellRenderer(
48: new SDefaultTableCellRenderer() {
49: public SComponent getTableCellRendererComponent(
50: STable table, Object value,
51: boolean selected, int row, int col) {
52: return super
53: .getTableCellRendererComponent(table,
54: RiskManagementIcons.ICONS
55: .get(value), selected,
56: row, col);
57: }
58: });
59: treeTable.addMouseListener(new SMouseListener() {
60: public void mouseClicked(SMouseEvent e) {
61: int row = treeTable.rowAtPoint(e.getPoint());
62: int col = treeTable.columnAtPoint(e.getPoint());
63: XTreeTableNode node = (XTreeTableNode) treeTableModel
64: .getNodeModel().get(row);
65: if (col == 0 && node instanceof RiskTreeTableNode) {
66: RiskTreeTableNode riskTreeTableNode = (RiskTreeTableNode) node;
67:
68: final ActionProvider sessionActionProvider = Client
69: .getInstance().getActionProvider();
70: ShowEditorAction action = (ShowEditorAction) sessionActionProvider
71: .getAction("org.concern.actions.subjects");
72: if (action != null && action.isEnabled()) {
73: Map query = new HashMap();
74: query.put("process", "RiskManagement");
75: query
76: .put("subject", ""
77: + riskTreeTableNode.getObject()
78: .getId());
79: query.put("locale", ""
80: + SessionManager.getSession()
81: .getLocale().toString());
82: action.navigate(query);
83: }
84: e.consume();
85: }
86: }
87: });
88: setViewportView(treeTable);
89: setPreferredSize(SDimension.FULLAREA);
90: setMode(SScrollPane.MODE_COMPLETE);
91: }
92: }
|