Search in sources :

Example 1 with FileUploadPanel

use of org.projectforge.web.wicket.flowlayout.FileUploadPanel 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 FileUploadPanel

use of org.projectforge.web.wicket.flowlayout.FileUploadPanel in project projectforge by micromata.

the class AddressImportForm method onInitialize.

/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize() {
    super.onInitialize();
    gridBuilder.newSplitPanel(GridSize.COL50);
    final FieldsetPanel newFieldset = gridBuilder.newFieldset(getString("address.book.vCardImport.fileUploadPanel"));
    final FileUploadField uploadField = new FileUploadField(FileUploadPanel.WICKET_ID, new PropertyModel<List<FileUpload>>(this, "uploads"));
    newFieldset.add(new FileUploadPanel(newFieldset.newChildId(), uploadField));
}
Also used : FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) FileUploadPanel(org.projectforge.web.wicket.flowlayout.FileUploadPanel) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField)

Example 3 with FileUploadPanel

use of org.projectforge.web.wicket.flowlayout.FileUploadPanel 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)

Example 4 with FileUploadPanel

use of org.projectforge.web.wicket.flowlayout.FileUploadPanel in project projectforge by micromata.

the class ReportObjectivesForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    add(new IFormValidator() {

        @Override
        public FormComponent<?>[] getDependentFormComponents() {
            return dependentFormComponents;
        }

        @Override
        public void validate(final Form<?> form) {
            final Date fromDate = fromDatePanel.getConvertedInput();
            final Date toDate = toDatePanel.getConvertedInput();
            if (toDate != null && fromDate != null && fromDate.after(toDate)) {
                toDatePanel.getDateField().error(getString("fibu.buchungssatz.error.invalidTimeperiod"));
            }
        }
    });
    filter = getFilter();
    gridBuilder.newGridPanel();
    {
        final FieldsetPanel fs = new FieldsetPanel(gridBuilder.getPanel(), getString("file"), "*.xml") {

            @Override
            public boolean isVisible() {
                return parentPage.getReportStorage() == null;
            }
        };
        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<>("import")) {

            @Override
            public final void onSubmit() {
                parentPage.importReportObjectivs();
            }
        }, getString("import"), SingleButtonPanel.NORMAL));
    }
    {
        final FieldsetPanel fs = new FieldsetPanel(gridBuilder.getPanel(), getString("timePeriod")) {

            @Override
            public boolean isVisible() {
                return reportObjectivesPanel.isVisible();
            }
        };
        fs.add(fromDatePanel = new DatePanel(fs.newChildId(), new PropertyModel<>(filter, "fromDate"), DatePanelSettings.get().withRequired(true)));
        dependentFormComponents[0] = fromDatePanel;
        fs.add(new DivTextPanel(fs.newChildId(), " - "));
        fs.add(toDatePanel = new DatePanel(fs.newChildId(), new PropertyModel<>(filter, "toDate"), DatePanelSettings.get()));
        dependentFormComponents[1] = toDatePanel;
        final Button createReportButton = new Button(SingleButtonPanel.WICKET_ID, new Model<>("createReport")) {

            @Override
            public final void onSubmit() {
                parentPage.createReport();
            }
        };
        setDefaultButton(createReportButton);
        fs.add(new SingleButtonPanel(fs.newChildId(), createReportButton, getString("fibu.kost.reporting.createReport"), SingleButtonPanel.DEFAULT_SUBMIT));
        fs.add(new SingleButtonPanel(fs.newChildId(), new Button(SingleButtonPanel.WICKET_ID, new Model<>("clear")) {

            @Override
            public final void onSubmit() {
                parentPage.clear();
            }
        }, getString("fibu.kost.reporting.clearStorage"), SingleButtonPanel.RESET));
    }
    final DivPanel panel = gridBuilder.getPanel();
    panel.add(reportObjectivesPanel = new ReportObjectivesPanel(panel.newChildId(), parentPage));
}
Also used : IFormValidator(org.apache.wicket.markup.html.form.validation.IFormValidator) PropertyModel(org.apache.wicket.model.PropertyModel) Date(java.util.Date) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField) DivTextPanel(org.projectforge.web.wicket.flowlayout.DivTextPanel) Button(org.apache.wicket.markup.html.form.Button) DatePanel(org.projectforge.web.wicket.components.DatePanel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) 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 5 with FileUploadPanel

use of org.projectforge.web.wicket.flowlayout.FileUploadPanel in project projectforge by micromata.

the class EmployeeSalaryImportForm 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));
    dropDownMonth.setRequired(true);
    fsMonthYear.add(dropDownMonth);
    dropDownYear = new DropDownChoicePanel<>(fsMonthYear.newChildId(), new DropDownChoice<>(DropDownChoicePanel.WICKET_ID, new PropertyModel<>(this, "selectedYear"), eedHelper.getDropDownYears()));
    dropDownYear.setRequired(true);
    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 EmployeeSalaryImportStoragePanel(panel.newChildId(), parentPage, importFilter);
    final Date dateToSelectAttrRow = new GregorianCalendar(selectedYear, (selectedMonth != null ? selectedMonth : PFDateTime.now().getMonthValue()) - 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)

Aggregations

FileUploadField (org.apache.wicket.markup.html.form.upload.FileUploadField)7 FieldsetPanel (org.projectforge.web.wicket.flowlayout.FieldsetPanel)7 FileUploadPanel (org.projectforge.web.wicket.flowlayout.FileUploadPanel)7 Button (org.apache.wicket.markup.html.form.Button)6 SingleButtonPanel (org.projectforge.web.wicket.components.SingleButtonPanel)6 DivPanel (org.projectforge.web.wicket.flowlayout.DivPanel)5 Date (java.util.Date)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3 Model (org.apache.wicket.model.Model)3 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 Bytes (org.apache.wicket.util.lang.Bytes)2 FileFieldSizeCheckBehavior (org.wicketstuff.html5.fileapi.FileFieldSizeCheckBehavior)2 FileList (org.wicketstuff.html5.fileapi.FileList)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 IFormValidator (org.apache.wicket.markup.html.form.validation.IFormValidator)1 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)1