use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class DoubleButtonPanel method initLayout.
private void initLayout() {
AjaxButton firstButton = new AjaxButton(ID_BUTTON_FIRST, createButtonStringResource(getFirstCaption())) {
@Override
public void onClick(AjaxRequestTarget target) {
firstPerformed(target, DoubleButtonPanel.this.getModel());
}
@Override
public boolean isEnabled() {
return isFirstEnabled(DoubleButtonPanel.this.getModel());
}
};
firstButton.add(new AttributeAppender("class", getFirstCssClass()));
AjaxButton secondButton = new AjaxButton(ID_BUTTON_SECOND, createButtonStringResource(getSecondCaption())) {
@Override
public void onClick(AjaxRequestTarget target) {
secondPerformed(target, DoubleButtonPanel.this.getModel());
}
@Override
public boolean isEnabled() {
return isSecondEnabled(DoubleButtonPanel.this.getModel());
}
};
secondButton.add(new AttributeAppender("class", getSecondCssClass()));
add(firstButton);
add(secondButton);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class MetadataPanel method initLayout.
private void initLayout() {
WebMarkupContainer metadataBlock = new WebMarkupContainer(ID_METADATA_BLOCK);
metadataBlock.setOutputMarkupId(true);
add(metadataBlock);
WebMarkupContainer headerContainer = new WebMarkupContainer(ID_HEADER_CONTAINER);
headerContainer.setOutputMarkupId(true);
headerContainer.add(new AttributeAppender("class", "prism-header " + additionalHeaderStyle));
metadataBlock.add(headerContainer);
Label metadataHeader = new Label(ID_METADATA_LABEL, createStringResource("AssignmentEditorPanel.metadataBlock", header != null ? header : ""));
metadataHeader.setOutputMarkupId(true);
headerContainer.add(metadataHeader);
RepeatingView metadataRowRepeater = new RepeatingView(ID_METADATA_ROW);
metadataBlock.add(metadataRowRepeater);
for (QName qname : metadataFieldsList) {
WebMarkupContainer metadataRow = new WebMarkupContainer(metadataRowRepeater.newChildId());
metadataRow.setOutputMarkupId(true);
if (metadataFieldsList.indexOf(qname) % 2 != 0) {
metadataRow.add(new AttributeAppender("class", "stripe"));
}
metadataRowRepeater.add(metadataRow);
metadataRow.add(new Label(ID_METADATA_PROPERTY_KEY, createStringResource(DOT_CLASS + qname.getLocalPart())));
AbstractReadOnlyModel<String> metadataFieldModel = new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PropertyModel<Object> tempModel = new PropertyModel<Object>(getModel(), qname.getLocalPart());
if (tempModel.getObject() instanceof XMLGregorianCalendar) {
return WebComponentUtil.getLocalizedDate((XMLGregorianCalendar) tempModel.getObject(), DateLabelComponent.MEDIUM_MEDIUM_STYLE);
} else if (tempModel.getObject() instanceof ObjectReferenceType) {
ObjectReferenceType ref = (ObjectReferenceType) tempModel.getObject();
return WebComponentUtil.getName(ref, getPageBase(), OPERATION_LOAD_USER);
} else if (tempModel.getObject() instanceof List) {
List list = (List) tempModel.getObject();
String result = "";
for (Object o : list) {
if (o instanceof ObjectReferenceType) {
if (result.length() > 0) {
result += ", ";
}
result += WebComponentUtil.getName((ObjectReferenceType) o, getPageBase(), OPERATION_LOAD_USER);
}
}
return result;
}
return "";
}
};
metadataRow.add(new Label(ID_METADATA_FILED, metadataFieldModel));
metadataRow.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return StringUtils.isNotEmpty(metadataFieldModel.getObject());
}
});
}
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class NameStep method createConnectorDropDown.
private DropDownFormGroup<PrismObject<ConnectorType>> createConnectorDropDown() {
return new DropDownFormGroup<PrismObject<ConnectorType>>(ID_CONNECTOR, selectedConnectorModel, relevantConnectorsModel, new IChoiceRenderer<PrismObject<ConnectorType>>() {
@Override
public PrismObject<ConnectorType> getObject(String id, IModel<? extends List<? extends PrismObject<ConnectorType>>> choices) {
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
}
@Override
public Object getDisplayValue(PrismObject<ConnectorType> object) {
return WebComponentUtil.getName(object);
}
@Override
public String getIdValue(PrismObject<ConnectorType> object, int index) {
return Integer.toString(index);
}
}, createStringResource("NameStep.connectorType"), "col-md-3", "col-md-6", true) {
@Override
protected DropDownChoice<PrismObject<ConnectorType>> createDropDown(String id, IModel<List<PrismObject<ConnectorType>>> choices, IChoiceRenderer<PrismObject<ConnectorType>> renderer, boolean required) {
DropDownChoice<PrismObject<ConnectorType>> choice = super.createDropDown(id, choices, renderer, required);
choice.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(getConnectorDropDown().getAdditionalInfoComponent());
}
});
choice.setOutputMarkupId(true);
return choice;
}
@Override
protected Component createAdditionalInfoComponent(String id) {
Label l = new Label(id, schemaChangeWarningModel);
l.add(new AttributeAppender("class", "text-danger"));
l.setOutputMarkupId(true);
return l;
}
};
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class AuditLogViewerPanel method addOrReplaceTable.
private void addOrReplaceTable(Form mainForm) {
AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {
private static final long serialVersionUID = 1L;
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<String, Object>();
AuditSearchDto search = auditSearchDto.getObject();
parameters.put("from", search.getFrom());
parameters.put("to", search.getTo());
if (search.getChannel() != null) {
parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
}
parameters.put("hostIdentifier", search.getHostIdentifier());
if (search.getInitiatorName() != null) {
parameters.put("initiatorName", search.getInitiatorName().getOid());
}
if (search.getTargetOwnerName() != null) {
parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
}
List<String> targetOids = new ArrayList<>();
if (isNotEmpty(search.getTargetNamesObjects())) {
targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
}
if (isNotEmpty(search.getTargetNames())) {
targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
}
if (!targetOids.isEmpty()) {
parameters.put("targetNames", targetOids);
}
if (search.getChangedItem().toItemPath() != null) {
ItemPath itemPath = search.getChangedItem().toItemPath();
parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
}
parameters.put("eventType", search.getEventType());
parameters.put("eventStage", search.getEventStage());
parameters.put("outcome", search.getOutcome());
if (isNotEmpty(search.getvalueRefTargetNames())) {
parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
}
return parameters;
}
@Override
protected void saveCurrentPage(long from, long count) {
if (count != 0) {
auditLogStorage.setPageNumber(from / count);
}
}
};
UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
int pageSize = DEFAULT_PAGE_SIZE;
if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
}
List<IColumn<AuditEventRecordType, String>> columns = initColumns();
BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
CSVDataExporter csvDataExporter = new CSVDataExporter() {
@Override
public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
((AuditEventRecordProvider) dataProvider).setExportSize(true);
super.exportData(dataProvider, columns, outputStream);
((AuditEventRecordProvider) dataProvider).setExportSize(false);
}
};
ResourceStreamResource resource = (new ResourceStreamResource() {
protected IResourceStream getResourceStream() {
return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
}
}).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
return exportDataLink;
}
@Override
public void setShowPaging(boolean show) {
//we don't need to do anything here
}
};
table.setShowPaging(true);
table.setCurrentPage(auditLogStorage.getPageNumber());
table.setOutputMarkupId(true);
mainForm.addOrReplace(table);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class JasperReportConfigurationPanel method createTextPanel.
@SuppressWarnings({ "rawtypes", "unchecked" })
private <J> Component createTextPanel(String componentId, final IModel<J> model, String expression, final Boolean mandatory) {
TextPanel<String> textPanel = new TextPanel<String>(componentId, new PropertyModel<String>(model, expression));
FormComponent input = textPanel.getBaseFormComponent();
input.add(new AttributeAppender("style", "width: 100%"));
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
input.add(new IValidator() {
private static final long serialVersionUID = 1L;
@Override
public void validate(IValidatable validatable) {
if (!mandatory) {
return;
}
if (validatable.getValue() == null) {
validatable.error(new ValidationError("JasperReportConfigurationPanel.errormsg"));
}
}
});
return textPanel;
}
Aggregations