private static final long serialVersionUID = -237113785224349354L;
public void handleAction(Action action, Object sender, Object target) {
if (ACTION_EDIT.equals(action)) {
int i = (Integer) target;
Request r = myRequestsList.get(i);
me.getApplication().getMainWindow().addWindow(new EditRequestUI(r, page));
System.out.println(r.getProjectID());
}
if (ACTION_DELETE.equals(action)) {
int i = (Integer) target;
Request r = myRequestsList.get(i);
try {
requestDao.deleteRequest(r);
me.getApplication().getMainWindow().showNotification("Deleting", Notification.TYPE_HUMANIZED_MESSAGE);
initMyReqTable();
} catch (DAOException e) {
e.printStackTrace();
System.err.println("Delete Error");
me.getApplication().getMainWindow().showNotification("Can't delete that", Notification.TYPE_WARNING_MESSAGE);
} catch (ResourceNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProjectNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BookingNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Deleting");
}
}
public Action[] getActions(Object target, Object sender) {
return ACTIONS;
}
});
//adding containerProperty's to table
myRequestsTable.addContainerProperty("Sender", String.class, null);
myRequestsTable.addContainerProperty("Project", String.class, null);
myRequestsTable.addContainerProperty("Resource", String.class, null);
myRequestsTable.addContainerProperty("Date", String.class, null);
myRequestsTable.addContainerProperty("Ratio wanted", Label.class, null);
myRequestsTable.addContainerProperty("Current ratio", Label.class, null);
myRequestsTable.addContainerProperty("Expired", String.class, null);
for (int i = 0; i < myRequestsList.size(); i++) {
Request r = myRequestsList.get(i);
if (r.getWeek() < todayInt) {
r.setRejected(true);
requestDao.updateRequest(r);
continue;
}
Object[] obj = new Object[7];
obj[0] = userResource.getResourceName();
Project p = projectDao.getProjectByProjectID(r.getProjectID());
obj[1] = p.getProjectName();
Resource res = resourceDao.getResourceByResourceID(r.getResourceID());
obj[2] = res.getResourceName();
String date = formatter.format(Timestamp.toDate(r.getWeek()));
obj[3] = date;
Label l = new Label(Colorizer.floatToHTML(r.getRatio()));
l.setContentMode(Label.CONTENT_XHTML);
obj[4] = l;
Float f = bookingDao.getBookingsSumByResourceIDandWeek(r.getResourceID(), r.getWeek());
l = new Label(Colorizer.floatToHTML(f));
l.setContentMode(Label.CONTENT_XHTML);
obj[5] = l;
obj[6] = Boolean.toString(r.isRejected());
myRequestsTable.addItem(obj,i);
}
}