• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Places类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: findSystemCatalog

import org.openide.modules.Places; //导入依赖的package包/类
public static FileObject findSystemCatalog() {
    File f = Places.getCacheSubfile(SYSTEM_PRIVATE_CATALOG_FILE);
    if (f.exists()) {
        return FileUtil.toFileObject(f);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:Util.java


示例17: assertCache

import org.openide.modules.Places; //导入依赖的package包/类
private void assertCache() throws Exception {
    Stamps.getModulesJARs().flush(0);
    Stamps.getModulesJARs().shutdown();
    
    File f = Places.getCacheSubfile("all-modules.dat");
    assertTrue("Cache exists", f.exists());

    FileObject mf = fs.findResource(modulesfolder.getPath());
    assertNotNull("config folder exits", mf);
    
    CountingSecurityManager.initialize(new File(fs.getRootDirectory(), "Modules").getPath());
    
    MockModuleInstaller installer = new MockModuleInstaller();
    MockEvents ev = new MockEvents();
    ModuleManager mgr2 = new ModuleManager(installer, ev);
    assertNotNull(mf);
    ModuleList list2 = new ModuleList(mgr2, mf, ev);
    mgr2.mutexPrivileged().enterWriteAccess();
    CharSequence log = Log.enable("org.netbeans.core.startup.ModuleList", Level.FINEST);
    try {
        list2.readInitial();
    } finally {
        mgr2.mutexPrivileged().exitWriteAccess();
    }
    if (log.toString().indexOf("no cache") >= 0) {
        fail("Everything shall be read from cache:\n" + log);
    }
    if (log.toString().indexOf("Reading cache") < 0) {
        fail("Cache shall be read:\n" + log);
    }

    Set<String> moduleNew = cnbs(mgr2.getModules());
    Set<String> moduleOld = cnbs(mgr.getModules());
    
    assertEquals("Same set of modules:", moduleOld, moduleNew);
    
    CountingSecurityManager.assertCounts("Do not access the module config files", 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ModuleListTest.java


示例18: testUserdir

import org.openide.modules.Places; //导入依赖的package包/类
public void testUserdir() {
    String orig = System.setProperty("netbeans.user", "before");
    new CLIOptions().cli(new String[] { "-userdir", "wrong" });
    assertFalse("-userdir is not supported", "wrong".equals(System.getProperty("netbeans.user")));
    
    new CLIOptions().cli(new String[] { "--userdir", "correct" });
    final File exp = FileUtil.normalizeFile(new File("correct"));
    assertEquals("--userdir is supported via places", exp, Places.getUserDirectory());
    assertEquals("--userdir is supported", exp.getAbsolutePath(), System.getProperty("netbeans.user"));
    
    if (orig != null) {
        System.setProperty("netbeans.user", orig);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CLIOptionsTest.java


示例19: testRememberCacheDir

import org.openide.modules.Places; //导入依赖的package包/类
public void testRememberCacheDir() {
    File cacheDir = Places.getCacheDirectory();
    assertTrue("It is a directory", cacheDir.isDirectory());
    System.setProperty("mycache", cacheDir.getPath());
    
    File boot = InstalledFileLocator.getDefault().locate("lib/boot.jar", "org.netbeans.bootstrap", false);
    assertNotNull("Boot.jar found", boot);
    System.setProperty("myinstall", boot.getParentFile().getParentFile().getParentFile().getPath());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CachingPreventsFileTouchesTest.java


示例20: getNBConfigPath

import org.openide.modules.Places; //导入依赖的package包/类
/**
 * Returns the path for the Sunbversion configuration directory used 
 * by the Netbeans Subversion module.
 *
 * @return the path
 *
 */ 
public static String getNBConfigPath() {
    
    //T9Y - nb svn confing should be changable
    String t9yNbConfigPath = System.getProperty("netbeans.t9y.svn.nb.config.path");
    if (t9yNbConfigPath != null && t9yNbConfigPath.length() > 0) {
        return t9yNbConfigPath;
    }
    
    String nbHome = Places.getUserDirectory().getAbsolutePath();
    return nbHome + "/config/svn/config/";                                  // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SvnConfigFiles.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Replaceable类代码示例发布时间:2022-05-23
下一篇:
Java LeafPropertyLoader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap