update copyright
[fedora-idea.git] / java / idea-ui / src / com / intellij / facet / impl / ui / libraries / ChooseLibrariesDialog.java
blob2ff0bd8765be5451274e4dff8b6841ec286d9928
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.
16 package com.intellij.facet.impl.ui.libraries;
18 import com.intellij.ide.util.ElementsChooser;
19 import com.intellij.openapi.project.ProjectBundle;
20 import com.intellij.openapi.roots.libraries.Library;
21 import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
22 import com.intellij.openapi.ui.DialogWrapper;
23 import com.intellij.util.Icons;
24 import org.jetbrains.annotations.Nullable;
25 import org.jetbrains.annotations.NotNull;
27 import javax.swing.*;
28 import java.awt.*;
29 import java.util.Collection;
30 import java.util.List;
32 /**
33 * @author nik
35 public class ChooseLibrariesDialog extends DialogWrapper {
36 private final LibraryElementChooser myChooser;
38 public ChooseLibrariesDialog(final Component parent, final List<Library> libraries) {
39 super(parent, true);
40 setTitle(ProjectBundle.message("dialog.title.select.libraries"));
41 setModal(true);
42 myChooser = new LibraryElementChooser(libraries);
43 init();
46 @Nullable
47 protected JComponent createCenterPanel() {
48 return myChooser;
51 public void markElements(final Collection<Library> elements) {
52 myChooser.markElements(elements);
55 public List<Library> getMarkedLibraries() {
56 return myChooser.getMarkedElements();
59 private static class LibraryElementChooser extends ElementsChooser<Library> {
60 private LibraryElementChooser(final List<Library> elements) {
61 super(elements, false);
64 protected Icon getItemIcon(final Library value) {
65 return Icons.LIBRARY_ICON;
68 protected String getItemText(@NotNull final Library value) {
69 return OrderEntryCellAppearanceUtils.forLibrary(value).getText();