1 package com
.intellij
.openapi
.roots
.ui
.configuration
.projectRoot
.daemon
;
3 import com
.intellij
.openapi
.project
.ProjectBundle
;
4 import com
.intellij
.openapi
.roots
.JavadocOrderRootType
;
5 import com
.intellij
.openapi
.roots
.OrderRootType
;
6 import com
.intellij
.openapi
.roots
.impl
.libraries
.LibraryEx
;
7 import com
.intellij
.openapi
.roots
.impl
.libraries
.LibraryImpl
;
8 import com
.intellij
.openapi
.roots
.libraries
.Library
;
9 import com
.intellij
.openapi
.roots
.libraries
.LibraryTable
;
10 import com
.intellij
.openapi
.roots
.libraries
.LibraryTablesRegistrar
;
11 import com
.intellij
.openapi
.roots
.ui
.configuration
.projectRoot
.StructureConfigurableContext
;
12 import org
.jetbrains
.annotations
.NotNull
;
14 import java
.util
.Collections
;
15 import java
.util
.List
;
20 public class LibraryProjectStructureElement
extends ProjectStructureElement
{
21 private final Library myLibrary
;
23 public LibraryProjectStructureElement(@NotNull StructureConfigurableContext context
, @NotNull Library library
) {
28 public Library
getLibrary() {
33 public void check(ProjectStructureProblemsHolder problemsHolder
) {
34 final LibraryEx library
= (LibraryEx
)myLibrary
;
35 final String libraryName
= myLibrary
.getName();//todo[nik] get modified name?
36 if (!library
.allPathsValid(OrderRootType
.CLASSES
)) {
37 problemsHolder
.registerError(ProjectBundle
.message("project.roots.tooltip.library.misconfigured", libraryName
));
39 else if (!library
.allPathsValid(JavadocOrderRootType
.getInstance()) || !library
.allPathsValid(OrderRootType
.SOURCES
)) {
40 problemsHolder
.registerWarning(ProjectBundle
.message("project.roots.tooltip.library.misconfigured", libraryName
));
45 public List
<ProjectStructureElementUsage
> getUsagesInElement() {
46 return Collections
.emptyList();
50 public boolean equals(Object o
) {
51 if (this == o
) return true;
52 if (!(o
instanceof LibraryProjectStructureElement
)) return false;
54 return getSourceOrThis().equals(((LibraryProjectStructureElement
)o
).getSourceOrThis());
58 private Library
getSourceOrThis() {
59 final Library source
= ((LibraryImpl
)myLibrary
).getSource();
60 return source
!= null ? source
: myLibrary
;
64 public int hashCode() {
65 return getSourceOrThis().hashCode();
69 public String
toString() {
70 return "library:" + myLibrary
.getName();
74 public boolean highlightIfUnused() {
75 final LibraryTable libraryTable
= myLibrary
.getTable();
76 return libraryTable
!= null && LibraryTablesRegistrar
.PROJECT_LEVEL
.equals(libraryTable
.getTableLevel());