Search in sources :

Example 1 with TextArea

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

the class ObjectBlockEditor method clicked.

@Override
public void clicked(Component c) {
    if (c == cancel) {
        close();
        return;
    }
    if (c == save) {
        ArrayListSet<StoredObject> changed = new ArrayListSet<>();
        if (!canSave() || !saveBlockTextInt(changed)) {
            return;
        }
        if (changed.isEmpty()) {
            message("No changed made!");
            return;
        }
        if (transact(t -> {
            for (StoredObject storedObject : changed) {
                storedObject.save(t);
            }
        })) {
            close();
        }
        return;
    }
    if (c == expand) {
        expand.setVisible(false);
        collapse.setVisible(true);
        for (TextArea ta : blocks) {
            if (!ta.isEnabled()) {
                ta.setVisible(true);
            }
        }
        return;
    }
    if (c == collapse) {
        expand.setVisible(true);
        collapse.setVisible(false);
        for (TextArea ta : blocks) {
            if (!ta.isEnabled()) {
                ta.setVisible(false);
            }
        }
    }
}
Also used : StoredObject(com.storedobject.core.StoredObject) TextArea(com.storedobject.vaadin.TextArea) ArrayListSet(com.storedobject.common.ArrayListSet)

Example 2 with TextArea

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

the class ObjectBlockEditor method saveBlockTextInt.

private boolean saveBlockTextInt(List<StoredObject> changed) {
    int m = 0;
    String v;
    for (TextArea block : blocks) {
        if (block.isEnabled()) {
            try {
                v = block.getValue().trim();
                if (changed != null) {
                    if (!v.equals(originalValues.get(m))) {
                        changed.add(methodOwners.get(m));
                    }
                }
                methods.get(m).invoke(methodOwners.get(m), v);
                m++;
            } catch (Exception e) {
                error(e);
                return false;
            }
        }
    }
    return true;
}
Also used : TextArea(com.storedobject.vaadin.TextArea)

Example 3 with TextArea

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

the class ObjectBlockEditor method createBlock.

private void createBlock(String b, boolean editable, String placeholder) {
    TextArea ta = new TextArea();
    ta.setSpellCheck(false);
    if (!StringUtility.isWhite(b)) {
        ta.setValue(b);
    }
    if (!editable) {
        ta.setEnabled(false);
    }
    ta.setWidthFull();
    if (placeholder != null) {
        ta.setPlaceholder(StringUtility.makeLabel(placeholder));
    }
    layout.add(ta);
    blocks.add(ta);
}
Also used : TextArea(com.storedobject.vaadin.TextArea)

Aggregations

TextArea (com.storedobject.vaadin.TextArea)3 ArrayListSet (com.storedobject.common.ArrayListSet)1 StoredObject (com.storedobject.core.StoredObject)1