update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / ide / structureView / impl / java / PsiFieldTreeElement.java
blob34ae43ba0f8adb17fa07370988691ee1d5d53cf9
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.ide.structureView.impl.java;
18 import com.intellij.ide.structureView.StructureViewTreeElement;
19 import com.intellij.ide.util.treeView.smartTree.SortableTreeElement;
20 import com.intellij.navigation.ItemPresentation;
21 import com.intellij.psi.PsiField;
22 import com.intellij.psi.PsiSubstitutor;
23 import com.intellij.psi.util.PsiFormatUtil;
24 import org.jetbrains.annotations.NotNull;
26 import java.util.Collection;
27 import java.util.Collections;
29 public class PsiFieldTreeElement extends JavaClassTreeElementBase<PsiField> implements SortableTreeElement {
30 public PsiFieldTreeElement(PsiField field, boolean isInherited) {
31 super(isInherited,field);
34 @NotNull
35 public Collection<StructureViewTreeElement> getChildrenBase() {
36 return Collections.emptyList();
39 public ItemPresentation getPresentation() {
40 return this;
43 public String getPresentableText() {
44 return PsiFormatUtil.formatVariable(
45 getElement(),
46 PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.TYPE_AFTER | PsiFormatUtil.SHOW_INITIALIZER,
47 PsiSubstitutor.EMPTY
51 public PsiField getField() {
52 return getElement();
55 public String getAlphaSortKey() {
56 final PsiField field = getElement();
57 if (field != null) {
58 String name = field.getName();
59 if (name != null) {
60 return name;
63 return "";