use of com.evolveum.midpoint.web.component.input.DropDownChoicePanel in project midpoint by Evolveum.
the class AssignmentEditorPanel method addRelationDropDown.
private void addRelationDropDown(WebMarkupContainer relationContainer) {
List<RelationTypes> availableRelations = getModelObject().getNotAssignedRelationsList();
DropDownChoicePanel relation = WebComponentUtil.createEnumPanel(RelationTypes.class, ID_RELATION, getModelObject().isMultyAssignable() ? WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class) : Model.ofList(availableRelations), getRelationModel(availableRelations), this, false);
relation.setEnabled(getModel().getObject().isEditable());
relation.setOutputMarkupId(true);
relation.setOutputMarkupPlaceholderTag(true);
relation.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isCreatingNewAssignment();
}
});
relationContainer.add(relation);
}
use of com.evolveum.midpoint.web.component.input.DropDownChoicePanel in project midpoint by Evolveum.
the class WebComponentUtil method createEnumPanel.
public static DropDownChoicePanel createEnumPanel(final PrismPropertyDefinition def, String id, final IModel model, final Component component) {
// final Class clazz = model.getObject().getClass();
final Object o = model.getObject();
final IModel<List<DisplayableValue>> enumModelValues = new AbstractReadOnlyModel<List<DisplayableValue>>() {
@Override
public List<DisplayableValue> getObject() {
List<DisplayableValue> values = null;
if (def.getAllowedValues() != null) {
values = new ArrayList<>(def.getAllowedValues().size());
for (Object v : def.getAllowedValues()) {
if (v instanceof DisplayableValue) {
values.add(((DisplayableValue) v));
}
}
}
return values;
}
};
return new DropDownChoicePanel(id, model, enumModelValues, new IChoiceRenderer() {
@Override
public Object getObject(String id, IModel choices) {
if (StringUtils.isBlank(id)) {
return null;
}
return ((List) choices.getObject()).get(Integer.parseInt(id));
}
@Override
public Object getDisplayValue(Object object) {
if (object instanceof DisplayableValue) {
return ((DisplayableValue) object).getLabel();
}
for (DisplayableValue v : enumModelValues.getObject()) {
if (object.equals(v.getValue())) {
return v.getLabel();
}
}
return object;
}
@Override
public String getIdValue(Object object, int index) {
if (object instanceof String && enumModelValues != null && enumModelValues.getObject() != null) {
List<DisplayableValue> enumValues = enumModelValues.getObject();
for (DisplayableValue v : enumValues) {
if (object.equals(v.getValue())) {
return String.valueOf(enumValues.indexOf(v));
}
}
}
return String.valueOf(index);
}
}, true);
}
use of com.evolveum.midpoint.web.component.input.DropDownChoicePanel in project midpoint by Evolveum.
the class DefinitionScopePanel method initLayout.
protected void initLayout() {
final TextField nameField = new TextField(ID_NAME, new PropertyModel<>(getModel(), DefinitionScopeDto.F_NAME));
nameField.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return true;
}
});
add(nameField);
final TextArea descriptionField = new TextArea(ID_DESCRIPTION, new PropertyModel<>(getModel(), DefinitionScopeDto.F_DESCRIPTION));
descriptionField.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return true;
}
});
add(descriptionField);
DropDownChoicePanel objectTypeChooser = new DropDownChoicePanel(ID_OBJECT_TYPE_CHOOSER, new PropertyModel(getModel(), DefinitionScopeDto.F_OBJECT_TYPE), WebComponentUtil.createReadonlyModelFromEnum(DefinitionScopeObjectType.class), new EnumChoiceRenderer<DefinitionScopeObjectType>());
add(objectTypeChooser);
add(WebComponentUtil.createHelp(ID_OBJECT_TYPE_HELP));
TextArea filterTextArea = new TextArea(ID_SEARCH_FILTER, new PropertyModel<String>(getModel(), DefinitionScopeDto.F_SEARCH_FILTER_TEXT));
filterTextArea.setOutputMarkupId(true);
add(filterTextArea);
add(WebComponentUtil.createHelp(ID_SEARCH_FILTER_HELP));
add(new CheckBox(ID_INCLUDE_ASSIGNMENTS, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ASSIGNMENTS)));
add(new CheckBox(ID_INCLUDE_INDUCEMENTS, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_INDUCEMENTS)));
add(WebComponentUtil.createHelp(ID_ASSIGNMENTS_INDUCEMENTS_HELP));
add(new CheckBox(ID_INCLUDE_RESOURCES, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_RESOURCES)));
add(new CheckBox(ID_INCLUDE_ROLES, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ROLES)));
add(new CheckBox(ID_INCLUDE_ORGS, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ORGS)));
add(new CheckBox(ID_INCLUDE_SERVICES, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_SERVICES)));
add(WebComponentUtil.createHelp(ID_INCLUDE_TARGET_TYPES_HELP));
add(new CheckBox(ID_INCLUDE_ENABLED_ITEMS_ONLY, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ENABLED_ITEMS_ONLY)));
add(WebComponentUtil.createHelp(ID_INCLUDE_BY_STATUS_HELP));
}
use of com.evolveum.midpoint.web.component.input.DropDownChoicePanel in project midpoint by Evolveum.
the class ItemPathPanel method initLayout.
private void initLayout() {
ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, new AbstractReadOnlyModel<ItemPathDto>() {
private static final long serialVersionUID = 1L;
public ItemPathDto getObject() {
return ItemPathPanel.this.getModelObject();
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
return initNamspaceDefinitionMap();
}
};
itemDefPanel.setOutputMarkupId(true);
add(itemDefPanel);
AjaxButton plusButton = new AjaxButton(ID_PLUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
}
};
plusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
return true;
}
return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
}
});
plusButton.setOutputMarkupId(true);
add(plusButton);
AjaxButton minusButton = new AjaxButton(ID_MINUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ItemPathDto path = ItemPathPanel.this.getModelObject();
// ItemPathDto parent = null;
// if (path.getItemDef() == null){
// parent = path.getParentPath();
// } else {
// parent = path;
// }
refreshItemPathPanel(path, false, target);
}
};
minusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
}
});
minusButton.setOutputMarkupId(true);
add(minusButton);
DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<QName>(ID_NAMESPACE, new PropertyModel<QName>(getModel(), "objectType"), new ListModel<QName>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
refreshItemPath(ItemPathPanel.this.getModelObject(), target);
}
});
namespacePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
}
});
namespacePanel.setOutputMarkupId(true);
add(namespacePanel);
}
use of com.evolveum.midpoint.web.component.input.DropDownChoicePanel in project midpoint by Evolveum.
the class MergeObjectsPanel method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_FORM);
mainForm.setOutputMarkupId(true);
add(mainForm);
DropDownChoicePanel mergeTypeSelect = new DropDownChoicePanel(ID_MERGE_TYPE_SELECTOR, mergeTypeModel, mergeTypeChoicesModel);
mergeTypeSelect.getBaseFormComponent().add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
mergeResultObject = getMergeObjectsResult();
WebMarkupContainer resultObjectPanel = (WebMarkupContainer) get(ID_FORM).get(ID_OBJECTS_PANEL).get(ID_MERGE_RESULT_PANEL_CONTAINER);
resultObjectPanel.addOrReplace(getMergeResultObjectPanel());
target.add(resultObjectPanel);
}
});
mergeTypeSelect.setOutputMarkupId(true);
mainForm.add(mergeTypeSelect);
final WebMarkupContainer objectsPanel = new WebMarkupContainer(ID_OBJECTS_PANEL);
objectsPanel.setOutputMarkupId(true);
mainForm.addOrReplace(objectsPanel);
initObjectsPanel(objectsPanel);
AjaxButton switchDirectionButton = new AjaxButton(ID_SWITCH_DIRECTION_BUTTON, pageBase.createStringResource("MergeObjectsPanel.switchDirection")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
F temp = mergeObjectModel.getObject();
mergeObjectModel.setObject(mergeWithObjectModel.getObject());
mergeWithObjectModel.setObject(temp);
initObjectsPanel(objectsPanel);
ajaxRequestTarget.add(objectsPanel);
}
};
switchDirectionButton.setOutputMarkupId(true);
mainForm.add(switchDirectionButton);
}
Aggregations