-
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.
MID-6274 popup to select task execution mode before simulation starts
- Loading branch information
Showing
5 changed files
with
199 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
27 changes: 27 additions & 0 deletions
27
.../main/java/com/evolveum/midpoint/web/page/admin/shadows/ChooseTaskExecutionModePopup.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,27 @@ | ||
<!-- | ||
~ Copyright (c) 2010-2018 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 class="d-flex flex-column align-items-center gap-4"> | ||
<p class="mb-0"><wicket:message key="ChooseTaskExecutionModePopup.text"/></p> | ||
|
||
<div wicket:id="dropdown"/> | ||
</div> | ||
|
||
<wicket:fragment wicket:id="buttons"> | ||
<div class="d-flex flex-wrap gap-2 w-100"> | ||
<a class="btn btn-outline-primary" wicket:id="cancel"> | ||
<i class="fa fa-xmark mr-1"/> | ||
<span><wicket:message key="ChooseTaskExecutionModePopup.button.cancel"/></span> | ||
</a> | ||
<a class="btn btn-success" wicket:id="select"> | ||
<span><wicket:message key="ChooseTaskExecutionModePopup.button.select"/></span> | ||
<i class="fa fa-arrow-right ml-1"/> | ||
</a> | ||
</div> | ||
</wicket:fragment> | ||
</wicket:panel> |
109 changes: 109 additions & 0 deletions
109
.../main/java/com/evolveum/midpoint/web/page/admin/shadows/ChooseTaskExecutionModePopup.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,109 @@ | ||
/* | ||
* 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.web.page.admin.shadows; | ||
|
||
import com.evolveum.midpoint.gui.api.model.LoadableModel; | ||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
import com.evolveum.midpoint.prism.impl.DisplayableValueImpl; | ||
import com.evolveum.midpoint.schema.TaskExecutionMode; | ||
import com.evolveum.midpoint.util.DisplayableValue; | ||
import com.evolveum.midpoint.web.component.AjaxButton; | ||
import com.evolveum.midpoint.web.component.dialog.Popupable; | ||
import com.evolveum.midpoint.web.component.dialog.SimplePopupable; | ||
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel; | ||
import org.apache.wicket.Component; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.markup.html.panel.Fragment; | ||
import org.apache.wicket.model.IModel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ChooseTaskExecutionModePopup extends SimplePopupable<DisplayableValue<TaskExecutionMode>> { | ||
|
||
private static final String ID_BUTTONS = "buttons"; | ||
private static final String ID_DROPDOWN = "dropdown"; | ||
private static final String ID_CANCEL_BUTTON = "cancel"; | ||
private static final String ID_SELECT_BUTTON = "select"; | ||
|
||
private Fragment footer; | ||
|
||
public ChooseTaskExecutionModePopup(String id) { | ||
super(id, null, 400, 200, PageBase.createStringResourceStatic("ChooseTaskExecutionModePopup.title")); | ||
|
||
initLayout(); | ||
} | ||
|
||
@Override | ||
public IModel<DisplayableValue<TaskExecutionMode>> createModel() { | ||
return new LoadableModel<>(false) { | ||
@Override | ||
protected DisplayableValue<TaskExecutionMode> load() { | ||
return createValue(TaskExecutionMode.SIMULATED_SHADOWS_PRODUCTION); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public Component getContent() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public @NotNull Component getFooter() { | ||
return footer; | ||
} | ||
|
||
private DisplayableValue createValue(TaskExecutionMode mode) { | ||
return new DisplayableValueImpl(mode, "TaskExecutionMode." + mode); | ||
} | ||
|
||
private void initLayout() { | ||
IModel<List<DisplayableValue<TaskExecutionMode>>> choices = () -> Arrays.asList( | ||
createValue(TaskExecutionMode.SIMULATED_SHADOWS_DEVELOPMENT), | ||
createValue(TaskExecutionMode.SIMULATED_SHADOWS_PRODUCTION)); | ||
|
||
DropDownChoicePanel<TaskExecutionMode> dropdown = WebComponentUtil.createDropDownChoices(ID_DROPDOWN, getModel(), choices, false); | ||
add(dropdown); | ||
|
||
footer = initFooter(); | ||
} | ||
|
||
private Fragment initFooter() { | ||
Fragment footer = new Fragment(Popupable.ID_FOOTER, ID_BUTTONS, this); | ||
|
||
AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON) { | ||
|
||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
onCancelPerformed(target); | ||
} | ||
}; | ||
footer.add(cancelButton); | ||
|
||
AjaxButton selectButton = new AjaxButton(ID_SELECT_BUTTON) { | ||
|
||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
onSelectPerformed(target, ChooseTaskExecutionModePopup.this.getModelObject().getValue()); | ||
} | ||
}; | ||
footer.add(selectButton); | ||
|
||
return footer; | ||
} | ||
|
||
protected void onCancelPerformed(AjaxRequestTarget target) { | ||
getPageBase().hideMainPopup(target); | ||
} | ||
|
||
protected void onSelectPerformed(AjaxRequestTarget target, TaskExecutionMode mode) { | ||
|
||
} | ||
} |
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