update copyright
[fedora-idea.git] / plugins / cvs / cvs-plugin / src / com / intellij / cvsSupport2 / ui / AbstractListCellRenderer.java
blob458deffd2af01d7f0f11ce500fc5ee5bd94ec5c7
1 /*
2 * Copyright 2000-2009 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.cvsSupport2.ui;
18 import org.jetbrains.annotations.Nullable;
20 import javax.swing.*;
21 import java.awt.*;
23 /**
24 * author: lesya
26 public abstract class AbstractListCellRenderer extends DefaultListCellRenderer {
27 protected abstract String getPresentableString(Object value);
28 @Nullable
29 protected Icon getPresentableIcon(Object value){
30 return null;
33 public Component getListCellRendererComponent(
34 JList list,
35 Object value,
36 int index,
37 boolean isSelected,
38 boolean cellHasFocus) {
40 Component result = super.getListCellRendererComponent(list, getPresentableString(value), index, isSelected, cellHasFocus);
42 Icon icon = getPresentableIcon(value);
43 if (icon != null)
44 setIcon(icon);
46 return result;