Search in sources :

Example 66 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class PageArchetype method createMainPanel.

@Override
protected AbstractObjectMainPanel<ArchetypeType> createMainPanel(String id) {
    return new AbstractRoleMainPanel<>(id, getObjectModel(), getProjectionModel(), this) {

        private static final long serialVersionUID = 1L;

        @Override
        public AbstractRoleMemberPanel<ArchetypeType> createMemberPanel(String panelId, PageBase pageBase) {
            return new ArchetypeMembersPanel(panelId, new Model<>(getObject().asObjectable()), pageBase);
        }

        @Override
        protected List<ITab> createTabs(PageAdminObjectDetails<ArchetypeType> parentPage) {
            List<ITab> tabs = super.createTabs(parentPage);
            tabs.add(new PanelTab(parentPage.createStringResource("PageArchetype.archetypePolicy"), getTabVisibility(ComponentConstants.UI_ARCHTYPE_TAB_ARCHETYPE_POLICY_URL, false, parentPage)) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new ContainerOfSystemConfigurationPanel<ArchetypePolicyType>(panelId, PrismContainerWrapperModel.fromContainerWrapper(getObjectModel(), ArchetypeType.F_ARCHETYPE_POLICY), ArchetypePolicyType.COMPLEX_TYPE);
                }
            });
            return tabs;
        }
    };
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PageAdminObjectDetails(com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ArchetypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType) AbstractRoleMainPanel(com.evolveum.midpoint.web.component.objectdetails.AbstractRoleMainPanel) ArchetypePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypePolicyType)

Example 67 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class SwitchablePropertyValuePanel method getValueField.

private <T> Component getValueField(String id) {
    Component searchItemField = null;
    ItemDefinition propertyDef = getPropertyItemDefinition();
    if (propertyDef != null) {
        PrismObject<LookupTableType> lookupTable = WebComponentUtil.findLookupTable(propertyDef, getPageBase());
        if (propertyDef instanceof PrismReferenceDefinition) {
            searchItemField = new ReferenceValueSearchPanel(id, new PropertyModel<>(getModel(), "value.value"), (PrismReferenceDefinition) propertyDef) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void referenceValueUpdated(ObjectReferenceType ort, AjaxRequestTarget target) {
                    SwitchablePropertyValuePanel.this.getModelObject().getValue().setValue(ort);
                }
            };
        } else if (propertyDef instanceof PrismPropertyDefinition) {
            List<DisplayableValue> allowedValues = new ArrayList<>();
            if (((PrismPropertyDefinition) propertyDef).getAllowedValues() != null) {
                allowedValues.addAll(((PrismPropertyDefinition) propertyDef).getAllowedValues());
            } else if (propertyDef.getTypeClass().equals(boolean.class) || Boolean.class.isAssignableFrom(propertyDef.getTypeClass())) {
                allowedValues.add(new SearchValue<>(Boolean.TRUE, getString("Boolean.TRUE")));
                allowedValues.add(new SearchValue<>(Boolean.FALSE, getString("Boolean.FALSE")));
            }
            if (lookupTable != null) {
                searchItemField = new AutoCompleteTextPanel<String>(id, new PropertyModel<>(getModel(), "value." + ValueSearchFilterItem.F_VALUE), String.class, true, lookupTable.asObjectable()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public Iterator<String> getIterator(String input) {
                        return WebComponentUtil.prepareAutoCompleteList(lookupTable.asObjectable(), input, ((PageBase) getPage()).getLocalizationService()).iterator();
                    }
                };
            } else if (CollectionUtils.isNotEmpty(allowedValues)) {
                List<T> allowedValuesList = new ArrayList<>();
                allowedValues.forEach(val -> allowedValuesList.add((T) val.getValue()));
                searchItemField = new DropDownChoicePanel<T>(id, new PropertyModel<>(getModel(), "value." + ValueSearchFilterItem.F_VALUE), Model.ofList(allowedValuesList), new IChoiceRenderer<T>() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public Object getDisplayValue(T val) {
                        if (val instanceof DisplayableValue) {
                            return ((DisplayableValue) val).getLabel();
                        }
                        return val;
                    }

                    @Override
                    public String getIdValue(T val, int index) {
                        return Integer.toString(index);
                    }

                    @Override
                    public T getObject(String id, IModel<? extends List<? extends T>> choices) {
                        return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
                    }
                }, true);
            } else {
                searchItemField = new TextPanel<String>(id, new PropertyModel<>(getModel(), "value." + ValueSearchFilterItem.F_VALUE));
            }
        }
    }
    if (searchItemField instanceof InputPanel) {
        ((InputPanel) searchItemField).getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    }
    return searchItemField != null ? searchItemField : new WebMarkupContainer(id);
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) ArrayList(java.util.ArrayList) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.apache.wicket.Component) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 68 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class PageSelfDashboard method initMyAccounts.

private void initMyAccounts(Session session) {
    AsyncDashboardPanel<Object, List<SimpleAccountDto>> accounts = new AsyncDashboardPanel<>(ID_ACCOUNTS, createStringResource("PageDashboard.accounts"), GuiStyleConstants.CLASS_SHADOW_ICON_ACCOUNT, GuiStyleConstants.CLASS_OBJECT_SHADOW_BOX_CSS_CLASSES, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected SecurityContextAwareCallable<CallableResult<List<SimpleAccountDto>>> createCallable(Authentication auth, IModel<Object> callableParameterModel) {
            return new SecurityContextAwareCallable<>(getSecurityContextManager(), auth) {

                @Override
                public AccountCallableResult<List<SimpleAccountDto>> callWithContextPrepared() {
                    // TODO is this correct? [med]
                    setupContext(application, session);
                    return loadAccounts();
                }
            };
        }

        @Override
        protected Component getMainComponent(String markupId) {
            return new MyAccountsPanel(markupId, new PropertyModel<>(getModel(), CallableResult.F_VALUE));
        }

        @Override
        protected void onPostSuccess(AjaxRequestTarget target) {
            showFetchResult();
            super.onPostSuccess(target);
        }

        @Override
        protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
            showFetchResult();
            super.onUpdateError(target, ex);
        }

        private void showFetchResult() {
            AccountCallableResult<List<SimpleAccountDto>> result = (AccountCallableResult<List<SimpleAccountDto>>) getModel().getObject();
            PageBase page = (PageBase) getPage();
            for (OperationResult res : result.getFetchResults()) {
                if (!WebComponentUtil.isSuccessOrHandledError(res)) {
                    page.showResult(res);
                }
            }
        }
    };
    accounts.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_ACCOUNTS);
            return WebComponentUtil.getElementVisibility(visibilityType);
        }
    });
    add(accounts);
}
Also used : IModel(org.apache.wicket.model.IModel) SimpleAccountDto(com.evolveum.midpoint.web.page.admin.home.dto.SimpleAccountDto) SecurityContextAwareCallable(com.evolveum.midpoint.web.component.SecurityContextAwareCallable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AsyncDashboardPanel(com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel) MyAccountsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyAccountsPanel) Authentication(org.springframework.security.core.Authentication) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collections.emptyList(java.util.Collections.emptyList) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) CallableResult(com.evolveum.midpoint.web.component.util.CallableResult) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)

Example 69 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class RoleCatalogTabPanel method createScopeItem.

private SearchItem createScopeItem(Search search) {
    return new SpecialSearchItem(search) {

        @Override
        public ObjectFilter createFilter(PageBase pageBase, VariablesMap variables) {
            return null;
        }

        @Override
        public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
            return new SearchSpecialItemPanel(id, new PropertyModel(getRoleCatalogStorage(), RoleCatalogStorage.F_ORG_SEARCH_SCOPE)) {

                @Override
                protected WebMarkupContainer initSearchItemField(String id) {
                    DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, getModelValue(), Model.of(Arrays.asList(SearchBoxScopeType.values())), new EnumChoiceRenderer(), false);
                    inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
                    inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 88px; max-width: 400px !important;"));
                    inputPanel.setOutputMarkupId(true);
                    return inputPanel;
                }

                @Override
                protected IModel<String> createLabelModel() {
                    return getPageBase().createStringResource("abstractRoleMemberPanel.searchScope");
                }

                @Override
                protected IModel<String> createHelpModel() {
                    return getPageBase().createStringResource("abstractRoleMemberPanel.searchScope.tooltip");
                }
            };
        }
    };
}
Also used : SpecialSearchItem(com.evolveum.midpoint.web.component.search.SpecialSearchItem) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) EnumChoiceRenderer(org.apache.wicket.markup.html.form.EnumChoiceRenderer) PropertyModel(org.apache.wicket.model.PropertyModel) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)

Example 70 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ConfigurationStep method testConnectionPerformed.

// copied from PageResource, TODO deduplicate
private void testConnectionPerformed(AjaxRequestTarget target) {
    parentPage.refreshIssues(null);
    if (parentPage.isReadOnly() || !isComplete()) {
        return;
    }
    saveChanges();
    PageBase page = getPageBase();
    TestConnectionResultPanel testConnectionPanel = new TestConnectionResultPanel(page.getMainPopupBodyId(), resourceModelNoFetch.getObject().getOid(), getPage());
    testConnectionPanel.setOutputMarkupId(true);
    page.showMainPopup(testConnectionPanel, target);
    // page.showResult(result, "Test connection failed", false);
    target.add(page.getFeedbackPanel());
    target.add(getForm());
}
Also used : TestConnectionResultPanel(com.evolveum.midpoint.web.page.admin.resources.component.TestConnectionResultPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Aggregations

PageBase (com.evolveum.midpoint.gui.api.page.PageBase)82 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)30 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)25 Task (com.evolveum.midpoint.task.api.Task)16 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)13 IModel (org.apache.wicket.model.IModel)12 Label (org.apache.wicket.markup.html.basic.Label)11 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)9 ArrayList (java.util.ArrayList)9 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)9 List (java.util.List)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 RestartResponseException (org.apache.wicket.RestartResponseException)6 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)5 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)5 QName (javax.xml.namespace.QName)5