*/
public class EventMasterDetailView extends TimeFinderMasterDetailView<Event> {
@Override
public CollectionMasterDetailForm<Event> createForm(Dao<Event> dao, String[] columns) {
final DataPool pool = ((PoolDescriptor) getDescriptor()).getDataPool();
return new CollectionMasterDetailForm<Event>(dao, columns) {
@Override
protected void printAction(Iterator<Event> iter) {
final List<Event> events = new ArrayList<Event>();
while (iter.hasNext()) {
events.add(iter.next());
}
Iterator<? extends Resource> resIter = Arrays.asList(new Resource() {
@Override
public Collection<Event> getEvents() {
return events;
}
@Override
public void addEvent(Event ev, boolean reverseAdd) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean removeEvent(Event ev, boolean reverseRemove) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getName() {
return "Master Plan";
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
}).iterator();
HtmlPlannerComponent.printResources(resIter, settings);
}
private EventForm objForm;
@Override
protected AbstractDetailForm createDetailForm(HierarchicalFormModel parentFormModel,
ValueModel valueHolder, ObservableList masterList) {
objForm = new EventForm(parentFormModel,
"eventsDetails", valueHolder, masterList) {
@Override
protected void addTabs() {
SwingBindingFactory factory = (SwingBindingFactory) getBindingFactory();
getFormBuilder().add(factory.createBoundComboBox(
"location", pool.getDao(Location.class).getAll(), "name"));
TableFormBuilder builder = createTab(getMessage("persons.label"));
final Dao<Person> personDao = pool.getDao(Person.class);
/****************************************************************
* WARNING: it is important to wrap the (person) collection in
* another one (here ArrayList). Otherwise the changes
* to the dao will have direct effect to the value in ValueHolder
* and newValue.equals(oldValue) == true for every change!
****************************************************************/
final ValueHolder personHolder = new ValueHolder(new ArrayList<Person>(personDao.getAll()));
//1. persons => Event.set and getPersons are necessary
//2. personDao.getAll() => all available persons
//3. name => prints the name as one list item
ShuttleList sl = (ShuttleList) builder.add(
factory.createBoundShuttleList("persons",
personHolder, "name"))[1];
sl.setVisibleRowCount(10);
TableFormBuilder fBuilder = createTab(getMessage("features.label"));
final Dao<Feature> featureDao = pool.getDao(Feature.class);
final ValueHolder featureHolder = new ValueHolder(new ArrayList<Feature>(featureDao.getAll()));
sl = (ShuttleList) fBuilder.add(factory.createBoundShuttleList("features",
featureHolder, null))[1];
sl.setVisibleRowCount(10);