Java Code Examples for org.openide.filesystems.FileObject#existsExt()

The following examples show how to use org.openide.filesystems.FileObject#existsExt() . 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 File: BaseActionProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private String[] getTargetsForApplet(
        @NonNull final FileObject file,
        @NonNull final JavaActionProvider.Context context) {
    String[] res = null;
    if (AppletSupport.isApplet(file)) {
        EditableProperties ep = updateHelper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH);
        String jvmargs = ep.getProperty(ProjectProperties.RUN_JVM_ARGS);
        // do this only when security policy is not set manually
        if ((jvmargs == null) || !(jvmargs.indexOf("java.security.policy") != -1)) {  //NOI18N
            AppletSupport.generateSecurityPolicy(project.getProjectDirectory());
            if ((jvmargs == null) || (jvmargs.length() == 0)) {
                ep.setProperty(ProjectProperties.RUN_JVM_ARGS, "-Djava.security.policy=applet.policy"); //NOI18N
            } else {
                ep.setProperty(ProjectProperties.RUN_JVM_ARGS, jvmargs + " -Djava.security.policy=applet.policy"); //NOI18N
            }
            updateHelper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
            try {
                ProjectManager.getDefault().saveProject(project);
            } catch (IOException e) {
                ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "Error while saving project: " + e);
            }
        }
        URL url;
        if (file.existsExt("html") || file.existsExt("HTML")) { //NOI18N
            url = copyAppletHTML(file, "html"); //NOI18N
        } else {
            url = generateAppletHTML(file);
        }
        if (url == null) {
            return null;
        }
        context.setProperty("applet.url", url.toString()); // NOI18N
        String[] pathFqn = ActionProviderSupport.pathAndFqn(file, projectSourceRoots.getRoots());
        if (pathFqn != null) {
            switch(context.getCommand()) {
                case COMMAND_RUN_SINGLE:
                    res = new String[] {"run-applet"}; // NOI18N
                    break;
                case COMMAND_DEBUG_SINGLE:
                    context.setProperty("debug.class", pathFqn[1]); // NOI18N
                    res = new String[] {"debug-applet"}; // NOI18N
                    break;
                case COMMAND_PROFILE_SINGLE:
                    context.setProperty("run.class", pathFqn[1]); // NOI18N
                    res = new String[]{"profile-applet"}; // NOI18N
                    break;
            }
        }
    }
    return res;
}
 
Example 2
Source File: RefactoringInfo.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static boolean isJavaFileOfForm(FileObject fo) {
    return isJavaFile(fo) && fo.existsExt("form"); // NOI18N
}
 
Example 3
Source File: J2SEAntProjectSupportProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
    public void configurePropertiesForProfiling(final Map<String, String> props, final FileObject profiledClassFile) {
        if (profiledClassFile == null) {
////            if (mainClassSetManually != null) {
////                props.put("main.class", mainClassSetManually); // NOI18N
////                mainClassSetManually = null;
////            }
        } else {
            // In case the class to profile is explicitely selected (profile-single)
            // 1. specify profiled class name
            
            // FIXME
            JavaProfilerSource src = JavaProfilerSource.createFrom(profiledClassFile);
            if (src != null) {
                Project project = getProject();
                if (src.isApplet()) {
                    
                    String jvmargs = props.get("run.jvmargs"); // NOI18N
                    PropertyEvaluator projectProps = J2SEProjectProfilingSupportProvider.getProjectProperties(project);

                    URL url = null;

                    // do this only when security policy is not set manually
                    if ((jvmargs == null) || !(jvmargs.indexOf("java.security.policy") > 0)) { //NOI18N
                        String buildDirProp = projectProps.getProperty("build.dir"); //NOI18N
                                                                                     // TODO [M9] what if buildDirProp is null?

                        FileObject buildFolder = ProjectUtilities.getOrCreateBuildFolder(project, buildDirProp);

                        AppletSupport.generateSecurityPolicy(project.getProjectDirectory(), buildFolder);

                        if ((jvmargs == null) || (jvmargs.length() == 0)) {
                            props.put("run.jvmargs",
                                              "-Djava.security.policy=" + FileUtil.toFile(buildFolder).getPath() + File.separator
                                              + "applet.policy"); //NOI18N
                        } else {
                            props.put("run.jvmargs",
                                              jvmargs + " -Djava.security.policy=" + FileUtil.toFile(buildFolder).getPath()
                                              + File.separator + "applet.policy"); //NOI18N
                        }
                    }

                    if (profiledClassFile.existsExt("html") || profiledClassFile.existsExt("HTML")) { //NOI18N
                        url = ProjectUtilities.copyAppletHTML(project, projectProps, profiledClassFile, "html"); //NOI18N
                    } else {
                        url = ProjectUtilities.generateAppletHTML(project, projectProps, profiledClassFile);
                    }

                    if (url == null) {
                        return; // TODO: fail?
                    }

                    props.put("applet.url", url.toString()); // NOI18N
                } else {
                    final String profiledClass = src.getTopLevelClass().getQualifiedName();
                    props.put("profile.class", profiledClass); //NOI18N
                }

                // 2. include it in javac.includes so that the compile-single picks it up
                final String clazz = FileUtil.getRelativePath(ProjectUtilities.getRootOf(ProjectUtilities.getSourceRoots(project),
                                                                                         profiledClassFile), profiledClassFile);
                props.put("javac.includes", clazz); //NOI18N
            }
        }
    }