diff options
Diffstat (limited to 'java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor')
2 files changed, 81 insertions, 5 deletions
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java index 34bd02b84950..eb87df2a47e7 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java @@ -16,6 +16,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.codeInsight.ExternalAnnotationsManager; +import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; @@ -23,22 +24,22 @@ import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.projectRoots.ui.Util; import com.intellij.openapi.roots.AnnotationOrderRootType; import com.intellij.openapi.roots.JavadocOrderRootType; +import com.intellij.openapi.roots.NativeLibraryOrderRootType; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.ui.*; import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory; import com.intellij.openapi.roots.ui.configuration.PathUIUtils; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; import com.intellij.util.IconUtil; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import java.util.*; /** * @author nik @@ -63,7 +64,15 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen PathUIUtils.JAVA_SOURCE_ROOT_DETECTOR, new FileTypeBasedRootFilter(OrderRootType.SOURCES, true, StdFileTypes.JAVA, "source archive directory"), new JavadocRootDetector(), - new AnnotationsRootFilter()); + new AnnotationsRootFilter(), new NativeLibraryRootFilter()); + } + + @NotNull + @Override + public FileChooserDescriptor createAttachFilesChooserDescriptor(@Nullable String libraryName) { + FileChooserDescriptor descriptor = super.createAttachFilesChooserDescriptor(libraryName); + descriptor.setDescription(ProjectBundle.message("library.java.attach.files.description")); + return descriptor; } public static OrderRootTypePresentation getDefaultPresentation(OrderRootType type) { @@ -110,6 +119,27 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen } } + private static class NativeLibraryRootFilter extends RootFilter { + private static final Set<String> NATIVE_LIBRARY_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, "dll", "so", "dylib"); + + private NativeLibraryRootFilter() { + super(NativeLibraryOrderRootType.getInstance(), false, "external annotations"); + } + + @Override + public boolean isAccepted(@NotNull VirtualFile rootCandidate, @NotNull ProgressIndicator progressIndicator) { + if (rootCandidate.isDirectory()) { + for (VirtualFile file : rootCandidate.getChildren()) { + String extension = file.getExtension(); + if (extension != null && NATIVE_LIBRARY_EXTENSIONS.contains(extension)) { + return true; + } + } + } + return false; + } + } + private static class AttachUrlJavadocDescriptor extends AttachRootButtonDescriptor { private AttachUrlJavadocDescriptor() { super(JavadocOrderRootType.getInstance(), IconUtil.getAddLinkIcon(), ProjectBundle.message("module.libraries.javadoc.url.button")); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NativeLibraryOrderRootTypeUIFactory.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NativeLibraryOrderRootTypeUIFactory.java new file mode 100644 index 000000000000..85ddcc42405c --- /dev/null +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NativeLibraryOrderRootTypeUIFactory.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 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. + */ + +/* + * User: anna + * Date: 26-Dec-2007 + */ +package com.intellij.openapi.roots.ui.configuration.libraryEditor; + +import com.intellij.icons.AllIcons; +import com.intellij.openapi.project.ProjectBundle; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.ui.SdkPathEditor; +import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory; + +import javax.swing.*; + +public class NativeLibraryOrderRootTypeUIFactory implements OrderRootTypeUIFactory { + @Override + public Icon getIcon() { + return AllIcons.Nodes.NativeLibrariesFolder; + } + + @Override + public String getNodeText() { + return ProjectBundle.message("project.roots.native.library.node.text"); + } + + @Override + public SdkPathEditor createPathEditor(Sdk sdk) { + return null; + } +} |