Skip to content

Commit

Permalink
adding table for associations to resource wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 3, 2022
1 parent 265b228 commit 2b7c6aa
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
attrMappingButton.showTitleAsLabel(true);
attrMappingButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-basis-0 flex-fill mr-3"));
attrMappingButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-grow-1 mr-3 mb-3"));
attrMappingButton.add(AttributeAppender.append("style", "width: 30%;"));
topButtons.add(attrMappingButton);
}

Expand All @@ -367,7 +368,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
synchConfButton.showTitleAsLabel(true);
synchConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-fill flex-basis-0 mr-3"));
synchConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-grow-1 mr-3 mb-3"));
synchConfButton.add(AttributeAppender.append("style", "width: 30%;"));
topButtons.add(synchConfButton);
}

Expand All @@ -388,7 +390,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
correlationConfButton.showTitleAsLabel(true);
correlationConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-fill flex-basis-0 mr-3"));
correlationConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-grow-1 mb-3"));
correlationConfButton.add(AttributeAppender.append("style", "width: 30%;"));
topButtons.add(correlationConfButton);
}

Expand All @@ -409,7 +412,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
credentialsConfButton.showTitleAsLabel(true);
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-basis-0 flex-fill mr-3"));
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-grow-1 mr-3"));
credentialsConfButton.add(AttributeAppender.append("style", "width: 30%;"));
topButtons.add(credentialsConfButton);
}

Expand All @@ -430,7 +434,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
credentialsConfButton.showTitleAsLabel(true);
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-basis-0 flex-fill mr-3"));
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-grow-1 mr-3"));
credentialsConfButton.add(AttributeAppender.append("style", "width: 30%;"));
topButtons.add(credentialsConfButton);
}

Expand All @@ -451,7 +456,8 @@ public void onClick(AjaxRequestTarget target) {
}
};
credentialsConfButton.showTitleAsLabel(true);
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-basis-0 flex-fill"));
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-grow-1"));
credentialsConfButton.add(AttributeAppender.append("style", "width: 30%;"));
topButtons.add(credentialsConfButton);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@
*/
package com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.associations;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;

import com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder;
import com.evolveum.midpoint.gui.impl.prism.panel.PrismContainerValuePanel;
import com.evolveum.midpoint.gui.impl.prism.panel.PrismValuePanel;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.AbstractResourceWizardStepPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.component.prism.ItemVisibility;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand All @@ -37,17 +39,17 @@
applicableForOperation = OperationTypeType.ADD,
display = @PanelDisplay(label = "PageResource.wizard.step.associations", icon = "fa fa-shield"),
expanded = true)
public class AssociationsStepPanel extends AbstractResourceWizardStepPanel {
public class AssociationStepPanel extends AbstractResourceWizardStepPanel {

protected static final String ID_PANEL = "panel";

public static final String PANEL_TYPE = "AssociationsWizardPanel";

private final IModel<PrismContainerWrapper<ResourceObjectAssociationType>> containerModel;
private final IModel<PrismContainerValueWrapper<ResourceObjectAssociationType>> containerModel;
private final ResourceDetailsModel resourceModel;

public AssociationsStepPanel(ResourceDetailsModel model,
IModel<PrismContainerWrapper<ResourceObjectAssociationType>> containerModel) {
public AssociationStepPanel(ResourceDetailsModel model,
IModel<PrismContainerValueWrapper<ResourceObjectAssociationType>> containerModel) {
super(model);
this.containerModel = containerModel;
this.resourceModel = model;
Expand All @@ -60,12 +62,12 @@ protected void onInitialize() {
}

private void initLayout() {
SingleContainerPanel panel;
if (getContainerConfiguration() == null) {
panel = new SingleContainerPanel(ID_PANEL, getContainerFormModel(), ResourcePasswordDefinitionType.COMPLEX_TYPE);
} else {
panel = new SingleContainerPanel(ID_PANEL, getContainerFormModel(), getContainerConfiguration());
}

ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder();
builder.panelConfiguration(getContainerConfiguration());

Panel panel = getPageBase().initContainerValuePanel(ID_PANEL, getContainerFormModel(), builder.build());

panel.setOutputMarkupId(true);
panel.add(AttributeAppender.append("class", "card col-12"));
add(panel);
Expand All @@ -75,7 +77,7 @@ protected ContainerPanelConfigurationType getContainerConfiguration() {
return WebComponentUtil.getContainerConfiguration(resourceModel.getObjectDetailsPageConfiguration().getObject(), getPanelType());
}

protected IModel<? extends PrismContainerWrapper> getContainerFormModel() {
protected IModel<PrismContainerValueWrapper<ResourceObjectAssociationType>> getContainerFormModel() {
return containerModel;
}

Expand Down Expand Up @@ -116,4 +118,9 @@ protected IModel<?> getSubTextModel() {
public VisibleEnableBehaviour getBackBehaviour() {
return new VisibleBehaviour(() -> false);
}

@Override
protected boolean isSubmitVisible() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
* 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.resource.component.wizard.objectType.associations;

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

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel;
import com.evolveum.midpoint.gui.impl.component.data.column.AbstractItemWrapperColumn;
import com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn;
import com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder;
import com.evolveum.midpoint.model.api.AssignmentObjectRelation;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
* @author lskublik
*/
public abstract class AssociationsTable extends MultivalueContainerListPanel<ResourceObjectAssociationType> {

private final IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> valueModel;

public AssociationsTable(
String id,
IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> valueModel) {
super(id, ResourceObjectAssociationType.class);
this.valueModel = valueModel;
}

@Override
protected boolean isHeaderVisible() {
return false;
}

@Override
protected List<Component> createToolbarButtonsList(String idButton) {
List<Component> buttons = super.createToolbarButtonsList(idButton);
buttons.forEach(button -> {
if (button instanceof AjaxIconButton) {
((AjaxIconButton) button).showTitleAsLabel(true);
}
});
return buttons;
}

@Override
protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec) {
createNewAssociation(target);
refreshTable(target);
}

protected PrismContainerValueWrapper createNewAssociation(AjaxRequestTarget target) {
PrismContainerWrapper<ResourceObjectAssociationType> container = getContainerModel().getObject();
PrismContainerValue<ResourceObjectAssociationType> newReaction = container.getItem().createNewValue();
PrismContainerValueWrapper<ResourceObjectAssociationType> newReactionWrapper =
createNewItemContainerValueWrapper(newReaction, container, target);
return newReactionWrapper;
}

@Override
protected boolean isCreateNewObjectVisible() {
return true;
}

@Override
protected List<InlineMenuItem> createInlineMenu() {
List<InlineMenuItem> items = new ArrayList<>();

InlineMenuItem item = new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {
private static final long serialVersionUID = 1L;

@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
}

@Override
public boolean isHeaderMenuItem() {
return false;
}

@Override
public InlineMenuItemAction initAction() {
return createEditColumnAction();
}
};
items.add(item);

items.add(new ButtonInlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {
private static final long serialVersionUID = 1L;

@Override
public CompositedIconBuilder getIconCompositedBuilder() {
return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_ICON_TRASH);
}

@Override
public InlineMenuItemAction initAction() {
return createDeleteColumnAction();
}
});
return items;
}

@Override
protected IModel<PrismContainerWrapper<ResourceObjectAssociationType>> getContainerModel() {
return PrismContainerWrapperModel.fromContainerValueWrapper(
valueModel,
ResourceObjectTypeDefinitionType.F_ASSOCIATION);
}

@Override
protected List<IColumn<PrismContainerValueWrapper<ResourceObjectAssociationType>, String>> createDefaultColumns() {
List<IColumn<PrismContainerValueWrapper<ResourceObjectAssociationType>, String>> columns = new ArrayList<>();

columns.add(new CheckBoxHeaderColumn<>());

IModel<PrismContainerDefinition<ResourceObjectAssociationType>> associationsDef = getAssociationsDefinition();
columns.add(new PrismPropertyWrapperColumn<ResourceObjectAssociationType, String>(
associationsDef,
ResourceObjectAssociationType.F_DISPLAY_NAME,
AbstractItemWrapperColumn.ColumnType.VALUE,
getPageBase()));

columns.add(new PrismPropertyWrapperColumn<ResourceObjectAssociationType, String>(
associationsDef,
ResourceObjectAssociationType.F_KIND,
AbstractItemWrapperColumn.ColumnType.VALUE,
getPageBase()));

columns.add(new PrismPropertyWrapperColumn<ResourceObjectAssociationType, String>(
associationsDef,
ResourceObjectAssociationType.F_INTENT,
AbstractItemWrapperColumn.ColumnType.VALUE,
getPageBase()));

columns.add(new PrismPropertyWrapperColumn<ResourceObjectAssociationType, String>(
associationsDef,
ResourceObjectAssociationType.F_DIRECTION,
AbstractItemWrapperColumn.ColumnType.VALUE,
getPageBase()));

columns.add(new PrismPropertyWrapperColumn<ResourceObjectAssociationType, String>(
associationsDef,
ResourceObjectAssociationType.F_ASSOCIATION_ATTRIBUTE,
AbstractItemWrapperColumn.ColumnType.VALUE,
getPageBase()));

columns.add(new PrismPropertyWrapperColumn<ResourceObjectAssociationType, String>(
associationsDef,
ResourceObjectAssociationType.F_VALUE_ATTRIBUTE,
AbstractItemWrapperColumn.ColumnType.VALUE,
getPageBase()));

return columns;
}

protected LoadableModel<PrismContainerDefinition<ResourceObjectAssociationType>> getAssociationsDefinition() {
return new LoadableModel<>() {
@Override
protected PrismContainerDefinition<ResourceObjectAssociationType> load() {
return valueModel.getObject().getDefinition().findContainerDefinition(
ResourceObjectTypeDefinitionType.F_ASSOCIATION);
}
};
}

@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PANEL_CORRELATION_ITEMS_WIZARD;
}

@Override
protected String getKeyOfTitleForNewObjectButton() {
return "AssociationsTable.newObject";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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="ml-auto mr-auto col-11" wicket:id="table"/>
</wicket:extend>
</body>
</html>

0 comments on commit 2b7c6aa

Please sign in to comment.