Skip to content

Commit

Permalink
Merge branch 'master' into feature/smart-correlation-prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jul 27, 2022
2 parents 1a4009f + cd061d3 commit acb5a51
Show file tree
Hide file tree
Showing 81 changed files with 2,556 additions and 615 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ public class GuiStyleConstants {
public static final String CLASS_ICON_PERFORMANCE = "fa fa-chart-area";
public static final String CLASS_ICON_TASK_RESULTS = "fa fa-list-alt";

public static final String CLASS_ICON_SEARCH = "fa fa-search flip-icon";
public static final String CLASS_ICON_SEARCH_FLIP = "fa fa-search flip-icon";
public static final String CLASS_ICON_SEARCH = "fa fa-search";

public static final String CLASS_ICON_SAVE = "fa fa-save";
public static final String CLASS_ICON_PREVIEW = "fa fa-eye";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!--
~ Copyright (c) 2022 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div class="d-flex flex-column gap-3 align-items-center mt-5">
<h2 class="mb-3" wicket:id="text"/>
<h5 class="text-secondary mb-5" wicket:id="subText"/>
<div class="col-12">
<wicket:child/>
</div>
<div class="d-flex gap-3 justify-content-center">
<a class="btn" wicket:id="buttons"/>
</div>
</div>
</wicket:panel>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.
*/
package com.evolveum.midpoint.gui.api.component.wizard;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.page.admin.resources.PageResources;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

public abstract class AbstractWizardBasicPanel extends BasePanel {

private static final String ID_TEXT = "text";
private static final String ID_SUBTEXT = "subText";
private static final String ID_BUTTONS = "buttons";

private final ResourceDetailsModel resourceModel;
public AbstractWizardBasicPanel(String id, ResourceDetailsModel resourceModel) {
super(id);
this.resourceModel = resourceModel;
}

public ResourceDetailsModel getResourceModel() {
return resourceModel;
}

@Override
protected void onInitialize() {
super.onInitialize();
initLayout();
}

private void initLayout() {

Label mainText = new Label(ID_TEXT, getTextModel());
mainText.add(new VisibleBehaviour(() -> getTextModel().getObject() != null));
add(mainText);

Label secondaryText = new Label(ID_SUBTEXT, getSubTextModel());
secondaryText.add(new VisibleBehaviour(() -> getSubTextModel().getObject() != null));
add(secondaryText);

RepeatingView buttons = new RepeatingView(ID_BUTTONS);

AjaxIconButton exit = new AjaxIconButton(
buttons.newChildId(),
Model.of("fa fa-right-from-bracket"),
getPageBase().createStringResource("ResourceWizard.exit")) {
@Override
public void onClick(AjaxRequestTarget target) {
onExitPerformed(target);
}
};
exit.showTitleAsLabel(true);
exit.add(AttributeAppender.append("class", "btn btn-outline-primary"));
buttons.add(exit);

addCustomButtons(buttons);
add(buttons);
}

protected void onExitPerformed(AjaxRequestTarget target) {
getPageBase().navigateToNext(PageResources.class);
}

protected void addCustomButtons(RepeatingView buttons) {
}

protected abstract IModel<String> getSubTextModel();

protected abstract IModel<String> getTextModel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ <h5 class="text-secondary mb-5" wicket:id="subText"/>
<i class="fas fa-arrow-left mr-2"></i>
<wicket:message key="WizardHeader.back"/>
</a>
<a class="btn btn-outline-primary" wicket:id="exit">
<i class="fas fa-arrow-left mr-2"></i>
<wicket:message key="WizardPanel.exit"/>
</a>
<a class="btn btn-success" wicket:id="next">
<wicket:message key="WizardHeader.next"/>
<span wicket:id="nextLabel"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
Expand All @@ -24,20 +22,21 @@
/**
* @author lskublik
*/
public class BasicWizardPanel<T> extends WizardStepPanel<T> {
public class BasicWizardStepPanel<T> extends WizardStepPanel<T> {

private static final long serialVersionUID = 1L;

private static final String ID_TEXT = "text";
private static final String ID_SUBTEXT = "subText";
private static final String ID_BACK = "back";
private static final String ID_EXIT = "exit";
private static final String ID_NEXT = "next";
private static final String ID_NEXT_LABEL = "nextLabel";

public BasicWizardPanel() {
public BasicWizardStepPanel() {
}

public BasicWizardPanel(IModel<T> model) {
public BasicWizardStepPanel(IModel<T> model) {
super(model);
}

Expand Down Expand Up @@ -70,6 +69,19 @@ public void onClick(AjaxRequestTarget target) {
WebComponentUtil.addDisabledClassBehavior(back);
add(back);

AjaxLink exit = new AjaxLink<>(ID_EXIT) {

@Override
public void onClick(AjaxRequestTarget target) {
onExitPerformed(target);
}
};
exit.add(getExitVisibility());
exit.setOutputMarkupId(true);
exit.setOutputMarkupPlaceholderTag(true);
WebComponentUtil.addDisabledClassBehavior(exit);
add(exit);

AjaxSubmitButton next = new AjaxSubmitButton(ID_NEXT) {

@Override
Expand All @@ -92,6 +104,13 @@ protected void onError(AjaxRequestTarget target) {
next.add(nextLabel);
}

protected VisibleBehaviour getExitVisibility() {
return new VisibleBehaviour(() -> false);
}

protected void onExitPerformed(AjaxRequestTarget target) {
}

protected IModel<String> getNextLabelModel() {
return () -> {
WizardStep step = getWizard().getNextPanel();
Expand All @@ -102,10 +121,6 @@ protected IModel<String> getNextLabelModel() {
protected void updateFeedbackPanels(AjaxRequestTarget target) {
}

protected WebMarkupContainer createContentPanel(String id) {
return new WebMarkupContainer(id);
}

protected AjaxSubmitButton getNext() {
return (AjaxSubmitButton) get(ID_NEXT);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.evolveum.midpoint.gui.api.component.wizard;

import java.io.Serializable;

public interface TileEnum extends Serializable {
String getIcon();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!--
~ Copyright (c) 2022 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:extend>
<div class="request-access-wizard d-flex flex-wrap gap-3 justify-content-center">
<wicket:container wicket:id="list">
<div class="card mb-0 simple-tile selectable" wicket:id="tile"/>
</wicket:container>
</div>
</wicket:extend>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* 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.
*/
package com.evolveum.midpoint.gui.api.component.wizard;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.impl.component.tile.Tile;
import com.evolveum.midpoint.gui.impl.component.tile.TilePanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;

import org.apache.commons.lang3.Validate;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import java.util.ArrayList;
import java.util.List;

public abstract class WizardChoicePanel<T extends TileEnum> extends AbstractWizardBasicPanel {

private static final String ID_LIST = "list";
private static final String ID_TILE = "tile";

private LoadableModel<List<Tile<T>>> tiles;

private final Class<T> tileTypeClass;

/**
* @param tileTypeClass have to be Enum class
**/
public WizardChoicePanel(String id, ResourceDetailsModel resourceModel, Class<T> tileTypeClass) {
super(id, resourceModel);
Validate.isAssignableFrom(Enum.class, tileTypeClass);
this.tileTypeClass = tileTypeClass;
}

@Override
protected void onInitialize() {
super.onInitialize();
initModels();
initLayout();
}

private void initModels() {
tiles = new LoadableModel<>(false) {

@Override
protected List<Tile<T>> load() {
List<Tile<T>> list = new ArrayList<>();

for (T type : tileTypeClass.getEnumConstants()) {
Tile tile = new Tile(type.getIcon(), getString((Enum) type));
tile.setValue(type);
list.add(tile);
}
addDefaultTile(list);

return list;
}
};
}

protected void addDefaultTile(List<Tile<T>> list) {
}

private void initLayout() {
ListView<Tile<T>> list = new ListView<>(ID_LIST, tiles) {

@Override
protected void populateItem(ListItem<Tile<T>> item) {
TilePanel tp = new TilePanel(ID_TILE, item.getModel()) {

@Override
protected void onClick(AjaxRequestTarget target) {
Tile<T> tile = item.getModelObject();
onTileClick(tile.getValue(), target);
}
};
item.add(tp);
}
};
add(list);
}

protected abstract void onTileClick(T value, AjaxRequestTarget target);
}

0 comments on commit acb5a51

Please sign in to comment.