-
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
7 changed files
with
237 additions
and
50 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...in-gui/src/main/java/com/evolveum/midpoint/gui/api/component/progressbar/ProgressBar.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,61 @@ | ||
package com.evolveum.midpoint.gui.api.component.progressbar; | ||
|
||
import com.evolveum.midpoint.util.LocalizableMessage; | ||
|
||
public class ProgressBar { | ||
|
||
public enum State { | ||
|
||
SUCCESS("bg-success"), | ||
INFO("bg-info"), | ||
DANGER("bg-danger"), | ||
WARNINIG("bg-warning"), | ||
SECONDARY("bg-secondary"), | ||
PRIMARY("bg-primary"); | ||
|
||
private String cssClass; | ||
|
||
State(String cssClass) { | ||
this.cssClass = cssClass; | ||
} | ||
|
||
public String getCssClass() { | ||
return cssClass; | ||
} | ||
} | ||
|
||
private double value; | ||
|
||
private State state; | ||
|
||
private LocalizableMessage text; | ||
|
||
public ProgressBar(double value, State state) { | ||
this.value = value; | ||
this.state = state; | ||
} | ||
|
||
public double getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(double value) { | ||
this.value = value; | ||
} | ||
|
||
public State getState() { | ||
return state; | ||
} | ||
|
||
public void setState(State state) { | ||
this.state = state; | ||
} | ||
|
||
public LocalizableMessage getText() { | ||
return text; | ||
} | ||
|
||
public void setText(LocalizableMessage text) { | ||
this.text = text; | ||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
...i/src/main/java/com/evolveum/midpoint/gui/api/component/progressbar/ProgressBarPanel.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,67 @@ | ||
/* | ||
* Copyright (c) 2016-2021 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.api.component.progressbar; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.behavior.AttributeAppender; | ||
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; | ||
|
||
/** | ||
* @author semancik | ||
*/ | ||
public class ProgressBarPanel extends BasePanel<List<ProgressBar>> { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private static final String ID_BARS = "bars"; | ||
private static final String ID_BAR = "bar"; | ||
private static final String ID_TEXT = "text"; | ||
|
||
public ProgressBarPanel(String id, IModel<List<ProgressBar>> model) { | ||
super(id, model); | ||
|
||
initLayout(); | ||
} | ||
|
||
@Override | ||
protected void onComponentTag(ComponentTag tag) { | ||
super.onComponentTag(tag); | ||
|
||
checkComponentTag(tag, "div"); | ||
} | ||
|
||
private void initLayout() { | ||
add(AttributeAppender.append("class", "progress rounded")); | ||
|
||
ListView<ProgressBar> bars = new ListView<>(ID_BARS, getModelObject()) { | ||
@Override | ||
protected void populateItem(ListItem<ProgressBar> item) { | ||
item.add(createBar(ID_BAR, item.getModel())); | ||
} | ||
}; | ||
add(bars); | ||
|
||
Label text = new Label(ID_TEXT); | ||
add(text); | ||
} | ||
|
||
private Component createBar(String id, IModel<ProgressBar> model) { | ||
WebComponent bar = new WebComponent(id); | ||
bar.add(AttributeAppender.append("class", () -> model.getObject().getState().getCssClass())); | ||
bar.add(AttributeAppender.append("style", () -> "width: " + model.getObject().getValue() + "%;")); | ||
|
||
return bar; | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
...i/src/main/java/com/evolveum/midpoint/gui/api/component/progressbar/ProgressbarPanel.java
This file was deleted.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
...-gui/src/main/java/com/evolveum/midpoint/web/component/data/column/ProgressBarColumn.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,32 @@ | ||
package com.evolveum.midpoint.web.component.data.column; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
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.repeater.Item; | ||
import org.apache.wicket.model.IModel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.gui.api.component.progressbar.ProgressBar; | ||
import com.evolveum.midpoint.gui.api.component.progressbar.ProgressBarPanel; | ||
|
||
public class ProgressBarColumn<R extends Serializable, S extends Serializable> extends AbstractColumn<R, S> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public ProgressBarColumn(IModel<String> displayModel) { | ||
super(displayModel); | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<R>> item, String id, IModel<R> rowModel) { | ||
item.add(new ProgressBarPanel(id, createProgressBarModel(rowModel))); | ||
} | ||
|
||
protected @NotNull IModel<List<ProgressBar>> createProgressBarModel(IModel<R> rowModel) { | ||
return () -> new ArrayList<>(); | ||
} | ||
} |
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