Example usage for com.intellij.openapi.vfs JarFileSystem JAR_SEPARATOR

List of usage examples for com.intellij.openapi.vfs JarFileSystem JAR_SEPARATOR

Introduction

In this page you can find the example usage for com.intellij.openapi.vfs JarFileSystem JAR_SEPARATOR.

Prototype

String JAR_SEPARATOR

To view the source code for com.intellij.openapi.vfs JarFileSystem JAR_SEPARATOR.

Click Source Link

Usage

From source file:com.cfsoft.ofbiz.facet.ui.OfbizFilesTree.java

License:Apache License

public OfbizFilesTree() {
    super(new CheckboxTreeCellRendererBase() {

        public void customizeRenderer(final JTree tree, final Object value, final boolean selected,
                final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
            if (!(value instanceof DefaultMutableTreeNode))
                return;
            final ColoredTreeCellRenderer renderer = getTextRenderer();
            final Object object = ((DefaultMutableTreeNode) value).getUserObject();
            if (object instanceof Module) {
                final Module module = (Module) object;
                final Icon icon = ModuleType.get(module).getNodeIcon(expanded);
                renderer.setIcon(icon);//from w  ww  . j av a 2 s .  c o m
                final String moduleName = module.getName();
                renderer.append(moduleName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
            } else if (object instanceof PsiFile) {
                final PsiFile psiFile = (PsiFile) object;
                final Icon icon = psiFile.getIcon(0);
                renderer.setIcon(icon);
                final String fileName = psiFile.getName();
                renderer.append(fileName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
                final VirtualFile virtualFile = psiFile.getVirtualFile();
                if (virtualFile != null) {
                    String path = virtualFile.getPath();
                    final int i = path.indexOf(JarFileSystem.JAR_SEPARATOR);
                    if (i >= 0) {
                        path = path.substring(i + JarFileSystem.JAR_SEPARATOR.length());
                    }
                    renderer.append(" (" + path + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
                }
            } else if (object instanceof VirtualFile) {
                final VirtualFile file = (VirtualFile) object;
                renderer.setIcon(FileTypeManager.getInstance().getFileTypeByFile(file).getIcon());
                renderer.append(file.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
                String path = file.getPath();
                final int i = path.indexOf(JarFileSystem.JAR_SEPARATOR);
                if (i >= 0) {
                    path = path.substring(i + JarFileSystem.JAR_SEPARATOR.length());
                }
                renderer.append(" (" + path + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
            }
        }
    }, null);

    PeerFactory.getInstance().getUIHelper().installTreeSpeedSearch(this, new Convertor<TreePath, String>() {
        public String convert(final TreePath treePath) {
            final Object object = ((CheckedTreeNode) treePath.getLastPathComponent()).getUserObject();
            if (object instanceof Module) {
                return ((Module) object).getName();
            } else if (object instanceof PsiFile) {
                return ((PsiFile) object).getName();
            } else if (object instanceof VirtualFile) {
                return ((VirtualFile) object).getName();
            } else {
                return "";
            }
        }
    });
}

From source file:com.github.intelliguard.util.ObfuscatorUtils.java

License:Apache License

@Nullable
private static VirtualFile findJarFile(@NotNull final String jarPath) {
    return JarFileSystem.getInstance()
            .refreshAndFindFileByPath(FileUtil.toSystemIndependentName(jarPath) + JarFileSystem.JAR_SEPARATOR);
}

From source file:com.intellij.coldFusion.model.psi.CfmlJavaLoaderClassType.java

License:Apache License

public CfmlJavaLoaderClassType(PsiComment comment, Project project) {
    super(PsiAnnotation.EMPTY_ARRAY);
    final String text = comment.getText();

    myProject = project;//from  w  w  w.  j ava  2  s . c o  m
    Matcher javaLoaderMatcher = CfmlFile.LOADER_DECL_PATTERN_TEMP.matcher(text);
    mySearchScope = GlobalSearchScope.allScope(project);//EMPTY_SCOPE;

    if (javaLoaderMatcher.matches()) {
        Collection<String> collection = CfmlPsiUtil.findBetween(text, "loadPaths=\"", "\"");
        if (collection != null) {
            for (String str : collection) {
                VirtualFile file = JarFileSystem.getInstance()
                        .findFileByPath(str + JarFileSystem.JAR_SEPARATOR);
                if (file != null) {
                    mySearchScope = mySearchScope.uniteWith(new JarFileScope(file));
                }
            }
        }
    }
}

From source file:de.halirutan.mathematica.sdk.MathematicaSdkType.java

License:Open Source License

private static void addJLinkJars(SdkModificator sdkModificator, String homePath) {

    final JarFileSystem jarFileSystem = JarFileSystem.getInstance();
    String path = homePath.replace(File.separatorChar, '/') + "/SystemFiles/Links/JLink/JLink.jar"
            + JarFileSystem.JAR_SEPARATOR;
    jarFileSystem.setNoCopyJarForPath(path);
    VirtualFile vFile = jarFileSystem.findFileByPath(path);
    sdkModificator.addRoot(vFile, OrderRootType.CLASSES);
}

From source file:defrac.intellij.sdk.DefracVersion.java

License:Apache License

@NotNull
private List<VirtualFile> librariesOf(@NotNull final String[] names) {
    final VirtualFile lib = getLib();

    if (lib == null) {
        return Collections.emptyList();
    }/*ww w.  j a  v a2 s  .c  o m*/

    final List<VirtualFile> result = Lists.newLinkedList();

    for (final String name : names) {
        final VirtualFile file = lib.findChild(DefracBundle.message(name));

        if (file == null) {
            continue;
        }

        final VirtualFile jarRoot = JarFileSystem.getInstance()
                .findFileByPath(file.getPath() + JarFileSystem.JAR_SEPARATOR);

        if (jarRoot == null) {
            continue;
        }

        result.add(jarRoot);
    }

    return result;
}

From source file:org.clarent.ivyidea.resolve.dependency.ExternalDependency.java

License:Apache License

@NotNull
public String getUrlForLibrary() {
    return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, localFile.getAbsolutePath())
            + JarFileSystem.JAR_SEPARATOR;
}

From source file:org.codehaus.groovy.intellij.GroovyLibraryManager.java

License:Apache License

private void addJarFileToLibrary(File jarFile, Library.ModifiableModel libraryModel) {
    String url = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL,
            jarFile.getAbsolutePath() + JarFileSystem.JAR_SEPARATOR);
    libraryModel.addRoot(url, OrderRootType.CLASSES);
}

From source file:org.f3.ideaplugin.F3Compiler.java

License:Open Source License

private static String path2string(List<VirtualFile> pathEntries) {
    StringBuffer buffer = new StringBuffer();
    for (VirtualFile entry : pathEntries) {
        if (buffer.length() != 0)
            buffer.append(File.pathSeparator);
        String path = entry.getPath();
        int jarSeparatorIndex = path.indexOf(JarFileSystem.JAR_SEPARATOR);
        if (jarSeparatorIndex > 0)
            path = path.substring(0, jarSeparatorIndex);
        buffer.append(path);/* ww w  . ja  va  2 s.c  o m*/
    }
    return buffer.toString();
}

From source file:org.f3.ideaplugin.project.F3SdkType.java

License:Open Source License

public void setupSdkPaths(Sdk sdk) {
    SdkModificator modificator = sdk.getSdkModificator();
    modificator.removeAllRoots();/*from w ww . j  av  a2  s. c  om*/
    LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
    JarFileSystem jarFileSystem = JarFileSystem.getInstance();

    VirtualFile lib = localFileSystem.findFileByPath(getLibraryPath(sdk).replace(File.separatorChar, '/'));
    if (lib != null) {
        for (VirtualFile libFile : lib.getChildren()) {
            if (libFile.getName().endsWith(".jar")) {
                VirtualFile inJar = jarFileSystem
                        .findFileByPath(libFile.getPath() + JarFileSystem.JAR_SEPARATOR);
                if (inJar != null)
                    modificator.addRoot(inJar, ProjectRootType.CLASS);
            }
        }
    }

    VirtualFile doc = LocalFileSystem.getInstance()
            .findFileByPath(getJavaDocPath(sdk).replace(File.separatorChar, '/'));
    if (doc != null) {
        for (VirtualFile docFile : doc.getChildren()) {
            if (docFile.isDirectory()
                    && localFileSystem.findFileByPath(docFile.getPath() + "/index.html") != null) {
                modificator.addRoot(docFile, ProjectRootType.JAVADOC);
            }
        }
    }

    F3SdkAdditionalData data = (F3SdkAdditionalData) sdk.getSdkAdditionalData();
    if (data != null) {
        Sdk javaSdk = data.findSdk();
        if (javaSdk != null) {
            SdkModificator javaModificator = javaSdk.getSdkModificator();
            if (javaModificator != null) {
                for (ProjectRootType type : EnumSet.of(ProjectRootType.SOURCE, ProjectRootType.CLASS,
                        ProjectRootType.JAVADOC)) { // ProjectRootType.values()
                    VirtualFile[] roots = javaModificator.getRoots(type);
                    if (roots != null)
                        for (VirtualFile root : roots)
                            modificator.addRoot(root, type);
                }
            }
        }
    }
    modificator.commitChanges();
}

From source file:org.intellij.grammar.actions.BnfRunJFlexAction.java

License:Apache License

private static boolean collectFiles(List<File> result, List<String> roots, String... urls) {
    main: for (int i = 0; i < urls.length; i++) {
        String url = urls[i];//from   w  w w  .  j a  v  a2 s .c  o m
        String name = url.substring(url.lastIndexOf("/") + 1);

        for (String root : roots) {
            root = StringUtil.trimEnd(root, JarFileSystem.JAR_SEPARATOR);
            String rootName = root.substring(root.lastIndexOf("/") + 1);
            int length = StringUtil
                    .commonPrefix(rootName.toLowerCase(Locale.ENGLISH), name.toLowerCase(Locale.ENGLISH))
                    .length();
            if (length < 4)
                continue;
            if (rootName.length() == length
                    || rootName.length() > length && "-_.".indexOf(rootName.charAt(length)) > -1) {
                File file = new File(FileUtil.toSystemDependentName(VfsUtil.urlToPath(root)));
                if (file.exists() && file.isFile()) {
                    result.add(file);
                    continue main;
                }
            }
        }
        if (result.size() < i)
            break;
    }
    if (result.size() == urls.length)
        return true;
    result.clear();
    return false;
}