-
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.
- Loading branch information
Showing
5 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/MyNodeBorder.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-2022 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 org.apache.wicket.Component; | ||
import org.apache.wicket.behavior.Behavior; | ||
import org.apache.wicket.request.Response; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MyNodeBorder extends Behavior { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private boolean[] branches; | ||
|
||
public MyNodeBorder(boolean[] branches) { | ||
this.branches = branches; | ||
} | ||
|
||
@Override | ||
public void beforeRender(Component component) { | ||
Response response = component.getResponse(); | ||
|
||
for (int i = 0; i < branches.length; i++) { | ||
if (i > 0) { | ||
response.write("<div class=\"ml-4\">"); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void afterRender(Component component) { | ||
Response response = component.getResponse(); | ||
|
||
for (int i = 0; i < branches.length; i++) { | ||
if (i > 0) { | ||
response.write("</div>"); | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...n-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/MyTableTree.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,46 @@ | ||
/* | ||
* Copyright (c) 2010-2022 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 java.util.Set; | ||
|
||
import org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.Component; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; | ||
import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider; | ||
import org.apache.wicket.extensions.markup.html.repeater.tree.TableTree; | ||
import org.apache.wicket.markup.repeater.data.IDataProvider; | ||
import org.apache.wicket.model.IModel; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MyTableTree<T, S> extends TableTree<T, S> { | ||
|
||
public MyTableTree(String id, List<? extends IColumn<T, S>> columns, ITreeProvider<T> provider, long rowsPerPage) { | ||
this(id, columns, provider, rowsPerPage, null); | ||
} | ||
|
||
public MyTableTree(String id, List<? extends IColumn<T, S>> columns, ITreeProvider<T> provider, long rowsPerPage, IModel<? extends Set<T>> state) { | ||
super(id, columns, provider, rowsPerPage, state); | ||
} | ||
|
||
@Override | ||
public Component newContentComponent(String id, IModel<T> model) { | ||
return new MyTreeColumnPanel<>(id, this, model); | ||
} | ||
|
||
@Override | ||
protected DataTable<T, S> newDataTable(String id, List<? extends IColumn<T, S>> iColumns, IDataProvider<T> dataProvider, long rowsPerPage) { | ||
DataTable<T, S> table = super.newDataTable(id, iColumns, dataProvider, rowsPerPage); | ||
table.add(AttributeModifier.replace("class", "table")); | ||
return table; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...-gui/src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/MyTreeColumn.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,39 @@ | ||
/* | ||
* Copyright (c) 2010-2022 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 org.apache.wicket.Component; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; | ||
import org.apache.wicket.extensions.markup.html.repeater.tree.table.NodeModel; | ||
import org.apache.wicket.extensions.markup.html.repeater.tree.table.TreeColumn; | ||
import org.apache.wicket.markup.repeater.Item; | ||
import org.apache.wicket.model.IModel; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MyTreeColumn<T, S> extends TreeColumn<T, S> { | ||
|
||
public MyTreeColumn(IModel<String> displayModel) { | ||
super(displayModel); | ||
} | ||
|
||
public MyTreeColumn(IModel<String> displayModel, S sortProperty) { | ||
super(displayModel, sortProperty); | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<T>> item, String id, IModel<T> rowModel) { | ||
NodeModel<T> model = (NodeModel<T>) rowModel; | ||
|
||
Component component = getTree().newNodeComponent(id, model.getWrappedModel()); | ||
component.add(new MyNodeBorder(model.getBranches())); | ||
|
||
item.add(component); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/MyTreeColumnPanel.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,16 @@ | ||
<!-- | ||
~ Copyright (c) 2022 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> | ||
<a href="#" class="text-body" wicket:id="link"> | ||
<i wicket:id="chevron"/> | ||
<i class="ml-3" wicket:id="icon"/> | ||
<span class="ml-2" wicket:id="label"/> | ||
</a> | ||
</wicket:panel> | ||
</html> |
105 changes: 105 additions & 0 deletions
105
...src/main/java/com/evolveum/midpoint/gui/impl/page/admin/simulation/MyTreeColumnPanel.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,105 @@ | ||
/* | ||
* Copyright (c) 2010-2022 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 org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.ajax.markup.html.AjaxLink; | ||
import org.apache.wicket.extensions.markup.html.repeater.tree.AbstractTree; | ||
import org.apache.wicket.markup.html.WebComponent; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.model.IModel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
import com.evolveum.midpoint.web.component.util.VisibleBehaviour; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class MyTreeColumnPanel<T> extends BasePanel<T> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private static final String ID_LINK = "link"; | ||
private static final String ID_CHEVRON = "chevron"; | ||
private static final String ID_ICON = "icon"; | ||
private static final String ID_LABEL = "label"; | ||
|
||
private final AbstractTree<T> tree; | ||
|
||
public MyTreeColumnPanel(@NotNull String id, @NotNull AbstractTree<T> tree, @NotNull IModel<T> model) { | ||
super(id, model); | ||
|
||
this.tree = tree; | ||
|
||
initLayout(); | ||
} | ||
|
||
private void initLayout() { | ||
AjaxLink<T> link = new AjaxLink<>(ID_LINK) { | ||
|
||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
onClickPerformed(target); | ||
} | ||
}; | ||
add(link); | ||
|
||
WebComponent chevron = new WebComponent(ID_CHEVRON); | ||
chevron.add(AttributeModifier.append("class", () -> getChevronCss(getModel()))); | ||
link.add(chevron); | ||
|
||
WebComponent icon = new WebComponent(ID_ICON); | ||
icon.add(AttributeModifier.append("class", () -> getIconCss(getModel()))); | ||
icon.add(new VisibleBehaviour(() -> getIconCss(getModel()) != null)); | ||
link.add(icon); | ||
|
||
Label label = new Label(ID_LABEL, getModel()); | ||
link.add(label); | ||
} | ||
|
||
protected String getIconCss(IModel<T> model) { | ||
return null; | ||
} | ||
|
||
protected String getChevronCss(IModel<T> model) { | ||
T t = model.getObject(); | ||
|
||
String cssClass = ""; | ||
if (tree.getProvider().hasChildren(t)) { | ||
if (tree.getState(t) == AbstractTree.State.EXPANDED) { | ||
cssClass = "fa fa-chevron-down"; | ||
} else { | ||
cssClass = "fa fa-chevron-right"; | ||
} | ||
} else { | ||
cssClass = "fa fa-chevron-right invisible"; | ||
} | ||
|
||
if (isSelected()) { | ||
cssClass += " active"; | ||
} | ||
|
||
return cssClass; | ||
} | ||
|
||
protected boolean isSelected() { | ||
return false; | ||
} | ||
|
||
protected void onClickPerformed(AjaxRequestTarget target) { | ||
T t = getModelObject(); | ||
|
||
if (tree.getState(t) == AbstractTree.State.EXPANDED) { | ||
tree.collapse(t); | ||
} else { | ||
tree.expand(t); | ||
} | ||
} | ||
} |