Skip to content

Commit

Permalink
assignment panel cleanup, adding default expression panel - text edit…
Browse files Browse the repository at this point in the history
…or, new panel for variableBinding, focusMappings assignments panel (as a part of MID-6210)
  • Loading branch information
katkav committed Apr 15, 2020
1 parent 5895e23 commit 1600ac4
Show file tree
Hide file tree
Showing 15 changed files with 656 additions and 534 deletions.
Expand Up @@ -71,6 +71,7 @@
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.component.DateLabelComponent;
import com.evolveum.midpoint.web.component.TabbedPanel;
import com.evolveum.midpoint.web.component.assignment.AssignmentsUtil;
import com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb;
import com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageClass;
import com.evolveum.midpoint.web.component.breadcrumbs.BreadcrumbPageInstance;
Expand Down Expand Up @@ -1249,10 +1250,8 @@ public static <C extends Containerable> String getDisplayName(PrismContainerValu
}
} else if (prismContainerValue.canRepresent(AssignmentType.class)) {
AssignmentType assignmentType = (AssignmentType) prismContainerValue.asContainerable();
if (assignmentType.getTargetRef() != null) {
ObjectReferenceType assignmentTargetRef = assignmentType.getTargetRef();
displayName = getName(assignmentTargetRef) + " - " + normalizeRelation(assignmentTargetRef.getRelation()).getLocalPart();
} else {
displayName = AssignmentsUtil.getName(assignmentType, null);
if (StringUtils.isBlank(displayName)) {
displayName = "AssignmentTypeDetailsPanel.containerTitle";
}
} else if (prismContainerValue.canRepresent(ExclusionPolicyConstraintType.class)) {
Expand Down Expand Up @@ -1331,10 +1330,36 @@ public static <C extends Containerable> String getDisplayName(PrismContainerValu
}
} else if (prismContainerValue.canRepresent(MappingType.class)) {
MappingType mapping = (MappingType) prismContainerValue.asContainerable();
if (mapping.getName() != null && !mapping.getName().isEmpty()) {
String name = mapping.getName();
String mappingName = mapping.getName();
if (StringUtils.isNotBlank(mappingName)) {
String description = mapping.getDescription();
displayName = name + (StringUtils.isNotEmpty(description) ? (" - " + description) : "");
displayName = mappingName + (StringUtils.isNotEmpty(description) ? (" - " + description) : "");
} else {
List<VariableBindingDefinitionType> sources = mapping.getSource();
String sourceDescription = "";
if (CollectionUtils.isNotEmpty(sources)) {
Iterator<VariableBindingDefinitionType> iterator = sources.iterator();
while (iterator.hasNext()) {
VariableBindingDefinitionType source = iterator.next();
if (source == null || source.getPath() == null) {
continue;
}
String sourcePath = source.getPath().toString();
sourceDescription +=sourcePath;
if (iterator.hasNext()) {
sourceDescription += ",";
}
}
}
VariableBindingDefinitionType target = mapping.getTarget();
String targetDescription = target.getPath() != null ? target.getPath().toString() : null;
if (StringUtils.isBlank(sourceDescription)) {
sourceDescription = "(no sources)";
}
if (StringUtils.isBlank(targetDescription)) {
targetDescription = "(no targets)";
}
displayName = sourceDescription + " - " + targetDescription;
}
} else {

Expand Down
@@ -0,0 +1,14 @@
<!--
~ Copyright (c) 2020 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 wicket:id="pathPanel"></div>
</wicket:panel>
</body>
</html>
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2020 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;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.path.ItemPathDto;
import com.evolveum.midpoint.gui.api.component.path.ItemPathPanel;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType;

import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;

public class VariableBindingDefinitionTypePanel extends BasePanel<VariableBindingDefinitionType> {

private static final String ID_PATH_LABEL = "pathLabel";
private static final String ID_PATH_PANEL = "pathPanel";

public VariableBindingDefinitionTypePanel(String id, IModel<VariableBindingDefinitionType> model) {
super(id, model);
}

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

private void initLayout() {
ItemPathPanel pathPanel = new ItemPathPanel(ID_PATH_PANEL, createPathModel()) {

@Override
protected void onUpdate(ItemPathDto itemPathDto) {
ItemPath newPath = getModelObject().toItemPath();
ItemPathType newPathtype = null;
if (newPath != null) {
newPathtype = new ItemPathType(newPath);
}

VariableBindingDefinitionTypePanel.this.getModelObject().setPath(newPathtype);
}
};
pathPanel.setOutputMarkupId(true);
add(pathPanel);

}

private ItemPathDto createPathModel() {
VariableBindingDefinitionType variable = getModelObject();
if (variable == null) {
return new ItemPathDto();
}
return new ItemPathDto(variable.getPath());
}
}
@@ -1,60 +1,50 @@
/*
* Copyright (c) 2020 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.factory;

import com.evolveum.midpoint.gui.api.factory.AbstractGuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.Serializable;

@Component
public class ConditionPanelFactory extends AbstractGuiComponentFactory<ExpressionType> implements Serializable {

@PostConstruct
public void register() {
getRegistry().addToRegistry(this);
}

@Override
protected Panel getPanel(PrismPropertyPanelContext<ExpressionType> panelCtx) {
AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200){
@Override
protected boolean isResizeToMaxHeight() {
return false;
}
};
// conditionPanel.getEditor().add(new OnChangeAjaxBehavior() {
// @Override
// protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
//
// }
// });
conditionPanel.getEditor().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
conditionPanel.getEditor().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
return conditionPanel;
}

@Override
public <IW extends ItemWrapper> boolean match(IW wrapper) {
ItemPath assignmentConditionPath = ItemPath.create(AssignmentHolderType.F_ASSIGNMENT, AssignmentType.F_CONDITION, MappingType.F_EXPRESSION);
ItemPath inducementConditionPath = ItemPath.create(AbstractRoleType.F_INDUCEMENT, AssignmentType.F_CONDITION, MappingType.F_EXPRESSION);

ItemPath wrapperPath = wrapper.getPath().namedSegmentsOnly();
return wrapper instanceof PrismPropertyWrapper && (inducementConditionPath.isSubPathOrEquivalent(wrapperPath) || assignmentConditionPath.isSubPathOrEquivalent(wrapperPath) || QNameUtil.match(AssignmentType.F_CONDITION, wrapper.getItemName()));
}
}
/*
* Copyright (c) 2020 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.factory;

import com.evolveum.midpoint.gui.api.factory.AbstractGuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.Serializable;

@Component
public class ConditionPanelFactory extends AbstractGuiComponentFactory<ExpressionType> implements Serializable {

@PostConstruct
public void register() {
getRegistry().addToRegistry(this);
}

@Override
protected Panel getPanel(PrismPropertyPanelContext<ExpressionType> panelCtx) {
AceEditorPanel conditionPanel = new AceEditorPanel(panelCtx.getComponentId(), null, new ExpressionModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 200){
@Override
protected boolean isResizeToMaxHeight() {
return false;
}
};
conditionPanel.getEditor().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
conditionPanel.getEditor().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
return conditionPanel;
}

@Override
public <IW extends ItemWrapper> boolean match(IW wrapper) {
return QNameUtil.match(ExpressionType.COMPLEX_TYPE, wrapper.getTypeName());
}
}
Expand Up @@ -49,7 +49,11 @@ protected PrismPropertyWrapper<ExpressionType> createWrapper(PrismContainerValue
ItemStatus status, WrapperContext ctx) {

ExpressionWrapper propertyWrapper = new ExpressionWrapper(parent, item, status);
getRegistry().registerWrapperPanel(item.getDefinition().getTypeName(), ExpressionPropertyPanel.class);
if (propertyWrapper.isConstructionExpression() || propertyWrapper.isAttributeExpression() || propertyWrapper.isAssociationExpression()) {
getRegistry().registerWrapperPanel(propertyWrapper.getTypeName(), ExpressionPropertyPanel.class);
} else {
return super.createWrapper(parent, item, status, ctx);
}
return propertyWrapper;
}

Expand Down
Expand Up @@ -46,7 +46,7 @@ public <IW extends ItemWrapper> boolean match(IW wrapper) {

@Override
protected Panel getPanel(PrismPropertyPanelContext<ItemPathType> panelCtx) {
return new ItemPathPanel(panelCtx.getComponentId(), (ItemPathType) panelCtx.getRealValueModel().getObject()) {
return new ItemPathPanel(panelCtx.getComponentId(), panelCtx.getRealValueModel().getObject()) {

private static final long serialVersionUID = 1L;

Expand Down
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 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.factory;

import com.evolveum.midpoint.gui.api.factory.AbstractGuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.impl.component.VariableBindingDefinitionTypePanel;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType;

import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class VariableBindingDefinitionTypePanelFactory extends AbstractGuiComponentFactory<VariableBindingDefinitionType> {


@PostConstruct
public void register() {
getRegistry().addToRegistry(this);
}

@Override
protected Panel getPanel(PrismPropertyPanelContext<VariableBindingDefinitionType> panelCtx) {
return new VariableBindingDefinitionTypePanel(panelCtx.getComponentId(), panelCtx.getRealValueModel());
}

@Override
public <IW extends ItemWrapper> boolean match(IW wrapper) {
return QNameUtil.match(VariableBindingDefinitionType.COMPLEX_TYPE, wrapper.getTypeName());
}
}
Expand Up @@ -14,11 +14,15 @@

import org.jetbrains.annotations.Nullable;

import javax.xml.namespace.QName;

/**
* Created by honchar
*/
public class ExpressionWrapper extends PrismPropertyWrapperImpl<ExpressionType> {

private QName customQName = new QName("com.evolveum.midpoint.gui","customExtenstionType");

private static final Trace LOGGER = TraceManager.getTrace(ExpressionWrapper.class);
private ConstructionType construction;

Expand Down Expand Up @@ -114,7 +118,13 @@ public Integer getDisplayOrder() {
return super.getDisplayOrder();
}
}
// @Override

@Override
public QName getTypeName() {
return customQName;
}

// @Override
// public boolean hasChanged() {
// for (ValueWrapperOld valueWrapper : getValues()) {
// ExpressionType expression = (ExpressionType) ((PrismPropertyValue) valueWrapper.getValue()).getValue();
Expand Down
Expand Up @@ -110,14 +110,11 @@ protected void populateItem(ListItem<VW> item) {


Component panel = createValuePanel(item, componentFactory, getVisibilityHandler(), getEditabilityHandler());
// panel.add(getEnableBehaviourOfValuePanel(ItemPanel.this.getModelObject()));
createButtons(item);
}

};

// values.setReuseItems(true);
// customValuesPanel(values);
return values;
}

Expand Down

0 comments on commit 1600ac4

Please sign in to comment.