Search in sources :

Example 81 with Library

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

the class CreateNewLibraryAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Library library = createLibrary(myType, myLibrariesConfigurable.getTree(), myProject, myLibrariesConfigurable.getModelProvider().getModifiableModel());
    if (library == null)
        return;
    final BaseLibrariesConfigurable rootConfigurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
    final DefaultMutableTreeNode libraryNode = MasterDetailsComponent.findNodeByObject((TreeNode) rootConfigurable.getTree().getModel().getRoot(), library);
    rootConfigurable.selectNodeInTree(libraryNode);
    LibraryEditingUtil.showDialogAndAddLibraryToDependencies(library, myProject, true);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Library(com.intellij.openapi.roots.libraries.Library) BaseLibrariesConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.BaseLibrariesConfigurable)

Example 82 with Library

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

the class CreateNewLibraryDialog method createLibrary.

@NotNull
public Library createLibrary() {
    final LibraryTable.ModifiableModel modifiableModel = getTableModifiableModel();
    final LibraryType<?> type = myLibraryEditor.getType();
    final Library library = modifiableModel.createLibrary(myLibraryEditor.getName(), type != null ? type.getKind() : null);
    final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx) library.getModifiableModel();
    myLibraryEditor.applyTo(model);
    new WriteAction() {

        @Override
        protected void run(@NotNull final Result result) {
            model.commit();
        }
    }.execute();
    return library;
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) WriteAction(com.intellij.openapi.application.WriteAction) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) Library(com.intellij.openapi.roots.libraries.Library) Result(com.intellij.openapi.application.Result) NotNull(org.jetbrains.annotations.NotNull)

Example 83 with Library

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

the class AddNewLibraryDependencyAction method doCreateLibrary.

private static void doCreateLibrary(ClasspathPanel classpathPanel, StructureConfigurableContext context, LibraryCreatedCallback callback, final JComponent component, @Nullable final LibraryType libraryType) {
    final NewLibraryChooser chooser = new NewLibraryChooser(classpathPanel.getProject(), classpathPanel.getRootModel(), libraryType, context, component);
    final Library library = chooser.createLibrary();
    if (library != null) {
        callback.libraryCreated(library);
    }
}
Also used : Library(com.intellij.openapi.roots.libraries.Library)

Example 84 with Library

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

the class ChangeLibraryLevelInClasspathAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    final OrderEntry entry = myPanel.getSelectedEntry();
    if (!(entry instanceof LibraryOrderEntry))
        return;
    LibraryOrderEntry libraryEntry = (LibraryOrderEntry) entry;
    final LibraryEx library = (LibraryEx) libraryEntry.getLibrary();
    if (library == null)
        return;
    final Library copied = doCopy(library);
    if (copied == null)
        return;
    if (!isConvertingToModuleLibrary()) {
        OrderEntryUtil.replaceLibrary(myPanel.getRootModel(), library, copied);
    } else {
        OrderEntryUtil.replaceLibraryEntryByAdded(myPanel.getRootModel(), libraryEntry);
    }
}
Also used : LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library)

Example 85 with Library

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

the class ClasspathPanelImpl method doEdit.

private void doEdit() {
    final OrderEntry entry = getSelectedEntry();
    if (!(entry instanceof LibraryOrderEntry))
        return;
    final Library library = ((LibraryOrderEntry) entry).getLibrary();
    if (library == null) {
        return;
    }
    final LibraryTable table = library.getTable();
    final String tableLevel = table != null ? table.getTableLevel() : LibraryTableImplUtil.MODULE_LEVEL;
    final LibraryTablePresentation presentation = LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
    final LibraryTableModifiableModelProvider provider = getModifiableModelProvider(tableLevel);
    EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(this, provider, library, myState.getProject(), presentation, getStructureConfigurableContext());
    dialog.setContextModule(getRootModel().getModule());
    dialog.show();
    myEntryTable.repaint();
    ModuleStructureConfigurable.getInstance(myState.getProject()).getTree().repaint();
}
Also used : LibraryTablePresentation(com.intellij.openapi.roots.libraries.LibraryTablePresentation) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) EditExistingLibraryDialog(com.intellij.openapi.roots.ui.configuration.libraryEditor.EditExistingLibraryDialog) Library(com.intellij.openapi.roots.libraries.Library) LibraryTableModifiableModelProvider(com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider)

Aggregations

Library (com.intellij.openapi.roots.libraries.Library)240 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)58 VirtualFile (com.intellij.openapi.vfs.VirtualFile)58 Module (com.intellij.openapi.module.Module)41 NotNull (org.jetbrains.annotations.NotNull)31 File (java.io.File)29 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)25 Nullable (org.jetbrains.annotations.Nullable)25 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)23 Project (com.intellij.openapi.project.Project)22 ProjectLibraryTable (com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable)20 ArrayList (java.util.ArrayList)15 Sdk (com.intellij.openapi.projectRoots.Sdk)13 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)13 OrderEntry (com.intellij.openapi.roots.OrderEntry)10 THashSet (gnu.trove.THashSet)9 IOException (java.io.IOException)9 Element (org.jdom.Element)9 OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)8 LibrariesContainer (com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer)7