mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
description of custom libraries shown in tooltips
This commit is contained in:
+2
-2
@@ -68,7 +68,7 @@ class AddLibraryAction extends AddItemPopupAction<Library> {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ClasspathTableItem createTableItem(final Library item) {
|
||||
protected ClasspathTableItem<?> createTableItem(final Library item) {
|
||||
// clear invalid order entry corresponding to added library if any
|
||||
final ModifiableRootModel rootModel = myClasspathPanel.getRootModel();
|
||||
final OrderEntry[] orderEntries = rootModel.getOrderEntries();
|
||||
@@ -85,7 +85,7 @@ class AddLibraryAction extends AddItemPopupAction<Library> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return ClasspathTableItem.createLibItem(rootModel.addLibraryEntry(item));
|
||||
return ClasspathTableItem.createLibItem(rootModel.addLibraryEntry(item), myContext);
|
||||
}
|
||||
|
||||
protected ClasspathElementChooser<Library> createChooser() {
|
||||
|
||||
+3
-3
@@ -32,17 +32,17 @@ class AddNewLibraryItemAction extends ChooseAndAddAction<Library> {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
protected ClasspathTableItem createTableItem(final Library item) {
|
||||
protected ClasspathTableItem<?> createTableItem(final Library item) {
|
||||
final OrderEntry[] entries = myClasspathPanel.getRootModel().getOrderEntries();
|
||||
for (OrderEntry entry : entries) {
|
||||
if (entry instanceof LibraryOrderEntry) {
|
||||
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
|
||||
if (item.equals(libraryOrderEntry.getLibrary())) {
|
||||
return ClasspathTableItem.createLibItem(libraryOrderEntry);
|
||||
return ClasspathTableItem.createLibItem(libraryOrderEntry, myContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ClasspathTableItem.createLibItem(myClasspathPanel.getRootModel().addLibraryEntry(item));
|
||||
return ClasspathTableItem.createLibItem(myClasspathPanel.getRootModel().addLibraryEntry(item), myContext);
|
||||
}
|
||||
|
||||
protected ClasspathElementChooser<Library> createChooser() {
|
||||
|
||||
+8
-3
@@ -21,6 +21,7 @@ import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
import com.intellij.util.Icons;
|
||||
|
||||
/**
|
||||
@@ -28,18 +29,22 @@ import com.intellij.util.Icons;
|
||||
*/
|
||||
class AddSingleEntryModuleLibraryAction extends AddItemPopupAction<Library> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.classpath.AddSingleEntryModuleLibraryAction");
|
||||
private StructureConfigurableContext myContext;
|
||||
|
||||
public AddSingleEntryModuleLibraryAction(final ClasspathPanel classpathPanel, int actionIndex) {
|
||||
public AddSingleEntryModuleLibraryAction(final ClasspathPanel classpathPanel,
|
||||
int actionIndex,
|
||||
StructureConfigurableContext context) {
|
||||
super(classpathPanel, actionIndex, ProjectBundle.message("classpath.add.simple.module.library.action"), Icons.JAR_ICON);
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
protected ClasspathTableItem createTableItem(final Library item) {
|
||||
protected ClasspathTableItem<?> createTableItem(final Library item) {
|
||||
final OrderEntry[] entries = myClasspathPanel.getRootModel().getOrderEntries();
|
||||
for (OrderEntry entry : entries) {
|
||||
if (entry instanceof LibraryOrderEntry) {
|
||||
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
|
||||
if (item.equals(libraryOrderEntry.getLibrary())) {
|
||||
return ClasspathTableItem.createLibItem(libraryOrderEntry);
|
||||
return ClasspathTableItem.createLibItem(libraryOrderEntry, myContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -44,9 +44,9 @@ public abstract class ChooseAndAddAction<ItemType> extends ClasspathPanelAction
|
||||
if (chosen.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<ClasspathTableItem> toAdd = new ArrayList<ClasspathTableItem>();
|
||||
List<ClasspathTableItem<?>> toAdd = new ArrayList<ClasspathTableItem<?>>();
|
||||
for (ItemType item : chosen) {
|
||||
final ClasspathTableItem tableItem = createTableItem(item);
|
||||
final ClasspathTableItem<?> tableItem = createTableItem(item);
|
||||
if (tableItem != null) {
|
||||
toAdd.add(tableItem);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public abstract class ChooseAndAddAction<ItemType> extends ClasspathPanelAction
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract ClasspathTableItem createTableItem(final ItemType item);
|
||||
protected abstract ClasspathTableItem<?> createTableItem(final ItemType item);
|
||||
|
||||
@Nullable
|
||||
protected abstract ClasspathElementChooser<ItemType> createChooser();
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
public interface ClasspathPanel {
|
||||
void runClasspathPanelAction(Runnable action);
|
||||
|
||||
void addItems(List<ClasspathTableItem> toAdd);
|
||||
void addItems(List<ClasspathTableItem<?>> toAdd);
|
||||
|
||||
ModifiableRootModel getRootModel();
|
||||
|
||||
|
||||
+24
-18
@@ -76,7 +76,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
super(new BorderLayout());
|
||||
|
||||
myState = state;
|
||||
myModel = new ClasspathTableModel(state);
|
||||
myModel = new ClasspathTableModel(state, getStructureConfigurableContext());
|
||||
myEntryTable = new Table(myModel);
|
||||
myEntryTable.setShowGrid(false);
|
||||
myEntryTable.setDragEnabled(false);
|
||||
@@ -111,7 +111,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
}
|
||||
|
||||
public String getElementText(Object element) {
|
||||
return getCellAppearance((ClasspathTableItem)element, getStructureConfigurableContext(), false).getText();
|
||||
return getCellAppearance((ClasspathTableItem<?>)element, getStructureConfigurableContext(), false).getText();
|
||||
}
|
||||
|
||||
public void selectElement(Object element, String selectedText) {
|
||||
@@ -137,7 +137,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
final int[] selectedRows = myEntryTable.getSelectedRows();
|
||||
boolean currentlyMarked = true;
|
||||
for (final int selectedRow : selectedRows) {
|
||||
final ClasspathTableItem item = myModel.getItemAt(myEntryTable.convertRowIndexToModel(selectedRow));
|
||||
final ClasspathTableItem<?> item = myModel.getItemAt(myEntryTable.convertRowIndexToModel(selectedRow));
|
||||
if (selectedRow < 0 || !item.isExportable()) {
|
||||
return;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
for (final int selectedRow : selectedRows) {
|
||||
minRow = Math.min(minRow, selectedRow);
|
||||
maxRow = Math.max(maxRow, selectedRow);
|
||||
final ClasspathTableItem item = myModel.getItemAt(selectedRow);
|
||||
final ClasspathTableItem<?> item = myModel.getItemAt(selectedRow);
|
||||
if (!item.isRemovable()) {
|
||||
removeButtonEnabled = false;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
upButton.setEnabled(minRow > 0 && minRow < myEntryTable.getRowCount());
|
||||
downButton.setEnabled(maxRow >= 0 && maxRow < myEntryTable.getRowCount() - 1);
|
||||
removeButton.setEnabled(removeButtonEnabled);
|
||||
ClasspathTableItem selectedItem = selectedRows.length == 1 ? myModel.getItemAt(selectedRows[0]) : null;
|
||||
ClasspathTableItem<?> selectedItem = selectedRows.length == 1 ? myModel.getItemAt(selectedRows[0]) : null;
|
||||
myEditButton.setEnabled(selectedItem != null && selectedItem.isEditable());
|
||||
}
|
||||
});
|
||||
@@ -339,7 +339,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
return;
|
||||
}
|
||||
for (final Object removedRow : removedRows) {
|
||||
final ClasspathTableItem item = (ClasspathTableItem)((Object[])removedRow)[ClasspathTableModel.ITEM_COLUMN];
|
||||
final ClasspathTableItem<?> item = (ClasspathTableItem<?>)((Object[])removedRow)[ClasspathTableModel.ITEM_COLUMN];
|
||||
final OrderEntry orderEntry = item.getEntry();
|
||||
if (orderEntry == null) {
|
||||
continue;
|
||||
@@ -358,7 +358,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
myEditButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final int row = myEntryTable.getSelectedRow();
|
||||
final ClasspathTableItem item = myModel.getItemAt(row);
|
||||
final ClasspathTableItem<?> item = myModel.getItemAt(row);
|
||||
final OrderEntry entry = item.getEntry();
|
||||
if (!(entry instanceof LibraryOrderEntry)) return;
|
||||
|
||||
@@ -417,8 +417,8 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(List<ClasspathTableItem> toAdd) {
|
||||
for (ClasspathTableItem item : toAdd) {
|
||||
public void addItems(List<ClasspathTableItem<?>> toAdd) {
|
||||
for (ClasspathTableItem<?> item : toAdd) {
|
||||
myModel.addItem(item);
|
||||
}
|
||||
myModel.fireTableDataChanged();
|
||||
@@ -453,12 +453,13 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
if (myPopupActions == null) {
|
||||
int actionIndex = 1;
|
||||
final List<AddItemPopupAction<?>> actions = new ArrayList<AddItemPopupAction<?>>();
|
||||
actions.add(new AddSingleEntryModuleLibraryAction(this, actionIndex++));
|
||||
actions.add(new AddLibraryAction(this, actionIndex++, ProjectBundle.message("classpath.add.library.action"), getStructureConfigurableContext()));
|
||||
final StructureConfigurableContext context = getStructureConfigurableContext();
|
||||
actions.add(new AddSingleEntryModuleLibraryAction(this, actionIndex++, context));
|
||||
actions.add(new AddLibraryAction(this, actionIndex++, ProjectBundle.message("classpath.add.library.action"), context));
|
||||
actions.add(new AddItemPopupAction<Module>(this, actionIndex, ProjectBundle.message("classpath.add.module.dependency.action"),
|
||||
StdModuleTypes.JAVA.getNodeIcon(false)) {
|
||||
protected ClasspathTableItem createTableItem(final Module item) {
|
||||
return ClasspathTableItem.createItem(getRootModel().addModuleOrderEntry(item));
|
||||
protected ClasspathTableItem<?> createTableItem(final Module item) {
|
||||
return ClasspathTableItem.createItem(getRootModel().addModuleOrderEntry(item), context);
|
||||
}
|
||||
protected ClasspathElementChooser<Module> createChooser() {
|
||||
final List<Module> chooseItems = getDependencyModules();
|
||||
@@ -533,7 +534,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
|
||||
private int moveRow(final int row, final int increment) {
|
||||
int newIndex = Math.abs(row + increment) % myModel.getRowCount();
|
||||
final ClasspathTableItem item = myModel.removeDataRow(row);
|
||||
final ClasspathTableItem<?> item = myModel.removeDataRow(row);
|
||||
myModel.addItemAt(item, newIndex);
|
||||
return newIndex;
|
||||
}
|
||||
@@ -593,7 +594,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
}
|
||||
|
||||
|
||||
private static CellAppearance getCellAppearance(final ClasspathTableItem item,
|
||||
private static CellAppearance getCellAppearance(final ClasspathTableItem<?> item,
|
||||
StructureConfigurableContext context,
|
||||
final boolean selected) {
|
||||
if (item instanceof InvalidJdkItem) {
|
||||
@@ -616,8 +617,13 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
setPaintFocusBorder(false);
|
||||
setFocusBorderAroundIcon(true);
|
||||
setBorder(NO_FOCUS_BORDER);
|
||||
if (value instanceof ClasspathTableItem) {
|
||||
getCellAppearance((ClasspathTableItem)value, myContext, selected).customize(this);
|
||||
if (value instanceof ClasspathTableItem<?>) {
|
||||
final ClasspathTableItem<?> tableItem = (ClasspathTableItem<?>)value;
|
||||
getCellAppearance(tableItem, myContext, selected).customize(this);
|
||||
String tooltip = tableItem.getTooltipText();
|
||||
if (tooltip != null) {
|
||||
setToolTipText(tooltip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -666,7 +672,7 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
protected ProjectStructureElement getSelectedElement() {
|
||||
int row = myEntryTable.getSelectedRow();
|
||||
if (0 <= row && row < myModel.getRowCount()) {
|
||||
ClasspathTableItem item = myModel.getItemAt(row);
|
||||
ClasspathTableItem<?> item = myModel.getItemAt(row);
|
||||
final OrderEntry entry = item.getEntry();
|
||||
if (entry instanceof LibraryOrderEntry) {
|
||||
final Library library = ((LibraryOrderEntry)entry).getLibrary();
|
||||
|
||||
+18
-15
@@ -16,41 +16,38 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.classpath;
|
||||
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class ClasspathTableItem {
|
||||
@Nullable protected final OrderEntry myEntry;
|
||||
class ClasspathTableItem<T extends OrderEntry> {
|
||||
@Nullable protected final T myEntry;
|
||||
private final boolean myRemovable;
|
||||
|
||||
@Nullable
|
||||
public static ClasspathTableItem createItem(OrderEntry orderEntry) {
|
||||
public static ClasspathTableItem<?> createItem(OrderEntry orderEntry, StructureConfigurableContext context) {
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
return new ClasspathTableItem(orderEntry, false);
|
||||
return new ClasspathTableItem<OrderEntry>(orderEntry, false);
|
||||
}
|
||||
else if (orderEntry instanceof LibraryOrderEntry) {
|
||||
return createLibItem((LibraryOrderEntry)orderEntry);
|
||||
return createLibItem((LibraryOrderEntry)orderEntry, context);
|
||||
}
|
||||
else if (orderEntry instanceof ModuleOrderEntry) {
|
||||
return new ClasspathTableItem(orderEntry, true);
|
||||
return new ClasspathTableItem<OrderEntry>(orderEntry, true);
|
||||
}
|
||||
else if (orderEntry instanceof ModuleSourceOrderEntry) {
|
||||
return new ClasspathTableItem(orderEntry, false);
|
||||
return new ClasspathTableItem<OrderEntry>(orderEntry, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ClasspathTableItem createLibItem(LibraryOrderEntry orderEntry) {
|
||||
return new ClasspathTableItem(orderEntry, true) {
|
||||
public boolean isEditable() {
|
||||
return myEntry != null && myEntry.isValid();
|
||||
}
|
||||
};
|
||||
public static ClasspathTableItem<LibraryOrderEntry> createLibItem(final LibraryOrderEntry orderEntry, final StructureConfigurableContext context) {
|
||||
return new LibraryItem(orderEntry, context);
|
||||
}
|
||||
|
||||
protected ClasspathTableItem(@Nullable OrderEntry entry, boolean removable) {
|
||||
protected ClasspathTableItem(@Nullable T entry, boolean removable) {
|
||||
myEntry = entry;
|
||||
myRemovable = removable;
|
||||
}
|
||||
@@ -81,7 +78,7 @@ class ClasspathTableItem {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final OrderEntry getEntry() {
|
||||
public final T getEntry() {
|
||||
return myEntry;
|
||||
}
|
||||
|
||||
@@ -92,4 +89,10 @@ class ClasspathTableItem {
|
||||
public boolean isEditable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTooltipText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-10
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
import com.intellij.util.ui.ItemRemovable;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
@@ -35,11 +36,13 @@ class ClasspathTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
public static final int EXPORT_COLUMN = 0;
|
||||
public static final int ITEM_COLUMN = 1;
|
||||
public static final int SCOPE_COLUMN = 2;
|
||||
private final List<ClasspathTableItem> myItems = new ArrayList<ClasspathTableItem>();
|
||||
private final List<ClasspathTableItem<?>> myItems = new ArrayList<ClasspathTableItem<?>>();
|
||||
private final ModuleConfigurationState myState;
|
||||
private StructureConfigurableContext myContext;
|
||||
|
||||
public ClasspathTableModel(final ModuleConfigurationState state) {
|
||||
public ClasspathTableModel(final ModuleConfigurationState state, StructureConfigurableContext context) {
|
||||
myState = state;
|
||||
myContext = context;
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -54,26 +57,26 @@ class ClasspathTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
hasJdkOrderEntry = true;
|
||||
}
|
||||
addItem(ClasspathTableItem.createItem(orderEntry));
|
||||
addItem(ClasspathTableItem.createItem(orderEntry, myContext));
|
||||
}
|
||||
if (!hasJdkOrderEntry) {
|
||||
addItemAt(new InvalidJdkItem(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public ClasspathTableItem getItemAt(int row) {
|
||||
public ClasspathTableItem<?> getItemAt(int row) {
|
||||
return myItems.get(row);
|
||||
}
|
||||
|
||||
public void addItem(ClasspathTableItem item) {
|
||||
public void addItem(ClasspathTableItem<?> item) {
|
||||
myItems.add(item);
|
||||
}
|
||||
|
||||
public void addItemAt(ClasspathTableItem item, int row) {
|
||||
public void addItemAt(ClasspathTableItem<?> item, int row) {
|
||||
myItems.add(row, item);
|
||||
}
|
||||
|
||||
public ClasspathTableItem removeDataRow(int row) {
|
||||
public ClasspathTableItem<?> removeDataRow(int row) {
|
||||
return myItems.remove(row);
|
||||
}
|
||||
|
||||
@@ -90,7 +93,7 @@ class ClasspathTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
}
|
||||
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
final ClasspathTableItem item = myItems.get(rowIndex);
|
||||
final ClasspathTableItem<?> item = myItems.get(rowIndex);
|
||||
if (columnIndex == EXPORT_COLUMN) {
|
||||
return item.isExported();
|
||||
}
|
||||
@@ -105,7 +108,7 @@ class ClasspathTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
}
|
||||
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
final ClasspathTableItem item = myItems.get(rowIndex);
|
||||
final ClasspathTableItem<?> item = myItems.get(rowIndex);
|
||||
if (columnIndex == EXPORT_COLUMN) {
|
||||
item.setExported(((Boolean)aValue).booleanValue());
|
||||
}
|
||||
@@ -143,7 +146,7 @@ class ClasspathTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
if (column == EXPORT_COLUMN || column == SCOPE_COLUMN) {
|
||||
final ClasspathTableItem item = myItems.get(row);
|
||||
final ClasspathTableItem<?> item = myItems.get(row);
|
||||
return item != null && item.isExportable();
|
||||
}
|
||||
return false;
|
||||
|
||||
+3
-1
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.classpath;
|
||||
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class InvalidJdkItem extends ClasspathTableItem {
|
||||
public class InvalidJdkItem extends ClasspathTableItem<OrderEntry> {
|
||||
public InvalidJdkItem() {
|
||||
super(null, false);
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.classpath;
|
||||
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class LibraryItem extends ClasspathTableItem<LibraryOrderEntry> {
|
||||
private final StructureConfigurableContext myContext;
|
||||
|
||||
public LibraryItem(LibraryOrderEntry orderEntry, StructureConfigurableContext context) {
|
||||
super(orderEntry, true);
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public boolean isEditable() {
|
||||
return myEntry != null && myEntry.isValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltipText() {
|
||||
if (myEntry == null) return null;
|
||||
|
||||
final Library library = myEntry.getLibrary();
|
||||
if (library == null) return null;
|
||||
|
||||
final List<String> descriptions = LibraryPresentationManager.getInstance().getDescriptions(library, myContext);
|
||||
return "<html>" + StringUtil.join(descriptions, "<br>") + "</html>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user