update copyright
[fedora-idea.git] / java / idea-ui / src / com / intellij / openapi / roots / ui / configuration / LibraryChooserElement.java
blob54386314ffa90777c26203c8836559e65a11cd00
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.
17 /**
18 * @author cdr
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;
29 import javax.swing.*;
30 import java.awt.*;
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() {
43 return null;
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() {
51 return Color.RED;
55 public LibraryChooserElement(Library library, final LibraryOrderEntry orderEntry) {
56 myLibrary = library;
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");
62 else {
63 myName = myLibrary != null? myLibrary.getName() : myOrderEntry.getLibraryName();
67 public String toString() {
68 return myName;
71 public String getName() {
72 return myName;
75 public Library getLibrary() {
76 return myLibrary;
79 public LibraryOrderEntry getOrderEntry() {
80 return myOrderEntry;
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;