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:com.etest.common.CommonComboBox.java

public static ComboBox getSchoolYear(String inputPrompt) {
    ComboBox select = new ComboBox();
    select.setWidth("100%");
    select.setInputPrompt(inputPrompt);//from  ww  w. j a  va 2s  .  c  o  m
    select.setNullSelectionAllowed(false);

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    int year = cal.get(Calendar.YEAR);

    for (int i = 0; i < 6; i++) {
        select.addItem((year - 1) + " - " + year);
        year++;
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.etest.common.CommonComboBox.java

public static ComboBox getAllFacultyExceptTeamLeader(String inputPrompt, int facultyId) {
    ComboBox select = new ComboBox();
    select.setWidth("100%");
    select.setInputPrompt(inputPrompt);/*from  w  w  w . jav a2  s.c  o m*/
    select.setNullSelectionAllowed(false);
    select.addContainerProperty("y", String.class, "");
    select.setItemCaptionPropertyId("y");

    Item i;
    for (Users u : TeamTeachDAO.getAllFacultyExceptTeamLeader(facultyId)) {
        i = select.addItem(u.getFacultyId());
        i.getItemProperty("y").setValue(u.getName());
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.etest.common.CommonComboBox.java

public static ComboBox getBloomsTaxonomy(String inputPrompt) {
    ComboBox select = new ComboBox();
    select.setWidth("100%");
    select.setInputPrompt(inputPrompt);/*w ww .j a v a  2  s  .c  om*/
    select.setNullSelectionAllowed(false);
    select.addContainerProperty("y", String.class, "");
    select.setItemCaptionPropertyId("y");

    Item i;
    for (BloomsTaxonomy bt : BloomsTaxonomy.getListOfBloomsTaxonomy()) {
        i = select.addItem(bt.getBloomsTaxonomyId());
        i.getItemProperty("y").setValue(bt.getBloomsTaxonomy());
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.etest.valo.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);/*from  w  w  w  . j a va 2 s. c  o  m*/
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Monthly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.etest.valo.Tables.java

License:Apache License

static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes,
        boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact,
        boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) {
    table.setSelectable(true);/*from   ww w.  j a  v a  2 s.c om*/
    table.setMultiSelect(true);
    table.setSortEnabled(true);
    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    table.setPageLength(6);
    table.addActionHandler(MainUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(MainUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(MainUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        table.setHeight("300px");
    } else {
        table.setSizeUndefined();
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

From source file:com.fnc.view.ui.AlphaListMainUI.java

ComboBox selectYear() {
    year = new ComboBox();
    year.setWidth("100%");
    year.setNullSelectionAllowed(false);
    year.addStyleName(ValoTheme.COMBOBOX_SMALL);

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    int y = cal.get(Calendar.YEAR);

    for (int i = y; i > 2011; i--) {
        year.addItem(String.valueOf(i));
    }/*from   w  ww. j  av  a  2s.co  m*/
    year.setValue(String.valueOf(y));

    return year;
}

From source file:com.foc.vaadin.gui.components.FVGISCoordinateLayout.java

License:Apache License

public FVGISCoordinateLayout(String caption, boolean longitude, FString property) {
    super(null);// www .  j av  a 2s .co m
    setSpacing(true);

    this.longitude = longitude;
    this.property = property;

    if (!ConfigInfo.isGuiRTL()) {
        Label lbl = new Label(caption);
        lbl.addStyleName("foc-bold");
        lbl.addStyleName("foc-f14");
        addComponent(lbl);
    }

    degreeField = new NumTextField(0, longitude ? 180 : 90);
    addComponent(degreeField);

    Label lbl = new Label(DEGREE);
    lbl.addStyleName("foc-bold");
    lbl.addStyleName("foc-f14");
    addComponent(lbl);

    minutesField = new NumTextField(0, 60);
    addComponent(minutesField);

    lbl = new Label(MINUTES_COMMA);
    lbl.addStyleName("foc-bold");
    lbl.addStyleName("foc-f14");
    addComponent(lbl);
    addComponent(new Label(MINUTES_COMMA));

    milliMinutesField = new NumTextField(0, 999);
    addComponent(milliMinutesField);

    lbl = new Label(MINUTES);
    lbl.addStyleName("foc-bold");
    lbl.addStyleName("foc-f14");
    addComponent(lbl);

    orientationField = new ComboBox();
    if (longitude) {
        orientationField.addItem("E");
        orientationField.addItem("W");
    } else {
        orientationField.addItem("N");
        orientationField.addItem("S");
    }
    orientationField.setWidth("70px");
    addComponent(orientationField);

    if (ConfigInfo.isGuiRTL()) {
        addComponent(new Label(caption));
    }

    copyMemoryToGui();
}

From source file:com.foc.vaadin.gui.components.treeGrid.FVColumnEditorRendererConverter.java

License:Apache License

@SuppressWarnings("serial")
public void createComponents() {
    if (getTableColumn() != null && getGridColumn() != null) {
        FField focField = getTableColumn().getField();
        if (focField != null) {
            // -----------------------------------------------------------
            // FDateField
            // -----------------------------------------------------------
            /*/* www.jav a  2 s . com*/
            if(focField instanceof FDateField || focField instanceof FDateTimeField){
               DateField dateField = new DateField();
                    
               FVAbstractConverter<String, java.sql.Date> converter = new FVAbstractConverter<String, java.sql.Date>(this) {
                  public java.sql.Date convertToModel(String value, Class<? extends java.sql.Date> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
             java.sql.Date date = null;
             try{
                date = new java.sql.Date((FDate.getDateFormat().parse(value)).getTime());
             }catch (Exception e){
                date = null;
             }
             return date;
                  }
                    
                  public String convertToPresentation(java.sql.Date value, Class<? extends String> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
             String stringValue = "";
             try{
                if(value == null){
                   stringValue = FDate.convertDateToDisplayString(value);
                }
             }catch (Exception e){
                stringValue = "";
             }
             return stringValue;
                  }
                    
                  public Class<java.sql.Date> getModelType() {
             return java.sql.Date.class;
                  }
                    
                  public Class<String> getPresentationType() {
             return String.class;
                  }
               };
               getGridColumn().setConverter(converter);
                //dateField.setConverter((Converter)converter);
               getGridColumn().setRenderer(new DateRenderer(FDate.getDateFormat()));
                    
               // -----------------------------------------------------------
               // FMultipleChoiceField
               // -----------------------------------------------------------
            }else*/ if (focField instanceof FMultipleChoiceField) {

                // Editor
                // ------
                ComboBox combo = new ComboBox();
                FMultipleChoiceField mFld = (FMultipleChoiceField) focField;
                Iterator<FMultipleChoiceItem> iter = mFld.getChoiceIterator();
                while (iter != null && iter.hasNext()) {
                    FMultipleChoiceItem item = (FMultipleChoiceItem) iter.next();
                    combo.addItem(item.getTitle());
                }
                getGridColumn().setEditorField(combo);

                FVAbstractConverter<String, FMultipleChoiceItem> converter = new FVAbstractConverter<String, FMultipleChoiceItem>(
                        this) {
                    public FMultipleChoiceItem convertToModel(String value,
                            Class<? extends FMultipleChoiceItem> targetType, Locale locale)
                            throws com.vaadin.data.util.converter.Converter.ConversionException {
                        FMultipleChoiceItem foundItem = null;

                        FMultipleChoiceField mFld = (FMultipleChoiceField) getTableColumn().getField();
                        Iterator iter = mFld.getChoiceIterator();
                        while (iter != null && iter.hasNext()) {
                            FMultipleChoiceItem item = (FMultipleChoiceItem) iter.next();
                            if (item.getTitle().equals(value)) {
                                foundItem = item;
                            }
                        }

                        return foundItem;
                    }

                    public String convertToPresentation(FMultipleChoiceItem value,
                            Class<? extends String> targetType, Locale locale)
                            throws com.vaadin.data.util.converter.Converter.ConversionException {
                        return value != null ? value.getTitle() : null;
                    }

                    public Class<FMultipleChoiceItem> getModelType() {
                        return FMultipleChoiceItem.class;
                    }

                    public Class<String> getPresentationType() {
                        return String.class;
                    }
                };
                getGridColumn().setConverter(converter);
                combo.setConverter((Converter) converter);
                getGridColumn().setRenderer(new TextRenderer(), converter);

                // -----------------------------------------------------------
                // FObjectField
                // -----------------------------------------------------------
            } else if (focField instanceof FObjectField) {
                // Editor
                // ------
                FObjectField oFld = (FObjectField) focField;
                FVObjectComboBox combo = new FVObjectComboBox(oFld, getTableColumn().getCaptionProp());
                getGridColumn().setEditorField(combo);

                FVAbstractConverter<String, Long> converter = new FVAbstractConverter<String, Long>(this) {

                    private FocList getFocList() {
                        FObjectField oFld = (FObjectField) getTableColumn().getField();
                        FocList list = oFld != null ? oFld.getSelectionList() : null;
                        return list;
                    }

                    public Long convertToModel(String value, Class<? extends Long> targetType, Locale locale)
                            throws com.vaadin.data.util.converter.Converter.ConversionException {
                        Long foundItem = null;

                        FocList list = getFocList();
                        if (list != null) {
                            for (int i = 0; i < list.size(); i++) {
                                FocObject fObj = list.getFocObject(i);
                                FProperty prop = fObj.getFocPropertyForPath(getTableColumn().getCaptionProp());
                                if (prop != null && prop.getValue() == value) {
                                    foundItem = fObj.getReferenceInt();
                                }
                            }
                        }
                        return foundItem;
                    }

                    public String convertToPresentation(Long value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        String stirngDisplay = "";
                        if (value == null) {
                            if (getTableColumn() != null && getTableColumn().getField() != null
                                    && ((FObjectField) getTableColumn().getField())
                                            .getNullValueDisplayString() != null) {
                                stirngDisplay = ((FObjectField) getTableColumn().getField())
                                        .getNullValueDisplayString();
                            }
                        } else {
                            FocList list = getFocList();
                            FocObject foudnObject = null;
                            try {
                                foudnObject = list != null ? list.searchByReference(value) : null;
                            } catch (Exception e) {
                                foudnObject = list != null ? list.searchByReference(value) : null;
                                Globals.logException(e);
                            }

                            String captionPath = getTableColumn().getCaptionProp();
                            if (captionPath == null || captionPath.isEmpty()) {
                                FObjectField objField = (getTableColumn() != null)
                                        ? (FObjectField) getTableColumn().getField()
                                        : null;
                                FocDesc focDesc = objField != null ? objField.getFocDesc() : null;

                                if (focDesc != null) {
                                    if (focDesc.getFieldByID(FField.FLD_CODE) != null) {
                                        captionPath = FField.FNAME_CODE;
                                    } else if (focDesc.getFieldByID(FField.FLD_NAME) != null) {
                                        captionPath = FField.FNAME_NAME;
                                    } else if (focDesc.getFieldByID(FField.FLD_DESCRIPTION) != null) {
                                        captionPath = FField.FNAME_DESCRIPTION;
                                    }
                                }
                            }

                            FProperty prop = foudnObject != null
                                    ? foudnObject.getFocPropertyForPath(captionPath)
                                    : null;
                            stirngDisplay = prop != null ? prop.getString() : "";
                        }
                        return stirngDisplay;
                    }

                    public Class<Long> getModelType() {
                        return Long.class;
                    }

                    public Class<String> getPresentationType() {
                        return String.class;
                    }
                };
                getGridColumn().setConverter(converter);
                // combo.setConverter((Converter)converter);
                getGridColumn().setRenderer(new TextRenderer(), converter);
            } else if (focField instanceof FNumField) {
                FNumField numField = (FNumField) focField;
                if (numField != null && numField.getFormat() != null) {
                    TextField textField = new FVEditorField_Numeric(getTableColumn()); //new TextField();
                    getGridColumn().setEditorField(textField);

                    NumberRenderer numberRenderer = new NumberRenderer(numField.getFormat());
                    getGridColumn().setRenderer(numberRenderer);
                }
            } else if (focField instanceof FBoolField) {
                FBoolField bField = (FBoolField) focField;

                if (bField != null) {
                    CheckBox cb = new CheckBox();
                    cb.setImmediate(true);
                    getGridColumn().setEditorField(cb);
                    getGridColumn().setRenderer(new ImageRenderer(), new Converter<Resource, Boolean>() {
                        @Override
                        public Boolean convertToModel(Resource value, Class<? extends Boolean> targetType,
                                Locale l) throws Converter.ConversionException {
                            return false;
                        }

                        @Override
                        public Resource convertToPresentation(Boolean value,
                                Class<? extends Resource> targetType, Locale l)
                                throws Converter.ConversionException {
                            Resource res = null;
                            if (value) {
                                res = FVIconFactory.getInstance().getFVIcon_Small(FVIconFactory.ICON_APPLY);
                            } else {
                                res = FVIconFactory.getInstance().getFVIcon_Small("cancel-icon.png");
                            }
                            return res;
                        }

                        @Override
                        public Class<Boolean> getModelType() {
                            return Boolean.class;
                        }

                        @Override
                        public Class<Resource> getPresentationType() {
                            return Resource.class;
                        }
                    });
                    /*
                                      cb.setConverter(new Converter<Boolean, Boolean>(){
                            
                                         @Override
                                         public Boolean convertToModel(Boolean value, Class<? extends Boolean> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                                            return value;
                                         }
                            
                                         @Override
                                         public Boolean convertToPresentation(Boolean value, Class<? extends Boolean> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                                            return value;
                                         }
                            
                                         @Override
                                         public Class<Boolean> getModelType() {
                                            return Boolean.class;
                                         }
                            
                                         @Override
                                         public Class<Boolean> getPresentationType() {
                                            return Boolean.class;
                                         }
                                                 
                                      });
                                      */
                }
            } else if (focField instanceof FDateTimeField) {
                //               DateField dateField = new DateField();
                //               getGridColumn().setEditorField(dateField);

                //               dateField.setConverter(new Converter<Date, Date>(){
                //
                //                  @Override
                //                  public Date convertToModel(Date value, Class<? extends Date> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                //                     return value;
                //                  }
                //
                //                  @Override
                //                  public Date convertToPresentation(Date value, Class<? extends Date> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                //                     // TODO Auto-generated method stub
                //                     return value;
                //                  }
                //
                //                  @Override
                //                  public Class<Date> getModelType() {
                //                     // TODO Auto-generated method stub
                //                     return Date.class;
                //                  }
                //
                //                  @Override
                //                  public Class<Date> getPresentationType() {
                //                     // TODO Auto-generated method stub
                //                     return Date.class;
                //                  }
                //                  
                //               });
            }
        }
    }
}

From source file:com.foc.vaadin.gui.windows.AddTabWindow.java

License:Apache License

public AddTabWindow(final TabSheet tabSheet, final VerticalLayout addTabLayout) {
    super("Add New Tab");
    setModal(true);/*  w  w w .  j a v a2  s  .  c om*/
    setWidth("264px");
    setHeight("272px");

    layout = new VerticalLayout();
    buttonsLayout = new HorizontalLayout();
    optionsLayout = new VerticalLayout();
    seperateLayout = new VerticalLayout();

    tabName = new TextField();
    tabNameWrapper = new FVWrapperLayout(tabName, "Tab Name:", width);
    layoutHeight = new TextField();
    heightWrapper = new FVWrapperLayout(layoutHeight, "Height:", width);
    layoutWidth = new TextField();
    widthWrapper = new FVWrapperLayout(layoutWidth, "Width:", width);
    innerLayout = new ComboBox();
    innerLayoutWrapper = new FVWrapperLayout(innerLayout, "Layout Type:", width);

    for (int i = 0; i < layoutTypes.length; i++) {
        innerLayout.addItem(layoutTypes[i]);
    }

    innerLayout.setImmediate(true);
    innerLayout.setNullSelectionAllowed(false);
    innerLayout.setValue(layoutTypes[0]);

    innerLayout.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String layoutType = event.getProperty().toString();

            if (layoutType.equals(FXML.TAG_GRID_LAYOUT)) {
                layoutCols = new TextField();
                colsWrapper = new FVWrapperLayout(layoutCols, "Columns:", width);
                layoutRows = new TextField();
                rowsWrapper = new FVWrapperLayout(layoutRows, "Rows:", width);

                optionsLayout.addComponent(colsWrapper);
                optionsLayout.addComponent(rowsWrapper);

                setHeight("350px");

            } else {

                if (layoutCols != null) {
                    optionsLayout.removeComponent(colsWrapper);
                    layoutCols = null;
                    colsWrapper = null;
                }

                if (layoutRows != null) {
                    optionsLayout.removeComponent(rowsWrapper);
                    layoutRows = null;
                    rowsWrapper = null;
                }

                setHeight("272px");
            }
        }
    });

    create = new Button("Create");
    cancel = new Button("Cancel");

    cancel.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    create.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            String layoutType = innerLayout.getValue().toString();

            AttributesImpl attributes = new AttributesImpl();

            attributes.addAttribute("", "name", "name", "CDATA", "null");
            attributes.addAttribute("", "height", "height", "CDATA",
                    layoutHeight.getValue().toString().isEmpty() ? "-1px"
                            : layoutHeight.getValue().toString() + "px");
            attributes.addAttribute("", "width", "width", "CDATA",
                    layoutWidth.getValue().toString().isEmpty() ? "-1px"
                            : layoutWidth.getValue().toString() + "px");

            if (layoutType.equals(FXML.TAG_ABSOLUTE_LAYOUT)) {
                selectedLayout = new FVAbsoluteLayout(attributes);
            } else if (layoutType.equals(FXML.TAG_VERTICAL_LAYOUT)) {
                selectedLayout = new FVVerticalLayout(attributes);
            } else if (layoutType.equals(FXML.TAG_HORIZONTAL_LAYOUT)) {
                selectedLayout = new FVHorizontalLayout(attributes);
            } else {

                attributes.addAttribute("", "rows", "rows", "CDATA", layoutRows.getValue().toString());
                attributes.addAttribute("", "cols", "cols", "CDATA", layoutCols.getValue().toString());

                selectedLayout = new FVGridLayout(attributes);
            }

            tabSheet.removeTab(tabSheet.getTab(addTabLayout));
            tabSheet.addTab((Component) selectedLayout, tabName.getValue().toString());
            tabSheet.addTab(addTabLayout, "+");
            close();
        }
    });

    optionsLayout.setSpacing(true);
    optionsLayout.addComponent(widthWrapper);
    optionsLayout.addComponent(heightWrapper);

    seperateLayout.setHeight("25px");

    buttonsLayout.setSpacing(true);
    buttonsLayout.addComponent(create);
    buttonsLayout.addComponent(cancel);

    layout.setSpacing(true);
    layout.addComponent(tabNameWrapper);
    layout.addComponent(innerLayoutWrapper);
    layout.addComponent(optionsLayout);
    layout.addComponent(seperateLayout);
    layout.addComponent(buttonsLayout);

    layout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER);

    setContent(layout);
}

From source file:com.github.carljmosca.MainLayout.java

private void init() {
    setSizeFull();//  w w w  .  j  a  va  2s .  c  o  m
    addStyleName("menylayout");
    Responsive.makeResponsive(this);
    ComboBox<Person> cmbPerson = new ComboBox<>();
    cmbPerson.setItems(personProcessor.findAll());
    cmbPerson.setItemCaptionGenerator(c -> c.getTitle() + " " + c.getFirstName() + " " + c.getLastName());
    cmbPerson.addValueChangeListener((HasValue.ValueChangeEvent<Person> event) -> {
        binder.setBean(cmbPerson.getValue());
    });
    title = new ComboBox("Title", Arrays.asList(titles));
    firstName = new TextField("First");
    middleName = new TextField("Middle");
    lastName = new TextField("Last");
    Button btnNew = new Button("New");
    btnNew.addClickListener((Button.ClickEvent event) -> {
        person = new Person();
        binder.setBean(person);
    });
    Button btnSave = new Button("Save");
    btnSave.addClickListener((Button.ClickEvent event) -> {
        personProcessor.addPerson(person);
        cmbPerson.setItems(personProcessor.findAll());
    });
    personLayout.setWidth(null);
    personLayout.setSpacing(true);
    personLayout.addStyleName("menu");
    personLayout.addComponent(title);
    personLayout.addComponent(firstName);
    personLayout.addComponent(middleName);
    personLayout.addComponent(lastName);
    personLayout.addComponent(btnNew);
    addComponent(btnSave);
    addComponent(cmbPerson);
    addComponent(personLayout);
    //addComponent(buttonLayout);
    doBinding();
}