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;
}
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;
}
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;
}
use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.
the class TimeActionModel method createColumns.
/**
* Create the columns in the model
*/
@Override
protected ArrayList<ProxyColumn<TimeAction>> createColumns() {
ArrayList<ProxyColumn<TimeAction>> cols = new ArrayList<ProxyColumn<TimeAction>>(4);
cols.add(new ProxyColumn<TimeAction>("action.plan.day", 100) {
public Object getValueAt(TimeAction ta) {
return ta.getDayPlan();
}
});
cols.add(new ProxyColumn<TimeAction>("action.plan.date", 100) {
public Object getValueAt(TimeAction ta) {
return ta.getSchedDate();
}
});
cols.add(new ProxyColumn<TimeAction>("action.plan.time", 80) {
public Object getValueAt(TimeAction ta) {
return ta.getTimeOfDay();
}
});
cols.add(new ProxyColumn<TimeAction>("action.plan.phase", 100) {
public Object getValueAt(TimeAction ta) {
return ta.getPhase();
}
public boolean isEditable(TimeAction ta) {
return canWrite(ta);
}
public void setValueAt(TimeAction ta, Object value) {
if (value instanceof PlanPhase)
ta.setPhase((PlanPhase) value);
}
protected TableCellEditor createCellEditor() {
JComboBox<PlanPhase> cbx = new JComboBox<PlanPhase>();
cbx.setModel(new IComboBoxModel<PlanPhase>(phase_mdl));
return new DefaultCellEditor(cbx);
}
});
return cols;
}
use of javax.swing.DefaultCellEditor in project iris by mnit-rtmc.
the class RoadModel method createColumns.
/**
* Create the columns in the model
*/
@Override
protected ArrayList<ProxyColumn<Road>> createColumns() {
ArrayList<ProxyColumn<Road>> cols = new ArrayList<ProxyColumn<Road>>(4);
cols.add(new ProxyColumn<Road>("location.road", 200) {
public Object getValueAt(Road r) {
return r.getName();
}
});
cols.add(new ProxyColumn<Road>("location.road.abbrev", 80) {
public Object getValueAt(Road r) {
return r.getAbbrev();
}
public boolean isEditable(Road r) {
return canWrite(r);
}
public void setValueAt(Road r, Object value) {
r.setAbbrev(value.toString());
}
});
cols.add(new ProxyColumn<Road>("location.road.class", 120) {
public Object getValueAt(Road r) {
return RoadClass.fromOrdinal(r.getRClass());
}
public boolean isEditable(Road r) {
return canWrite(r);
}
public void setValueAt(Road r, Object value) {
if (value instanceof RoadClass) {
RoadClass c = (RoadClass) value;
r.setRClass((short) c.ordinal());
}
}
protected TableCellEditor createCellEditor() {
JComboBox<RoadClass> cbx = new JComboBox<RoadClass>(RoadClass.values());
return new DefaultCellEditor(cbx);
}
});
cols.add(new ProxyColumn<Road>("location.direction", 120) {
public Object getValueAt(Road r) {
return Direction.fromOrdinal(r.getDirection());
}
public boolean isEditable(Road r) {
return canWrite(r);
}
public void setValueAt(Road r, Object value) {
if (value instanceof Direction) {
Direction d = (Direction) value;
r.setDirection((short) d.ordinal());
}
}
protected TableCellEditor createCellEditor() {
JComboBox<Direction> cbx = new JComboBox<Direction>(Direction.values());
return new DefaultCellEditor(cbx);
}
});
return cols;
}
Aggregations