Search in sources :

Example 1 with Privilege

use of us.mn.state.dot.sonar.Privilege in project iris by mnit-rtmc.

the class PrivilegeModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<Privilege>> createColumns() {
    ArrayList<ProxyColumn<Privilege>> cols = new ArrayList<ProxyColumn<Privilege>>(5);
    cols.add(new ProxyColumn<Privilege>("privilege.type", 140) {

        public Object getValueAt(Privilege p) {
            return p.getTypeN();
        }

        public boolean isEditable(Privilege p) {
            return canWrite(p);
        }

        public void setValueAt(Privilege p, Object value) {
            p.setTypeN(value.toString().trim());
        }

        protected TableCellEditor createCellEditor() {
            return new DefaultCellEditor(new JComboBox<String>(ALL_TYPES));
        }
    });
    cols.add(new ProxyColumn<Privilege>("privilege.obj", 140) {

        public Object getValueAt(Privilege p) {
            return p.getObjN();
        }

        public boolean isEditable(Privilege p) {
            return canWrite(p);
        }

        public void setValueAt(Privilege p, Object value) {
            String v = value.toString().trim();
            p.setObjN(v);
        }
    });
    cols.add(new ProxyColumn<Privilege>("privilege.group", 140) {

        public Object getValueAt(Privilege p) {
            return p.getGroupN();
        }

        public boolean isEditable(Privilege p) {
            return canWrite(p);
        }

        public void setValueAt(Privilege p, Object value) {
            String v = value.toString().trim();
            p.setGroupN(v);
        }
    });
    cols.add(new ProxyColumn<Privilege>("privilege.attr", 120) {

        public Object getValueAt(Privilege p) {
            return p.getAttrN();
        }

        public boolean isEditable(Privilege p) {
            return canWrite(p);
        }

        public void setValueAt(Privilege p, Object value) {
            String v = value.toString().trim();
            p.setAttrN(v);
        }
    });
    cols.add(new ProxyColumn<Privilege>("privilege.write", 60, Boolean.class) {

        public Object getValueAt(Privilege p) {
            return p.getWrite();
        }

        public boolean isEditable(Privilege p) {
            return canWrite(p);
        }

        public void setValueAt(Privilege p, Object value) {
            if (value instanceof Boolean)
                p.setWrite((Boolean) value);
        }
    });
    return cols;
}
Also used : JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableCellEditor(javax.swing.table.TableCellEditor) Privilege(us.mn.state.dot.sonar.Privilege) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

ArrayList (java.util.ArrayList)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1 JComboBox (javax.swing.JComboBox)1 TableCellEditor (javax.swing.table.TableCellEditor)1 Privilege (us.mn.state.dot.sonar.Privilege)1 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)1