Search in sources :

Example 1 with SingleButtonPanel

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

the class EmployeeBillingImportForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    gridBuilder.newGridPanel();
    // Date DropDowns
    final FieldsetPanel fsMonthYear = gridBuilder.newFieldset(I18nHelper.getLocalizedMessage("plugins.eed.listcare.yearmonth"));
    dropDownMonth = new DropDownChoicePanel<>(fsMonthYear.newChildId(), new DropDownChoice<>(DropDownChoicePanel.WICKET_ID, new PropertyModel<>(this, "selectedMonth"), EEDHelper.MONTH_INTEGERS));
    fsMonthYear.add(dropDownMonth);
    dropDownYear = new DropDownChoicePanel<>(fsMonthYear.newChildId(), new DropDownChoice<>(DropDownChoicePanel.WICKET_ID, new PropertyModel<>(this, "selectedYear"), eedHelper.getDropDownYears()));
    fsMonthYear.add(dropDownYear);
    // upload buttons
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("file"), "*.xls");
        fileUploadField = new FileUploadField(FileUploadPanel.WICKET_ID);
        fs.add(new FileUploadPanel(fs.newChildId(), fileUploadField));
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID) {

            @Override
            public final void onSubmit() {
                final Date dateToSelectAttrRow = new GregorianCalendar(selectedYear, selectedMonth - 1, 1, 0, 0).getTime();
                storagePanel.setDateToSelectAttrRow(dateToSelectAttrRow);
                final boolean success = parentPage.doImport(dateToSelectAttrRow);
                if (success) {
                    setDateDropDownsEnabled(false);
                }
            }
        }, getString("upload"), SingleButtonPanel.NORMAL).setTooltip(getString("common.import.upload.tooltip")));
        addClearButton(fs);
    }
    addImportFilterRadio(gridBuilder);
    // preview of the imported data
    gridBuilder.newGridPanel();
    final DivPanel panel = gridBuilder.getPanel();
    storagePanel = new EmployeeBillingImportStoragePanel(panel.newChildId(), parentPage, importFilter);
    final Date dateToSelectAttrRow = new GregorianCalendar(selectedYear, selectedMonth - 1, 1, 0, 0).getTime();
    storagePanel.setDateToSelectAttrRow(dateToSelectAttrRow);
    panel.add(storagePanel);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Button(org.apache.wicket.markup.html.form.Button) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) FileUploadPanel(org.projectforge.web.wicket.flowlayout.FileUploadPanel) DivPanel(org.projectforge.web.wicket.flowlayout.DivPanel) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Example 2 with SingleButtonPanel

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

the class IHKForm method showMissingDescriptionList.

void showMissingDescriptionList(List<TimesheetDO> missingDescriptionList) {
    gridBuilder.newSplitPanel(GridSize.COL66);
    DateFormat date = new SimpleDateFormat("dd.MM.yyyy");
    DateFormat time = new SimpleDateFormat("HH:mm");
    for (TimesheetDO ts : missingDescriptionList) {
        String label = getString("plugins.ihk.nodescriptionfound");
        if (ts.getKost2() != null) {
            if (ts.getKost2().getDescription() != null) {
                label = ts.getKost2().getDescription();
            } else if (ts.getKost2().getDisplayName() != null) {
                label = ts.getKost2().getDisplayName();
            }
        }
        final FieldsetPanel fs = gridBuilder.newFieldset(label);
        fs.add(new DivTextPanel(fs.newChildId(), date.format(ts.getStartTime().getTime()) + " " + time.format(ts.getStartTime().getTime()) + " - " + time.format(ts.getStopTime().getTime())));
        Button editButton = new Button(SingleButtonPanel.WICKET_ID, new Model("edit")) {

            @Override
            public void onSubmit() {
                parentPage.edit(ts);
            }
        };
        fs.add(new SingleButtonPanel(fs.newChildId(), editButton, getString("plugins.ihk.edit"), SingleButtonPanel.CANCEL));
    }
    // Download anyway button
    final FieldsetPanel downloadPanel = gridBuilder.newFieldset("");
    Button downloadButton = new Button(SingleButtonPanel.WICKET_ID, new Model("download")) {

        @Override
        public void onSubmit() {
            parentPage.export(true);
        }
    };
    downloadPanel.add(new SingleButtonPanel(downloadPanel.newChildId(), downloadButton, getString("plugins.ihk.downloadAnyway"), SingleButtonPanel.DEFAULT_SUBMIT));
}
Also used : Button(org.apache.wicket.markup.html.form.Button) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) LocalDateModel(org.projectforge.web.wicket.components.LocalDateModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) ResourceModel(org.apache.wicket.model.ResourceModel) TimesheetDO(org.projectforge.business.timesheet.TimesheetDO) SimpleDateFormat(java.text.SimpleDateFormat) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Example 3 with SingleButtonPanel

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

the class AccessEditForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    gridBuilder.newGridPanel();
    {
        // Task
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task"));
        final TaskSelectPanel taskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<TaskDO>(data, "task"), parentPage, "taskId");
        fs.add(taskSelectPanel.setRequired(true));
        taskSelectPanel.init();
    }
    {
        // Group
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("group")).suppressLabelForWarning();
        groupSelectPanel = new NewGroupSelectPanel(fs.newChildId(), new PropertyModel<GroupDO>(data, "group"), parentPage, "groupId");
        fs.add(groupSelectPanel.setRequired(true));
        groupSelectPanel.init();
    }
    {
        // Option recursive
        gridBuilder.newFieldset(getString("recursive")).addCheckBox(new PropertyModel<Boolean>(data, "recursive"), null).setTooltip(getString("access.recursive.help"));
    }
    {
        // Access entries table
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("access.accessTable")).suppressLabelForWarning();
        final AccessEditTablePanel accessEditTablePanel = new AccessEditTablePanel(fs.newChildId(), data);
        fs.add(accessEditTablePanel);
        accessEditTablePanel.init();
    }
    {
        // Templates
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("access.templates")).suppressLabelForWarning();
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("clear")) {

            @Override
            public final void onSubmit() {
                data.clear();
            }
        }, getString("access.templates.clear"), SingleButtonPanel.NORMAL));
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("guest")) {

            @Override
            public final void onSubmit() {
                data.guest();
            }
        }, getString("access.templates.guest"), SingleButtonPanel.NORMAL));
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("employee")) {

            @Override
            public final void onSubmit() {
                data.employee();
            }
        }, getString("access.templates.employee"), SingleButtonPanel.NORMAL));
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("leader")) {

            @Override
            public final void onSubmit() {
                data.leader();
            }
        }, getString("access.templates.leader"), SingleButtonPanel.NORMAL));
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("administrator")) {

            @Override
            public final void onSubmit() {
                data.administrator();
            }
        }, getString("access.templates.administrator"), SingleButtonPanel.DANGER));
    }
    {
        // Description
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("description"));
        fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "description")), true);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) MaxLengthTextArea(org.projectforge.web.wicket.components.MaxLengthTextArea) TaskSelectPanel(org.projectforge.web.task.TaskSelectPanel) NewGroupSelectPanel(org.projectforge.web.user.NewGroupSelectPanel) Button(org.apache.wicket.markup.html.form.Button) 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) GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO)

Example 4 with SingleButtonPanel

use of org.projectforge.web.wicket.components.SingleButtonPanel 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 5 with SingleButtonPanel

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

the class DatevImportForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    this.setOutputMarkupId(true);
    Bytes maxSize = Bytes.valueOf(configurationService.getMaxFileSizeDatev());
    this.setMaxSize(maxSize);
    gridBuilder.newGridPanel();
    String hint = I18nHelper.getLocalizedMessage("finance.datev.upload.hint", NumberHelper.formatBytes(maxSize.bytes()));
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("file"), hint);
    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>("uploadAccounts")) {

        @Override
        public final void onSubmit() {
            parentPage.importAccountList();
        }
    }, getString("finance.datev.uploadAccountList"), SingleButtonPanel.NORMAL).setTooltip(getString("common.import.upload.tooltip")));
    fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<String>("uploadRecords")) {

        @Override
        public final void onSubmit() {
            parentPage.importAccountRecords();
        }
    }, getString("finance.datev.uploadAccountingRecords"), SingleButtonPanel.NORMAL).setTooltip(getString("common.import.upload.tooltip")));
    addClearButton(fs);
    addImportFilterRadio(gridBuilder);
    // Statistics
    new BusinessAssessment4Fieldset(gridBuilder) {

        /**
         * @see org.projectforge.web.fibu.BusinessAssessment4Fieldset#getBusinessAssessment()
         */
        @Override
        protected BusinessAssessment getBusinessAssessment() {
            return storagePanel.businessAssessment;
        }

        @Override
        public boolean isVisible() {
            return storagePanel.businessAssessment != null;
        }
    };
    gridBuilder.newGridPanel();
    final DivPanel panel = gridBuilder.getPanel();
    storagePanel = new DatevImportStoragePanel(panel.newChildId(), parentPage, importFilter);
    panel.add(storagePanel);
    this.fileUploadField.add(new FileFieldSizeCheckBehavior() {

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final FileList fileList) {
            // return form to remove errors
            target.add(DatevImportForm.this.feedbackPanel);
        }

        @Override
        protected void addErrorMsg(AjaxRequestTarget target, FileList fileList) {
            DatevImportForm.this.addError("common.uploadpanel.filetolarge", NumberHelper.formatBytes(maxSize.bytes()));
        }

        @Override
        protected void onError(final AjaxRequestTarget target, final FileList fileList) {
            // clear input field to avoid uploading the image
            DatevImportForm.this.fileUploadField.clearInput();
            // return form
            target.add(DatevImportForm.this);
        }
    });
}
Also used : FileList(org.wicketstuff.html5.fileapi.FileList) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Bytes(org.apache.wicket.util.lang.Bytes) Button(org.apache.wicket.markup.html.form.Button) FileFieldSizeCheckBehavior(org.wicketstuff.html5.fileapi.FileFieldSizeCheckBehavior) Model(org.apache.wicket.model.Model) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) FileUploadPanel(org.projectforge.web.wicket.flowlayout.FileUploadPanel) DivPanel(org.projectforge.web.wicket.flowlayout.DivPanel) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Aggregations

SingleButtonPanel (org.projectforge.web.wicket.components.SingleButtonPanel)41 Button (org.apache.wicket.markup.html.form.Button)33 Model (org.apache.wicket.model.Model)25 PropertyModel (org.apache.wicket.model.PropertyModel)24 FieldsetPanel (org.projectforge.web.wicket.flowlayout.FieldsetPanel)15 DivPanel (org.projectforge.web.wicket.flowlayout.DivPanel)10 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)8 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)8 MaxLengthTextArea (org.projectforge.web.wicket.components.MaxLengthTextArea)8 DivTextPanel (org.projectforge.web.wicket.flowlayout.DivTextPanel)7 FileUploadField (org.apache.wicket.markup.html.form.upload.FileUploadField)6 FileUploadPanel (org.projectforge.web.wicket.flowlayout.FileUploadPanel)6 Date (java.util.Date)5 ResourceModel (org.apache.wicket.model.ResourceModel)5 LocalDateModel (org.projectforge.web.wicket.components.LocalDateModel)5 LocalDate (java.time.LocalDate)4 List (java.util.List)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 IModel (org.apache.wicket.model.IModel)4 LabelValueChoiceRenderer (org.projectforge.web.wicket.components.LabelValueChoiceRenderer)4