Example #1
0
  /**
   * Creates the default CASA file object in the JBI project.
   *
   * @param project a JBI project
   * @return the newly created CASA file object
   */
  public static FileObject createDefaultCasaFileObject(JbiProject project) {
    ProjectInformation projInfo = project.getLookup().lookup(ProjectInformation.class);
    assert projInfo != null;
    String projName = projInfo.getName();
    FileObject confFO = project.getProjectDirectory().getFileObject(CASA_DIR_NAME);
    FileObject casaFO = null;
    try {
      FileObject casaTemplateFO =
          FileUtil.getConfigFile(
              "org-netbeans-modules-compapp-projects-jbi/project.casa" // NOI18N
              );
      casaFO = FileUtil.copyFile(casaTemplateFO, confFO, projName);
      //            registerCasaFileListener(project);
    } catch (IOException ex) {
      ex.printStackTrace();
    }

    return casaFO;
  }
Example #2
0
  /**
   * Gets the CASA file object in the given JBI project.
   *
   * @param project a JBI project
   * @param create if <code>true</code> and the CASA file doesn't exist in the project, then an
   *     empty CASA file will be created
   * @return CASA file object
   */
  public static FileObject getCasaFileObject(JbiProject project, boolean create) {
    ProjectInformation projInfo = project.getLookup().lookup(ProjectInformation.class);
    assert projInfo != null;

    String projName = projInfo.getName();

    FileObject confFO = project.getProjectDirectory().getFileObject(CASA_DIR_NAME);
    if (confFO == null) {
      // This could happen during compapp rename with directory name change.
      return null;
    }

    FileObject casaFO = confFO.getFileObject(projName + CASA_EXT);

    if (casaFO == null && create) {
      casaFO = createDefaultCasaFileObject(project);
      updateCasaWithJBIModules(project);
    }

    return casaFO;
  }