-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
27 changed files
with
922 additions
and
391 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
.../src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/DetailsTableItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/DetailsTablePanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
83 changes: 83 additions & 0 deletions
83
...src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/DetailsTablePanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...rc/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/GuiSimulationsUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.