-
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.
adding new expression panel for expression elements of attribute mapping
- Loading branch information
Showing
33 changed files
with
1,095 additions
and
209 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
15 changes: 15 additions & 0 deletions
15
...gui/src/main/java/com/evolveum/midpoint/gui/impl/component/dialog/OnePanelPopupPanel.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,15 @@ | ||
<!-- | ||
~ Copyright (c) 2023 Evolveum | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
<wicket:panel xmlns:wicket="http://wicket.apache.org"> | ||
<div wicket:id="panel"/> | ||
|
||
<div class="d-flex"> | ||
<a wicket:id="doneButton" class="ml-auto btn btn-primary"> | ||
<span><wicket:message key="OnePanelPopupPanel.button.done"/></span> | ||
</a> | ||
</div> | ||
</wicket:panel> |
71 changes: 71 additions & 0 deletions
71
...gui/src/main/java/com/evolveum/midpoint/gui/impl/component/dialog/OnePanelPopupPanel.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,71 @@ | ||
/* | ||
* Copyright (c) 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.component.dialog; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.ajax.markup.html.AjaxLink; | ||
import org.apache.wicket.markup.html.WebMarkupContainer; | ||
|
||
import com.evolveum.midpoint.web.component.dialog.Popupable; | ||
|
||
public abstract class OnePanelPopupPanel extends BasePanel implements Popupable { | ||
private static final String ID_PANEL = "panel"; | ||
private static final String ID_BUTTON_DONE = "doneButton"; | ||
public OnePanelPopupPanel(String id){ | ||
super(id); | ||
initLayout(); | ||
} | ||
|
||
private void initLayout(){ | ||
add(createPanel(ID_PANEL)); | ||
AjaxLink<Void> done = new AjaxLink<>(ID_BUTTON_DONE) { | ||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
processHide(target); | ||
} | ||
}; | ||
add(done); | ||
} | ||
|
||
protected void processHide(AjaxRequestTarget target) { | ||
getPageBase().hideMainPopup(target); | ||
} | ||
|
||
protected Component getPanel () { | ||
return get(ID_PANEL); | ||
} | ||
|
||
protected abstract WebMarkupContainer createPanel(String id); | ||
|
||
@Override | ||
public int getWidth() { | ||
return 400; | ||
} | ||
|
||
@Override | ||
public int getHeight() { | ||
return 600; | ||
} | ||
|
||
@Override | ||
public String getWidthUnit(){ | ||
return "px"; | ||
} | ||
|
||
@Override | ||
public String getHeightUnit(){ | ||
return "px"; | ||
} | ||
|
||
@Override | ||
public Component getContent() { | ||
return this; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...a/com/evolveum/midpoint/gui/impl/component/input/expression/EvaluatorExpressionPanel.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,29 @@ | ||
<!-- | ||
~ Copyright (c) 2023 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="valueContainer"> | ||
<div class="prism-property-label p-0"> | ||
<span wicket:id="valueContainerLabel" /> | ||
<button wicket:id="add" class="btn btn-tool text-primary" trigger="hover"> | ||
<i class="fa fa-plus-circle pr-1"></i> | ||
<wicket:message key="VerticalFormItemHeaderPanel.addValue"/> | ||
</button> | ||
|
||
<button wicket:id="remove" class="btn btn-tool text-danger" trigger="hover"> | ||
<i class="fa fa-eraser pr-1"></i> | ||
<wicket:message key="VerticalFormItemHeaderPanel.removeAll"/> | ||
</button> | ||
</div> | ||
<div class="prism-property-value" wicket:id="valueInput"/> | ||
<span wicket:id="feedback"/> | ||
</div> | ||
</wicket:panel> | ||
</html> | ||
|
165 changes: 165 additions & 0 deletions
165
...a/com/evolveum/midpoint/gui/impl/component/input/expression/EvaluatorExpressionPanel.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,165 @@ | ||
/* | ||
* Copyright (c) 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.component.input.expression; | ||
|
||
import com.evolveum.midpoint.gui.api.component.BasePanel; | ||
import com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel; | ||
import com.evolveum.midpoint.gui.api.model.NonEmptyModel; | ||
import com.evolveum.midpoint.gui.impl.component.message.FeedbackLabels; | ||
import com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel; | ||
import com.evolveum.midpoint.web.component.input.TextPanel; | ||
import com.evolveum.midpoint.web.component.prism.InputPanel; | ||
import com.evolveum.midpoint.web.component.util.VisibleBehaviour; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; | ||
|
||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.ajax.markup.html.AjaxLink; | ||
import org.apache.wicket.behavior.Behavior; | ||
import org.apache.wicket.markup.html.WebMarkupContainer; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.model.IModel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public abstract class EvaluatorExpressionPanel extends BasePanel<ExpressionType> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private static final String ID_VALUE_INPUT = "valueInput"; | ||
private static final String ID_VALUE_CONTAINER = "valueContainer"; | ||
private static final String ID_VALUE_CONTAINER_LABEL = "valueContainerLabel"; | ||
private static final String ID_ADD_BUTTON = "add"; | ||
private static final String ID_REMOVE_BUTTON = "remove"; | ||
private static final String ID_FEEDBACK = "feedback"; | ||
|
||
public EvaluatorExpressionPanel(String id, IModel<ExpressionType> model) { | ||
super(id, model); | ||
} | ||
|
||
@Override | ||
protected void onInitialize() { | ||
super.onInitialize(); | ||
initLayout(); | ||
} | ||
|
||
private void initLayout() { | ||
setOutputMarkupId(true); | ||
|
||
WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER); | ||
valueContainer.setOutputMarkupId(true); | ||
add(valueContainer); | ||
|
||
valueContainer.add(new Label(ID_VALUE_CONTAINER_LABEL, getValueContainerLabelModel())); | ||
|
||
FeedbackLabels feedback = new FeedbackLabels(ID_FEEDBACK); | ||
feedback.setOutputMarkupPlaceholderTag(true); | ||
valueContainer.add(feedback); | ||
|
||
AjaxLink<Void> addButton = new AjaxLink<>(ID_ADD_BUTTON) { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
addValue(target); | ||
} | ||
}; | ||
valueContainer.add(addButton); | ||
|
||
AjaxLink<Void> removeButton = new AjaxLink<>(ID_REMOVE_BUTTON) { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
removeItem(target); | ||
} | ||
}; | ||
valueContainer.add(removeButton); | ||
|
||
valueContainer.add(createDefaultInputPanel()); | ||
} | ||
|
||
public abstract IModel<String> getValueContainerLabelModel(); | ||
|
||
protected WebMarkupContainer createDefaultInputPanel() { | ||
|
||
IModel<List<String>> model = new IModel<>() { | ||
@Override | ||
public List<String> getObject() { | ||
return getEvaluatorValues(); | ||
} | ||
|
||
@Override | ||
public void setObject(List<String> strings) { | ||
updateEvaluatorValue(getModelObject(), strings); | ||
} | ||
|
||
@Override | ||
public void detach() { | ||
} | ||
}; | ||
|
||
NonEmptyModel<Boolean> readOnlyModel = new NonEmptyLoadableModel<>(false) { | ||
@NotNull | ||
@Override | ||
protected Boolean load() { | ||
return false; | ||
} | ||
}; | ||
MultiValueTextPanel<String> valueInput = new MultiValueTextPanel<>(EvaluatorExpressionPanel.ID_VALUE_INPUT, model, readOnlyModel, false) { | ||
|
||
@Override | ||
protected Behavior getAddButtonVisibleBehavior(NonEmptyModel<Boolean> readOnlyModel) { | ||
return VisibleBehaviour.ALWAYS_INVISIBLE; | ||
} | ||
|
||
@Override | ||
protected IModel<String> createEmptyItemPlaceholder() { | ||
return () -> ""; | ||
} | ||
|
||
@Override | ||
protected InputPanel createTextPanel(String id, IModel<String> model) { | ||
return EvaluatorExpressionPanel.this.createTextPanel(id, model); | ||
} | ||
|
||
@Override | ||
protected void modelObjectUpdatePerformed(AjaxRequestTarget target, List<String> strings) { | ||
updateEvaluatorValue(EvaluatorExpressionPanel.this.getModelObject(), strings); | ||
target.add(getFeedback()); | ||
} | ||
}; | ||
valueInput.setOutputMarkupId(true); | ||
return valueInput; | ||
} | ||
|
||
protected InputPanel createTextPanel(String id, IModel<String> model) { | ||
return new TextPanel<>(id, model); | ||
} | ||
|
||
private void removeItem(AjaxRequestTarget target) { | ||
getModelObject().getExpressionEvaluator().clear(); | ||
target.add(get(ID_VALUE_CONTAINER)); | ||
target.add(getFeedback()); | ||
} | ||
|
||
private void addValue(AjaxRequestTarget target) { | ||
List<String> values = getEvaluatorValues(); | ||
values.add(""); | ||
updateEvaluatorValue(EvaluatorExpressionPanel.this.getModelObject(), values); | ||
target.add(get(ID_VALUE_CONTAINER)); | ||
target.add(getFeedback()); | ||
} | ||
|
||
protected FeedbackLabels getFeedback() { | ||
return (FeedbackLabels) get(createComponentPath(ID_VALUE_CONTAINER, ID_FEEDBACK)); | ||
} | ||
|
||
protected abstract void updateEvaluatorValue(ExpressionType expression, List<String> values); | ||
|
||
protected abstract List<String> getEvaluatorValues(); | ||
} |
33 changes: 33 additions & 0 deletions
33
.../main/java/com/evolveum/midpoint/gui/impl/component/input/expression/ExpressionPanel.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,33 @@ | ||
<!-- | ||
~ Copyright (c) 2023 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> | ||
<wicket:enclosure child="typeChoice"> | ||
<div class="input-group mb-1"> | ||
<div class="custom-file" style="height: calc(1.8125rem + 2px);" wicket:id="typeChoice"/> | ||
<wicket:enclosure child="typeButton"> | ||
<div class="input-group-append"> | ||
<button class="pl-2 btn btn-sm btn-primary" wicket:id="typeButton"/> | ||
</div> | ||
</wicket:enclosure> | ||
</div> | ||
</wicket:enclosure> | ||
<div wicket:id="infoContainer" class="d-flex"> | ||
<span class="text-info" wicket:id="infoLabel"/> | ||
<span class="btn btn-tool mt-0"> | ||
<i class="p-1" wicket:id="infoIcon"/> | ||
</span> | ||
<button class="ml-auto btn btn-sm btn-primary" wicket:id="resetButton"> | ||
<wicket:message key="ExpressionPanel.resetButton"/> | ||
</button> | ||
</div> | ||
<div wicket:id="evaluatorPanel"/> | ||
</wicket:panel> | ||
</html> | ||
|
Oops, something went wrong.