ResourceNotFoundException {
this.removeComponent(resourceTable);
resourceTable = new Table();
resourceList = resourceDao
.getResourcesByProjectAndGroupAndType(p, g, r);
Resource userResource = null;
if (!manager) {
try {
userResource = resourceDao.getResourceByUser(user);
} catch (Exception e) {
manager = true;
}
}
resourceTable.addContainerProperty("Resource name", Label.class, null);
resourceTable.addContainerProperty("Resource type", String.class, null);
for (int index = 0; index < resourceList.size(); index++) {
Resource res = resourceList.get(index);
Label label = null;
if (!manager && res.getResourceID() == userResource.getResourceID()) {
label = new Label("<b>" + res.getResourceName() + "</b>");
label.setContentMode(Label.CONTENT_XHTML);
} else {
label = new Label(res.getResourceName());
label.setContentMode(Label.CONTENT_XHTML);
}
resourceType = resourceTypeDao.getResourceTypeByResourceTypeID(res
.getResourceTypeID());
Object[] obj = new Object[2];
obj[0] = label;
obj[1] = resourceType.getResourceTypeName();
resourceTable.addItem(obj, index);
}
resourceTable.addListener(new ItemClickListener() {
/**
*
*/
private static final long serialVersionUID = 9059222161035189221L;
public void itemClick(ItemClickEvent event) {
int id = (Integer) event.getItemId();
Resource r = resourceList.get(id);
System.out.println(r.getResourceName());
refresher.update(r);
}
});
resourceTable.addActionHandler( new Handler() {
/**
*
*/
private static final long serialVersionUID = -7637588286867019717L;
public void handleAction(Action action, Object sender, Object target) {
try {
me.getApplication().getMainWindow().removeWindow(descriptionWindow);
} catch (Exception e) {
}
descriptionWindow.removeAllComponents();
int id = (Integer) target;
Resource r = resourceList.get(id);
Panel p = new Panel();
Label l = new Label(r.getDescription());
l.setWidth("350px");
p.addComponent(l);
descriptionWindow.addComponent(p);
descriptionWindow.setWidth("400px");
me.getApplication().getMainWindow().addWindow(descriptionWindow);