Search in sources :

Example 11 with EnableBehaviour

use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.

the class AssignmentPopup method createAddButton.

private AjaxButton createAddButton() {
    AjaxButton addButton = new AjaxButton(ID_ASSIGN_BUTTON, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Map<String, AssignmentType> selectedAssignmentsMap = new HashMap<>();
            TabbedPanel<ITab> panel = (TabbedPanel) AssignmentPopup.this.get(createComponentPath(ID_FORM, ID_TABS_PANEL));
            panel.getTabs().getObject().forEach(panelTab -> {
                WebMarkupContainer assignmentPanel = ((PanelTab) panelTab).getPanel();
                if (assignmentPanel == null) {
                    return;
                }
                if (AbstractAssignmentPopupTabPanel.class.isAssignableFrom(assignmentPanel.getClass())) {
                    Map<String, AssignmentType> map = (((AbstractAssignmentPopupTabPanel) assignmentPanel).getSelectedAssignmentsMap());
                    map.forEach(selectedAssignmentsMap::putIfAbsent);
                }
            });
            List<AssignmentType> assignments = new ArrayList<>(selectedAssignmentsMap.values());
            getPageBase().hideMainPopup(target);
            addPerformed(target, assignments);
        }
    };
    addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
    addButton.add(new EnableBehaviour(this::isAssignButtonEnabled));
    addButton.setOutputMarkupId(true);
    return addButton;
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 12 with EnableBehaviour

use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.

the class ChooseMemberPopup method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    Form form = new Form(ID_FORM);
    form.setOutputMarkupId(true);
    add(form);
    IModel<List<CompositedIconButtonDto>> assignButtonDescriptionModel = createAssignButtonDescriptionModel();
    MultiCompositedButtonPanel assignDescriptionButtonsPanel = new MultiCompositedButtonPanel(ID_COMPOSITED_BUTTONS, assignButtonDescriptionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
            Form form = (Form) ChooseMemberPopup.this.get(ID_FORM);
            isCompositedButtonsPanelVisible = false;
            addOrReplaceTabPanels(form, relationSpec);
            target.add(form);
        }
    };
    form.add(assignDescriptionButtonsPanel);
    assignDescriptionButtonsPanel.add(new VisibleBehaviour(() -> isCompositedButtonsPanelVisible));
    addOrReplaceTabPanels(form, null);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, createStringResource("userBrowserDialog.button.cancelButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
        }
    };
    cancelButton.setOutputMarkupId(true);
    form.add(cancelButton);
    AjaxButton addButton = new AjaxButton(ID_ADD_BUTTON, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            boolean orgPanelProcessed = false;
            for (ITab panelTab : tabs) {
                WebMarkupContainer tabPanel = ((CountablePanelTab) panelTab).getPanel();
                if (tabPanel == null) {
                    continue;
                }
                MemberPopupTabPanel memberPanel = (MemberPopupTabPanel) tabPanel;
                if (memberPanel.getObjectType().equals(ObjectTypes.ORG) && orgPanelProcessed) {
                    continue;
                }
                List<ObjectType> selectedObjects = memberPanel.getObjectType().equals(ObjectTypes.ORG) ? memberPanel.getPreselectedObjects() : memberPanel.getSelectedObjectsList();
                if (selectedObjects == null || selectedObjects.size() == 0) {
                    continue;
                }
                executeMemberOperation(memberPanel.getAbstractRoleTypeObject(), createInOidQuery(selectedObjects), memberPanel.getRelationValue(), memberPanel.getObjectType().getTypeQName(), target, getPageBase());
                if (memberPanel.getObjectType().equals(ObjectTypes.ORG)) {
                    orgPanelProcessed = true;
                }
            }
            ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
        }
    };
    addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
    addButton.add(new EnableBehaviour(() -> isAddButtonEnabled()));
    addButton.setOutputMarkupId(true);
    form.add(addButton);
}
Also used : WebPage(org.apache.wicket.markup.html.WebPage) Form(org.apache.wicket.markup.html.form.Form) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 13 with EnableBehaviour

use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.

the class CheckBoxPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    add(container);
    AjaxCheckBox check = new AjaxCheckBox(ID_CHECK, checkboxModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            CheckBoxPanel.this.onUpdate(target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            CheckBoxPanel.this.updateAjaxAttributes(attributes);
        }
    };
    check.setOutputMarkupId(true);
    check.add(new EnableBehaviour(() -> isCheckboxEnabled()));
    container.add(check);
    Label label = new Label(ID_LABEL, labelModel);
    label.add(new VisibleBehaviour(() -> labelModel != null));
    label.setRenderBodyOnly(true);
    container.add(label);
    if (tooltipModel != null) {
        container.add(new AttributeModifier("title", tooltipModel));
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 14 with EnableBehaviour

use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.

the class LinkedReferencePanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    IModel<DisplayType> displayModel = new ReadOnlyModel<>(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return null;
        }
        DisplayType displayType = GuiDisplayTypeUtil.getDisplayTypeForObject(ref.getObject(), null, getPageBase());
        if (displayType == null) {
            displayType = new DisplayType();
        }
        if (displayType.getIcon() == null) {
            displayType.setIcon(WebComponentUtil.createIconType(WebComponentUtil.createDefaultBlackIcon(ref.getTargetType())));
        }
        return displayType;
    });
    ImagePanel imagePanel = new ImagePanel(ID_ICON, displayModel);
    imagePanel.setOutputMarkupId(true);
    add(imagePanel);
    AjaxLink<PrismReferenceValue> nameLink = new AjaxLink<PrismReferenceValue>(ID_NAME, referenceModel) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            WebComponentUtil.dispatchToObjectDetailsPage(referenceModel.getObject(), LinkedReferencePanel.this, false);
        }
    };
    nameLink.add(new EnableBehaviour(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return false;
        }
        return ref.getObject() != null;
    }));
    nameLink.setOutputMarkupId(true);
    add(nameLink);
    Label nameLinkText = new Label(ID_NAME_TEXT, new ReadOnlyModel<>(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return "";
        }
        return WebComponentUtil.getReferencedObjectDisplayNameAndName(ref.asReferencable(), false, getPageBase());
    }));
    nameLinkText.setOutputMarkupId(true);
    nameLink.add(nameLinkText);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 15 with EnableBehaviour

use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.

the class SearchPropertiesConfigPanel method getTableColumns.

private List<IColumn<SelectableBean<ValueSearchFilterItem>, String>> getTableColumns() {
    List<IColumn<SelectableBean<ValueSearchFilterItem>, String>> columns = new ArrayList<>();
    CheckBoxHeaderColumn<SelectableBean<ValueSearchFilterItem>> checkboxColumn = new CheckBoxHeaderColumn<>();
    columns.add(checkboxColumn);
    IColumn<SelectableBean<ValueSearchFilterItem>, String> propertyColumn = new PropertyColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.property"), "value." + ValueSearchFilterItem.F_PROPERTY_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return getColumnStyleClass();
        }
    };
    columns.add(propertyColumn);
    IColumn<SelectableBean<ValueSearchFilterItem>, String> valueColumn = new AbstractColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.value")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ValueSearchFilterItem>>> item, String id, IModel<SelectableBean<ValueSearchFilterItem>> rowModel) {
            item.add(new SwitchablePropertyValuePanel(id, rowModel));
        }

        @Override
        public String getCssClass() {
            return "max-width-column";
        }
    };
    columns.add(valueColumn);
    IColumn<SelectableBean<ValueSearchFilterItem>, String> filterColumn = new AbstractColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.filter")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ValueSearchFilterItem>>> item, String id, IModel<SelectableBean<ValueSearchFilterItem>> rowModel) {
            List<ValueSearchFilterItem.FilterName> availableFilterNames = rowModel.getObject().getValue().getAvailableFilterNameList();
            DropDownChoicePanel<ValueSearchFilterItem.FilterName> filterPanel = WebComponentUtil.createEnumPanel(id, Model.ofList(availableFilterNames), new PropertyModel<>(rowModel, "value." + ValueSearchFilterItem.F_FILTER_TYPE_NAME), SearchPropertiesConfigPanel.this, false, getPageBase().createStringResource("SearchPropertiesConfigPanel.selectFilter").getString());
            filterPanel.setOutputMarkupId(true);
            filterPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            filterPanel.getBaseFormComponent().add(new EnableBehaviour(() -> availableFilterNames.size() > 1));
            item.add(filterPanel);
        }

        @Override
        public String getCssClass() {
            return getColumnStyleClass();
        }
    };
    columns.add(filterColumn);
    IColumn<SelectableBean<ValueSearchFilterItem>, String> matchingRuleColumn = new AbstractColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.matchingRule")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ValueSearchFilterItem>>> item, String id, IModel<SelectableBean<ValueSearchFilterItem>> rowModel) {
            DropDownChoicePanel<ValueSearchFilterItem.MatchingRule> matchingRulePanel = WebComponentUtil.createEnumPanel(id, Model.ofList(rowModel.getObject().getValue().getAvailableMatchingRuleList()), new PropertyModel<>(rowModel, "value." + ValueSearchFilterItem.F_MATCHING_RULE), SearchPropertiesConfigPanel.this, true, getPageBase().createStringResource("SearchPropertiesConfigPanel.selectMatchingRule").getString());
            matchingRulePanel.setOutputMarkupId(true);
            matchingRulePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            item.add(matchingRulePanel);
        }

        @Override
        public String getCssClass() {
            return getColumnStyleClass();
        }
    };
    columns.add(matchingRuleColumn);
    CheckBoxColumn<SelectableBean<ValueSearchFilterItem>> negationColumn = new CheckBoxColumn<SelectableBean<ValueSearchFilterItem>>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.applyNegotiation"), "value." + ValueSearchFilterItem.F_APPLY_NEGATION) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return "min-width-column";
        }
    };
    columns.add(negationColumn);
    InlineMenuButtonColumn<SelectableBean<ValueSearchFilterItem>> actionsColumn = new InlineMenuButtonColumn<SelectableBean<ValueSearchFilterItem>>(getTableMenuItems(), getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return "min-width-column";
        }
    };
    columns.add(actionsColumn);
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) Item(org.apache.wicket.markup.repeater.Item) ValueSearchFilterItem(com.evolveum.midpoint.web.component.search.filter.ValueSearchFilterItem) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) IModel(org.apache.wicket.model.IModel) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ValueSearchFilterItem(com.evolveum.midpoint.web.component.search.filter.ValueSearchFilterItem)

Aggregations

EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)17 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)9 ArrayList (java.util.ArrayList)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 Label (org.apache.wicket.markup.html.basic.Label)6 QName (javax.xml.namespace.QName)5 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)4 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)3 Form (org.apache.wicket.markup.html.form.Form)3 IModel (org.apache.wicket.model.IModel)3 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)2 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)2 Task (com.evolveum.midpoint.task.api.Task)2