mock filetype manager if no application allows running lexer suites.
[fedora-idea.git] / platform-api / src / com / intellij / ui / TableCellState.java
blob4b02f75f0d91ba5b46d1ab50e056cd654675e16c
1 /*
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;
20 import javax.swing.*;
21 import javax.swing.border.Border;
22 import java.awt.*;
24 public class TableCellState {
25 private boolean mySelected;
26 private Color myForeground;
27 private Color myBackground;
28 private Font myFont;
29 private Border myCellBorder;
31 public void collectState(JTable table, boolean isSelected, boolean hasFocus, int row, int column) {
32 clear();
33 mySelected = isSelected;
34 myFont = table.getFont();
35 if (isSelected) {
36 myForeground = table.getSelectionForeground();
37 myBackground = table.getSelectionBackground();
39 else {
40 myForeground = table.getForeground();
41 myBackground = table.getBackground();
43 if (hasFocus) {
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() {
60 mySelected = false;
61 myForeground = null;
62 myBackground = null;
63 myFont = null;
64 myCellBorder = null;
67 public SimpleTextAttributes modifyAttributes(SimpleTextAttributes attributes) {
68 if (!mySelected) return attributes;
69 return new SimpleTextAttributes(attributes.getStyle(), myForeground);