Search in sources :

Example 16 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class ProgressPanel method setButtonVisibility.

private void setButtonVisibility(AjaxRequestTarget target, String buttonId, boolean visible) {
    AjaxSubmitButton backButton = getButton(buttonId);
    backButton.setVisible(visible);
    target.add(backButton);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton)

Example 17 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class AbstractObjectMainPanel method initLayoutSaveButton.

protected void initLayoutSaveButton(final PageAdminObjectDetails<O> parentPage) {
    AjaxSubmitButton saveButton = new AjaxSubmitButton(ID_SAVE, parentPage.createStringResource("pageAdminFocus.button.save")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            getDetailsPage().savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    saveButton.add(getVisibilityForSaveButton());
    saveButton.setOutputMarkupId(true);
    saveButton.setOutputMarkupPlaceholderTag(true);
    mainForm.setDefaultButton(saveButton);
    mainForm.add(saveButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton)

Example 18 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class AbstractObjectMainPanel method initLayoutPreviewButton.

// TEMPORARY
protected void initLayoutPreviewButton(final PageAdminObjectDetails<O> parentPage) {
    AjaxSubmitButton previewButton = new AjaxSubmitButton(ID_PREVIEW_CHANGES, parentPage.createStringResource("pageAdminFocus.button.previewChanges")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            getDetailsPage().previewPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    previewButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_PREVIEW_CHANGES_URL) && AbstractObjectMainPanel.this.isPreviewButtonVisible();
        }

        @Override
        public boolean isEnabled() {
            if (ItemStatus.NOT_CHANGED == getObjectWrapper().getStatus() && !getObjectWrapper().canModify()) {
                return areSavePreviewButtonsEnabled();
            }
            return true;
        }
    });
    previewButton.setOutputMarkupId(true);
    previewButton.setOutputMarkupPlaceholderTag(true);
    mainForm.add(previewButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 19 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class MultiStateHorizontalButton method initLayout.

private void initLayout() {
    WebMarkupContainer buttonsPanel = new WebMarkupContainer(ID_BUTTONS_CONTAINER);
    buttonsPanel.setOutputMarkupId(true);
    add(buttonsPanel);
    RepeatingView buttons = new RepeatingView(ID_BUTTON);
    buttons.setOutputMarkupId(true);
    buttonsPanel.add(buttons);
    for (String propertyKey : propertyKeysList) {
        AjaxSubmitButton button = new AjaxSubmitButton(buttons.newChildId(), pageBase.createStringResource(propertyKey)) {

            @Override
            public void onSubmit(AjaxRequestTarget ajaxRequestTarget) {
                MultiStateHorizontalButton.this.onStateChanged(propertyKeysList.indexOf(propertyKey), ajaxRequestTarget);
            }

            @Override
            public void onError(AjaxRequestTarget ajaxRequestTarget) {
                MultiStateHorizontalButton.this.onStateChanged(propertyKeysList.indexOf(propertyKey), ajaxRequestTarget);
            }
        };
        button.add(getActiveButtonClassAppender(propertyKeysList.indexOf(propertyKey)));
        button.setOutputMarkupId(true);
        buttons.add(button);
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 20 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class UploadDownloadPanel method initLayout.

private void initLayout() {
    final FileUploadField fileUpload = new FileUploadField(ID_INPUT_FILE) {

        private static final long serialVersionUID = 1L;

        @Override
        public String[] getInputAsArray() {
            List<String> input = new ArrayList<>();
            try {
                input.add(new String(IOUtils.toByteArray(getStream())));
            } catch (IOException e) {
                LOGGER.error("Unable to define file content type: {}", e.getLocalizedMessage());
            }
            return input.toArray(new String[0]);
        }
    };
    Form form = this.findParent(Form.class);
    fileUpload.add(new AjaxFormSubmitBehavior(form, "change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            super.onSubmit(target);
            UploadDownloadPanel.this.uploadFilePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            super.onError(target);
            UploadDownloadPanel.this.uploadFilePerformed(target);
        }
    });
    fileUpload.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
    fileUpload.setOutputMarkupId(true);
    add(fileUpload);
    final AjaxDownloadBehaviorFromStream downloadBehavior = new AjaxDownloadBehaviorFromStream() {

        private static final long serialVersionUID = 1L;

        @Override
        protected InputStream initStream() {
            InputStream is = getStream();
            try {
                String newContentType = URLConnection.guessContentTypeFromStream(is);
                if (StringUtils.isNotEmpty(newContentType)) {
                    setContentType(newContentType);
                }
            } catch (IOException ex) {
                LOGGER.error("Unable to define download file content type: {}", ex.getLocalizedMessage());
            }
            return is;
        }
    };
    downloadBehavior.setContentType(getDownloadContentType());
    downloadBehavior.setFileName(getDownloadFileName());
    add(downloadBehavior);
    add(new AjaxSubmitButton(ID_BUTTON_DOWNLOAD) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            downloadPerformed(downloadBehavior, target);
        }
    });
    AjaxSubmitButton deleteButton = new AjaxSubmitButton(ID_BUTTON_DELETE) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            removeFilePerformed(target);
        }
    };
    deleteButton.add(new VisibleBehaviour(() -> !isReadOnly));
    add(deleteButton);
    add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(org.apache.wicket.markup.html.form.Form) AjaxDownloadBehaviorFromStream(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)67 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)65 Form (org.apache.wicket.markup.html.form.Form)27 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)23 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)23 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)12 ArrayList (java.util.ArrayList)9 List (java.util.List)8 Label (org.apache.wicket.markup.html.basic.Label)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)7 ListItem (org.apache.wicket.markup.html.list.ListItem)5 CheckFormGroup (com.evolveum.midpoint.web.component.form.CheckFormGroup)4 AceEditor (com.evolveum.midpoint.web.component.AceEditor)3 Form (com.evolveum.midpoint.web.component.form.Form)3 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)3 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)3 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3