Search in sources :

Example 6 with CheckBox

use of com.vaadin.ui.CheckBox 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 7 with CheckBox

use of com.vaadin.ui.CheckBox 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 8 with CheckBox

use of com.vaadin.ui.CheckBox in project Activiti by Activiti.

the class FormPopupWindow method getFormPropertyDefinition.

protected FormPropertyDefinition getFormPropertyDefinition(Item item) {
    String type = (String) ((ComboBox) item.getItemProperty(PropertyTable.ID_PROPERTY_TYPE).getValue()).getValue();
    FormPropertyDefinition result = null;
    if (type.equals("number")) {
        result = new NumberPropertyDefinition();
    } else if (type.equals("date")) {
        result = new DatePropertyDefinition();
    } else {
        result = new TextPropertyDefinition();
    }
    // Set generic properties
    result.setName((String) item.getItemProperty(PropertyTable.ID_PROPERTY_NAME).getValue());
    result.setMandatory((Boolean) ((CheckBox) item.getItemProperty(PropertyTable.ID_PROPERTY_REQUIRED).getValue()).getValue());
    return result;
}
Also used : NumberPropertyDefinition(org.activiti.workflow.simple.definition.form.NumberPropertyDefinition) TextPropertyDefinition(org.activiti.workflow.simple.definition.form.TextPropertyDefinition) CheckBox(com.vaadin.ui.CheckBox) FormPropertyDefinition(org.activiti.workflow.simple.definition.form.FormPropertyDefinition) DatePropertyDefinition(org.activiti.workflow.simple.definition.form.DatePropertyDefinition)

Example 9 with CheckBox

use of com.vaadin.ui.CheckBox in project Activiti by Activiti.

the class PropertyTable method addPropertyRow.

protected void addPropertyRow(Object itemId, String propertyName, String propertyType, Boolean required) {
    Object newItemId = null;
    if (itemId == null) {
        // add at the end of list
        newItemId = addItem();
    } else {
        newItemId = addItemAfter(itemId);
    }
    Item newItem = getItem(newItemId);
    // name
    newItem.getItemProperty(ID_PROPERTY_NAME).setValue(propertyName == null ? DEFAULT_PROPERTY_NAME : propertyName);
    // type
    ComboBox typeComboBox = new ComboBox("", Arrays.asList("text", "number", "date"));
    typeComboBox.setNullSelectionAllowed(false);
    if (propertyType == null) {
        typeComboBox.setValue(typeComboBox.getItemIds().iterator().next());
    } else {
        typeComboBox.setValue(propertyType);
    }
    newItem.getItemProperty(ID_PROPERTY_TYPE).setValue(typeComboBox);
    // required
    CheckBox requiredCheckBox = new CheckBox();
    requiredCheckBox.setValue(required == null ? false : required);
    newItem.getItemProperty(ID_PROPERTY_REQUIRED).setValue(requiredCheckBox);
    // actions
    HorizontalLayout actionButtons = new HorizontalLayout();
    Button deleteRowButton = new Button("-");
    deleteRowButton.setData(newItemId);
    deleteRowButton.addListener(new DeletePropertyClickListener(this));
    actionButtons.addComponent(deleteRowButton);
    Button addRowButton = new Button("+");
    addRowButton.setData(newItemId);
    addRowButton.addListener(new AddPropertyClickListener(this));
    actionButtons.addComponent(addRowButton);
    newItem.getItemProperty(ID_PROPERTY_ACTIONS).setValue(actionButtons);
}
Also used : Item(com.vaadin.data.Item) DeletePropertyClickListener(org.activiti.explorer.ui.process.simple.editor.listener.DeletePropertyClickListener) Button(com.vaadin.ui.Button) ComboBox(com.vaadin.ui.ComboBox) CheckBox(com.vaadin.ui.CheckBox) AddPropertyClickListener(org.activiti.explorer.ui.process.simple.editor.listener.AddPropertyClickListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 10 with CheckBox

use of com.vaadin.ui.CheckBox in project Activiti by Activiti.

the class TaskTable method addTaskRow.

protected Object addTaskRow(Object previousTaskItemId, String taskName, String taskAssignee, String taskGroups, String taskDescription, Boolean startWithPrevious) {
    Object newItemId = null;
    if (previousTaskItemId == null) {
        // add at the end of list
        newItemId = addItem();
    } else {
        newItemId = addItemAfter(previousTaskItemId);
    }
    Item newItem = getItem(newItemId);
    // name
    newItem.getItemProperty(ID_NAME).setValue(taskName == null ? "my task" : taskName);
    // assignee
    ComboBox assigneeComboBox = new ComboBox();
    assigneeComboBox.setNullSelectionAllowed(true);
    try {
        for (User user : ProcessEngines.getDefaultProcessEngine().getIdentityService().createUserQuery().orderByUserFirstName().asc().list()) {
            assigneeComboBox.addItem(user.getId());
            assigneeComboBox.setItemCaption(user.getId(), user.getFirstName() + " " + user.getLastName());
        }
    } catch (Exception e) {
    // Don't do anything. Will be an empty dropdown.
    }
    if (taskAssignee != null) {
        assigneeComboBox.select(taskAssignee);
    }
    newItem.getItemProperty(ID_ASSIGNEE).setValue(assigneeComboBox);
    // groups
    ComboBox groupComboBox = new ComboBox();
    groupComboBox.setNullSelectionAllowed(true);
    try {
        for (Group group : ProcessEngines.getDefaultProcessEngine().getIdentityService().createGroupQuery().orderByGroupName().asc().list()) {
            groupComboBox.addItem(group.getId());
            groupComboBox.setItemCaption(group.getId(), group.getName());
        }
    } catch (Exception e) {
    // Don't do anything. Will be an empty dropdown.
    }
    if (taskGroups != null) {
        groupComboBox.select(taskGroups);
    }
    newItem.getItemProperty(ID_GROUPS).setValue(groupComboBox);
    // description
    TextField descriptionTextField = new TextField();
    descriptionTextField.setColumns(16);
    descriptionTextField.setRows(1);
    if (taskDescription != null) {
        descriptionTextField.setValue(taskDescription);
    }
    newItem.getItemProperty(ID_DESCRIPTION).setValue(descriptionTextField);
    // concurrency
    CheckBox startWithPreviousCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_START_WITH_PREVIOUS));
    startWithPreviousCheckBox.setValue(startWithPrevious == null ? false : startWithPrevious);
    newItem.getItemProperty(ID_START_WITH_PREVIOUS).setValue(startWithPreviousCheckBox);
    // actions
    newItem.getItemProperty(ID_ACTIONS).setValue(generateActionButtons(newItemId));
    return newItemId;
}
Also used : Item(com.vaadin.data.Item) Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User) ComboBox(com.vaadin.ui.ComboBox) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField)

Aggregations

CheckBox (com.vaadin.ui.CheckBox)14 Item (com.vaadin.data.Item)3 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)3 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)3 TextField (com.vaadin.ui.TextField)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)2 ClickListener (com.vaadin.ui.Button.ClickListener)2 ComboBox (com.vaadin.ui.ComboBox)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Label (com.vaadin.ui.Label)2 Property (com.vaadin.data.Property)1 FieldEvents (com.vaadin.event.FieldEvents)1 Button (com.vaadin.ui.Button)1 DateField (com.vaadin.ui.DateField)1 Form (com.vaadin.ui.Form)1 PasswordField (com.vaadin.ui.PasswordField)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1