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.jumpmind.metl.ui.views.design.PropertySheet.java

License:Open Source License

protected void addSettingField(final XMLSetting definition, final AbstractObjectWithSettings obj,
        FormLayout formLayout) {/*from   w  ww  . jav  a  2  s . com*/
    boolean required = definition.isRequired();
    if (definition.isVisible()) {
        Component component = null;
        if (obj instanceof Component) {
            component = (Component) obj;
        }
        String description = definition.getDescription();
        Type type = definition.getType();
        FlowStep step = null;
        switch (type) {
        case BOOLEAN:
            final CheckBox checkBox = new CheckBox(definition.getName());
            checkBox.setImmediate(true);
            boolean defaultValue = false;
            if (isNotBlank(definition.getDefaultValue())) {
                defaultValue = Boolean.parseBoolean(definition.getDefaultValue());
            }
            checkBox.setValue(obj.getBoolean(definition.getId(), defaultValue));
            checkBox.setRequired(required);
            checkBox.setDescription(description);

            checkBox.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    saveSetting(definition.getId(), checkBox.getValue().toString(), obj);
                    if (listener != null) {
                        List<Component> components = new ArrayList<Component>(1);
                        components.add((Component) obj);
                        listener.componentChanged(components);
                    }
                }
            });
            checkBox.setReadOnly(readOnly);
            formLayout.addComponent(checkBox);
            break;
        case CHOICE:
            final AbstractSelect choice = new ComboBox(definition.getName());
            choice.setImmediate(true);
            List<String> choices = definition.getChoices() != null ? definition.getChoices().getChoice()
                    : new ArrayList<String>(0);
            for (String c : choices) {
                choice.addItem(c);
            }
            choice.setValue(obj.get(definition.getId(), definition.getDefaultValue()));
            choice.setDescription(description);
            choice.setNullSelectionAllowed(false);
            choice.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    saveSetting(definition.getId(), (String) choice.getValue(), obj);
                }
            });
            choice.setReadOnly(readOnly);
            formLayout.addComponent(choice);
            break;
        case PASSWORD:
            ImmediateUpdatePasswordField passwordField = new ImmediateUpdatePasswordField(
                    definition.getName()) {
                private static final long serialVersionUID = 1L;

                protected void save(String text) {
                    saveSetting(definition.getId(), text, obj);
                };
            };
            passwordField.setValue(obj.get(definition.getId(), definition.getDefaultValue()));
            passwordField.setRequired(required);
            passwordField.setDescription(description);
            passwordField.setReadOnly(readOnly);
            formLayout.addComponent(passwordField);
            break;
        case INTEGER:
            ImmediateUpdateTextField integerField = new ImmediateUpdateTextField(definition.getName()) {
                private static final long serialVersionUID = 1L;

                protected void save(String text) {
                    saveSetting(definition.getId(), text, obj);
                };
            };
            integerField.setConverter(Integer.class);
            integerField.setValue(obj.get(definition.getId(), definition.getDefaultValue()));
            integerField.setRequired(required);
            integerField.setDescription(description);
            integerField.setReadOnly(readOnly);
            formLayout.addComponent(integerField);
            break;
        case TEXT:
            ImmediateUpdateTextField textField = new ImmediateUpdateTextField(definition.getName()) {
                private static final long serialVersionUID = 1L;

                protected void save(String text) {
                    saveSetting(definition.getId(), text, obj);
                };
            };
            textField.setValue(obj.get(definition.getId(), definition.getDefaultValue()));
            textField.setRequired(required);
            textField.setDescription(description);
            textField.setReadOnly(readOnly);
            formLayout.addComponent(textField);
            break;
        case SOURCE_STEP:
            step = getSingleFlowStep();
            if (step != null) {
                Flow flow = context.getConfigurationService().findFlow(step.getFlowId());
                final AbstractSelect sourceStepsCombo = new ComboBox(definition.getName());
                sourceStepsCombo.setImmediate(true);

                List<FlowStepLink> sourceSteps = flow.findFlowStepLinksWithTarget(step.getId());
                for (FlowStepLink flowStepLink : sourceSteps) {
                    FlowStep sourceStep = flow.findFlowStepWithId(flowStepLink.getSourceStepId());
                    sourceStepsCombo.addItem(sourceStep.getId());
                    sourceStepsCombo.setItemCaption(sourceStep.getId(), sourceStep.getName());
                }
                sourceStepsCombo.setValue(obj.get(definition.getId()));
                sourceStepsCombo.setDescription(description);
                sourceStepsCombo.setNullSelectionAllowed(false);
                sourceStepsCombo.addValueChangeListener(new ValueChangeListener() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        saveSetting(definition.getId(), (String) sourceStepsCombo.getValue(), obj);
                    }
                });
                sourceStepsCombo.setReadOnly(readOnly);
                formLayout.addComponent(sourceStepsCombo);
            }
            break;
        case FLOW:
            step = getSingleFlowStep();
            if (step != null) {
                String projectVersionId = step.getComponent().getProjectVersionId();
                List<FlowName> flows = context.getConfigurationService().findFlowsInProject(projectVersionId,
                        false);
                final AbstractSelect combo = new ComboBox(definition.getName());
                combo.setImmediate(true);
                for (FlowName name : flows) {
                    if (!step.getFlowId().equals(name.getId())) {
                        combo.addItem(name.getId());
                        combo.setItemCaption(name.getId(), name.getName());
                    }
                }
                combo.setValue(obj.get(definition.getId()));
                combo.setDescription(description);
                combo.setNullSelectionAllowed(false);
                combo.addValueChangeListener(new ValueChangeListener() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        saveSetting(definition.getId(), (String) combo.getValue(), obj);
                    }
                });
                combo.setReadOnly(readOnly);
                formLayout.addComponent(combo);
            }
            break;
        case STREAMABLE_RESOURCE:
            formLayout.addComponent(createResourceCombo(definition, obj, ResourceCategory.STREAMABLE));
            break;
        case DATASOURCE_RESOURCE:
            formLayout.addComponent(createResourceCombo(definition, obj, ResourceCategory.DATASOURCE));
            break;
        case ENTITY_COLUMN:
            if (component != null) {
                List<ModelEntity> entities = new ArrayList<ModelEntity>();
                Model model = component.getInputModel();
                if (model != null) {
                    model.sortAttributes();
                    entities.addAll(model.getModelEntities());
                }
                model = component.getOutputModel();
                if (model != null) {
                    model.sortAttributes();
                    entities.addAll(model.getModelEntities());
                }
                AbstractObjectNameBasedSorter.sort(entities);

                final AbstractSelect entityColumnCombo = new ComboBox(definition.getName());
                entityColumnCombo.setImmediate(true);

                for (ModelEntity modelEntity : entities) {
                    for (ModelAttribute attribute : modelEntity.getModelAttributes()) {
                        entityColumnCombo.addItem(attribute.getId());
                        entityColumnCombo.setItemCaption(attribute.getId(),
                                modelEntity.getName() + "." + attribute.getName());
                    }
                }
                String currentValue = obj.get(definition.getId());
                if (currentValue != null) {
                    entityColumnCombo.setValue(obj.get(definition.getId()));
                }
                entityColumnCombo.setDescription(description);
                entityColumnCombo.setNullSelectionAllowed(definition.isRequired());
                entityColumnCombo.addValueChangeListener(new ValueChangeListener() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        saveSetting(definition.getId(), (String) entityColumnCombo.getValue(), obj);
                    }
                });
                entityColumnCombo.setReadOnly(readOnly);
                formLayout.addComponent(entityColumnCombo);
            }
            break;
        case SCRIPT:
            final AceEditor editor = CommonUiUtils.createAceEditor();
            editor.setTextChangeEventMode(TextChangeEventMode.LAZY);
            editor.setTextChangeTimeout(200);
            editor.setMode(AceMode.java);
            editor.setHeight(10, Unit.EM);
            editor.setCaption(definition.getName());
            editor.setShowGutter(false);
            editor.setShowPrintMargin(false);
            editor.setValue(obj.get(definition.getId(), definition.getDefaultValue()));
            editor.addTextChangeListener(new TextChangeListener() {
                @Override
                public void textChange(TextChangeEvent event) {
                    Setting data = obj.findSetting(definition.getId());
                    data.setValue(event.getText());
                    context.getConfigurationService().save(data);
                }
            });
            editor.setReadOnly(readOnly);
            formLayout.addComponent(editor);
            break;
        case MULTILINE_TEXT:
        case XML:
            ImmediateUpdateTextArea area = new ImmediateUpdateTextArea(definition.getName()) {
                private static final long serialVersionUID = 1L;

                protected void save(String text) {
                    saveSetting(definition.getId(), text, obj);
                };
            };
            area.setValue(obj.get(definition.getId(), definition.getDefaultValue()));
            area.setRows(5);
            area.setRequired(required);
            area.setDescription(description);
            area.setReadOnly(readOnly);
            formLayout.addComponent(area);
            break;
        default:
            break;

        }
    }
}

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);// ww  w. j  ava  2s  . com
    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/* w w w. j a v a  2s .  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

public void selectAll() {
    @SuppressWarnings("unchecked")
    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.isEnabled()) {
            checkBox.setValue(Boolean.TRUE);
        }//from w  w  w.j av a 2s  . c om
    }
}

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

License:Open Source License

public void selectNone() {
    @SuppressWarnings("unchecked")
    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.isEnabled()) {
            checkBox.setValue(Boolean.FALSE);
        }/* www .  j a va2 s  .co  m*/
    }
}

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  ww  .  j av  a 2s. c om*/

    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.opencms.ui.dataview.CmsDataViewPanel.java

License:Open Source License

/**
* Creates a new instance.<p>/*from  w  w  w .j ava  2  s.  c o  m*/
*
* @param viewInstance the data view instance
* @param multiselect true if multi-selection should be allowed
*/
public CmsDataViewPanel(I_CmsDataView viewInstance, boolean multiselect) {
    m_dataView = viewInstance;
    CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);

    m_pagingControls.addCallback(new I_PagingCallback() {

        public void pageChanged(int page) {

            refreshData(false, null);
        }
    });
    m_fullTextSearch.addShortcutListener(new ShortcutListener("Save", KeyCode.ENTER, null) {

        private static final long serialVersionUID = 1L;

        @Override
        public void handleAction(Object sender, Object target) {

            refreshData(false, null);

        }
    });
    m_searchButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            refreshData(true, null);
        }

    });
    m_container = new IndexedContainer();
    for (CmsDataViewColumn column : m_dataView.getColumns()) {
        m_container.addContainerProperty(column.getId(),
                CmsColumnValueConverter.getColumnClass(column.getType()), null);

    }
    m_container.addContainerProperty(ID_COLUMN, String.class, null);

    final PagedTable table = new PagedTable(m_container);
    table.addStyleName(OpenCmsTheme.TABLE_CELL_PADDING);
    table.setMultiSelect(multiselect);

    table.addGeneratedColumn("checked", new ColumnGenerator() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public Object generateCell(final Table source, final Object itemId, final Object columnId) {

            CheckBox cb = getCheckBox(itemId);
            cb.setValue(Boolean.valueOf(source.isSelected(itemId)));
            cb.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                public void valueChange(ValueChangeEvent event) {

                    boolean val = ((Boolean) (event.getProperty().getValue())).booleanValue();
                    if (val) {
                        source.select(itemId);
                    } else {
                        source.unselect(itemId);
                    }
                }
            });
            return cb;
        }
    });

    table.addStyleName("o-wrap-table");
    Object[] visibleCols = new String[m_dataView.getColumns().size() + 1];
    visibleCols[0] = "checked";
    int i = 1;
    for (CmsDataViewColumn col : m_dataView.getColumns()) {
        visibleCols[i++] = col.getId();

    }
    table.setVisibleColumns(visibleCols);
    table.setColumnWidth("checked", 45);
    table.setColumnHeader("checked", "");
    for (CmsDataViewColumn col : m_dataView.getColumns()) {
        table.setColumnHeader(col.getId(), col.getNiceName());
        table.setColumnWidth(col.getId(), col.getPreferredWidth());
    }

    table.setPageLength(0);
    table.setWidth("100%"); //
    table.setHeight("100%");
    m_table.set(table);
    table.setSelectable(true);
    replaceComponent(m_tablePlaceholder, table);
    setExpandRatio(table, 1.0f);

    addAttachListener(new AttachListener() {

        private static final long serialVersionUID = 1L;

        public void attach(AttachEvent event) {

            refreshData(true, null);
        }
    });
    table.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {

            if (table.isMultiSelect()) {
                if (m_recursiveValueChange) {
                    updateCheckboxesWithSelectedIds(m_realSelection);
                } else {
                    updateRealSelection(getIdsFromSelection(event));
                    if (m_realSelection.equals(event.getProperty().getValue())) {
                        updateCheckboxesWithSelectedIds(m_realSelection);
                    } else {
                        try {
                            m_recursiveValueChange = true;
                            m_table.get().setValue(m_realSelection);
                        } finally {
                            m_recursiveValueChange = false;
                        }
                    }
                }

            } else {
                Set<Object> ids = getIdsFromSelection(event);
                updateCheckboxesWithSelectedIds(ids);

            }

        }

        /**
         * Gets the ids from the selection event.<p>
         *
         * @param event a selection event
         *
         * @return the set of ids from the selection event
         */
        protected Set<Object> getIdsFromSelection(ValueChangeEvent event) {

            Set<Object> ids = Sets.newHashSet();
            if (event != null) {
                if (event.getProperty().getValue() instanceof Collection) {
                    ids.addAll((Collection<?>) event.getProperty().getValue());
                } else {
                    ids.add(event.getProperty().getValue());
                }
            }
            return ids;
        }

        @SuppressWarnings("synthetic-access")
        protected void updateCheckboxesWithSelectedIds(Set<Object> selectedIds) {

            for (Map.Entry<Object, CheckBox> entry : m_checkBoxes.entrySet()) {
                if (!(selectedIds.contains(entry.getKey()))) {
                    entry.getValue().setValue(Boolean.FALSE);
                }
            }

            for (Object id : selectedIds) {
                getCheckBox(id).setValue(Boolean.TRUE);
            }
        }
    });
    List<CmsDataViewFilter> filters = new ArrayList<CmsDataViewFilter>(m_dataView.getFilters());
    updateFilters(filters);
}

From source file:org.opencms.ui.util.CmsLogicalCheckboxGroup.java

License:Open Source License

/**
 * Adds a check box to the group.<p>
 *
 * @param checkBox the check box to add/*from  w  w  w.  j  a  v a2s . com*/
 */
public void add(final CheckBox checkBox) {

    checkBox.setValue(Boolean.FALSE);
    m_checkboxes.add(checkBox);
    ValueChangeListener listener = new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void valueChange(ValueChangeEvent event) {

            if (m_runningEvent) {
                return;
            } else {
                try {
                    m_runningEvent = true;
                    if (((Boolean) event.getProperty().getValue()).booleanValue()) {
                        if ((m_selected != null) && (m_selected != checkBox)) {
                            m_selected.setValue(Boolean.FALSE);
                        }
                        setActiveCheckBox(checkBox);
                    } else {
                        setActiveCheckBox(null);
                        m_selected = null;
                    }

                    // TODO Auto-generated method stub
                } finally {
                    m_runningEvent = false;

                }
            }

        }
    };
    checkBox.addValueChangeListener(listener);
    m_listeners.put(checkBox, listener);
}

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

License:Open Source License

/**
 * Creates a new instance.<p>/*from  www  . j a v a2  s .  c  o  m*/
 *
 * @param checkinBean the bean to be used for the check-in operation.
 */
public CmsGitToolOptionsPanel(CmsGitCheckin checkinBean) {
    m_checkinBean = checkinBean;
    if (!checkinBean.hasValidConfiguration()) {
        setMargin(true);
        Label errorLabel = new Label(CmsVaadinUtils.getMessageText(Messages.GUI_GIT_APP_UNCONFIGURED_0));
        errorLabel.setContentMode(ContentMode.HTML);
        addComponent(errorLabel);
        return;
    }
    CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
    configureConfigurationSelector();
    updateForNewConfiguration(m_checkinBean.getCurrentConfiguration());

    m_user = A_CmsUI.getCmsObject().getRequestContext().getCurrentUser();
    restoreFieldsFromUserInfo();

    setAdvancedVisible(false);
    m_toggleOptions.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            setAdvancedVisible(!m_advancedVisible);
        }
    });
    m_okButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void buttonClick(ClickEvent event) {

            if (m_dialogTab == DialogTab.checkIn) {
                runAction(ActionType.checkIn);
            } else {
                runAction(ActionType.checkOut);
            }
        }
    });
    m_cancel.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            A_CmsUI.get().getPage().setLocation(CmsVaadinUtils.getWorkplaceLink());
        }
    });
    m_deselectAll.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            for (Map.Entry<String, CheckBox> entry : m_moduleCheckboxes.entrySet()) {
                CheckBox checkBox = entry.getValue();
                checkBox.setValue(Boolean.FALSE);
            }
        }
    });

    m_tabs.addStyleName(ValoTheme.TABSHEET_FRAMED);
    m_tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    m_tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void selectedTabChange(SelectedTabChangeEvent event) {

            DialogTab tab;
            if (m_tabs.getSelectedTab() == m_checkoutTab) {
                tab = DialogTab.checkOut;
            } else {
                tab = DialogTab.checkIn;
            }
            CmsGitToolOptionsPanel.this.setTab(tab);

        }

    });
    m_fetchAndReset.setValue(Boolean.TRUE);
    setTab(m_dialogTab);
}

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

License:Open Source License

/**
 * Adds a check box and info widget for a module which should be selectable for check-in.<p>
 *
 * @param moduleName the name of the module
 *//*from w ww. j ava2 s . c  om*/
public void addSelectableModule(final String moduleName) {

    boolean enabled = true; /* OpenCms.getModuleManager().hasModule(moduleName); */
    CheckBox moduleCheckBox = new CheckBox();
    String iconUri = CmsWorkplace.getResourceUri("tools/modules/buttons/modules.png");
    CmsResourceInfo info = new CmsResourceInfo(moduleName, "", iconUri);
    HorizontalLayout line = new HorizontalLayout();
    line.setWidth("100%");
    line.addComponent(moduleCheckBox);
    info.setWidth("100%");
    line.addComponent(info);
    line.setComponentAlignment(moduleCheckBox, Alignment.MIDDLE_CENTER);
    line.setExpandRatio(info, 1.0f);
    moduleCheckBox.setEnabled(true);
    moduleCheckBox.setValue(Boolean.valueOf(enabled)); // If enabled, then checked by default
    m_moduleCheckboxes.put(moduleName, moduleCheckBox);
    m_moduleSelectionContainer.addComponent(line, m_moduleSelectionContainer.getComponentCount() - 1);
    setTab(m_dialogTab);
}