当前位置: 首页>>代码示例>>Java>>正文


Java Places类代码示例

本文整理汇总了Java中org.openide.modules.Places的典型用法代码示例。如果您正苦于以下问题:Java Places类的具体用法?Java Places怎么用?Java Places使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Places类属于org.openide.modules包,在下文中一共展示了Places类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildScript

import org.openide.modules.Places; //导入依赖的package包/类
private static FileObject buildScript(String actionName, boolean forceCopy) throws IOException {
    URL script = locateScript(actionName);

    if (script == null) {
        return null;
    }

    URL thisClassSource = ProjectRunnerImpl.class.getProtectionDomain().getCodeSource().getLocation();
    File jarFile = FileUtil.archiveOrDirForURL(thisClassSource);
    File scriptFile = Places.getCacheSubfile("executor-snippets/" + actionName + ".xml");
    
    if (forceCopy || !scriptFile.canRead() || (jarFile != null && jarFile.lastModified() > scriptFile.lastModified())) {
        try {
            URLConnection connection = script.openConnection();
            FileObject target = FileUtil.createData(scriptFile);

            copyFile(connection, target);
            return target;
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
            return null;
        }
    }

    return FileUtil.toFileObject(scriptFile);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ProjectRunnerImpl.java

示例2: discardCachesImpl

import org.openide.modules.Places; //导入依赖的package包/类
private static void discardCachesImpl(AtomicLong al) {
    File user = Places.getUserDirectory();
    long now = System.currentTimeMillis();
    if (user != null) {
        File f = new File(user, ".lastModified");
        if (f.exists()) {
            f.setLastModified(now);
        } else {
            f.getParentFile().mkdirs();
            try {
                f.createNewFile();
            } catch (IOException ex) {
                LOG.log(Level.WARNING, "Cannot create " + f, ex);
            }
        }
    }
    if (al != null) {
        al.set(now);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Stamps.java

示例3: setUp

import org.openide.modules.Places; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {

    super.setUp();
    cacheDir = new File(Places.getCacheDirectory(), PlatformLayersCacheManager.CACHE_PATH);
    assertFalse("Cache not yet saved", cacheDir.isDirectory());
    plaf = NbPlatform.getDefaultPlatform();
    jarNames = new HashSet<String>();
    Collections.addAll(jarNames, "org-netbeans-modules-apisupport-project.jar",
            "org-netbeans-core-windows.jar",
            "org-openide-filesystems.jar",  // not in "modules" dir, but has layer.xml
            "org-openide-util.jar");    // doesn't have layer.xml
    clusters = plaf.getDestDir().listFiles(new FileFilter() {
        public boolean accept(File pathname) {
            return (pathname.getName().startsWith("platform")
                    || pathname.getName().startsWith("apisupport"))
                    && ClusterUtils.isValidCluster(pathname);
        }
    });
    PlatformLayersCacheManager.reset();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PlatformLayersCacheManagerTest.java

示例4: markReadyForRestart

import org.openide.modules.Places; //导入依赖的package包/类
/** Creates files that instruct the native launcher to perform restart as
 * soon as the Java process finishes. 
 * 
 * @since 1.45
 * @throws UnsupportedOperationException some environments (like WebStart)
 *   do not support restart and may throw an exception to indicate that
 */
static void markReadyForRestart() throws UnsupportedOperationException {
    String classLoaderName = TopSecurityManager.class.getClassLoader().getClass().getName();
    if (!classLoaderName.endsWith(".Launcher$AppClassLoader") && !classLoaderName.endsWith(".ClassLoaders$AppClassLoader")) {   // NOI18N
        throw new UnsupportedOperationException("not running in regular module system, cannot restart"); // NOI18N
    }
    File userdir = Places.getUserDirectory();
    if (userdir == null) {
        throw new UnsupportedOperationException("no userdir"); // NOI18N
    }
    File restartFile = new File(userdir, "var/restart"); // NOI18N
    if (!restartFile.exists()) {
        try {
            restartFile.createNewFile();
        } catch (IOException x) {
            throw new UnsupportedOperationException(x);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ModuleLifecycleManager.java

示例5: defaultHandler

import org.openide.modules.Places; //导入依赖的package包/类
private static synchronized Handler defaultHandler() {
    if (defaultHandler != null) return defaultHandler;

    File home = Places.getUserDirectory();
    if (home != null && !CLIOptions.noLogging) {
        File dir = new File(new File(home, "var"), "log");
        dir.mkdirs ();

        Handler h = NbLogging.createMessagesHandler(dir);
        defaultHandler = NbLogging.createDispatchHandler(h, 5000);
    }

    if (defaultHandler == null) {
        defaultHandler = streamHandler();
        disabledConsole = true;
    }
    return defaultHandler;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:TopLogging.java

示例6: testManifestCaching

import org.openide.modules.Places; //导入依赖的package包/类
/** Test #26786/#28755: manifest caching can be buggy.
 */
public void testManifestCaching() throws Exception {
    PlacesTestUtils.setUserDirectory(getWorkDir());
    ModuleInstaller inst = new org.netbeans.core.startup.NbInstaller(new MockEvents());
    File littleJar = new File(jars, "little-manifest.jar");
    //inst.loadManifest(littleJar).write(System.out);
    assertEquals(getManifest(littleJar), inst.loadManifest(littleJar));
    File mediumJar = new File(jars, "medium-manifest.jar");
    assertEquals(getManifest(mediumJar), inst.loadManifest(mediumJar));
    File bigJar = new File(jars, "big-manifest.jar");
    assertEquals(getManifest(bigJar), inst.loadManifest(bigJar));
    Stamps.getModulesJARs().shutdown();
    File allManifestsDat = Places.getCacheSubfile("all-manifest.dat");
    assertTrue("File " + allManifestsDat + " exists", allManifestsDat.isFile());
    // Create a new NbInstaller, since otherwise it turns off caching...
    inst = new org.netbeans.core.startup.NbInstaller(new MockEvents());
    assertEquals(getManifest(littleJar), inst.loadManifest(littleJar));
    assertEquals(getManifest(mediumJar), inst.loadManifest(mediumJar));
    assertEquals(getManifest(bigJar), inst.loadManifest(bigJar));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:NbInstallerTest9.java

示例7: createAndCleanTrashArea

import org.openide.modules.Places; //导入依赖的package包/类
private void createAndCleanTrashArea() throws IOException {
    if (trashRoot != null) {
        return;
    }
    FileObject r = FileUtil.toFileObject(Places.getCacheSubdirectory("jshell"));
    if (r == null) {
        throw new IOException("Unable to create cache for generated snippets");
    }
    LOG.log(Level.FINE, "Clearing trash area");
    trashRoot = r;
    for (FileObject f : r.getChildren()) {
        LOG.log(Level.FINE, "Deleting: {0}", f);
        try {
            f.delete();
        } catch (IOException ex) {
            LOG.log(Level.WARNING, "Could not delete Java Shell work area {0}: {1}", new Object[] { f, ex });
            ignoreNames.add(f.getNameExt());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ShellRegistry.java

示例8: findProject

import org.openide.modules.Places; //导入依赖的package包/类
private static Project findProject(Lookup context) {
    Project prj = context.lookup(Project.class);
    if (prj == null) {
        FileObject f = context.lookup(FileObject.class);
        if (f != null) {
            File cache = Places.getCacheDirectory();
            FileObject cacheFO = FileUtil.toFileObject(cache);
            prj = FileOwnerQuery.getOwner(f);
            if (cacheFO != null && prj != null) {
                if (FileUtil.isParentOf(prj.getProjectDirectory(), cacheFO)) {
                    prj = null;
                }
            }
        }
    }
    return prj;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:PersistentSnippetsSupport.java

示例9: getCosScript

import org.openide.modules.Places; //导入依赖的package包/类
@NonNull
private FileObject getCosScript() throws IOException {
    final FileObject snippets = FileUtil.createFolder(
            Places.getCacheSubdirectory(SNIPPETS));
    FileObject cosScript = snippets.getFileObject(SCRIPT);
    if (cosScript == null) {
        cosScript = FileUtil.createData(snippets, SCRIPT);
        final FileLock lock = cosScript.lock();
        try (InputStream in = getClass().getResourceAsStream(SCRIPT_TEMPLATE);
                OutputStream out = cosScript.getOutputStream(lock)) {
            FileUtil.copy(in, out);
        } finally {
            lock.releaseLock();
        }
    }
    return cosScript;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:J2SEActionProvider.java

示例10: getCacheFolder

import org.openide.modules.Places; //导入依赖的package包/类
@NonNull
synchronized FileObject getCacheFolder() {
    if (cacheFolder == null) {
        File cache = Places.getCacheSubdirectory("index"); // NOI18N
        if (!cache.isDirectory()) {
            throw new IllegalStateException("Indices cache folder " + cache.getAbsolutePath() + " is not a folder"); //NOI18N
        }
        if (!cache.canRead()) {
            throw new IllegalStateException("Can't read from indices cache folder " + cache.getAbsolutePath()); //NOI18N
        }
        if (!cache.canWrite()) {
            throw new IllegalStateException("Can't write to indices cache folder " + cache.getAbsolutePath()); //NOI18N
        }
        cacheFolder = FileUtil.toFileObject(cache);
        if (cacheFolder == null) {
            throw new IllegalStateException("Can't convert indices cache folder " + cache.getAbsolutePath() + " to FileObject"); //NOI18N
        }
    }
    return cacheFolder;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DefaultCacheFolderProvider.java

示例11: goMinusR

import org.openide.modules.Places; //导入依赖的package包/类
/** Tries to set permissions on preferences storage file to -rw------- */
public static void goMinusR(Preferences p) {
    File props = new File(Places.getUserDirectory(), ("config/Preferences" + p.absolutePath()).replace('/', File.separatorChar) + ".properties");
    if (props.isFile()) {
        props.setReadable(false, false); // seems to be necessary, not sure why
        props.setReadable(true, true);
        LOG.log(Level.FINE, "chmod go-r {0}", props);
    } else {
        LOG.log(Level.FINE, "no such file to chmod: {0}", props);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Utils.java

示例12: createAttachment

import org.openide.modules.Places; //导入依赖的package包/类
private void createAttachment (AttachmentInfo newAttachment) {
    AttachmentPanel attachment = new AttachmentPanel(nbCallback);
    attachment.setBackground(UIUtils.getSectionPanelBackground());
    horizontalGroup.addComponent(attachment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    verticalGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
    verticalGroup.addComponent(attachment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    if (noneLabel.isVisible()) {
        noneLabel.setVisible(false);
        switchHelper();
        updateButtonText(false);
    }
    attachment.addPropertyChangeListener(getDeletedListener());
    
    if (newAttachment != null) {
        attachment.setAttachment(newAttachment.getFile(), newAttachment.getDescription(),
                newAttachment.getContentType(), newAttachment.isPatch());
    }
    if(nbCallback != null) {
        File f = new File(Places.getUserDirectory(), nbCallback.getLogFilePath()); 
        if(f.exists()) {
            attachment.setAttachment(f, nbCallback.getLogFileDescription(), nbCallback.getLogFileContentType(), false); // NOI18N
        }
        attachment.browseButton.setEnabled(false);
        attachment.fileField.setEnabled(false);
        attachment.fileTypeCombo.setEnabled(false);
        attachment.patchChoice.setEnabled(false);
    } else {
        attachment.viewButton.setVisible(false);
    }

    newAttachments.add(attachment);
    UIUtils.keepFocusedComponentVisible(attachment, parentPanel);
    revalidate();
    attachment.addChangeListener(getChangeListener());
    attachment.fileField.requestFocus();
    if (nbCallback != null) {
        supp.fireChange();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:AttachmentsPanel.java

示例13: fileImpl

import org.openide.modules.Places; //导入依赖的package包/类
private static File fileImpl(String cache, int[] len, long moduleJARs) {
    File cacheFile = new File(Places.getCacheDirectory(), cache);
    long last = cacheFile.lastModified();
    if (last <= 0) {
        LOG.log(Level.FINE, "Cache does not exist when asking for {0}", cache); // NOI18N
        cacheFile = findFallbackCache(cache);
        if (cacheFile == null || (last = cacheFile.lastModified()) <= 0) {
            return null;
        }
        LOG.log(Level.FINE, "Found fallback cache at {0}", cacheFile);
    }

    if (moduleJARs > last) {
        LOG.log(Level.FINE, "Timestamp does not pass when asking for {0}. Newest file {1}", new Object[] { cache, moduleNewestFile }); // NOI18N
        return null;
    }

    long longLen = cacheFile.length();
    if (longLen > Integer.MAX_VALUE) {
        LOG.log(Level.WARNING, "Cache file is too big: {0} bytes for {1}", new Object[]{longLen, cacheFile}); // NOI18N
        return null;
    }
    if (len != null) {
        len[0] = (int)longLen;
    }
    
    LOG.log(Level.FINE, "Cache found: {0}", cache); // NOI18N
    return cacheFile;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:Stamps.java

示例14: getArchetypes

import org.openide.modules.Places; //导入依赖的package包/类
@Override
public List<Archetype> getArchetypes() {
    File root = Places.getCacheSubdirectory("mavenarchetypes"); //NOI18N
    ArrayList<Archetype> toRet = new ArrayList<Archetype>();
    MavenEmbedder embedder = EmbedderFactory.getOnlineEmbedder();
    SettingsDecryptionResult settings = embedder.lookupComponent(SettingsDecrypter.class).decrypt(new DefaultSettingsDecryptionRequest(embedder.getSettings()));
    
    for (RepositoryInfo info : RepositoryPreferences.getInstance().getRepositoryInfos()) {
        if (info.isRemoteDownloadable()) {
            File catalog = new File(new File( root, info.getId()), "archetype-catalog.xml"); //NOI18N
            boolean download = false;
            if (!catalog.exists()) {
                download = true;
            } else {
                long lastM = catalog.lastModified();
                if (lastM == 0) {
                    download = true;
                } else if (lastM - System.currentTimeMillis() > ARCHETYPE_TIMEOUT) {
                    download = true;
                }
            }
            
            if (download) {
                download(info.getId(), info.getRepositoryUrl(), catalog, settings, embedder);
            }
            
            if (catalog.exists()) {
                try {
                    toRet.addAll(CatalogRepoProvider.getArchetypes(Utilities.toURI(catalog).toURL(), info.getRepositoryUrl()));
                } catch (MalformedURLException ex) {
                    LOG.log(Level.INFO, null, ex);
                }
            }
        }
    }
    
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CatalogRepoProvider.java

示例15: getAltMavenLocation

import org.openide.modules.Places; //导入依赖的package包/类
private File getAltMavenLocation() {
    if (MavenSettings.getDefault().isUseBestMavenAltLocation()) {
        String s = MavenSettings.getDefault().getBestMavenAltLocation();
        if (s != null && s.trim().length() > 0) {
            return FileUtil.normalizeFile(new File(s));
        }
    }
    return Places.getCacheSubdirectory("downloaded-mavens");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:MavenCommandLineExecutor.java


注:本文中的org.openide.modules.Places类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。