Search in sources :

Example 1 with ObjAttributeWrapper

use of org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper in project cayenne by apache.

the class ObjAttributeTableModel method getValueAt.

public Object getValueAt(int row, int column) {
    ObjAttributeWrapper attribute = getAttribute(row);
    DbAttribute dbAttribute = attribute.getDbAttribute();
    switch(column) {
        case INHERITED:
            return attribute.isInherited();
        case OBJ_ATTRIBUTE:
            return attribute.getName();
        case OBJ_ATTRIBUTE_TYPE:
            return attribute.getType();
        case LOCKING:
            return attribute.isUsedForLocking() ? Boolean.TRUE : Boolean.FALSE;
        case DB_ATTRIBUTE:
            return getDBAttribute(attribute, dbAttribute);
        case DB_ATTRIBUTE_TYPE:
            return getDBAttributeType(attribute, dbAttribute);
        case COMMENT:
            return getComment(attribute.getValue());
        default:
            return null;
    }
}
Also used : DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttributeWrapper(org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper)

Example 2 with ObjAttributeWrapper

use of org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper in project cayenne by apache.

the class ObjEntityAttributePanel method objAttributeAdded.

public void objAttributeAdded(AttributeEvent e) {
    ObjAttributeTableModel model = (ObjAttributeTableModel) table.getModel();
    if (!model.isValid()) {
        model.resetModel();
    }
    model.addRow(new ObjAttributeWrapper((ObjAttribute) e.getAttribute()));
    model.fireTableDataChanged();
    int ind = -1;
    List<ObjAttributeWrapper> list = model.getObjectList();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getValue() == e.getAttribute()) {
            ind = i;
        }
    }
    table.select(ind);
}
Also used : ObjAttribute(org.apache.cayenne.map.ObjAttribute) ObjAttributeWrapper(org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper)

Example 3 with ObjAttributeWrapper

use of org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper in project cayenne by apache.

the class ObjAttributeTableModel method setUpdatedValueAt.

@Override
public void setUpdatedValueAt(Object value, int row, int column) {
    ObjAttributeWrapper attribute = getAttribute(row);
    attribute.resetEdits();
    AttributeEvent event = new AttributeEvent(eventSource, attribute.getValue(), entity);
    switch(column) {
        case OBJ_ATTRIBUTE:
            event.setOldName(attribute.getName());
            setObjAttribute(attribute, value);
            fireTableCellUpdated(row, column);
            break;
        case OBJ_ATTRIBUTE_TYPE:
            setObjAttributeType(attribute, value);
            fireTableCellUpdated(row, column);
            break;
        case LOCKING:
            setColumnLocking(attribute, value);
            fireTableCellUpdated(row, column);
            break;
        case DB_ATTRIBUTE:
            setDbAttribute(attribute, value);
            fireTableRowsUpdated(row, row);
            break;
        case COMMENT:
            setComment((String) value, attribute.getValue());
        default:
            fireTableRowsUpdated(row, row);
            break;
    }
    mediator.fireObjAttributeEvent(event);
}
Also used : ObjAttributeWrapper(org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent)

Aggregations

ObjAttributeWrapper (org.apache.cayenne.modeler.editor.wrapper.ObjAttributeWrapper)3 DbAttribute (org.apache.cayenne.map.DbAttribute)1 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1 AttributeEvent (org.apache.cayenne.map.event.AttributeEvent)1