Search in sources :

Example 1 with DateField

use of com.storedobject.vaadin.DateField in project SODevelopment by syampillai.

the class ProcessCheckList method createField.

private void createField(AbstractCheckList node, int level) {
    StringBuilder sb = new StringBuilder();
    sb.append(String.valueOf((char) 187).repeat(Math.max(0, level)));
    if (sb.length() > 0) {
        sb.append(' ');
    }
    ELabel label = new ELabel(sb + node.getName());
    DateField df = new DateField();
    df.setValue(node.getCompleted() ? node.getCompletedOn() : DateUtility.today());
    Checkbox cb = new Checkbox();
    cb.setValue(node.getCompleted());
    items.add(new Object[] { node, df, cb });
    add(label);
    addField(df);
    addField(cb);
    node.listItems().forEach(n -> {
        df.setReadOnly(true);
        cb.setReadOnly(true);
        createField(n, level + 1);
    });
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) DateField(com.storedobject.vaadin.DateField)

Example 2 with DateField

use of com.storedobject.vaadin.DateField in project SODevelopment by syampillai.

the class DatePeriodField method df.

private static DateField df() {
    DateField df = new DateField();
    df.getField().setWidth("110px");
    return df;
}
Also used : DateField(com.storedobject.vaadin.DateField)

Example 3 with DateField

use of com.storedobject.vaadin.DateField in project SODevelopment by syampillai.

the class ProcessCheckList method process.

@Override
protected boolean process() {
    ArrayList<AbstractCheckList> modified = new ArrayList<>();
    AbstractCheckList node;
    Date date;
    boolean completed;
    for (Object[] row : items) {
        if (((DateField) row[1]).isReadOnly()) {
            continue;
        }
        node = (AbstractCheckList) row[0];
        completed = ((Checkbox) row[2]).getValue();
        date = ((DateField) row[1]).getValue();
        if (node.getCompleted() == completed && date.compareTo(node.getCompletedOn()) == 0) {
            continue;
        }
        node.setCompletedOn(date);
        node.setCompleted(completed);
        modified.add(node);
    }
    if (modified.isEmpty()) {
        message("No changes done");
        return true;
    }
    completed = transact(t -> {
        for (AbstractCheckList m : modified) {
            m.save(t);
        }
    });
    if (!completed) {
        return true;
    }
    // noinspection SuspiciousMethodCalls
    items.removeIf(r -> modified.contains(r[0]));
    modified.clear();
    items.removeIf(r -> {
        AbstractCheckList item = (AbstractCheckList) r[0];
        if (item.getCompleted() == item.checkCompleteness()) {
            return true;
        }
        modified.add(item);
        return false;
    });
    transact(t -> {
        for (AbstractCheckList m : modified) {
            m.save(t);
        }
    });
    return true;
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) DateUtility(com.storedobject.core.DateUtility) com.storedobject.ui(com.storedobject.ui) DateField(com.storedobject.vaadin.DateField) GridLayout(com.storedobject.vaadin.GridLayout) AbstractCheckList(com.storedobject.core.AbstractCheckList) HasComponents(com.vaadin.flow.component.HasComponents) DataForm(com.storedobject.vaadin.DataForm) Date(java.sql.Date) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) DateField(com.storedobject.vaadin.DateField) AbstractCheckList(com.storedobject.core.AbstractCheckList) Date(java.sql.Date)

Aggregations

DateField (com.storedobject.vaadin.DateField)3 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)2 AbstractCheckList (com.storedobject.core.AbstractCheckList)1 DateUtility (com.storedobject.core.DateUtility)1 com.storedobject.ui (com.storedobject.ui)1 DataForm (com.storedobject.vaadin.DataForm)1 GridLayout (com.storedobject.vaadin.GridLayout)1 HasComponents (com.vaadin.flow.component.HasComponents)1 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1