Skip to content

Commit

Permalink
RoleType is set as default for AbstractRole value choose panel
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 22, 2018
1 parent 923ea59 commit 636862a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Expand Up @@ -69,9 +69,6 @@ public class ValueChoosePanel<T, O extends ObjectType> extends BasePanel<T> {
private static final String ID_TEXT = "text";
private static final String ID_FEEDBACK = "feedback";
private static final String ID_EDIT = "edit";

protected static final String MODAL_ID_OBJECT_SELECTION_POPUP = "objectSelectionPopup";


public ValueChoosePanel(String id, IModel<T> value) {
super(id, value);
Expand Down Expand Up @@ -216,7 +213,7 @@ protected void editValuePerformed(AjaxRequestTarget target) {
if (CollectionUtils.isEmpty(supportedTypes)){
supportedTypes = WebComponentUtil.createObjectTypeList();
}
Class<O> defaultType = (Class<O>) WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), supportedTypes.iterator().next());
Class<O> defaultType = getDefaultType(supportedTypes);
ObjectBrowserPanel<O> objectBrowserPanel = new ObjectBrowserPanel<O>(
getPageBase().getMainPopupBodyId(), defaultType, supportedTypes, false, getPageBase(),
filter) {
Expand All @@ -237,7 +234,11 @@ protected void onSelectPerformed(AjaxRequestTarget target, O object) {
public List<QName> getSupportedTypes() {
return WebComponentUtil.createObjectTypeList();
}


protected Class<O> getDefaultType(List<QName> supportedTypes){
return (Class<O>) WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), supportedTypes.iterator().next());
}


/*
* TODO - this method contains check, if chosen object already is not in
Expand Down
Expand Up @@ -24,6 +24,7 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.web.component.input.*;
import com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard;
Expand Down Expand Up @@ -696,6 +697,16 @@ public List<QName> getSupportedTypes() {
}
return targetTypeList;
}

@Override
protected Class getDefaultType(List<QName> supportedTypes){
if (AbstractRoleType.COMPLEX_TYPE.equals(((PrismReference)item).getDefinition().getTargetTypeName())){
return RoleType.class;
} else {
return super.getDefaultType(supportedTypes);
}
}

};

}
Expand Down

0 comments on commit 636862a

Please sign in to comment.