IDEADEV-41116: exploded war artefact: add warning for dependent module
[fedora-idea.git] / java / idea-ui / src / com / intellij / openapi / roots / ui / configuration / LibraryDependantsPanel.java
bloba536e60297fb8fd5359e27956012e167705638c9
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.
18 * Created by IntelliJ IDEA.
19 * User: Anna.Kozlova
20 * Date: 14-Aug-2006
21 * Time: 15:50:48
23 package com.intellij.openapi.roots.ui.configuration;
25 import com.intellij.openapi.module.Module;
26 import com.intellij.openapi.roots.LibraryOrderEntry;
27 import com.intellij.openapi.roots.ModifiableRootModel;
28 import com.intellij.openapi.roots.OrderEntry;
29 import com.intellij.openapi.roots.libraries.Library;
30 import com.intellij.openapi.util.Comparing;
31 import com.intellij.ui.BooleanTableCellRenderer;
32 import com.intellij.ui.OrderPanel;
34 import javax.swing.*;
35 import javax.swing.table.DefaultTableCellRenderer;
36 import java.awt.*;
38 /**
39 * Dead code now
41 public class LibraryDependantsPanel extends OrderPanel<ModifiableRootModel> {
42 private final Library myLibrary;
44 public LibraryDependantsPanel(final Library library) {
45 super(ModifiableRootModel.class, true);
46 myLibrary = library;
47 getEntryTable().setDefaultRenderer(ModifiableRootModel.class, new DefaultTableCellRenderer(){
48 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
49 final Component cellRendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
50 if (value instanceof ModifiableRootModel){
51 final ModifiableRootModel model = (ModifiableRootModel)value;
52 final Module module = model.getModule();
53 setText(module.getName());
54 setIcon(module.getModuleType().getNodeIcon(false));
56 return cellRendererComponent;
58 });
59 getEntryTable().setDefaultRenderer(Boolean.class, new BooleanTableCellRenderer());
61 setBorder(BorderFactory.createTitledBorder("Used In"));
65 public boolean isCheckable(final ModifiableRootModel entry) {
66 return true;
69 public boolean isChecked(final ModifiableRootModel model) {
70 final OrderEntry[] entries = model.getOrderEntries();
71 for (OrderEntry entry : entries) {
72 if (entry instanceof LibraryOrderEntry) {
73 final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
74 if (Comparing.equal(libraryOrderEntry.getLibrary(), myLibrary)) {
75 return true;
79 return false;
82 public void setChecked(final ModifiableRootModel model, final boolean checked) {
83 if (checked) {
84 model.addLibraryEntry(myLibrary);
86 else {
87 final OrderEntry[] entries = model.getOrderEntries();
88 for (OrderEntry entry : entries) {
89 if (entry instanceof LibraryOrderEntry) {
90 final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
91 if (Comparing.equal(libraryOrderEntry.getLibrary(), myLibrary)) {
92 model.removeOrderEntry(libraryOrderEntry);
93 break;