01: package salomeTMF_plug.requirements.ihm;
02:
03: import java.awt.Color;
04: import java.awt.Component;
05: import java.util.Vector;
06:
07: import javax.swing.JTable;
08: import javax.swing.table.DefaultTableCellRenderer;
09: import javax.swing.table.TableColumn;
10:
11: import salomeTMF_plug.requirements.data.ReqFilter;
12: import salomeTMF_plug.requirements.data.ReqLeaf;
13: import salomeTMF_plug.requirements.sqlWrapper.ReqWrapper;
14:
15: public class PriorityTableCellRenderer extends DefaultTableCellRenderer {
16: Vector reqCovered;
17:
18: public PriorityTableCellRenderer(Vector _reqCovered) {
19: reqCovered = _reqCovered;
20: }
21:
22: public Component getTableCellRendererComponent(JTable table,
23: Object value, boolean isSelected, boolean hasFocus,
24: int row, int column) {
25:
26: super .getTableCellRendererComponent(table, value, isSelected,
27: hasFocus, row, column);
28:
29: try {
30:
31: Object objReq = reqCovered.elementAt(row);
32: int priority = 0;
33: if (objReq instanceof ReqLeaf) {
34: priority = ((ReqLeaf) objReq).getPriorityFromModel();
35: } else if (objReq instanceof ReqWrapper) {
36: priority = ((ReqWrapper) objReq).getPriority();
37: }
38:
39: if (priority == ReqFilter.P_HIGHT) {
40: setForeground(Color.red);
41: } else if (priority == ReqFilter.P_MEDIUM) {
42: setForeground(Color.blue);
43: } else if (priority == ReqFilter.P_LOW) {
44: setForeground(Color.black);
45: } else if (priority == ReqFilter.P_NONE) {
46: setForeground(Color.gray);
47: }
48: /*
49: TableColumn pcolumn = null;
50: pcolumn = table.getColumnModel().getColumn(0);
51: pcolumn.setPreferredWidth(2);
52: pcolumn = table.getColumnModel().getColumn(1);
53: pcolumn.setPreferredWidth(2);
54: pcolumn = table.getColumnModel().getColumn(2);
55: pcolumn.setPreferredWidth(5);
56: pcolumn = table.getColumnModel().getColumn(3);
57: pcolumn.setPreferredWidth(5);
58: pcolumn = table.getColumnModel().getColumn(4);
59: pcolumn.setPreferredWidth(5);
60: */
61:
62: } catch (Exception e) {
63:
64: }
65: return this;
66: }
67: }
|