Example usage for com.vaadin.ui AbstractField setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:componentwrappers.AOpenbisInfoComponent.java

License:Open Source License

public AOpenbisInfoComponent(String description, AbstractField<?> comp, String width) {
    this(description, comp);
    comp.setWidth(width);
}

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);//from w w w .  j  av  a 2 s.  c om
    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 String updateIndicatorValue(final Main main, HorizontalLayout hl, final Base base,
        final Indicator indicator, boolean canWrite) {

    final Database database = main.getDatabase();

    Datatype dt = indicator.getDatatype(database);
    if (dt != null) {

        final AbstractField<?> field = dt.getEditor(main, base, indicator, false, null);
        field.setWidth("150px");
        field.setReadOnly(!canWrite);/*  w  w  w .  j  av a  2 s  .c  o  m*/
        hl.addComponent(field);
        hl.setComponentAlignment(field, Alignment.MIDDLE_LEFT);
        Object value = field.getValue();
        return value != null ? value.toString() : "";

    } else {

        Object value = indicator.getValue();
        final String formatted = value != null ? value.toString() : "";

        final TextField tf = new TextField();
        tf.setValue(formatted);
        tf.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 3547126051252580446L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                try {
                    double value = Double.parseDouble(tf.getValue());
                    indicator.updateWithComment(main, base, value, main.getUIState().forecastMeters,
                            new AbstractCommentCallback() {

                                public void canceled() {
                                    tf.setValue(formatted);
                                }

                            });
                } catch (NumberFormatException e) {
                    tf.setComponentError(new UserError("Arvon tulee olla numero"));
                }
            }
        });
        tf.setWidth("150px");
        tf.setReadOnly(!canWrite);
        hl.addComponent(tf);
        hl.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
        return tf.getValue();

    }

}

From source file:info.magnolia.configuration.app.overview.toolbar.ToolbarViewImpl.java

License:Open Source License

private void initFilterInputProperties(AbstractField component) {
    component.setImmediate(true);/*from  ww w  .  j a va2  s .com*/
    component.addValueChangeListener(filterChangeListener);
    if (component instanceof AbstractSelect) {
        component.addStyleName("filter-input");
        component.setWidth("160px");
        final AbstractSelect select = (AbstractSelect) component;
        select.setNullSelectionAllowed(true);
    }
}

From source file:nl.kpmg.lcm.ui.view.administration.components.RemoteLcmCreateWindow.java

License:Apache License

private HorizontalLayout createLayoutForField(AbstractField field, boolean isRequired) {
    HorizontalLayout fieldLayout = new HorizontalLayout();
    field.setRequired(isRequired);//www .  j ava 2s.co  m
    field.setWidth("70%");
    fieldLayout.setWidth("100%");
    fieldLayout.addStyleName("margin-top-10");
    fieldLayout.addComponent(field);

    return fieldLayout;
}

From source file:nz.co.senanque.vaadinsupport.HintsImpl.java

License:Apache License

public void setCommonProperties(final AbstractField ret, final MaduraPropertyWrapper property,
        final MessageSource messageSource) {
    ret.setWidth(getWidth());
    ret.setReadThrough(true);//from w  w w .j  ava  2 s .c o  m
    ret.setPropertyDataSource(property);
    ret.setCaption(property.getLabel());
    ret.setRequired(property.isRequired());
    if (property.isRequired()) {
        ret.setInvalidCommitted(true);
    }
    if (property.isReadOnly()) {
        ret.setReadOnly(true);
    }
    ret.setEnabled(property.isEnabled());
    ret.setVisible(property.isVisible());
    ret.setImmediate(m_forceImmediate);
    ret.setLocale(LocaleContextHolder.getLocale());
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
    ret.setDescription(
            messageSourceAccessor.getMessage(property.getDescription(), null, property.getDescription()));
    if (property.isNumeric()) {
        ret.addStyleName("v-textfield-align-right");
    }
    ret.setErrorHandler(new ComponentErrorHandler() {

        private static final long serialVersionUID = -1393935533100204195L;

        public boolean handleComponentError(ComponentErrorEvent event) {
            Throwable t = event.getThrowable();
            while (t != null) {
                if (t instanceof ValidationException) {
                    ret.setComponentError(new UserError(((ValidationException) t).getMessage()));
                    return true;
                }
                t = t.getCause();
            }
            return false;
        }
    });

}

From source file:nz.co.senanque.vaadinsupport.TouchkitHintsImpl.java

License:Apache License

public void setCommonProperties(final AbstractField ret, final MaduraPropertyWrapper property,
        final MessageSource messageSource) {
    ret.setWidth(getWidth());
    ret.setReadThrough(true);/*from ww  w . ja  v  a 2 s .  c  o  m*/
    ret.setPropertyDataSource(property);
    ret.setCaption(property.getLabel());
    ret.setRequired(property.isRequired());
    if (property.isRequired()) {
        ret.setInvalidCommitted(true);
    }
    ret.setReadOnly(property.isReadOnly());
    ret.setEnabled(property.isEnabled());
    ret.setVisible(property.isVisible());
    ret.setImmediate(m_forceImmediate);
    ret.setLocale(LocaleContextHolder.getLocale());
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
    ret.setDescription(
            messageSourceAccessor.getMessage(property.getDescription(), null, property.getDescription()));
    if (property.isNumeric()) {
        ret.addStyleName("v-textfield-align-right");
    }
    ret.setErrorHandler(new ComponentErrorHandler() {

        private static final long serialVersionUID = -1393935533100204195L;

        public boolean handleComponentError(ComponentErrorEvent event) {
            Throwable t = event.getThrowable();
            while (t != null) {
                if (t instanceof ValidationException) {
                    ret.setComponentError(new UserError(((ValidationException) t).getMessage()));
                    return true;
                }
                t = t.getCause();
            }
            return false;
        }
    });

}

From source file:ru.codeinside.adm.ui.CrudNews.java

License:Mozilla Public License

private AbstractField createField(String caption, Boolean readOnly) {
    AbstractField textField;
    if (caption.equals("")) {
        textField = new RichTextArea(caption);
    } else {/* w  ww  . j a  v a 2s.  c o  m*/
        textField = new TextField(caption);
        ((TextField) textField).setMaxLength(255);
    }
    textField.setImmediate(true);
    textField.setWidth("40%");
    textField.setReadOnly(readOnly);
    return textField;
}