01: /*
02: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
03: *
04: * http://izpack.org/
05: * http://izpack.codehaus.org/
06: *
07: * Copyright 2007 Dennis Reil
08: *
09: * Licensed under the Apache License, Version 2.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.apache.org/licenses/LICENSE-2.0
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: */
21:
22: package com.izforge.izpack.installer;
23:
24: import java.awt.Color;
25: import java.awt.Component;
26: import java.util.Iterator;
27: import java.util.Map;
28:
29: import javax.swing.JComponent;
30: import javax.swing.JLabel;
31: import javax.swing.JTable;
32: import javax.swing.table.DefaultTableCellRenderer;
33:
34: /**
35: * @author Dennis Reil, <Dennis.Reil@reddot.de>
36: * @version $Id: $
37: */
38: public class ConditionHistoryTableCellRenderer extends
39: DefaultTableCellRenderer {
40: private static final long serialVersionUID = 6779914244548965230L;
41: private Map<String, ConditionHistory> conditionhistory;
42:
43: public ConditionHistoryTableCellRenderer(
44: Map<String, ConditionHistory> conditionhistory) {
45: this .conditionhistory = conditionhistory;
46: }
47:
48: /* (non-Javadoc)
49: * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
50: */
51: public Component getTableCellRendererComponent(JTable table,
52: Object value, boolean isSelected, boolean hasFocus,
53: int row, int column) {
54: JComponent comp = null;
55:
56: ConditionHistory ch = (ConditionHistory) value;
57:
58: JLabel label = new JLabel();
59: label.setAutoscrolls(true);
60: comp = label;
61:
62: label.setText(ch.toString());
63:
64: comp.setOpaque(true);
65: if (ch.isNewcondition()) {
66: comp.setBackground(Color.green);
67: } else if (ch.isChangedcondition()) {
68: comp.setBackground(Color.yellow);
69: }
70: return comp;
71: }
72:
73: public void clearState() {
74: for (String s : conditionhistory.keySet()) {
75: ConditionHistory ch = conditionhistory.get(s);
76: ch.clearState();
77: }
78: }
79: }
|