Example usage for com.vaadin.ui VerticalLayout setHeightUndefined

List of usage examples for com.vaadin.ui VerticalLayout setHeightUndefined

Introduction

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

Prototype

@Override
    public void setHeightUndefined() 

Source Link

Usage

From source file:com.cms.utils.CommonUtils.java

public static Panel addOg2Panel(OptionGroup og, String caption, String height) {
    og.setWidth("100%");
    og.setHeight("-1px");
    og.setImmediate(true);/* ww w .j a va 2  s  .  c  om*/
    og.setMultiSelect(true);
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeightUndefined();
    layout.setImmediate(true);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(og);
    layout.setComponentAlignment(og, Alignment.MIDDLE_LEFT);
    Panel panel = new Panel();
    if (!DataUtil.isStringNullOrEmpty(caption)) {
        panel.setCaption(caption);
    }
    panel.setWidth("100%");
    panel.setImmediate(true);
    if (!DataUtil.isStringNullOrEmpty(height)) {
        panel.setHeight(height);
    } else {
        panel.setHeight("200px");
    }
    panel.addStyleName(Runo.PANEL_LIGHT);
    panel.setContent(layout);
    return panel;
}

From source file:com.esofthead.mycollab.mobile.ui.ConfirmDialog.java

License:Open Source License

private void constructUI(final String message, final String okCaption, final String cancelCaption) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeightUndefined();
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    VerticalLayout messageWrapper = new VerticalLayout();
    messageWrapper.setStyleName("message-wrapper");
    messageWrapper.setWidth("100%");
    messageWrapper.setMargin(true);//from  www  .j  a v  a  2s .  c o m

    final Label messageDisplay = new Label(message);
    messageDisplay.setWidth("100%");
    messageWrapper.addComponent(messageDisplay);
    layout.addComponent(messageWrapper);

    HorizontalLayout controlBtn = new HorizontalLayout();
    controlBtn.setWidth("100%");

    final Button okBtn = new Button(okCaption);
    okBtn.setWidth("100%");
    okBtn.setHeight("35px");
    final Button cancelBtn = new Button(cancelCaption);
    cancelBtn.setWidth("100%");
    cancelBtn.setHeight("35px");

    Button.ClickListener listener = new Button.ClickListener() {
        private static final long serialVersionUID = -8306231710367659086L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialog.this.setConfirmed(event.getButton() == okBtn);
            if (ConfirmDialog.this.getListener() != null) {
                ConfirmDialog.this.getListener().onClose(ConfirmDialog.this);
            }
            ConfirmDialog.this.close();
        }

    };

    okBtn.addClickListener(listener);
    cancelBtn.addClickListener(listener);

    controlBtn.addComponent(cancelBtn);
    controlBtn.addComponent(okBtn);

    layout.addComponent(controlBtn);
    this.setContent(layout);
}

From source file:com.etest.view.tq.charts.GraphicalInventoryBarChart.java

public GraphicalInventoryBarChart() {
    setModal(true);//from w  w w.  j  a  v  a2 s  .c o m

    VerticalLayout v = new VerticalLayout();
    v.setMargin(true);

    //        Panel panel = new Panel();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Curriculum c : cs.getAllCurriculum()) {
        for (int i = 0; i < 2; i++) {
            if (i == 0) {
                dataset.addValue(rs.getTotalCasesBySubject(c.getCurriculumId()), "Cases", c.getSubject());
            } else {
                dataset.addValue(rs.getTotalItemsBySubject(c.getCurriculumId()), "Items", c.getSubject());
            }
        }
    }

    JFreeChart chart = ChartFactory.createBarChart("Inventory of Items and Cases", "Subjects", "", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();

    Color color;

    for (int i = 0; i < dataset.getRowCount(); i++) {
        if (i % 2 == 0) {
            renderer.setSeriesPaint(i, new Color(0, 0, 255));
        } else {
            renderer.setSeriesPaint(i, new Color(255, 0, 0));
        }
    }

    //        JFreeChartWrapper wrapper = new JFreeChartWrapper(chart){
    //            
    //            @Override
    //            public void attach(){
    //                super.attach();
    //                setResource("src", getSource());
    //            }
    //            
    //        };

    v.addComponent(new ReportChartWrapper(chart, null, null));
    v.setWidthUndefined();
    v.setHeightUndefined();

    setContent(v);
    getContent().setWidthUndefined();
    getContent().setHeightUndefined();
    center();
}

From source file:com.etest.view.tq.charts.GraphicalInventoryPieChart.java

public GraphicalInventoryPieChart(int curriculumId) {
    this.curriculumId = curriculumId;
    setModal(true);//from ww w .  j  av a2 s  .  c  o m

    int percentage = 0;
    VerticalLayout v = new VerticalLayout();
    DefaultPieDataset dataset = new DefaultPieDataset();

    for (BloomsClass b : BloomsClass.values()) {
        percentage = (int) calculatePercentageOfItemsPerBloomsClass(
                rs.getTotalItemsBySubject(getCurriculumId()),
                rs.getTotalItemsByBloomsCass(getCurriculumId(), tq.getBloomsClassId(b.toString())));

        dataset.setValue(b + " " + percentage + "%", percentage);
    }

    JFreeChart chart = ChartFactory.createPieChart(
            "Inventory of Items for " + cs.getCurriculumById(getCurriculumId()).getSubject(), dataset, true,
            true, false);

    //        JFreeChartWrapper wrapper = new JFreeChartWrapper(chart){
    //            
    //            @Override
    //            public void attach(){
    //                super.attach();
    //                setResource("src", getSource());
    //            }
    //            
    //        };

    v.addComponent(new ReportChartWrapper(chart, null, null));
    v.setWidthUndefined();
    v.setHeightUndefined();

    setContent(v);
    getContent().setWidthUndefined();
    getContent().setHeightUndefined();
    center();
}

From source file:com.mycollab.mobile.ui.ConfirmDialog.java

License:Open Source License

private void constructUI(final String message, final String okCaption, final String cancelCaption) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeightUndefined();
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    VerticalLayout messageWrapper = new VerticalLayout();
    messageWrapper.setStyleName("message-wrapper");
    messageWrapper.setWidth("100%");
    messageWrapper.setMargin(true);/*from w  ww  .j a va  2 s.c o m*/

    final Label messageDisplay = new Label(message);
    messageDisplay.setWidth("100%");
    messageWrapper.addComponent(messageDisplay);
    layout.addComponent(messageWrapper);

    HorizontalLayout controlBtn = new HorizontalLayout();
    controlBtn.setWidth("100%");

    final Button okBtn = new Button(okCaption);
    okBtn.setWidth("100%");
    okBtn.setHeight("35px");
    final Button cancelBtn = new Button(cancelCaption);
    cancelBtn.setWidth("100%");
    cancelBtn.setHeight("35px");

    ClickListener listener = (clickEvent) -> {
        ConfirmDialog.this.setConfirmed(clickEvent.getButton() == okBtn);
        if (ConfirmDialog.this.getListener() != null) {
            ConfirmDialog.this.getListener().onClose(ConfirmDialog.this);
        }
        close();
    };

    okBtn.addClickListener(listener);
    cancelBtn.addClickListener(listener);

    controlBtn.addComponent(cancelBtn);
    controlBtn.addComponent(okBtn);

    layout.addComponent(controlBtn);
    this.setContent(layout);
}

From source file:ed.cracken.pos.ui.products.ProductForm.java

public void initComponents() {
    setId("product-form");
    setStyleName("product-form-wrapper");
    addStyleName("product-form");
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.setHeightUndefined();
    formLayout.setSpacing(true);//from w w  w  .  j a v  a2  s  . c o m
    formLayout.setStyleName("form-layout");
    formLayout.addComponent(productName = new TextField("Name"));
    HorizontalLayout priceAndStockLayout = new HorizontalLayout();
    priceAndStockLayout.addComponent(price = new TextField("Price"));
    priceAndStockLayout.addComponent(stockCount = new TextField("Stock"));
    formLayout.addComponent(priceAndStockLayout);
    formLayout.addComponent(availability = new ComboBox("Availability"));
    formLayout.addComponent(category = new CategoryField("Category"));
    CssLayout separator = new CssLayout();
    separator.setStyleName("expander");
    formLayout.addComponent(separator);
    formLayout.addComponent(save = new Button("Save") {
        {
            setStyleName("primary");
            setId("save");
        }
    });
    formLayout.addComponent(cancel = new Button("Cancel") {
        {
            setStyleName("cancel");
            setId("cancel");
        }
    });
    formLayout.addComponent(delete = new Button("Delete") {
        {
            setStyleName("danger");
            setId("delete");
        }
    });
    addComponent(formLayout);

}

From source file:ed.cracken.pos.ui.purchases.PurchaseItemForm.java

public PurchaseItemForm(PurchaserLogic viewLogic) {

    setId("product-form");
    setStyleName("product-form-wrapper");
    addStyleName("product-form");
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.setHeightUndefined();
    formLayout.setSpacing(true);/*from w w w.j av  a2s .  c  o  m*/
    formLayout.setStyleName("form-layout");
    formLayout.addComponent(productId = new TextField("Code"));
    formLayout.addComponent(description = new TextField("Description"));
    formLayout.addComponent(price = new DecimalNumberField("Price"));
    formLayout.addComponent(quantity = new DecimalNumberField("Quantity"));
    formLayout.addComponent(discount = new DecimalNumberField("Discount"));
    formLayout.addComponent(subtotal = new DecimalNumberField("Subtotal"));
    price.setConverter(BigDecimal.class);
    quantity.addTextChangeListener((FieldEvents.TextChangeEvent event) -> {
        if (!event.getText().isEmpty()) {
            try {
                NumberFormat nf = DecimalFormat.getInstance();
                nf.setMaximumFractionDigits(2);

                ItemTo item;
                BigDecimal r = BigDecimal.valueOf(nf.parse(event.getText()).longValue())
                        .multiply((item = fieldGroup.getItemDataSource().getBean()).getPrice());
                subtotal.setReadOnly(false);

                subtotal.setValue(nf.format(r.doubleValue()));
                subtotal.setReadOnly(true);
            } catch (ParseException ex) {
                Logger.getLogger(PurchaseItemForm.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    CssLayout separator = new CssLayout();
    separator.setStyleName("expander");
    formLayout.addComponent(separator);
    formLayout.addComponent(save = new StyledButton("Aplicar", "primary", "save"));
    formLayout.addComponent(cancel = new StyledButton("Cancelar", "cancel", "cancel"));
    formLayout.addComponent(delete = new StyledButton("Quitar", "danger", "delete"));
    save.addClickListener((Button.ClickEvent event) -> {
        try {
            fieldGroup.commit();
            viewLogic.updateItem(fieldGroup.getItemDataSource().getBean());
        } catch (FieldGroup.CommitException e) {
            e.printStackTrace(System.err);
        }
    });
    cancel.addClickListener((Button.ClickEvent event) -> {
        viewLogic.cancelItemChanges();
    });
    delete.addClickListener((Button.ClickEvent event) -> {
        viewLogic.removeItem(fieldGroup.getItemDataSource().getBean());
    });

    addComponent(formLayout);
    configBinding();
}

From source file:ed.cracken.pos.ui.seller.SellItemForm.java

public SellItemForm(SellerLogic viewLogic) {

    setId("product-form");
    setStyleName("product-form-wrapper");
    addStyleName("product-form");
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.setHeightUndefined();
    formLayout.setSpacing(true);/*from  www.j  a v a2s. c o m*/
    formLayout.setStyleName("form-layout");
    formLayout.addComponent(productId = new TextField("Code"));
    formLayout.addComponent(description = new TextField("Description"));
    formLayout.addComponent(price = new DecimalNumberField("Price"));
    formLayout.addComponent(quantity = new DecimalNumberField("Quantity"));
    formLayout.addComponent(discount = new DecimalNumberField("Discount"));
    formLayout.addComponent(subtotal = new DecimalNumberField("Subtotal"));
    price.setConverter(BigDecimal.class);
    quantity.addTextChangeListener((FieldEvents.TextChangeEvent event) -> {
        if (!event.getText().isEmpty()) {
            try {
                NumberFormat nf = DecimalFormat.getInstance();
                nf.setMaximumFractionDigits(2);

                ItemTo item;
                BigDecimal r = BigDecimal.valueOf(nf.parse(event.getText()).longValue())
                        .multiply((item = fieldGroup.getItemDataSource().getBean()).getPrice());
                subtotal.setReadOnly(false);

                subtotal.setValue(nf.format(r.doubleValue()));
                subtotal.setReadOnly(true);
            } catch (ParseException ex) {
                Logger.getLogger(SellItemForm.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    CssLayout separator = new CssLayout();
    separator.setStyleName("expander");
    formLayout.addComponent(separator);
    formLayout.addComponent(save = new StyledButton("Aplicar", "primary", "save"));
    formLayout.addComponent(cancel = new StyledButton("Cancelar", "cancel", "cancel"));
    formLayout.addComponent(delete = new StyledButton("Quitar", "danger", "delete"));
    save.addClickListener((Button.ClickEvent event) -> {
        try {
            fieldGroup.commit();
            viewLogic.updateItem(fieldGroup.getItemDataSource().getBean());
        } catch (FieldGroup.CommitException e) {
            e.printStackTrace(System.err);
        }
    });
    cancel.addClickListener((Button.ClickEvent event) -> {
        viewLogic.cancelItemChanges();
    });
    delete.addClickListener((Button.ClickEvent event) -> {
        viewLogic.removeItem(fieldGroup.getItemDataSource().getBean());
    });

    addComponent(formLayout);
    configBinding();
}

From source file:fi.semantum.strategia.widget.Indicator.java

License:Open Source License

public static void editIndicator(final Main main, final Base base, final Indicator indicator) {

    final Database database = main.getDatabase();

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//from   w w w .j  a va 2s .  co  m
    content.setHeightUndefined();
    content.setSpacing(true);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.setWidth("100%");
    content.addComponent(hl);
    content.setExpandRatio(hl, 0.0f);

    final TextField tf = new TextField("Tunniste");
    tf.setValue(indicator.getId(database));
    tf.setWidth("100%");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    hl.addComponent(tf);
    hl.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
    hl.setExpandRatio(tf, 2.0f);

    final TextField tf1 = new TextField("Teksti");
    tf1.setValue(indicator.getText(database));
    tf1.setWidth("100%");
    tf1.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    hl.addComponent(tf1);
    hl.setComponentAlignment(tf1, Alignment.MIDDLE_CENTER);
    hl.setExpandRatio(tf1, 2.0f);

    final TextField unit = makeUnit(database, hl, indicator);

    final TextField tf2 = new TextField();
    tf2.setCaption("Voimassaolo");
    tf2.setValue(Utils.getValidity(database, indicator));
    tf2.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tf2.setWidth("100%");
    hl.addComponent(tf2);
    hl.setComponentAlignment(tf2, Alignment.MIDDLE_CENTER);
    hl.setExpandRatio(tf2, 1.0f);

    final TextArea ta = new TextArea("Mritys");
    ta.setValue(indicator.getText(database));
    ta.setWidth("100%");
    ta.setHeight("100px");
    content.addComponent(ta);
    content.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
    content.setExpandRatio(ta, 0.0f);

    final Label ta2 = makeHistory(database, indicator, main.getUIState().forecastMeters);
    content.addComponent(ta2);
    content.setComponentAlignment(ta2, Alignment.MIDDLE_CENTER);
    content.setExpandRatio(ta2, 1.0f);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button ok = new Button("Tallenna", new Button.ClickListener() {

        private static final long serialVersionUID = 1992235622970234624L;

        public void buttonClick(ClickEvent event) {
            indicator.modifyId(main, tf.getValue());
            Utils.modifyValidity(main, indicator, tf2.getValue());
            indicator.modifyText(main, tf1.getValue());
            indicator.modifyDescription(main, ta.getValue());
            if (unit != null) {
                indicator.modifyUnit(main, unit.getValue());
            }
            Updates.update(main, true);
            manageIndicators(main, main.getUIState().currentItem);
        }

    });
    buttons.addComponent(ok);

    Button close = new Button("Sulje");
    buttons.addComponent(close);

    final Window dialog = Dialogs.makeDialog(main, "650px", "800px", "Muokkaa indikaattoria", null, content,
            buttons);
    close.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1992235622970234624L;

        public void buttonClick(ClickEvent event) {
            main.removeWindow(dialog);
            manageIndicators(main, main.getUIState().currentItem);
        }

    });

}

From source file:fi.semantum.strategia.widget.Meter.java

License:Open Source License

public static void editMeter(final Main main, final Base base, final Meter meter) {

    Database database = main.getDatabase();

    final VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//from ww  w. j  a v  a2  s  .c  o m
    content.setHeightUndefined();
    content.setSpacing(true);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    hl.setSpacing(true);
    hl.setMargin(false);

    final TextField tf = new TextField();
    tf.setCaption("Lyhytnimi");
    tf.setValue(meter.getId(database));
    tf.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tf.setWidth("100%");

    hl.addComponent(tf);
    hl.setComponentAlignment(tf, Alignment.TOP_CENTER);
    hl.setExpandRatio(tf, 1.0f);

    final TextField tf1 = new TextField();
    tf1.setCaption("Teksti");
    tf1.setValue(meter.getText(database));
    tf1.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tf1.setWidth("100%");

    hl.addComponent(tf1);
    hl.setComponentAlignment(tf1, Alignment.TOP_CENTER);
    hl.setExpandRatio(tf1, 2.0f);

    content.addComponent(hl);
    content.setComponentAlignment(hl, Alignment.TOP_CENTER);
    content.setExpandRatio(hl, 0.0f);

    final TextField tf2 = new TextField();
    tf2.setCaption("Voimassaolo");
    tf2.setValue(Utils.getValidity(database, meter));
    tf2.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tf2.setWidth("100%");

    content.addComponent(tf2);
    content.setComponentAlignment(tf2, Alignment.TOP_CENTER);
    content.setExpandRatio(tf2, 0.0f);

    final TextArea ta = new TextArea();
    ta.setCaption("Mritys");
    ta.setValue(meter.getText(database));
    ta.addStyleName(ValoTheme.TEXTAREA_TINY);
    ta.setHeight("100%");
    ta.setWidth("100%");

    content.addComponent(ta);
    content.setComponentAlignment(ta, Alignment.TOP_CENTER);
    content.setExpandRatio(ta, 1.0f);

    final TrafficValuation valuation = meter.trafficValuation;
    final Runnable onOK = valuation != null ? valuation.getEditor(content, main, meter) : null;

    Indicator indicator = meter.getPossibleIndicator(database);
    if (indicator != null) {
        final Label ta2 = Indicator.makeHistory(database, indicator, main.getUIState().forecastMeters);
        content.addComponent(ta2);
        content.setComponentAlignment(ta2, Alignment.MIDDLE_CENTER);
        content.setExpandRatio(ta2, 1.0f);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button ok = new Button("Tallenna", new Button.ClickListener() {

        private static final long serialVersionUID = 1992235622970234624L;

        public void buttonClick(ClickEvent event) {
            if (onOK != null)
                onOK.run();
            meter.modifyId(main, tf.getValue());
            meter.modifyText(main, tf1.getValue());
            Utils.modifyValidity(main, meter, tf2.getValue());
            meter.modifyDescription(main, ta.getValue());
            Updates.update(main, true);
            manageMeters(main, main.getUIState().currentItem);
        }

    });
    buttons.addComponent(ok);

    Button close = new Button("Sulje");
    buttons.addComponent(close);

    final Window dialog = Dialogs.makeDialog(main, "500px", "800px", "Mrit mittaria", null, content,
            buttons);
    close.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8065367213523520602L;

        public void buttonClick(ClickEvent event) {
            main.removeWindow(dialog);
            manageMeters(main, main.getUIState().currentItem);
        }

    });

}