public void validate(final Form< ? > form)
{
if (parentPage.isMassUpdateMode() == true) {
} else {
final TimesheetFilter filter = getSearchFilter();
final Date from = startDate.getConvertedInput();
final Date to = stopDate.getConvertedInput();
if (from == null && to == null && filter.getTaskId() == null) {
error(getString("timesheet.error.filter.needMore"));
} else if (from != null && to != null && from.after(to) == true) {
error(getString("timesheet.error.startTimeAfterStopTime"));
}
}
}
});
final TimesheetFilter filter = getSearchFilter();
{
gridBuilder.newSplitPanel(GridSize.COL66);
final FieldsetPanel fs = gridBuilder.newFieldset(getString("task")).suppressLabelForWarning();
final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new Model<TaskDO>() {
@Override
public TaskDO getObject()
{
return taskTree.getTaskById(getSearchFilter().getTaskId());
}
@Override
public void setObject(final TaskDO task)
{
if (task != null) {
getSearchFilter().setTaskId(task.getId());
} else {
getSearchFilter().setTaskId(null);
}
}
}, parentPage, "taskId");
fs.add(taskSelectPanel);
taskSelectPanel.init();
taskSelectPanel.setRequired(false);
}
{
// Assignee
gridBuilder.newSplitPanel(GridSize.COL33);
final FieldsetPanel fs = gridBuilder.newFieldset(getString("user"));
final UserSelectPanel assigneeSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
@Override
public PFUserDO getObject()
{
return userGroupCache.getUser(filter.getUserId());
}
@Override
public void setObject(final PFUserDO object)
{
if (object == null) {
filter.setUserId(null);
} else {
filter.setUserId(object.getId());
}
}
}, parentPage, "userId");
fs.add(assigneeSelectPanel);
assigneeSelectPanel.setDefaultFormProcessing(false);
assigneeSelectPanel.init().withAutoSubmit(true);
}
{
gridBuilder.newSplitPanel(GridSize.COL66);
final FieldsetPanel fs = gridBuilder.newFieldset(getString("timePeriod"));
startDate = new DatePanel(fs.newChildId(), new PropertyModel<Date>(filter, "startTime"), DatePanelSettings.get()
.withSelectPeriodMode(true));
fs.add(dependentFormComponents[0] = startDate);
fs.setLabelFor(startDate);
fs.add(new DivTextPanel(fs.newChildId(), " - "));
stopDate = new DatePanel(fs.newChildId(), new PropertyModel<Date>(filter, "stopTime"), DatePanelSettings.get().withSelectPeriodMode(
true));
fs.add(dependentFormComponents[1] = stopDate);
{
final SubmitLink unselectPeriodLink = new SubmitLink(IconLinkPanel.LINK_ID) {
@Override
public void onSubmit()
{
getSearchFilter().setStartTime(null);
getSearchFilter().setStopTime(null);
clearInput();
parentPage.refresh();
};
};
unselectPeriodLink.setDefaultFormProcessing(false);
fs.add(new IconLinkPanel(fs.newChildId(), IconType.REMOVE_SIGN, new ResourceModel("calendar.tooltip.unselectPeriod"),
unselectPeriodLink).setColor(CSSColor.RED));
}
final QuickSelectPanel quickSelectPanel = new QuickSelectPanel(fs.newChildId(), parentPage, "quickSelect", startDate);
fs.add(quickSelectPanel);
quickSelectPanel.init();
fs.add(new DivTextPanel(fs.newChildId(), new Model<String>() {
@Override
public String getObject()
{
return WicketUtils.getCalendarWeeks(TimesheetListForm.this, filter.getStartTime(), filter.getStopTime());
}
}));
fs.add(new HtmlCommentPanel(fs.newChildId(), new Model<String>() {
@Override
public String getObject()
{
return WicketUtils.getUTCDates(filter.getStartTime(), filter.getStopTime());
}
}));
}
{
// Duration