Search in sources :

Example 1 with LabelValueChoiceRenderer

use of org.projectforge.web.wicket.components.LabelValueChoiceRenderer in project projectforge by micromata.

the class MonthlyEmployeeReportForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("timesheet.user"));
        if (accessChecker.hasLoggedInUserAccessToTimesheetsOfOtherUsers()) {
            final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<PFUserDO>(filter, "user"), parentPage, "user");
            userSelectPanel.setRequired(true);
            fs.add(userSelectPanel);
            userSelectPanel.init();
        } else {
            filter.setUser(ThreadLocalUserContext.getUser());
            fs.add(new DivTextPanel(fs.newChildId(), filter.getUser().getFullname()));
        }
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("calendar.month"));
        yearChoice = new DropDownChoice<Integer>(fs.getDropDownChoiceId(), new PropertyModel<Integer>(filter, "year"), new ArrayList<Integer>()) {

            /**
             * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications()
             */
            @Override
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }
        };
        yearChoice.setNullValid(false).setRequired(true);
        fs.add(yearChoice);
        // DropDownChoice months
        final LabelValueChoiceRenderer<Integer> monthChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
        for (int month = 1; month <= 12; month++) {
            monthChoiceRenderer.addValue(month, StringHelper.format2DigitNumber(month));
        }
        monthChoice = new DropDownChoice<Integer>(fs.getDropDownChoiceId(), new PropertyModel<Integer>(filter, "month"), monthChoiceRenderer.getValues(), monthChoiceRenderer) {

            /**
             * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications()
             */
            @Override
            protected boolean wantOnSelectionChangedNotifications() {
                return true;
            }
        };
        monthChoice.setNullValid(false).setRequired(true);
        fs.add(monthChoice);
        final QuickSelectMonthPanel quickSelectPanel = new QuickSelectMonthPanel(fs.newChildId(), new Model<LocalDate>() {

            /**
             * @see org.apache.wicket.model.Model#getObject()
             */
            @Override
            public LocalDate getObject() {
                Integer year = filter.getYear();
                Integer month = filter.getMonth();
                PFDateTime date;
                if (year == null || month == null) {
                    date = PFDateTime.now().getBeginOfMonth();
                } else {
                    date = PFDateTime.withDate(filter.getYear(), PFDayUtils.validateMonthValue(filter.getMonth()), 1);
                }
                return date.getLocalDate();
            }

            /**
             * @see org.apache.wicket.model.Model#setObject(java.io.Serializable)
             */
            @Override
            public void setObject(final LocalDate object) {
                if (object != null) {
                    setDate(object);
                }
            }
        }, parentPage, "quickSelect");
        fs.add(quickSelectPanel);
        quickSelectPanel.init();
    }
    {
        final Button showButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("show"));
        final SingleButtonPanel showButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), showButton, getString("show"), SingleButtonPanel.DEFAULT_SUBMIT);
        actionButtons.add(showButtonPanel);
        setDefaultButton(showButton);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) LocalDate(java.time.LocalDate) PFDateTime(org.projectforge.framework.time.PFDateTime) QuickSelectMonthPanel(org.projectforge.web.calendar.QuickSelectMonthPanel) UserSelectPanel(org.projectforge.web.user.UserSelectPanel) DivTextPanel(org.projectforge.web.wicket.flowlayout.DivTextPanel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Button(org.apache.wicket.markup.html.form.Button) LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Example 2 with LabelValueChoiceRenderer

use of org.projectforge.web.wicket.components.LabelValueChoiceRenderer in project projectforge by micromata.

the class AccountingRecordListForm method onOptionsPanelCreate.

/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel,
 * org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel) {
    // DropDownChoices from
    final YearListCoiceRenderer yearListChoiceRenderer = new YearListCoiceRenderer(buchungssatzDao.getYears(), false);
    final DropDownChoice<Integer> fromYearChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Integer>(this, "fromYear"), yearListChoiceRenderer.getYears(), yearListChoiceRenderer);
    fromYearChoice.setNullValid(false).setRequired(true);
    optionsFieldsetPanel.add(fromYearChoice);
    final LabelValueChoiceRenderer<Integer> monthChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
    for (int i = 1; i <= 12; i++) {
        monthChoiceRenderer.addValue(i, StringHelper.format2DigitNumber(i));
    }
    final DropDownChoice<Integer> fromMonthChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Integer>(this, "fromMonth"), monthChoiceRenderer.getValues(), monthChoiceRenderer);
    fromMonthChoice.setNullValid(true);
    optionsFieldsetPanel.add(fromMonthChoice);
    optionsFieldsetPanel.add(new DivTextPanel(optionsFieldsetPanel.newChildId(), " - "));
    // DropDownChoices to
    final DropDownChoice<Integer> toYearChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Integer>(this, "toYear"), yearListChoiceRenderer.getYears(), yearListChoiceRenderer);
    toYearChoice.setNullValid(false).setRequired(true);
    optionsFieldsetPanel.add(toYearChoice);
    final DropDownChoice<Integer> toMonthChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Integer>(this, "toMonth"), monthChoiceRenderer.getValues(), monthChoiceRenderer);
    toMonthChoice.setNullValid(true);
    optionsFieldsetPanel.add(toMonthChoice);
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) DivTextPanel(org.projectforge.web.wicket.flowlayout.DivTextPanel) LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) YearListCoiceRenderer(org.projectforge.web.wicket.components.YearListCoiceRenderer)

Example 3 with LabelValueChoiceRenderer

use of org.projectforge.web.wicket.components.LabelValueChoiceRenderer in project projectforge by micromata.

the class EmployeeSalaryListForm method onOptionsPanelCreate.

/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel,
 * org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel) {
    final YearListCoiceRenderer yearListChoiceRenderer = new YearListCoiceRenderer(employeeSalaryDao.getYears(), true);
    optionsFieldsetPanel.addDropDownChoice(new PropertyModel<Integer>(this, "year"), yearListChoiceRenderer.getYears(), yearListChoiceRenderer, true).setNullValid(false);
    // DropDownChoice months
    final LabelValueChoiceRenderer<Integer> monthChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
    for (int month = 1; month <= 12; month++) {
        monthChoiceRenderer.addValue(month, StringHelper.format2DigitNumber(month));
    }
    optionsFieldsetPanel.addDropDownChoice(new PropertyModel<Integer>(this, "month"), monthChoiceRenderer.getValues(), monthChoiceRenderer, true).setNullValid(true);
}
Also used : LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) YearListCoiceRenderer(org.projectforge.web.wicket.components.YearListCoiceRenderer) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 4 with LabelValueChoiceRenderer

use of org.projectforge.web.wicket.components.LabelValueChoiceRenderer in project projectforge by micromata.

the class TeamCalCalendarForm method init.

/**
 * @see org.projectforge.web.calendar.CalendarForm#init()
 */
@SuppressWarnings("serial")
@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.web.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("change") {

        private static final long serialVersionUID = 8999698636114154230L;

        @Override
        protected void onUpdate(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
        protected void onStringImport(final AjaxRequestTarget target, final String fileName, final String content) {
            ICalParser parser = ICalParser.parseAllFields();
            parser.parse(content);
            if (parser.getExtractedEvents().isEmpty()) {
                errorDialog.setMessage(getString("plugins.teamcal.import.ics.noEventsGiven")).open(target);
                return;
            }
            if (parser.getExtractedEvents().size() > 1) {
                // Can't import multiple entries, redirect to import page:
                redirectToImportPage(parser.getVEvents(), activeModel.getObject());
                return;
            }
            // Here we have just one event.
            final TeamEventDO event = parser.getExtractedEvents().get(0);
            final TemplateEntry activeTemplateEntry = ((TeamCalCalendarFilter) filter).getActiveTemplateEntry();
            if (event.getUid() != null && activeTemplateEntry != null) {
                final TeamEventDO dbEvent = teamEventDao.getByUid(activeTemplateEntry.getDefaultCalendarId(), event.getUid(), false);
                if (dbEvent != null) {
                    if (ThreadLocalUserContext.getUserId().equals(dbEvent.getCreator().getPk()) || dbEvent.isDeleted()) {
                        event.setId(dbEvent.getPk());
                        event.setCreated(dbEvent.getCreated());
                        event.setCreator(dbEvent.getCreator());
                        event.setDeleted(dbEvent.isDeleted());
                    } else {
                        // Can't import event with existing uid in selected calendar, redirect to import page:
                        redirectToImportPage(parser.getVEvents(), activeModel.getObject());
                        return;
                    }
                }
            }
            // set calendar
            if (activeTemplateEntry != null && activeTemplateEntry.getDefaultCalendarId() != null) {
                teamEventDao.setCalendar(event, activeTemplateEntry.getDefaultCalendarId());
            }
            // fix attendees
            teamEventService.fixAttendees(event);
            final Set<TeamEventAttendeeDO> originAssignedAttendees = new HashSet<>();
            event.getAttendees().forEach(attendee -> {
                attendee.setPk(null);
                originAssignedAttendees.add(attendee);
            });
            event.setAttendees(new HashSet<>());
            final TeamEventEditPage editPage = new TeamEventEditPage(new PageParameters(), event);
            final TeamEventEditForm form = editPage.getForm();
            originAssignedAttendees.forEach(attendee -> {
                if (attendee.getAddress() != null) {
                    form.getAttendeeWicketProvider().initSortedAttendees();
                    form.getAttendeeWicketProvider().getSortedAttendees().forEach(sortedAttendee -> {
                        if (sortedAttendee.getAddress() != null && sortedAttendee.getAddress().getPk().equals(attendee.getAddress().getPk())) {
                            sortedAttendee.setId(form.getAttendeeWicketProvider().getAndDecreaseInternalNewAttendeeSequence());
                            form.getAssignAttendeesListHelper().assignItem(sortedAttendee);
                        }
                    });
                } else {
                    attendee.setId(form.getAttendeeWicketProvider().getAndDecreaseInternalNewAttendeeSequence());
                    form.getAttendeeWicketProvider().getCustomAttendees().add(attendee);
                    form.getAssignAttendeesListHelper().assignItem(attendee);
                }
            });
            setResponsePage(editPage);
        }
    }.setTooltip(getString("plugins.teamcal.dropIcsPanel.tooltip")));
}
Also used : TeamEventEditForm(org.projectforge.web.teamcal.event.TeamEventEditForm) HashSet(java.util.HashSet) Set(java.util.Set) TemplateEntry(org.projectforge.business.teamcal.filter.TemplateEntry) TeamEventDO(org.projectforge.business.teamcal.event.model.TeamEventDO) ResourceModel(org.apache.wicket.model.ResourceModel) ICalParser(org.projectforge.business.teamcal.event.ical.ICalParser) TeamEventEditPage(org.projectforge.web.teamcal.event.TeamEventEditPage) TeamCalListPage(org.projectforge.web.teamcal.admin.TeamCalListPage) HashSet(java.util.HashSet) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) TeamEventAttendeeDO(org.projectforge.business.teamcal.event.model.TeamEventAttendeeDO) TeamCalCalendarFilter(org.projectforge.business.teamcal.filter.TeamCalCalendarFilter) PropertyModel(org.apache.wicket.model.PropertyModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) TeamEventListPage(org.projectforge.web.teamcal.event.TeamEventListPage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) TeamCalFilterDialog(org.projectforge.web.teamcal.dialog.TeamCalFilterDialog) DropIcsPanel(org.projectforge.web.teamcal.event.importics.DropIcsPanel)

Example 5 with LabelValueChoiceRenderer

use of org.projectforge.web.wicket.components.LabelValueChoiceRenderer in project projectforge by micromata.

the class TimesheetMassUpdateForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    final TaskTree taskTree = TaskTreeHelper.getTaskTree();
    timesheetPageSupport = new TimesheetPageSupport(parentPage, gridBuilder, timesheetDao, data);
    gridBuilder.newGridPanel();
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task"));
        fs.addCheckBox(new PropertyModel<Boolean>(this, "updateTask"), getString("update") + ":", getString("massupdate.updateTask"));
        final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(data, "task"), parentPage, "taskId");
        fs.add(taskSelectPanel);
        taskSelectPanel.init();
    }
    {
        kost2Fieldset = new FieldsetPanel(gridBuilder.getPanel(), getString("fibu.kost2")) {

            @Override
            public boolean isVisible() {
                return CollectionUtils.isNotEmpty(kost2List);
            }
        };
        kost2Fieldset.addCheckBox(new PropertyModel<Boolean>(this, "updateKost2"), getString("update") + ":", getString("massupdate.updateKost2"));
        kost2List = timesheetDao.getKost2List(data);
        final LabelValueChoiceRenderer<Integer> kost2ChoiceRenderer = getKost2LabelValueChoiceRenderer();
        kost2Choice = TimesheetEditForm.createCost2ChoiceRenderer(kost2Fieldset.getDropDownChoiceId(), timesheetDao, taskTree, kost2ChoiceRenderer, data, kost2List);
        kost2Fieldset.add(kost2Choice);
    }
    {
        timesheetPageSupport.addLocation(timesheetRecentService);
    }
    {
        {
            // Reference
            final FieldsetPanel fs = gridBuilder.newFieldset(getString("timesheet.reference"));
            final MaxLengthTextField referenceTextField = new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "reference"));
            fs.add(referenceTextField);
        }
    }
}
Also used : LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) MaxLengthTextField(org.projectforge.web.wicket.components.MaxLengthTextField) PropertyModel(org.apache.wicket.model.PropertyModel) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) TaskSelectPanel(org.projectforge.web.task.TaskSelectPanel) TaskTree(org.projectforge.business.task.TaskTree)

Aggregations

LabelValueChoiceRenderer (org.projectforge.web.wicket.components.LabelValueChoiceRenderer)18 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)14 PropertyModel (org.apache.wicket.model.PropertyModel)14 FieldsetPanel (org.projectforge.web.wicket.flowlayout.FieldsetPanel)8 Button (org.apache.wicket.markup.html.form.Button)5 Model (org.apache.wicket.model.Model)5 UserSelectPanel (org.projectforge.web.user.UserSelectPanel)5 DivTextPanel (org.projectforge.web.wicket.flowlayout.DivTextPanel)5 MaxLengthTextArea (org.projectforge.web.wicket.components.MaxLengthTextArea)4 MaxLengthTextField (org.projectforge.web.wicket.components.MaxLengthTextField)4 SingleButtonPanel (org.projectforge.web.wicket.components.SingleButtonPanel)4 List (java.util.List)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 PFUserDO (org.projectforge.framework.persistence.user.entities.PFUserDO)3 TaskSelectPanel (org.projectforge.web.task.TaskSelectPanel)3 YearListCoiceRenderer (org.projectforge.web.wicket.components.YearListCoiceRenderer)3 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)2