update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / ide / projectView / impl / nodes / PsiFieldNode.java
blob7713af9f7dec38c7bed5feb7288b916c4201e2c3
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.projectView.impl.nodes;
18 import com.intellij.ide.projectView.PresentationData;
19 import com.intellij.ide.projectView.ViewSettings;
20 import com.intellij.ide.util.treeView.AbstractTreeNode;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.psi.PsiClass;
23 import com.intellij.psi.PsiField;
24 import com.intellij.psi.PsiSubstitutor;
25 import com.intellij.psi.util.PsiFormatUtil;
27 import java.util.Collection;
29 public class PsiFieldNode extends BasePsiMemberNode<PsiField>{
30 public PsiFieldNode(Project project, PsiField value, ViewSettings viewSettings) {
31 super(project, value, viewSettings);
34 public Collection<AbstractTreeNode> getChildrenImpl() {
35 return null;
38 public void updateImpl(PresentationData data) {
39 String name = PsiFormatUtil.formatVariable(getValue(),
40 PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.TYPE_AFTER | PsiFormatUtil.SHOW_INITIALIZER,
41 PsiSubstitutor.EMPTY);
42 int c = name.indexOf('\n');
43 if (c > -1) {
44 name = name.substring(0, c - 1);
46 data.setPresentableText(name);
49 public int getWeight() {
50 return 70;
53 @Override
54 public String getTitle() {
55 final PsiField field = getValue();
56 if (field != null) {
57 PsiClass aClass = field.getContainingClass();
58 if (aClass != null) {
59 return aClass.getQualifiedName();
61 else {
62 return field.toString();
65 return super.getTitle();