Java Code Examples for org.openide.filesystems.FileObject.hasExt()

The following are Jave code examples for showing how to use hasExt() of the org.openide.filesystems.FileObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: JFXProjectConfigurations.java   Source Code and License Vote up 6 votes
private void readNonDefaultConfigs(String subDir, boolean createIfNotExists) {
    FileObject configsFO = projectDir.getFileObject(subDir); // NOI18N
    if (configsFO != null) {
        for (FileObject kid : configsFO.getChildren()) {
            if (!kid.hasExt(PROPERTIES_FILE_EXT)) { // NOI18N
                continue;
            }
            Map<String,String> c = getConfig(kid.getName());
            if (c == null && !createIfNotExists) {
                continue;
            }
            EditableProperties cep = null;
            try {
                cep = JFXProjectUtils.readFromFile( kid );
            } catch (IOException ex) {
                // can be ignored
            }
            addToConfig(kid.getName(), cep);
            appParams.extractEntries(cep, kid.getName());
            appManifestEntries.extractEntries(cep, kid.getName());
        }
    }
}
 
Example 2
Project: incubator-netbeans   File: ModuleActions.java   Source Code and License Vote up 6 votes
@CheckForNull TestSources findTestSources(@NonNull Lookup context, boolean allowFolders) {
    TYPE: for (String testType : project.supportedTestTypes()) {
        FileObject testSrcDir = project.getTestSourceDirectory(testType);
        if (testSrcDir != null) {
            FileObject[] files = ActionUtils.findSelectedFiles(context, testSrcDir, null, true);
            if (files != null) {
                for (FileObject file : files) {
                    if (!(file.hasExt("java") || allowFolders && file.isFolder())) {
                        break TYPE;
                    }
                }
                return new TestSources(files, testType, testSrcDir, null);
            }
        }
    }
    return null;
}
 
Example 3
Project: incubator-netbeans   File: CreatedModifiedFiles.java   Source Code and License Vote up 6 votes
@Override
public void run() throws IOException {
    FileObject target = FileUtil.createData(getProject().getProjectDirectory(), path);
    if (tokens == null) {
        copyByteAfterByte(content, target);
    } else {
        copyAndSubstituteTokens(content, target, tokens);
    }
    // #129446: form editor doesn't work sanely unless you do this:
    if (target.hasExt("form")) { // NOI18N
        FileObject java = FileUtil.findBrother(target, "java"); // NOI18N
        if (java != null) {
            java.setAttribute("justCreatedByNewWizard", true); // NOI18N
        }
    } else if (target.hasExt("java") && FileUtil.findBrother(target, "form") != null) { // NOI18N
        target.setAttribute("justCreatedByNewWizard", true); // NOI18N
    }
}
 
Example 4
Project: incubator-netbeans   File: JavaActions.java   Source Code and License Vote up 6 votes
/**
 * Check to see if a (node-like) selection contains one or more Java sources (or folders) inside the root.
 */
static boolean containsSelectedJavaSources(FileObject root, Lookup context) {
    Set<FileObject> selection = new HashSet<FileObject>();
    for (DataObject dob : context.lookupAll(DataObject.class)) {
        selection.add(dob.getPrimaryFile());
    }
    if (selection.isEmpty()) {
        return false;
    }
    for (FileObject f : selection) {
        if (f.isData() && !f.hasExt("java")) { // NOI18N
            return false;
        }
        if (f != root && !FileUtil.isParentOf(root, f)) {
            return false;
        }
    }
    return true;
}
 
Example 5
Project: incubator-netbeans   File: ProjectConfigurations.java   Source Code and License Vote up 6 votes
@NonNull
private Map<String,Configuration> calculateConfigs() {
    final Map<String,Configuration> cfgs = new HashMap<>();
    if (configDir != null) {
        for (FileObject kid : configDir.getChildren()) {
            if (!kid.hasExt("properties")) {    //NOI18N
                continue;
            }
            try {
                try (InputStream is = kid.getInputStream()) {
                    final Properties props = new Properties();
                    props.load(is);
                    final String name = kid.getName();
                    final String label = props.getProperty("$label"); // NOI18N
                    cfgs.put(name, new Configuration(name, label != null ? label : name));
                }
            } catch (IOException x) {
                LOGGER.log(Level.INFO, null, x);
            }
        }
    }
    configs = cfgs;
    LOGGER.log(Level.FINEST, "Calculated configurations: {0}", cfgs);
    return cfgs;
}
 
Example 6
Project: incubator-netbeans   File: DataObjectSaveAsTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (!fo.isFolder()) {
        // here is the common code for the worse behaviour
        if (fo.hasExt("prima")) {
            return FileUtil.findBrother(fo, "seconda") != null ? fo : null;
        }
        
        if (fo.hasExt("seconda")) {
            return FileUtil.findBrother(fo, "prima");
        }
    }
    return null;
}
 
Example 7
Project: incubator-netbeans   File: PropertyChangeTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (!fo.isFolder()) {
        // here is the common code for the worse behaviour
        if (fo.hasExt("prima")) {
            return FileUtil.findBrother(fo, "seconda") != null ? fo : null;
        }
        
        if (fo.hasExt("seconda")) {
            return FileUtil.findBrother(fo, "prima");
        }
    }
    return null;
}
 
Example 8
Project: incubator-netbeans   File: PropertiesProviderTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    Integer i = queried.get(fo);
    queried.put(fo, i == null ? 1 : i + 1);
    FileObject ret;
    
    if (fo.hasExt("java") || fo.hasExt("form")) {
        ret = org.openide.filesystems.FileUtil.findBrother(fo, "java");
    } else {
        ret = null;
    }
    
    LOG.fine("findPrimaryFile for " + fo + " yeilded " + ret);
    return ret;
}
 
Example 9
Project: incubator-netbeans   File: CreateFromTemplateHandlerTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt("java") || fo.hasExt("form")) {
        return org.openide.filesystems.FileUtil.findBrother(fo, "java");
    } else {
        return null;
    }
}
 
Example 10
Project: incubator-netbeans   File: DocumentTitlePropertyTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (!fo.isFolder()) {
        // here is the common code for the worse behaviour
        if (fo.hasExt("prima")) {
            return FileUtil.findBrother(fo, "seconda") != null ? fo : null;
        }
        
        if (fo.hasExt("seconda")) {
            return FileUtil.findBrother(fo, "prima");
        }
    }
    return null;
}
 
Example 11
Project: incubator-netbeans   File: SCFTHandlerTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    Integer i = queried.get(fo);
    queried.put(fo, i == null ? 1 : i + 1);
    FileObject ret;
    
    if (fo.hasExt("java") || fo.hasExt("form")) {
        ret = org.openide.filesystems.FileUtil.findBrother(fo, "java");
    } else {
        ret = null;
    }
    
    LOG.fine("findPrimaryFile for " + fo + " yeilded " + ret);
    return ret;
}
 
Example 12
Project: incubator-netbeans   File: FightWithWrongOrderInPathsTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt(JAVA_EXTENSION)) {
        return fo;
    } else {
        return null;
    }
}
 
Example 13
Project: incubator-netbeans   File: SCFTHandlerTest.java   Source Code and License Vote up 5 votes
protected FileObject findPrimaryFile(FileObject fo) {
    Integer i = queried.get(fo);
    queried.put(fo, i == null ? 1 : i + 1);
    FileObject ret;
    
    if (fo.hasExt("java") || fo.hasExt("form")) {
        ret = org.openide.filesystems.FileUtil.findBrother(fo, "java");
    } else {
        ret = null;
    }
    
    LOG.fine("findPrimaryFile for " + fo + " yeilded " + ret);
    return ret;
}
 
Example 14
Project: incubator-netbeans   File: CreateFromTemplateHandlerTest.java   Source Code and License Vote up 4 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt("prima")) {
        return fo;
    }
    return null;
}
 
Example 15
Project: incubator-netbeans   File: ScriptingCreateFromTemplateTest.java   Source Code and License Vote up 4 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt("prima")) {
        return fo;
    }
    return null;
}
 
Example 16
Project: incubator-netbeans   File: ScriptingCreateFromTemplateTest.java   Source Code and License Vote up 4 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt("prima")) {
        return fo;
    }
    return null;
}
 
Example 17
Project: incubator-netbeans   File: DataObjectRegistrationHinter.java   Source Code and License Vote up 4 votes
private boolean isSeparator(FileObject fo) {
    return (fo != null) && (fo.hasExt("instance") && ("javax.swing.JSeparator".equals(fo.getAttribute("instanceClass"))));
}
 
Example 18
Project: incubator-netbeans   File: JavaProjectProfilingSupportProvider.java   Source Code and License Vote up 4 votes
@Override
public boolean isFileObjectSupported(FileObject file) {
    return file.hasExt("java"); // NOI18N
}
 
Example 19
Project: incubator-netbeans   File: CanYouQueryFromRenameTest.java   Source Code and License Vote up 4 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt("txt") || fo.equals(instanceFile)) {
        return fo;
    }
    return null;
}
 
Example 20
Project: incubator-netbeans   File: PropertiesProviderTest.java   Source Code and License Vote up 4 votes
protected FileObject findPrimaryFile(FileObject fo) {
    if (fo.hasExt("prima")) {
        return fo;
    }
    return null;
}