Search in sources :

Example 1 with ValueChangeListener

use of com.vaadin.data.Property.ValueChangeListener in project opennms by OpenNMS.

the class CheckboxGenerator method generateCell.

@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 {
        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;
        }
    }
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) CheckBox(com.vaadin.ui.CheckBox)

Example 2 with ValueChangeListener

use of com.vaadin.data.Property.ValueChangeListener in project Activiti by Activiti.

the class ChangeProcessSuspensionStatePopupWindow method addTimeSection.

protected void addTimeSection(boolean suspend) {
    Label timeLabel = new Label(suspend ? i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DESCRIPTION) : i18nManager.getMessage(Messages.PROCESS_ACTIVATE_POPUP_TIME_DESCRIPTION));
    verticalLayout.addComponent(timeLabel);
    verticalLayout.addComponent(new Label("&nbsp", Label.CONTENT_XHTML));
    nowCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_NOW), true);
    nowCheckBox.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE);
    nowCheckBox.setImmediate(true);
    nowCheckBox.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            if (nowCheckBox.booleanValue() == true) {
                dateField.setValue(null);
                dateCheckBox.setValue(false);
            } else {
                dateCheckBox.setValue(true);
                dateField.setValue(new Date());
            }
        }
    });
    verticalLayout.addComponent(nowCheckBox);
    HorizontalLayout dateLayout = new HorizontalLayout();
    verticalLayout.addComponent(dateLayout);
    dateCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DATE));
    dateCheckBox.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE);
    dateCheckBox.setImmediate(true);
    dateCheckBox.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            if (dateCheckBox.booleanValue() == true) {
                dateField.setValue(new Date());
                nowCheckBox.setValue(false);
            } else {
                dateField.setValue(null);
                nowCheckBox.setValue(true);
            }
        }
    });
    dateLayout.addComponent(dateCheckBox);
    dateField = new DateField();
    dateField.setImmediate(true);
    dateField.addListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            if (dateField.getValue() != null) {
                nowCheckBox.setValue(false);
                dateCheckBox.setValue(true);
            }
        }
    });
    dateLayout.addComponent(dateField);
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) CheckBox(com.vaadin.ui.CheckBox) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) DateField(com.vaadin.ui.DateField) ClickListener(com.vaadin.ui.Button.ClickListener) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with ValueChangeListener

use of com.vaadin.data.Property.ValueChangeListener in project Activiti by Activiti.

the class SimpleTableEditor method initButtons.

protected void initButtons(GridLayout layout) {
    final Button saveButton = new Button(ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_SAVE));
    saveButton.setEnabled(nameField.getValue() != null && !"".equals((String) nameField.getValue()));
    toolBar.addButton(saveButton);
    saveButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            save();
        }
    });
    // Dependending on namefield value, save button is enabled
    nameField.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            if (nameField.getValue() != null && !"".equals((String) nameField.getValue())) {
                saveButton.setEnabled(true);
            } else {
                saveButton.setEnabled(false);
            }
        }
    });
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 4 with ValueChangeListener

use of com.vaadin.data.Property.ValueChangeListener in project Activiti by Activiti.

the class AccountSelectionPopup method initImapComponent.

protected void initImapComponent() {
    imapForm = new Form();
    imapForm.setDescription(i18nManager.getMessage(Messages.IMAP_DESCRIPTION));
    final TextField imapServer = new TextField(i18nManager.getMessage(Messages.IMAP_SERVER));
    imapForm.getLayout().addComponent(imapServer);
    final TextField imapPort = new TextField(i18nManager.getMessage(Messages.IMAP_PORT));
    imapPort.setWidth(30, UNITS_PIXELS);
    // Default imap port (non-ssl)
    imapPort.setValue(143);
    imapForm.getLayout().addComponent(imapPort);
    final CheckBox useSSL = new CheckBox(i18nManager.getMessage(Messages.IMAP_SSL));
    useSSL.setValue(false);
    useSSL.setImmediate(true);
    imapForm.getLayout().addComponent(useSSL);
    useSSL.addListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            imapPort.setValue(((Boolean) useSSL.getValue()) ? 993 : 143);
        }
    });
    final TextField imapUserName = new TextField(i18nManager.getMessage(Messages.IMAP_USERNAME));
    imapForm.getLayout().addComponent(imapUserName);
    final PasswordField imapPassword = new PasswordField(i18nManager.getMessage(Messages.IMAP_PASSWORD));
    imapForm.getLayout().addComponent(imapPassword);
    // Matching listener
    imapClickListener = new ClickListener() {

        public void buttonClick(ClickEvent event) {
            Map<String, Object> accountDetails = createAccountDetails("imap", imapUserName.getValue().toString(), imapPassword.getValue().toString(), "server", imapServer.getValue().toString(), "port", imapPort.getValue().toString(), "ssl", imapPort.getValue().toString());
            fireEvent(new SubmitEvent(AccountSelectionPopup.this, SubmitEvent.SUBMITTED, accountDetails));
        }
    };
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Form(com.vaadin.ui.Form) CheckBox(com.vaadin.ui.CheckBox) ClickEvent(com.vaadin.ui.Button.ClickEvent) TextField(com.vaadin.ui.TextField) PasswordField(com.vaadin.ui.PasswordField) HashMap(java.util.HashMap) Map(java.util.Map) ClickListener(com.vaadin.ui.Button.ClickListener) SubmitEvent(org.activiti.explorer.ui.event.SubmitEvent)

Example 5 with ValueChangeListener

use of com.vaadin.data.Property.ValueChangeListener in project Activiti by Activiti.

the class TabbedSelectionWindow method initSelectionTable.

protected void initSelectionTable() {
    selectionTable = new Table();
    selectionTable.setSizeUndefined();
    selectionTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
    selectionTable.setSelectable(true);
    selectionTable.setImmediate(true);
    selectionTable.setNullSelectionAllowed(false);
    selectionTable.setWidth(150, UNITS_PIXELS);
    selectionTable.setHeight(100, UNITS_PERCENTAGE);
    selectionTable.setCellStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        public String getStyle(Object itemId, Object propertyId) {
            if ("name".equals(propertyId)) {
                return ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST_LAST_COLUMN;
            }
            return null;
        }
    });
    selectionTable.addStyleName(ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST);
    selectionTable.addContainerProperty("type", Embedded.class, null);
    selectionTable.setColumnWidth("type", 22);
    selectionTable.addContainerProperty("name", String.class, null);
    // Listener to switch to the selected component
    selectionTable.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            String name = (String) event.getProperty().getValue();
            if (name != null) {
                currentSelection = name;
                currentComponent = components.get(name);
                selectedComponentLayout.removeComponent(selectedComponentLayout.getComponent(0, 0));
                if (currentComponent != null) {
                    currentComponent.setSizeFull();
                    selectedComponentLayout.addComponent(currentComponent, 0, 0);
                    okButton.setEnabled(true);
                } else {
                    okButton.setEnabled(false);
                }
            }
        }
    });
    windowLayout.addComponent(selectionTable);
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) CellStyleGenerator(com.vaadin.ui.Table.CellStyleGenerator)

Aggregations

ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)10 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)10 ClickEvent (com.vaadin.ui.Button.ClickEvent)4 ClickListener (com.vaadin.ui.Button.ClickListener)4 Button (com.vaadin.ui.Button)3 CheckBox (com.vaadin.ui.CheckBox)3 Item (com.vaadin.data.Item)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 Table (com.vaadin.ui.Table)2 CellStyleGenerator (com.vaadin.ui.Table.CellStyleGenerator)2 Resource (com.vaadin.terminal.Resource)1 DateField (com.vaadin.ui.DateField)1 Embedded (com.vaadin.ui.Embedded)1 Form (com.vaadin.ui.Form)1 ListSelect (com.vaadin.ui.ListSelect)1 NativeSelect (com.vaadin.ui.NativeSelect)1 PasswordField (com.vaadin.ui.PasswordField)1 Select (com.vaadin.ui.Select)1 TextField (com.vaadin.ui.TextField)1