List of usage examples for com.intellij.openapi.vfs JarFileSystem PROTOCOL
String PROTOCOL
To view the source code for com.intellij.openapi.vfs JarFileSystem PROTOCOL.
Click Source Link
From source file:com.intellij.testFramework.PsiTestUtil.java
License:Apache License
public static void addLibrary(final Module module, final String libName, final String libDir, final String[] classRoots, final String[] sourceRoots) { final String parentUrl = VirtualFileManager.constructUrl( classRoots[0].endsWith(".jar!/") ? JarFileSystem.PROTOCOL : LocalFileSystem.PROTOCOL, libDir); List<String> classesUrls = new ArrayList<String>(); List<String> sourceUrls = new ArrayList<String>(); for (String classRoot : classRoots) { classesUrls.add(parentUrl + classRoot); }/*w ww. j a v a 2s . c om*/ for (String sourceRoot : sourceRoots) { sourceUrls.add(parentUrl + sourceRoot); } ModuleRootModificationUtil.addModuleLibrary(module, libName, classesUrls, sourceUrls); }
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.codehaus.groovy.intellij.GroovyLibraryManagerTest.java
License:Apache License
private void configureGroovyLibraryWithPluginJarFiles(Mock mockLibraryModel) { mockLibraryModel.stubs().method("addRoot").with(startsWith(JarFileSystem.PROTOCOL), same(OrderRootType.CLASSES)); mockLibraryModel.expects(once()).method("commit"); }
From source file:org.jetbrains.android.maven.AndroidFacetImporterBase.java
License:Apache License
private static void updateUrl(@NotNull Library.ModifiableModel library, @NotNull String path) { final OrderRootType type = OrderRootType.CLASSES; final String newUrl = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, path) + JarFileSystem.JAR_SEPARATOR; boolean urlExists = false; for (String url : library.getUrls(type)) { if (newUrl.equals(url)) { urlExists = true;/*ww w . ja va2 s.co m*/ } else { library.removeRoot(url, type); } } if (!urlExists) { library.addRoot(newUrl, type); } }
From source file:org.moe.idea.utils.ModuleObserver.java
License:Apache License
private void addMOEDependencies(@NotNull final Module module) { final String home = MOESdkPlugin.getSdkRootPath(module); if (home == null || home.isEmpty()) { LOG.debug("Unable to find MOE home"); return;// w w w .j ava 2s . co m } ApplicationManager.getApplication().runWriteAction(new DumbAwareRunnable() { @Override public void run() { for (String jar : MOE_JARS) { String jarPath = home + File.separator + MOE_JARS_PATH + File.separator + jar; VirtualFile file = LocalFileSystem.getInstance().findFileByPath(jarPath); if (file == null) { return; } final ModuleRootManager manager = ModuleRootManager.getInstance(module); final ModifiableRootModel rootModel = manager.getModifiableModel(); final Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary(); final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel(); libraryModel.setName("Maven: " + jar); String url = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, jarPath) + JarFileSystem.JAR_SEPARATOR; libraryModel.addRoot(url, OrderRootType.CLASSES); libraryModel.commit(); final LibraryOrderEntry orderEntry = rootModel.findLibraryOrderEntry(jarLibrary); orderEntry.setScope(DependencyScope.COMPILE); rootModel.commit(); } checkRunConfiguration(module.getProject(), module); } }); }
From source file:org.moe.idea.utils.ModuleObserver.java
License:Apache License
private void checkMOEDependencies(@NotNull final Module module) { final String home = MOESdkPlugin.getSdkRootPath(module); if (home == null || home.isEmpty()) { LOG.debug("Unable to find MOE home"); return;/* w w w. j a v a 2 s. co m*/ } ModuleRootManager manager = ModuleRootManager.getInstance(module); final ModifiableRootModel rootModel = manager.getModifiableModel(); final LibraryTable libraryTable = rootModel.getModuleLibraryTable(); ApplicationManager.getApplication().runWriteAction(new DumbAwareRunnable() { @Override public void run() { for (String jar : MOE_JARS) { Library library = libraryTable.getLibraryByName("Maven: " + jar); if (library != null) { String jarPath = home + File.separator + MOE_JARS_PATH + File.separator + jar; String[] urls = library.getUrls(OrderRootType.CLASSES); if (urls.length > 0) { String url = urls[0]; String newUrl = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, jarPath) + JarFileSystem.JAR_SEPARATOR; if (!url.equals(newUrl)) { final Library.ModifiableModel libraryModel = library.getModifiableModel(); libraryModel.removeRoot(url, OrderRootType.CLASSES); libraryModel.addRoot(newUrl, OrderRootType.CLASSES); libraryModel.commit(); } } } } rootModel.commit(); } }); }
From source file:org.napile.idea.thermit.doc.AntDomDocumentationProvider.java
License:Apache License
@Nullable private static VirtualFile getHelpFile(final PsiElement element) { final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class); if (xmlTag == null) { return null; }//from www .j a va 2 s . c o m final AntDomElement antElement = ThermitSupport.getAntDomElement(xmlTag); if (antElement == null) { return null; } final AntDomProject antProject = antElement.getAntProject(); if (antProject == null) { return null; } final AntInstallation installation = antProject.getAntInstallation(); if (installation == null) { return null; // not configured properly and bundled installation missing } final String antHomeDir = AntInstallation.HOME_DIR.get(installation.getProperties()); if (antHomeDir == null) { return null; } @NonNls String path = antHomeDir + "/docs/manual"; String url; if (new File(path).exists()) { url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(path)); } else { path = antHomeDir + "/docs.zip"; if (new File(path).exists()) { url = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(path) + JarFileSystem.JAR_SEPARATOR + "docs/manual"); } else { return null; } } final VirtualFile documentationRoot = VirtualFileManager.getInstance().findFileByUrl(url); if (documentationRoot == null) { return null; } return getHelpFile(antElement, documentationRoot); }