Search in sources :

Example 1 with EntityListTableModel

use of com.codename1.rad.ui.table.EntityListTableModel in project CodeRAD by shannah.

the class TablePropertyView method update.

@Override
public void update() {
    super.update();
    EntityListTableModel model = (EntityListTableModel) getComponent().getModel();
    EntityList list = model.getEntityList();
    EntityList ePropertyVal = getPropertyAsEntityList();
    if (ePropertyVal == list) {
        return;
    }
    TableColumns columns = (TableColumns) getField().findAttribute(TableColumns.class);
    if (columns == null) {
        throw new IllegalStateException("Cannot create TablePropertyView for field " + getField() + " because the field does not define any columns.  Add a ColumnsNode attribute to the field.");
    }
    EntityListTableModel newModel = new EntityListTableModel(list.getRowType(), ePropertyVal, columns);
    getComponent().setModel(newModel);
}
Also used : TableColumns(com.codename1.rad.nodes.TableColumns) EntityList(com.codename1.rad.models.EntityList) EntityListTableModel(com.codename1.rad.ui.table.EntityListTableModel)

Example 2 with EntityListTableModel

use of com.codename1.rad.ui.table.EntityListTableModel in project CodeRAD by shannah.

the class EntityListTableCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(Table table, Object value, boolean isSelected, int row, int column) {
    EntityListTableModel model = (EntityListTableModel) table.getModel();
    FieldNode field = model.getColumnField(column);
    Entity entity = model.getEntity(row);
    if (entity == null) {
        if (parent != null) {
            return parent.getTableCellEditorComponent(table, value, isSelected, row, column);
        } else {
            return new com.codename1.ui.Label();
        }
    }
    return viewFactory.createPropertyView(entity, field);
}
Also used : Entity(com.codename1.rad.models.Entity) FieldNode(com.codename1.rad.nodes.FieldNode)

Example 3 with EntityListTableModel

use of com.codename1.rad.ui.table.EntityListTableModel in project CodeRAD by shannah.

the class TablePropertyView method commit.

@Override
public void commit() {
    EntityListTableModel model = (EntityListTableModel) getComponent().getModel();
    EntityList list = model.getEntityList();
    EntityList ePropertyVal = getPropertyAsEntityList();
    if (ePropertyVal == list) {
        return;
    }
    getEntity().getEntity().set(getProperty(), list);
}
Also used : EntityList(com.codename1.rad.models.EntityList) EntityListTableModel(com.codename1.rad.ui.table.EntityListTableModel)

Example 4 with EntityListTableModel

use of com.codename1.rad.ui.table.EntityListTableModel in project CodeRAD by shannah.

the class EntityListTableCellRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(Table table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    EntityListTableModel model = (EntityListTableModel) table.getModel();
    FieldNode field = model.getColumnField(column);
    FieldNode fieldCopy = field.copy();
    fieldCopy.setAttributes(new Editable(false));
    Entity entity = model.getEntity(row);
    if (entity == null) {
        if (parent != null) {
            return parent.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        } else {
            return new com.codename1.ui.Label();
        }
    }
    return viewFactory.createPropertyView(entity, fieldCopy);
}
Also used : Entity(com.codename1.rad.models.Entity) FieldNode(com.codename1.rad.nodes.FieldNode) Editable(com.codename1.rad.models.Property.Editable)

Aggregations

Entity (com.codename1.rad.models.Entity)2 EntityList (com.codename1.rad.models.EntityList)2 FieldNode (com.codename1.rad.nodes.FieldNode)2 EntityListTableModel (com.codename1.rad.ui.table.EntityListTableModel)2 Editable (com.codename1.rad.models.Property.Editable)1 TableColumns (com.codename1.rad.nodes.TableColumns)1