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
.packageDependencies
.ui
;
18 import com
.intellij
.openapi
.roots
.JdkOrderEntry
;
19 import com
.intellij
.openapi
.roots
.OrderEntry
;
20 import com
.intellij
.openapi
.util
.IconLoader
;
21 import com
.intellij
.psi
.PsiFile
;
26 public class LibraryNode
extends PackageDependenciesNode
{
27 private static final Icon LIB_ICON_OPEN
= IconLoader
.getIcon("/nodes/ppLibOpen.png");
28 private static final Icon LIB_ICON_CLOSED
= IconLoader
.getIcon("/nodes/ppLibClosed.png");
29 private static final Icon JDK_ICON_OPEN
= IconLoader
.getIcon("/nodes/ppJdkOpen.png");
30 private static final Icon JDK_ICON_CLOSED
= IconLoader
.getIcon("/nodes/ppJdkClosed.png");
32 private final OrderEntry myLibraryOrJdk
;
34 public LibraryNode(OrderEntry libraryOrJdk
) {
35 myLibraryOrJdk
= libraryOrJdk
;
38 public void fillFiles(Set
<PsiFile
> set
, boolean recursively
) {
39 super.fillFiles(set
, recursively
);
40 int count
= getChildCount();
41 for (int i
= 0; i
< count
; i
++) {
42 PackageDependenciesNode child
= (PackageDependenciesNode
)getChildAt(i
);
43 child
.fillFiles(set
, true);
47 public String
toString() {
48 return myLibraryOrJdk
.getPresentableName();
51 public int getWeight() {
55 public boolean equals(Object o
) {
57 return super.equals(o
);
59 if (this == o
) return true;
60 if (!(o
instanceof LibraryNode
)) return false;
62 final LibraryNode libraryNode
= (LibraryNode
)o
;
64 if (!myLibraryOrJdk
.equals(libraryNode
.myLibraryOrJdk
)) return false;
69 public int hashCode() {
70 return myLibraryOrJdk
.hashCode();
73 public Icon
getOpenIcon() {
74 return myLibraryOrJdk
instanceof JdkOrderEntry ? JDK_ICON_OPEN
: LIB_ICON_OPEN
;
77 public Icon
getClosedIcon() {
78 return myLibraryOrJdk
instanceof JdkOrderEntry ? JDK_ICON_CLOSED
: LIB_ICON_CLOSED
;