Search in sources :

Example 11 with LoadableModel

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

the class OperationResultPanel method createMessage.

private Label createMessage() {
    Label message = null;
    if (StringUtils.isNotBlank(getModelObject().getMessage())) {
        PropertyModel<String> messageModel = new PropertyModel<String>(getModel(), "message");
        message = new Label(ID_MESSAGE_LABEL, messageModel);
    } else {
        message = new Label(ID_MESSAGE_LABEL, new LoadableModel<Object>() {

            private static final long serialVersionUID = 1L;

            @Override
            protected Object load() {
                OpResult result = OperationResultPanel.this.getModelObject();
                String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
                return getPage().getString(resourceKey, null, resourceKey);
            }
        });
    }
    //message.setRenderBodyOnly(true);
    message.setOutputMarkupId(true);
    return message;
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 12 with LoadableModel

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

the class OperationResultPanel method initDetails.

private void initDetails(WebMarkupContainer box, Page parentPage) {
    final WebMarkupContainer details = new WebMarkupContainer("details", getModel());
    details.setOutputMarkupId(true);
    details.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModel().getObject().isShowMore();
        }
    });
    box.add(details);
    WebMarkupContainer operationPanel = new WebMarkupContainer("type");
    operationPanel.setOutputMarkupId(true);
    operationPanel.add(new AttributeAppender("class", new LoadableModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected String load() {
            return getLabelCss(getModel());
        }
    }, " "));
    details.add(operationPanel);
    Label operationLabel = new Label("operationLabel", parentPage.getString("FeedbackAlertMessageDetails.operation"));
    operationLabel.setOutputMarkupId(true);
    operationPanel.add(operationLabel);
    Label operation = new Label("operation", new LoadableModel<Object>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected Object load() {
            OpResult result = getModelObject();
            String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
            return getPage().getString(resourceKey, null, resourceKey);
        }
    });
    operation.setOutputMarkupId(true);
    operationPanel.add(operation);
    Label count = new Label("countLabel", parentPage.getString("FeedbackAlertMessageDetails.count"));
    count.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            OpResult result = getModelObject();
            return result.getCount() > 1;
        }
    });
    operationPanel.add(count);
    operationPanel.add(initCountPanel(getModel()));
    Label message = new Label("resultMessage", // PageBase.new
    new PropertyModel<String>(getModel(), "message").getObject());
    // PropertyModel<String>(model,
    // "message"));
    message.setOutputMarkupId(true);
    message.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotBlank(getModelObject().getMessage());
        }
    });
    operationPanel.add(message);
    Label messageLabel = new Label("messageLabel", parentPage.getString("FeedbackAlertMessageDetails.message"));
    messageLabel.setOutputMarkupId(true);
    messageLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotBlank(getModelObject().getMessage());
        }
    });
    operationPanel.add(messageLabel);
    initParams(operationPanel, getModel(), parentPage);
    initContexts(operationPanel, getModel(), parentPage);
    initError(operationPanel, getModel(), parentPage);
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 13 with LoadableModel

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

the class Wizard method initLayout.

protected void initLayout() {
    Form form = new Form(ID_FORM);
    add(form);
    IModel<List<WizardStepDto>> stepsModel = new LoadableModel<List<WizardStepDto>>() {

        @Override
        protected List<WizardStepDto> load() {
            return loadSteps();
        }
    };
    WizardSteps steps = new WizardSteps(ID_STEPS, stepsModel) {

        @Override
        public IWizardStep getActiveStep() {
            if (Wizard.this.getModel() != null && Wizard.this.getModel().getObject() != null) {
                return Wizard.this.getModel().getObject().getActiveStep();
            }
            return null;
        }

        @Override
        public void changeStepPerformed(AjaxRequestTarget target, WizardStepDto dto) {
            changeStep(target, dto);
        }
    };
    steps.setOutputMarkupId(true);
    steps.setVisible(hasMoreThanOneStep());
    form.add(steps);
    WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
    form.add(header);
    WebMarkupContainer view = new WebMarkupContainer(ID_VIEW);
    form.add(view);
    WizardIssuesPanel issuesPanel = new WizardIssuesPanel(ID_ISSUES, issuesModel);
    issuesPanel.setOutputMarkupId(true);
    form.add(issuesPanel);
    WizardButtonBar buttons = new WizardButtonBar(ID_BUTTONS, this);
    buttons.setOutputMarkupId(true);
    form.add(buttons);
    WebMarkupContainer autoSaveNote = new WebMarkupContainer(ID_AUTO_SAVE_NOTE);
    autoSaveNote.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
            return !wizardPage.isConfigurationOnly() && !wizardPage.isReadOnly();
        }
    });
    form.add(autoSaveNote);
    WebMarkupContainer readOnlyNote = new WebMarkupContainer(ID_READ_ONLY_NOTE);
    readOnlyNote.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
            return wizardPage.isReadOnly();
        }
    });
    form.add(readOnlyNote);
    readOnlyNote.add(new AjaxFallbackLink<String>(ID_READ_ONLY_SWITCH) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
            // e.g. to switch configuration models to read-write
            wizardPage.resetModels();
            wizardPage.setReadOnly(false);
            ajaxRequestTarget.add(wizardPage);
        }
    });
    IWizardModel wizard = getWizardModel();
    wizard.addListener(this);
    wizard.reset();
}
Also used : Form(org.apache.wicket.markup.html.form.Form) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 14 with LoadableModel

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

the class AbstractOrgTabPanel method initLayout.

private void initLayout() {
    final IModel<List<ITab>> tabModel = new LoadableModel<List<ITab>>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<ITab> load() {
            LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
            roots = loadOrgRoots();
            final List<ITab> tabs = new ArrayList<>();
            for (PrismObject<OrgType> root : roots) {
                final String oid = root.getOid();
                tabs.add(new AbstractTab(createTabTitle(root)) {

                    private static final long serialVersionUID = 1L;

                    private int tabId = tabs.size();

                    @Override
                    public WebMarkupContainer getPanel(String panelId) {
                        add(new AjaxEventBehavior("load") {

                            private static final long serialVersionUID = 1L;

                            protected void onEvent(final AjaxRequestTarget target) {
                                SessionStorage storage = getPageBase().getSessionStorage();
                                storage.getUsers().setSelectedTabId(tabId);
                            }
                        });
                        Panel panel = createTreePanel(panelId, new Model(oid), getPageBase());
                        panel.setOutputMarkupId(true);
                        return panel;
                    }
                });
            }
            LOGGER.debug("Tab count is {}", new Object[] { tabs.size() });
            return tabs;
        }
    };
    final SessionStorage storage = getPageBase().getSessionStorage();
    int selectedTab = storage.getUsers().getSelectedTabId() == -1 ? 0 : storage.getUsers().getSelectedTabId();
    List<ITab> tabsList = tabModel.getObject();
    if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
        storage.getUsers().setSelectedTabId(0);
        selectedTab = 0;
    }
    AjaxTabbedPanel<ITab> tabbedPanel = new AjaxTabbedPanel<ITab>(ID_TABS, tabModel.getObject(), new Model<>(selectedTab), null) {

        private static final long serialVersionUID = 1L;

        @Override
        public TabbedPanel<ITab> setSelectedTab(int index) {
            changeTabPerformed(index);
            return super.setSelectedTab(index);
        }
    };
    tabbedPanel.setOutputMarkupId(true);
    if (tabsList == null || tabsList.size() == 0) {
        tabbedPanel.setVisible(false);
    }
    add(tabbedPanel);
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ArrayList(java.util.ArrayList) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) ArrayList(java.util.ArrayList) List(java.util.List) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Example 15 with LoadableModel

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

the class AbstractTreeTablePanel method refreshTabbedPanel.

protected void refreshTabbedPanel(AjaxRequestTarget target) {
    PageBase page = getPageBase();
    TabbedPanel tabbedPanel = findParent(TabbedPanel.class);
    IModel<List<ITab>> tabs = tabbedPanel.getTabs();
    if (tabs instanceof LoadableModel) {
        ((LoadableModel) tabs).reset();
    }
    if (tabs.getObject() != null && tabs.getObject().size() > 0) {
        tabbedPanel.setSelectedTab(0);
    }
    target.add(tabbedPanel);
    target.add(page.getFeedbackPanel());
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) List(java.util.List) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

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