@Override
protected void init()
{
super.init();
{
final IconButtonPanel icsExportButtonPanel = new IconButtonPanel(buttonGroupPanel.newChildId(), IconType.LIST, new ResourceModel(
"plugins.teamcal.calendar.listAndIcsExport.tooltip")) {
/**
* @see org.projectforge.web.wicket.flowlayout.IconButtonPanel#onSubmit()
*/
@Override
protected void onSubmit()
{
setResponsePage(TeamCalListPage.class);
}
};
icsExportButtonPanel.setDefaultFormProcessing(false);
buttonGroupPanel.addButton(icsExportButtonPanel);
}
{
final IconButtonPanel searchButtonPanel = new IconButtonPanel(buttonGroupPanel.newChildId(), IconType.SEARCH, new ResourceModel(
"search")) {
/**
* @see org.projectforge.web.wicket.flowlayout.IconButtonPanel#onSubmit()
*/
@Override
protected void onSubmit()
{
final Set<Integer> visibleCalsSet = ((TeamCalCalendarFilter) filter).getActiveVisibleCalendarIds();
final String calendars = StringHelper.objectColToString(visibleCalsSet, ",");
final TeamEventListPage teamEventListPage = new TeamEventListPage(new PageParameters().add(TeamEventListPage.PARAM_CALENDARS,
calendars));
setResponsePage(teamEventListPage);
}
};
searchButtonPanel.setDefaultFormProcessing(false);
buttonGroupPanel.addButton(searchButtonPanel);
}
final TeamCalFilterDialog dialog = new TeamCalFilterDialog(parentPage.newModalDialogId(), (TeamCalCalendarFilter) filter) {
/**
* @see org.projectforge.plugins.teamcal.dialog.TeamCalFilterDialog#onClose(org.apache.wicket.ajax.AjaxRequestTarget)
*/
@Override
protected void onClose(final AjaxRequestTarget target)
{
activeTemplate = ((TeamCalCalendarFilter) filter).getActiveTemplateEntry();
target.add(templateChoice.getDropDownChoice());
}
};
parentPage.add(dialog);
dialog.init();
final List<TemplateEntry> values = ((TeamCalCalendarFilter) filter).getTemplateEntries();
final LabelValueChoiceRenderer<TemplateEntry> templateNamesChoiceRenderer = new LabelValueChoiceRenderer<TemplateEntry>();
for (final TemplateEntry entry : values) {
templateNamesChoiceRenderer.addValue(entry, entry.getName());
}
templateNamesChoiceRenderer.addValue(new TemplateEntry().setName(MAGIC_FILTER_ENTRY),
getString("plugins.teamcal.calendar.filter.newEntry"));
final IModel<TemplateEntry> activeModel = new PropertyModel<TemplateEntry>(this, "activeTemplate");
this.activeTemplate = ((TeamCalCalendarFilter) filter).getActiveTemplateEntry();
templateChoice = new DropDownChoicePanel<TemplateEntry>(fieldset.newChildId(), activeModel, templateNamesChoiceRenderer.getValues(),
templateNamesChoiceRenderer, false);
fieldset.add(templateChoice);
templateChoice.setTooltip(getString("plugins.teamcal.calendar.filter.choose"));
templateChoice.getDropDownChoice().setOutputMarkupId(true);
templateChoice.getDropDownChoice().add(new AjaxFormComponentUpdatingBehavior("onChange") {
private static final long serialVersionUID = 8999698636114154230L;
/**
* @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget)
*/
@Override
protected void onUpdate(final AjaxRequestTarget target)
{
final TemplateEntry selectedEntry = activeModel.getObject();
if (MAGIC_FILTER_ENTRY.equals(selectedEntry.getName()) == false) {
((TeamCalCalendarFilter) filter).setActiveTemplateEntry(selectedEntry);
filter.setSelectedCalendar(TemplateEntry.calcCalendarStringForCalendar(selectedEntry.getDefaultCalendarId()));
setResponsePage(getParentPage().getClass());
} else {
final String newTemplateName = ((TeamCalCalendarFilter) filter)
.getNewTemplateName(getString("plugins.teamcal.calendar.filterDialog.newTemplateName"));
if (newTemplateName == null) {
// New filter 9 is already reached.
activeTemplate = ((TeamCalCalendarFilter) filter).getActiveTemplateEntry();
target.add(templateChoice.getDropDownChoice());
return;
}
dialog.openNew(target, newTemplateName);
// Redraw the content:
dialog.redraw().addContent(target);
}
}
});
final IconButtonPanel calendarButtonPanel = new AjaxIconButtonPanel(buttonGroupPanel.newChildId(), IconType.EDIT, new ResourceModel(
"plugins.teamcal.calendar.filter.edit")) {
/**
* @see org.projectforge.web.wicket.flowlayout.AjaxIconButtonPanel#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
*/
@Override
protected void onSubmit(final AjaxRequestTarget target)
{
dialog.open(target);
// Redraw the content:
dialog.redraw().addContent(target);
}
};
calendarButtonPanel.setDefaultFormProcessing(false);
buttonGroupPanel.addButton(calendarButtonPanel);
fieldset.add(new DropIcsPanel(fieldset.newChildId()) {
@Override