Example usage for com.vaadin.ui CheckBox setValue

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

Introduction

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

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Sets the value of this CheckBox.

Usage

From source file:org.opencms.workplace.tools.git.ui.CmsGitToolOptionsPanel.java

License:Open Source License

/**
 * Enables/disables checkboxes for listed modules which are not installed.<p>
 *
 * @param enable true if the checkboxes for modules which are not installed should be enabled, false if they should be disabled
 *//*w  ww  . j a v  a  2s . c om*/
public void enableCheckboxesForNotInstalledModules(boolean enable) {

    for (Map.Entry<String, CheckBox> entry : m_moduleCheckboxes.entrySet()) {
        String moduleName = entry.getKey();
        CheckBox checkbox = entry.getValue();
        if (!OpenCms.getModuleManager().hasModule(moduleName)) {
            checkbox.setEnabled(enable);
            if (!enable) {
                checkbox.setValue(Boolean.FALSE);
            }
        }
    }
}

From source file:org.opennms.features.topology.plugins.browsers.CheckboxGenerator.java

License:Open Source License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    final Property<Integer> property = source.getContainerProperty(itemId, m_valueProperty);
    if (property.getValue() == null) {
        return null;
    } else {//from   www  .  java  2s .c om
        if (SecurityContextHolder.getContext().toString().contains(Authentication.ROLE_READONLY)) {
            // Do not render the checkboxes for read-only users
            return null;
        } else {
            final CheckBox button = new CheckBox();
            button.setData(property.getValue());
            button.setValue(isSelected((Integer) property.getValue()));
            button.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 2991986878904005830L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    if (Boolean.TRUE.equals(event.getProperty().getValue())) {
                        m_selectedCheckboxes.add(property.getValue());
                        m_notSelectedCheckboxes.remove(property.getValue());
                    } else {
                        m_selectedCheckboxes.remove(property.getValue());
                        m_notSelectedCheckboxes.add(property.getValue());
                    }
                }
            });
            m_checkboxes.add(button);
            return button;
        }
    }
}

From source file:org.opennms.features.topology.plugins.browsers.CheckboxGenerator.java

License:Open Source License

public void clearSelectedIds(Table source) {
    m_selectAll = false;/*www . j av a2 s .  c o  m*/

    // Uncheck all of the checkboxes
    for (CheckBox button : m_checkboxes) {
        button.setValue(false);
    }
    m_selectedCheckboxes.clear();
    m_notSelectedCheckboxes.clear();
}

From source file:org.opennms.features.topology.plugins.browsers.CheckboxGenerator.java

License:Open Source License

public void selectAll(Table source) {
    m_selectAll = true;//from  w  ww  .ja  va 2  s. c  o  m

    m_selectedCheckboxes.clear();
    m_notSelectedCheckboxes.clear();
    // Check all of the checkboxes
    for (CheckBox button : m_checkboxes) {
        button.setValue(true);
        m_selectedCheckboxes.add((Integer) button.getData());
    }
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardOverview.java

License:Open Source License

/**
 * Constructor for creating new instances.
 *
 * @param wallboardConfigView the {@link WallboardConfigView}
 *///  w  w w . j  a v  a2  s. c  o  m
public WallboardOverview(WallboardConfigView wallboardConfigView) {
    /**
     * Setting the member fields
     */
    this.m_wallboardConfigView = wallboardConfigView;

    /**
     * Setting up the layout component
     */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    Label label = new Label("Overview");
    label.addStyleName("configuration-title");

    Button button = new Button("Help");
    button.setStyleName("small");
    button.setDescription("Display help and usage");

    button.addClickListener(new HelpClickListener(this, m_wallboardConfigView.getDashletSelector()));

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.addComponent(label);
    horizontalLayout.addComponent(button);
    horizontalLayout.setWidth(100, Unit.PERCENTAGE);

    horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    horizontalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    addComponent(horizontalLayout);

    /**
     * Adding the table with the required {@link Table.ColumnGenerator} objects
     */
    m_table = new Table();
    m_table.setSizeFull();

    m_table.addGeneratedColumn("Edit", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            Button button = new Button("Edit");
            button.setDescription("Edit this Ops Board configuration");
            button.setStyleName("small");
            button.addClickListener(new Button.ClickListener() {
                public void buttonClick(Button.ClickEvent clickEvent) {
                    m_wallboardConfigView.openWallboardEditor((Wallboard) itemId);
                }
            });
            return button;
        }
    });

    m_table.addGeneratedColumn("Remove", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            Button button = new Button("Remove");
            button.setDescription("Delete this Ops Board configuration");
            button.setStyleName("small");
            button.addClickListener(new Button.ClickListener() {
                public void buttonClick(Button.ClickEvent clickEvent) {
                    m_wallboardConfigView.removeTab(((Wallboard) itemId).getTitle());
                    WallboardProvider.getInstance().removeWallboard((Wallboard) itemId);
                    refreshTable();
                }
            });
            return button;
        }
    });

    m_table.addGeneratedColumn("Preview", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            Button button = new Button("Preview");
            button.setDescription("Preview this Ops Board configuration");
            button.setStyleName("small");
            button.addClickListener(new PreviewClickListener(WallboardOverview.this, (Wallboard) itemId));
            return button;
        }
    });

    m_table.addGeneratedColumn("Default", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            CheckBox checkBox = new CheckBox();
            checkBox.setImmediate(true);
            checkBox.setDescription("Make this Ops Board configuration the default");

            final Wallboard wallboard = m_beanItemContainer.getItem(itemId).getBean();
            checkBox.setValue(wallboard.isDefault());

            checkBox.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue());

                    if (newValue) {
                        for (Wallboard wallboard1 : m_beanItemContainer.getItemIds()) {
                            wallboard1.setDefault(false);
                        }
                    }

                    wallboard.setDefault(newValue);

                    m_table.refreshRowCache();

                    WallboardProvider.getInstance().save();
                }
            });
            return checkBox;
        }
    });

    refreshTable();

    /**
     * Adding the table
     */
    addComponent(m_table);

    setExpandRatio(m_table, 1.0f);
}

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);
    Collection<Field<?>> columns = getFieldsForItemId(rowId);
    columns.remove(checkBox);/* w w  w .  j a v  a 2  s.  c  o  m*/
    enableFields(columns, checkBox.getValue());
}

From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewsConfigList.java

License:Open Source License

/**
 * Constructor for creating this component.
 *
 * @param surveillanceViewService the surveillance view service to be used
 *//* w  w  w  . ja  v  a 2s. c om*/
public SurveillanceViewsConfigList(SurveillanceViewService surveillanceViewService) {
    /**
     * set the fields
     */
    this.m_surveillanceViewService = surveillanceViewService;

    /**
     * Loading the config
     */
    reloadSurveillanceViews();

    /**
     * Setting up the layout component
     */
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    Label label = new Label("Surveillance View Configurations");
    label.addStyleName("configuration-title");

    /*
    Button button = new Button("Help");
    button.setStyleName("small");
    button.setDescription("Display help and usage");
    */

    /**
     * button.addClickListener(new HelpClickListener(this, m_wallboardConfigView.getDashletSelector()));
     */

    Button addButton = new Button("Add");
    addButton.setStyleName("small");
    addButton.setDescription("Add surveillance view configuration");

    addButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String newName;
            int i = 0;

            do {
                i++;
                newName = "Untitled #" + i;
            } while (SurveillanceViewProvider.getInstance().containsView(newName));

            View view = new View();
            view.setName(newName);

            getUI().addWindow(new SurveillanceViewConfigurationWindow(m_surveillanceViewService, view,
                    new SurveillanceViewConfigurationWindow.SaveActionListener() {
                        @Override
                        public void save(View view) {
                            m_beanItemContainer.addItem(view);

                            SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration().getViews()
                                    .add(view);
                            SurveillanceViewProvider.getInstance().save();

                            ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved",
                                    "Surveillance View");

                            m_table.refreshRowCache();
                            m_table.sort(new Object[] { "name" }, new boolean[] { true });
                        }
                    }));
        }
    });

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.addComponent(label);
    // horizontalLayout.addComponent(button);
    horizontalLayout.setWidth(100, Unit.PERCENTAGE);

    horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    // horizontalLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    addComponent(horizontalLayout);

    addComponent(addButton);

    /**
     * Adding the table with the required {@link com.vaadin.ui.Table.ColumnGenerator} objects
     */
    m_table = new Table();

    m_table.setContainerDataSource(m_beanItemContainer);
    m_table.setSizeFull();
    m_table.sort(new Object[] { "name" }, new boolean[] { true });

    m_table.addGeneratedColumn("Edit", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            Button button = new Button("Edit");
            button.setDescription("Edit this Surveillance View configuration");
            button.setStyleName("small");
            button.addClickListener(new Button.ClickListener() {
                public void buttonClick(Button.ClickEvent clickEvent) {
                    getUI().addWindow(new SurveillanceViewConfigurationWindow(m_surveillanceViewService,
                            m_beanItemContainer.getItem(itemId).getBean(),
                            new SurveillanceViewConfigurationWindow.SaveActionListener() {
                                @Override
                                public void save(View view) {
                                    View oldView = m_beanItemContainer.getItem(itemId).getBean();

                                    m_beanItemContainer.removeItem(itemId);
                                    m_beanItemContainer.addItem(view);

                                    SurveillanceViewProvider.getInstance().replaceView(oldView, view);

                                    SurveillanceViewProvider.getInstance().save();
                                    ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved",
                                            "Surveillance view");

                                    m_table.refreshRowCache();
                                    m_table.sort(new Object[] { "name" }, new boolean[] { true });
                                }
                            }));
                }
            });
            return button;
        }
    }

    );

    m_table.addGeneratedColumn("Remove", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            Button button = new Button("Remove");
            button.setDescription("Delete this Surveillance View configuration");
            button.setStyleName("small");
            button.addClickListener(new Button.ClickListener() {
                public void buttonClick(Button.ClickEvent clickEvent) {
                    SurveillanceViewProvider.getInstance().removeView((View) itemId);
                    m_beanItemContainer.removeItem(itemId);
                }
            });
            return button;
        }
    });

    m_table.addGeneratedColumn("Preview", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            Button button = new Button("Preview");
            button.setDescription("Preview this Surveillance View configuration");
            button.setStyleName("small");

            button.addClickListener(new PreviewClickListener(m_surveillanceViewService,
                    SurveillanceViewsConfigList.this, (View) itemId));

            return button;
        }
    }

    );

    m_table.addGeneratedColumn("Default", new Table.ColumnGenerator() {
        public Object generateCell(Table source, final Object itemId, Object columnId) {
            CheckBox checkBox = new CheckBox();
            checkBox.setImmediate(true);
            checkBox.setDescription("Make this Surveillance View configuration the default");

            final View view = m_beanItemContainer.getItem(itemId).getBean();

            checkBox.setValue(SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration()
                    .getDefaultView().equals(view.getName()));

            checkBox.addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
                    boolean newValue = ((Boolean) valueChangeEvent.getProperty().getValue());

                    if (newValue) {
                        SurveillanceViewProvider.getInstance().getSurveillanceViewConfiguration()
                                .setDefaultView(view.getName());
                    }

                    m_table.refreshRowCache();

                    SurveillanceViewProvider.getInstance().save();

                    ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Data saved",
                            "Default surveillance view");
                }
            });
            return checkBox;
        }
    }

    );

    m_table.setVisibleColumns(new Object[] { "name", "Edit", "Remove", "Preview", "Default" });
    m_table.setColumnHeader("name", "Name");

    /**
     * Adding the table
     */
    addComponent(m_table);

    setExpandRatio(m_table, 1.0f);
}

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

License:Open Source License

/**
 * LoginConfigView constructor./*ww w  . j a va2 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);
}

From source file:org.vaadin.alump.fancylayouts.demo.CssLayoutDemo.java

License:Apache License

public CssLayoutDemo() {
    setMargin(true);/*from www. j av a  2s .  c om*/
    setSpacing(true);
    setSizeFull();

    final FancyCssLayout cssLayout = new FancyCssLayout();

    Label todo = new Label("FancyCssLayout adds transitions when you add or remove components from it.");
    addComponent(todo);

    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setWidth("100%");
    addComponent(hLayout);

    Button addContent = new Button("Add new content item");
    hLayout.addComponent(addContent);

    CheckBox middleCbox = new CheckBox("add middle");
    middleCbox.setImmediate(true);
    middleCbox.setValue(addCssMiddle);
    hLayout.addComponent(middleCbox);

    CheckBox marginCbox = new CheckBox("slide");
    marginCbox.setImmediate(true);
    marginCbox.setValue(cssLayout.isTransitionEnabled(FancyTransition.SLIDE));
    hLayout.addComponent(marginCbox);

    CheckBox styleCbox = new CheckBox("cards");
    styleCbox.setImmediate(true);
    styleCbox.setValue(boxMode);
    hLayout.addComponent(styleCbox);

    final Label counterLabel = new Label(getClickCounterCaption());
    hLayout.addComponent(counterLabel);

    cssLayout.setSizeFull();
    addComponent(cssLayout);
    setExpandRatio(cssLayout, 1.0f);

    for (int i = 0; i < 10; ++i) {
        addCssLayoutContent(cssLayout);
    }

    addContent.addClickListener(new Button.ClickListener() {

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

    middleCbox.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            addCssMiddle = (Boolean) event.getProperty().getValue();
        }

    });

    marginCbox.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            cssLayout.setSlideEnabled((Boolean) event.getProperty().getValue());
        }

    });

    styleCbox.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) event.getProperty().getValue();
            Iterator<Component> iter = cssLayout.iterator();
            while (iter.hasNext()) {
                Component component = iter.next();
                if (value) {
                    component.addStyleName("demo-removable-two");
                } else {
                    component.removeStyleName("demo-removable-two");
                }
            }
            boxMode = value;
        }

    });

    cssLayout.addLayoutClickListener(new LayoutClickListener() {

        @Override
        public void layoutClick(LayoutClickEvent event) {
            ++clickCounter;
            if (event.getChildComponent() == null) {
                ++layoutClickCounter;
            }
            counterLabel.setValue(getClickCounterCaption());
        }

    });

}

From source file:org.vaadin.alump.fancylayouts.demo.ImageDemo.java

License:Apache License

public ImageDemo() {
    setMargin(true);/*from   w ww. j a v  a  2 s  . c  o m*/
    setSpacing(true);
    setWidth("100%");

    Label desc = new Label(
            "FancyImage can be used when you want to present multiple images in one place. This component allows you to select which image to show when or just enabled the automatic slide show mode.");
    addComponent(desc);

    final FancyImage image = new FancyImage();
    image.setWidth("500px");
    image.setHeight("281px");

    // Setting images used
    final List<Resource> resources = getImageResources();
    for (Resource resource : resources) {
        image.addResource(resource);
    }

    // Setting slideshow timeout to 3 seconds (3000 millisecs)
    image.setSlideShowTimeout(3000);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    addComponent(buttonLayout);
    addComponent(image);
    setComponentAlignment(image, Alignment.TOP_CENTER);

    for (int i = 0; i < resources.size(); ++i) {
        final Button button = new Button("Pic " + (i + 1));
        buttonLayout.addComponent(button);
        final Resource res = resources.get(i);
        button.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                image.showResource(res);

            }
        });
        disableWhenAutoPlay.add(button);
    }

    CheckBox auto = new CheckBox("Slide show");
    auto.setImmediate(true);
    buttonLayout.addComponent(auto);

    CheckBox fade = new CheckBox("Fade");
    fade.setDescription("Fade image when changing");
    fade.setImmediate(true);
    fade.setValue(image.isFadeTransition());
    buttonLayout.addComponent(fade);

    CheckBox rotate = new CheckBox("Rotate");
    rotate.setDescription("Rotate image when changing");
    rotate.setImmediate(true);
    rotate.setValue(image.isRotateTransition());
    buttonLayout.addComponent(rotate);

    horizontal = new CheckBox("Horizontal");
    horizontal.setDescription("Should rotate happen horizontally or vertically.");
    horizontal.setValue(true);
    buttonLayout.addComponent(horizontal);

    TextField timeout = new TextField();
    timeout.setCaption("Slide show millisecs");
    timeout.setValue(String.valueOf(image.getSlideShowTimeout()));
    timeout.setDescription("How many millisec the slideshow shows one image");
    buttonLayout.addComponent(timeout);
    timeout.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            try {
                int value = Integer.parseInt(event.getText());
                // Change slide show value
                image.setSlideShowTimeout(value);
            } catch (NumberFormatException e) {
            }
        }

    });

    auto.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            // Enable/disable slideshow mode
            image.setSlideShowEnabled(value);
            for (Component component : disableWhenAutoPlay) {
                component.setEnabled(!value);
            }
        }
    });

    fade.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            image.setFadeTransition(value.booleanValue());
        }
    });

    rotate.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean value = (Boolean) event.getProperty().getValue();
            image.setRotateTransition(value.booleanValue(), horizontal.getValue());
        }
    });

    horizontal.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (image.isRotateTransition()) {
                image.setRotateTransition(true, (Boolean) event.getProperty().getValue());
            }
        }
    });
}