Search in sources :

Example 1 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class ObjectHistoryTabPanel method initLayout.

private void initLayout(final LoadableModel<ObjectWrapper<F>> focusWrapperModel, final PageAdminObjectDetails<F> page) {
    AuditSearchDto searchDto = new AuditSearchDto();
    ObjectReferenceType ort = new ObjectReferenceType();
    ort.setOid(focusWrapperModel.getObject().getOid());
    searchDto.setTargetNames(asList(ort));
    searchDto.setEventStage(AuditEventStageType.EXECUTION);
    Map<String, Boolean> visibilityMap = new HashMap<>();
    visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_COLUMN_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_COLUMN_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_COLUMN_VISIBILITY, false);
    AuditLogViewerPanel panel = new AuditLogViewerPanel(ID_MAIN_PANEL, page, searchDto, visibilityMap) {

        @Override
        protected List<IColumn<AuditEventRecordType, String>> initColumns() {
            List<IColumn<AuditEventRecordType, String>> columns = super.initColumns();
            IColumn<AuditEventRecordType, String> column = new MultiButtonColumn<AuditEventRecordType>(new Model(), 2) {

                private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS };

                @Override
                public String getCaption(int id) {
                    return "";
                }

                @Override
                public String getButtonTitle(int id) {
                    switch(id) {
                        case 0:
                            return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectDataTitle").getString();
                        case 1:
                            return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectXmlTitle").getString();
                    }
                    return "";
                }

                @Override
                public String getButtonColorCssClass(int id) {
                    return colors[id].toString();
                }

                @Override
                protected String getButtonCssClass(int id) {
                    StringBuilder sb = new StringBuilder();
                    sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" ");
                    sb.append(getButtonColorCssClass(id)).append(" ");
                    switch(id) {
                        case 0:
                            sb.append("fa fa-circle-o");
                            break;
                        case 1:
                            sb.append("fa fa-file-text-o");
                            break;
                    }
                    return sb.toString();
                }

                @Override
                public void clickPerformed(int id, AjaxRequestTarget target, IModel<AuditEventRecordType> model) {
                    switch(id) {
                        case 0:
                            currentStateButtonClicked(target, focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE), page.getCompileTimeClass());
                            break;
                        case 1:
                            viewObjectXmlButtonClicked(focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), page.getCompileTimeClass(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE));
                            break;
                    }
                }
            };
            columns.add(column);
            return columns;
        }
    };
    panel.setOutputMarkupId(true);
    add(panel);
}
Also used : IModel(org.apache.wicket.model.IModel) HashMap(java.util.HashMap) AuditSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuditLogViewerPanel(com.evolveum.midpoint.web.page.admin.reports.component.AuditLogViewerPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DoubleButtonColumn(com.evolveum.midpoint.web.component.data.column.DoubleButtonColumn) MultiButtonColumn(com.evolveum.midpoint.web.component.data.column.MultiButtonColumn)

Example 2 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel 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 3 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class CapabilityStep method editCapabilityPerformed.

@SuppressWarnings("unchecked")
private void editCapabilityPerformed(final AjaxRequestTarget target, CapabilityDto<? extends CapabilityType> capability) {
    dtoModel.getObject().setSelected(capability);
    WebMarkupContainer config = getConfigContainer();
    WebMarkupContainer newConfig;
    CapabilityType capType = capability.getCapability();
    if (capType instanceof ActivationCapabilityType) {
        newConfig = new CapabilityActivationPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ActivationCapabilityType>) capability), parentPage) {

            @Override
            public IModel<List<QName>> createAttributeChoiceModel(final IChoiceRenderer<QName> renderer) {
                LoadableModel<List<QName>> attributeChoiceModel = new LoadableModel<List<QName>>(false) {

                    @Override
                    protected List<QName> load() {
                        List<QName> choices = new ArrayList<>();
                        PrismObject<ResourceType> resourcePrism = resourceModel.getObject();
                        try {
                            ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resourcePrism, getPageBase().getPrismContext());
                            if (schema != null) {
                                ObjectClassComplexTypeDefinition def = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
                                for (ResourceAttributeDefinition attribute : def.getAttributeDefinitions()) {
                                    choices.add(attribute.getName());
                                }
                            }
                        } catch (CommonException | RuntimeException e) {
                            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource schema attributes.", e);
                            getPageBase().error("Couldn't load resource schema attributes" + e);
                        }
                        Collections.sort(choices, new Comparator<QName>() {

                            @Override
                            public int compare(QName o1, QName o2) {
                                String s1 = (String) renderer.getDisplayValue(o1);
                                String s2 = (String) renderer.getDisplayValue(o2);
                                return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
                            }
                        });
                        return choices;
                    }
                };
                parentPage.registerDependentModel(attributeChoiceModel);
                return attributeChoiceModel;
            }
        };
    } else if (capType instanceof ScriptCapabilityType) {
        newConfig = new CapabilityScriptPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ScriptCapabilityType>) capability), getTable(), parentPage);
    } else if (capType instanceof CredentialsCapabilityType) {
        newConfig = new CapabilityCredentialsPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CredentialsCapabilityType>) capability), getTable(), parentPage);
    } else {
        newConfig = new CapabilityValuePanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CapabilityType>) capability), getTable(), parentPage);
    }
    // TODO other specific capabilities (paged, count, ...)
    newConfig.setOutputMarkupId(true);
    config.replaceWith(newConfig);
    target.add(newConfig);
    target.add(getTable());
}
Also used : RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) CapabilityDto(com.evolveum.midpoint.web.component.wizard.resource.dto.CapabilityDto) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 4 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class TargetUserSelectorComponent method getTargetUsersButtonTitle.

private IModel<String> getTargetUsersButtonTitle() {
    return new LoadableModel<String>(true) {

        public String load() {
            if (getRoleCatalogStorage().isSelfRequest()) {
                return createStringResource("AssignmentCatalogPanel.requestForMe").getString();
            }
            List<PrismObject<UserType>> targetUsersList = getRoleCatalogStorage().getTargetUserList();
            if (targetUsersList.size() == 1) {
                return createStringResource("AssignmentCatalogPanel.requestFor").getString() + " " + targetUsersList.get(0).getName().getOrig();
            }
            StringBuilder sb = new StringBuilder(createStringResource("AssignmentCatalogPanel.requestForMultiple", targetUsersList.size()).getString());
            sb.append(System.lineSeparator());
            if (getRoleCatalogStorage().isMultiUserRequest()) {
                List<PrismObject<UserType>> sortedList = getRoleCatalogStorage().getTargetUserList();
                Collections.sort(sortedList, new Comparator<PrismObject<UserType>>() {

                    @Override
                    public int compare(PrismObject<UserType> u1, PrismObject<UserType> u2) {
                        return String.CASE_INSENSITIVE_ORDER.compare(u1.getName().getOrig(), u2.getName().getOrig());
                    }
                });
                int columnsAmount = sortedList.size() / TARGET_USERS_TITLE_ROWS;
                Iterator<PrismObject<UserType>> it = sortedList.iterator();
                while (it.hasNext()) {
                    for (int i = 0; i <= columnsAmount; i++) {
                        if (it.hasNext()) {
                            PrismObject user = it.next();
                            sb.append(user.getName().getOrig());
                            if (it.hasNext()) {
                                sb.append(",\t");
                            }
                        }
                    }
                    sb.append(System.lineSeparator());
                }
            }
            return sb.toString();
        }
    };
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 5 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class FocusMainPanel method createTabPanel.

protected WebMarkupContainer createTabPanel(String panelId, FormSpecificationType formSpecificationType, PageAdminObjectDetails<F> parentPage) {
    String panelClassName = formSpecificationType.getPanelClass();
    Class<?> panelClass;
    try {
        panelClass = Class.forName(panelClassName);
    } catch (ClassNotFoundException e) {
        throw new SystemException("Panel class '" + panelClassName + "' as specified in admin GUI configuration was not found", e);
    }
    if (AbstractFocusTabPanel.class.isAssignableFrom(panelClass)) {
        Constructor<?> constructor;
        try {
            constructor = panelClass.getConstructor(String.class, Form.class, LoadableModel.class, LoadableModel.class, LoadableModel.class, PageBase.class);
        } catch (NoSuchMethodException | SecurityException e) {
            throw new SystemException("Unable to locate constructor (String,Form,LoadableModel,LoadableModel,LoadableModel,PageBase) in " + panelClass + ": " + e.getMessage(), e);
        }
        AbstractFocusTabPanel<F> tabPanel;
        try {
            tabPanel = (AbstractFocusTabPanel<F>) constructor.newInstance(panelId, getMainForm(), getObjectModel(), assignmentsModel, projectionModel, parentPage);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new SystemException("Error instantiating " + panelClass + ": " + e.getMessage(), e);
        }
        return tabPanel;
    } else if (AbstractObjectTabPanel.class.isAssignableFrom(panelClass)) {
        Constructor<?> constructor;
        try {
            constructor = panelClass.getConstructor(String.class, Form.class, LoadableModel.class, PageBase.class);
        } catch (NoSuchMethodException | SecurityException e) {
            throw new SystemException("Unable to locate constructor (String,Form,LoadableModel,PageBase) in " + panelClass + ": " + e.getMessage(), e);
        }
        AbstractObjectTabPanel<F> tabPanel;
        try {
            tabPanel = (AbstractObjectTabPanel<F>) constructor.newInstance(panelId, getMainForm(), getObjectModel(), parentPage);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new SystemException("Error instantiating " + panelClass + ": " + e.getMessage(), e);
        }
        return tabPanel;
    } else {
        throw new UnsupportedOperationException("Tab panels that are not subclasses of AbstractObjectTabPanel or AbstractFocusTabPanel are not supported yet (got " + panelClass + ")");
    }
}
Also used : Form(com.evolveum.midpoint.web.component.form.Form) Constructor(java.lang.reflect.Constructor) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CountableLoadableModel(com.evolveum.midpoint.gui.api.model.CountableLoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Aggregations

LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)24 ArrayList (java.util.ArrayList)8 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 List (java.util.List)5 Model (org.apache.wicket.model.Model)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 IModel (org.apache.wicket.model.IModel)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 Label (org.apache.wicket.markup.html.basic.Label)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 TabbedPanel (com.evolveum.midpoint.web.component.TabbedPanel)2