Example usage for com.vaadin.ui Label setWidth

List of usage examples for com.vaadin.ui Label setWidth

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:fi.semantum.strategia.Utils.java

License:Open Source License

public static void setUserMeter(final Main main, final Base base, final Meter m) {

    final Database database = main.getDatabase();

    final Window subwindow = new Window("Aseta mittarin arvo", new VerticalLayout());
    subwindow.setModal(true);//  w ww  .  j  av  a  2 s.  com
    subwindow.setWidth("350px");
    subwindow.setResizable(false);

    final VerticalLayout winLayout = (VerticalLayout) subwindow.getContent();
    winLayout.setMargin(true);
    winLayout.setSpacing(true);

    String caption = m.getCaption(database);
    if (caption != null && !caption.isEmpty()) {
        final Label header = new Label(caption);
        header.addStyleName(ValoTheme.LABEL_LARGE);
        winLayout.addComponent(header);
    }

    final Indicator indicator = m.getPossibleIndicator(database);
    if (indicator == null)
        return;

    Datatype dt = indicator.getDatatype(database);
    if (!(dt instanceof EnumerationDatatype))
        return;

    final Label l = new Label("Selite: " + indicator.getValueShortComment());

    AbstractField<?> forecastField = dt.getEditor(main, base, indicator, true, new CommentCallback() {

        @Override
        public void runWithComment(String shortComment, String comment) {
            l.setValue("Selite: " + indicator.getValueShortComment());
        }

        @Override
        public void canceled() {
        }

    });
    forecastField.setWidth("100%");
    forecastField.setCaption("Ennuste");
    winLayout.addComponent(forecastField);

    AbstractField<?> currentField = dt.getEditor(main, base, indicator, false, new CommentCallback() {

        @Override
        public void runWithComment(String shortComment, String comment) {
            l.setValue("Selite: " + indicator.getValueShortComment());
        }

        @Override
        public void canceled() {
        }

    });
    currentField.setWidth("100%");
    currentField.setCaption("Toteuma");
    winLayout.addComponent(currentField);

    winLayout.addComponent(l);

    l.setWidth("100%");
    winLayout.setComponentAlignment(l, Alignment.BOTTOM_CENTER);

    HorizontalLayout hl = new HorizontalLayout();
    winLayout.addComponent(hl);
    winLayout.setComponentAlignment(hl, Alignment.BOTTOM_CENTER);

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

        private static final long serialVersionUID = 1364802814012491490L;

        public void buttonClick(ClickEvent event) {
            main.removeWindow(subwindow);
        }

    });

    Button define = new Button("Mrit", new Button.ClickListener() {

        private static final long serialVersionUID = 1364802814012491490L;

        public void buttonClick(ClickEvent event) {
            Meter.editMeter(main, base, m);
        }

    });

    hl.addComponent(ok);
    hl.setComponentAlignment(ok, Alignment.BOTTOM_LEFT);
    hl.addComponent(define);
    hl.setComponentAlignment(define, Alignment.BOTTOM_LEFT);

    main.addWindow(subwindow);

}

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

License:Open Source License

public static Label makeHistory(Database database, Indicator indicator, boolean forecast) {

    Label ta2 = new Label("Historia");
    ta2.setContentMode(ContentMode.HTML);
    ta2.setWidth("100%");
    ta2.setHeight("100%");

    StringBuilder sb = new StringBuilder();
    sb.append("<b>Historia</b><br><br>");

    for (Map.Entry<Date, TimeSeriesEntry> entry : indicator.values.list()) {
        TimeSeriesEntry tse = entry.getValue();
        Account account = tse.getAccount();
        Date date = entry.getKey();
        String user = account != null ? account.getId(database) : "Jrjestelm";
        sb.append("<b>");
        sb.append(user);// www . ja v  a2  s.co  m
        sb.append("</b> pivitti ");
        sb.append(forecast ? " ennustetta" : " toteumaa");
        sb.append(" <b>");
        sb.append(Utils.describeDate(date));
        sb.append("</b><br><hr>");
        sb.append("&nbsp;Uusi arvo on <b>");
        sb.append(forecast ? tse.getForecast() : tse.getValue() + " " + indicator.getUnitAndComment());
        sb.append("</b><br>");
        String comment = tse.getComment();
        if (comment != null)
            sb.append("<p>" + tse.getComment() + "</p>");
        sb.append("<br>");
    }

    ta2.setValue(sb.toString());
    return ta2;

}

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

License:Open Source License

public static void updateIndicators(final Main main, final Base base, boolean canWrite) {

    final Database database = main.getDatabase();

    List<IndicatorDescription> descs = new ArrayList<IndicatorDescription>();
    fillIndicatorDescriptions(main, base, "", descs);

    boolean isMap = base instanceof Strategiakartta;

    if (isMap && (!descs.isEmpty() || canWrite)) {

        HorizontalLayout indiHeader = new HorizontalLayout();
        indiHeader.setSpacing(true);//from  ww w  .  ja v a  2s .  c  om

        Label header = new Label("Indikaattorit (ennuste)");
        main.propertyCells.add(Utils.excelRow(header.getValue()));
        header.setHeight("32px");
        header.addStyleName(ValoTheme.LABEL_HUGE);
        header.addStyleName(ValoTheme.LABEL_BOLD);
        indiHeader.addComponent(header);
        indiHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER);

        if (canWrite) {

            final Image editIndicators = new Image(null, new ThemeResource("chart_line_edit.png"));
            editIndicators.setHeight("24px");
            editIndicators.setWidth("24px");
            editIndicators.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editIndicators);
                    manageIndicators(main, main.getUIState().currentItem);
                }

            });

            indiHeader.addComponent(editIndicators);
            indiHeader.setComponentAlignment(editIndicators, Alignment.BOTTOM_CENTER);

        }

        main.properties.addComponent(indiHeader);
        main.properties.setComponentAlignment(indiHeader, Alignment.MIDDLE_CENTER);

        VerticalLayout indicators = new VerticalLayout();

        boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI);

        Property time = Property.find(database, Property.AIKAVALI);

        int index = 0;
        for (final IndicatorDescription desc : descs) {

            ArrayList<String> excelRow = new ArrayList<String>();

            Indicator indicator = desc.indicator;

            final HorizontalLayout hl = new HorizontalLayout();
            hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty");
            hl.setSpacing(true);

            Label l = new Label(desc.caption);
            excelRow.add(l.getValue().replace("%nbsp", ""));
            l.setContentMode(ContentMode.HTML);
            l.setWidth("450px");
            l.addStyleName("propertyName");
            l.setData(desc);
            hl.addComponent(l);
            hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

            String value = updateIndicatorValue(main, hl, base, indicator, canWrite);
            excelRow.add(value);

            Label unit = new Label(indicator.getUnit());
            unit.setWidth("100px");
            hl.addComponent(unit);
            hl.setComponentAlignment(unit, Alignment.MIDDLE_LEFT);
            excelRow.add(unit.getValue());

            Label comment = new Label(indicator.getValueShortComment());
            comment.setWidth("150px");
            hl.addComponent(comment);
            hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT);
            excelRow.add(comment.getValue());

            if (showYears) {

                HorizontalLayout hl2 = new HorizontalLayout();
                hl2.setWidth("70px");
                hl2.setHeight("100%");
                hl.addComponent(hl2);
                hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

                String years = time.getPropertyValue(indicator);
                if (years == null)
                    years = Property.AIKAVALI_KAIKKI;

                final Label region = new Label(years);
                region.setWidthUndefined();

                excelRow.add(region.getValue());

                hl2.addComponent(region);
                hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER);

            }

            final Image wiki = new Image();
            wiki.setSource(new ThemeResource("table_edit.png"));
            wiki.setHeight("24px");
            wiki.setWidth("24px");
            wiki.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Wiki.openWiki(main, desc.indicator);
                }

            });

            hl.addComponent(wiki);
            hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER);

            indicators.addComponent(hl);
            indicators.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

            main.propertyCells.add(excelRow);

        }

        indicators.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 3295743025581923380L;

            private String extractData(Component c) {
                if (c instanceof AbstractComponent) {
                    Object data = ((AbstractComponent) c).getData();
                    if (data instanceof IndicatorDescription) {
                        IndicatorDescription desc = (IndicatorDescription) data;
                        return desc.indicator.getDescription(database);
                    }
                }
                return null;
            }

            @Override
            public void layoutClick(LayoutClickEvent event) {

                String desc = extractData(event.getClickedComponent());
                if (desc == null)
                    return;

                String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">";
                content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">"
                        + desc + "</div>";
                content += "</div>";

                Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE);
                n.setHtmlContentAllowed(true);
                n.show(Page.getCurrent());

            }

        });

        main.properties.addComponent(indicators);
        main.properties.setComponentAlignment(indicators, Alignment.MIDDLE_CENTER);

    }

}

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

License:Open Source License

public static void updateMeters(final Main main, boolean canWrite) {

    if (main.getUIState().currentItem instanceof Strategiakartta)
        return;/*from  w  ww.j  av  a2s  .  c o  m*/

    final Database database = main.getDatabase();

    final Base base = main.getUIState().currentItem;

    List<MeterDescription> descs = makeMeterDescriptions(main, base, false);
    if (!descs.isEmpty() || canWrite) {

        HorizontalLayout meterHeader = new HorizontalLayout();
        meterHeader.setSpacing(true);

        Label header = new Label("Mittarit");
        main.propertyCells.add(Utils.excelRow(header.getValue()));
        header.setHeight("32px");
        header.addStyleName(ValoTheme.LABEL_HUGE);
        header.addStyleName(ValoTheme.LABEL_BOLD);
        meterHeader.addComponent(header);
        meterHeader.setComponentAlignment(header, Alignment.BOTTOM_CENTER);

        if (canWrite) {

            final Image editMeters = new Image(null, new ThemeResource("chart_bar_edit.png"));
            editMeters.setHeight("24px");
            editMeters.setWidth("24px");
            editMeters.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 2661060702097338722L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editMeters);
                    manageMeters(main, main.getUIState().currentItem);
                }

            });

            meterHeader.addComponent(editMeters);
            meterHeader.setComponentAlignment(editMeters, Alignment.BOTTOM_CENTER);

        }

        main.properties.addComponent(meterHeader);
        main.properties.setComponentAlignment(meterHeader, Alignment.MIDDLE_CENTER);

        VerticalLayout meters = new VerticalLayout();

        boolean showYears = main.getUIState().time.equals(Property.AIKAVALI_KAIKKI);

        Property time = Property.find(database, Property.AIKAVALI);

        int index = 0;
        for (final MeterDescription desc : descs) {

            ArrayList<String> excelRow = new ArrayList<String>();

            final Meter meter = desc.meter;

            final HorizontalLayout hl = new HorizontalLayout();
            hl.addStyleName((((index++) & 1) == 0) ? "evenProperty" : "oddProperty");
            hl.setSpacing(true);

            Label l = new Label(desc.caption);
            excelRow.add(l.getValue().replace("%nbsp", ""));
            l.setContentMode(ContentMode.HTML);
            l.setWidth("450px");
            l.addStyleName("propertyName");
            l.setData(desc);
            hl.addComponent(l);
            hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);

            String value = updateMeterValue(main, hl, base, meter, canWrite);
            excelRow.add(value);

            String shortComment = "";
            Indicator indicator = meter.getPossibleIndicator(database);
            if (indicator != null)
                shortComment = indicator.getValueShortComment();
            Label comment = new Label(shortComment);
            comment.setWidth("150px");
            hl.addComponent(comment);
            hl.setComponentAlignment(comment, Alignment.MIDDLE_LEFT);
            excelRow.add(comment.getValue());

            if (showYears) {

                HorizontalLayout hl2 = new HorizontalLayout();
                hl2.setWidth("70px");
                hl2.setHeight("100%");
                hl.addComponent(hl2);
                hl.setComponentAlignment(hl2, Alignment.MIDDLE_LEFT);

                String years = time.getPropertyValue(meter);
                if (years == null)
                    years = Property.AIKAVALI_KAIKKI;

                final Label region = new Label(years);
                region.setWidthUndefined();

                excelRow.add(region.getValue());

                hl2.addComponent(region);
                hl2.setComponentAlignment(region, Alignment.MIDDLE_CENTER);

            }

            AbsoluteLayout image = new AbsoluteLayout();
            image.setWidth("32px");
            image.setHeight("32px");
            image.addStyleName("meterColor" + index);

            String color = meter.getTrafficColor(database);

            Styles styles = Page.getCurrent().getStyles();
            styles.add(
                    ".fi_semantum_strategia div." + "meterColor" + index + " { background: " + color + "; }");

            hl.addComponent(image);
            hl.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
            hl.setExpandRatio(image, 0.0f);

            meters.addComponent(hl);
            meters.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

            ThemeResource res = desc.meter.showInMap ? new ThemeResource("zoom.png")
                    : new ThemeResource("zoom_out.png");

            final Image show = new Image();
            show.setSource(res);
            show.setHeight("24px");
            show.setWidth("24px");
            if (canWrite) {
                show.setDescription("Klikkaamalla voit valita, nytetnk mittaria strategiakartassa");
                show.addClickListener(new MouseEvents.ClickListener() {

                    private static final long serialVersionUID = 7156984656942915939L;

                    @Override
                    public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                        desc.meter.setShowInMap(!desc.meter.showInMap);
                        Updates.update(main, true);
                    }

                });
            }

            hl.addComponent(show);
            hl.setComponentAlignment(show, Alignment.MIDDLE_CENTER);

            final Image wiki = new Image();
            wiki.setSource(new ThemeResource("table_edit.png"));
            wiki.setHeight("24px");
            wiki.setWidth("24px");
            wiki.setDescription("Klikkaamalla voit siirty tausta-asiakirjaan");
            wiki.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = 7156984656942915939L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Wiki.openWiki(main, desc.meter);
                }

            });

            hl.addComponent(wiki);
            hl.setComponentAlignment(wiki, Alignment.MIDDLE_CENTER);

            if (canWrite) {
                final Button principalButton = new Button();
                if (meter.isPrincipal) {
                    principalButton.setCaption("Poista kokonaisarvio");
                } else {
                    principalButton.setCaption("Aseta kokonaisarvioksi");
                }
                principalButton.setStyleName(ValoTheme.BUTTON_TINY);
                principalButton.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 8247560202892661226L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        if (meter.isPrincipal) {
                            meter.isPrincipal = false;
                        } else {
                            for (Meter m : base.getMeters(database))
                                m.isPrincipal = false;
                            meter.isPrincipal = true;
                        }
                        Updates.update(main, true);

                    }

                });
                hl.addComponent(principalButton);
                hl.setComponentAlignment(principalButton, Alignment.MIDDLE_CENTER);
            }

            main.propertyCells.add(excelRow);

        }

        meters.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 3295743025581923380L;

            private String extractData(Component c) {
                if (c instanceof AbstractComponent) {
                    Object data = ((AbstractComponent) c).getData();
                    if (data instanceof MeterDescription) {
                        MeterDescription desc = (MeterDescription) data;
                        return desc.meter.getDescription(database);
                    }
                }
                return null;
            }

            @Override
            public void layoutClick(LayoutClickEvent event) {

                String desc = extractData(event.getClickedComponent());
                if (desc == null)
                    return;

                String content = "<div style=\"width: 700px; border: 2px solid; padding: 5px\">";
                content += "<div style=\"text-align: center; white-space:normal; font-size: 36px; padding: 10px\">"
                        + desc + "</div>";
                content += "</div>";

                Notification n = new Notification(content, Notification.Type.HUMANIZED_MESSAGE);
                n.setHtmlContentAllowed(true);
                n.show(Page.getCurrent());

            }

        });

        main.properties.addComponent(meters);
        main.properties.setComponentAlignment(meters, Alignment.MIDDLE_CENTER);

    }

}

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

License:Open Source License

public static void updateProperties(final Main main, final Base base, boolean canWrite) {

    final Database database = main.getDatabase();

    String headerText = main.getUIState().currentItem.getCaption(database);
    main.propertyCells.add(Utils.excelRow(headerText));
    Label header = new Label(headerText);
    header.setWidth("800px");
    header.addStyleName("propertyHeader");
    header.addStyleName(ValoTheme.LABEL_HUGE);
    header.addStyleName(ValoTheme.LABEL_BOLD);
    main.properties.addComponent(header);
    main.properties.setComponentAlignment(header, Alignment.MIDDLE_CENTER);

    ArrayList<Pair> sorted = new ArrayList<Pair>(main.getUIState().currentItem.properties);
    Collections.sort(sorted, new Comparator<Pair>() {

        @Override/*w  ww  . jav a 2  s . c om*/
        public int compare(Pair arg0, Pair arg1) {

            final Property p0 = database.find(arg0.first);
            final Property p1 = database.find(arg1.first);
            return p0.getId(database).compareTo(p1.getId(database));

        }

    });

    Property typeProperty = Property.find(database, Property.TYPE);

    for (Pair pair : sorted) {

        // Skip type
        if (typeProperty.uuid.equals(pair.first))
            continue;

        final Property p = database.find(pair.first);
        String value = pair.second;
        final HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        String label = p.getText(database);
        main.propertyCells.add(Utils.excelRow(label, value));
        Label l = new Label(label);
        l.setWidth("450px");
        l.addStyleName("propertyName");
        hl.addComponent(l);
        List<String> enumeration = p.getEnumeration(database);
        if (enumeration.isEmpty()) {
            final TextField tf = new TextField();
            tf.setValue(value);
            tf.setWidth("350px");
            hl.addComponent(tf);
            hl.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
            tf.setReadOnly(p.readOnly);
            tf.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 7729833503749464603L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    Utils.loseFocus(hl);
                    if (p.set(main, main.getUIState().currentItem, tf.getValue()))
                        Updates.update(main, true);
                }
            });
            tf.setReadOnly(!canWrite);
        } else {
            final ComboBox combo = new ComboBox();
            combo.setWidth("350px");
            combo.setInvalidAllowed(false);
            combo.setNullSelectionAllowed(false);
            for (String e : enumeration) {
                combo.addItem(e);
            }
            combo.select(p.getEnumerationValue(database, value));
            combo.setPageLength(0);
            combo.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 3511164709346832901L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    Utils.loseFocus(hl);
                    if (p.set(main, main.getUIState().currentItem, combo.getValue().toString()))
                        Updates.update(main, true);
                }
            });
            combo.setReadOnly(!canWrite);
            hl.addComponent(combo);
            hl.setComponentAlignment(combo, Alignment.MIDDLE_LEFT);
        }
        hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);
        main.properties.addComponent(hl);
        main.properties.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);
    }

}

From source file:fr.amapj.view.engine.grid.booleangrid.PopupBooleanGrid.java

License:Open Source License

private void constructHeaderLine(VerticalLayout mainLayout, GridHeaderLine line) {
    HorizontalLayout header1 = new HorizontalLayout();
    if (line.height != -1) {
        header1.setHeight(line.height + "px");
    }//from ww w .jav a2s. c o  m

    int index = 0;
    for (String str : line.cells) {
        Label dateLabel = new Label(str);
        dateLabel.setSizeFull();
        if (line.styleName != null) {
            dateLabel.addStyleName(line.styleName);
        }

        if (index == 0) {
            dateLabel.setWidth((param.largeurCol + 5) + "px");
        } else {
            dateLabel.setWidth((param.largeurCol + 2) + "px");
        }

        header1.addComponent(dateLabel);
        index++;

    }
    mainLayout.addComponent(header1);
}

From source file:fr.amapj.view.engine.grid.booleangrid.PopupBooleanGrid.java

License:Open Source License

private void addRow(int lig) {
    List<Object> cells = new ArrayList<Object>();

    Label dateLabel = new Label(param.leftPartLine.get(lig));
    dateLabel.addStyleName("big");
    dateLabel.addStyleName("align-center");
    dateLabel.setWidth(param.largeurCol + "px");
    cells.add(dateLabel);//from  w  w w .j  av a  2  s .c  om

    if (param.leftPartLine2 != null) {
        dateLabel = new Label(param.leftPartLine2.get(lig));
        dateLabel.addStyleName("big");
        dateLabel.addStyleName("align-center");
        dateLabel.setWidth(param.largeurCol + "px");
        cells.add(dateLabel);
    }

    for (int j = 0; j < param.nbCol; j++) {
        boolean box = param.box[lig][j];

        CheckBox checkbox = new CheckBox();
        checkbox.setValue(box);
        checkbox.addStyleName("align-center");
        checkbox.addStyleName("big");
        checkbox.setWidth((param.largeurCol - 10) + "px");
        cells.add(checkbox);
    }

    table.addItem(cells.toArray(), new Integer(lig));

}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

private void addRow(int lig) {
    List<Object> cells = new ArrayList<Object>();

    Label dateLabel = new Label(param.leftPartLine.get(lig));
    dateLabel.addStyleName("date-saisie");
    dateLabel.setWidth(param.largeurCol + "px");

    cells.add(dateLabel);/*from w w  w.ja  va 2 s  . c  o m*/

    int qte = param.montant[lig];
    boolean isExcluded = isExcluded(lig);

    if (param.readOnly) {
        //
        String txt;

        if (isExcluded) {
            txt = "XXXXXX";
        } else if (qte == 0) {
            txt = "";
        } else {
            txt = "" + new CurrencyTextFieldConverter().convertToString(qte);
        }
        Label tf = new Label(txt);
        tf.addStyleName("cell-voir");
        tf.setWidth((param.largeurCol - 10) + "px");
        cells.add(tf);
    } else {
        if (isExcluded) {
            TextField tf = new TextField();
            tf.setValue("XXXXXX");
            tf.setEnabled(false);
            tf.addStyleName("cell-voir");
            tf.setWidth((param.largeurCol - 10) + "px");
            cells.add(tf);
        } else {
            //
            // Si derniere ligne : on  autorise les nombres ngatifs (sauf si on en mode de saisie de la dernire ligne)
            boolean allowNegativeNumber = (lig == param.nbLig - 1) && (param.computeLastLine == true);
            final TextField tf = BaseUiTools.createCurrencyField("", allowNegativeNumber);
            tf.setData(new GridIJData(lig, 0));
            tf.setConvertedValue(new Integer(qte));
            tf.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    try {
                        updateModele();
                    } catch (ErreurSaisieException e) {
                        NotificationHelper.displayNotificationMontant();
                    }
                }
            });

            tf.addStyleName("cell-saisie");
            tf.setWidth((param.largeurCol - 10) + "px");
            shortCutManager.registerTextField(tf);
            cells.add(tf);

            // Si derniere ligne : on desactive la saisie , sauf si pas de recalcul
            if ((lig == param.nbLig - 1) && (param.computeLastLine == true)) {
                tf.setEnabled(false);
                lastLineTextField = tf;
            }
        }

    }

    table.addItem(cells.toArray(), new Integer(lig));

}

From source file:fr.amapj.view.engine.grid.integergrid.PopupIntegerGrid.java

License:Open Source License

private void constructHeaderLine(VerticalLayout mainLayout, GridHeaderLine line) {
    HorizontalLayout header1 = new HorizontalLayout();
    if (line.height != -1) {
        header1.setHeight(line.height + "px");
    }/*from   w  ww .j  av a2 s .  co  m*/

    int index = 0;
    for (String str : line.cells) {
        Label dateLabel = new Label(str);
        dateLabel.setSizeFull();
        if (line.styleName != null) {
            dateLabel.addStyleName(line.styleName);
        }
        if (index == 0) {
            dateLabel.setWidth((param.leftPartLineLargeur + 5) + "px");
        } else {
            dateLabel.setWidth((param.largeurCol + 2) + "px");
        }

        header1.addComponent(dateLabel);

        index++;
    }
    mainLayout.addComponent(header1);
}

From source file:fr.amapj.view.engine.grid.integergrid.PopupIntegerGrid.java

License:Open Source License

private void addRow(int lig) {
    List<Object> cells = new ArrayList<Object>();

    Label dateLabel = new Label(param.leftPartLine.get(lig), ContentMode.HTML);
    dateLabel.addStyleName(param.leftPartLineStyle);

    cells.add(dateLabel);//from   w w  w.ja va 2s.  c  o m
    for (int j = 0; j < param.nbCol; j++) {
        int qte = param.qte[lig][j];
        boolean isExcluded = isExcluded(lig, j);

        // En lecture simple
        if (param.readOnly) {
            //
            String txt;

            if (isExcluded) {
                txt = "XXXXXX";
            } else if (qte == 0) {
                txt = "";
            } else {
                txt = "" + qte;
            }
            Label tf = new Label(txt);
            tf.addStyleName("cell-voir");
            tf.setWidth((param.largeurCol - 10) + "px");
            cells.add(tf);
        }
        // En mode normal
        else {
            // Si la cellule est exclue
            if (isExcluded) {
                TextField tf = new TextField();
                tf.setValue("XXXXXX");
                tf.setEnabled(false);
                tf.addStyleName("cell-voir");
                tf.setWidth((param.largeurCol - 10) + "px");
                cells.add(tf);
            } else {
                //
                final TextField tf = BaseUiTools.createQteField("");
                tf.setData(new GridIJData(lig, j));
                if (qte == 0) {
                    tf.setConvertedValue(null);
                } else {
                    tf.setConvertedValue(new Integer(qte));
                }
                tf.addValueChangeListener(new Property.ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        try {
                            GridIJData ij = (GridIJData) tf.getData();
                            int qte = readValueInCell(tf);
                            param.updateQte(ij.i(), ij.j(), qte);
                            displayMontantTotal();
                        } catch (ErreurSaisieException e) {
                            NotificationHelper.displayNotificationQte();
                        }
                    }
                });

                tf.addStyleName("cell-saisie");
                tf.setWidth((param.largeurCol - 10) + "px");
                shortCutManager.registerTextField(tf);
                cells.add(tf);
            }
        }
    }

    table.addItem(cells.toArray(), new Integer(lig));

}