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
.PsiClassChildrenSource
;
20 import com
.intellij
.ide
.projectView
.ViewSettings
;
21 import com
.intellij
.ide
.util
.treeView
.AbstractTreeNode
;
22 import com
.intellij
.openapi
.project
.Project
;
23 import com
.intellij
.psi
.*;
24 import org
.jetbrains
.annotations
.NotNull
;
26 import java
.util
.ArrayList
;
27 import java
.util
.Collection
;
29 public class ClassSmartPointerNode
extends BaseSmartPointerPsiNode
<SmartPsiElementPointer
>{
30 public ClassSmartPointerNode(Project project
, PsiClass value
, ViewSettings viewSettings
) {
31 super(project
, SmartPointerManager
.getInstance(project
).createLazyPointer(value
), viewSettings
);
34 public ClassSmartPointerNode(Project project
, Object value
, ViewSettings viewSettings
) {
35 this(project
, (PsiClass
)value
, viewSettings
);
39 public Collection
<AbstractTreeNode
> getChildrenImpl() {
40 PsiClass parent
= getPsiClass();
41 final ArrayList
<AbstractTreeNode
> treeNodes
= new ArrayList
<AbstractTreeNode
>();
43 ArrayList
<PsiElement
> result
= new ArrayList
<PsiElement
>();
44 if (getSettings().isShowMembers()) {
45 PsiClassChildrenSource
.DEFAULT_CHILDREN
.addChildren(parent
, result
);
46 for (PsiElement psiElement
: result
) {
47 psiElement
.accept(new JavaElementVisitor() {
48 @Override public void visitClass(PsiClass aClass
) {
49 treeNodes
.add(new ClassSmartPointerNode(getProject(), aClass
, getSettings()));
52 @Override public void visitMethod(PsiMethod method
) {
53 treeNodes
.add(new MethodSmartPointerNode(getProject(), method
, getSettings()));
56 @Override public void visitField(PsiField field
) {
57 treeNodes
.add(new FieldSmartPointerNode(getProject(), field
, getSettings()));
60 @Override public void visitReferenceExpression(PsiReferenceExpression expression
) {
61 visitExpression(expression
);
69 public void updateImpl(PresentationData data
) {
70 final PsiClass aClass
= getPsiClass();
72 data
.setPresentableText(aClass
.getName());
76 public boolean isTopLevel() {
77 return getPsiElement() != null && getPsiElement().getParent() instanceof PsiFile
;
81 public boolean expandOnDoubleClick() {
85 public PsiClass
getPsiClass() {
86 return (PsiClass
)getPsiElement();
89 public boolean isAlwaysExpand() {
90 return getParentValue() instanceof PsiFile
;