Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 6, 2023
2 parents 6bc540e + 06e77b0 commit f64ee4e
Show file tree
Hide file tree
Showing 27 changed files with 922 additions and 391 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.admin.simulation;

import java.io.Serializable;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

/**
* Created by Viliam Repan (lazyman).
*/
public class DetailsTableItem implements Serializable {

private IModel<String> label;

private IModel<String> value;

public DetailsTableItem(IModel<String> label, IModel<String> value) {
this.label = label;
this.value = value;
}

public IModel<String> getLabel() {
return label;
}

public IModel<String> getValue() {
return value;
}

public Component createValueComponent(String id) {
Label label = new Label(id, value);
label.setRenderBodyOnly(true);
return label;
}

public VisibleBehaviour isVisible() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
~ Copyright (c) 2010-2023 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="card-header d-flex gap-2 align-items-center">
<i class="mr-1" wicket:id="icon"/>
<h5 class="mb-0" wicket:id="title"/>
</div>
<div class="card-body p-0">
<table class="table">
<tr wicket:id="details">
<td wicket:id="label"/>
<td><span wicket:id="value"/></td>
</tr>
</table>
</div>
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.admin.simulation;

import java.util.List;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

/**
* Created by Viliam Repan (lazyman).
*/
public class DetailsTablePanel extends BasePanel<List<DetailsTableItem>> {

private static final long serialVersionUID = 1L;

private static final String ID_ICON = "icon";
private static final String ID_TITLE = "title";
private static final String ID_DETAILS = "details";
private static final String ID_LABEL = "label";
private static final String ID_VALUE = "value";

private IModel<String> iconCssClass;

private IModel<String> title;

public DetailsTablePanel(String id, IModel<String> iconCssClass, IModel<String> title, IModel<List<DetailsTableItem>> model) {
super(id, model);

this.iconCssClass = iconCssClass;
this.title = title;

initLayout();
}

@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);

checkComponentTag(tag, "div");
}

private void initLayout() {
add(AttributeModifier.append("class", "card"));

WebComponent icon = new WebComponent(ID_ICON);
icon.add(AttributeModifier.append("class", iconCssClass));
icon.add(new VisibleBehaviour(() -> iconCssClass.getObject() != null));
add(icon);

Label title = new Label(ID_TITLE, this.title);
title.add(new VisibleBehaviour(() -> this.title.getObject() != null));
add(title);

ListView<DetailsTableItem> details = new ListView<>(ID_DETAILS, getModel()) {

@Override
protected void populateItem(ListItem<DetailsTableItem> item) {
DetailsTableItem data = item.getModelObject();
item.add(new Label(ID_LABEL, () -> data.getLabel().getObject()));
item.add(data.createValueComponent(ID_VALUE));

if (data.isVisible() != null) {
item.add(data.isVisible());
}
}
};
add(details);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.admin.simulation;

import javax.xml.namespace.QName;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.gui.api.component.Badge;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectProcessingStateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SimulationResultProcessedObjectType;

/**
* Created by Viliam Repan (lazyman).
*/
public class GuiSimulationsUtil {

//todo move elsewhere
@Deprecated
public StringResourceModel createStringResource(String resourceKey, IModel<?> model, Object... objects) {
return new StringResourceModel(resourceKey).setModel(model)
.setDefaultValue(resourceKey)
.setParameters(objects);
}

//todo move elsewhere
@Deprecated
public static String getString(Component component, String key, Object... params) {
return new StringResourceModel(key, component)
.setDefaultValue(key)
.setParameters(params).getString();
}

public static Label createProcessedObjectStateLabel(String id, IModel<SimulationResultProcessedObjectType> model) {
Label label = new Label(id, () -> {
ObjectProcessingStateType state = model.getObject().getState();
if (state == null) {
return null;
}

return getString(null, WebComponentUtil.createEnumResourceKey(state));
});
label.add(AttributeModifier.append("class", () -> {
ObjectProcessingStateType state = model.getObject().getState();
if (state == null) {
return null;
}

switch (state) {
case ADDED:
return Badge.State.SUCCESS.getCss();
case DELETED:
return Badge.State.DANGER.getCss();
case MODIFIED:
return Badge.State.INFO.getCss();
case UNMODIFIED:
default:
return Badge.State.SECONDARY.getCss();
}
}));

return label;
}

public static String getProcessedObjectType(@NotNull IModel<SimulationResultProcessedObjectType> model) {
SimulationResultProcessedObjectType object = model.getObject();
if (object == null || object.getType() == null) {
return null;
}

QName type = object.getType();
ObjectTypes ot = ObjectTypes.getObjectTypeFromTypeQName(type);
String key = WebComponentUtil.createEnumResourceKey(ot);

return getString(null, key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,7 @@

<div class="row">
<div class="col-3">
<div class="card">
<div class="card-header d-flex gap-2 align-items-center">
<i class="mr-1 fa-solid fa-circle-question"></i>
<h5 class="mb-0">
<wicket:message key="PageSimulationResult.details"/>
</h5>
</div>
<div class="card-body p-0">
<table class="table">
<tr wicket:id="details">
<td wicket:id="label"/>
<td><span wicket:id="value"/></td>
</tr>
</table>
</div>
</div>
<div wicket:id="details"/>
</div>
<div class="col-9 row gap-3">
<div class="col-2" wicket:id="widgets">
Expand Down

0 comments on commit f64ee4e

Please sign in to comment.