diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form index a93ec4db125b..88a7a26bf53c 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/LibraryRootsComponentForm.form @@ -1,6 +1,6 @@
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureDialogCellAppearanceUtils.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureDialogCellAppearanceUtils.java new file mode 100644 index 000000000000..b43b082decea --- /dev/null +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureDialogCellAppearanceUtils.java @@ -0,0 +1,59 @@ +/* + * 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; + +import com.intellij.openapi.roots.LibraryOrderEntry; +import com.intellij.openapi.roots.OrderEntry; +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.roots.ui.util.CellAppearance; +import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils; +import com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance; + +import javax.swing.*; + +/** + * @author nik + */ +//todo[nik] extract service from OrderEntryCellAppearanceUtils and use this class as its implementation for idea-ui +public class ProjectStructureDialogCellAppearanceUtils { + + private ProjectStructureDialogCellAppearanceUtils() { + } + + public static CellAppearance forOrderEntry(OrderEntry orderEntry, StructureConfigurableContext context, boolean selected) { + if (orderEntry instanceof LibraryOrderEntry) { + final Library library = ((LibraryOrderEntry)orderEntry).getLibrary(); + if (orderEntry.isValid()) { + return forLibrary(library, context); + } + } + return OrderEntryCellAppearanceUtils.forOrderEntry(orderEntry, selected); + } + + public static CellAppearance forLibrary(Library library, StructureConfigurableContext context) { + final Icon icon = LibraryPresentationManager.getInstance().getCustomIcon(library, context); + if (icon != null) { + final String name = library.getName(); + if (name != null) { + return SimpleTextCellAppearance.normal(name, icon); + } + } + return OrderEntryCellAppearanceUtils.forLibrary(library); + } + +} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java index 4368359e1b1b..dd023a9a6d21 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java @@ -18,7 +18,6 @@ package com.intellij.openapi.roots.ui.configuration.classpath; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.ApplicationEx; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.StdModuleTypes; import com.intellij.openapi.project.Project; @@ -27,10 +26,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; -import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider; -import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; +import com.intellij.openapi.roots.ui.configuration.*; import com.intellij.openapi.roots.ui.configuration.dependencyAnalysis.AnalyzeDependenciesDialog; import com.intellij.openapi.roots.ui.configuration.libraryEditor.ChooseModulesDialog; import com.intellij.openapi.roots.ui.configuration.libraryEditor.EditExistingLibraryDialog; @@ -69,8 +65,6 @@ import java.util.List; import java.util.Set; public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.configuration.classpath.ClasspathPanel"); - private final Table myEntryTable; private final ClasspathTableModel myModel; private final EventDispatcherLibraryPresentationProvider
getPresentationProvider(LibraryKind
kind) {
+ if (myPresentationProviders == null) {
+ final Map )myPresentationProviders.get(kind);
+ }
+
+ @Override
+ public Icon getCustomIcon(@NotNull Library library, StructureConfigurableContext context) {
+ final List boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
+ final LibraryPresentationProvider provider = getPresentationProvider(kind);
+ if (provider != null) {
+ ContainerUtil.addIfNotNull(icons, provider.getIcon());
+ }
+ return true;
+ }
+ });
+ return icons;
+ }
+
+ private static VirtualFile[] getLibraryFiles(Library library, StructureConfigurableContext context) {
+ if (context != null) {
+ final LibraryTable table = library.getTable();
+ if (table != null) {
+ final LibraryTable.ModifiableModel modifiableModel = context.getModifiableLibraryTable(table);
+ if (modifiableModel instanceof LibrariesModifiableModel) {
+ final LibrariesModifiableModel librariesModel = (LibrariesModifiableModel)modifiableModel;
+ if (librariesModel.hasLibraryEditor(library)) {
+ return librariesModel.getLibraryEditor(library).getFiles(OrderRootType.CLASSES);
+ }
+ }
+ }
+ }
+ return library.getFiles(OrderRootType.CLASSES);
+ }
+
+ @NotNull
+ @Override
+ public List boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
+ final LibraryPresentationProvider provider = getPresentationProvider(kind);
+ if (provider != null) {
+ ContainerUtil.addIfNotNull(result, provider.getDescription(properties));
+ }
+ return true;
+ }
+ });
+ return result;
+ }
+}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationProvider.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationProvider.java
new file mode 100644
index 000000000000..8b902e93a3b7
--- /dev/null
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryPresentationProvider.java
@@ -0,0 +1,48 @@
+/*
+ * 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.libraries;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.roots.libraries.LibraryKind;
+import com.intellij.openapi.roots.libraries.LibraryProperties;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+/**
+ * @author nik
+ */
+public abstract class LibraryPresentationProvider {
+ public static final ExtensionPointName myKind;
+
+ protected LibraryPresentationProvider(LibraryKind kind) {
+ myKind = kind;
+ }
+
+ public final LibraryKind getKind() {
+ return myKind;
+ }
+
+ @Nullable
+ public abstract Icon getIcon();
+
+ @Nullable
+ public String getDescription(@NotNull P properties) {
+ return null;
+ }
+}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java
index 9e42015fdbd6..5d9ac32c6f1a 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java
@@ -36,8 +36,10 @@ import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryUtil;
import com.intellij.openapi.roots.ui.configuration.ModuleEditor;
import com.intellij.openapi.roots.ui.configuration.PathUIUtils;
+import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
+import com.intellij.openapi.ui.ex.MultiLineLabel;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.ui.popup.PopupStep;
@@ -90,6 +92,7 @@ public class LibraryRootsComponent implements Disposable {
private JPanel myTreePanel;
private JButton myAttachAnnotationsButton;
private JButton myAttachMoreButton;
+ private MultiLineLabel myPropertiesLabel;
private Tree myTree;
private LibraryTableTreeBuilder myTreeBuilder;
private static final Icon INVALID_ITEM_ICON = IconLoader.getIcon("/nodes/ppInvalid.png");
@@ -101,10 +104,21 @@ public class LibraryRootsComponent implements Disposable {
private final Map, List