update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / ide / favoritesTreeView / smartPointerPsiNodes / FieldSmartPointerNode.java
blobc980063b805d94205f3f3269c8c06f82788e2b77
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.favoritesTreeView.smartPointerPsiNodes;
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.PsiField;
23 import com.intellij.psi.PsiSubstitutor;
24 import com.intellij.psi.SmartPointerManager;
25 import com.intellij.psi.SmartPsiElementPointer;
26 import com.intellij.psi.util.PsiFormatUtil;
27 import org.jetbrains.annotations.NotNull;
29 import java.util.Collection;
30 import java.util.Collections;
32 public class FieldSmartPointerNode extends BaseSmartPointerPsiNode<SmartPsiElementPointer>{
34 public FieldSmartPointerNode(Project project, PsiField value, ViewSettings viewSettings) {
35 super(project, SmartPointerManager.getInstance(project).createLazyPointer(value), viewSettings);
38 public FieldSmartPointerNode(final Project project, final Object value, final ViewSettings viewSettings) {
39 this(project, (PsiField)value, viewSettings);
42 @NotNull
43 public Collection<AbstractTreeNode> getChildrenImpl() {
44 return Collections.emptyList();
47 public void updateImpl(PresentationData data) {
48 String name = PsiFormatUtil.formatVariable(
49 (PsiField)getPsiElement(),
50 PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.TYPE_AFTER | PsiFormatUtil.SHOW_INITIALIZER,
51 PsiSubstitutor.EMPTY);
52 int c = name.indexOf('\n');
53 if (c > -1) {
54 name = name.substring(0, c - 1);
56 data.setPresentableText(name);