use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class OrgTreeFolderContent method initLayout.
private void initLayout() {
SelectableFolderContent folder = new SelectableFolderContent(ID_FOLDER, tree, getModel(), selected) {
private static final long serialVersionUID = 1L;
@Override
protected void onClick(Optional<AjaxRequestTarget> target) {
super.onClick(target);
OrgTreeFolderContent.this.setSelectedItem(selected.getObject(), orgTreeStorage);
selectTreeItemPerformed(selected.getObject(), target.get());
Component component = get("table");
if (component != null) {
target.get().add(component);
}
}
};
folder.setOutputMarkupId(true);
addOrReplace(folder);
if (selected.getObject().equals(getModelObject())) {
getParent().add(AttributeAppender.append("class", "success"));
} else {
getParent().add(new AttributeAppender("class", "success", " ") {
@Override
protected Serializable newValue(String currentValue, String removeValue) {
currentValue = getSeparator() + currentValue + getSeparator();
removeValue = getSeparator() + removeValue + getSeparator();
return currentValue.replace(removeValue, getSeparator());
}
});
}
MenuMultiButtonPanel<OrgType> menuButtons = new MenuMultiButtonPanel<>(ID_MENU, new PropertyModel<>(getModel(), TreeSelectableBean.F_VALUE), 2, createInlineMenuItemsModel());
menuButtons.setOutputMarkupId(true);
addOrReplace(menuButtons);
CheckBoxPanel checkBoxPanel = new CheckBoxPanel(ID_CHECK, getCheckboxModel(getModel())) {
@Override
public void onUpdate(AjaxRequestTarget target) {
getModelObject().setSelected(!getModelObject().isSelected());
OrgTreeFolderContent.this.onUpdateCheckbox(target);
}
};
checkBoxPanel.add(new VisibleBehaviour(() -> selectable));
addOrReplace(checkBoxPanel);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class DashboardPanel method initLayout.
private void initLayout(IModel<String> titleModel, String icon, String boxCssClasses) {
if (boxCssClasses == null) {
boxCssClasses = GuiStyleConstants.CLASS_BOX_DEFAULT;
}
WebMarkupContainer dashboardParent = new WebMarkupContainer(ID_DASHBOARD_PARENT);
dashboardParent.add(new AttributeAppender("class", " " + boxCssClasses));
add(dashboardParent);
WebMarkupContainer dashboardTitle = new WebMarkupContainer(ID_DASHBOARD_TITLE);
dashboardParent.add(dashboardTitle);
Label title = new Label(ID_TITLE);
title.setRenderBodyOnly(true);
title.setDefaultModel(titleModel);
dashboardTitle.add(title);
WebMarkupContainer dashboardContent = new WebMarkupContainer(ID_DASHBOARD_CONTENT);
dashboardContent.add(getMainComponent(ID_CONTENT));
dashboardParent.add(dashboardContent);
WebMarkupContainer iconI = new WebMarkupContainer(ID_ICON);
iconI.add(AttributeModifier.replace("class", icon));
dashboardTitle.add(iconI);
}
use of org.apache.wicket.behavior.AttributeAppender 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 IModel<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> aCase = new AjaxLink<String>(ID_CASE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
final OpResult opResult = OperationResultPanel.this.getModelObject();
String oid = opResult.getCaseOid();
if (oid == null || !opResult.isCaseVisible()) {
// just for safety
return;
}
ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.CASE);
WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
}
};
aCase.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getCaseOid() != null && getModelObject().isCaseVisible();
}
});
box.add(aCase);
AjaxLink<String> showAll = new AjaxLink<String>(ID_SHOW_ALL) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideAll(true, 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, 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 IModel<File>() {
private static final long serialVersionUID = 1L;
@Override
public File getObject() {
String home = getPageBase().getMidpointConfiguration().getMidpointHome();
File f = new File(home, "result");
try (DataOutputStream 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);
}
return f;
}
});
downloadXml.add(new VisibleBehaviour(() -> getModelObject().isParent()));
downloadXml.setDeleteAfterDownload(true);
box.add(downloadXml);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class ValidationErrorPanel method initHeader.
private void initHeader(WebMarkupContainer box) {
WebMarkupContainer iconType = new WebMarkupContainer("iconType");
iconType.setOutputMarkupId(true);
iconType.add(new AttributeAppender("class", new IModel() {
@Override
public Object getObject() {
FeedbackMessage result = getModelObject();
if (result == null) {
return " fa-info";
}
switch(result.getLevel()) {
case FeedbackMessage.INFO:
case FeedbackMessage.DEBUG:
return " fa-info";
case FeedbackMessage.SUCCESS:
return " fa-check";
case FeedbackMessage.ERROR:
case FeedbackMessage.FATAL:
return " fa-ban";
case FeedbackMessage.UNDEFINED:
// TODO:
case FeedbackMessage.WARNING:
default:
return " fa-warning";
}
}
}));
box.add(iconType);
Label message = new Label(ID_MESSAGE, new PropertyModel<Serializable>(getModel(), "message"));
box.add(message);
AjaxLink<Void> close = new AjaxLink<Void>("close") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
close(target);
}
};
box.add(close);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class UserSelectionButton method initLayout.
private void initLayout() {
AjaxLink<String> userSelectionButton = new AjaxLink<String>(ID_USER_SELECTION_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
}
@Override
public void onClick(AjaxRequestTarget target) {
if (showUserSelectionPopup) {
initUserSelectionPopup(target);
}
showUserSelectionPopup = true;
}
};
userSelectionButton.add(AttributeModifier.append("class", getTargetUserButtonClass()));
userSelectionButton.setOutputMarkupId(true);
userSelectionButton.add(new AttributeAppender("title", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getUserSelectionButtonTitle();
}
}));
add(userSelectionButton);
Label label = new Label(ID_USER_SELECTION_BUTTON_LABEL, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getUserButtonLabel();
}
});
label.setRenderBodyOnly(true);
userSelectionButton.add(label);
AjaxLink<Void> deleteButton = new AjaxLink<Void>(ID_DELETE_SELECTED_USER_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
UserSelectionButton.this.onDeleteSelectedUsersPerformed(target);
}
};
deleteButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isDeleteButtonVisible();
}
});
userSelectionButton.add(deleteButton);
}
Aggregations