Esempio n. 1
0
 public void resetValues() {
   for (SelectableFeature feature : features) {
     feature.setManual(Selection.UNDEFINED);
     feature.setAutomatic(Selection.UNDEFINED);
   }
   update(false, null);
 }
Esempio n. 2
0
 public Set<String> getSelectedFeatureNames() {
   final Set<String> result = new HashSet<String>();
   for (SelectableFeature feature : features) {
     if (feature.getSelection() == Selection.SELECTED) {
       result.add(feature.getName());
     }
   }
   return result;
 }
Esempio n. 3
0
 public List<IFeature> getSelectedFeatures() {
   final List<IFeature> result = new ArrayList<IFeature>();
   for (SelectableFeature feature : features) {
     if (feature.getSelection() == Selection.SELECTED) {
       result.add(feature.getFeature());
     }
   }
   return result;
 }
Esempio n. 4
0
 public List<SelectableFeature> getManualFeatures() {
   final List<SelectableFeature> featureList = new LinkedList<SelectableFeature>();
   for (SelectableFeature selectableFeature : features) {
     if (selectableFeature.getAutomatic() == Selection.UNDEFINED
         && !selectableFeature.getFeature().getStructure().hasHiddenParent()) {
       featureList.add(selectableFeature);
     }
   }
   return featureList;
 }
Esempio n. 5
0
 /**
  * Turns all automatic into manual values
  *
  * @param discardDeselected if {@code true} all automatic deselected features get undefined
  *     instead of manual deselected
  */
 public void makeManual(boolean discardDeselected) {
   for (SelectableFeature feature : features) {
     final Selection autoSelection = feature.getAutomatic();
     if (autoSelection != Selection.UNDEFINED) {
       feature.setAutomatic(Selection.UNDEFINED);
       if (!discardDeselected || autoSelection == Selection.SELECTED) {
         feature.setManual(autoSelection);
       }
     }
   }
 }
Esempio n. 6
0
 private void initFeatures(SelectableFeature sFeature, IFeature feature) {
   if (sFeature != null && sFeature.getName() != null) {
     features.add(sFeature);
     table.put(sFeature.getName(), sFeature);
     for (IFeatureStructure child : feature.getStructure().getChildren()) {
       SelectableFeature sChild = new SelectableFeature(this, child.getFeature());
       sFeature.addChild(sChild);
       initFeatures(sChild, child.getFeature());
     }
   }
 }
Esempio n. 7
0
 @Override
 public String toString() {
   StringBuilder builder = new StringBuilder();
   for (SelectableFeature feature : features) {
     if (feature.getSelection() == Selection.SELECTED
         && feature.getFeature().getStructure().isConcrete()) {
       builder.append(feature.getFeature().getName());
       builder.append("\n");
     }
   }
   return builder.toString();
 }
Esempio n. 8
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;
  }
Esempio n. 9
0
  private SelectableFeature initRoot() {
    final IFeature featureRoot = FeatureUtils.getRoot(featureModel);
    final SelectableFeature root = new SelectableFeature(this, featureRoot);

    if (featureRoot != null) {
      initFeatures(root, featureRoot);
    } else {
      features.add(root);
      table.put(root.getName(), root);
    }

    return root;
  }
Esempio n. 10
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);
  }
Esempio n. 11
0
 public void setManual(SelectableFeature feature, Selection selection) {
   feature.setManual(selection);
   update(false, null);
 }
Esempio n. 12
0
 void setAutomatic(SelectableFeature feature, Selection selection) {
   feature.setAutomatic(selection);
 }
Esempio n. 13
0
 void resetAutomaticValues() {
   for (SelectableFeature feature : features) {
     feature.setAutomatic(Selection.UNDEFINED);
   }
 }