org.openide.modules.InstalledFileLocator Java Examples

The following examples show how to use org.openide.modules.InstalledFileLocator. 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: SetupUtil.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void commonSetUp(File workingDir) throws Exception {
    File testuserdir = new File(workingDir.getParentFile(), "testuser");
    System.getProperties().setProperty("netbeans.user", testuserdir.getAbsolutePath());
    SaasServicesModelTest.resetSaasServicesModel();
    FileObject websvcHome = SaasServicesModel.getWebServiceHome();
    File userconfig = FileUtil.toFile(websvcHome.getParent());
    MainFS fs = new MainFS();
    fs.setConfigRootDir(userconfig);
    TestRepository.defaultFileSystem = fs;
    
    MockServices.setServices(DialogDisplayerNotifier.class, InstalledFileLocatorImpl.class, TestRepository.class);
    
    InstalledFileLocatorImpl locator = (InstalledFileLocatorImpl)Lookup.getDefault().lookup(InstalledFileLocator.class);
    locator.setUserConfigRoot(userconfig);
    
    File targetBuildProperties = new File(testuserdir, "build.properties");
    generatePropertiesFile(targetBuildProperties);
    
}
 
Example #2
Source File: JBJ2eePlatformFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public File[] getToolClasspathEntries(String toolName) {
    if (J2eePlatform.TOOL_WSIMPORT.equals(toolName)) {
        return getJaxWsLibraries();
    }
    if (J2eePlatform.TOOL_WSGEN.equals(toolName)) {
        return getJaxWsLibraries();
    }
    if (J2eePlatform.TOOL_WSCOMPILE.equals(toolName)) {
        File root = InstalledFileLocator.getDefault().locate("modules/ext/jaxrpc16", null, false); // NOI18N
        return new File[] {
            new File(root, "saaj-api.jar"),     // NOI18N
            new File(root, "saaj-impl.jar"),    // NOI18N
            new File(root, "jaxrpc-api.jar"),   // NOI18N
            new File(root, "jaxrpc-impl.jar"),  // NOI18N
        };
    }
    if (J2eePlatform.TOOL_APP_CLIENT_RUNTIME.equals(toolName)) {
        return new File(properties.getRootDir(), "client").listFiles(new FF()); // NOI18N
    }
    return null;
}
 
Example #3
Source File: MavenCommandLineExecutor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void injectEventSpy(final BeanRunConfig clonedConfig) {
    //TEMP 
    String mavenPath = clonedConfig.getProperties().get(CosChecker.MAVENEXTCLASSPATH);
    File jar = InstalledFileLocator.getDefault().locate("maven-nblib/netbeans-eventspy.jar", "org.netbeans.modules.maven", false);
    if (mavenPath == null) {
        mavenPath = "";
    } else {
        String delimiter = Utilities.isWindows() ? ";" : ":";
        if(mavenPath.contains(jar + delimiter)) {
            // invoked by output view > rerun? see also issue #249971
            return;
        }
        mavenPath = delimiter + mavenPath;
    }
    //netbeans-eventspy.jar comes first on classpath
    mavenPath = jar.getAbsolutePath() + mavenPath;
    clonedConfig.setProperty(CosChecker.MAVENEXTCLASSPATH, mavenPath);
}
 
Example #4
Source File: NbStartUtility.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected File getLocalFile(final HostInfo hostInfo) throws MissingResourceException {
    String osname = hostInfo.getOS().getFamily().cname();
    String platform = hostInfo.getCpuFamily().name().toLowerCase();
    String bitness = hostInfo.getOS().getBitness() == HostInfo.Bitness._64 ? "_64" : ""; // NOI18N

    // This method is called while HostInfo initialization so we cannot
    // use MacroExpander here (the same is for parent methods)
    InstalledFileLocator fl = InstalledFileLocatorProvider.getDefault();
    StringBuilder path = new StringBuilder("bin/nativeexecution/"); // NOI18N
    path.append(osname).append('-').append(platform).append(bitness).append("/pty"); // NOI18N

    File file = fl.locate(path.toString(), codeNameBase, false);

    if (file == null || !file.exists()) {
        throw new MissingResourceException(path.toString(), null, null);
    }

    return file;
}
 
Example #5
Source File: DictionaryInstallerPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void removeDictionary(Locale remove) {
    File toRemove = dictionaryFile(remove.toString(), false);

    toRemove.delete();
    toRemove = dictionaryFile(remove.toString(), true);
    toRemove.delete();

    if (InstalledFileLocator.getDefault().locate("modules/dict/dictionary_" + remove.toString() + ".description", null, false) != null) {
        String filename = userdir;

        filename += File.separator + "modules" + File.separator + "dict"; // NOI18N
        filename += File.separator + "dictionary";
        filename += "_" + remove.toString();

        File hiddenDictionaryFile = new File(filename + ".description_hidden");

        hiddenDictionaryFile.getParentFile().mkdirs();

        try {
            new FileOutputStream(hiddenDictionaryFile).close(); // NOI18N
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
 
Example #6
Source File: ClassPathProviderImplTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void doTestCompileCP() {
    File fakeJdkClasses = InstalledFileLocator.getDefault().locate("modules/ext/fakeJdkClasses.zip", "org.netbeans.modules.java.openjdk.project", false);

    checkCompileClassPath("repo/src/test1",
                          "${wd}/jdk/src/java.base/fake-target.jar" +
                          File.pathSeparatorChar +
                          "${wd}/langtools/src/java.compiler/fake-target.jar" +
                          File.pathSeparatorChar +
                          fakeJdkClasses.getAbsolutePath());
    checkCompileClassPath("repo/src/test2",
                          "${wd}/jdk/src/java.base/fake-target.jar" +
                          File.pathSeparatorChar +
                          "${wd}/langtools/src/java.compiler/fake-target.jar" +
                          File.pathSeparatorChar +
                          "${wd}/langtools/src/jdk.compiler/fake-target.jar" +
                          File.pathSeparatorChar +
                          fakeJdkClasses.getAbsolutePath());
    checkCompileClassPath("repo/src/test3",
                          "${wd}/jdk/src/java.base/fake-target.jar" +
                          File.pathSeparatorChar +
                          "${wd}/repo/src/test2/fake-target.jar" +
                          File.pathSeparatorChar +
                          fakeJdkClasses.getAbsolutePath());
}
 
Example #7
Source File: PhpSourcePath.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get list of folders, where asignatures file for PHP runtime are.
 * These files are also preindexed.
 * @return list of folders
 */
public static synchronized List<FileObject> getPreindexedFolders() {
    if (phpStubsFolder == null) {
        // Core classes: Stubs generated for the "builtin" php runtime and extenstions.
        File clusterFile = InstalledFileLocator.getDefault().locate("docs/phpsigfiles.zip", "org.netbeans.modules.php.project", true); //NOI18N

        if (clusterFile != null) {
            FileObject root = FileUtil.getArchiveRoot(FileUtil.toFileObject(clusterFile));
            phpStubsFolder = root.getFileObject("phpstubs/phpruntime"); //NOI18N
        }
    }
    if (phpStubsFolder == null) {
        // during tests
        return Collections.emptyList();
    }
    return Collections.singletonList(phpStubsFolder);
}
 
Example #8
Source File: BaseSampleProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static FileObject getSampleFile(String sampleName)
        throws DatabaseException {

    try {
        File jarfile = InstalledFileLocator.getDefault().locate(
            MODULE_JAR_FILE, null, false); // NOI18N

        JarFileSystem jarfs = new JarFileSystem();

        jarfs.setJarFile(jarfile);

        String filename = "/create-" + sampleName + ".sql";
        return jarfs.findResource(RESOURCE_DIR_PATH + filename);
    } catch (Exception e) {
        DatabaseException dbe = new DatabaseException(
                Utils.getMessage(
                    "MSG_ErrorLoadingSampleSQL", sampleName,
                    e.getMessage()));
        dbe.initCause(e);
        throw dbe;
    }
}
 
Example #9
Source File: RestSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void addJerseySpringJar() throws IOException {
    FileObject srcRoot = MiscUtilities.findSourceRoot(getProject());
    if (srcRoot != null) {
        ClassPath cp = ClassPath.getClassPath(srcRoot, ClassPath.COMPILE);
        if (cp ==null ||cp.findResource(
                "com/sun/jersey/api/spring/Autowire.class") == null)        //NOI18N
        {
            File jerseyRoot = InstalledFileLocator.getDefault().locate(JERSEY_API_LOCATION, null, false);
            if (jerseyRoot != null && jerseyRoot.isDirectory()) {
                File[] jerseyJars = jerseyRoot.listFiles(new MiscPrivateUtilities.JerseyFilter(JERSEY_SPRING_JAR_PATTERN));
                if (jerseyJars != null && jerseyJars.length>0) {
                    URL url = FileUtil.getArchiveRoot(jerseyJars[0].toURI().toURL());
                    ProjectClassPathModifier.addRoots(new URL[] {url}, srcRoot, ClassPath.COMPILE);
                }
            }
        }
    }
}
 
Example #10
Source File: SetupUtil.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void commonSetUp(File workingDir) throws Exception {
    File testuserdir = new File(workingDir.getParentFile(), "testuser");
    System.getProperties().setProperty("netbeans.user", testuserdir.getAbsolutePath());
    //SaasServicesModel.getInstance().reset();
    FileObject websvcHome = SaasServicesModel.getWebServiceHome();
    File userconfig = FileUtil.toFile(websvcHome.getParent());
    MainFS fs = new MainFS();
    fs.setConfigRootDir(userconfig);
    TestRepository.defaultFileSystem = fs;
    
    MockServices.setServices(InstalledFileLocatorImpl.class, TestRepository.class);
    
    InstalledFileLocatorImpl locator = (InstalledFileLocatorImpl)Lookup.getDefault().lookup(InstalledFileLocator.class);
    locator.setUserConfigRoot(userconfig);
    
    //File targetBuildProperties = new File(testuserdir, "build.properties");
    //generatePropertiesFile(targetBuildProperties);
    
}
 
Example #11
Source File: RestSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static ClassPath extendClassPathWithJaxRsApisIfNecessary(ClassPath classPath) {
    if (classPath.findResource("javax/ws/rs/core/Application.class") != null) {
        return classPath;
    }
    File jerseyRoot = InstalledFileLocator.getDefault().locate(JERSEY_API_LOCATION, "org.netbeans.modules.websvc.restlib", false);
    if (jerseyRoot != null && jerseyRoot.isDirectory()) {
        File[] jsr311Jars = jerseyRoot.listFiles(new MiscPrivateUtilities.JerseyFilter(JSR311_JAR_PATTERN));
        if (jsr311Jars != null && jsr311Jars.length>0) {
            FileObject fo = FileUtil.toFileObject(jsr311Jars[0]);
            if (fo != null) {
                fo = FileUtil.getArchiveRoot(fo);
                if (fo != null) {
                    return ClassPathSupport.createProxyClassPath(classPath,
                            ClassPathSupport.createClassPath(fo));
                }
            }
        }
    }
    return classPath;
}
 
Example #12
Source File: LocaleVariants.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Find a path such that InstalledFileLocator.getDefault().locate(path, null, false)
 * yields the given file. Only guaranteed to work in case the logical path is a suffix of
 * the file's absolute path (after converting path separators); otherwise there is no
 * general way to invert locate(...) so this heuristic may fail. However for the IFL
 * implementation used in a plain NB installation (i.e.
 * org.netbeans.core.modules.InstalledFileLocatorImpl), this condition will in fact hold.
 * @return the inverse of locate(...), or null if there is no such path
 * @see "#34069"
 */
private static String findLogicalPath(File f, String codeNameBase) {
    InstalledFileLocator l = InstalledFileLocator.getDefault();
    String path = f.getName();
    File parent = f.getParentFile();
    while (parent != null) {
        File probe = l.locate(path, codeNameBase, false);
        //System.err.println("Util.fLP: f=" + f + " parent=" + parent + " probe=" + probe + " f.equals(probe)=" + f.equals(probe));
        if (f.equals(probe)) {
            return path;
        }
        path = parent.getName() + '/' + path;
        parent = parent.getParentFile();
    }
    return null;
}
 
Example #13
Source File: TomcatProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public List/*<URL>*/ getJavadocs() {
    String path = ip.getProperty(PROP_JAVADOCS);
    if (path == null) {                
        ArrayList list = new ArrayList();
            // tomcat docs
            File jspApiDoc = new File(homeDir, "webapps/tomcat-docs/jspapi"); // NOI18N
            File servletApiDoc = new File(homeDir, "webapps/tomcat-docs/servletapi"); // NOI18N
            if (jspApiDoc.exists() && servletApiDoc.exists()) {
                addFileToList(list, jspApiDoc);
                addFileToList(list, servletApiDoc);
            } else {
                File j2eeDoc = InstalledFileLocator.getDefault().locate("docs/javaee-doc-api.jar", null, false); // NOI18N
                if (j2eeDoc != null) {
                    addFileToList(list, j2eeDoc);
                }
            }
            // jwsdp docs
            File docs = new File(homeDir, "docs/api"); // NOI18N
            if (docs.exists()) {
                addFileToList(list, docs);
            }
        return list;
    }
    return CustomizerSupport.tokenizePath(path);
}
 
Example #14
Source File: CssHelpResolver.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static synchronized URL getHelpZIPURL() {
      if (HELP_ZIP_URL == null) {
          File f = InstalledFileLocator.getDefault().locate(HELP_LOCATION, null, false); //NoI18N
          if (f != null) {
              try {
                  URL urll = f.toURI().toURL(); //toURI should escape the illegal characters like spaces
                  HELP_ZIP_URL = FileUtil.getArchiveRoot(urll);
              } catch (java.net.MalformedURLException e) {
                  ErrorManager.getDefault().notify(e);
              }
          } else {
Logger.getLogger(CssHelpResolver.class.getSimpleName())
                      .info("Cannot locate the css documentation file " + HELP_LOCATION ); //NOI18N
   }
      }

      return HELP_ZIP_URL;
  }
 
Example #15
Source File: LogViewer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void processLine(String line) {
    ContextLogSupport.LineInfo lineInfo = logSupport.analyzeLine(line);
    if (lineInfo.isError()) {
        if (lineInfo.isAccessible()) {
            try {
                errorWriter.println(line, logSupport.getLink(lineInfo.message(), lineInfo.path(), lineInfo.line()));
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        } else {
            errorWriter.println(line);
        }
    } else {
        if (line.contains("java.lang.LinkageError: JAXB 2.0 API")) { // NOI18N
            File jaxwsApi = InstalledFileLocator.getDefault().locate("modules/ext/jaxws21/api/jaxws-api.jar", null, false); // NOI18N
            File jaxbApi = InstalledFileLocator.getDefault().locate("modules/ext/jaxb/api/jaxb-api.jar", null, false); // NOI18N
            File endoresedDir = tomcatManager.getTomcatProperties().getJavaEndorsedDir();
            if (jaxwsApi != null && jaxbApi != null) {
                writer.println(NbBundle.getMessage(LogViewer.class, "MSG_WSSERVLET11", jaxwsApi.getParent(), jaxbApi.getParent(), endoresedDir));
            } else {
                writer.println(NbBundle.getMessage(LogViewer.class, "MSG_WSSERVLET11_NOJAR", endoresedDir));
            }
        }
        writer.println(line);
    }
}
 
Example #16
Source File: ParserLoader.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Bootstrapping method.
 * @return ParserLoader or null if library can not be located
 */
public static synchronized ParserLoader getInstance() {
                    
    if (instance != null) return instance;
    
    try {
        InstalledFileLocator installedFileLocator = InstalledFileLocator.getDefault();

        URL xer2url = installedFileLocator.locate(XERCES_ARCHIVE, CODENAME_BASE, false).toURL(); // NOI18N
        if ( Util.THIS.isLoggable() ) Util.THIS.debug ("Isolated library URL=" + xer2url); // NOI18N

        // The isolating classloader itself (not parent) must also see&load interface
        // implementation class because all subsequent classes must be loaded by the
        // isolating classloader (not its parent that does not see isolated jar)
        URL module = installedFileLocator.locate(MODULE_ARCHIVE, CODENAME_BASE, false).toURL(); // NOI18N
        if ( Util.THIS.isLoggable() ) Util.THIS.debug ("Isolated module URL=" + module); // NOI18N

        instance = new ParserLoader(new URL[] {xer2url, module});

    } catch (MalformedURLException ex) {
        if ( Util.THIS.isLoggable() )  Util.THIS.debug (ex);
    }
           
    return instance;
}
 
Example #17
Source File: JsTestDriverImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
    public void startServer(File jsTestDriverJar, int port, boolean strictMode, ServerListener listener) {
        if (wasStartedExternally(port)) {
            externallyStarted = true;
            IOProvider.getDefault().getIO("js-test-driver Server", false).getOut().
                    println("Port "+port+" is busy. Server was started outside of the IDE.");
            return;
        }
        ExecutionDescriptor descriptor = new ExecutionDescriptor().
                controllable(false).
//                outLineBased(true).
//                errLineBased(true).
                outProcessorFactory(new ServerInputProcessorFactory(listener)).
                frontWindowOnError(true);
        File extjar = InstalledFileLocator.getDefault().locate("modules/ext/libs.jstestdriver-ext.jar", "org.netbeans.libs.jstestdriver", false); // NOI18N
        ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(getJavaBinary()).
            addArgument("-cp").
            addArgument(jsTestDriverJar.getAbsolutePath()+File.pathSeparatorChar+extjar.getAbsolutePath()).
            addArgument("org.netbeans.libs.jstestdriver.ext.StartServer").
            addArgument(""+port).
            addArgument(""+strictMode);
        ExecutionService service = ExecutionService.newService(processBuilder, descriptor, "js-test-driver Server");
        task = service.run();
        running = true;
    }
 
Example #18
Source File: JsfDocumentation.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static URL getZipURL() {
    if (DOC_ZIP_URL == null) {
        File file = InstalledFileLocator.getDefault().locate(DOC_ZIP_FILE_NAME, null, false);
        if (file != null) {
            try {
                URL url = Utilities.toURI(file).toURL();
                DOC_ZIP_URL = FileUtil.getArchiveRoot(url);
            } catch (MalformedURLException ex) {
                Logger.getLogger(JsfDocumentation.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            Logger.getAnonymousLogger().warning(String.format("Cannot locate the %s documentation file.", DOC_ZIP_FILE_NAME)); //NOI18N
        }
    }
    return DOC_ZIP_URL;
}
 
Example #19
Source File: JQueryModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static JsObject getGlobalObject(ModelElementFactory modelElementFactory) {
    if (skipInTest) {
        return null;
    }

    if (globalObject == null) {
        File apiFile = InstalledFileLocator.getDefault().locate(JQueryCodeCompletion.HELP_LOCATION, "org.netbeans.modules.javascript2.jquery", false); //NoI18N
        if (apiFile != null) {
            globalObject = modelElementFactory.newGlobalObject(
                    FileUtil.toFileObject(apiFile), (int) apiFile.length());
            JsFunction function = new JQFunction(modelElementFactory.newFunction(
                    (DeclarationScope) globalObject, globalObject, JQueryUtils.JQUERY, Collections.<String>emptyList())); // NOI18N
            jQuery =  modelElementFactory.putGlobalProperty(globalObject, function);
            rjQuery = modelElementFactory.newReference(JQueryUtils.JQUERY$, jQuery, false); // NOI18N

            SelectorsLoader.addToModel(apiFile, modelElementFactory, jQuery);
            globalObject.addProperty(rjQuery.getName(), rjQuery);
        }
    }
    return globalObject;
}
 
Example #20
Source File: ChromeManagerAccessor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected String getCurrentPluginVersion(){
    File extensionFile = InstalledFileLocator.getDefault().locate(
            EXTENSION_PATH,PLUGIN_MODULE_NAME, false);
    if (extensionFile == null) {
        Logger.getLogger(ChromeExtensionManager.class.getCanonicalName()).
            info("Could not find chrome extension in installation directory!"); // NOI18N
        return null;
    }
    String content = Utils.readZip( extensionFile, "manifest.json");    // NOI18N
    int index = content.indexOf(VERSION);
    if ( index == -1){
        return null;
    }
    index = content.indexOf(',',index);
    return getValue(content, 0, index , VERSION);
}
 
Example #21
Source File: TypeScriptLSP.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@Messages({"WARN_NoNode=node.js not found, TypeScript support disabled.",
           "DESC_NoNode=Please specify node.js location in the Tools/Options, and restart the IDE."
})
public LanguageServerDescription startServer(Lookup lookup) {
    String node = NodeJsSupport.getInstance().getNode(null);
    if (node == null || node.isEmpty()) {
        NotificationDisplayer.getDefault().notify(Bundle.WARN_NoNode(), ImageUtilities.loadImageIcon("org/netbeans/modules/typescript/editor/icon.png", true), Bundle.DESC_NoNode(), evt -> {
            OptionsDisplayer.getDefault().open("Html5/NodeJs");
        });
        return null;
    }
    File server = InstalledFileLocator.getDefault().locate("typescript-lsp/node_modules/typescript-language-server/lib/cli.js", null, false);
    try {
        Process p = new ProcessBuilder(new String[] {node, server.getAbsolutePath(), "--stdio"}).directory(server.getParentFile().getParentFile()).redirectError(ProcessBuilder.Redirect.INHERIT).start();
        return LanguageServerDescription.create(p.getInputStream(), p.getOutputStream(), p);
    } catch (IOException ex) {
        LOG.log(Level.FINE, null, ex);
        return null;
    }
}
 
Example #22
Source File: PredefinedSymbols.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void initDoc() {
    File file = InstalledFileLocator.getDefault().locate("docs/predefined_vars.zip", null, true); //NoI18N
    if (file != null) {
        try {
            URL urll = Utilities.toURI(file).toURL();
            urll = FileUtil.getArchiveRoot(urll);
            docURLBase = urll.toString();
        } catch (java.net.MalformedURLException e) {
            LOGGER.log(Level.FINE, null, e);
        }
    }
}
 
Example #23
Source File: Wsdl2Java.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Find the ant script file.
 * The file is at <websvcmgr>/external and placed at
 */
private File getAntScript() {
    if (wsImportCompileScript == null) {
        wsImportCompileScript = InstalledFileLocator.getDefault().locate(
                wsImportCompileScriptName,
                "", // NOI18N
                false);
    }
    
    return wsImportCompileScript;
}
 
Example #24
Source File: DerbyOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static String getDefaultInstallLocation() {
    File location = InstalledFileLocator.getDefault().locate(INST_DIR, null, false);
    if (location == null) {
        return null;
    }
    if (!Util.isDerbyInstallLocation(location)) {
        return null;
    }
    return location.getAbsolutePath();
}
 
Example #25
Source File: AntRemotePackExporter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private synchronized AntProjectCookie getCookie() throws IOException {
    if (cookie == null) {
        File antFile = InstalledFileLocator.getDefault().locate("remote-pack-defs/build.xml", "org-netbeans-lib-profiler", false); //NOI18N
        cookie = DataObject.find(FileUtil.toFileObject(antFile)).getCookie(AntProjectCookie.class);
    }
    return cookie;
}
 
Example #26
Source File: NetBeansProfiler.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public String getLibsDir() {
    final File dir = InstalledFileLocator.getDefault()
                                         .locate(ProfilerModule.LIBS_DIR + "/jfluid-server.jar", //NOI18N
                                                 "org.netbeans.lib.profiler", false); //NOI18N

    if (dir == null) {
        return null;
    } else {
        return dir.getParentFile().getPath();
    }
}
 
Example #27
Source File: AutoUpgrade.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void copyToUserdir(File source) throws IOException, PropertyVetoException {
    File userdir = new File(System.getProperty("netbeans.user", "")); // NOI18N
    File netBeansDir = InstalledFileLocator.getDefault().locate("modules", null, false).getParentFile().getParentFile();  //NOI18N
    File importFile = new File(netBeansDir, "etc/netbeans.import");  //NOI18N
    LOGGER.fine("Import file: " + importFile);
    LOGGER.info("Importing from " + source + " to " + userdir); // NOI18N
    CopyFiles.copyDeep(source, userdir, importFile);
}
 
Example #28
Source File: InstallLibraryTask.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override
void run() {
    Preferences p = NbPreferences.forModule(InstallLibraryTask.class);
    if (p.getBoolean(KEY, false)) {
        // Only check once (i.e. on first start for a fresh user dir).
        return;
    }
    p.putBoolean(KEY, true);
    // find licenseAcceptedFile
    File licenseAcceptedFile = InstalledFileLocator.getDefault().locate("var/license_accepted", null, false); // NOI18N
    if (licenseAcceptedFile == null) {
        LOG.info("$userdir/var/license_accepted not found => skipping install JUnit.");
        return ;
    }
    try {
        // read content of file
        String content = FileUtil.toFileObject(licenseAcceptedFile).asText();
        LOG.fine("Content of $userdir/var/license_accepted: " + content);
        if (content != null && content.indexOf(JUNIT_APPROVED) != -1) {
            // IDE license accepted, JUnit accpeted => let's install silently
            LOG.fine(" IDE license accepted, JUnit accepted => let's install silently"); 
            JUnitLibraryInstaller.install(true);
        } else if (content != null && content.indexOf(JUNIT_DENIED) != -1) {
            // IDE license accepted but JUnit disapproved => do nothing
            LOG.fine("IDE license accepted but JUnit disapproved => do nothing"); 
        } else {
            // IDE license accepted, JUnit N/A => use prompt & wizard way
            LOG.fine("IDE license accepted, JUnit N/A => use prompt & wizard way"); 
            RP.post(new Runnable() {

                @Override
                public void run() {
                    JUnitLibraryInstaller.install(false);
                }
            });
        }
    } catch (IOException ex) {
        LOG.log(Level.INFO, "while reading " + licenseAcceptedFile, ex);
    }
}
 
Example #29
Source File: JavaHlClientAdapterFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void presetJavahlWindows() {
    String libPath = System.getProperty(SUBVERSION_NATIVE_LIBRARY);
    if (libPath != null && !libPath.trim().equals("")) {
        // the path is already set -> lets ensure we load all dependencies
        // from the same folder and let then svnClientAdapter take care for the rest
        LOG.log(Level.FINE, "preset subversion.native.library={0}", new Object[] { libPath } );
        int idx = libPath.lastIndexOf(File.separator);
        if(idx > -1) {
            libPath = libPath.substring(0, idx);
            LOG.log(Level.FINE, "loading dependencies from ", new Object[] { libPath } );
            loadJavahlDependencies(libPath);
        }
        return;
    }
            
    File location = InstalledFileLocator.getDefault().locate("modules/lib/libsvnjavahl-1.dll", JAVAHL_WIN32_MODULE_CODE_NAME, false);
    if(location == null) {
        LOG.fine("could not find location for bundled javahl library");
        location = getJavahlFromExecutablePath("libsvnjavahl-1.dll");
        if(location == null) {
            return;
        }
    }
    // the library seems to be available in the netbeans install/user dir
    // => set it up so that it will used by the svnClientAdapter
    LOG.fine("libsvnjavahl-1.dll located : " + location.getAbsolutePath());
    String locationPath = location.getParentFile().getAbsolutePath();
    // svnClientAdapter workaround - we have to explicitly load the
    // libsvnjavahl-1 dependencies as svnClientAdapter  tryies to get them via loadLibrary.
    // That won't work i they aren't on java.library.path
    loadJavahlDependencies(locationPath);

    // libsvnjavahl-1 must be loaded by the svnClientAdapter to get the factory initialized
    locationPath = location.getAbsolutePath();
    LOG.log(Level.FINE, "setting subversion.native.library={0}", new Object[] { locationPath });
    System.setProperty("subversion.native.library", locationPath);
}
 
Example #30
Source File: JspParserImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void initURLs() throws MalformedURLException, IOException {
    if (urls == null) {
        File[] files = new File[JAR_FILE_NAMES.length];
        List<String> missing = new ArrayList<String>();
        for(int i = 0; i < JAR_FILE_NAMES.length; i++) {
            files[i] = InstalledFileLocator.getDefault().locate(JAR_FILE_NAMES[i], null, false);
            if(files[i] == null) {
                missing.add(JAR_FILE_NAMES[i]);
            }
        }

        if(!missing.isEmpty()) {
            //something wasn't found, report error and cancel the initialization
            StringBuffer msg = new StringBuffer();
            msg.append("Cannot initialize JSP parser, following JAR files couldn't be localted: "); //NOI18N
            for(String fname : missing) {
                msg.append(fname);
                msg.append(','); //NOI18N
            }
            msg.setCharAt(msg.length() - 1, '.'); //replace last comma

            throw new IOException(msg.toString());
        }

        URL[] urls2 = new URL[files.length];
        for (int i = 0; i < files.length; i++) {
            urls2[i] = files[i].toURI().toURL();
        }
        urls = urls2;
    }
}