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.
20 package com
.intellij
.openapi
.roots
.ui
.configuration
;
22 import com
.intellij
.ide
.util
.ElementsChooser
;
23 import com
.intellij
.openapi
.diagnostic
.Logger
;
24 import com
.intellij
.openapi
.project
.ProjectBundle
;
25 import com
.intellij
.openapi
.roots
.LibraryOrderEntry
;
26 import com
.intellij
.openapi
.roots
.libraries
.Library
;
27 import com
.intellij
.util
.Icons
;
32 public class LibraryChooserElement
{
33 private static final Logger LOG
= Logger
.getInstance("#com.intellij.openapi.roots.ui.configuration.LibraryChooserElement");
35 private final String myName
;
36 private final Library myLibrary
;
37 private LibraryOrderEntry myOrderEntry
;
38 public static final ElementsChooser
.ElementProperties VALID_LIBRARY_ELEMENT_PROPERTIES
= new ElementsChooser
.ElementProperties() {
39 public Icon
getIcon() {
40 return Icons
.LIBRARY_ICON
;
42 public Color
getColor() {
46 public static final ElementsChooser
.ElementProperties INVALID_LIBRARY_ELEMENT_PROPERTIES
= new ElementsChooser
.ElementProperties() {
47 public Icon
getIcon() {
48 return Icons
.LIBRARY_ICON
;
50 public Color
getColor() {
55 public LibraryChooserElement(Library library
, final LibraryOrderEntry orderEntry
) {
57 myOrderEntry
= orderEntry
;
58 if (myLibrary
== null && myOrderEntry
== null) {
59 LOG
.assertTrue(false, "Both library and order entry are null");
60 myName
= ProjectBundle
.message("module.libraries.unknown.item");
63 myName
= myLibrary
!= null? myLibrary
.getName() : myOrderEntry
.getLibraryName();
67 public String
toString() {
71 public String
getName() {
75 public Library
getLibrary() {
79 public LibraryOrderEntry
getOrderEntry() {
83 public void setOrderEntry(LibraryOrderEntry orderEntry
) {
84 myOrderEntry
= orderEntry
;
87 public boolean isAttachedToProject() {
88 return myOrderEntry
!= null;
91 public boolean isValid() {
92 return myLibrary
!= null;