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;
}
}
}
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(" ", 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);
}
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;
}
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);
}
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;
}
Aggregations