Example usage for com.vaadin.ui ComboBox ComboBox

List of usage examples for com.vaadin.ui ComboBox ComboBox

Introduction

In this page you can find the example usage for com.vaadin.ui ComboBox ComboBox.

Prototype

public ComboBox() 

Source Link

Document

Constructs an empty combo box without a caption.

Usage

From source file:de.fzi.fhemapi.view.vaadin.ui.NewRoomPanel.java

License:Apache License

private VerticalLayout buildMainLayout() {
    VerticalLayout layout = new VerticalLayout();

    nameTextField = new TextField();
    HorizontalLayout nameLay = UIHelper.buildAttributePanel("Name", nameTextField);
    layout.addComponent(nameLay);/*from   w  w w  .  j  a v  a2  s . c o m*/

    typeComboBox = new ComboBox();
    for (String type : roomTypes) {
        typeComboBox.addItem(type);
    }

    HorizontalLayout typeLay = UIHelper.buildAttributePanel("Typ", typeComboBox);
    layout.addComponent(typeLay);
    layout.setComponentAlignment(typeLay, Alignment.TOP_CENTER);

    Label devicesLabel = new Label();
    devicesLabel.setImmediate(false);
    devicesLabel.setWidth("100%");
    devicesLabel.setHeight("50");
    devicesLabel.setValue("<b>Gerte</b>");
    devicesLabel.setContentMode(Label.CONTENT_XHTML);
    layout.addComponent(devicesLabel);
    layout.setComponentAlignment(devicesLabel, Alignment.TOP_CENTER);

    List<Device> deviceList = parent.server.getDeviceManager().getDevices();
    devicesCheckBox = new CheckBox[deviceList.size()];
    for (int i = 0; i < deviceList.size(); i++) {
        devicesCheckBox[i] = new CheckBox(deviceList.get(i).getName());
        layout.addComponent(devicesCheckBox[i]);
        layout.setComponentAlignment(devicesCheckBox[i], Alignment.MIDDLE_CENTER);
    }

    Button saveButton = new Button("Speichern");
    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            List<String> names = new LinkedList<String>();
            for (CheckBox checkbox : devicesCheckBox) {
                if (checkbox.booleanValue())
                    names.add(checkbox.getCaption());
            }

            Structure struc = new Structure((String) nameTextField.getValue(), (String) typeComboBox.getValue(),
                    names);
            MessageResponse response = parent.server.getStructureManager().createNewStructure(struc);
            getWindow().showNotification(response.toString(), Notification.TYPE_TRAY_NOTIFICATION);
            parent.server.getStructureManager().rereadFromFHEM();
            parent.reloadTree();
        }
    });
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER);

    return layout;
}

From source file:de.metas.ui.web.vaadin.window.components.FieldEditorFactory.java

License:Open Source License

private final ComboBox createField_ComboBox(final DataFieldPropertyDescriptor descriptor) {
    ////w w w.  j  ava2s. co m
    // DataSource & Container
    final String columnName = descriptor.getColumnName();
    final int displayType = descriptor.getDisplayType();
    final int adReferenceId = descriptor.getAD_Reference_Value_ID();
    final ILookupDataSource dataSource = windowContext.getLookupDataSource(columnName, displayType,
            adReferenceId);
    final FieldEditorContainer container = LookupFieldEditorContainer.of(dataSource);

    //
    // Converter
    // final Converter<Object, ?> converter = container.getConverter();

    //
    // ComboBox
    final ComboBox comboboxField = new ComboBox();
    // comboboxField.setConverter(converter);
    comboboxField.setContainerDataSource(container);
    comboboxField.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    comboboxField.setItemCaptionPropertyId(container.getCaptionPropertyId());
    comboboxField.setItemIconPropertyId(container.getIconPropertyId());
    return comboboxField;
}

From source file:de.unioninvestment.eai.portal.portlet.crud.datatypes.AbstractDataType.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
protected AbstractSelect createSelect(Class<?> type, Object propertyId, Format format) {
    AbstractSelect select = new ComboBox();
    select.setConverter((Converter) createFormatter(type, format));
    select.setReadOnly(isReadonly());//from  ww w. j  a  v a2 s .  com
    return select;
}

From source file:de.uni_leipzig.informatik.pcai042.boa.gui.goldstandard.GoldstandardGUI.java

License:Open Source License

@SuppressWarnings("deprecation")
@AutoGenerated// ww  w.ja va  2s. c o m
private AbsoluteLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new AbsoluteLayout();
    mainLayout.setCaption("close XML");
    mainLayout.setImmediate(false);
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    mainLayout.setMargin(false);

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // buttonNext
    buttonNext = new Button();
    buttonNext.setCaption("next");
    buttonNext.setImmediate(true);
    buttonNext.setWidth("-1px");
    buttonNext.setHeight("-1px");
    mainLayout.addComponent(buttonNext, "top:0.0px;left:81.0px;");

    // buttonDiscard
    buttonDiscard = new Button();
    buttonDiscard.setCaption("discard");
    buttonDiscard.setImmediate(true);
    buttonDiscard.setWidth("-1px");
    buttonDiscard.setHeight("-1px");
    mainLayout.addComponent(buttonDiscard, "top:0.0px;left:431.0px;");

    // buttonAddAnno
    buttonAddAnno = new Button();
    buttonAddAnno.setCaption("add");
    buttonAddAnno.setImmediate(true);
    buttonAddAnno.setWidth("-1px");
    buttonAddAnno.setHeight("-1px");
    mainLayout.addComponent(buttonAddAnno, "top:180.0px;left:160.0px;");

    // buttonDelAnno
    buttonDelAnno = new Button();
    buttonDelAnno.setCaption("delete");
    buttonDelAnno.setImmediate(true);
    buttonDelAnno.setWidth("-1px");
    buttonDelAnno.setHeight("-1px");
    mainLayout.addComponent(buttonDelAnno, "top:180.0px;left:439.0px;");

    // comboBoxTypes
    comboBoxTypes = new ComboBox();
    comboBoxTypes.setImmediate(false);
    comboBoxTypes.setWidth("210px");
    comboBoxTypes.setHeight("-1px");
    mainLayout.addComponent(comboBoxTypes, "top:269.0px;left:0.0px;");

    // textFieldLabel
    textFieldLabel = new TextField();
    textFieldLabel.setImmediate(false);
    textFieldLabel.setWidth("210px");
    textFieldLabel.setHeight("-1px");
    textFieldLabel.setSecret(false);
    mainLayout.addComponent(textFieldLabel, "top:206.0px;left:0.0px;");

    // labelLabel
    labelLabel = new Label();
    labelLabel.setImmediate(false);
    labelLabel.setWidth("-1px");
    labelLabel.setHeight("-1px");
    labelLabel.setValue("Label:");
    mainLayout.addComponent(labelLabel, "top:182.0px;left:1.0px;");

    // labelType
    labelType = new Label();
    labelType.setImmediate(false);
    labelType.setWidth("-1px");
    labelType.setHeight("-1px");
    labelType.setValue("Type:");
    mainLayout.addComponent(labelType, "top:242.0px;left:0.0px;");

    // panelTokens
    panelTokens = buildPanelTokens();
    mainLayout.addComponent(panelTokens, "top:30.0px;left:0.0px;");

    // listSelectAnnotations
    listSelectAnnotations = new ListSelect();
    listSelectAnnotations.setImmediate(false);
    listSelectAnnotations.setWidth("271px");
    listSelectAnnotations.setHeight("87px");
    mainLayout.addComponent(listSelectAnnotations, "top:206.0px;left:230.0px;");

    // labelSentence
    labelSentence = new Label();
    labelSentence.setImmediate(false);
    labelSentence.setWidth("-1px");
    labelSentence.setHeight("-1px");
    labelSentence.setValue("Sentence:");
    mainLayout.addComponent(labelSentence, "top:2.0px;left:0.0px;");

    // labelAnnotations
    labelAnnotations = new Label();
    labelAnnotations.setImmediate(false);
    labelAnnotations.setWidth("-1px");
    labelAnnotations.setHeight("-1px");
    labelAnnotations.setValue("Annotations:");
    mainLayout.addComponent(labelAnnotations, "top:182.0px;left:230.0px;");

    return mainLayout;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterViewImpl.java

License:Open Source License

private void generateUi() {

    setMargin(true);/* w  ww. j av a  2 s . c  om*/
    //setSizeFull();
    setLocked(true);
    setStyleName("small");

    // TODO: Zeilenanzahl anpassen
    gridLayout = new GridLayout(3, 30);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    //gridLayout.setSizeFull();

    VerticalLayout infoBox = new VerticalLayout();
    infoBox.setMargin(true);
    Label infoText1 = new Label("<h3>Deterministische Parameter:</h3>");
    infoText1.setContentMode(Label.CONTENT_XHTML);
    Label infoText2 = new Label(
            "Hier geben Sie das Basisjahr an, auf welches die knftigen Cashflows abgezinst werden. "
                    + "Zustzlich mssen Sie auch die Anzahl der einzubeziehenden zuknftigen Perioden ange-ben. "
                    + "Beachten Sie hierbei, dass Sie nur so viele Perioden angeben, "
                    + "wie Sie Daten ber die Cashflows des Unternehmens haben.");
    Label infoText3 = new Label("<h3>Stochastische Parameter:</h3>");
    infoText3.setContentMode(Label.CONTENT_XHTML);
    Label infoText4 = new Label(
            "Hier geben Sie das Basisjahr an, auf welches die knftigen Cashflows abgezinst werden. "
                    + "Zustzlich mssen Sie auch die Anzahl der zu prognostizierenden Perioden angeben. "
                    + "Die Prognose erfolgt auf Basis vergangener Werte, daher mssen Sie auch die Anzahl der ver-gangenen Perioden angeben. "
                    + "Beachten Sie hierbei, dass Sie nur so viele Perioden angeben, wie Sie Daten ber die Cashflows des Unternehmens haben. "
                    + "Des Weiteren haben Sie die Mglichkeit die Anzahl der Wiederholungen anzugeben. "
                    + "Info: Je mehr Iterationen Sie durchfhren lassen, desto genauer werden die Prognosewerte, aber desto lnger dauert die Berechnung.");

    infoBox.addComponent(infoText1);
    infoBox.addComponent(infoText2);
    infoBox.addComponent(infoText3);
    infoBox.addComponent(infoText4);

    setFirstComponent(gridLayout);
    setSecondComponent(infoBox);

    // Heading 1
    labelHeadingCommon = new Label("Allgemein");
    //gridLayout.addComponent(labelHeadingCommon, 0, 0);

    labelBasisYear = new Label("Basisjahr");
    gridLayout.addComponent(labelBasisYear, 0, 1);

    textfieldBasisYear = new TextField();
    textfieldBasisYear.setImmediate(true);
    textfieldBasisYear.setDescription(toolTipBasisYear);
    textfieldBasisYear.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.basisYearChosen((String) textfieldBasisYear.getValue());
        }
    });
    gridLayout.addComponent(textfieldBasisYear, 1, 1);

    // Heading 2
    labelHeadingMethDet = new Label("Stochastische Parameter:");
    gridLayout.addComponent(labelHeadingMethDet, 0, 3);

    labelNumPeriods = new Label("Anzahl zu prognostizierender Perioden");
    gridLayout.addComponent(labelNumPeriods, 0, 4);

    textfieldNumPeriodsToForecast = new TextField();
    textfieldNumPeriodsToForecast.setImmediate(true);
    textfieldNumPeriodsToForecast.setDescription(toolTipNumPeriodsToForecast);
    textfieldNumPeriodsToForecast.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.numberPeriodsToForecastChosen((String) textfieldNumPeriodsToForecast.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPeriodsToForecast, 1, 4);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 4);

    labelIterations = new Label("Durchlufe / Iterationen");
    gridLayout.addComponent(labelIterations, 0, 5);

    textfieldIterations = new TextField();
    textfieldIterations.setImmediate(true);
    // textfieldIterations.setValue(10000);
    textfieldIterations.setDescription(toolTipIterations);
    textfieldIterations.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            logger.debug(textfieldIterations.getValue());
            presenter.iterationChosen((String) textfieldIterations.getValue());
        }
    });
    gridLayout.addComponent(textfieldIterations, 1, 5);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 5);

    labelNumSpecifiedPastPeriods = new Label("Anzahl anzugebender, vergangener Perioden");
    gridLayout.addComponent(labelNumSpecifiedPastPeriods, 0, 6);

    textfieldNumSpecifiedPastPeriods = new TextField();
    textfieldNumSpecifiedPastPeriods.setImmediate(true);
    // textfieldIterations.setValue(10000);
    textfieldNumSpecifiedPastPeriods.setDescription(toolTipNumSpecifiedPastPeriods);
    textfieldNumSpecifiedPastPeriods.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            logger.debug(textfieldNumSpecifiedPastPeriods.getValue());
            presenter.specifiedPastPeriodsChosen((String) textfieldNumSpecifiedPastPeriods.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumSpecifiedPastPeriods, 1, 6);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 6);

    /**
     * Auskommentiert, da nicht fr Zeitreihenanalyse bentigt
     * 
    labelStepsPerPeriod = new Label("Schritte pro Periode");
    gridLayout.addComponent(labelStepsPerPeriod, 0, 6);
            
            
    textfieldStepsPerPeriod = new TextField();
    textfieldStepsPerPeriod.setImmediate(true);
    textfieldStepsPerPeriod.setDescription(toolTipStepsPerPeriod);
    textfieldStepsPerPeriod.addListener(new Property.ValueChangeListener() {
       private static final long serialVersionUID = 1L;
            
       public void valueChange(ValueChangeEvent event) {
    presenter.stepsPerPeriodChosen((String) textfieldStepsPerPeriod
          .getValue());
       }
    });
    gridLayout.addComponent(textfieldStepsPerPeriod, 1, 6);
            
    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 6);
     */
    // Heading 3

    labelHeadingTimeSeries = new Label("Stochastisch: Zeitreihenanalyse");
    //gridLayout.addComponent(labelHeadingTimeSeries, 0, 8);

    labelNumPastPeriods = new Label("Anzahl einbezogener, vergangener Perioden");
    gridLayout.addComponent(labelNumPastPeriods, 0, 9);

    textfieldNumPastPeriods = new TextField();
    textfieldNumPastPeriods.setImmediate(true);
    // textfieldNumPastPeriods: Wert darf hier nicht gesetzt werden
    // -> ber Event, sodass der Wert ins Projekt bernommen wird und nicht
    // nur einfach angezeigt wird ohne ausgewertet werden zu knnen
    // textfieldNumPastPeriods.setValue(5);
    textfieldNumPastPeriods.setDescription(toolTipNumPastPeriods
            + " Bitte beachten Sie, dass in dem Reiter Perioden immer eine Periode mehr angegeben werden muss. Diese zustzliche Periode wird bei einem Berechnungsverfahren der Zeitreihenanalyse bentigt.");
    textfieldNumPastPeriods.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.relevantPastPeriodsChosen((String) textfieldNumPastPeriods.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPastPeriods, 1, 9);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 9);

    checkboxIndustryRepresentative = new CheckBox();
    checkboxIndustryRepresentative.setCaption("Branchenstellvertreter einbeziehen");
    checkboxIndustryRepresentative.setDescription(toolTipIndustryRepresentatives);
    checkboxIndustryRepresentative.addListener(new ClickListener() {
        /**
         * Derzeit unbenutzt, da die Funkionalitaet in der Berechnung noch
         * nicht hinterlegt ist.
         * 
         * @see init()-Methode dieser Klasse
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.industryRepresentativeCheckBoxSelected(checkboxIndustryRepresentative.booleanValue());
        }
    });
    gridLayout.addComponent(checkboxIndustryRepresentative, 0, 10);

    comboBoxRepresentatives = new ComboBox();
    comboBoxRepresentatives.setImmediate(true);
    comboBoxRepresentatives.setInputPrompt("Branche ausw\u00e4hlen");
    comboBoxRepresentatives.setNullSelectionAllowed(false);
    comboBoxRepresentatives.addListener(new Property.ValueChangeListener() {
        /**
         * Derzeit unbenutzt, da die Funkionalitaet in der Berechnung auf
         * Basis von Branchenverreter in dieser Softareversion noch nicht
         * hinterlegt ist.
         * 
         * @see init()-Methode dieser Klasse
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            presenter.industryRepresentativeListItemChosen((String) event.getProperty().getValue());
            logger.debug("Branche " + event + " gewaehlt");
        }
    });

    gridLayout.addComponent(comboBoxRepresentatives, 1, 10);

    // Heading 4

    // Heading 6
    labelHeadingMethDet = new Label("Deterministische Parameter:");
    gridLayout.addComponent(labelHeadingMethDet, 0, 26);
    labelNumPeriods_deterministic = new Label("Anzahl anzugebender Perioden");
    gridLayout.addComponent(labelNumPeriods_deterministic, 0, 27);

    textfieldNumPeriodsToForecast_deterministic = new TextField();
    textfieldNumPeriodsToForecast_deterministic.setImmediate(true);
    textfieldNumPeriodsToForecast_deterministic.setDescription(toolTipNumPeriodsToForecast_deterministic);
    textfieldNumPeriodsToForecast_deterministic.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.numberPeriodsToForecastChosen_deterministic(
                    (String) textfieldNumPeriodsToForecast_deterministic.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPeriodsToForecast_deterministic, 1, 27);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 27);

}

From source file:ec.com.vipsoft.ce.ui.FacturaView.java

public void construirGui() {
    HorizontalLayout l1 = new HorizontalLayout();
    l1.setSpacing(true);/*from  w ww  .  j a  v  a  2  s .  c  o  m*/
    tipoFactura = new ComboBox();
    tipoFactura.addItem("regular");
    tipoFactura.setItemCaption("regular", "REGULAR");
    tipoFactura.addItem("exportacion");
    tipoFactura.setItemCaption("exportacion", "EXPORTACION");
    tipoFactura.addItem("reembolso");
    tipoFactura.setItemCaption("reembolso", "REEMBOLSO");
    tipoFactura.setNullSelectionAllowed(false);
    tipoFactura.setValue("regular");

    tipoIdentificacion = new ComboBox();

    tipoIdentificacion.addItem("05");
    tipoIdentificacion.setItemCaption("05", "CEDULA");
    tipoIdentificacion.addItem("06");
    tipoIdentificacion.setItemCaption("06", "PASAPORTE");
    tipoIdentificacion.addItem("07");
    tipoIdentificacion.setItemCaption("07", "FINAL");
    tipoIdentificacion.addItem("08");
    tipoIdentificacion.setItemCaption("08", "ID EXTERIOR");
    tipoIdentificacion.addItem("04");
    tipoIdentificacion.setItemCaption("04", "RUC");
    tipoIdentificacion.setNullSelectionAllowed(false);
    tipoIdentificacion.setValue("04");

    l1.addComponent(tipoIdentificacion);
    rucBeneficiario = new CampoNumeroIdentificacion();
    l1.addComponent(rucBeneficiario);
    Label lrazonSocial = new Label("R. Social");
    l1.addComponent(lrazonSocial);
    razonSocialBeneficiario = new CampoRazonSocial();
    l1.addComponent(razonSocialBeneficiario);
    Label ldireccion = new Label("Dir.");
    l1.addComponent(ldireccion);
    direccion = new CampoDireccion();
    l1.addComponent(direccion);
    fechaEmision = new CampoFecha();
    l1.addComponent(fechaEmision);
    //////////////////////////////////////////
    HorizontalLayout l2 = new HorizontalLayout();
    l2.setSpacing(true);
    Label lordenCompra = new Label("OC");
    setMargin(true);
    l2.addComponent(lordenCompra);
    ordenCompra = new TextField();
    ordenCompra.setWidth("70px");
    l2.addComponent(ordenCompra);
    Label lvencimiento = new Label("Cond. Pago");
    l2.addComponent(lvencimiento);
    formaPago = new CampoCodigo();
    formaPago.setWidth("100px");
    l2.addComponent(formaPago);
    Label lguia = new Label("Gua Remisin");
    l2.addComponent(lguia);
    numeroGuiaRemision = new CampoNumeroComprobante();
    l2.addComponent(numeroGuiaRemision);
    Label lsucursalCliente = new Label("Sucursal cliente");
    l2.addComponent(lsucursalCliente);
    codigoEstablecimientoDestino = new CampoCodigo();
    codigoEstablecimientoDestino.setInputPrompt("001");
    codigoEstablecimientoDestino.setWidth("70px");
    l2.addComponent(codigoEstablecimientoDestino);

    ////////////////////////////////
    codigoIVA = new ComboBox();
    codigoIVA.addItem("0");
    codigoIVA.addItem("2");
    codigoIVA.setNullSelectionAllowed(false);
    codigoIVA.setValue("2");
    codigoIVA.setItemCaption("0", "0%");
    codigoIVA.setItemCaption("2", "12%");
    codigoIVA.setWidth("80px");
    HorizontalLayout l3 = new HorizontalLayout();
    l3.setSpacing(true);
    botonBuscarDetalle = new BotonBuscar();
    l3.addComponent(botonBuscarDetalle);
    codigoP = new TextField();
    codigoP.setWidth("80px");
    l3.addComponent(codigoP);
    bienSeleccionado = new TextField();
    bienSeleccionado.setWidth("150px");
    l3.addComponent(bienSeleccionado);
    l3.addComponent(new Label("IVA"));
    l3.addComponent(codigoIVA);
    Label lcantidad = new Label("Cant.");
    l3.addComponent(lcantidad);
    cantidad = new CampoCantidad();
    l3.addComponent(cantidad);
    Label lvalorU = new Label("V. Unitario");
    l3.addComponent(lvalorU);
    valorUnitario = new CampoDinero();
    l3.addComponent(valorUnitario);
    Label ldescuento = new Label("Dcto.");
    l3.addComponent(ldescuento);
    descuento = new CampoDinero();
    l3.addComponent(descuento);
    Label labelLote = new Label("lote");
    l3.addComponent(labelLote);
    lote = new TextField();
    lote.setInputPrompt("lote 323, expira 2016-05-22");
    lote.setWidth("165px");
    botonAnadirDetalle = new BotonAnadir();
    l3.addComponent(lote);
    l3.addComponent(botonAnadirDetalle);
    botonEliminarDetalle = new BotonRemoverDetalle();
    l3.addComponent(botonEliminarDetalle);
    botonRegistrar = new BotonRegistrar();
    botonCancelar = new BotonCancelar();
    //l3.addComponent(botonRegistrar);
    //l3.addComponent(botonCancelar);
    ////////////////////////////////////////
    HorizontalLayout l4 = new HorizontalLayout();
    l4.setSizeFull();

    tablaDetalles = new Grid();
    beanContainerDetalles = new BeanItemContainer<FacturaDetalleBinding>(FacturaDetalleBinding.class);
    tablaDetalles.setContainerDataSource(beanContainerDetalles);
    //   tablaDetalles.setEditorEnabled(true);

    //        tablaDetalles.setPageLength(5);
    //        tablaDetalles.setSelectable(true);
    //        tablaDetalles.setMultiSelect(false);
    tablaDetalles.setWidth("100%");
    tablaDetalles.setReadOnly(true);
    tablaDetalles.removeColumn("infoAdicional3");
    tablaDetalles.removeColumn("infoAdicional2");
    tablaDetalles.removeColumn("codigoAlterno");
    tablaDetalles.removeColumn("codigoIVA");
    tablaDetalles.removeColumn("ice");
    tablaDetalles.setColumnOrder("cantidad", "codigo", "descripcion", "infoAdicional1", "valorUnitario",
            "descuento", "iva12", "valorTotal");
    l4.addComponent(tablaDetalles);
    l4.setComponentAlignment(tablaDetalles, Alignment.MIDDLE_CENTER);
    ///////////////////////////////////////////////////////7
    HorizontalLayout l5 = new HorizontalLayout();

    l5.setSpacing(true);
    l5.addComponent(tipoFactura);
    Label lcountry = new Label("PAIS DETINO");
    l5.addComponent(lcountry);
    comboPaisDestino = construirComboPaises();
    l5.addComponent(comboPaisDestino);
    HorizontalLayout l6 = new HorizontalLayout();
    l6.setSpacing(true);
    subtotal = new Label("Subtotal $0.00");
    iva12 = new Label("IVA12%  $0.00");
    ice = new Label("ICE $0.00");
    total = new Label("TOTAL $0.00");
    l6.addComponent(subtotal);
    l6.addComponent(iva12);
    l6.addComponent(ice);
    l6.addComponent(total);
    l6.addComponent(botonRegistrar);
    l6.addComponent(botonCancelar);
    l5.addComponent(l6);
    //        l5.addComponent(botonRegistrar);
    //        l5.addComponent(botonCancelar);

    //        l5.setSizeFull();
    //        VerticalLayout v1=new VerticalLayout();
    //        Label linfo=new Label("Info");
    //        HorizontalLayout vl1=new HorizontalLayout();
    //        vl1.setSpacing(true);
    //        vl1.addComponent(linfo);
    //       
    //        v1.addComponent(vl1);

    //        VerticalLayout v2=new VerticalLayout();
    //        v2.setSizeFull();
    //    
    //        HorizontalLayout v2l1=new HorizontalLayout();
    //        v2l1.addComponent(botonRegistrar);
    //        v2l1.addComponent(botonCancelar);
    //        v2.addComponent(v2l1);
    //        v2.setComponentAlignment(v2l1, Alignment.TOP_RIGHT);
    //        l5.addComponent(v1);
    //        l5.addComponent(v2);

    //////////////////////////////////////////////
    setSpacing(true);
    addComponent(l1);
    addComponent(l2);
    addComponent(l3);
    addComponent(l4);
    addComponent(l5);
    setComponentAlignment(l1, Alignment.MIDDLE_CENTER);
    setComponentAlignment(l2, Alignment.MIDDLE_CENTER);
    setComponentAlignment(l3, Alignment.MIDDLE_CENTER);
    setComponentAlignment(l4, Alignment.MIDDLE_CENTER);
    //  setComponentAlignment(l5, Alignment.MIDDLE_CENTER);
}

From source file:ec.com.vipsoft.ce.ui.FacturaView.java

public ComboBox construirComboPaises() {
    ComboBox retorno = new ComboBox();
    retorno.addItem("074");
    retorno.setItemCaption("074", "BOUVET ISLAND");

    retorno.addItem("101");
    retorno.setItemCaption("101", "ARGENTINA");

    retorno.addItem("102");
    retorno.setItemCaption("102", "BOLIVIA");
    retorno.addItem("103");
    retorno.setItemCaption("103", "BRASIL");
    retorno.addItem("104");
    retorno.setItemCaption("104", "CANADA");
    retorno.addItem("105");
    retorno.setItemCaption("105", "COLOMBIA");
    retorno.addItem("106");
    retorno.setItemCaption("106", "COSTA RICA");
    retorno.addItem("107");
    retorno.setItemCaption("107", "CUBA");
    retorno.addItem("108");
    retorno.setItemCaption("108", "CHILE");
    retorno.addItem("109");
    retorno.setItemCaption("109", "ANGILA");
    retorno.addItem("110");
    retorno.setItemCaption("110", "ESTADOS UNIDOS");
    return retorno;
}

From source file:edu.kit.dama.ui.admin.AdminUIMainView.java

License:Apache License

/**
 * Setup the login form including its logic.
 *//*from  w w  w  . ja  v  a2s .c  o m*/
private void setupLoginForm(AbstractLoginComponent.AUTH_MODE type, String pendingAuth, VaadinRequest request) {
    ComboBox authSelection = new ComboBox();
    authSelection.setWidth("400px");
    authSelection.setNullSelectionAllowed(false);
    authSelection.setStyleName("auth_selection");
    Label spacer = new Label("<br/>", ContentMode.HTML);
    spacer.setWidth("400px");

    String orcidClientId = DataManagerSettings.getSingleton()
            .getStringProperty(OrcidLoginComponent.ORCID_CLIENT_ID_PROPERTY, null);
    String orcidClientSecret = DataManagerSettings.getSingleton()
            .getStringProperty(OrcidLoginComponent.ORCID_CLIENT_SECRET_PROPERTY, null);

    /// String b2AccessClientId = DataManagerSettings.getSingleton().getStringProperty(B2AccessLoginComponent.B2ACCESS_CLIENT_ID_PROPERTY, null);
    // String b2AccessClientSecret = DataManagerSettings.getSingleton().getStringProperty(B2AccessLoginComponent.B2ACCESS_CLIENT_SECRET_PROPERTY, null);
    List<AbstractLoginComponent> components = new ArrayList<>();

    if (orcidClientId != null && !orcidClientId.equals("ORCID_CLIENT_ID") && orcidClientSecret != null
            && !orcidClientSecret.equals("ORCID_CLIENT_SECRET")) {
        components.add(new OrcidLoginComponent());
    }

    /*B2Access is currently not supported. 
    if (b2AccessClientId != null && b2AccessClientSecret != null) {
    components.add(new B2AccessLoginComponent());
    }*/
    components.add(new EmailPasswordLoginComponent());

    loginComponents = components.toArray(new AbstractLoginComponent[] {});

    //default login component has index 0
    loginComponent = loginComponents[0];
    for (AbstractLoginComponent component : loginComponents) {
        //add new login component
        authSelection.addItem(component.getLoginIdentifier());
        authSelection.setItemCaption(component.getLoginIdentifier(), component.getLoginLabel());

        if (pendingAuth != null && pendingAuth.equals(component.getLoginIdentifier())) {
            //login or registration process in pending, continue process
            loginComponent = component;
            try {
                switch (type) {
                case REGISTRATION:
                    loginComponent.doRegistration(request);
                    break;
                default:
                    loginComponent.doLogin(request);
                    break;
                }

            } catch (UnauthorizedAccessAttemptException ex) {
                //failed to continue auth...cancel.
                String message = "Failed to continue pending "
                        + (AbstractLoginComponent.AUTH_MODE.LOGIN.equals(type) ? "login" : "registration")
                        + " for authentication #" + pendingAuth + ".";
                LOGGER.error(message, ex);
                UIComponentTools.showError(message);
                VaadinSession.getCurrent().setAttribute("auth_pending", null);
                VaadinSession.getCurrent().setAttribute("registration_pending", null);
                loginComponent.reset();
            }
        }
    }

    authSelection.select(loginComponent.getLoginIdentifier());

    authSelection.addValueChangeListener((Property.ValueChangeEvent event) -> {
        String value = (String) event.getProperty().getValue();
        if (value != null) {
            for (AbstractLoginComponent component : loginComponents) {
                if (value.equals(component.getLoginIdentifier())) {
                    loginForm.replaceComponent(loginComponent, component);
                    loginComponent = component;
                }
            }
        }
    });

    loginForm = new VerticalLayout(authSelection, spacer, loginComponent);
    loginForm.setComponentAlignment(authSelection, Alignment.TOP_CENTER);
    loginForm.setComponentAlignment(spacer, Alignment.TOP_CENTER);
    loginForm.setComponentAlignment(loginComponent, Alignment.TOP_CENTER);
}

From source file:edu.kit.dama.ui.admin.LoginInformationBar.java

License:Apache License

private void buildMainLayout() {
    loggedInAsLabel = new Label("Login Username");
    loggedInAsLabel.addStyleName("myboldcaption");
    loggedInUserLabel = new Label();
    activeGroupLabel = new Label("Active Group");
    activeGroupLabel.addStyleName("myboldcaption");
    groupSelection = new ComboBox();
    groupSelection.addValueChangeListener(this);
    activeRoleLabel = new Label("Current Role");
    activeRoleLabel.addStyleName("myboldcaption");
    roleLabel = new Label();

    Label spacer1 = new Label("");
    home = buildMenuItem("home", new ThemeResource("img/70x48/logo_default.png"));
    profile = buildMenuItem("profile", new ThemeResource("img/70x48/preferences.png"));
    simon = buildMenuItem("simon", new ThemeResource("img/70x48/simon.png"));
    settings = buildMenuItem("settings", new ThemeResource("img/70x48/gears_preferences.png"));
    exit = buildMenuItem("exit", new ThemeResource("img/70x48/exit.png"));

    final AbsoluteLayout helps = new AbsoluteLayout();
    helps.setHeight("48px");
    helps.setWidth("100%");
    addHelpItem("home", "Return to the main page.", helps);
    addHelpItem("profile", "Open your profile, e.g. to change your password.", helps);
    addHelpItem("simon",
            "Open the <b>SI</b>mple<b>MON</b>itoring Tool, e.g. to check the availability of single services.",
            helps);//from  w  ww. j a v  a  2  s . c om
    addHelpItem("settings", "Open the system settings. (Only available for Group Managers and Administrators)",
            helps);
    addHelpItem("exit", "Logout.", helps);

    HorizontalLayout navigation = new HorizontalLayout(home, profile, simon, settings, exit, helps, spacer1);
    navigation.setExpandRatio(helps, .9f);
    navigation.setExpandRatio(spacer1, .1f);
    navigation.setSizeFull();
    navigation.addStyleName("mynavigationmargin");

    navigation.addLayoutClickListener((LayoutEvents.LayoutClickEvent event) -> {
        if (home.equals(event.getClickedComponent())) {
            parent.updateView(VIEW.INFORMATION);
        } else if (profile.equals(event.getClickedComponent())) {
            parent.updateView(VIEW.PROFILE);
        } else if (simon.equals(event.getClickedComponent())) {
            parent.updateView(VIEW.SIMON);
        } else if (settings.equals(event.getClickedComponent())) {
            parent.updateView(VIEW.SETTINGS);
        } else if (exit.equals(event.getClickedComponent())) {
            parent.logout();
        }
    });

    GridLayout loginInformationLayout = new UIUtils7.GridLayoutBuilder(3, 2)
            .addComponent(loggedInAsLabel, Alignment.MIDDLE_CENTER, 0, 0, 1, 1)
            .addComponent(activeGroupLabel, Alignment.MIDDLE_CENTER, 1, 0, 1, 1)
            .addComponent(activeRoleLabel, Alignment.MIDDLE_CENTER, 2, 0, 1, 1)
            .addComponent(loggedInUserLabel, Alignment.MIDDLE_CENTER, 0, 1, 1, 1)
            .addComponent(groupSelection, Alignment.MIDDLE_CENTER, 1, 1, 1, 1)
            .addComponent(roleLabel, Alignment.MIDDLE_CENTER, 2, 1, 1, 1).getLayout();

    loginInformationLayout.setSpacing(true);

    mainLayout = new UIUtils7.GridLayoutBuilder(5, 2)
            .addComponent(navigation, Alignment.MIDDLE_LEFT, 0, 0, 3, 2)
            .addComponent(loginInformationLayout, Alignment.MIDDLE_RIGHT, 3, 0, 2, 2).getLayout();
    mainLayout.setColumnExpandRatio(0, 1.0f);
    mainLayout.setColumnExpandRatio(1, .01f);
    mainLayout.setColumnExpandRatio(2, .01f);
    mainLayout.setColumnExpandRatio(3, .01f);
    mainLayout.setColumnExpandRatio(4, .01f);

    mainLayout.setSpacing(true);
    mainLayout.setMargin(new MarginInfo(false, true, false, true));
    mainLayout.setSizeFull();
}

From source file:edu.kit.dama.ui.commons.util.PaginationLayout.java

License:Apache License

/**
 * Update the layout. This method is either called internally when scrolling
 * or//from ww  w . ja v  a2  s.c  om
 */
public final void update() {
    //remove all components (old result page and navigation)
    removeAllComponents();

    //add current results
    renderPage();

    //build pagination
    int pages = overallEntries / entriesPerPage;
    if (overallEntries % entriesPerPage > 0) {
        pages++;
    }

    final int overallPages = pages;
    HorizontalLayout navigation = new HorizontalLayout();
    //add "JumpToFirstPage" button
    final NativeButton first = new NativeButton();
    first.setIcon(firstIcon);
    if (firstIcon == null) {
        first.setCaption("<<");
    }
    first.setDescription("First Page");
    first.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = 0;
            update();
        }
    });
    //add "PreviousPage" button
    final NativeButton prev = new NativeButton();
    prev.setIcon(prevIcon);
    if (prevIcon == null) {
        prev.setCaption("<");
    }
    prev.setDescription("Previous Page");
    prev.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage > 0) {
                currentPage--;
                update();
            }
        }
    });
    //add "NextPage" button
    final NativeButton next = new NativeButton();
    next.setIcon(nextIcon);
    if (nextIcon == null) {
        next.setCaption(">");
    }
    next.setDescription("Next Page");
    next.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage + 1 < overallPages) {
                currentPage++;
                update();
            }
        }
    });
    //add "JumpToLastPage" button
    final NativeButton last = new NativeButton();
    last.setIcon(endIcon);
    if (endIcon == null) {
        next.setCaption(">>");
    }
    last.setDescription("Last Page");
    last.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = overallPages - 1;
            update();
        }
    });

    //enable/disable buttons depending on the current page
    if (overallPages == 0) {
        first.setEnabled(false);
        prev.setEnabled(false);
        next.setEnabled(false);
        last.setEnabled(false);
    } else {
        first.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        prev.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
        last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
    }

    //at first, put the page size selection box into the navigation
    final ComboBox entriesPerPageBox = new ComboBox();
    entriesPerPageBox.setItemCaptionPropertyId("name");
    entriesPerPageBox.addContainerProperty("name", String.class, null);
    entriesPerPageBox.addItem(5);
    entriesPerPageBox.getContainerProperty(5, "name").setValue("5 Entries / Page");
    entriesPerPageBox.addItem(10);
    entriesPerPageBox.getContainerProperty(10, "name").setValue("10 Entries / Page");
    entriesPerPageBox.addItem(15);
    entriesPerPageBox.getContainerProperty(15, "name").setValue("15 Entries / Page");
    entriesPerPageBox.addItem(20);
    entriesPerPageBox.getContainerProperty(20, "name").setValue("20 Entries / Page");

    entriesPerPageBox.setValue(entriesPerPage);
    entriesPerPageBox.setNullSelectionAllowed(false);
    entriesPerPageBox.setImmediate(true);

    entriesPerPageBox.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            entriesPerPage = (Integer) entriesPerPageBox.getValue();
            update();
        }
    });

    navigation.addComponent(entriesPerPageBox);

    //filler labels are added to the beginning and to the end to keep the navigation in the middle
    Label leftFiller = new Label();
    leftFiller.setWidth("25px");
    navigation.addComponent(leftFiller);
    navigation.addComponent(first);
    navigation.addComponent(prev);

    //Show max. 10 pages at once for performance and layout reasons.
    //If there are more than 10 pages, "move" the to show 10 pages based on the current page.
    int start = currentPage - 5;
    start = (start < 0) ? 0 : start;
    int end = start + 10;
    end = (end > pages) ? pages : end;

    if (end - start < 10 && pages > 10) {
        start = end - 10;
    }

    if (overallPages == 0) {
        Label noEntryLabel = new Label("<i>No entries</i>", Label.CONTENT_XHTML);
        //noEntryLabel.setWidth("80px");
        noEntryLabel.setSizeUndefined();
        navigation.addComponent(noEntryLabel);
        navigation.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER);
    }
    //build the actual page entries
    for (int i = start; i < end; i++) {
        if (i == currentPage) {
            //the current page is marked with a special style
            Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", Label.CONTENT_XHTML);
            pageLink.setStyleName("currentpage");
            pageLink.setWidth("15px");
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        } else {
            //otherwise normal links are added, click-events are handled via LayoutClickListener 
            Link pageLink = new Link(Integer.toString(i + 1), null);
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        }
    }
    //add right navigation buttons
    navigation.addComponent(next);
    navigation.addComponent(last);
    //...and fill the remaining space 
    Label rightFiller = new Label();
    navigation.addComponent(rightFiller);
    //  navigation.setExpandRatio(leftFiller, 1.0f);
    navigation.setExpandRatio(rightFiller, 1.0f);
    navigation.setSpacing(true);

    //put everything ot the middle
    navigation.setComponentAlignment(first, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(prev, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(last, Alignment.MIDDLE_CENTER);

    //add layout click listener to be able to navigate by clicking the single pages
    navigation.addListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {

            // Get the child component which was clicked
            Component child = event.getChildComponent();

            if (child == null) {
                // Not over any child component
            } else {
                // Over a child component
                if (child instanceof Link) {
                    // Over a valid child element
                    currentPage = Integer.parseInt(((Link) child).getCaption()) - 1;
                    update();
                }
            }
        }
    });

    //finalize
    navigation.setWidth("100%");
    navigation.setHeight("25px");

    //add navigation and align it right below the result page
    addComponent(page);
    setExpandRatio(page, 1f);
    if (overallEntries > 0) {
        addComponent(navigation);
        setComponentAlignment(navigation, Alignment.BOTTOM_CENTER);
        setExpandRatio(navigation, .05f);
    }
    requestRepaint();
}