Package com.es.app.customs

Source Code of com.es.app.customs.cstSearchTable

package com.es.app.customs;

import com.es.app.data.GstFormat;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.server.ThemeResource;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;

public class cstSearchTable extends VerticalLayout implements ClickListener {
  /**
   *
   */
  private static final long serialVersionUID = -6329172857657453358L;
  /** Controls */
  private Button btnSearch;
  private TextField txtBusca;
  private Table tblContainer;

  private void gstContainerTbl() {
    int size = getTblContainer().getContainerDataSource().size();
    getTblContainer().setCaption(
        "Resultados Encontrados: "
            + (size == 1500 ? size + " (Maximo a visualizar)"
                : size));
    if (size == 0) {
      getTblContainer().setDescription(null);
      getTblContainer().setContainerDataSource(null);
      getTblContainer().removeAllItems();
      getTblContainer().addContainerProperty("Nota", String.class, null);
      getTblContainer().addItem(
          new Object[] { "Su busqueda no genero resultados..." }, 0);
    } else
      getTblContainer().setDescription(
          GstFormat.description("Click para visualizar"));

  }

  public void setImmediate(boolean immediate) {
    getBtnSearch().setImmediate(immediate);
    getTxtBusca().setImmediate(immediate);
    getTblContainer().setImmediate(immediate);
  }

  public Table getTblContainer() {
    return tblContainer;
  }

  public Button getBtnSearch() {
    return btnSearch;
  }

  public TextField getTxtBusca() {
    return txtBusca;
  }

  public void setTxtBusca(TextField txtBusca) {
    this.txtBusca = txtBusca;
  }

  public void setBtnSearch(Button btnSearch) {
    this.btnSearch = btnSearch;
  }

  public void setTblContainer(Table tblContainer) {
    this.tblContainer = tblContainer;
  }

  public cstSearchTable() {
    // TODO Auto-generated constructor stub
    buildMain();
  }

  public cstSearchTable(String caption, IndexedContainer container) {
    // TODO Auto-generated constructor stub
    setCaption(caption);
    getTblContainer().setContainerDataSource(container);
    buildMain();
  }

  private void buildMain() {
    super.setMargin(false);
    super.setSpacing(false);
    super.setImmediate(true);
    super.setWidth("100%");
    super.setHeight("-1px");

    GridLayout grlSearch = new GridLayout(2, 1);
    grlSearch.setWidth("100%");
    grlSearch.setHeight("-1px");
    grlSearch.setSpacing(true);

    setTxtBusca(new TextField());
    getTxtBusca().setWidth("100%");
    getTxtBusca().setHeight("-1px");
    grlSearch.addComponent(getTxtBusca());
    grlSearch.setComponentAlignment(getTxtBusca(), Alignment.MIDDLE_CENTER);
    grlSearch.setColumnExpandRatio(0, 2);

    setBtnSearch(new Button());
    getBtnSearch().setIcon(
        new ThemeResource("../factelect/icons/refresh.png"));
    getBtnSearch().setWidth("-1px");
    getBtnSearch().setHeight("-1px");
    getBtnSearch().setStyleName(Reindeer.BUTTON_LINK);
    getBtnSearch().setDescription(
        GstFormat.description("Buscar", "Realizar busqueda con <br/>"
            + "el contenido indicado..."));
    getBtnSearch().addClickListener(this);
    grlSearch.addComponent(getBtnSearch());
    grlSearch
        .setComponentAlignment(getBtnSearch(), Alignment.MIDDLE_CENTER);
    addComponent(grlSearch);

    setTblContainer(new Table());
    getTblContainer().setWidth("100%");
    getTblContainer().setHeight("-1px");
    addComponent(getTblContainer());
  }

  @Override
  public void buttonClick(ClickEvent event) {
    // TODO Auto-generated method stub
    gstContainerTbl();
  }
}
TOP

Related Classes of com.es.app.customs.cstSearchTable

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.