2 * Copyright 2000-2007 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.ui
;
18 import com
.intellij
.util
.ui
.UIUtil
;
21 import javax
.swing
.border
.Border
;
24 public class TableCellState
{
25 private boolean mySelected
;
26 private Color myForeground
;
27 private Color myBackground
;
29 private Border myCellBorder
;
31 public void collectState(JTable table
, boolean isSelected
, boolean hasFocus
, int row
, int column
) {
33 mySelected
= isSelected
;
34 myFont
= table
.getFont();
36 myForeground
= table
.getSelectionForeground();
37 myBackground
= table
.getSelectionBackground();
40 myForeground
= table
.getForeground();
41 myBackground
= table
.getBackground();
44 myCellBorder
= UIUtil
.getTableFocusCellHighlightBorder();
45 if (table
.isCellEditable(row
, column
)) {
46 myForeground
= UIUtil
.getTableFocusCellForeground();
47 myBackground
= UIUtil
.getTableFocusCellBackground();
52 public void updateRenderer(JComponent renderer
) {
53 renderer
.setForeground(myForeground
);
54 renderer
.setBackground(myBackground
);
55 renderer
.setFont(myFont
);
56 renderer
.setBorder(myCellBorder
);
59 protected void clear() {
67 public SimpleTextAttributes
modifyAttributes(SimpleTextAttributes attributes
) {
68 if (!mySelected
) return attributes
;
69 return new SimpleTextAttributes(attributes
.getStyle(), myForeground
);