private List<Configuration> createConfigurations(
      final Collection<String> unusedFeatures, final IMonitor monitor, boolean collect) {
    monitor.setTaskName("Create configurations");
    monitor.setRemainingWork(unusedFeatures.size());
    final List<Configuration> confs = new LinkedList<Configuration>();
    final FileHandler<Configuration> writer =
        new FileHandler<>(ConfigurationManager.getDefaultFormat());
    Configuration configuration = new Configuration(featureModel, false);
    try {
      List<List<String>> solutions = configuration.coverFeatures(unusedFeatures, monitor, false);
      for (List<String> solution : solutions) {
        configuration = new Configuration(featureModel, false);
        for (String feature : solution) {
          if (!"True".equals(feature)) {
            configuration.setManual(feature, Selection.SELECTED);
          }
        }
        if (collect) {
          confs.add(configuration);
        } else {
          final IFile configurationFile = getConfigurationFile(project.getConfigFolder());
          writer.write(Paths.get(configurationFile.getLocationURI()), configuration);
        }
      }
    } catch (TimeoutException e1) {
      e1.printStackTrace();
    }

    return confs;
  }
Ejemplo n.º 2
0
 public void setManual(String name, Selection selection) {
   SelectableFeature feature = table.get(name);
   if (feature == null) {
     throw new FeatureNotFoundException();
   }
   setManual(feature, selection);
 }
  private List<Configuration> createConfigurations(
      final Collection<String> unusedFeatures, final WorkMonitor monitor, boolean collect) {
    final List<Configuration> confs = new LinkedList<Configuration>();
    try {
      Configuration configuration = new Configuration(featureModel, false);
      List<List<String>> solutions = configuration.coverFeatures(unusedFeatures, monitor, false);
      for (List<String> solution : solutions) {
        configuration = new Configuration(featureModel, false);
        for (String feature : solution) {
          if (!"True".equals(feature)) {
            configuration.setManual(feature, Selection.SELECTED);
          }
        }
        if (collect) {
          confs.add(configuration);
        } else {
          final ConfigurationWriter writer = new ConfigurationWriter(configuration);
          writer.saveToFile(getConfigurationFile(project.getConfigFolder()));
        }
      }

    } catch (TimeoutException | CoreException e1) {
      e1.printStackTrace();
    }

    return confs;
  }
Ejemplo n.º 4
0
  /**
   * This method creates a clone of the given {@link Configuration}
   *
   * @param configuration The configuration to clone
   */
  protected Configuration(Configuration configuration) {
    this.featureModel = configuration.featureModel;
    this.ignoreAbstractFeatures = configuration.ignoreAbstractFeatures;
    this.propagator = configuration.propagator.clone(this);
    propagate = false;
    this.root = initRoot();

    for (SelectableFeature f : configuration.features) {
      setManual(f.getName(), f.getManual());
      setAutomatic(f.getName(), f.getAutomatic());
    }
    this.propagate = configuration.propagate;
  }
Ejemplo n.º 5
0
  /**
   * Copy constructor. Copies the status of a given configuration.
   *
   * @param configuration
   * @param featureModel the underlying feature model. The model can be different from the old
   *     configuration.
   * @param propagate
   */
  public Configuration(Configuration configuration, IFeatureModel featureModel) {
    this.featureModel = featureModel;
    this.ignoreAbstractFeatures = configuration.ignoreAbstractFeatures;
    this.propagator = new ConfigurationPropagator(this);
    this.propagate = false;
    this.root = initRoot();

    for (SelectableFeature f : configuration.features) {
      try {
        setManual(f.getName(), (f.getManual()));
      } catch (FeatureNotFoundException e) {
      }
    }

    loadPropagator(configuration.propagate);
  }