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;
  }
  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;
  }
  protected void updateTree() {
    itemMap.clear();
    if (errorMessage(tree)) {
      final Configuration configuration = configurationEditor.getConfiguration();
      tree.removeAll();
      final TreeItem root = new TreeItem(tree, 0);
      root.setText(configuration.getRoot().getName());
      root.setData(configuration.getRoot());
      itemMap.put(configuration.getRoot(), root);

      buildTree(
          root,
          configuration.getRoot().getChildren(),
          new FunctionalInterfaces.IFunction<Void, Void>() {
            @Override
            public Void invoke(Void t) {
              //					updateInfoLabel();
              computeTree(false);
              return null;
            }
          });
    }
  }
示例#4
0
 private String createProductDefinition(Configuration configuration) {
   String ret =
       "product " + this.configName + " from " + this.featureModel.getRoot().getName() + " : {";
   int i = 0;
   for (Iterator<Feature> iter = configuration.getSelectedFeatures().iterator();
       iter.hasNext(); ) {
     Feature feature = iter.next();
     if (!feature.isAbstract()) {
       if (i++ != 0) ret += ", ";
       ret += feature.getName();
     }
   }
   return ret + "}";
 }