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.
18 * Created by IntelliJ IDEA.
22 * To change template for new class use
23 * Code Style | Class Templates options (Tools | IDE Options).
25 package com
.intellij
.refactoring
.ui
;
27 import com
.intellij
.openapi
.util
.Iconable
;
28 import com
.intellij
.psi
.PsiClass
;
29 import com
.intellij
.refactoring
.RefactoringBundle
;
35 * Renders a list cell which contains a class
37 public class ClassCellRenderer
extends DefaultListCellRenderer
{
38 private final boolean myShowReadOnly
;
39 public ClassCellRenderer() {
41 myShowReadOnly
= true;
44 public ClassCellRenderer(boolean showReadOnly
) {
46 myShowReadOnly
= showReadOnly
;
49 public Component
getListCellRendererComponent(
54 boolean cellHasFocus
) {
55 super.getListCellRendererComponent(list
, value
, index
, isSelected
, cellHasFocus
);
57 return customizeRenderer(this, value
, myShowReadOnly
);
60 public static JLabel
customizeRenderer(final JLabel cellRendererComponent
, final Object value
, final boolean showReadOnly
) {
61 PsiClass aClass
= (PsiClass
) value
;
62 cellRendererComponent
.setText(getClassText(aClass
));
64 int flags
= Iconable
.ICON_FLAG_VISIBILITY
;
66 flags
|= Iconable
.ICON_FLAG_READ_STATUS
;
68 Icon icon
= aClass
.getIcon(flags
);
70 cellRendererComponent
.setIcon(icon
);
72 return cellRendererComponent
;
75 private static String
getClassText(PsiClass aClass
) {
76 String qualifiedName
= aClass
.getQualifiedName();
77 if (qualifiedName
!= null) {
81 String name
= aClass
.getName();
86 return RefactoringBundle
.message("anonymous.class.text");