Search in sources :

Example 11 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class SearchPanel method initLayout.

private void initLayout() {
    moreDialogModel = new LoadableModel<MoreDialogDto>(false) {

        @Override
        protected MoreDialogDto load() {
            MoreDialogDto dto = new MoreDialogDto();
            dto.setProperties(createPropertiesList());
            return dto;
        }
    };
    Form form = new Form(ID_FORM);
    add(form);
    ListView items = new ListView<SearchItem>(ID_ITEMS, new PropertyModel<List<SearchItem>>(getModel(), Search.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<SearchItem> item) {
            SearchItemPanel searchItem = new SearchItemPanel(ID_ITEM, item.getModel());
            item.add(searchItem);
        }
    };
    items.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(items);
    WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP);
    moreGroup.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(moreGroup);
    AjaxLink more = new AjaxLink(ID_MORE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE));
            Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER));
            togglePopover(target, button, popover, 14);
        }
    };
    more.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            return !search.getAvailableDefinitions().isEmpty();
        }
    });
    more.setOutputMarkupId(true);
    moreGroup.add(more);
    WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER);
    searchContainer.setOutputMarkupId(true);
    form.add(searchContainer);
    AjaxSubmitButton searchSimple = new AjaxSubmitButton(ID_SEARCH_SIMPLE) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            searchPerformed(target);
        }
    };
    searchSimple.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
                return true;
            }
            return false;
        }

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
        }
    });
    searchSimple.setOutputMarkupId(true);
    searchContainer.add(searchSimple);
    WebMarkupContainer searchDropdown = new WebMarkupContainer(ID_SEARCH_DROPDOWN);
    searchDropdown.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) && queryPlagroundAccessible;
        }
    });
    searchContainer.add(searchDropdown);
    AjaxSubmitButton searchButtonBeforeDropdown = new AjaxSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            searchPerformed(target);
        }
    };
    searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
                return true;
            }
            Search search = getModelObject();
            PrismContext ctx = getPageBase().getPrismContext();
            return search.isAdvancedQueryValid(ctx);
        }
    });
    searchDropdown.add(searchButtonBeforeDropdown);
    List<InlineMenuItem> searchItems = new ArrayList<>();
    InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.search"), new InlineMenuItemAction() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismContext ctx = getPageBase().getPrismContext();
            if (getModelObject().isAdvancedQueryValid(ctx)) {
                searchPerformed(target);
            }
        }
    });
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.debug"), new InlineMenuItemAction() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            debugPerformed();
        }
    });
    searchItems.add(searchItem);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) {

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel());
            menuItemBody.setRenderBodyOnly(true);
            item.add(menuItemBody);
        }
    };
    searchDropdown.add(li);
    WebMarkupContainer linksContainer = new WebMarkupContainer(ID_LINKS_CONTAINER);
    linksContainer.setOutputMarkupId(true);
    form.add(linksContainer);
    AjaxButton advanced = new AjaxButton(ID_ADVANCED, createStringResource("SearchPanel.advanced")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.ADVANCED);
        }
    };
    advanced.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(advanced);
    AjaxButton fullTextButton = new AjaxButton(ID_FULL_TEXT, createStringResource("SearchPanel.fullText")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.FULLTEXT);
        }
    };
    fullTextButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && !SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(fullTextButton);
    AjaxButton basicSearchButton = new AjaxButton(ID_BASIC_SEARCH, createStringResource("SearchPanel.basic")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.BASIC);
        }
    };
    basicSearchButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !SearchBoxModeType.BASIC.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(basicSearchButton);
    advanced.add(new AttributeAppender("style", new LoadableModel<String>() {

        @Override
        public String load() {
            return basicSearchButton.isVisible() ? "margin-top: -20px;" : "display: table-cell; vertical-align: top;";
        }
    }));
    initPopover();
    WebMarkupContainer fullTextContainer = new WebMarkupContainer(ID_FULL_TEXT_CONTAINER);
    fullTextContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT);
        }
    });
    fullTextContainer.setOutputMarkupId(true);
    form.add(fullTextContainer);
    TextField fullTextInput = new TextField(ID_FULL_TEXT_FIELD, new PropertyModel<String>(getModel(), Search.F_FULL_TEXT));
    fullTextInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    fullTextInput.add(new Behavior() {

        @Override
        public void bind(Component component) {
            super.bind(component);
            component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {$('[about=\"searchSimple\"]').click();}")));
        }
    });
    fullTextInput.setOutputMarkupId(true);
    fullTextInput.add(new AttributeAppender("placeholder", createStringResource("SearchPanel.fullTextSearch")));
    fullTextInput.add(createVisibleBehaviour(SearchBoxModeType.FULLTEXT));
    fullTextContainer.add(fullTextInput);
    WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP);
    advancedGroup.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED));
    advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle()));
    advancedGroup.setOutputMarkupId(true);
    form.add(advancedGroup);
    Label advancedCheck = new Label(ID_ADVANCED_CHECK);
    advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle()));
    advancedGroup.add(advancedCheck);
    final TextArea advancedArea = new TextArea(ID_ADVANCED_AREA, new PropertyModel(getModel(), Search.F_ADVANCED_QUERY));
    advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateAdvancedArea(advancedArea, target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setThrottlingSettings(new ThrottlingSettings(ID_ADVANCED_AREA, Duration.milliseconds(500), true));
        }
    });
    advancedGroup.add(advancedArea);
    Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
    advancedError.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            if (!search.isShowAdvanced()) {
                return false;
            }
            return StringUtils.isNotEmpty(search.getAdvancedError());
        }
    });
    advancedGroup.add(advancedError);
}
Also used : ThrottlingSettings(org.apache.wicket.ajax.attributes.ThrottlingSettings) Form(org.apache.wicket.markup.html.form.Form) TextArea(org.apache.wicket.markup.html.form.TextArea) PrismContext(com.evolveum.midpoint.prism.PrismContext) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Behavior(org.apache.wicket.behavior.Behavior) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Component(org.apache.wicket.Component) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) MenuLinkPanel(com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 12 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class SchemaListPanel method initLayout.

protected void initLayout() {
    final ObjectClassDataProvider dataProvider = new ObjectClassDataProvider(allClasses);
    TextField objectClass = new TextField<>(ID_OBJECT_CLASS, new Model<>());
    objectClass.setOutputMarkupId(true);
    objectClass.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateSearchPerformed(target, dataProvider);
        }
    });
    add(objectClass);
    AjaxButton clearSearch = new AjaxButton(ID_CLEAR_SEARCH) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            clearSearchPerformed(target, dataProvider);
        }
    };
    add(clearSearch);
    WebMarkupContainer tableBody = new WebMarkupContainer(ID_TABLE_BODY);
    tableBody.setOutputMarkupId(true);
    add(tableBody);
    DataView<ObjectClassDto> objectClassDataView = new DataView<ObjectClassDto>(ID_OBJECT_CLASS_LIST, dataProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {

        @Override
        protected void populateItem(final Item<ObjectClassDto> item) {
            AjaxLink link = new AjaxLink(ID_CLASS_LINK) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    objectClassClickPerformed(target, item.getModelObject());
                }
            };
            item.add(link);
            Label label = new Label(ID_LABEL, new PropertyModel<>(item.getModel(), ObjectClassDto.F_DISPLAY_NAME));
            link.add(label);
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return item.getModelObject().isSelected() ? "success" : null;
                }
            }));
        }
    };
    tableBody.add(objectClassDataView);
    NavigatorPanel objectClassNavigator = new NavigatorPanel(ID_NAVIGATOR, objectClassDataView, true);
    objectClassNavigator.setOutputMarkupId(true);
    objectClassNavigator.setOutputMarkupPlaceholderTag(true);
    add(objectClassNavigator);
    WebMarkupContainer objectClassInfoContainer = new WebMarkupContainer(ID_OBJECT_CLASS_INFO_CONTAINER);
    objectClassInfoContainer.setOutputMarkupId(true);
    add(objectClassInfoContainer);
    WebMarkupContainer objectClassInfoColumn = new WebMarkupContainer(ID_OBJECT_CLASS_INFO_COLUMN);
    objectClassInfoColumn.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getSelectedObjectClass() != null;
        }
    });
    objectClassInfoContainer.add(objectClassInfoColumn);
    initDetailsPanel(objectClassInfoColumn);
    ListDataProvider<AttributeDto> attributeProvider = new ListDataProvider<>(this, attributeModel, true);
    attributeProvider.setSort(AttributeDto.F_DISPLAY_ORDER, SortOrder.ASCENDING);
    BoxedTablePanel<AttributeDto> attributeTable = new BoxedTablePanel<>(ID_ATTRIBUTE_TABLE, attributeProvider, initColumns());
    attributeTable.setOutputMarkupId(true);
    attributeTable.setItemsPerPage(UserProfileStorage.DEFAULT_PAGING_SIZE);
    attributeTable.setShowPaging(true);
    objectClassInfoColumn.add(attributeTable);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) Label(org.apache.wicket.markup.html.basic.Label) ObjectClassDataProvider(com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDataProvider) ObjectClassDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDto) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AttributeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.AttributeDto) DataView(org.apache.wicket.markup.repeater.data.DataView) Item(org.apache.wicket.markup.repeater.Item) NavigatorPanel(com.evolveum.midpoint.web.component.data.paging.NavigatorPanel) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 13 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class WizardHelpDialog method initLayout.

public void initLayout(WebMarkupContainer content) {
    Label helpLabel = new Label(ID_HELP, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(determineHelpKey());
        }
    });
    helpLabel.setEscapeModelStrings(false);
    content.add(helpLabel);
    AjaxLink ok = new AjaxLink(ID_BUTTON_OK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closePerformed(target);
        }
    };
    content.add(ok);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 14 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class SchemaHandlingStep method initLayout.

private void initLayout() {
    final ListDataProvider<ResourceObjectTypeDefinitionTypeDto> objectTypeProvider = new ListDataProvider<>(this, new PropertyModel<List<ResourceObjectTypeDefinitionTypeDto>>(schemaHandlingDtoModel, SchemaHandlingDto.F_OBJECT_TYPE_DTO_LIST));
    // first row - object types table
    WebMarkupContainer objectTypesTable = new WebMarkupContainer(ID_ROWS);
    objectTypesTable.setOutputMarkupId(true);
    add(objectTypesTable);
    // second row - object type editor
    WebMarkupContainer objectTypeEditor = new WebMarkupContainer(ID_OBJECT_TYPE_EDITOR);
    objectTypeEditor.setOutputMarkupId(true);
    objectTypeEditor.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAnySelected();
        }
    });
    add(objectTypeEditor);
    // third row container
    WebMarkupContainer thirdRowContainer = new WebMarkupContainer(ID_THIRD_ROW_CONTAINER);
    thirdRowContainer.setOutputMarkupId(true);
    add(thirdRowContainer);
    // ---------------------- details -----------------------
    // Object type table (list)
    DataView<ResourceObjectTypeDefinitionTypeDto> objectTypeDataView = new DataView<ResourceObjectTypeDefinitionTypeDto>(ID_ROW_OBJECT_TYPE, objectTypeProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {

        @Override
        protected void populateItem(final Item<ResourceObjectTypeDefinitionTypeDto> item) {
            final ResourceObjectTypeDefinitionTypeDto objectType = item.getModelObject();
            AjaxSubmitLink link = new AjaxSubmitLink(ID_LINK_OBJECT_TYPE) {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    editObjectTypePerformed(target, objectType);
                }

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(parentPage.getFeedbackPanel());
                }
            };
            item.add(link);
            Label label = new Label(ID_NAME_OBJECT_TYPE, createObjectTypeDisplayModel(objectType));
            label.setOutputMarkupId(true);
            link.add(label);
            AjaxLink delete = new AjaxLink(ID_BUTTON_DELETE_OBJECT_TYPE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteObjectTypePerformed(target, objectType);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            link.add(delete);
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return isSelected(item.getModelObject()) ? "success" : null;
                }
            }));
        }
    };
    objectTypesTable.add(objectTypeDataView);
    NavigatorPanel navigator = new NavigatorPanel(ID_PAGING_OBJECT_TYPE, objectTypeDataView, true);
    navigator.setOutputMarkupPlaceholderTag(true);
    navigator.setOutputMarkupId(true);
    add(navigator);
    AjaxSubmitLink add = new AjaxSubmitLink(ID_BUTTON_ADD_OBJECT_TYPE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            addObjectTypePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
    initObjectTypeEditor(objectTypeEditor);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DataView(org.apache.wicket.markup.repeater.data.DataView) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) NavigatorPanel(com.evolveum.midpoint.web.component.data.paging.NavigatorPanel) ResourceObjectTypeDefinitionTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ResourceObjectTypeDefinitionTypeDto) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 15 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class DelegationEditorPanel method initHeaderRow.

@Override
protected void initHeaderRow() {
    if (delegatedToMe) {
        privilegesListModel = new LoadableModel<List<AssignmentsPreviewDto>>(false) {

            @Override
            protected List<AssignmentsPreviewDto> load() {
                return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList();
            }
        };
    }
    AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    selected.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isSimpleView();
        }
    });
    headerRow.add(selected);
    Label arrowIcon = new Label(ID_ARROW_ICON);
    headerRow.add(arrowIcon);
    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
    headerRow.add(typeImage);
    AjaxLink name = new AjaxLink(ID_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(name);
    Label nameLabel;
    if (delegatedToMe) {
        OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME);
        Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME);
        nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils.resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result));
    } else {
        nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    }
    nameLabel.setOutputMarkupId(true);
    name.add(nameLabel);
    AssignmentEditorDto dto = getModelObject();
    dto.getTargetRef();
    WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
    if (delegatedToMe) {
        delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject())));
    } else {
        if (getModelObject().getDelegationOwner() != null) {
            delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
        }
    }
    headerRow.add(delegatedToTypeImage);
    AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(delegatedToName);
    Label delegatedToNameLabel;
    if (delegatedToMe) {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    } else {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName());
    }
    delegatedToNameLabel.setOutputMarkupId(true);
    delegatedToName.add(delegatedToNameLabel);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !DelegationEditorPanel.this.getModelObject().isMinimized();
        }
    };
    headerRow.add(expandButton);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) Task(com.evolveum.midpoint.task.api.Task) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)81 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)80 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)50 Label (org.apache.wicket.markup.html.basic.Label)48 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)44 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)28 ListItem (org.apache.wicket.markup.html.list.ListItem)21 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)17 ListView (org.apache.wicket.markup.html.list.ListView)17 TextField (org.apache.wicket.markup.html.form.TextField)15 ArrayList (java.util.ArrayList)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 AttributeModifier (org.apache.wicket.AttributeModifier)12 List (java.util.List)11 Form (org.apache.wicket.markup.html.form.Form)11 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)10 IModel (org.apache.wicket.model.IModel)9 Model (org.apache.wicket.model.Model)8 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)6 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)6