private void restoreWidgetValues() {
   if (description != null) {
     nameText.setText(description.getName());
     nameText.setEnabled(false);
   } else {
     nameText.setText(repository.getName());
   }
   locationText.setText(TernModuleHelper.getPath(repository.getBaseDir()));
 }
Esempio n. 2
0
  @Override
  public void commit(Object caller) throws IOException {
    removeCaller(caller);
    if (isDirty()) {
      try {
        // save tern project with updated tern modules
        ITernRepository repository = project.getRepository();
        // clear Plugin + JSON Type Definition
        project.clearPlugins();
        project.clearLibs();
        // Add Plugin + JSON Type Definition
        Collection<String> requiredDependencies = null;
        ITernModule dependencyModule = null;
        List<ITernModule> sortedModules = new ArrayList<ITernModule>();
        for (ITernModule module : this.getCheckedModules()) {
          TernModuleMetadata metadata = module.getMetadata();
          if (metadata != null) {
            // add required dependencies (ex : if ecma6 is checked,
            // ecma5 must
            // be added too).
            requiredDependencies = metadata.getRequiredDependencies(module.getVersion());
            for (String dependency : requiredDependencies) {
              dependencyModule = repository.getModule(dependency);
              if (dependencyModule != null && !sortedModules.contains(dependencyModule)) {
                sortedModules.add(dependencyModule);
              }
            }
          }
          if (module != null && !sortedModules.contains(module)) {
            sortedModules.add(module);
          }
        }
        TernModuleHelper.sort(sortedModules);
        for (ITernModule m : sortedModules) {
          TernModuleHelper.update(m, project);
        }
        project.save();

      } finally {
        clear();
      }
    }
  }
 private IProjectDescription getProjectDescription() {
   File dotProject = new File(repository.getBaseDir(), IProjectDescription.DESCRIPTION_FILE_NAME);
   if (dotProject.exists()) {
     IPath path = new Path(TernModuleHelper.getPath(dotProject));
     try {
       return ResourcesPlugin.getWorkspace().loadProjectDescription(path);
     } catch (CoreException e) {
       Trace.trace(Trace.SEVERE, "Error while getting .project description", e);
     }
   }
   return null;
 }
Esempio n. 4
0
 public void initialize() throws TernException {
   // Get local and global tern modules
   List<ITernModule> allModules = project.getAllModules();
   // Group by type
   workingCopyModules = TernModuleHelper.groupByType(allModules);
   // checked modules
   List<ITernModule> checkedModules =
       new WorkingCopyModuleList(
           this,
           TernCorePlugin.getTernRepositoryManager()
               .getCheckedModules(project, workingCopyModules));
   this.setCheckedModules(checkedModules);
 }