use of us.mn.state.dot.tms.DayMatcher 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 us.mn.state.dot.tms.DayMatcher in project iris by mnit-rtmc.
the class DayMatcherModel method removeDayMatcher.
/**
* Remove a day matcher from an array
*/
private DayMatcher[] removeDayMatcher(DayMatcher[] matchers, DayMatcher matcher) {
TreeSet<DayMatcher> dm_set = new TreeSet<DayMatcher>(comparator());
for (DayMatcher dm : matchers) dm_set.add(dm);
dm_set.remove(matcher);
return dm_set.toArray(new DayMatcher[0]);
}
use of us.mn.state.dot.tms.DayMatcher in project iris by mnit-rtmc.
the class DayMatcherModel method addDayMatcher.
/**
* Add a day matcher to an array
*/
private DayMatcher[] addDayMatcher(DayMatcher[] matchers, DayMatcher matcher) {
TreeSet<DayMatcher> dm_set = new TreeSet<DayMatcher>(comparator());
for (DayMatcher dm : matchers) dm_set.add(dm);
dm_set.add(matcher);
return dm_set.toArray(new DayMatcher[0]);
}
use of us.mn.state.dot.tms.DayMatcher in project iris by mnit-rtmc.
the class DayPlanImpl method doSetDayMatchers.
/**
* Set the day matchers assigned to the day plan
*/
public void doSetDayMatchers(DayMatcher[] dms) throws TMSException {
TreeSet<Storable> dm_set = new TreeSet<Storable>();
for (DayMatcher dm : dms) {
if (dm instanceof DayMatcherImpl)
dm_set.add((DayMatcherImpl) dm);
else {
throw new ChangeVetoException("Invalid day matcher");
}
}
mapping.update(this, dm_set);
setDayMatchers(dms);
}
Aggregations