Search in sources :

Example 46 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.

the class CommConfigModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<CommConfig>> createColumns() {
    ArrayList<ProxyColumn<CommConfig>> cols = new ArrayList<ProxyColumn<CommConfig>>(9);
    cols.add(new ProxyColumn<CommConfig>("comm.config", 60) {

        public Object getValueAt(CommConfig cc) {
            return cc.getName();
        }
    });
    cols.add(new ProxyColumn<CommConfig>("device.description", 220) {

        public Object getValueAt(CommConfig cc) {
            return cc.getDescription();
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "description");
        }

        public void setValueAt(CommConfig cc, Object value) {
            cc.setDescription(value.toString().trim());
        }
    });
    cols.add(new ProxyColumn<CommConfig>("comm.config.protocol", 140) {

        public Object getValueAt(CommConfig cc) {
            return CommProtocol.fromOrdinal(cc.getProtocol());
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "protocol");
        }

        public void setValueAt(CommConfig cc, Object value) {
            if (value instanceof CommProtocol) {
                CommProtocol cp = (CommProtocol) value;
                cc.setProtocol((short) cp.ordinal());
            }
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<CommProtocol> cbx = new JComboBox<CommProtocol>(CommProtocol.valuesSorted());
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<CommConfig>("comm.config.modem", 56, Boolean.class) {

        public Object getValueAt(CommConfig cc) {
            return cc.getModem();
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "modem");
        }

        public void setValueAt(CommConfig cc, Object value) {
            if (value instanceof Boolean)
                cc.setModem((Boolean) value);
        }
    });
    cols.add(new ProxyColumn<CommConfig>("comm.config.timeout_ms", 60) {

        public Object getValueAt(CommConfig cc) {
            return cc.getTimeoutMs();
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "timeoutMs");
        }

        public void setValueAt(CommConfig cc, Object value) {
            if (value instanceof Integer)
                cc.setTimeoutMs((Integer) value);
        }

        protected TableCellEditor createCellEditor() {
            return new TimeoutCellEditor(MAX_TIMEOUT_MS);
        }
    });
    cols.add(new PeriodColumn("comm.config.poll_period_sec", CommConfig.VALID_PERIODS, 92) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getPollPeriodSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setPollPeriodSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "pollPeriodSec");
        }
    });
    cols.add(new PeriodColumn("comm.config.long_poll_period_sec", CommConfig.VALID_PERIODS, 92) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getLongPollPeriodSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setLongPollPeriodSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "longPollPeriodSec");
        }
    });
    cols.add(new PeriodColumn("comm.config.idle_disconnect_sec", CommConfig.VALID_DISCONNECT, 108) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getIdleDisconnectSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setIdleDisconnectSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "idleDisconnectSec");
        }
    });
    cols.add(new PeriodColumn("comm.config.no_response_disconnect_sec", CommConfig.VALID_DISCONNECT, 108) {

        protected int getPeriodSec(CommConfig cc) {
            return cc.getNoResponseDisconnectSec();
        }

        protected void setPeriodSec(CommConfig cc, int s) {
            cc.setNoResponseDisconnectSec(s);
        }

        public boolean isEditable(CommConfig cc) {
            return canWrite(cc, "noResponseDisconnectSec");
        }
    });
    return cols;
}
Also used : JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) DefaultCellEditor(javax.swing.DefaultCellEditor) CommProtocol(us.mn.state.dot.tms.CommProtocol) TableCellEditor(javax.swing.table.TableCellEditor) CommConfig(us.mn.state.dot.tms.CommConfig) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn)

Example 47 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.

the class LaneUseMultiModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<LaneUseMulti>> createColumns() {
    ArrayList<ProxyColumn<LaneUseMulti>> cols = new ArrayList<ProxyColumn<LaneUseMulti>>(4);
    cols.add(new ProxyColumn<LaneUseMulti>("device.name", 80) {

        public Object getValueAt(LaneUseMulti lum) {
            return lum.getName();
        }
    });
    cols.add(new ProxyColumn<LaneUseMulti>("lane.use.multi.indication", 100) {

        public Object getValueAt(LaneUseMulti lum) {
            return LaneUseIndication.fromOrdinal(lum.getIndication());
        }

        public boolean isEditable(LaneUseMulti lum) {
            return canWrite(lum);
        }

        public void setValueAt(LaneUseMulti lum, Object value) {
            if (value instanceof LaneUseIndication) {
                LaneUseIndication v = (LaneUseIndication) value;
                lum.setIndication(v.ordinal());
            }
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<LaneUseIndication> cbx = new JComboBox<LaneUseIndication>(LaneUseIndication.values());
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<LaneUseMulti>("lane.use.multi.msg", 80, Integer.class) {

        public Object getValueAt(LaneUseMulti lum) {
            return lum.getMsgNum();
        }

        public boolean isEditable(LaneUseMulti lum) {
            return canWrite(lum);
        }

        public void setValueAt(LaneUseMulti lum, Object value) {
            if (value instanceof Integer)
                lum.setMsgNum((Integer) value);
            else
                lum.setMsgNum(null);
        }
    });
    cols.add(new ProxyColumn<LaneUseMulti>("dms.quick.message", 160) {

        public Object getValueAt(LaneUseMulti lum) {
            return lum.getQuickMessage();
        }

        public boolean isEditable(LaneUseMulti lum) {
            return canWrite(lum);
        }

        public void setValueAt(LaneUseMulti lum, Object value) {
            lum.setQuickMessage(QuickMessageHelper.lookup(value.toString()));
        }
    });
    return cols;
}
Also used : JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) LaneUseIndication(us.mn.state.dot.tms.LaneUseIndication) TableCellEditor(javax.swing.table.TableCellEditor) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn) LaneUseMulti(us.mn.state.dot.tms.LaneUseMulti) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 48 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.

the class DayMatcherModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<DayMatcher>> createColumns() {
    ArrayList<ProxyColumn<DayMatcher>> cols = new ArrayList<ProxyColumn<DayMatcher>>(8);
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.assigned", 80, Boolean.class) {

        public Object getValueAt(DayMatcher dm) {
            return isAssigned(dm);
        }

        public boolean isEditable(DayMatcher dm) {
            return canWriteDayPlanDayMatchers();
        }

        public void setValueAt(DayMatcher dm, Object value) {
            if (value instanceof Boolean)
                setAssigned(dm, (Boolean) value);
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.name", 200) {

        public Object getValueAt(DayMatcher dm) {
            return dm.getName();
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.holiday", 80, Boolean.class) {

        public Object getValueAt(DayMatcher dm) {
            return dm.getHoliday();
        }

        public boolean isEditable(DayMatcher dm) {
            return canWrite(dm);
        }

        public void setValueAt(DayMatcher dm, Object value) {
            if (value instanceof Boolean)
                dm.setHoliday((Boolean) value);
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.month", 100) {

        public Object getValueAt(DayMatcher dm) {
            return MONTHS.get(dm.getMonth() + 1);
        }

        public boolean isEditable(DayMatcher dm) {
            return canWrite(dm);
        }

        public void setValueAt(DayMatcher dm, Object value) {
            dm.setMonth(MONTHS.indexOf(value) - 1);
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<String> cbx = new JComboBox<String>(MONTHS.toArray(new String[0]));
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.day", 64) {

        public Object getValueAt(DayMatcher dm) {
            return DAYS.get(dm.getDay());
        }

        public boolean isEditable(DayMatcher dm) {
            return canWrite(dm) && isWeekShiftBlank(dm);
        }

        public void setValueAt(DayMatcher dm, Object value) {
            dm.setDay(DAYS.indexOf(value));
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<String> cbx = new JComboBox<String>(DAYS.toArray(new String[0]));
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.week", 80) {

        public Object getValueAt(DayMatcher dm) {
            return WEEKS.get(dm.getWeek() + 1);
        }

        public boolean isEditable(DayMatcher dm) {
            return canWrite(dm) && isDayBlank(dm);
        }

        public void setValueAt(DayMatcher dm, Object value) {
            dm.setWeek(WEEKS.indexOf(value) - 1);
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<String> cbx = new JComboBox<String>(WEEKS.toArray(new String[0]));
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.weekday", 100) {

        public Object getValueAt(DayMatcher dm) {
            return WEEKDAYS.get(dm.getWeekday());
        }

        public boolean isEditable(DayMatcher dm) {
            return canWrite(dm);
        }

        public void setValueAt(DayMatcher dm, Object value) {
            dm.setWeekday(WEEKDAYS.indexOf(value));
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<String> cbx = new JComboBox<String>(WEEKDAYS.toArray(new String[0]));
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<DayMatcher>("day.matcher.shift", 64) {

        public Object getValueAt(DayMatcher dm) {
            return SHIFTS.get(dm.getShift() + 2);
        }

        public boolean isEditable(DayMatcher dm) {
            return canWrite(dm) && isDayBlank(dm);
        }

        public void setValueAt(DayMatcher dm, Object value) {
            dm.setShift(SHIFTS.indexOf(value) - 2);
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<String> cbx = new JComboBox<String>(SHIFTS.toArray(new String[0]));
            return new DefaultCellEditor(cbx);
        }
    });
    return cols;
}
Also used : DayMatcher(us.mn.state.dot.tms.DayMatcher) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableCellEditor(javax.swing.table.TableCellEditor) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 49 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.

the class DmsActionModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<DmsAction>> createColumns() {
    ArrayList<ProxyColumn<DmsAction>> cols = new ArrayList<ProxyColumn<DmsAction>>(5);
    cols.add(new ProxyColumn<DmsAction>("action.plan.dms.group", 120) {

        public Object getValueAt(DmsAction da) {
            return da.getSignGroup();
        }
    });
    cols.add(new ProxyColumn<DmsAction>("action.plan.phase", 100) {

        public Object getValueAt(DmsAction da) {
            return da.getPhase();
        }

        public boolean isEditable(DmsAction da) {
            return canWrite(da);
        }

        public void setValueAt(DmsAction da, Object value) {
            if (value instanceof PlanPhase)
                da.setPhase((PlanPhase) value);
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<PlanPhase> cbx = new JComboBox<PlanPhase>();
            cbx.setModel(new IComboBoxModel<PlanPhase>(phase_mdl));
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<DmsAction>("quick.message", 160) {

        public Object getValueAt(DmsAction da) {
            return da.getQuickMessage();
        }

        public boolean isEditable(DmsAction da) {
            return canWrite(da);
        }

        public void setValueAt(DmsAction da, Object value) {
            String v = value.toString().trim();
            da.setQuickMessage(QuickMessageHelper.lookup(v));
        }
    });
    cols.add(new ProxyColumn<DmsAction>("dms.beacon.enabled", 100, Boolean.class) {

        public Object getValueAt(DmsAction da) {
            return da.getBeaconEnabled();
        }

        public boolean isEditable(DmsAction da) {
            return canWrite(da);
        }

        public void setValueAt(DmsAction da, Object value) {
            if (value instanceof Boolean)
                da.setBeaconEnabled((Boolean) value);
        }
    });
    cols.add(new ProxyColumn<DmsAction>("dms.msg.priority", 120) {

        public Object getValueAt(DmsAction da) {
            return DmsMsgPriority.fromOrdinal(da.getMsgPriority());
        }

        public boolean isEditable(DmsAction da) {
            return canWrite(da);
        }

        public void setValueAt(DmsAction da, Object value) {
            if (value instanceof DmsMsgPriority) {
                DmsMsgPriority p = (DmsMsgPriority) value;
                da.setMsgPriority(p.ordinal());
            }
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<DmsMsgPriority> cbx = new JComboBox<DmsMsgPriority>(PRIORITIES);
            return new DefaultCellEditor(cbx);
        }
    });
    return cols;
}
Also used : JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) DmsMsgPriority(us.mn.state.dot.tms.DmsMsgPriority) DmsAction(us.mn.state.dot.tms.DmsAction) DefaultCellEditor(javax.swing.DefaultCellEditor) IComboBoxModel(us.mn.state.dot.tms.client.widget.IComboBoxModel) PlanPhase(us.mn.state.dot.tms.PlanPhase) TableCellEditor(javax.swing.table.TableCellEditor) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn)

Example 50 with DefaultCellEditor

use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.

the class PlanPhaseModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<PlanPhase>> createColumns() {
    ArrayList<ProxyColumn<PlanPhase>> cols = new ArrayList<ProxyColumn<PlanPhase>>(3);
    cols.add(new ProxyColumn<PlanPhase>("action.plan.phase.name", 120) {

        public Object getValueAt(PlanPhase p) {
            return p.getName();
        }
    });
    cols.add(new ProxyColumn<PlanPhase>("action.plan.phase.hold", 120, Integer.class) {

        public Object getValueAt(PlanPhase p) {
            return p.getHoldTime();
        }

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

        public void setValueAt(PlanPhase p, Object value) {
            if (value instanceof Integer)
                p.setHoldTime((Integer) value);
        }
    });
    cols.add(new ProxyColumn<PlanPhase>("action.plan.phase.next", 120) {

        public Object getValueAt(PlanPhase p) {
            return p.getNextPhase();
        }

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

        public void setValueAt(PlanPhase p, Object value) {
            if (value instanceof PlanPhase)
                p.setNextPhase((PlanPhase) value);
            else
                p.setNextPhase(null);
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<PlanPhase> cbx = new JComboBox<PlanPhase>();
            cbx.setModel(new IComboBoxModel<PlanPhase>(phase_mdl));
            return new DefaultCellEditor(cbx);
        }
    });
    return cols;
}
Also used : IComboBoxModel(us.mn.state.dot.tms.client.widget.IComboBoxModel) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) PlanPhase(us.mn.state.dot.tms.PlanPhase) TableCellEditor(javax.swing.table.TableCellEditor) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)180 JComboBox (javax.swing.JComboBox)116 TableColumn (javax.swing.table.TableColumn)57 JTable (javax.swing.JTable)56 ArrayList (java.util.ArrayList)44 TableCellEditor (javax.swing.table.TableCellEditor)35 JScrollPane (javax.swing.JScrollPane)33 JPanel (javax.swing.JPanel)25 ActionEvent (java.awt.event.ActionEvent)24 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)23 JTextField (javax.swing.JTextField)22 JLabel (javax.swing.JLabel)20 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)20 Component (java.awt.Component)18 DefaultTableModel (javax.swing.table.DefaultTableModel)17 Dimension (java.awt.Dimension)16 JButton (javax.swing.JButton)16 ActionListener (java.awt.event.ActionListener)15 JCheckBox (javax.swing.JCheckBox)13 TableColumnModel (javax.swing.table.TableColumnModel)13