Search in sources :

Example 1 with LibraryType

use of com.intellij.openapi.roots.libraries.LibraryType in project intellij-community by JetBrains.

the class AddNewLibraryDependencyAction method chooseTypeAndCreate.

public static void chooseTypeAndCreate(final ClasspathPanel classpathPanel, final StructureConfigurableContext context, final JButton contextButton, @NotNull final LibraryCreatedCallback callback) {
    if (LibraryEditingUtil.hasSuitableTypes(classpathPanel)) {
        final ListPopup popup = JBPopupFactory.getInstance().createListPopup(LibraryEditingUtil.createChooseTypeStep(classpathPanel, libraryType -> doCreateLibrary(classpathPanel, context, callback, contextButton, libraryType)));
        popup.showUnderneathOf(contextButton);
    } else {
        doCreateLibrary(classpathPanel, context, callback, contextButton, null);
    }
}
Also used : Library(com.intellij.openapi.roots.libraries.Library) ListPopup(com.intellij.openapi.ui.popup.ListPopup) Nullable(org.jetbrains.annotations.Nullable) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibraryEditingUtil(com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryType(com.intellij.openapi.roots.libraries.LibraryType) NotNull(org.jetbrains.annotations.NotNull) ParameterizedRunnable(com.intellij.util.ParameterizedRunnable) javax.swing(javax.swing) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Example 2 with LibraryType

use of com.intellij.openapi.roots.libraries.LibraryType in project intellij-community by JetBrains.

the class CreateNewLibraryAction method createActionOrGroup.

public static AnAction[] createActionOrGroup(@NotNull String text, @NotNull BaseLibrariesConfigurable librariesConfigurable, @NotNull final Project project) {
    final LibraryType<?>[] extensions = LibraryType.EP_NAME.getExtensions();
    List<LibraryType<?>> suitableTypes = new ArrayList<>();
    if (librariesConfigurable instanceof ProjectLibrariesConfigurable || !project.isDefault()) {
        final ModuleStructureConfigurable configurable = ModuleStructureConfigurable.getInstance(project);
        for (LibraryType<?> extension : extensions) {
            if (!LibraryEditingUtil.getSuitableModules(configurable, extension.getKind(), null).isEmpty()) {
                suitableTypes.add(extension);
            }
        }
    } else {
        Collections.addAll(suitableTypes, extensions);
    }
    if (suitableTypes.isEmpty()) {
        return new AnAction[] { new CreateNewLibraryAction(text, PlatformIcons.LIBRARY_ICON, null, librariesConfigurable, project) };
    }
    List<AnAction> actions = new ArrayList<>();
    actions.add(new CreateNewLibraryAction(IdeBundle.message("create.default.library.type.action.name"), PlatformIcons.LIBRARY_ICON, null, librariesConfigurable, project));
    for (LibraryType<?> type : suitableTypes) {
        final String actionName = type.getCreateActionName();
        if (actionName != null) {
            actions.add(new CreateNewLibraryAction(actionName, type.getIcon(null), type, librariesConfigurable, project));
        }
    }
    return actions.toArray(new AnAction[actions.size()]);
}
Also used : ModuleStructureConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable) LibraryType(com.intellij.openapi.roots.libraries.LibraryType) ArrayList(java.util.ArrayList) ProjectLibrariesConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectLibrariesConfigurable) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

LibraryType (com.intellij.openapi.roots.libraries.LibraryType)2 AnAction (com.intellij.openapi.actionSystem.AnAction)1 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 OrderEntry (com.intellij.openapi.roots.OrderEntry)1 Library (com.intellij.openapi.roots.libraries.Library)1 LibraryEditingUtil (com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil)1 ModuleStructureConfigurable (com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable)1 ProjectLibrariesConfigurable (com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectLibrariesConfigurable)1 StructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext)1 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)1 ListPopup (com.intellij.openapi.ui.popup.ListPopup)1 ParameterizedRunnable (com.intellij.util.ParameterizedRunnable)1 ArrayList (java.util.ArrayList)1 javax.swing (javax.swing)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1