예제 #1
0
  public static void addNature(IProject project) {

    if (!project.isOpen()) {
      return;
    }

    // Get the description
    IProjectDescription description;
    try {
      description = project.getDescription();
    } catch (CoreException e) {
      JsonLog.logError("Error get project description: ", e);
      return;
    }

    List<String> newIds = new ArrayList<String>();
    String[] natureIds = description.getNatureIds();
    for (String natureId : natureIds) {
      if (natureId.equals(NATURE_ID)) {
        return;
      }
    }

    newIds.addAll(Arrays.asList(natureIds));
    newIds.add(NATURE_ID);

    // Save description
    description.setNatureIds(newIds.toArray(new String[newIds.size()]));
    try {
      project.setDescription(description, null);
    } catch (CoreException e) {
      JsonLog.logError("Error set project description: ", e);
    }
  }
예제 #2
0
  public static boolean hasNature(IProject project) {

    try {
      return project.isOpen() && project.hasNature(NATURE_ID);
    } catch (CoreException e) {
      JsonLog.logError("Error determining if project has nature.: ", e);
      return false;
    }
  }