Skip to content

Commit

Permalink
adding resource wizard panels for resource object type activation
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 2, 2022
1 parent 804aee7 commit 265b228
Show file tree
Hide file tree
Showing 17 changed files with 494 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.evolveum.midpoint.gui.impl.page.admin.component.ResourceOperationalButtonsPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.ResourceWizardPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.ResourceObjectTypeWizardPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.activation.ActivationsWizardPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.associations.AssociationsWizardPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.attributeMapping.AttributeMappingWizardPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.correlation.CorrelationWizardPanel;
import com.evolveum.midpoint.gui.impl.page.admin.resource.component.wizard.objectType.credentials.CredentialsWizardPanel;
Expand Down Expand Up @@ -244,6 +246,50 @@ protected void onExitPerformed(AjaxRequestTarget target) {
target.add(fragment);
}

public void showActivationsWizard(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> valueModel) {
Fragment fragment = new Fragment(ID_DETAILS_VIEW, ID_WIZARD_FRAGMENT, PageResource.this);
fragment.setOutputMarkupId(true);
addOrReplace(fragment);
ActivationsWizardPanel wizard = new ActivationsWizardPanel(
ID_WIZARD, getObjectDetailsModels(), valueModel) {

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

@Override
protected void onExitPerformed(AjaxRequestTarget target) {
backToDetailsFromWizard(target);
}
};
wizard.setOutputMarkupId(true);
fragment.add(wizard);
target.add(fragment);
}

public void showAssociationsWizard(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> valueModel) {
Fragment fragment = new Fragment(ID_DETAILS_VIEW, ID_WIZARD_FRAGMENT, PageResource.this);
fragment.setOutputMarkupId(true);
addOrReplace(fragment);
AssociationsWizardPanel wizard = new AssociationsWizardPanel(
ID_WIZARD, getObjectDetailsModels(), valueModel) {

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

@Override
protected void onExitPerformed(AjaxRequestTarget target) {
backToDetailsFromWizard(target);
}
};
wizard.setOutputMarkupId(true);
fragment.add(wizard);
target.add(fragment);
}

private void backToDetailsFromWizard(AjaxRequestTarget target) {
//TODO change it and use parameter, when it will be implemented
ObjectDetailsStorage storage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ protected void initLayout() {
initAttributeMappingButton(topButtons);
initCorrelationButton(topButtons);
initCredentialsButton(topButtons);
initActivationsButton(topButtons);
initAssociationsButton(topButtons);

final Form mainForm = new MidpointForm(ID_MAIN_FORM);
mainForm.setOutputMarkupId(true);
Expand Down Expand Up @@ -407,6 +409,48 @@ 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"));
topButtons.add(credentialsConfButton);
}

private void initActivationsButton(RepeatingView topButtons) {
AjaxIconButton credentialsConfButton = new AjaxIconButton(
topButtons.newChildId(),
Model.of(ResourceObjectTypePreviewTileType.ACTIVATION.getIcon()),
getPageBase().createStringResource(ResourceObjectTypePreviewTileType.ACTIVATION)) {
@Override
public void onClick(AjaxRequestTarget target) {
IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> valueModel =
getResourceObjectTypeValue(target);
if (valueModel != null) {
getObjectDetailsModels().getPageResource().showActivationsWizard(
target,
valueModel);
}
}
};
credentialsConfButton.showTitleAsLabel(true);
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-basis-0 flex-fill mr-3"));
topButtons.add(credentialsConfButton);
}

private void initAssociationsButton(RepeatingView topButtons) {
AjaxIconButton credentialsConfButton = new AjaxIconButton(
topButtons.newChildId(),
Model.of(ResourceObjectTypePreviewTileType.ASSOCIATIONS.getIcon()),
getPageBase().createStringResource(ResourceObjectTypePreviewTileType.ASSOCIATIONS)) {
@Override
public void onClick(AjaxRequestTarget target) {
IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> valueModel =
getResourceObjectTypeValue(target);
if (valueModel != null) {
getObjectDetailsModels().getPageResource().showAssociationsWizard(
target,
valueModel);
}
}
};
credentialsConfButton.showTitleAsLabel(true);
credentialsConfButton.add(AttributeAppender.append("class", "btn btn-primary p-3 flex-basis-0 flex-fill"));
topButtons.add(credentialsConfButton);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public VisibleEnableBehaviour getStepsBehaviour() {
if (getWizard().getSteps().size() <= 1) {
return VisibleEnableBehaviour.ALWAYS_INVISIBLE;
}
return super.getHeaderBehaviour();
return super.getStepsBehaviour();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public enum ResourceObjectTypePreviewTileType implements TileEnum {
SYNCHRONIZATION_CONFIG("fa fa-arrows-rotate"),
CORRELATION_CONFIG("fa fa-code-branch"),
// CAPABILITIES_CONFIG("fab fa-react"),
// ACTIVATION("fa fa-toggle-off"),
CREDENTIALS("fa fa-key");
// ASSOCIATIONS("fa fa-shield");
ACTIVATION("fa fa-toggle-off"),
CREDENTIALS("fa fa-key"),
ASSOCIATIONS("fa fa-shield");

private String icon;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,28 @@
import org.apache.wicket.behavior.AttributeAppender;
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.*;

/**
* @author lskublik
*/

@Experimental
@PanelInstance(identifier = "credentialsWizard",
applicableForType = ResourceType.class,
applicableForOperation = OperationTypeType.ADD,
display = @PanelDisplay(label = "PageResource.wizard.step.credentials", icon = "fa fa-key"),
expanded = true)
public class AdministrativeStatusStepPanel extends AbstractResourceWizardStepPanel {

private static final Trace LOGGER = TraceManager.getTrace(AdministrativeStatusStepPanel.class);
public abstract class ActivationMappingStepPanel extends AbstractResourceWizardStepPanel {

protected static final String ID_PANEL = "panel";

public static final String PANEL_TYPE = "credentialsWizard";

private final IModel<PrismContainerWrapper<ResourcePasswordDefinitionType>> containerModel;
private final IModel<PrismContainerWrapper<ResourceBidirectionalMappingType>> containerModel;
private final ResourceDetailsModel resourceModel;

public AdministrativeStatusStepPanel(ResourceDetailsModel model,
IModel<PrismContainerWrapper<ResourcePasswordDefinitionType>> containerModel) {
public ActivationMappingStepPanel(ResourceDetailsModel model,
IModel<PrismContainerWrapper<ResourceBidirectionalMappingType>> containerModel) {
super(model);
this.containerModel = containerModel;
this.resourceModel = model;
Expand All @@ -64,27 +46,9 @@ protected void onInitialize() {
private void initLayout() {
SingleContainerPanel panel;
if (getContainerConfiguration() == null) {
panel = new SingleContainerPanel(ID_PANEL, getContainerFormModel(), ResourcePasswordDefinitionType.COMPLEX_TYPE){

@Override
protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
if (isItemHidden(itemWrapper)) {
return ItemVisibility.HIDDEN;
}
return super.getVisibility(itemWrapper);
}
};
panel = new SingleContainerPanel(ID_PANEL, getContainerFormModel(), ResourcePasswordDefinitionType.COMPLEX_TYPE);
} else {
panel = new SingleContainerPanel(ID_PANEL, getContainerFormModel(), getContainerConfiguration()) {

@Override
protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
if (isItemHidden(itemWrapper)) {
return ItemVisibility.HIDDEN;
}
return super.getVisibility(itemWrapper);
}
};
panel = new SingleContainerPanel(ID_PANEL, getContainerFormModel(), getContainerConfiguration());
}
panel.setOutputMarkupId(true);
panel.add(AttributeAppender.append("class", "card col-12"));
Expand All @@ -95,14 +59,7 @@ protected ContainerPanelConfigurationType getContainerConfiguration() {
return WebComponentUtil.getContainerConfiguration(resourceModel.getObjectDetailsPageConfiguration().getObject(), getPanelType());
}

private boolean isItemHidden(ItemWrapper itemWrapper) {
return itemWrapper.getPath().namedSegmentsOnly().equivalent(
ItemPath.create(ResourceType.F_SCHEMA_HANDLING,
SchemaHandlingType.F_OBJECT_TYPE,
ResourceObjectTypeDefinitionType.F_CREDENTIALS,
ResourceCredentialsDefinitionType.F_PASSWORD,
ResourcePasswordDefinitionType.F_CACHING));
}
protected abstract String getPanelType();

protected IModel<? extends PrismContainerWrapper> getContainerFormModel() {
return containerModel;
Expand All @@ -113,36 +70,8 @@ protected void updateFeedbackPanels(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel());
}

protected String getPanelType() {
return PANEL_TYPE;
}

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

// private String getIcon() {
// return "fa fa-key";
// }

@Override
public IModel<String> getTitle() {
return createStringResource("PageResource.wizard.step.credentials");
}

@Override
protected IModel<?> getTextModel() {
return createStringResource("PageResource.wizard.step.credentials.text");
}

@Override
protected IModel<?> getSubTextModel() {
return createStringResource("PageResource.wizard.step.credentials.subText");
}

@Override
public VisibleEnableBehaviour getBackBehaviour() {
return new VisibleBehaviour(() -> false);
}
}

0 comments on commit 265b228

Please sign in to comment.