@SuppressWarnings("serial") @Override protected void init() { super.init(); gridBuilder.newGridPanel(); { final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.event.teamCal")); final List<TeamCalDO> list = teamCalDao.getAllCalendarsWithFullAccess(); final LabelValueChoiceRenderer<TeamCalDO> calChoiceRenderer = new LabelValueChoiceRenderer<TeamCalDO>(); for (final TeamCalDO cal : list) { calChoiceRenderer.addValue(cal, cal.getTitle()); } final DropDownChoice<TeamCalDO> calDropDownChoice = new DropDownChoice<TeamCalDO>( fs.getDropDownChoiceId(), new PropertyModel<TeamCalDO>(this, "calendar"), calChoiceRenderer.getValues(), calChoiceRenderer) { /** * @see * org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications() */ @Override protected boolean wantOnSelectionChangedNotifications() { return true; } /** * @see * org.apache.wicket.markup.html.form.DropDownChoice#onSelectionChanged(java.lang.Object) */ @Override protected void onSelectionChanged(final TeamCalDO newSelection) { parentPage.reconcile(); } }; calDropDownChoice.setNullValid(false); calDropDownChoice.setRequired(true); fs.add(calDropDownChoice); } { final FieldsetPanel fs = gridBuilder.newFieldset(getString("file"), "*.ics"); fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID); fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField)); fs.add( new SingleButtonPanel( fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("importEvents")) { @Override public final void onSubmit() { parentPage.importEvents(); } }, getString("upload"), SingleButtonPanel.NORMAL) .setTooltip(getString("common.import.upload.tooltip"))); addClearButton(fs); } { addImportFilterRadio(gridBuilder); } gridBuilder.newGridPanel(); final DivPanel panel = gridBuilder.getPanel(); storagePanel = new TeamCalImportStoragePanel(panel.newChildId(), parentPage, importFilter); panel.add(storagePanel); }
/** @see org.apache.wicket.Component#onBeforeRender() */ @SuppressWarnings("serial") protected void redraw( final TemplateEntry activeTemplateEntry, final List<TeamCalDO> selectedCalendars) { columnRepeater.removeAll(); final int counter = selectedCalendars.size(); int rowsPerColumn = counter / 3; if (counter % 3 > 0) { ++rowsPerColumn; // Need one more row. } int rowCounter = 0; WebMarkupContainer columnContainer; RepeatingView rowRepeater = null; for (final TeamCalDO calendar : selectedCalendars) { if (rowCounter++ % rowsPerColumn == 0) { // Start new column: columnContainer = new WebMarkupContainer(columnRepeater.newChildId()); columnContainer.add(AttributeModifier.append("class", GridSize.COL33.getClassAttrValue())); columnRepeater.add(columnContainer); rowRepeater = new RepeatingView("rowRepeater"); columnContainer.add(rowRepeater); } final WebMarkupContainer container = new WebMarkupContainer(rowRepeater.newChildId()); rowRepeater.add(container); final IModel<Boolean> model = Model.of(activeTemplateEntry.isVisible(calendar.getId()) == true); final CheckBoxPanel checkBoxPanel = new CheckBoxPanel("isVisible", model, ""); checkBoxPanel .getCheckBox() .add( new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = 3523446385818267608L; @Override protected void onUpdate(final AjaxRequestTarget target) { final Boolean newSelection = checkBoxPanel.getCheckBox().getConvertedInput(); final TemplateCalendarProperties properties = activeTemplateEntry.getCalendarProperties(calendar.getId()); if (newSelection != properties.isVisible()) { properties.setVisible(newSelection); activeTemplateEntry.setDirty(); } } }); container.add(checkBoxPanel); WicketUtils.addTooltip( checkBoxPanel.getCheckBox(), getString("plugins.teamcal.filterDialog.calendarIsVisible.tooltip")); container.add(new Label("name", calendar.getTitle())); final ColorPickerPanel picker = new ColorPickerPanel("colorPicker", activeTemplateEntry.getColorCode(calendar.getId())) { @Override protected void onColorUpdate(final String selectedColor) { final TemplateCalendarProperties props = activeTemplateEntry.getCalendarProperties(calendar.getId()); if (props != null) { props.setColorCode(selectedColor); } else { log.warn( "TeamCalendarProperties not found: calendar.id='" + calendar.getId() + "' + for active template '" + activeTemplateEntry.getName() + "'."); } } }; container.add(picker); } }
protected Integer getCalendarId() { return calendar != null ? calendar.getId() : null; }