Search in sources :

Example 1 with MultilevelPanel

use of org.apache.syncope.client.console.panels.MultilevelPanel in project syncope by apache.

the class Reports method buildTabList.

private List<ITab> buildTabList() {
    final List<ITab> tabs = new ArrayList<>();
    tabs.add(new AbstractTab(new ResourceModel("reports")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            final MultilevelPanel mlp = new MultilevelPanel(panelId);
            mlp.setFirstLevel(new ReportDirectoryPanel(mlp, getPageReference()) {

                private static final long serialVersionUID = -2195387360323687302L;

                @Override
                protected void viewTask(final ReportTO reportTO, final AjaxRequestTarget target) {
                    mlp.next(new StringResourceModel("report.view", this, new Model<>(reportTO)).getObject(), new ReportExecutionDetails(reportTO, getPageReference()), target);
                }
            });
            return mlp;
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("report.templates")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new ReportTemplateDirectoryPanel(panelId, getPageReference());
        }
    });
    return tabs;
}
Also used : ReportDirectoryPanel(org.apache.syncope.client.console.reports.ReportDirectoryPanel) ArrayList(java.util.ArrayList) ReportTO(org.apache.syncope.common.lib.to.ReportTO) ReportExecutionDetails(org.apache.syncope.client.console.reports.ReportExecutionDetails) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ReportDirectoryPanel(org.apache.syncope.client.console.reports.ReportDirectoryPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) MultilevelPanel(org.apache.syncope.client.console.panels.MultilevelPanel) ReportTemplateDirectoryPanel(org.apache.syncope.client.console.reports.ReportTemplateDirectoryPanel) MultilevelPanel(org.apache.syncope.client.console.panels.MultilevelPanel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) ReportTemplateDirectoryPanel(org.apache.syncope.client.console.reports.ReportTemplateDirectoryPanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 2 with MultilevelPanel

use of org.apache.syncope.client.console.panels.MultilevelPanel in project syncope by apache.

the class StatusPanel method init.

private void init(final AnyTO any, final IModel<List<StatusBean>> model, final List<Pair<ConnObjectTO, ConnObjectWrapper>> connObjects, final PageReference pageRef, final boolean enableConnObjectLink) {
    final List<StatusBean> statusBeans = new ArrayList<>(connObjects.size() + 1);
    initialStatusBeanMap = new LinkedHashMap<>(connObjects.size() + 1);
    final StatusBean syncope = new StatusBean(any, Constants.SYNCOPE);
    if (any instanceof UserTO) {
        syncope.setConnObjectLink(((UserTO) any).getUsername());
        Status syncopeStatus = Status.UNDEFINED;
        if (((UserTO) any).getStatus() != null) {
            try {
                syncopeStatus = Status.valueOf(((UserTO) any).getStatus().toUpperCase());
            } catch (IllegalArgumentException e) {
                LOG.warn("Unexpected status found: {}", ((UserTO) any).getStatus(), e);
            }
        }
        syncope.setStatus(syncopeStatus);
    } else if (any instanceof GroupTO) {
        syncope.setConnObjectLink(((GroupTO) any).getName());
        syncope.setStatus(Status.ACTIVE);
    }
    statusBeans.add(syncope);
    initialStatusBeanMap.put(syncope.getResource(), syncope);
    connObjects.forEach(pair -> {
        ConnObjectWrapper entry = pair.getRight();
        final StatusBean statusBean = statusUtils.getStatusBean(entry.getAny(), entry.getResourceName(), entry.getConnObjectTO(), any instanceof GroupTO);
        initialStatusBeanMap.put(entry.getResourceName(), statusBean);
        statusBeans.add(statusBean);
    });
    final MultilevelPanel mlp = new MultilevelPanel("resources");
    add(mlp);
    ListViewPanel.Builder<StatusBean> builder = new ListViewPanel.Builder<StatusBean>(StatusBean.class, pageRef) {

        private static final long serialVersionUID = -6809736686861678498L;

        @Override
        protected Component getValueComponent(final String key, final StatusBean bean) {
            if ("status".equalsIgnoreCase(key)) {
                return StatusUtils.getStatusImagePanel("field", bean.getStatus());
            } else {
                return super.getValueComponent(key, bean);
            }
        }
    };
    builder.setModel(model);
    builder.setItems(statusBeans);
    builder.includes("resource", "connObjectLink", "status");
    builder.withChecks(ListViewPanel.CheckAvailability.NONE);
    builder.setReuseItem(false);
    final ActionLink<StatusBean> connObjectLink = new ActionLink<StatusBean>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        protected boolean statusCondition(final StatusBean bean) {
            final Pair<ConnObjectTO, ConnObjectTO> pair = getConnObjectTO(bean.getKey(), bean.getResource(), connObjects);
            return pair != null && pair.getRight() != null;
        }

        @Override
        public void onClick(final AjaxRequestTarget target, final StatusBean bean) {
            mlp.next(bean.getResource(), new RemoteAnyPanel(bean, connObjects), target);
        }
    };
    if (!enableConnObjectLink) {
        connObjectLink.disable();
    }
    builder.addAction(connObjectLink, ActionLink.ActionType.VIEW, StandardEntitlement.RESOURCE_GET_CONNOBJECT);
    listViewPanel = ListViewPanel.class.cast(builder.build(MultilevelPanel.FIRST_LEVEL_ID));
    mlp.setFirstLevel(listViewPanel);
}
Also used : Status(org.apache.syncope.client.console.commons.status.Status) ArrayList(java.util.ArrayList) GroupTO(org.apache.syncope.common.lib.to.GroupTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MultilevelPanel(org.apache.syncope.client.console.panels.MultilevelPanel) StatusBean(org.apache.syncope.client.console.commons.status.StatusBean) UserTO(org.apache.syncope.common.lib.to.UserTO) ListViewPanel(org.apache.syncope.client.console.panels.ListViewPanel) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) ConnObjectWrapper(org.apache.syncope.client.console.commons.status.ConnObjectWrapper) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Aggregations

ArrayList (java.util.ArrayList)2 MultilevelPanel (org.apache.syncope.client.console.panels.MultilevelPanel)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)1 ConnObjectWrapper (org.apache.syncope.client.console.commons.status.ConnObjectWrapper)1 Status (org.apache.syncope.client.console.commons.status.Status)1 StatusBean (org.apache.syncope.client.console.commons.status.StatusBean)1 ListViewPanel (org.apache.syncope.client.console.panels.ListViewPanel)1 ReportDirectoryPanel (org.apache.syncope.client.console.reports.ReportDirectoryPanel)1 ReportExecutionDetails (org.apache.syncope.client.console.reports.ReportExecutionDetails)1 ReportTemplateDirectoryPanel (org.apache.syncope.client.console.reports.ReportTemplateDirectoryPanel)1 ActionLink (org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)1 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)1 GroupTO (org.apache.syncope.common.lib.to.GroupTO)1 ReportTO (org.apache.syncope.common.lib.to.ReportTO)1 UserTO (org.apache.syncope.common.lib.to.UserTO)1 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)1 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)1 Panel (org.apache.wicket.markup.html.panel.Panel)1 ResourceModel (org.apache.wicket.model.ResourceModel)1