Package org.molgenis.ui

Source Code of org.molgenis.ui.SelectInput

package org.molgenis.ui;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.molgenis.util.ValueLabel;

public class SelectInput extends HtmlInput<SelectInput, ValueLabel>
{
  List<ValueLabel> options = new ArrayList<ValueLabel>();

  public SelectInput(String id, ValueLabel value)
  {
    super(id, value);
  }

  public SelectInput(String id, String value)
  {
    super(id, new ValueLabel(value, value));
  }

  public SelectInput setOptions(Map<String, String> options)
  {
    this.options.clear();
    for (Entry<String, String> e : options.entrySet())
    {
      this.options.add(new ValueLabel(e.getKey(), e.getValue()));
    }
    return this;
  }

  public SelectInput options(String... options)
  {
    this.options.clear();
    for (String s : options)
    {
      this.options.add(new ValueLabel(s, s));
    }
    return this;
  }

  public void clearOptions()
  {
    options.clear();
  }

  public List<ValueLabel> getOptions()
  {
    return options;
  }
}
TOP

Related Classes of org.molgenis.ui.SelectInput

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.