use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class HelpInfoPanel method initLayout.
public void initLayout(final String messageKey) {
WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
add(content);
Label helpLabel = new Label(ID_HELP, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return getString(messageKey);
}
});
helpLabel.setEscapeModelStrings(false);
content.add(helpLabel);
AjaxLink ok = new AjaxLink(ID_BUTTON_OK) {
@Override
public void onClick(AjaxRequestTarget target) {
closePerformed(target);
}
};
content.add(ok);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class StageEditorPanel method initPanelLayout.
private void initPanelLayout() {
AjaxLink name = new AjaxLink(ID_NAME) {
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
Label nameLabel = new Label(ID_NAME_LABEL, getModel().getObject().getName() == null || getModel().getObject().getName().trim().equals("") ? "Stage definition #" + getModel().getObject().getNumber() : getModel().getObject().getName());
name.add(nameLabel);
add(name);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class PageAccountActivation method initLayout.
private void initLayout() {
WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
activationContainer.setOutputMarkupId(true);
add(activationContainer);
activationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !activated;
}
});
Form form = new Form<>(ID_MAIN_FORM);
activationContainer.add(form);
Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", new PropertyModel<>(userModel, "name.orig")));
usernamePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return false;
}
});
form.add(usernamePanel);
PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
form.add(passwordPanel);
AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
propagatePassword(target, form);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
target.add(getFeedbackPanel());
}
};
form.add(confirmPasswrod);
WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
confirmationContainer.setOutputMarkupId(true);
confirmationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return activated;
}
});
add(confirmationContainer);
AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(PageLogin.class);
}
};
confirmationContainer.add(linkToLogin);
RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
confirmationContainer.add(activatedShadows);
List<ShadowType> shadowsToActivate = getShadowsToActivate();
if (shadowsToActivate.isEmpty()) {
LOGGER.error("No accounts to validate for user {}", userModel.getObject());
getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
throw new RestartResponseException(PageLogin.class);
}
for (ShadowType shadow : shadowsToActivate) {
Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
activatedShadows.add(shadowDesc);
}
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class PageRegistrationConfirmation method initLayout.
private void initLayout(final OperationResult result) {
WebMarkupContainer successPanel = new WebMarkupContainer(ID_SUCCESS_PANEL);
add(successPanel);
successPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return result.getStatus() != OperationResultStatus.FATAL_ERROR;
}
@Override
public boolean isEnabled() {
return result.getStatus() != OperationResultStatus.FATAL_ERROR;
}
});
Label successMessage = new Label(ID_LABEL_SUCCESS, createStringResource("PageRegistrationConfirmation.confirmation.successful"));
successPanel.add(successMessage);
AjaxLink<String> continueToLogin = new AjaxLink<String>(ID_LINK_LOGIN) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(PageLogin.class);
}
};
successPanel.add(continueToLogin);
WebMarkupContainer errorPanel = new WebMarkupContainer(ID_ERROR_PANEL);
add(errorPanel);
errorPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return result.getStatus() == OperationResultStatus.FATAL_ERROR;
}
@Override
public boolean isVisible() {
return result.getStatus() == OperationResultStatus.FATAL_ERROR;
}
});
Label errorMessage = new Label(ID_LABEL_ERROR, createStringResource("PageRegistrationConfirmation.confirmation.error"));
errorPanel.add(errorMessage);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class OperationResultPanel method initHeader.
private void initHeader(WebMarkupContainer box) {
WebMarkupContainer iconType = new WebMarkupContainer(ID_ICON_TYPE);
iconType.setOutputMarkupId(true);
iconType.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
StringBuilder sb = new StringBuilder();
OpResult message = getModelObject();
switch(message.getStatus()) {
case IN_PROGRESS:
case NOT_APPLICABLE:
sb.append(" fa-info");
break;
case SUCCESS:
sb.append(" fa-check");
break;
case FATAL_ERROR:
sb.append(" fa-ban");
break;
case PARTIAL_ERROR:
case UNKNOWN:
case WARNING:
case HANDLED_ERROR:
default:
sb.append(" fa-warning");
}
return sb.toString();
}
}));
box.add(iconType);
Label message = createMessage();
AjaxLink<String> showMore = new AjaxLink<String>(ID_MESSAGE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
OpResult result = OperationResultPanel.this.getModelObject();
result.setShowMore(!result.isShowMore());
// hack to be able to expand/collapse OpResult after rendered.
result.setAlreadyShown(false);
target.add(OperationResultPanel.this);
}
};
showMore.add(message);
box.add(showMore);
AjaxLink<String> backgroundTask = new AjaxLink<String>(ID_BACKGROUND_TASK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
final OpResult opResult = OperationResultPanel.this.getModelObject();
String oid = opResult.getBackgroundTaskOid();
if (oid == null || !opResult.isBackgroundTaskVisible()) {
// just for safety
return;
}
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.TASK);
WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
}
};
backgroundTask.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getBackgroundTaskOid() != null && getModelObject().isBackgroundTaskVisible();
}
});
box.add(backgroundTask);
AjaxLink<String> showAll = new AjaxLink<String>(ID_SHOW_ALL) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideAll(true, OperationResultPanel.this.getModelObject(), target);
}
};
showAll.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !OperationResultPanel.this.getModelObject().isShowMore();
}
});
box.add(showAll);
AjaxLink<String> hideAll = new AjaxLink<String>(ID_HIDE_ALL) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideAll(false, OperationResultPanel.this.getModel().getObject(), target);
}
};
hideAll.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return OperationResultPanel.this.getModelObject().isShowMore();
}
});
box.add(hideAll);
AjaxLink<String> close = new AjaxLink<String>("close") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
close(target);
}
};
box.add(close);
DownloadLink downloadXml = new DownloadLink("downloadXml", new AbstractReadOnlyModel<File>() {
private static final long serialVersionUID = 1L;
@Override
public File getObject() {
String home = getPageBase().getMidpointConfiguration().getMidpointHome();
File f = new File(home, "result");
DataOutputStream dos = null;
try {
dos = new DataOutputStream(new FileOutputStream(f));
dos.writeBytes(OperationResultPanel.this.getModel().getObject().getXml());
} catch (IOException e) {
LOGGER.error("Could not download result: {}", e.getMessage(), e);
} finally {
IOUtils.closeQuietly(dos);
}
return f;
}
});
downloadXml.setDeleteAfterDownload(true);
box.add(downloadXml);
}
Aggregations