コード例 #1
0
 @Override
 public void setValue(String value) throws CoreException {
   if (!canUpdate()) {
     throw new CoreException(
         new Status(
             IStatus.ERROR,
             AutotoolsPlugin.PLUGIN_ID,
             ConfigureMessages.getString(UNMODIFIABLE_CONFIG_OPTION)));
   }
   synchronized (option) {
     option.setValue(value);
   }
 }
コード例 #2
0
  /** @since 1.2 */
  public synchronized void updateAutotoolCfgOptions(
      IProject project, String cfgId, Map<String, IAutotoolsOption> options) throws CoreException {

    // Verify project is valid Autotools project
    if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              AutotoolsPlugin.PLUGIN_ID,
              ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT)));
    }

    // Verify configuration id is valid
    IAConfiguration cfg = findCfg(project, cfgId);
    if (cfg == null) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              AutotoolsPlugin.PLUGIN_ID,
              ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID)));
    }

    // Get set of configuration options and convert to set of IAutotoolOptions
    for (Iterator<Entry<String, IAutotoolsOption>> i = options.entrySet().iterator();
        i.hasNext(); ) {
      Map.Entry<String, IAutotoolsOption> entry = i.next();
      String name = entry.getKey();
      IAutotoolsOption option = entry.getValue();
      IConfigureOption cfgOption = cfg.getOption(name);
      if (cfgOption != null) {
        cfgOption.setValue(option.getValue());
      }
    }

    // Save changes
    saveConfigs(project);
  }