Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding column for outcome of CaseType to cases default columns (creat…
…ing of panel with icon and count) (MID-6629)
- Loading branch information
Showing
6 changed files
with
266 additions
and
25 deletions.
There are no files selected for viewing
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
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
48 changes: 48 additions & 0 deletions
48
...in-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/CountIconColumn.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,48 @@ | ||
/* | ||
* Copyright (c) 2010-2018 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.web.component.data.column; | ||
|
||
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; | ||
import org.apache.wicket.markup.html.WebMarkupContainer; | ||
import org.apache.wicket.markup.repeater.Item; | ||
import org.apache.wicket.model.IModel; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author skublik | ||
*/ | ||
public abstract class CountIconColumn<T> extends AbstractColumn<T, String> {//implements IExportableColumn<T, String> { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public CountIconColumn(IModel<String> displayModel) { | ||
super(displayModel); | ||
} | ||
|
||
public CountIconColumn(IModel<String> displayModel, String sortProperty) { | ||
super(displayModel, sortProperty); | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, IModel<T> rowModel) { | ||
Map<DisplayType, Integer> map = getIconDisplayType(rowModel); | ||
if (map != null) { | ||
cellItem.add(new CountIconPanel(componentId, getIconDisplayType(rowModel))); | ||
} else { | ||
cellItem.add(new WebMarkupContainer(componentId)); | ||
} | ||
} | ||
|
||
protected abstract Map<DisplayType, Integer> getIconDisplayType(final IModel<T> rowModel); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...min-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/CountIconPanel.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,18 @@ | ||
<!-- | ||
~ Copyright (c) 2010-2013 Evolveum | ||
~ | ||
~ 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 wicket:id="icons"> | ||
<div style="display: inline-block; float: left; padding-right: 10px;" > | ||
<i style="float: left; margin-top: 2px;" wicket:id="icon"/> | ||
<div style="float: left;" wicket:id="count"/> | ||
</div> | ||
</div> | ||
</wicket:panel> | ||
</html> |
96 changes: 96 additions & 0 deletions
96
...min-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/CountIconPanel.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,96 @@ | ||
/* | ||
* Copyright (C) 2010-2020 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.web.component.data.column; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel; | ||
import com.evolveum.midpoint.web.component.util.VisibleBehaviour; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.IconType; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.behavior.AttributeAppender; | ||
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.Model; | ||
import org.apache.wicket.model.PropertyModel; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* @author skublik | ||
*/ | ||
public class CountIconPanel extends BasePanel<List<DisplayType>> { | ||
|
||
private static final String ID_ICONS = "icons"; | ||
private static final String ID_COUNT = "count"; | ||
private static final String ID_ICON = "icon"; | ||
|
||
private Map<DisplayType, Integer> icons; | ||
|
||
public CountIconPanel(String id, Map<DisplayType, Integer> icons) { | ||
super(id, new Model()); | ||
this.icons = icons; | ||
getModel().setObject(new ArrayList<>(icons.keySet())); | ||
} | ||
|
||
@Override | ||
protected void onInitialize() { | ||
super.onInitialize(); | ||
initLayout(); | ||
} | ||
|
||
private void initLayout() { | ||
|
||
getModelObject().sort((d1, d2) -> { | ||
if (d1 == null || d1.getIcon() == null || d1.getIcon().getCssClass() == null | ||
|| d2 == null || d2.getIcon() == null || d2.getIcon().getCssClass() == null) { | ||
return 0; | ||
} | ||
return d1.getIcon().getCssClass().compareTo(d2.getIcon().getCssClass()); | ||
}); | ||
|
||
ListView<DisplayType> iconsPanel = new ListView<DisplayType>(ID_ICONS, getModel()) { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
protected void populateItem(ListItem<DisplayType> item) { | ||
Label icon = new Label(ID_ICON); | ||
icon.add(AttributeModifier.replace("class", new PropertyModel<>(item.getModel(), "icon.cssClass"))); | ||
if (item.getModelObject() != null && item.getModelObject().getTooltip() != null) { | ||
icon.add(AttributeModifier.replace("title", getPageBase().createStringResource(item.getModelObject().getTooltip().getOrig()))); | ||
} | ||
icon.add(AttributeAppender.append("style", | ||
new ReadOnlyModel<>(() -> StringUtils.isNotBlank(getColor(item.getModelObject())) ? "color: " + getColor(item.getModelObject()) + ";" : ""))); | ||
icon.setOutputMarkupId(true); | ||
icon.add(new VisibleBehaviour(() -> item.getModelObject() != null && item.getModelObject().getIcon() != null && StringUtils.isNotEmpty(item.getModelObject().getIcon().getCssClass()))); | ||
item.add(icon); | ||
|
||
Integer count = icons.get(item.getModelObject()); | ||
Label countPanel = new Label(ID_COUNT, Model.of(count)); | ||
item.add(countPanel); | ||
} | ||
}; | ||
add(iconsPanel); | ||
} | ||
|
||
private String getColor(DisplayType displayType) { | ||
if (displayType == null) { | ||
return null; | ||
} | ||
|
||
IconType icon = displayType.getIcon(); | ||
if (icon == null) { | ||
return null; | ||
} | ||
|
||
return icon.getColor(); | ||
} | ||
} |
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