Java Code Examples for org.openide.filesystems.FileObject

The following examples show how to use org.openide.filesystems.FileObject. These examples are extracted from open source projects. 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 Project: netbeans   Source File: SourceFoldersPanel.java    License: Apache License 2.0 6 votes vote down vote up
private List<SourceFolder> findPossibleSourceRoots() {
    List<SourceFolder> srcFolders = new ArrayList<SourceFolder>();
    File baseFolder = model.getBaseFolder();
    FileObject baseFolderFO = FileUtil.toFileObject(baseFolder);
    final Collection<? extends FileObject> sourceRoots = JavadocAndSourceRootDetection.findSourceRoots(baseFolderFO, null);
    for (FileObject possibleSrcRoot : sourceRoots) {
        JavaProjectGenerator.SourceFolder sf = new JavaProjectGenerator.SourceFolder();
        File sourceLoc = FileUtil.normalizeFile(FileUtil.toFile(possibleSrcRoot));
        sf.location = Util.relativizeLocation(model.getBaseFolder(), model.getNBProjectFolder(), sourceLoc);
        sf.type = ProjectModel.TYPE_JAVA;
        sf.style = JavaProjectNature.STYLE_PACKAGES;
        sf.label = getDefaultLabel(sf.location, false);
        sf.encoding = model.getEncoding();
        srcFolders.add(sf);
    }
    return srcFolders;
}
 
Example 2
Source Project: netbeans   Source File: SelectFilePanel.java    License: Apache License 2.0 6 votes vote down vote up
private SelectFilePanel(List<FileObject> sourceRoots, List<FileObject> files) {
    assert EventQueue.isDispatchThread();
    assert sourceRoots != null;
    assert !sourceRoots.isEmpty();
    assert files.size() > 1;

    this.sourceRoots = sourceRoots;

    initComponents();

    model = new DefaultListModel<>();
    for (FileObject fo : files) {
        assert isParentOf(sourceRoots, fo) : fo + " not underneath " + sourceRoots;
        model.addElement(fo);
    }

    selectFileList.setCellRenderer(new FileListCellRenderer());
    selectFileList.setModel(model);
    selectFileList.setSelectedIndex(0);
    selectFileList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            validateSelection();
        }
    });
}
 
Example 3
Source Project: netbeans   Source File: DBScriptPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void initialize(Project project, FileObject targetFolder) {
    this.project = project;
    
    projectTextField.setText(ProjectUtils.getInformation(project).getDisplayName());
    
    SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project);
    SourceGroupUISupport.connect(locationComboBox, sourceGroups);
    
    packageComboBox.setRenderer(PackageView.listRenderer());
    
    updatePackageComboBox();
    
    if (targetFolder != null) {
        // set default source group and package cf. targetFolder
        SourceGroup targetSourceGroup = SourceGroups.getFolderSourceGroup(sourceGroups, targetFolder);
        if (targetSourceGroup != null) {
            locationComboBox.setSelectedItem(targetSourceGroup);
            String targetPackage = SourceGroups.getPackageForFolder(targetSourceGroup, targetFolder);
            if (targetPackage != null) {
                packageComboBoxEditor.setText(targetPackage);
            }
        }
    }
    createDropScriptCheckbox.setVisible(false);//isn't supported yet
    uniqueName();
}
 
Example 4
Source Project: netbeans   Source File: CssEmbeddingProviderTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkVirtualSource(String file) throws Exception {
    FileObject fo = getTestFile(file);
    assertNotNull(fo);

    Source source = Source.create(fo);
    assertNotNull(source);

    Snapshot snapshot = source.createSnapshot();
    assertNotNull(snapshot);

    CssEmbeddingProvider provider = new CssEmbeddingProvider();

    List<Embedding> embeddings = provider.getEmbeddings(snapshot);
    assertNotNull(embeddings);
    assertEquals(1, embeddings.size());

    Embedding embedding = embeddings.get(0);
    Snapshot virtualSource = embedding.getSnapshot();
    String virtualSourceText = virtualSource.getText().toString();

    assertDescriptionMatches(file, virtualSourceText, false, ".virtual");
}
 
Example 5
Source Project: netbeans   Source File: CreateArchetypeTest.java    License: Apache License 2.0 6 votes vote down vote up
private AssertContent assertFile(String msg, FileObject root, String... path) throws IOException {
    FileObject at = root;
    for (String element : path) {
        at.refresh();
        FileObject next = at.getFileObject(element);
        if (next == null) {
            fail(msg +
                "\nCannot find " + Arrays.toString(path) +
                " found only " + at.getPath() +
                " and it contains:\n" +
                Arrays.toString(at.getChildren())
            );
            break;
        }
        at = next;
    }
    assertTrue("Expecting data " + at, at.isData());
    return new AssertContent(at);
}
 
Example 6
Source Project: netbeans   Source File: UnitUtilities.java    License: Apache License 2.0 6 votes vote down vote up
/**Copied from org.netbeans.api.project.
 * Create a scratch directory for tests.
 * Will be in /tmp or whatever, and will be empty.
 * If you just need a java.io.File use clearWorkDir + getWorkDir.
 */
public static FileObject makeScratchDir(NbTestCase test) throws IOException {
    test.clearWorkDir();
    File root = test.getWorkDir();
    assert root.isDirectory() && root.list().length == 0;
    FileObject fo = FileUtil.toFileObject(root);
    if (fo != null) {
        // Presumably using masterfs.
        return fo;
    } else {
        // For the benefit of those not using masterfs.
        LocalFileSystem lfs = new LocalFileSystem();
        try {
            lfs.setRootDirectory(root);
        } catch (PropertyVetoException e) {
            assert false : e;
        }
        Repository.getDefault().addFileSystem(lfs);
        return lfs.getRoot();
    }
}
 
Example 7
Source Project: netbeans   Source File: EnablePreviewAntProj.java    License: Apache License 2.0 6 votes vote down vote up
private static void storeEditableProperties(final Project prj, final String propertiesPath, final EditableProperties ep)
        throws IOException {
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            @Override
            public Void run() throws IOException {
                FileObject propertiesFo = prj.getProjectDirectory().getFileObject(propertiesPath);
                if (propertiesFo != null) {
                    OutputStream os = null;
                    try {
                        os = propertiesFo.getOutputStream();
                        ep.store(os);
                    } finally {
                        if (os != null) {
                            os.close();
                        }
                    }
                }
                return null;
            }
        });
    } catch (MutexException ex) {
    }
}
 
Example 8
Source Project: nb-ci-plugin   Source File: CIRepositories.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Set<CIFile> getFiles() {
    Set<CIFile> files = new HashSet<CIFile>();
    StringBuilder sb = new StringBuilder(ROOT_PATH);
    sb.append("/").append(name);
    sb.append("/").append(branch.toLowerCase());

    FileObject parent = FileUtil.getConfigFile(sb.toString());

    for (FileObject child : parent.getChildren()) {
        String file = (String) child.getAttribute(ATTRIBUTE_FILE);
        String version = (String) child.getAttribute(ATTRIBUTE_VERSION);
        String fileUrl = (String) child.getAttribute(ATTRIBUTE_URL);
        String md5Sum = (String) child.getAttribute(ATTRIBUTE_MD5SUM);
        String sha1Sum = (String) child.getAttribute(ATTRIBUTE_SHA1SUM);

        files.add(new CIFileImpl(file, branch, version, fileUrl, md5Sum, sha1Sum));
    }

    return files;
}
 
Example 9
Source Project: netbeans   Source File: J2eePlatformSourceForBinaryQuery.java    License: Apache License 2.0 6 votes vote down vote up
private URL getNormalizedURL (URL url) {
    //URL is already nornalized, return it
    if (isNormalizedURL(url)) {
        return url;
    }
    //Todo: Should listen on the LibrariesManager and cleanup cache        
    // in this case the search can use the cache onle and can be faster 
    // from O(n) to O(ln(n))
    URL normalizedURL = (URL) this.normalizedURLCache.get (url);
    if (normalizedURL == null) {
        FileObject fo = URLMapper.findFileObject(url);
        if (fo != null) {
            try {
                normalizedURL = fo.getURL();
                this.normalizedURLCache.put (url, normalizedURL);
            } catch (FileStateInvalidException e) {
                Exceptions.printStackTrace(e);
            }
        }
    }
    return normalizedURL;
}
 
Example 10
Source Project: BART   Source File: MainMemoryPanel.java    License: MIT License 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    File home = new File(System.getProperty("user.home"));
    File toLoad = new FileChooserBuilder(" 'Instance/Schema' XML File")
                                .setTitle("Choose File")
                                .setDefaultWorkingDirectory(home)
                                .setApproveText("OK")
                                .setAcceptAllFileFilterUsed(false)
                                .addFileFilter(new FileNameExtensionFilter("XML import file", "xml","XML"))
                                .showOpenDialog();
                
        if(toLoad==null){
            return;
        }
        FileObject fo = FileUtil.toFileObject(toLoad);
        if(fo.isFolder()){
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Select 'file.xml' no folder", NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }
        field.setText(fo.getPath());
}
 
Example 11
Source Project: netbeans   Source File: NbMoveRefactoringPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private void setup(Collection fileObjects, String postfix, boolean recursively) {
    for (Iterator i = fileObjects.iterator(); i.hasNext(); ) {
        FileObject fo = (FileObject) i.next();
        if (RetoucheUtils.isJavaFile(fo)) {
            packagePostfix.put(fo, postfix.replace('/', '.'));
            filesToMove.add(fo);
        } else if (!(fo.isFolder())) {
            packagePostfix.put(fo, postfix.replace('/', '.'));
        } else if (VisibilityQuery.getDefault().isVisible(fo)) {
            //o instanceof DataFolder
            //CVS folders are ignored
            boolean addDot = !"".equals(postfix);
            Collection col = new ArrayList();
            for (FileObject fo2: fo.getChildren()) {
                col.add(fo2);
            }
            if (recursively)
                setup(col, postfix +(addDot?".":"") +fo.getName(), true); // NOI18N
        }
    }
}
 
Example 12
Source Project: netbeans   Source File: ObserversModel.java    License: Apache License 2.0 6 votes vote down vote up
private void update( List<ExecutableElement> methods , 
        CompilationController controller) 
{
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    
    Map<Element, InjectableTreeNode<? extends Element>> methodsMap= 
        new LinkedHashMap<Element, InjectableTreeNode<? extends Element>>();
    
    for (ExecutableElement method : methods) {
        FileObject fileObject = SourceUtils.getFile(ElementHandle
                .create(method), controller.getClasspathInfo());
        MethodTreeNode node = new MethodTreeNode(fileObject, 
                method, (DeclaredType)controller.getElementUtilities().
                enclosingTypeElement(method).asType(),
                false, controller);
        insertTreeNode( methodsMap , method , node , root ,  controller);
        
    }
    setRoot(root);
}
 
Example 13
Source Project: netbeans   Source File: _RetoucheUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Tries to find {@link FileObject} which contains class with given className.<br>
 * This method will enter javac context for referenceFileObject to find class by its className,
 * therefore don't call this method within other javac context.
 * 
 * @param referenceFileObject helper file for entering javac context
 * @param className fully-qualified class name to resolve file for
 * @return resolved file or null if not found
 */
public static FileObject resolveFileObjectForClass(FileObject referenceFileObject, final String className) throws IOException {
    final FileObject[] result = new FileObject[1];
    JavaSource javaSource = JavaSource.forFileObject(referenceFileObject);
    if (javaSource == null) {
        // Should not happen, at least some debug logging, see i.e. issue #202495.
        Logger.getLogger(_RetoucheUtil.class.getName()).log(
                Level.SEVERE, "JavaSource not created for FileObject: path={0}, valid={1}, mime-type={2}",
                new Object[]{
                    referenceFileObject.getPath(),
                    referenceFileObject.isValid(),
                    referenceFileObject.getMIMEType()});
    }
    javaSource.runUserActionTask(new Task<CompilationController>() {
        @Override
        public void run(CompilationController controller) throws IOException {
            controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
            TypeElement typeElement = controller.getElements().getTypeElement(className);
            if (typeElement != null) {
                result[0] = org.netbeans.api.java.source.SourceUtils.getFile(ElementHandle.create(typeElement), controller.getClasspathInfo());
            }
        }
    }, true);
    return result[0];
}
 
Example 14
Source Project: netbeans   Source File: ActionProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
private Project findOwner(Collection<? extends Project> projects, FileObject fo) {
    FileObject parent = fo.getParent();
    if(parent == null) {
        return null;
    }
    for (Project prj : projects) {
        if(prj.getProjectDirectory().equals(fo.getParent())) {
            return prj;
        }
    }
    return null;
}
 
Example 15
Source Project: netbeans   Source File: TestUtilities.java    License: Apache License 2.0 5 votes vote down vote up
public static final FileObject copyStringToFileObject(FileObject fo, String content) 
    throws IOException 
 {
    OutputStream os = fo.getOutputStream();
    try {
        InputStream is = new ByteArrayInputStream(content.getBytes("UTF-8"));
        FileUtil.copy(is, os);
        return fo;
    } finally {
        os.close();
    }
}
 
Example 16
Source Project: netbeans   Source File: CreatedModifiedFilesTest.java    License: Apache License 2.0 5 votes vote down vote up
/** @see "#64273" */
public void testCreateLayerEntryWithoutLocalizingBundle() throws Exception {
    NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module");
    project.getProjectDirectory().getFileObject("src/org/example/module/resources/Bundle.properties").delete();
    FileObject mf = project.getProjectDirectory().getFileObject("manifest.mf");
    EditableManifest m;
    InputStream is = mf.getInputStream();
    try {
        m = new EditableManifest(is);
    } finally {
        is.close();
    }
    m.removeAttribute("OpenIDE-Module-Localizing-Bundle", null);
    OutputStream os = mf.getOutputStream();
    try {
        m.write(os);
    } finally {
        os.close();
    }
    CreatedModifiedFiles cmf = new CreatedModifiedFiles(project);
    Operation op = cmf.createLayerEntry("f", null, null, "F!", null);
    cmf.add(op);
    cmf.run();
    String[] supposedContent = new String[] {
        "<filesystem>",
        "<file name=\"f\"/>",
        "</filesystem>"
    };
    assertLayerContent(supposedContent, 
            new File(getWorkDir(), "module/src/org/example/module/resources/layer.xml"));
}
 
Example 17
Source Project: netbeans   Source File: JspUtils.java    License: Apache License 2.0 5 votes vote down vote up
/** Finds a FileObject relative to a given root folder, with a given relative path. 
 * @param rootFolder the root folder
 * @relativePath the relative path (not starting with a '/', delimited by '/')
 * @return fileobject relative to the given root folder or null if not found.
 * @exception IllegalArgumentException if relativeObject is not in rootFolder's tree.
 */
public static FileObject findRelativeFileObject(FileObject rootFolder, String relativePath) {
    if (relativePath.startsWith("/")) {  // NOI18N
        relativePath = relativePath.substring(1);
    }
    FileObject myObj = rootFolder;
    StringTokenizer st = new StringTokenizer(relativePath, "/"); // NOI18N
    while (myObj != null && st.hasMoreTokens()) {
        myObj = myObj.getFileObject(st.nextToken());
    }
    return myObj;
}
 
Example 18
Source Project: netbeans   Source File: TestCatalogModel.java    License: Apache License 2.0 5 votes vote down vote up
private Document  getDocument(FileObject fo){
    Document result = null;
    if (documentPooling) {
        result = documentPool().get(fo);
    }
    if (result != null) return result;
    try {
        
        File file = FileUtil.toFile(fo);
        FileInputStream fis = new FileInputStream(file);
        byte buffer[] = new byte[fis.available()];
        result = new org.netbeans.editor.BaseDocument(
                org.netbeans.modules.xml.text.syntax.XMLKit.class, false);
        result.remove(0, result.getLength());
        fis.read(buffer);
        fis.close();
        String str = new String(buffer);
        result.insertString(0,str,null);
        
    } catch (Exception dObjEx) {
        return null;
    }
    if (documentPooling) {
        documentPool().put(fo, result);
    }
    return result;
}
 
Example 19
Source Project: netbeans   Source File: DOMConvertorTest.java    License: Apache License 2.0 5 votes vote down vote up
protected Object readElement(org.w3c.dom.Element element) throws java.io.IOException, ClassNotFoundException {
    if (!element.getTagName().equals(ELM_COMPOSED_SETTING)) {
        throw new IllegalArgumentException("required element: " +
            ELM_COMPOSED_SETTING + ", but was: " + element.getTagName());
    }
    
    // test presence of context
    Lookup l = findContext(element.getOwnerDocument());
    if (l == null) throw new NullPointerException("missing context");
    FileObject fo = (FileObject) l.lookup(FileObject.class);
    if (fo == null) throw new NullPointerException("missing info about source");
    
    ComposedSetting cs = new ComposedSetting();
    NodeList nl = element.getChildNodes();
    for (int i = 0, len = nl.getLength(); i < len; i++) {
        Node n = nl.item(i);
        if (n instanceof Element) {
            Object obj = delegateRead((Element) n);
            if (obj instanceof java.awt.Button) {
                if (cs.b1 == null) {
                    cs.b1 = (java.awt.Button) obj;
                } else {
                    cs.b2 = (java.awt.Button) obj;
                }
            } else {
                cs.cs = (ComposedSetting) obj;
            }
        }
    }
    return cs;
}
 
Example 20
Source Project: netbeans   Source File: Util.java    License: Apache License 2.0 5 votes vote down vote up
@CheckForNull
private static PathResourceImplementation getJfxRt(@NonNull final Collection<? extends FileObject> installFolders) {
    for (FileObject installFolder : installFolders) {
        final FileObject jfxrt = installFolder.getFileObject(JFXRT_PATH);
        if (jfxrt != null && FileUtil.isArchiveFile(jfxrt)) {
            return ClassPathSupport.createResource(FileUtil.getArchiveRoot(jfxrt.toURL()));
        }
    }
    return null;
}
 
Example 21
Source Project: netbeans   Source File: PoliciesVisualPanel.java    License: Apache License 2.0 5 votes vote down vote up
/** Creates new form PoliciesVisualPanel */
public PoliciesVisualPanel( final List<String> policyIds , 
        FileObject javaFile ) 
{
    myWsJavaFile = javaFile;
    
    final JavaSource javaSource = JavaSource.forFileObject(javaFile );
    if ( javaSource == null ){
        showLabel( NbBundle.getMessage( PoliciesVisualPanel.class, 
                "ERR_NoWSAccess"));         // NOI18N
        return;
    }
    else {
        showLabel( NbBundle.getMessage( PoliciesVisualPanel.class, 
            "LBL_Wait"));         // NOI18N
    }
    
    JAVA_PROCESSOR.post( new Runnable() {
        
        @Override
        public void run() {
            final Set<String> chosenIds = getWsPolicyIds( javaSource );
            SwingUtilities.invokeLater( new Runnable() {
                @Override
                public void run() {
                    initUI(policyIds, chosenIds );
                }
            });
            
        }
    });
    
}
 
Example 22
Source Project: netbeans   Source File: PHPCodeCompletion201870Test.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Map<String, ClassPath> createClassPathsForTest() {
    return Collections.singletonMap(
        PhpSourcePath.SOURCE_CP,
        ClassPathSupport.createClassPath(new FileObject[] {
            FileUtil.toFileObject(new File(getDataDir(), "/testfiles/completion/lib/test201870/"))
        })
    );
}
 
Example 23
Source Project: netbeans   Source File: ResourceWizardPanel.java    License: Apache License 2.0 5 votes vote down vote up
/** Helper method. Gets user selected resource. */
private DataObject selectResource() {        
    FileObject fo = null;
    DataObject source = null;
    for (DataObject dobj : sourceMap.keySet()) {
        fo = dobj.getPrimaryFile();            
        source = dobj;
    }

    // Get i18n support for this source.
    I18nSupport support = null;
    try {
        support = FactoryRegistry.getFactory(source.getClass()).create(source);
    } catch(IOException ioe) {
        ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe);            
    }

    ResourceHolder rh = support != null ? support.getResourceHolder() : null;
    
    DataObject template = null;
    try {
        template = rh != null ? rh.getTemplate(rh.getResourceClasses()[0]) : null;
    } catch (IOException ex) {
        ErrorManager.getDefault().notify(ex);
    }
        
    return SelectorUtils.selectOrCreateBundle(fo, template, null);
}
 
Example 24
Source Project: netbeans   Source File: TestUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static EditableProperties loadProjectProperties(
        final FileObject projectDir) throws IOException {
    FileObject propsFO = projectDir.getFileObject(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    InputStream propsIS = propsFO.getInputStream();
    EditableProperties props = new EditableProperties(true);
    try {
        props.load(propsIS);
    } finally {
        propsIS.close();
    }
    return props;
}
 
Example 25
Source Project: netbeans   Source File: ElementsTest.java    License: Apache License 2.0 5 votes vote down vote up
public void test175535() throws Exception {
    prepareTest();
    FileObject otherFO = FileUtil.createData(sourceRoot, "test/A.java");
    TestUtilities.copyStringToFile(FileUtil.toFile(otherFO),
            "package test;" +
            "public class A implements Runnable {" +
            "    @Override" +
            "    public void run() {}" +
            "}");
    TestUtilities.copyStringToFile(FileUtil.toFile(testFO),
            "public class Test {" +
            "}");
    SourceUtilsTestUtil.compileRecursively(sourceRoot);
    JavaSource javaSource = JavaSource.forFileObject(testFO);
    javaSource.runUserActionTask(new Task<CompilationController>() {
        public void run(CompilationController controller) throws IOException {
            controller.toPhase(JavaSource.Phase.RESOLVED);
            TypeElement typeElement = controller.getElements().getTypeElement("test.A");
            assertNotNull(typeElement);
            Element el = typeElement.getEnclosedElements().get(1);
            assertNotNull(el);
            assertEquals("run", el.getSimpleName().toString());
            TreePath mpath = controller.getTrees().getPath(el);
            MethodTree mtree = (MethodTree) mpath.getLeaf();
            assertNotNull(mtree);
            List<? extends AnnotationTree> annotations = mtree.getModifiers().getAnnotations();
            TypeMirror annotation = controller.getTrees().getTypeMirror(new TreePath(mpath, annotations.get(0)));
            assertNotNull(annotation);
            Element e = controller.getTrees().getElement(new TreePath(mpath, annotations.get(0)));
            assertNotNull(e);
            assertEquals(((DeclaredType)annotation).asElement(), e);
        }
    }, true);
}
 
Example 26
public FileObject getFile() {
    List<FileObject> result = super.getFileObjects();
    
    if (result.size() == 1)
        return result.get(0);
    
    return null;
}
 
Example 27
Source Project: netbeans   Source File: EcmaLevelRule.java    License: Apache License 2.0 5 votes vote down vote up
private static void reindexFile(final FileObject fo) {
    RP.post(new Runnable() {
        @Override
        public void run() {
            //refresh Action Items for this file
            IndexingManager.getDefault().refreshIndexAndWait(fo.getParent().toURL(),
                    Collections.singleton(fo.toURL()), true, false);
        }
    });
}
 
Example 28
Source Project: netbeans   Source File: Issue239162Test.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Map<String, ClassPath> createClassPathsForTest() {
    List<FileObject> cpRoots = new LinkedList<FileObject>(ClasspathProviderImplAccessor.getJsStubs());
    
    cpRoots.add(FileUtil.toFileObject(new File(getDataDir(), "/testfiles/navigation/239162")));
    return Collections.singletonMap(
        JS_SOURCE_ID,
        ClassPathSupport.createClassPath(cpRoots.toArray(new FileObject[cpRoots.size()]))
    );
}
 
Example 29
Source Project: netbeans   Source File: WadlSaasEx.java    License: Apache License 2.0 5 votes vote down vote up
public List<FileObject> getJaxbSourceJars() {
    if (jaxbSourceJars == null) {
        try {
            compileSchemas();
            return Collections.unmodifiableList(jaxbSourceJars);
        } catch(IOException ex) {
            ex.printStackTrace();
        }
    }
    return Collections.emptyList();
}
 
Example 30
Source Project: netbeans   Source File: GenerateBeanInfoAction.java    License: Apache License 2.0 5 votes vote down vote up
protected boolean enable( Node[] activatedNodes ) {
    if (activatedNodes.length != 1) {
        return false;
    } else {
        FileObject fo = findFileObject(activatedNodes[0]);
        return fo != null && JavaSource.forFileObject(fo) != null
                && !fo.getName().endsWith("BeanInfo"); //NOI18N
    }
}