Example usage for com.vaadin.ui CheckBox CheckBox

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

Introduction

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

Prototype

public CheckBox() 

Source Link

Document

Creates a new checkbox.

Usage

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
            // -----------------------------------------------------------
            /*/*from w  ww  .  ja v  a2 s. c om*/
            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.github.mjvesa.herd.wordset.VaadinWordSet.java

License:Apache License

@Override
public Word[] getWords() {
    return new Word[] {

            new BaseWord("new-button", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2492817908731559368L;

                @Override/*from ww w  . j av a2 s  .c  om*/
                public void execute(final Interpreter interpreter) {

                    Button b = new Button("", new Button.ClickListener() {
                        private static final long serialVersionUID = -4622489800920283752L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            Button b = event.getButton();
                            Word command = (Word) b.getData();
                            if (command != null) {
                                interpreter.execute(command);
                            }
                        }
                    });
                    interpreter.pushData(b);
                }
            },

            new BaseWord("set-click-listener", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5749856686458297558L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Button b = (Button) interpreter.popData();
                    b.setData(o);
                    interpreter.pushData(b);
                }
            },

            new BaseWord("new-hl", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8813556668649386248L;

                @Override
                public void execute(Interpreter interpreter) {
                    HorizontalLayout hl = new HorizontalLayout();
                    hl.setSpacing(true);
                    interpreter.pushData(hl);
                }
            },

            new BaseWord("new-vl", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1848213448504804229L;

                @Override
                public void execute(Interpreter interpreter) {
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) {

                private static final long serialVersionUID = 4079634885691605257L;

                @Override
                public void execute(Interpreter interpreter) {
                    Integer height = (Integer) interpreter.popData();
                    Integer width = (Integer) interpreter.popData();
                    interpreter.pushData(new GridLayout(width, height));
                }
            },

            new BaseWord("gl-new-line", "", Word.POSTPONED) {

                private static final long serialVersionUID = 975877390052961807L;

                @Override
                public void execute(Interpreter interpreter) {
                    ((GridLayout) interpreter.peekData()).newLine();
                }
            },

            new BaseWord("new-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6887364362728545090L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = new Window();
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    w.setContent(vl);
                    interpreter.pushData(w);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("main-panel", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8622281600566696475L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(interpreter.getMainPanel());
                }
            },

            new BaseWord("add-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = 7106029415576813922L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = (Window) interpreter.popData();
                    interpreter.getView().getUI().addWindow(w);
                }
            },

            new BaseWord("add-component", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5640824046985354091L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.addComponent(comp);
                    interpreter.pushData(cc);
                }
            },

            new BaseWord("set-caption", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5497598050469462487L;

                @Override
                public void execute(Interpreter interpreter) {
                    String s = (String) interpreter.popData();
                    Component c = (Component) interpreter.popData();
                    c.setCaption(s);
                    interpreter.pushData(c);
                }
            },

            new BaseWord("set-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1769743552659215058L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Property p = (Property) interpreter.popData();
                    p.setValue(o);
                    interpreter.pushData(p);
                }
            },

            new BaseWord("get-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8445550546521886374L;

                @Override
                public void execute(Interpreter interpreter) {
                    Field f = (Field) interpreter.popData();
                    interpreter.pushData(f);
                    interpreter.pushData(f.getValue());

                }
            },

            new BaseWord("set-size-full", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1206491811133054467L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeFull();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-size-undefined", "", Word.POSTPONED) {

                private static final long serialVersionUID = -3450618729379622987L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeUndefined();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-height", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8426734568403715950L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setHeight(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-width", "", Word.POSTPONED) {

                private static final long serialVersionUID = -4558264143049463814L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setWidth(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("clear-container", "", Word.POSTPONED) {

                private static final long serialVersionUID = 1070175466682034329L;

                @Override
                public void execute(Interpreter interpreter) {
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.removeAllComponents();
                }
            },

            new BaseWord("new-check-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 4018632924389912599L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new CheckBox());
                }
            },

            new BaseWord("new-date-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = 6313296566085274642L;

                @Override
                public void execute(final Interpreter interpreter) {
                    interpreter.pushData(new DateField());
                    final String dfCommand = (String) interpreter.popData();
                    DateField df = new DateField();
                    df.setImmediate(true);
                    df.addValueChangeListener(new ValueChangeListener() {
                        /**
                        * 
                        */
                        private static final long serialVersionUID = 1472139878970514093L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(dfCommand);
                        }

                    });
                    interpreter.pushData(df);
                }
            },

            new BaseWord("new-label", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2825285195439247251L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new Label());
                }
            },

            new BaseWord("new-text-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1064489458253275380L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tfCommand = interpreter.getNextNonNopWord();
                    TextField tf = new TextField();
                    tf.setCaption((String) interpreter.popData());
                    tf.setValue("");
                    tf.setImmediate(true);
                    tf.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = 4325104922208051065L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(tfCommand);
                        }
                    });
                    interpreter.pushData(tf);
                }
            },

            new BaseWord("new-table", "", Word.POSTPONED) {

                private static final long serialVersionUID = -5052653341575232035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tableCommand = interpreter.getParser().getNextWord();
                    Table table = new Table();
                    table.setCaption((String) interpreter.popData());
                    table.setImmediate(true);
                    table.setSelectable(true);
                    table.addItemClickListener(new ItemClickListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3585546076571010729L;

                        public void itemClick(ItemClickEvent event) {

                            interpreter.pushData(event.getItem());
                            interpreter.execute(interpreter.getDictionary().get(tableCommand));
                        }
                    });
                    interpreter.pushData(table);
                }
            },

            new BaseWord("new-combo-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 3881577354424928897L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String newItemCommand = interpreter.getParser().getNextWord();
                    final String itemSelectedCommand = interpreter.getParser().getNextWord();
                    final ComboBox cb = new ComboBox();
                    String str = (String) interpreter.popData();
                    cb.setNullSelectionAllowed(false);
                    cb.setCaption(str);
                    cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    cb.setNewItemsAllowed(true);
                    cb.setNewItemHandler(new NewItemHandler() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3340658590351611289L;

                        public void addNewItem(String newItemCaption) {
                            cb.setImmediate(false);
                            interpreter.pushData(newItemCaption);
                            interpreter.interpret(newItemCommand);
                            cb.setImmediate(true);
                        }
                    });

                    cb.addValueChangeListener(new ValueChangeListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 2706579869793251379L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(
                                    cb.getContainerDataSource().getItem(event.getProperty().getValue()));
                            interpreter.interpret(itemSelectedCommand);
                        }
                    });
                    cb.setImmediate(true);
                    interpreter.pushData(cb);
                }
            },

            new BaseWord("new-select", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6142351970812196488L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String selCommand = interpreter.getParser().getNextWord();
                    final ComboBox sel = new ComboBox();
                    sel.setCaption((String) interpreter.popData());
                    sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    sel.setNullSelectionAllowed(false);
                    sel.setImmediate(true);
                    sel.addValueChangeListener(new ValueChangeListener() {
                        /**
                        *
                        */
                        private static final long serialVersionUID = -7705548618092166199L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(selCommand);
                        }
                    });
                    interpreter.pushData(sel);
                }
            },

            new BaseWord("new-list-select", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8686093227035249035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String lselCommand = interpreter.getParser().getNextWord();
                    final ListSelect lsel = new ListSelect();
                    lsel.setCaption((String) interpreter.popData());
                    lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    lsel.setNullSelectionAllowed(false);
                    lsel.setImmediate(true);
                    lsel.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = -5523488417834167806L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(lselCommand);
                        }
                    });
                    interpreter.pushData(lsel);
                }
            },

            new BaseWord("set-container-data-source", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8644721936358613031L;

                @Override
                public void execute(Interpreter interpreter) {
                    Container cont = (Container) interpreter.popData();
                    AbstractSelect as = (AbstractSelect) interpreter.popData();
                    as.setContainerDataSource(cont);
                    interpreter.pushData(as);
                }
            },

            new BaseWord("set-column-headers", "", Word.POSTPONED) {
                private static final long serialVersionUID = -7296881714369214846L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0]));
                }
            },

            new BaseWord("set-visible-columns", "", Word.POSTPONED) {
                private static final long serialVersionUID = 5674765074478598320L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0]));
                }
            }

    };
}

From source file:com.haulmont.cuba.web.gui.components.presentations.PresentationEditor.java

License:Apache License

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();

    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();/*from w  ww  .  j  a v a 2 s.  co m*/
    root.setSpacing(true);
    setContent(root);

    messages = AppBeans.get(Messages.class);

    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);

    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);

    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);

    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);

    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);

    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);

    nameField.focus();
}

From source file:com.haulmont.cuba.web.gui.components.presentations.TablePresentations.java

License:Apache License

protected void initLayout() {
    setSpacing(true);/*w w  w.j  a  va2s  .c o  m*/

    Label titleLabel = new Label(messages.getMainMessage("PresentationsPopup.title"));
    titleLabel.setStyleName("c-table-prefs-title");
    titleLabel.setWidth("-1px");
    addComponent(titleLabel);
    setComponentAlignment(titleLabel, Alignment.MIDDLE_CENTER);

    menuBar = new CubaMenuBar();
    menuBar.setStyleName("c-table-prefs-list");
    menuBar.setWidth("100%");
    menuBar.setHeight("-1px");
    menuBar.setVertical(true);
    addComponent(menuBar);

    button = new WebPopupButton();
    button.setCaption(messages.getMainMessage("PresentationsPopup.actions"));
    addComponent(button.<Component>getComponent());
    setComponentAlignment(button.<Component>getComponent(), Alignment.MIDDLE_CENTER);

    textSelectionCheckBox = new CheckBox();
    textSelectionCheckBox.setImmediate(true);
    textSelectionCheckBox.setInvalidCommitted(true);
    textSelectionCheckBox.setCaption(messages.getMainMessage("PresentationsPopup.textSelection"));
    addComponent(textSelectionCheckBox);
    textSelectionCheckBox.setPropertyDataSource(new AbstractProperty() {
        @Override
        public Object getValue() {
            return tableImpl.isTextSelectionEnabled();
        }

        @Override
        public void setValue(Object newValue) throws Property.ReadOnlyException {
            if (newValue instanceof Boolean) {
                tableImpl.setTextSelectionEnabled((Boolean) newValue);
            }
        }

        @Override
        public Class getType() {
            return Boolean.class;
        }
    });
}

From source file:com.jain.addon.web.bean.factory.AbstractFieldFactory.java

License:Apache License

protected Field<?> createBooleanField(JNIProperty property) {
    return new CheckBox();
}

From source file:com.jain.addon.web.bean.factory.generator.select.BooleanFieldGenerator.java

License:Apache License

public Field<?> createField(Class<?> type, JNIProperty property) {
    CheckBox field = new CheckBox();
    return field;
}

From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java

License:Apache License

public FindLayersViewComponent() {

    treeTable = new ExpressZipTreeTable();
    popupTable = new ExpressZipTreeTable();
    configureTable(treeTable);/*w  w w . j a v a2s  .  c  o m*/

    popupSelectionListener = new Property.ValueChangeListener() {
        private static final long serialVersionUID = 625365970493526725L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // the current popup selection
            Set<ExpressZipLayer> popupSelection = (Set<ExpressZipLayer>) event.getProperty().getValue();

            // get the tree's current selection
            HashSet<ExpressZipLayer> treeSelection = new HashSet<ExpressZipLayer>(
                    (Set<ExpressZipLayer>) treeTable.getValue());

            // remove all items in common with popup
            treeSelection.removeAll(popupTable.getItemIds());

            // set the treeTable selection to the union
            Set<ExpressZipLayer> unionSelection = new HashSet<ExpressZipLayer>();
            unionSelection.addAll(popupSelection);
            unionSelection.addAll(treeSelection);
            treeTable.setValue(unionSelection);
        }
    };
    popupTable.addListener(popupSelectionListener);

    treeTable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 6236114836521221107L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Set<ExpressZipLayer> highlightedLayers = (Set<ExpressZipLayer>) event.getProperty().getValue();
            for (FindLayersViewListener listener : listeners) {
                listener.layerHighlightedEvent(highlightedLayers);
            }

            // reset selection of popup table
            popupTable.removeListener(popupSelectionListener);

            // intersection of treeTable's selection and popupTable items
            Set<ExpressZipLayer> popupSelection = new HashSet<ExpressZipLayer>();
            popupSelection.addAll(highlightedLayers);
            popupSelection.retainAll(popupTable.getItemIds());
            popupTable.setValue(popupSelection);

            popupTable.addListener(popupSelectionListener);
        }
    });
    configureTable(popupTable);

    filter = new Filter(this);
    filterButtonListener = new FilterListeners();
    axisSelectedListener = new AxisSelected();
    listeners = new ArrayList<FindLayersViewListener>();
    btnNext = new ExpressZipButton("Next", Style.STEP);
    btnBack = new ExpressZipButton("Back", Style.STEP);

    btnAddFilter = new ExpressZipButton("Add Filter", Style.ACTION);
    btnAddFilter.addStyleName("filter-flow");

    hshFilterButtons = new HashMap<Button, FilterObject>();
    cssLayers = new CssLayout();

    basemapSelector = new ComboBox();
    basemapSelector.setWidth(100.0f, UNITS_PERCENTAGE);
    basemapSelector.setTextInputAllowed(false);
    basemapSelector.setImmediate(true);
    basemapSelector.setNullSelectionAllowed(false);
    basemapSelector.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -7358667131762099215L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue();
            boolean enableCheckbox = false;
            if (l instanceof WebMapServiceLayer) {
                for (ExpressZipLayer local : mapModel.getLocalBaseLayers()) {
                    if (l.toString().equals(local.getName())) {
                        enableCheckbox = true;
                        break;
                    }
                }
            }
            includeBasemap.setEnabled(enableCheckbox);
            if (!enableCheckbox) {
                includeBasemap.setValue(false);
            }

            if (mapModel.getBaseLayerTerms(l) != null && !mapModel.getBaseLayerTermsAccepted(l)) {
                final Window modal = new Window("Terms of Use");
                modal.setModal(true);
                modal.setClosable(false);
                modal.setResizable(false);
                modal.getContent().setSizeUndefined(); // trick to size around content
                Button bOK = new ExpressZipButton("OK", Style.ACTION, new ClickListener() {
                    private static final long serialVersionUID = -2872178665349848542L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue();
                        mapModel.setBaseLayerTermsAccepted(l);
                        for (FindLayersViewListener listener : listeners)
                            listener.baseMapChanged(l);
                        ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal);
                    }
                });
                Button bCancel = new ExpressZipButton("Cancel", Style.ACTION, new ClickListener() {
                    private static final long serialVersionUID = -3044064554876422836L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        basemapSelector.select(mapModel.getBaseLayers().get(0));
                        ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal);
                    }
                });
                HorizontalLayout buttons = new HorizontalLayout();
                buttons.setSpacing(true);
                buttons.addComponent(bOK);
                buttons.addComponent(bCancel);
                Label termsText = new Label(mapModel.getBaseLayerTerms(l));
                termsText.setContentMode(Label.CONTENT_XHTML);
                VerticalLayout vlay = new VerticalLayout();
                vlay.addComponent(termsText);
                vlay.addComponent(buttons);
                vlay.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);
                vlay.setWidth(400, UNITS_PIXELS);
                modal.getContent().addComponent(vlay);
                ((ExpressZipWindow) getApplication().getMainWindow()).addWindow(modal);
            } else {
                for (FindLayersViewListener listener : listeners)
                    listener.baseMapChanged(l);
            }
        }
    });

    includeBasemap = new CheckBox();
    includeBasemap.setDescription("Include this basemap in the exported image.");
    includeBasemap.setWidth(64f, UNITS_PIXELS);

    HorizontalLayout basemapLayout = new HorizontalLayout();
    basemapLayout.setWidth(100f, UNITS_PERCENTAGE);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSizeFull();
    setSizeFull();

    Label step = new Label("Step 1: Select Layers");
    step.addStyleName("step");
    layout.addComponent(step);

    layout.addComponent(treeTable);
    layout.setSpacing(true);
    treeTable.setSizeFull();
    layout.setExpandRatio(treeTable, 1f);

    layout.addComponent(new Panel(BASEMAP, basemapLayout));
    basemapLayout.addComponent(basemapSelector);
    basemapLayout.setExpandRatio(basemapSelector, 1f);
    basemapLayout.addComponent(includeBasemap);

    layout.addComponent(cssLayers);
    cssLayers.addComponent(btnAddFilter);

    HorizontalLayout backSubmitLayout = new HorizontalLayout();
    backSubmitLayout.setWidth("100%");
    backSubmitLayout.addComponent(btnBack);
    backSubmitLayout.addComponent(btnNext);
    backSubmitLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT);
    backSubmitLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT);

    VerticalLayout navLayout = new VerticalLayout();
    navLayout.addComponent(backSubmitLayout);
    navLayout.setSpacing(true);

    ThemeResource banner = new ThemeResource("img/ProgressBar1.png");
    navLayout.addComponent(new Embedded(null, banner));

    layout.addComponent(navLayout);
    layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER);

    btnNext.addListener(this);
    btnNext.setEnabled(false);
    btnBack.setEnabled(false); // always disabled
    btnAddFilter.addListener(this);

    layout.addStyleName("findlayers");
    setCompositionRoot(layout);
}

From source file:com.m1kah.ui.TodoComponent.java

License:Open Source License

private void initInputRow() {
    toggleAllButton = new CheckBox();
    toggleAllButton.setId("toggle-all");

    inputField = new TextField();
    inputField.setInputPrompt("What needs to be done?");

    Panel panel = new Panel(inputField);
    panel.addShortcutListener(new ShortcutListener("", ShortcutAction.KeyCode.ENTER, null) {
        @Override//from  w  ww. j av a  2  s  .c o  m
        public void handleAction(Object o, Object o1) {
            addNewTodo();
        }
    });

    HorizontalLayout inputFieldLayout = new HorizontalLayout(toggleAllButton, panel);
    inputFieldLayout.setComponentAlignment(toggleAllButton, Alignment.MIDDLE_LEFT);
    inputFieldLayout.setId("new-todo");
    addComponent(inputFieldLayout);
}

From source file:com.m1kah.ui.TodoRow.java

License:Open Source License

private void initCheckBox() {
    checkBox = new CheckBox();
    checkBox.addStyleName("toggle");
    checkBox.setImmediate(true);//from ww w  .ja va 2s .  c  o  m
    checkBox.setValue(todo.isCompleted());

}

From source file:com.mycollab.module.project.view.kanban.AddNewColumnWindow.java

License:Open Source License

public AddNewColumnWindow(final IKanbanView kanbanView, final String type, final String fieldGroup) {
    super(UserUIContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN));
    this.withModal(true).withResizable(false).withWidth("800px").withCenter();
    MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false));
    GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);
    this.setContent(layout);

    final TextField stageField = new TextField();
    final CheckBox defaultProject = new CheckBox();
    defaultProject.setVisible(UserUIContext.canBeYes(RolePermissionCollections.GLOBAL_PROJECT_SETTINGS));
    final ColorPicker colorPicker = new ColorPicker("", new com.vaadin.shared.ui.colorpicker.Color(
            DEFAULT_COLOR.getRed(), DEFAULT_COLOR.getGreen(), DEFAULT_COLOR.getBlue()));
    final TextArea description = new TextArea();

    gridFormLayoutHelper.addComponent(stageField, UserUIContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0);
    gridFormLayoutHelper.addComponent(defaultProject,
            UserUIContext.getMessage(TaskI18nEnum.FORM_COLUMN_DEFAULT_FOR_NEW_PROJECT), 0, 1);
    gridFormLayoutHelper.addComponent(colorPicker, UserUIContext.getMessage(TaskI18nEnum.FORM_COLUMN_COLOR), 0,
            2);//from   w  ww.ja  v  a2 s  .co m
    gridFormLayoutHelper.addComponent(description, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0,
            3);

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        OptionVal optionVal = new OptionVal();
        optionVal.setCreatedtime(new GregorianCalendar().getTime());
        optionVal.setCreateduser(UserUIContext.getUsername());
        optionVal.setDescription(description.getValue());
        com.vaadin.shared.ui.colorpicker.Color color = colorPicker.getColor();
        String cssColor = color.getCSS();
        if (cssColor.startsWith("#")) {
            cssColor = cssColor.substring(1);
        }
        optionVal.setColor(cssColor);
        if (defaultProject.getValue()) {
            optionVal.setIsdefault(true);
        } else {
            optionVal.setIsdefault(false);
            optionVal.setExtraid(CurrentProjectVariables.getProjectId());
        }
        optionVal.setSaccountid(MyCollabUI.getAccountId());
        optionVal.setType(type);
        optionVal.setTypeval(stageField.getValue());
        optionVal.setFieldgroup(fieldGroup);
        OptionValService optionService = AppContextUtil.getSpringBean(OptionValService.class);
        int optionValId = optionService.saveWithSession(optionVal, UserUIContext.getUsername());

        if (optionVal.getIsdefault()) {
            optionVal.setId(null);
            optionVal.setIsdefault(false);
            optionVal.setRefoption(optionValId);
            optionVal.setExtraid(CurrentProjectVariables.getProjectId());
            optionService.saveWithSession(optionVal, UserUIContext.getUsername());
        }
        kanbanView.addColumn(optionVal);
        close();
    }).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MHorizontalLayout controls = new MHorizontalLayout().with(cancelBtn, saveBtn)
            .withMargin(new MarginInfo(false, true, false, false));
    layout.with(gridFormLayoutHelper.getLayout(), controls).withAlign(controls, Alignment.BOTTOM_RIGHT);
}