Example usage for org.springframework.ide.eclipse.boot.wizard HierarchicalMultiSelectionFieldModel setSelection

List of usage examples for org.springframework.ide.eclipse.boot.wizard HierarchicalMultiSelectionFieldModel setSelection

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.wizard HierarchicalMultiSelectionFieldModel setSelection.

Prototype

public void setSelection(String catName, T dep, boolean selected) 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.wizard.DefaultDependencies.java

/**
 * Selects stored default dependencies on the passed selection model 
 * /*from  ww  w  . j a  va 2 s. c  o  m*/
 * @param model dependency selection model
 */
public void restore(HierarchicalMultiSelectionFieldModel<Dependency> model) {
    Arrays.asList(get(PREF_DEFAULT_DEPENDENCIES, "").split(DEPENDECIES_DELIMITER)).forEach(id -> {
        model.getCategories().stream().filter(category -> {
            Optional<Dependency> matchedDependency = Arrays.asList(model.getContents(category).getChoices())
                    .stream().filter(dependency -> {
                        return id.equals(dependency.getId());
                    }).findFirst();
            matchedDependency.ifPresent(d -> {
                model.setSelection(category, d, true);
            });
            return matchedDependency.isPresent();
        }).findFirst();
    });
}