Search in sources :

Example 1 with DropDownChoicePanel

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);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 2 with DropDownChoicePanel

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);
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) IModel(org.apache.wicket.model.IModel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 3 with DropDownChoicePanel

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));
}
Also used : DefinitionScopeObjectType(com.evolveum.midpoint.web.page.admin.certification.dto.DefinitionScopeObjectType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) PropertyModel(org.apache.wicket.model.PropertyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 4 with DropDownChoicePanel

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);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Collection(java.util.Collection) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 5 with DropDownChoicePanel

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Form(com.evolveum.midpoint.web.component.form.Form) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)9 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 PropertyModel (org.apache.wicket.model.PropertyModel)4 Component (org.apache.wicket.Component)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 FormComponent (org.apache.wicket.markup.html.form.FormComponent)3 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)2 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)2 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)2 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 Label (org.apache.wicket.markup.html.basic.Label)2 ObjectTypeSelectPanel (com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel)1 ItemPathDto (com.evolveum.midpoint.gui.api.component.path.ItemPathDto)1 ItemPathPanel (com.evolveum.midpoint.gui.api.component.path.ItemPathPanel)1