Search in sources :

Example 1 with AddPropertyClickListener

use of org.activiti.explorer.ui.process.simple.editor.listener.AddPropertyClickListener 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)

Aggregations

Item (com.vaadin.data.Item)1 Button (com.vaadin.ui.Button)1 CheckBox (com.vaadin.ui.CheckBox)1 ComboBox (com.vaadin.ui.ComboBox)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 AddPropertyClickListener (org.activiti.explorer.ui.process.simple.editor.listener.AddPropertyClickListener)1 DeletePropertyClickListener (org.activiti.explorer.ui.process.simple.editor.listener.DeletePropertyClickListener)1