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


Java URLMapper.findURL方法代码示例

本文整理汇总了Java中org.openide.filesystems.URLMapper.findURL方法的典型用法代码示例。如果您正苦于以下问题:Java URLMapper.findURL方法的具体用法?Java URLMapper.findURL怎么用?Java URLMapper.findURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.URLMapper的用法示例。


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

示例1: testQuery

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public void testQuery() throws Exception {
    JavaPlatform platform = JavaPlatform.getDefault();
    ClassPath cp = platform.getBootstrapLibraries();
    FileObject pfo = cp.getRoots()[0];
    URL u = URLMapper.findURL(pfo, URLMapper.EXTERNAL);
    URL urls[] = JavadocForBinaryQuery.findJavadoc(u).getRoots();
    assertEquals(1, urls.length);
    assertTrue(urls[0].toString(), urls[0].toString().startsWith("https://docs.oracle.com/"));

    List<URL> l = new ArrayList<URL>();
    File javadocFile = getBaseDir();
    File api = new File (javadocFile,"api");
    File index = new File (api,"index-files");
    FileUtil.toFileObject(index);
    index.mkdirs();
    l.add(Utilities.toURI(javadocFile).toURL());
    J2SEPlatformImpl platformImpl = (J2SEPlatformImpl)platform;
    platformImpl.setJavadocFolders(l);
    urls = JavadocForBinaryQuery.findJavadoc(u).getRoots();
    assertEquals(1, urls.length);
    assertEquals(Utilities.toURI(api).toURL(), urls[0]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:J2SEPlatformJavadocForBinaryQueryTest.java

示例2: setParameters

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private Problem setParameters(boolean checkOnly) {
    if (panel==null) {
        return null;
    }
    URL url = URLMapper.findURL(panel.getRootFolder(), URLMapper.EXTERNAL);
    try {
        TreePathHandle targetClass = panel.getTargetClass();
        if(targetClass != null) {
            refactoring.setTarget(Lookups.singleton(targetClass));
        } else {
            refactoring.setTarget(Lookups.singleton(new URL(url.toExternalForm() + panel.getPackageName().replace('.', '/')))); // NOI18N
        }
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
    }
    if (checkOnly) {
        return refactoring.fastCheckParameters();
    } else {
        return refactoring.checkParameters();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MoveClassesUI.java

示例3: actionPerformed

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
    File javadocFile = getJavadocFile();
    FileObject fo = FileUtil.toFileObject(javadocFile);
    if (fo != null) {
        FileObject jarfo = FileUtil.getArchiveRoot(fo);
        if (jarfo != null) {
            FileObject index = jarfo.getFileObject("apidocs/index.html"); //NOI18N
            if (index == null) {
                index = jarfo.getFileObject("index.html"); //NOI18N
            }
            if (index == null) {
                index = jarfo;
            }
            URL link = URLMapper.findURL(index, URLMapper.EXTERNAL);
            HtmlBrowser.URLDisplayer.getDefault().showURL(link);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ViewJavadocAction.java

示例4: testFindUnitTest

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void testFindUnitTest() throws Exception {
    URL u = UnitTestForSourceQuery.findUnitTest(projdir);
    assertNull(u);
    
    u = UnitTestForSourceQuery.findUnitTest(sources);
    assertNotNull(u);
    URL result = URLMapper.findURL(tests, URLMapper.EXTERNAL);
    assertNotNull(result);
    assertEquals(result, u);
    
    u = UnitTestForSourceQuery.findSource(tests);
    assertNotNull(u);
    result = URLMapper.findURL(sources, URLMapper.EXTERNAL);
    assertNotNull(result);
    assertEquals(result, u);
    
    //Test the case when the tests folder does not exist
    result = tests.toURL();
    tests.delete();
    u = UnitTestForSourceQuery.findUnitTest (sources);
    assertEquals (result, u);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:UnitTestForSourceQueryImplTest.java

示例5: findProjectRoots

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public static FileObject findProjectRoots(Project project, List<URL> urls) {
    if (project == null) {
        return null;
    }
    FileObject ret = null;
    Set<URL> knownURLs = new HashSet<>();
    for (SourceGroup sg : org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        if (org.netbeans.modules.jshell.project.ShellProjectUtils.isNormalRoot(sg)) {
            if (urls != null) {
                URL u = URLMapper.findURL(sg.getRootFolder(), URLMapper.INTERNAL);
                BinaryForSourceQuery.Result r = BinaryForSourceQuery.findBinaryRoots(u);
                for (URL ru : r.getRoots()) {
                    // ignore JARs, prefer output folder:
                    if (FileUtil.isArchiveArtifact(ru)) {
                        continue;
                    }
                    if (knownURLs.add(ru)) {
                        urls.add(ru);
                    }
                }
            }
            if (ret == null) {
                ret = sg.getRootFolder();
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ShellProjectUtils.java

示例6: normalizeURL

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private static URL normalizeURL(URL url) {
    FileObject fo = URLMapper.findFileObject(url);
    if (fo != null) {
        return URLMapper.findURL(fo, URLMapper.EXTERNAL);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ApisupportAntUtils.java

示例7: resolveLink

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
public CompletionDocumentation resolveLink(String link) {
    try {
        DescriptionSource target = src.resolveLink(link);
        if (target != null) {
            return new ExtDocum(target, null);
        }
        
        URL base = src.getContentURL();
        if (base == null) {
            // sorry, cannot resolve.
            return null;
        }
        
        URL targetURL = new URL(base, link);
        
        // leave the VM as soon as possible. This hack uses URLMappers
        // to find out whether URL (converted to FO and back) can be
        // represented outside the VM
        boolean external = true;
        FileObject f = URLMapper.findFileObject(targetURL);
        if (f != null) {
            external = URLMapper.findURL(f, URLMapper.EXTERNAL) != null;
        }
        return new URLDocum(targetURL, external);
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:XMLResultItem.java

示例8: getResources

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
public List<? extends PathResourceImplementation> getResources() {
    List<FileObject> res;
    synchronized (this) {
        if (resCache != null) {
            return resCache;
        }
        if (classpathResources == null) {
            return Collections.emptyList();
        }
        res = new ArrayList<>(classpathResources);
    }
    
    List<PathResourceImplementation> resources = new ArrayList<>(res.size());
    for (FileObject f : res) {
        if (FileUtil.isArchiveFile(f)) {
            f = FileUtil.getArchiveRoot(f);
        }
        URL u = URLMapper.findURL(f, URLMapper.EXTERNAL);
        if (u != null) {
            resources.add(ClassPathSupport.createResource(u));
        }
    }
    synchronized (this) {
        if (classpathResources.equals(res)) {
            resCache = resources;
        }
    }
    return resources;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ConfigurableClasspath.java

示例9: setupRefactoring

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private void setupRefactoring() {
    refactoring.setNewName(panel.getNewName());
    FileObject rootFolder = panel.getRootFolder();
    Lookup target = Lookup.EMPTY;
    if (rootFolder != null) {
        try {
            URL url = URLMapper.findURL(rootFolder, URLMapper.EXTERNAL);
            URL targetURL = new URL(url.toExternalForm() + panel.getPackageName().replace('.', '/')); // NOI18N
            target = Lookups.singleton(targetURL);
        } catch (MalformedURLException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    refactoring.setTarget(target);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CopyClassRefactoringUI.java

示例10: setUp

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    clearWorkDir();
    
    MockServices.setServices(TestSupport.TestProjectFactory.class, ContextProv.class);
    
    FileObject workDir = FileUtil.toFileObject(getWorkDir());
    assertNotNull(workDir);
    
    first = new CountDownLatch(1);
    middle = new CountDownLatch(1);
    rest = new CountDownLatch(2);
    
    List<URL> list = new ArrayList<URL>();
    List<ExtIcon> icons = new ArrayList<ExtIcon>();
    List<String> names = new ArrayList<String>();
    for (int i = 0; i < 10; i++) {
        FileObject prj = TestSupport.createTestProject(workDir, "prj" + i);
        URL url = URLMapper.findURL(prj, URLMapper.EXTERNAL);
        list.add(url);
        names.add(url.toExternalForm());
        icons.add(new ExtIcon());
        TestSupport.TestProject tmp = (TestSupport.TestProject)ProjectManager.getDefault ().findProject (prj);
        assertNotNull("Project found", tmp);
        CountDownLatch down = i == 0 ? first : (i == 5 ? middle : rest);
        tmp.setLookup(Lookups.singleton(new TestProjectOpenedHookImpl(down)));
    }
    
    OpenProjectListSettings.getInstance().setOpenProjectsURLs(list);
    OpenProjectListSettings.getInstance().setOpenProjectsDisplayNames(names);
    OpenProjectListSettings.getInstance().setOpenProjectsIcons(icons);
    
     //compute project root node children in sync mode
    System.setProperty("test.projectnode.sync", "true");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ProjectsRootNodePreferredFromContextOpenTest.java

示例11: setUp

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    clearWorkDir();
    
    MockServices.setServices(TestSupport.TestProjectFactory.class);
    
    FileObject workDir = FileUtil.toFileObject(getWorkDir());
    assertNotNull(workDir);
    
    first = new CountDownLatch(1);
    middle = new CountDownLatch(1);
    rest = new CountDownLatch(2);
    
    List<URL> list = new ArrayList<URL>();
    List<ExtIcon> icons = new ArrayList<ExtIcon>();
    List<String> names = new ArrayList<String>();
    for (int i = 0; i < 10; i++) {
        FileObject prj = TestSupport.createTestProject(workDir, "prj" + i);
        URL url = URLMapper.findURL(prj, URLMapper.EXTERNAL);
        list.add(url);
        names.add(url.toExternalForm());
        icons.add(new ExtIcon());
        TestSupport.TestProject tmp = (TestSupport.TestProject)ProjectManager.getDefault ().findProject (prj);
        assertNotNull("Project found", tmp);
        CountDownLatch down = i == 0 ? first : (i == 5 ? middle : rest);
        tmp.setLookup(Lookups.singleton(new TestProjectOpenedHookImpl(down)));
    }
    
    OpenProjectListSettings.getInstance().setOpenProjectsURLs(list);
    OpenProjectListSettings.getInstance().setOpenProjectsDisplayNames(names);
    OpenProjectListSettings.getInstance().setOpenProjectsIcons(icons);
    
     //compute project root node children in sync mode
    System.setProperty("test.projectnode.sync", "true");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ProjectsRootNodePreferredFromPopupTest.java

示例12: getURL

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
/** Get a good URL for this file object which works according to type:
 * -inside this VM
 * - inside this machine
 * - from networked machines 
 * @return a suitable URL, or null
 */            
public URL getURL(FileObject fileObject, int type) {
    
    // only do external and network URLs
    if (type != URLMapper.NETWORK)
        return null;
    
    // fileObject must not be null
    if (fileObject == null)
        return null;
    
    // It should be OK to call URLMapper here because we call
    // it with different then NETWORK type.
    URL u = URLMapper.findURL(fileObject, URLMapper.EXTERNAL);
    if (u == null) {
        // if EXTERNAL type is not available try the INTERNAL one
        u = URLMapper.findURL(fileObject, URLMapper.INTERNAL);
        if (u == null) {
            return null;
        }
    }
    String path = encodeURL(u);
    HttpServerSettings settings = httpserverSettings();
    settings.setRunning(true);
    try {
        URL newURL = new URL("http",   // NOI18N
            getLocalHost(),
            settings.getPort(),
            settings.getWrapperBaseURL() + path); // NOI18N
        return newURL;
    } catch (MalformedURLException e) {
        Logger.getLogger("global").log(Level.WARNING, null, e);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:HttpServerURLMapper.java

示例13: setUp

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    clearWorkDir();

    MockServices.setServices(TestSupport.TestProjectFactory.class);
    
    FileObject workDir = FileUtil.toFileObject(getWorkDir());
    assertNotNull(workDir);
    
    first = new CountDownLatch(1);
    middle = new CountDownLatch(1);
    rest = new CountDownLatch(2);
    
    List<URL> list = new ArrayList<URL>();
    List<ExtIcon> icons = new ArrayList<ExtIcon>();
    List<String> names = new ArrayList<String>();
    for (int i = 0; i < 10; i++) {
        FileObject prj = TestSupport.createTestProject(workDir, "prj" + i);
        URL url = URLMapper.findURL(prj, URLMapper.EXTERNAL);
        list.add(url);
        names.add(url.toExternalForm());
        icons.add(new ExtIcon());
        TestSupport.TestProject tmp = (TestSupport.TestProject)ProjectManager.getDefault ().findProject (prj);
        assertNotNull("Project found", tmp);
        CountDownLatch down = i == 0 ? first : (i == 5 ? middle : rest);
        tmp.setLookup(createLookup(tmp, new TestProjectOpenedHookImpl(down)));
    }
    
    OpenProjectListSettings.getInstance().setOpenProjectsURLs(list);
    OpenProjectListSettings.getInstance().setOpenProjectsDisplayNames(names);
    OpenProjectListSettings.getInstance().setOpenProjectsIcons(icons);
    
    OpenProjects.getDefault().addPropertyChangeListener(this);
    
     //compute project root node children in sync mode
    System.setProperty("test.projectnode.sync", "true");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ProjectsRootNodePreferredOpenTest.java

示例14: setUp

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    clearWorkDir();
    
    MockServices.setServices(TestSupport.TestProjectFactory.class);
    
    FileObject workDir = FileUtil.toFileObject(getWorkDir());
    assertNotNull(workDir);
    
    down = new CountDownLatch(1);
    
    List<URL> list = new ArrayList<URL>();
    List<ExtIcon> icons = new ArrayList<ExtIcon>();
    List<String> names = new ArrayList<String>();
    for (int i = 0; i < 30; i++) {
        FileObject prj = TestSupport.createTestProject(workDir, "prj" + i);
        URL url = URLMapper.findURL(prj, URLMapper.EXTERNAL);
        list.add(url);
        names.add(url.toExternalForm());
        icons.add(new ExtIcon());
        TestSupport.TestProject tmp = (TestSupport.TestProject)ProjectManager.getDefault ().findProject (prj);
        assertNotNull("Project found", tmp);
        tmp.setLookup(Lookups.singleton(new TestProjectOpenedHookImpl(down)));
    }
    
    OpenProjectListSettings.getInstance().setOpenProjectsURLs(list);
    OpenProjectListSettings.getInstance().setOpenProjectsDisplayNames(names);
    OpenProjectListSettings.getInstance().setOpenProjectsIcons(icons);
    
     //compute project root node children in sync mode
    System.setProperty("test.projectnode.sync", "true");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:OpenProjectListSetMainTest.java

示例15: DriverClassLoader

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public DriverClassLoader(JDBCDriver driver) {
    super(new URL[] {});
    
    // Go through the URLs, and if any of them have the nbinst: protocol,
    // convert these to full-path URLs usable by the classloader
    URL[] urls = driver.getURLs();
    
    for ( URL url : urls ) {
        if ("nbinst".equals(url.getProtocol())) { // NOI18N
            // try to get a file: URL for the nbinst: URL
            FileObject fo = URLMapper.findFileObject(url);
            if (fo == null) {
                LOGGER.log(Level.WARNING, 
                    "Unable to find file object for driver url " + url);
                continue;
            }
            
            URL localURL = URLMapper.findURL(fo, URLMapper.EXTERNAL);
            if (localURL == null) {
                LOGGER.log(Level.WARNING, 
                    "Unable to get file url for nbinst url " + url);
                continue;
            }
            
            super.addURL(localURL);
        } else {
            super.addURL(url);
        }
    }                                       
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:DriverClassLoader.java


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