Skip to content

Commit

Permalink
new relations dropdown component for assignments popup
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jul 26, 2018
1 parent 6c8e843 commit d6df32c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Expand Up @@ -15,29 +15,25 @@
*/
package com.evolveum.midpoint.gui.api.component;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.RoleSelectionSpecification;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.RelationTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.component.input.RelationDropDownChoicePanel;
import com.evolveum.midpoint.web.security.SecurityUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AreaCategoryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import org.apache.commons.collections.map.HashedMap;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.Model;

import javax.xml.namespace.QName;
import java.util.*;
Expand Down Expand Up @@ -66,13 +62,7 @@ protected void initParametersPanel(Fragment parametersPanel){
relationContainer.setOutputMarkupId(true);
parametersPanel.add(relationContainer);

DropDownChoicePanel<RelationTypes> relationSelector = WebComponentUtil.createEnumPanel(RelationTypes.class, ID_RELATION,
WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class), Model.of(RelationTypes.MEMBER),
FocusTypeAssignmentPopupTabPanel.this, false);
relationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
relationSelector.setOutputMarkupId(true);
relationSelector.setOutputMarkupPlaceholderTag(true);
relationContainer.add(relationSelector);
relationContainer.add(new RelationDropDownChoicePanel(ID_RELATION, null, AreaCategoryType.SELF_SERVICE));
}

@Override
Expand All @@ -88,16 +78,12 @@ protected Map<String, AssignmentType> getSelectedAssignmentsMap(){
}

public QName getRelationValue(){
DropDownChoicePanel<RelationTypes> relationPanel = getRelationDropDown();
RelationTypes relation = relationPanel.getModel().getObject();
if (relation == null) {
return SchemaConstants.ORG_DEFAULT;
}
return relation.getRelation();
RelationDropDownChoicePanel relationPanel = getRelationDropDown();
return relationPanel.getRelationValue();
}

private DropDownChoicePanel getRelationDropDown(){
return (DropDownChoicePanel)get(ID_PARAMETERS_PANEL).get(ID_RELATION_CONTAINER).get(ID_RELATION);
private RelationDropDownChoicePanel getRelationDropDown(){
return (RelationDropDownChoicePanel)get(ID_PARAMETERS_PANEL).get(ID_RELATION_CONTAINER).get(ID_RELATION);
}

@Override
Expand Down
Expand Up @@ -61,7 +61,11 @@ public RelationDropDownChoicePanel(String id, IModel<QName> model, AreaCategoryT
protected void onInitialize(){
super.onInitialize();

DropDownChoice<QName> input = new DropDownChoice<>(ID_INPUT, getModel(), Model.ofList(getChoicesList()), getRenderer());
List<QName> choicesList = getChoicesList();
QName defaultValue = choicesList.size() > 0 ? choicesList.get(0) : null;

DropDownChoice<QName> input = new DropDownChoice<>(ID_INPUT, getModel() == null ? Model.of(defaultValue) : getModel(),
Model.ofList(choicesList), getRenderer());
input.setNullValid(false);
input.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
add(input);
Expand Down Expand Up @@ -110,4 +114,8 @@ public String getIdValue(QName object, int index) {
}
};
}

public QName getRelationValue() {
return ((DropDownChoice<QName>) get(ID_INPUT)).getModelObject();
}
}

0 comments on commit d6df32c

Please sign in to comment.