com.intellij.openapi.roots.libraries.LibraryType Java Examples
The following examples show how to use
com.intellij.openapi.roots.libraries.LibraryType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LibraryGroupNode.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull static VirtualFile[] getLibraryRoots(@Nonnull LibraryOrderEntry orderEntry) { Library library = orderEntry.getLibrary(); if (library == null) return VirtualFile.EMPTY_ARRAY; OrderRootType[] rootTypes = LibraryType.getDefaultExternalRootTypes(); if (library instanceof LibraryEx) { if (((LibraryEx)library).isDisposed()) return VirtualFile.EMPTY_ARRAY; PersistentLibraryKind<?> libKind = ((LibraryEx)library).getKind(); if (libKind != null) { rootTypes = LibraryType.findByKind(libKind).getExternalRootTypes(); } } final ArrayList<VirtualFile> files = new ArrayList<VirtualFile>(); for (OrderRootType rootType : rootTypes) { files.addAll(Arrays.asList(library.getFiles(rootType))); } return VfsUtilCore.toVirtualFileArray(files); }
Example #2
Source File: FileOrDirectoryDependencyTabContext.java From consulo with Apache License 2.0 | 6 votes |
private Library createLibraryFromRoots(ModifiableModuleRootLayer layer, List<OrderRoot> roots, @Nullable final LibraryType libraryType) { final LibraryTable.ModifiableModel moduleLibraryModel = layer.getModuleLibraryTable().getModifiableModel(); final PersistentLibraryKind kind = libraryType == null ? null : libraryType.getKind(); final Library library = ((LibraryTableBase.ModifiableModelEx)moduleLibraryModel).createLibrary(null, kind); final LibraryEx.ModifiableModelEx libModel = (LibraryEx.ModifiableModelEx)library.getModifiableModel(); for (OrderRoot root : roots) { if (root.isJarDirectory()) { libModel.addJarDirectory(root.getFile(), false, root.getType()); } else { libModel.addRoot(root.getFile(), root.getType()); } } libModel.commit(); return library; }
Example #3
Source File: LibrariesContainerFactory.java From consulo with Apache License 2.0 | 6 votes |
@Override public Library createLibrary(@Nonnull NewLibraryEditor libraryEditor, @Nonnull LibraryLevel level) { LibraryTableModifiableModelProvider provider = getProvider(level); if (provider == null) { LOG.error("cannot create module library in this context"); } LibraryTableBase.ModifiableModelEx model = (LibraryTableBase.ModifiableModelEx)provider.getModifiableModel(); final LibraryType<?> type = libraryEditor.getType(); Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model), type == null ? null : type.getKind()); ExistingLibraryEditor createdLibraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library); createdLibraryEditor.setProperties(libraryEditor.getProperties()); libraryEditor.applyTo(createdLibraryEditor); return library; }
Example #4
Source File: LibraryRootsComponent.java From consulo with Apache License 2.0 | 6 votes |
public LibraryRootsComponent(@Nullable Project project, @Nonnull Computable<LibraryEditor> libraryEditorComputable) { myProject = project; myLibraryEditorComputable = libraryEditorComputable; final LibraryEditor editor = getLibraryEditor(); final LibraryType type = editor.getType(); if (type != null) { myDescriptor = type.createLibraryRootsComponentDescriptor(); //noinspection unchecked myPropertiesEditor = type.createPropertiesEditor(this); if (myPropertiesEditor != null) { myPropertiesPanel.add(myPropertiesEditor.createComponent(), BorderLayout.CENTER); } } if (myDescriptor == null) { myDescriptor = new DefaultLibraryRootsComponentDescriptor(); } init(new LibraryTreeStructure(this, myDescriptor)); updatePropertiesLabel(); onRootsChanged(); }
Example #5
Source File: CreateNewLibraryAction.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static NewLibraryConfiguration createNewLibraryConfiguration(@Nullable LibraryType type, @Nonnull JComponent parentComponent, @Nonnull Project project) { final NewLibraryConfiguration configuration; final VirtualFile baseDir = project.getBaseDir(); if (type != null) { configuration = type.createNewLibrary(parentComponent, baseDir, project); } else { configuration = LibraryTypeService.getInstance() .createLibraryFromFiles(new DefaultLibraryRootsComponentDescriptor(), parentComponent, baseDir, null, project); } if (configuration == null) return null; return configuration; }
Example #6
Source File: CreateNewLibraryAction.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static Library createLibrary(@Nullable final LibraryType type, @Nonnull final JComponent parentComponent, @Nonnull final Project project, @Nonnull final LibrariesModifiableModel modifiableModel) { final NewLibraryConfiguration configuration = createNewLibraryConfiguration(type, parentComponent, project); if (configuration == null) return null; final LibraryType<?> libraryType = configuration.getLibraryType(); final Library library = modifiableModel .createLibrary(LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()), libraryType != null ? libraryType.getKind() : null); final NewLibraryEditor editor = new NewLibraryEditor(libraryType, configuration.getProperties()); configuration.addRoots(editor); final Library.ModifiableModel model = library.getModifiableModel(); editor.applyTo((LibraryEx.ModifiableModelEx)model); WriteAction.run(model::commit); return library; }
Example #7
Source File: CreateNewLibraryDialog.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Library createLibrary() { final LibraryTableBase.ModifiableModelEx modifiableModel = (LibraryTableBase.ModifiableModelEx)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); WriteAction.run(model::commit); return library; }
Example #8
Source File: LibraryRootsComponent.java From consulo with Apache License 2.0 | 5 votes |
public void updatePropertiesLabel() { StringBuilder text = new StringBuilder(); final LibraryType<?> type = getLibraryEditor().getType(); final Set<LibraryKind> excluded = type != null ? Collections.<LibraryKind>singleton(type.getKind()) : Collections.<LibraryKind>emptySet(); for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(BinariesOrderRootType.getInstance()), excluded)) { if (text.length() > 0) { text.append("\n"); } text.append(description); } myPropertiesLabel.setText(text.toString()); }
Example #9
Source File: CreateNewLibraryAction.java From consulo with Apache License 2.0 | 5 votes |
public static AnAction[] createActionOrGroup(@Nonnull String text, @Nonnull BaseLibrariesConfigurable librariesConfigurable, final @Nonnull Project project) { final LibraryType<?>[] extensions = LibraryType.EP_NAME.getExtensions(); List<LibraryType<?>> suitableTypes = new ArrayList<LibraryType<?>>(); if (librariesConfigurable instanceof ProjectLibrariesConfigurable) { 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, AllIcons.Nodes.PpLib, null, librariesConfigurable, project)}; } List<AnAction> actions = new ArrayList<AnAction>(); actions.add(new CreateNewLibraryAction(IdeBundle.message("create.default.library.type.action.name"), AllIcons.Nodes.PpLib, null, librariesConfigurable, project)); for (LibraryType<?> type : suitableTypes) { final String actionName = type.getCreateActionName(); if (actionName != null) { actions.add(new CreateNewLibraryAction(actionName, type.getIcon(), type, librariesConfigurable, project)); } } return actions.toArray(new AnAction[actions.size()]); }
Example #10
Source File: CreateNewLibraryAction.java From consulo with Apache License 2.0 | 5 votes |
private CreateNewLibraryAction(@Nonnull String text, @Nullable Image icon, @Nullable LibraryType type, @Nonnull BaseLibrariesConfigurable librariesConfigurable, final @Nonnull Project project) { super(text, null, TargetAWT.to(icon)); myType = type; myLibrariesConfigurable = librariesConfigurable; myProject = project; }
Example #11
Source File: LibrariesContainerFactory.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Library createLibraryInTable(final @Nonnull NewLibraryEditor editor, final LibraryTable table) { LibraryTableBase.ModifiableModelEx modifiableModel = (LibraryTableBase.ModifiableModelEx) table.getModifiableModel(); final String name = StringUtil.isEmpty(editor.getName()) ? null : getUniqueLibraryName(editor.getName(), modifiableModel); final LibraryType<?> type = editor.getType(); Library library = modifiableModel.createLibrary(name, type == null ? null : type.getKind()); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel(); editor.applyTo(model); model.commit(); modifiableModel.commit(); return library; }
Example #12
Source File: FileOrDirectoryDependencyTabContext.java From consulo with Apache License 2.0 | 5 votes |
public FileOrDirectoryDependencyTabContext(Disposable parent, ClasspathPanel panel, StructureConfigurableContext context) { super(panel, context); myLibraryTypes = new HashMap<LibraryRootsComponentDescriptor, LibraryType>(); myDefaultDescriptor = new DefaultLibraryRootsComponentDescriptor(); for (LibraryType<?> libraryType : LibraryEditingUtil.getSuitableTypes(myClasspathPanel)) { LibraryRootsComponentDescriptor descriptor = null; if (libraryType != null) { descriptor = libraryType.createLibraryRootsComponentDescriptor(); } if (descriptor == null) { descriptor = myDefaultDescriptor; } if (!myLibraryTypes.containsKey(descriptor)) { myLibraryTypes.put(descriptor, libraryType); } } Module module = myClasspathPanel.getRootModel().getModule(); myFileChooserDescriptor = createFileChooserDescriptor(); myFileSystemTree = FileSystemTreeFactory.getInstance().createFileSystemTree(module.getProject(), myFileChooserDescriptor); Disposer.register(parent, myFileSystemTree); myFileSystemTree.showHiddens(true); final VirtualFile dirForSelect = ObjectUtil.chooseNotNull(module.getModuleDir(), module.getProject().getBaseDir()); if(dirForSelect != null) { myFileSystemTree.select(dirForSelect, new Runnable() { @Override public void run() { myFileSystemTree.expand(dirForSelect, null); } }); } }
Example #13
Source File: LibraryEditor.java From consulo with Apache License 2.0 | 4 votes |
@Nullable LibraryType<?> getType();
Example #14
Source File: MuleLibraryType.java From mule-intellij-plugins with Apache License 2.0 | 4 votes |
public static MuleLibraryType getInstance() { return (MuleLibraryType) LibraryType.findByKind(MuleLibraryKind.MULE_LIBRARY_KIND); }
Example #15
Source File: NewLibraryEditor.java From consulo with Apache License 2.0 | 4 votes |
@Override public void setType(@Nonnull LibraryType<?> type) { myType = type; }
Example #16
Source File: NewLibraryEditor.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nullable public LibraryType<?> getType() { return myType; }
Example #17
Source File: NewLibraryEditor.java From consulo with Apache License 2.0 | 4 votes |
public NewLibraryEditor(@Nullable LibraryType type, @Nullable LibraryProperties properties) { myType = type; myProperties = properties; myRoots = new MultiMap<>(); myExcludedRoots = new LinkedHashSet<>(); }
Example #18
Source File: LibraryKindLoader.java From consulo with Apache License 2.0 | 4 votes |
public LibraryKindLoader() { //todo[nik] this is temporary workaround for IDEA-98118: we need to initialize all library types to ensure that their kinds are created and registered in LibraryKind.ourAllKinds //In order to properly fix the problem we should extract all UI-related methods from LibraryType to a separate class and move LibraryType to projectModel-impl module LibraryType.EP_NAME.getExtensions(); }
Example #19
Source File: LibraryEditorBase.java From consulo with Apache License 2.0 | votes |
public abstract void setType(@Nonnull LibraryType<?> type);