Search in sources :

Example 11 with AjaxIconButton

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

the class CaseOperationalButtonsPanel method initStopProcessButton.

private void initStopProcessButton() {
    RepeatingView repeatingView = new RepeatingView(ID_CASES_BUTTONS);
    add(repeatingView);
    AjaxIconButton preview = new AjaxIconButton(repeatingView.newChildId(), Model.of(GuiStyleConstants.CLASS_STOP_MENU_ITEM), createStringResource("pageCases.button.stopProcess")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            stopCaseProcessConfirmed(ajaxRequestTarget);
        }
    };
    preview.showTitleAsLabel(true);
    preview.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
    repeatingView.add(preview);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton)

Example 12 with AjaxIconButton

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

the class AssignmentHolderOperationalButtonsPanel method createChangeArchetypeButton.

// TODO move to focus??
private void createChangeArchetypeButton(RepeatingView repeatingView) {
    IconType iconType = new IconType();
    iconType.setCssClass(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
    CompositedIconBuilder iconBuilder = new CompositedIconBuilder().setBasicIcon(GuiStyleConstants.EVO_ARCHETYPE_TYPE_ICON, IconCssStyle.IN_ROW_STYLE).appendLayerIcon(iconType, IconCssStyle.BOTTOM_RIGHT_STYLE);
    AjaxIconButton changeArchetype = new AjaxIconButton(repeatingView.newChildId(), Model.of(GuiStyleConstants.EVO_ARCHETYPE_TYPE_ICON), createStringResource("PageAdminObjectDetails.button.changeArchetype")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            changeArchetypeButtonClicked(target);
        }
    };
    changeArchetype.showTitleAsLabel(true);
    // && CollectionUtils.isNotEmpty(getArchetypeOidsListToAssign())));
    changeArchetype.add(new VisibleBehaviour(() -> isChangeArchetypeButtonVisible()));
    changeArchetype.add(AttributeAppender.append("class", "btn-default btn-sm"));
    repeatingView.add(changeArchetype);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)

Example 13 with AjaxIconButton

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

the class AssignmentPanel method initLayout.

private void initLayout() {
    MultivalueContainerListPanelWithDetailsPanel<AssignmentType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_ASSIGNMENTS, AssignmentType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isCreateNewObjectVisible() {
            return isNewObjectButtonVisible(getFocusObject());
        }

        @Override
        protected IModel<PrismContainerWrapper<AssignmentType>> getContainerModel() {
            return AssignmentPanel.this.getModel();
        }

        @Override
        protected void cancelItemDetailsPerformed(AjaxRequestTarget target) {
            AssignmentPanel.this.cancelAssignmentDetailsPerformed(target);
        }

        protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> createDefaultColumns() {
            if (AssignmentPanel.this.getModelObject() == null) {
                return new ArrayList<>();
            }
            return initBasicColumns();
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> bar = new ArrayList<>();
            AjaxIconButton newObjectButton = new AjaxIconButton(idButton, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON), createStringResource("MainObjectListPanel.newObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    newAssignmentClickPerformed(target);
                }
            };
            newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
            bar.add(newObjectButton);
            newObjectButton.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return isNewObjectButtonVisible(getFocusObject());
                }

                @Override
                public boolean isEnabled() {
                    return !isAssignmentsLimitReached();
                }
            });
            return bar;
        }

        @Override
        public void deleteItemPerformed(AjaxRequestTarget target, List<PrismContainerValueWrapper<AssignmentType>> toDeleteList) {
            int countAddedAssignments = 0;
            for (PrismContainerValueWrapper<AssignmentType> assignment : toDeleteList) {
                if (ValueStatus.ADDED.equals(assignment.getStatus())) {
                    countAddedAssignments++;
                }
            }
            boolean isLimitReached = isAssignmentsLimitReached(toDeleteList.size() - countAddedAssignments, true);
            if (isLimitReached) {
                warn(getParentPage().getString("AssignmentPanel.assignmentsLimitReachedWarning", assignmentsRequestsLimit));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            super.deleteItemPerformed(target, toDeleteList);
        }

        @Override
        protected AssignmentListProvider createProvider() {
            PageStorage pageStorage = getPageStorage(getAssignmentsTabStorageKey());
            return createAssignmentProvider(pageStorage, getSearchModel(), loadValuesModel());
        }

        @Override
        protected MultivalueContainerDetailsPanel<AssignmentType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AssignmentType>> item) {
            return createMultivalueContainerDetailsPanel(item);
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return AssignmentPanel.this.getTableId();
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
            return createSearchableItems(containerDef);
        }

        @Override
        public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
            super.refreshTable(ajaxRequestTarget);
            AssignmentPanel.this.refreshTable(ajaxRequestTarget);
        }

        @Override
        protected boolean isCollectionViewPanel() {
            return config != null && config.getListView() != null;
        }

        @Override
        protected CompiledObjectCollectionView getObjectCollectionView() {
            if (config == null) {
                return super.getObjectCollectionView();
            }
            GuiObjectListViewType listView = config.getListView();
            if (listView == null) {
                return null;
            }
            CollectionRefSpecificationType collectionRefSpecificationType = listView.getCollection();
            if (collectionRefSpecificationType == null) {
                return null;
            }
            Task task = getPageBase().createSimpleTask("Compile collection");
            OperationResult result = task.getResult();
            try {
                return getPageBase().getModelInteractionService().compileObjectCollectionView(collectionRefSpecificationType, AssignmentType.class, task, result);
            } catch (Throwable e) {
                e.printStackTrace();
            }
            return null;
        }
    };
    multivalueContainerListPanel.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) PageStorage(com.evolveum.midpoint.web.session.PageStorage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 14 with AjaxIconButton

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

the class PageTask method createResumePauseButton.

private void createResumePauseButton(RepeatingView repeatingView) {
    AjaxIconButton resumePauseRefreshing = new AjaxIconButton(repeatingView.newChildId(), (IModel<String>) this::createResumePauseButtonLabel, createStringResource("autoRefreshPanel.resumeRefreshing")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            refreshEnabled = !isRefreshEnabled();
            refresh(target);
        }
    };
    resumePauseRefreshing.add(AttributeAppender.append("class", "btn btn-default btn-margin-left btn-sm"));
    repeatingView.add(resumePauseRefreshing);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton)

Example 15 with AjaxIconButton

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

the class AbstractRoleMemberPanel method initMemberTable.

private <AH extends AssignmentHolderType> void initMemberTable(Form<?> form) {
    WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
    memberContainer.setOutputMarkupId(true);
    memberContainer.setOutputMarkupPlaceholderTag(true);
    form.add(memberContainer);
    // TODO QName defines a relation value which will be used for new member creation
    MainObjectListPanel<AH> childrenListPanel = new MainObjectListPanel<>(ID_MEMBER_TABLE, getDefaultObjectTypeClass(), getSearchOptions()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName());
        }

        @Override
        protected List<IColumn<SelectableBean<AH>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<AH>, String>> columns = super.createDefaultColumns();
            columns.add(createRelationColumn());
            return columns;
        }

        @Override
        protected boolean isObjectDetailsEnabled(IModel<SelectableBean<AH>> rowModel) {
            if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
                return false;
            }
            Class<?> objectClass = rowModel.getObject().getValue().getClass();
            return WebComponentUtil.hasDetailsPage(objectClass);
        }

        @Override
        protected boolean showNewObjectCreationPopup() {
            return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
        }

        @Override
        protected List<Component> createToolbarButtonsList(String buttonId) {
            List<Component> buttonsList = super.createToolbarButtonsList(buttonId);
            AjaxIconButton assignButton = createAssignButton(buttonId);
            buttonsList.add(1, assignButton);
            return buttonsList;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return createRowActions();
        }

        @Override
        protected String getStorageKey() {
            return AbstractRoleMemberPanel.this.createStorageKey();
        }

        protected PageStorage getPageStorage(String storageKey) {
            return getSession().getSessionStorage().getPageStorageMap().get(storageKey);
        }

        @Override
        protected Search<AH> createSearch(Class<AH> type) {
            return createMemberSearch(type);
        }

        @Override
        protected SelectableBeanObjectDataProvider<AH> createProvider() {
            SelectableBeanObjectDataProvider<AH> provider = createSelectableBeanObjectDataProvider(() -> getCustomizedQuery(getSearchModel().getObject()), null);
            provider.setIsMemberPanel(true);
            provider.addQueryVariables(ExpressionConstants.VAR_PARENT_OBJECT, AbstractRoleMemberPanel.this.getModelObject());
            return provider;
        }

        @Override
        public void refreshTable(AjaxRequestTarget target) {
            if (getSearchModel().isAttached() && getSearchModel().getObject() != null && getSearchModel().getObject().isTypeChanged()) {
                clearCache();
            }
            if (reloadPageOnRefresh()) {
                throw new RestartResponseException(getPage().getClass());
            } else {
                super.refreshTable(target);
            }
        }

        @Override
        protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
            List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
            if (refList == null) {
                refList = new ArrayList<>();
            }
            if (relation != null && CollectionUtils.isNotEmpty(relation.getArchetypeRefs())) {
                refList.addAll(relation.getArchetypeRefs());
            }
            ObjectReferenceType membershipRef = new ObjectReferenceType();
            membershipRef.setOid(AbstractRoleMemberPanel.this.getModelObject().getOid());
            membershipRef.setType(AbstractRoleMemberPanel.this.getModelObject().asPrismObject().getComplexTypeDefinition().getTypeName());
            membershipRef.setRelation(relation != null && CollectionUtils.isNotEmpty(relation.getRelations()) ? relation.getRelations().get(0) : null);
            refList.add(membershipRef);
            return refList;
        }

        @Override
        protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
            return loadMultiFunctionalButtonModel(true);
        }

        @Override
        protected String getTitleForNewObjectButton() {
            return createStringResource("TreeTablePanel.menu.createMember").getString();
        }
    };
    childrenListPanel.setOutputMarkupId(true);
    memberContainer.add(childrenListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) MultiFunctinalButtonDto(com.evolveum.midpoint.web.component.MultiFunctinalButtonDto) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) RestartResponseException(org.apache.wicket.RestartResponseException) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) Component(org.apache.wicket.Component)

Aggregations

AjaxIconButton (com.evolveum.midpoint.web.component.AjaxIconButton)31 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)27 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)11 Component (org.apache.wicket.Component)9 IModel (org.apache.wicket.model.IModel)9 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)7 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)6 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 ArrayList (java.util.ArrayList)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 List (java.util.List)3 AbstractColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn)3 Item (org.apache.wicket.markup.repeater.Item)3 ChooseMemberPopup (com.evolveum.midpoint.gui.api.component.ChooseMemberPopup)2 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)2 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2