Skip to content

Commit

Permalink
Merge branch 'feature/gui-wrapper' of https://github.com/Evolveum/mid…
Browse files Browse the repository at this point in the history
…point into feature/gui-wrapper
  • Loading branch information
katkav committed May 24, 2019
2 parents 7c46cab + f29e844 commit ba960d6
Show file tree
Hide file tree
Showing 21 changed files with 1,102 additions and 208 deletions.
Expand Up @@ -19,19 +19,14 @@
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.registry.GuiComponentRegistry;
import com.evolveum.midpoint.gui.impl.prism.CaseWorkItemTypeWrapper;
import com.evolveum.midpoint.gui.impl.prism.ExpressionWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismPropertyWrapper;
import com.evolveum.midpoint.gui.impl.prism.component.ExpressionPropertyPanel;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.page.admin.workflow.WorkItemDetailsPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down
Expand Up @@ -55,9 +55,13 @@ public int getOrder() {
@Override
protected PrismPropertyWrapper<ExpressionType> createWrapper(PrismContainerValueWrapper<?> parent, PrismProperty<ExpressionType> item,
ItemStatus status) {
getRegistry().registerWrapperPanel(item.getDefinition().getTypeName(), ExpressionPropertyPanel.class);
ExpressionWrapper propertyWrapper = new ExpressionWrapper(parent, item, status);
return propertyWrapper;
// if (propertyWrapper.isAttributeExpression() || propertyWrapper.isAssociationExpression()) {
getRegistry().registerWrapperPanel(item.getDefinition().getTypeName(), ExpressionPropertyPanel.class);
// } else {
// getRegistry().registerWrapperPanel(item.getDefinition().getTypeName(), PrismPropertyPanel.class);
// }
return propertyWrapper;
}

}
Expand Up @@ -165,7 +165,7 @@ public boolean skipCreateWrapper(ItemDefinition<?> def, WrapperContext wrapperCo
}

if (SearchFilterType.COMPLEX_TYPE.equals(def.getTypeName())) {
LOGGER.trace("Skipping creating wrapper for search filter.", def.getName());
LOGGER.trace("Skipping creating wrapper for search filter: {}", def.getName());
return true;
}

Expand Down
Expand Up @@ -46,7 +46,7 @@ public class WrapperContext {

public WrapperContext(Task task, OperationResult result) {
this.task = task;
this.result = result;
this.result = result != null ? result : new OperationResult("temporary"); // TODO !!!
}

public AuthorizationPhaseType getAuthzPhase() {
Expand Down
Expand Up @@ -112,6 +112,17 @@ public void setConstruction(ConstructionType construction) {
this.construction = construction;
}

@Override
public Integer getDisplayOrder() {
if (isAssociationExpression() || isAssociationExpression()) {
//todo MAX_VALUE doesn't guarantee that expression property
//will be displayed the last, as further there will be properties
//without any displayOrder displayed
return Integer.MAX_VALUE;
} else {
return super.getDisplayOrder();
}
}
// @Override
// public boolean hasChanged() {
// for (ValueWrapperOld valueWrapper : getValues()) {
Expand Down
Expand Up @@ -211,7 +211,7 @@ private void addValue(AjaxRequestTarget target) {
target.add(ItemPanel.this);
}

private void removeValue(VW valueToRemove, AjaxRequestTarget target) throws SchemaException {
protected void removeValue(VW valueToRemove, AjaxRequestTarget target) throws SchemaException {
LOGGER.debug("Removing value of {}", valueToRemove);
List<VW> values = getModelObject().getValues();

Expand Down
@@ -0,0 +1,43 @@
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row">
<div class="pull-left">
<button wicket:id="expandCollapseButton" wicket:message="title:PrismObjectPanel.expandCollapseContainer"
class="btn btn-box-tool expand-collapse-button" trigger="hover"><i class="fa fa-caret-down"></i></button>
</div>
<div wicket:id="labelContainer" style="float: left;">
<a class="prism-title" style="cursor: pointer;" wicket:id="label"/>

<span wicket:id="required" style="color: #f00; font-weight: bold;"
wicket:message="title:prismPropertyPanel.required">*</span>
<i class="helpTextIcon" wicket:id="help"/>
</div>

<div class="box-tools">
<button wicket:id="addButton" wicket:message="title:ExpressionPropertyHeaderPanel.addNewExpressionValue" class="btn btn-box-tool" trigger="hover">
<i class="fa fa-plus-circle"></i>
</button>
<button wicket:id="removeButton" wicket:message="title:ExpressionPropertyHeaderPanel.removeExpressionValue" class="btn btn-box-tool" trigger="hover">
<i class="fa fa-minus-circle"></i>
</button>
</div>
</div>
</wicket:panel>
</html>
@@ -0,0 +1,123 @@
package com.evolveum.midpoint.gui.impl.prism.component;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton;
import com.evolveum.midpoint.gui.api.prism.PrismContainerWrapper;
import com.evolveum.midpoint.gui.impl.prism.*;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.model.IModel;

import java.util.List;

/**
* Created by honchar
*/
public class ExpressionPropertyHeaderPanel extends ItemHeaderPanel<PrismPropertyValue<ExpressionType>, PrismProperty<ExpressionType>,
PrismPropertyDefinition<ExpressionType>, PrismPropertyWrapper<ExpressionType>> {
private static final long serialVersionUID = 1L;

private static final String ID_ADD_BUTTON = "addButton";
private static final String ID_REMOVE_BUTTON = "removeButton";
private static final String ID_EXPAND_COLLAPSE_BUTTON = "expandCollapseButton";

private boolean isExpanded;

public ExpressionPropertyHeaderPanel(String id, IModel<PrismPropertyWrapper<ExpressionType>> model) {
super(id, model);
isExpanded = model.getObject() != null && CollectionUtils.isNotEmpty(model.getObject().getValues());
}

@Override
protected void initButtons() {
AjaxLink<Void> addButton = new AjaxLink<Void>(ID_ADD_BUTTON) {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
addExpressionValuePerformed(target);
}
};
addButton.add(new VisibleBehaviour(() -> isExpressionValueEmpty()));
add(addButton);

AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_BUTTON) {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
removeExpressionValuePerformed(target);
}
};
removeButton.add(new VisibleBehaviour(() -> !isExpressionValueEmpty()));
add(removeButton);

ToggleIconButton<?> expandCollapseButton = new ToggleIconButton<Void>(ID_EXPAND_COLLAPSE_BUTTON,
GuiStyleConstants.CLASS_ICON_EXPAND_CONTAINER, GuiStyleConstants.CLASS_ICON_COLLAPSE_CONTAINER) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
onExpandClick(target);
}

@Override
public boolean isOn() {
return ExpressionPropertyHeaderPanel.this.getModelObject() != null && isExpanded;
}
};
expandCollapseButton.setOutputMarkupId(true);
add(expandCollapseButton);
}

@Override
protected Component createTitle(IModel<String> label) {
AjaxButton labelComponent = new AjaxButton(ID_LABEL, label) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
onExpandClick(target);
}
};
labelComponent.setOutputMarkupId(true);
labelComponent.add(AttributeAppender.append("style", "cursor: pointer;"));
return labelComponent;
}

private boolean isExpressionValueEmpty(){
if (getModelObject() == null || CollectionUtils.isEmpty(getModelObject().getValues())){
return true;
}
List<PrismPropertyValueWrapper<ExpressionType>> valueWrappers = getModelObject().getValues();
for(PrismPropertyValueWrapper<ExpressionType> expressionValueWrapper : valueWrappers){
if (expressionValueWrapper.getOldValue() != null && expressionValueWrapper.getOldValue().getValue() != null){
return false;
}
}
return true;
}

protected void onExpandClick(AjaxRequestTarget target) {
isExpanded = !isExpanded;
}

protected void addExpressionValuePerformed(AjaxRequestTarget target){

}

protected void removeExpressionValuePerformed(AjaxRequestTarget target){

}


}
Expand Up @@ -18,18 +18,9 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="col-md-2 col-xs-12 prism-property-label " wicket:id="header"/>
<div class="col-md-10 col-xs-12 prism-property-value" wicket:id="values">
<div class="row">
<div class="col-xs-10" wicket:id="expressionPanel"/>

<div wicket:id="buttonContainer" class="col-xs-2">
<span class="btn-group">
<!-- <a class="btn btn-danger btn-sm" wicket:id="removeButton"><i class="glyphicon glyphicon-minus"/></a>
<a class="btn btn-success btn-sm" wicket:id="addButton"><i class="glyphicon glyphicon-plus"/></a> -->
<a class="btn btn-box-tool" wicket:id="removeButton"><i class="fa fa-minus-circle"/></a>
<a class="btn btn-box-tool" wicket:id="addButton"><i class="fa fa-plus-circle"/></a>
</span>
</div>
<div class="row">
<div class="col-md-12 col-xs-12 prism-property-value" wicket:id="values">
<div wicket:id="expressionPanel"/>
</div>
</div>
</wicket:panel>
Expand Down

0 comments on commit ba960d6

Please sign in to comment.