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);
}
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);
}
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);
}
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);
}
}
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;
}
});
}
Aggregations