本文整理汇总了Java中com.intellij.openapi.roots.impl.libraries.LibraryEx类的典型用法代码示例。如果您正苦于以下问题:Java LibraryEx类的具体用法?Java LibraryEx怎么用?Java LibraryEx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LibraryEx类属于com.intellij.openapi.roots.impl.libraries包,在下文中一共展示了LibraryEx类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMuleHome
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Nullable
private static String getMuleHome(@NotNull Module module) {
if (!DumbService.isDumb(module.getProject())) {
final OrderEnumerator enumerator = ModuleRootManager.getInstance(module)
.orderEntries().recursively().librariesOnly().exportedOnly();
final String[] home = new String[1];
enumerator.forEachLibrary(library -> {
if (MuleLibraryKind.MULE_LIBRARY_KIND.equals(((LibraryEx) library).getKind()) &&
library.getFiles(OrderRootType.CLASSES) != null &&
library.getFiles(OrderRootType.CLASSES).length > 0) {
home[0] = getMuleHome(library.getFiles(OrderRootType.CLASSES)[0]);
return false;
} else {
return true;
}
});
return home[0];
}
return null;
}
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:22,代码来源:MuleSdk.java
示例2: testRemoveExcludedRootWhenParentRootIsRemoved
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
public void testRemoveExcludedRootWhenParentRootIsRemoved() {
VirtualFile jar = getJDomJar();
LibraryEx library = (LibraryEx)createLibrary("junit", jar, null);
LibraryEx.ModifiableModelEx model = library.getModifiableModel();
VirtualFile excluded = jar.findChild("org");
assertNotNull(excluded);
model.addExcludedRoot(excluded.getUrl());
commit(model);
assertOrderedEquals(library.getExcludedRoots(), excluded);
LibraryEx.ModifiableModelEx model2 = library.getModifiableModel();
model2.removeRoot(jar.getUrl(), OrderRootType.CLASSES);
commit(model2);
assertEmpty(library.getExcludedRoots());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LibraryTest.java
示例3: showDialogAndAddLibraryToDependencies
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
public static void showDialogAndAddLibraryToDependencies(final Library library, final Project project, boolean allowEmptySelection) {
for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
return;
}
}
final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
final List<Module> modules =
LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library);
if (modules.isEmpty()) return;
final ChooseModulesDialog
dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"),
ProjectBundle
.message("choose.modules.dialog.description", library.getName()));
if (dlg.showAndGet()) {
final List<Module> chosenModules = dlg.getChosenElements();
for (Module module : chosenModules) {
moduleStructureConfigurable.addLibraryOrderEntry(module, library);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ProjectStructureValidator.java
示例4: actionPerformed
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
final Object o = getSelectedObject();
if (o instanceof LibraryEx) {
final LibraryEx selected = (LibraryEx)o;
final String newName = Messages.showInputDialog("Enter library name:", "Copy Library", null, selected.getName() + "2", new NonEmptyInputValidator());
if (newName == null) return;
BaseLibrariesConfigurable configurable = BaseLibrariesConfigurable.this;
final LibraryEx library = (LibraryEx)myContext.getLibrary(selected.getName(), myLevel);
LOG.assertTrue(library != null);
final LibrariesModifiableModel libsModel = configurable.getModelProvider().getModifiableModel();
final Library lib = libsModel.createLibrary(newName, library.getKind());
final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)libsModel.getLibraryEditor(lib).getModel();
LibraryEditingUtil.copyLibrary(library, Collections.<String, String>emptyMap(), model);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:BaseLibrariesConfigurable.java
示例5: createLibrary
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Nullable
public static Library createLibrary(@Nullable final LibraryType type, @NotNull final JComponent parentComponent,
@NotNull final Project project, @NotNull 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);
AccessToken token = WriteAction.start();
try {
model.commit();
}
finally {
token.finish();
}
return library;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CreateNewLibraryAction.java
示例6: render
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Override
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes,
SimpleTextAttributes commentAttributes) {
final String name = myLibrary.getName();
if (name != null) {
presentationData.setIcon(PlatformIcons.LIBRARY_ICON);
presentationData.addText(name, mainAttributes);
presentationData.addText(LibraryElementPresentation.getLibraryTableComment(myLibrary), commentAttributes);
}
else {
if (((LibraryEx)myLibrary).isDisposed()) {
//todo[nik] disposed library should not be shown in the tree
presentationData.addText("Invalid Library", SimpleTextAttributes.ERROR_ATTRIBUTES);
return;
}
final VirtualFile[] files = myLibrary.getFiles(OrderRootType.CLASSES);
if (files.length > 0) {
final VirtualFile file = files[0];
presentationData.setIcon(VirtualFilePresentation.getIcon(file));
presentationData.addText(file.getName(), mainAttributes);
}
else {
presentationData.addText("Empty Library", SimpleTextAttributes.ERROR_ATTRIBUTES);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LibrarySourceItem.java
示例7: actionPerformed
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ChangeLibraryLevelInClasspathAction.java
示例8: createLibraryFromRoots
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
private Library createLibraryFromRoots(List<OrderRoot> roots, @Nullable final LibraryType libraryType) {
final PersistentLibraryKind kind = libraryType == null ? null : libraryType.getKind();
final Library library = myModuleLibrariesModel.createLibrary(null, kind);
final LibraryEx.ModifiableModelEx libModel = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
if (myDefaultPropertiesFactory != null) {
libModel.setProperties(myDefaultPropertiesFactory.fun(libraryType));
}
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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CreateModuleLibraryChooser.java
示例9: getTooltipText
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Override
public String getTooltipText() {
if (myEntry == null) return null;
final Library library = myEntry.getLibrary();
if (library == null) return null;
final String name = library.getName();
if (name != null) {
final List<String> invalidUrls = ((LibraryEx)library).getInvalidRootUrls(OrderRootType.CLASSES);
if (!invalidUrls.isEmpty()) {
return ProjectBundle.message("project.roots.tooltip.library.has.broken.paths", name, invalidUrls.size());
}
}
final List<String> descriptions = LibraryPresentationManager.getInstance().getDescriptions(library, myContext);
if (descriptions.isEmpty()) return null;
return XmlStringUtil.wrapInHtml(StringUtil.join(descriptions, "<br>"));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LibraryItem.java
示例10: getPresentableName
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@NotNull
@Override
public String getPresentableName() {
final String name = myLibrary.getName();
if (name != null) {
return name;
}
else {
if (myLibrary instanceof LibraryEx && ((LibraryEx)myLibrary).isDisposed()) {
return "<unknown>";
}
final String[] urls = myLibrary.getUrls(OrderRootType.CLASSES);
if (urls.length > 0) {
String url = urls[0];
return PathUtil.toPresentableUrl(url);
}
else {
return ProjectBundle.message("library.empty.library.item");
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ModuleLibraryOrderEntryImpl.java
示例11: getLibraryRoots
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@NotNull
public static VirtualFile[] getLibraryRoots(@NotNull LibraryOrderEntry orderEntry) {
Library library = orderEntry.getLibrary();
if (library == null) return VirtualFile.EMPTY_ARRAY;
OrderRootType[] rootTypes = LibraryType.DEFAULT_EXTERNAL_ROOT_TYPES;
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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LibraryGroupNode.java
示例12: createNewLibrary
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
private LibraryEx createNewLibrary(@NotNull final Module module, final LibraryTable.ModifiableModel modifiableModel) {
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(
libraryDescription.getGroupId(),
libraryDescription.getArtifactId(),
model.getVersion());
final LibraryEx library = (LibraryEx)modifiableModel.createLibrary(
LibraryEditingUtil.suggestNewLibraryName(modifiableModel, RepositoryLibraryType.getInstance().getDescription(libraryProperties)),
RepositoryLibraryType.REPOSITORY_LIBRARY_KIND);
RepositoryLibraryProperties realLibraryProperties = (RepositoryLibraryProperties)library.getProperties();
realLibraryProperties.setMavenId(libraryProperties.getMavenId());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
modifiableModel.commit();
}
});
RepositoryUtils.loadDependencies(
module.getProject(),
library,
model.isDownloadSources(),
model.isDownloadJavaDocs(),
null);
return library;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:RepositoryLibrarySupport.java
示例13: isLibraryEqualsToSelected
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
private boolean isLibraryEqualsToSelected(Library library) {
if (!(library instanceof LibraryEx)) {
return false;
}
LibraryEx libraryEx = (LibraryEx)library;
if (!RepositoryLibraryType.REPOSITORY_LIBRARY_KIND.equals(libraryEx.getKind())) {
return false;
}
LibraryProperties libraryProperties = libraryEx.getProperties();
if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
return false;
}
RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties)libraryProperties;
RepositoryLibraryDescription description = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);
if (!description.equals(libraryDescription)) {
return false;
}
return Comparing.equal(repositoryLibraryProperties.getVersion(), model.getVersion());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RepositoryLibrarySupport.java
示例14: getDefaultDependencyScope
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Nullable
@Override
public DependencyScope getDefaultDependencyScope(@NotNull Library library) {
if (!(library instanceof LibraryEx)) {
return null;
}
LibraryEx libraryEx = (LibraryEx)library;
LibraryProperties libraryProperties = libraryEx.getProperties();
if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
return null;
}
RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties)libraryProperties;
RepositoryLibraryDescription libraryDescription = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);
return libraryDescription.getSuggestedScope();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RepositoryLibraryDependencyScopeSuggester.java
示例15: isLibraryNeedToBeReloaded
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
private static boolean isLibraryNeedToBeReloaded(LibraryEx library, RepositoryLibraryProperties properties) {
String version = properties.getVersion();
if (version == null) {
return false;
}
if (version.equals(RepositoryUtils.LatestVersionId)
|| version.equals(RepositoryUtils.ReleaseVersionId)
|| version.endsWith(RepositoryUtils.SnapshotVersionSuffix)) {
return true;
}
for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
if (library.getFiles(orderRootType).length != library.getUrls(orderRootType).length) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:RepositoryLibrarySynchronizer.java
示例16: testAppEngine_defaultManagedLibrariesSelected
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
public void testAppEngine_defaultManagedLibrariesSelected() {
AppEngineStandardLibraryPanel libraryPanel =
new AppEngineStandardLibraryPanel(true /*enabled*/);
LibraryEx library = mock(LibraryEx.class);
when(library.getTable()).thenReturn(ProjectLibraryTable.getInstance(myModule.getProject()));
when(library.getExcludedRoots()).thenReturn(new VirtualFile[0]);
when(library.getName()).thenReturn("javax.servlet:servlet-api:2.5");
setupAppEngine(libraryPanel, library);
addSupport();
assertNull(FacetManager.getInstance(myModule).getFacetByType(WebFacet.ID));
final String moduleName = myModule.getName();
ArtifactsTestUtil.assertLayout(
myProject,
moduleName,
"<root>\n"
+ " WEB-INF/\n"
+ " classes/\n"
+ " module:"
+ moduleName
+ "\n"
+ " lib/\n"
+ " lib:javax.servlet:servlet-api:2.5(project)\n");
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:27,代码来源:AppEngineStandardSupportProviderTest.java
示例17: showDialogAndAddLibraryToDependencies
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
public static void showDialogAndAddLibraryToDependencies(final Library library, final Project project, boolean allowEmptySelection) {
for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
return;
}
}
final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
final List<Module> modules = LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library);
if (modules.isEmpty()) return;
final ChooseModulesDialog
dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"),
ProjectBundle
.message("choose.modules.dialog.description", library.getName()));
dlg.show();
if (dlg.isOK()) {
final List<Module> chosenModules = dlg.getChosenElements();
for (Module module : chosenModules) {
moduleStructureConfigurable.addLibraryOrderEntry(module, library);
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:ProjectStructureValidator.java
示例18: actionPerformed
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final ProjectStructureElement selectedElement = mySourceConfigurable.getSelectedElement();
if (!(selectedElement instanceof LibraryProjectStructureElement)) return;
final StructureConfigurableContext context = mySourceConfigurable.myContext;
final LibraryProjectStructureElement libraryElement = (LibraryProjectStructureElement)selectedElement;
final LibraryEx oldLibrary = (LibraryEx)context.getLibrary(libraryElement.getLibrary().getName(), mySourceConfigurable.getLevel());
LOG.assertTrue(oldLibrary != null);
final Library newLibrary = doCopy(oldLibrary);
if (newLibrary == null) return;
final Collection<ProjectStructureElementUsage> usages = context.getDaemonAnalyzer().getUsages(libraryElement);
for (ProjectStructureElementUsage usage : usages) {
usage.replaceElement(new LibraryProjectStructureElement(context, newLibrary));
}
if (!myCopy) {
mySourceConfigurable.removeLibrary(libraryElement);
}
ProjectStructureConfigurable.getInstance(myProject).selectProjectOrGlobalLibrary(newLibrary, true);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:ChangeLibraryLevelAction.java
示例19: createLibrary
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
@Nullable
public static Library createLibrary(@Nullable final LibraryType type, @NotNull final JComponent parentComponent,
@NotNull final Project project, @NotNull 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);
AccessToken token = WriteAction.start();
try {
model.commit();
}
finally {
token.finish();
}
return library;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:CreateNewLibraryAction.java
示例20: createLibraryFromRoots
import com.intellij.openapi.roots.impl.libraries.LibraryEx; //导入依赖的package包/类
private Library createLibraryFromRoots(List<OrderRoot> roots, @Nullable final LibraryType libraryType) {
final PersistentLibraryKind kind = libraryType == null ? null : libraryType.getKind();
final Library library = ((LibraryTableBase.ModifiableModelEx)myModuleLibrariesModel).createLibrary(null, kind);
final LibraryEx.ModifiableModelEx libModel = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
if (myDefaultPropertiesFactory != null) {
libModel.setProperties(myDefaultPropertiesFactory.fun(libraryType));
}
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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:CreateModuleLibraryChooser.java
注:本文中的com.intellij.openapi.roots.impl.libraries.LibraryEx类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论