Example usage for com.vaadin.ui CheckBox getValue

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

Introduction

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

Prototype

@Override
    public Boolean getValue() 

Source Link

Usage

From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbFillDialog.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<String> getSelectedTables() {
    tableSelectionLayout.listOfTablesTable.commit();
    List<String> select = new ArrayList<String>();
    Collection<Object> itemIds = (Collection<Object>) tableSelectionLayout.listOfTablesTable.getItemIds();
    for (Object itemId : itemIds) {
        Item item = tableSelectionLayout.listOfTablesTable.getItem(itemId);
        CheckBox checkBox = (CheckBox) item.getItemProperty("selected").getValue();
        if (checkBox.getValue().equals(Boolean.TRUE) && checkBox.isEnabled()) {
            select.add((String) itemId);
        }//w w  w .  j  a  v a 2s .c om
    }
    return select;
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableSelectionLayout.java

License:Open Source License

protected void createTableSelectionLayout(String titleKey) {

    this.addComponent(new Label(titleKey));

    HorizontalLayout schemaChooserLayout = new HorizontalLayout();
    schemaChooserLayout.setWidth(100, Unit.PERCENTAGE);
    schemaChooserLayout.setSpacing(true);
    this.addComponent(schemaChooserLayout);

    catalogSelect = new ComboBox("Catalog");
    catalogSelect.setImmediate(true);//from  w  w w.  j a va2 s .c  om
    CommonUiUtils.addItems(getCatalogs(), catalogSelect);
    schemaChooserLayout.addComponent(catalogSelect);
    if (selectedTablesSet.iterator().hasNext()) {
        catalogSelect.select(selectedTablesSet.iterator().next().getCatalog());
    } else {
        catalogSelect.select(databasePlatform.getDefaultCatalog());
    }
    schemaSelect = new ComboBox("Schema");
    schemaSelect.setImmediate(true);
    CommonUiUtils.addItems(getSchemas(), schemaSelect);
    schemaChooserLayout.addComponent(schemaSelect);
    if (selectedTablesSet.iterator().hasNext()) {
        schemaSelect.select(selectedTablesSet.iterator().next().getSchema());
    } else {
        schemaSelect.select(databasePlatform.getDefaultSchema());
    }

    Label spacer = new Label();
    schemaChooserLayout.addComponent(spacer);
    schemaChooserLayout.setExpandRatio(spacer, 1);

    filterField = new TextField();
    filterField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    filterField.setIcon(FontAwesome.SEARCH);
    filterField.setInputPrompt("Filter Tables");
    filterField.setNullRepresentation("");
    filterField.setImmediate(true);
    filterField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    filterField.setTextChangeTimeout(200);
    filterField.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = 1L;

        public void textChange(TextChangeEvent event) {
            filterField.setValue(event.getText());
            refreshTableOfTables();
        }
    });

    schemaChooserLayout.addComponent(filterField);
    schemaChooserLayout.setComponentAlignment(filterField, Alignment.BOTTOM_RIGHT);

    listOfTablesTable = CommonUiUtils.createTable();
    listOfTablesTable.setImmediate(true);
    listOfTablesTable.addItemClickListener(new ItemClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(ItemClickEvent event) {
            CheckBox checkBox = (CheckBox) event.getItem().getItemProperty("selected").getValue();
            checkBox.setValue(!checkBox.getValue());
        }
    });
    listOfTablesTable.addContainerProperty("selected", CheckBox.class, null);
    listOfTablesTable.setColumnWidth("selected", UiConstants.TABLE_SELECTED_COLUMN_WIDTH);
    listOfTablesTable.setColumnHeader("selected", "");
    listOfTablesTable.addContainerProperty("table", String.class, null);
    listOfTablesTable.setColumnHeader("table", "");
    listOfTablesTable.setSizeFull();
    this.addComponent(listOfTablesTable);
    this.setExpandRatio(listOfTablesTable, 1);

    schemaSelect.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            refreshTableOfTables();
        }
    });

    catalogSelect.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            refreshTableOfTables();
        }
    });

    refreshTableOfTables();

}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableSelectionLayout.java

License:Open Source License

private void populateTable(final String table) {
    final CheckBox checkBox = new CheckBox();
    checkBox.setValue(select(getSelectedCatalog(), getSelectedSchema(), table));
    listOfTablesTable.addItem(new Object[] { checkBox, table }, table);
    checkBox.addValueChangeListener(new Property.ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override//  www .  j a v  a2  s . c  o  m
        public void valueChange(ValueChangeEvent event) {
            if (checkBox.getValue()) {
                org.jumpmind.db.model.Table t = new org.jumpmind.db.model.Table(table);
                selectedTablesSet.add(t);
            } else {
                Iterator<org.jumpmind.db.model.Table> selectedIterator = selectedTablesSet.iterator();
                boolean notFound = true;
                while (selectedIterator.hasNext() || notFound) {
                    if (selectedIterator.next().getName().equals(table)) {
                        selectedIterator.remove();
                        notFound = false;
                    }
                }
            }
            selectionChanged();
        }
    });
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableSelectionLayout.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<String> getSelectedTables() {
    listOfTablesTable.commit();//  w  w  w  .  jav a  2 s.  co  m
    List<String> select = new ArrayList<String>();
    Collection<Object> itemIds = (Collection<Object>) listOfTablesTable.getItemIds();
    for (Object itemId : itemIds) {
        Item item = listOfTablesTable.getItem(itemId);
        CheckBox checkBox = (CheckBox) item.getItemProperty("selected").getValue();
        if (checkBox.getValue().equals(Boolean.TRUE) && checkBox.isEnabled()) {
            select.add((String) itemId);
        }
    }
    return select;
}

From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.impexp.BasicImpExp.java

License:Open Source License

protected List<PreferencesPage> getSelectedPages() {
    List<PreferencesPage> list = new ArrayList<>();
    for (CheckBox cb : checkBoxes) {
        if (cb.getValue()) {
            PreferencesPage page = (PreferencesPage) cb.getData();
            list.add(page);//from w w w . jav a2 s .co m
        }
    }
    return list;
}

From source file:org.mpavel.app.views.LoginView.java

License:Apache License

public LoginView(final String fragmentAndParameters) {
    setCaption("Login");

    VerticalLayout layout = new VerticalLayout();
    final TextField username = new TextField("Username");
    layout.addComponent(username);/*from  w w  w  .ja va2s  . c o m*/

    final PasswordField password = new PasswordField("Password");
    layout.addComponent(password);

    final CheckBox rememberMe = new CheckBox("Remember Me");
    layout.addComponent(rememberMe);

    username.focus();

    // TODO: Remove these two lines before production release
    username.setValue("admin");
    password.setValue("admin");

    if (ApplicationSecurity.isRemembered()) {
        username.setValue(ApplicationSecurity.whoIsRemembered());
        rememberMe.setValue(ApplicationSecurity.isRemembered());
        password.focus();
    }

    @SuppressWarnings("serial")
    final Button login = new Button("Login", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final Navigator navigator = UI.getCurrent().getNavigator();
            if (ApplicationSecurity.login(username.getValue(), password.getValue(), rememberMe.getValue())) {
                final String location = (fragmentAndParameters == null) ? ApplicationView.NAME
                        : fragmentAndParameters;

                navigator.navigateTo(location);
            } else {
                navigator.navigateTo(LoginView.NAME);
            }
        }
    });
    layout.addComponent(login);
    setContent(layout);
}

From source file:org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.AttributesTable.java

License:Open Source License

private void updateCheckBoxes() {
    for (Object eachRowId : getItemIds()) {
        CheckBox checkBox = getCheckBoxForRow(eachRowId);
        updateCheckBox(checkBox, eachRowId, checkBox.getValue());
    }//ww  w. ja  v  a2 s  .c o m
}

From source file:org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.AttributesTable.java

License:Open Source License

private void updateCheckBox(CheckBox checkBox, Object rowId, boolean enabled) {
    checkBox.setValue(enabled);//from  w  w  w .  jav a2  s  .  c  o m
    Collection<Field<?>> columns = getFieldsForItemId(rowId);
    columns.remove(checkBox);
    enableFields(columns, checkBox.getValue());
}

From source file:org.ops4j.pax.vaadin.samples.complex.app.MyComplexVaadinApplication.java

License:Apache License

@Override
public void init() {

    // TODO CHECK WHY THEME RENDERING IS TOO SLOW
    // setTheme("table");

    window = new Window("My Complex Vaadin Application");
    setMainWindow(window);/*from  w w  w. j av a 2 s  .  c  o  m*/

    final VerticalLayout layout = new VerticalLayout();
    final Table table = new Table("The Pax projects");
    table.addStyleName("multirowlabels");

    // Define two columns for the built-in container
    table.addContainerProperty("Code", String.class, null);
    table.addContainerProperty("Description", String.class, null);
    table.addContainerProperty("Creation Date", Date.class, null);
    // table.addContainerProperty("Edit", CheckBox.class, null);

    // Add a row the hard way
    Object newItemId = table.addItem();
    Item row1 = table.getItem(newItemId);
    row1.getItemProperty("Code").setValue("pax-vaadin");
    row1.getItemProperty("Description").setValue("OSGI vaadin project");
    //row1.getItemProperty("Creation date").setValue(new Date());

    // Add a few other rows using shorthand addItem()
    table.addItem(new Object[] { "pax-cdi", "pax cdi project", new Date() }, 2);
    table.addItem(new Object[] { "pax-logging", "pax logging project", new Date() }, 3);
    table.addItem(new Object[] { "pax-runner", "osgi runner tool", new Date() }, 4);
    table.addItem(new Object[] { "pax-web", "pax web project", new Date() }, 5);
    table.addItem(new Object[] { "pax-jdbc", "pax jdbc project", new Date() }, 6);

    // Allow selecting
    table.setSelectable(true);

    // Put the table in editable mode
    table.setEditable(false);

    // Reordering
    table.setColumnReorderingAllowed(true);

    // Allow switching to non-editable mode
    final CheckBox editable = new CheckBox("Table is editable", false);
    editable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 6291942958587745232L;

        public void valueChange(ValueChangeEvent event) {
            table.setEditable((Boolean) editable.getValue());
        }
    });
    editable.setImmediate(true);
    layout.addComponent(editable);

    // Handle selection changes
    table.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty().getValue() != null) {
                layout.addComponent(new Label("Selected item id " + event.getProperty().getValue().toString()));
            } else // Item deselected
            {
                layout.addComponent(new Label("Nothing selected"));
            }
        }
    });

    // Set Table Size
    table.setPageLength(table.size());

    layout.addComponent(table);
    window.addComponent(layout);

    IndexedContainer container = new IndexedContainer();
    container.addContainerProperty("foo", String.class, null);
    container.addContainerProperty("bar", String.class, null);
    container.addContainerProperty("baz", String.class, null);
    for (int i = 0; i < 100; i++) {
        Item item = container.addItem(i);
        item.getItemProperty("foo").setValue("foo " + i);
        item.getItemProperty("bar").setValue("bar");
        item.getItemProperty("baz").setValue("baz");
    }
    PagedTable pagedTable = new PagedTable("footable");
    pagedTable.setContainerDataSource(container);
    pagedTable.setPageLength(15);
    window.addComponent(pagedTable);
    window.addComponent(pagedTable.createControls());
    setMainWindow(window);

}

From source file:org.ripla.web.demo.config.views.LoginConfigView.java

License:Open Source License

/**
 * LoginConfigView constructor.// w ww .j a v a  2  s  .  c  o  m
 * 
 * @param inLoginConfig
 * @param inController
 *            {@link LoginConfigController}
 * @param inEnabled
 *            boolean <code>true</code> if login configuration is enabled
 */
public LoginConfigView(final boolean inLoginConfig, final LoginConfigController inController,
        final boolean inEnabled) {
    super();
    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = new VerticalLayout();
    setCompositionRoot(lLayout);
    lLayout.setStyleName("demo-view"); //$NON-NLS-1$
    lLayout.addComponent(new Label(String.format(RiplaViewHelper.TMPL_TITLE, "demo-pagetitle", //$NON-NLS-1$
            lMessages.getMessage("config.login.page.title")), ContentMode.HTML)); //$NON-NLS-1$

    lLayout.addComponent(new Label(lMessages.getMessage("view.login.remark"), ContentMode.HTML)); //$NON-NLS-1$
    if (!inEnabled) {
        lLayout.addComponent(new Label(lMessages.getMessage("view.login.disabled"), ContentMode.HTML)); //$NON-NLS-1$
    }

    final CheckBox lCheckbox = new CheckBox(lMessages.getMessage("view.login.chk.label")); //$NON-NLS-1$
    lCheckbox.setValue(inLoginConfig);
    lCheckbox.setEnabled(inEnabled);
    lCheckbox.focus();
    lLayout.addComponent(lCheckbox);

    final Button lSave = new Button(lMessages.getMessage("config.view.button.save")); //$NON-NLS-1$
    lSave.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            inController.saveChange(lCheckbox.getValue());
        }
    });
    lSave.setEnabled(inEnabled);
    lSave.setClickShortcut(KeyCode.ENTER);
    lLayout.addComponent(lSave);
}