Esempio n. 1
0
  /**
   * Check if model version is changed and rebuild PHP projects if necessary.
   *
   * @see PHPCoreConstants.STRUCTURE_VERSION
   */
  private void rebuildProjects() {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(ID);
    String modelVersion = preferences.get(PHPCoreConstants.STRUCTURE_VERSION_PREFERENCE, null);
    if (PHPCoreConstants.STRUCTURE_VERSION.equals(modelVersion)) {
      return;
    }

    preferences.put(
        PHPCoreConstants.STRUCTURE_VERSION_PREFERENCE, PHPCoreConstants.STRUCTURE_VERSION);
    try {
      preferences.flush();
    } catch (BackingStoreException e1) {
      Logger.logException(e1);
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IProject[] projects = workspace.getRoot().getProjects();
    if (workspace.isAutoBuilding()) {
      try {
        for (IProject project : projects) {
          if (PHPToolkitUtil.isPhpProject(project)) {
            project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
          }
        }
      } catch (CoreException e) {
        Logger.logException(e);
      }
    }
  }
Esempio n. 2
0
 /** Goes over the given projects and converts them */
 private void processProjects(final IProject[] projects) throws CoreException, ModelException {
   ProjectsIterate:
   for (IProject project : projects) {
     // skip unaccessible projects
     if (!project.isAccessible()) {
       continue ProjectsIterate;
     }
     // verify that the project is a PHP project
     if (PHPToolkitUtil.isPhpProject(project)) {
       IProjectDescription projectDescription = project.getDescription();
       ICommand[] commands = projectDescription.getBuildSpec();
       // check if the Script Builder is installed
       for (int i = 0; i < commands.length; ++i) {
         if (commands[i].getBuilderName().equals(DLTKCore.BUILDER_ID)) {
           // when the builder exists - continue to the next
           // project
           continue ProjectsIterate;
         }
       }
       // perform modifications only if the builder is not installed
       modifyProject(project);
     }
   }
 }