Search in sources :

Example 1 with LeftMenuPanel

use of com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel in project midpoint by Evolveum.

the class PageBase method initLayout.

private void initLayout() {
    TransparentWebMarkupContainer body = new TransparentWebMarkupContainer(ID_BODY);
    // body.add(new AttributeAppender("class", "hold-transition ", " "));
    // body.add(new AttributeAppender("class", "custom-hold-transition ", " "));
    body.add(AttributeAppender.append("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
            if (info == null || StringUtils.isEmpty(info.getSkin())) {
                return CLASS_DEFAULT_SKIN;
            }
            return info.getSkin();
        }
    }));
    add(body);
    WebMarkupContainer mainHeader = new WebMarkupContainer(ID_MAIN_HEADER);
    mainHeader.setOutputMarkupId(true);
    add(mainHeader);
    AjaxLink<String> logo = new AjaxLink<>(ID_LOGO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Class<? extends Page> page = MidPointApplication.get().getHomePage();
            setResponsePage(page);
        }
    };
    logo.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isCustomLogoVisible();
        }

        @Override
        public boolean isEnabled() {
            return isLogoLinkEnabled();
        }
    });
    mainHeader.add(logo);
    AjaxLink<String> customLogo = new AjaxLink<>(ID_CUSTOM_LOGO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            // TODO may be this should lead to customerUrl ?
            Class<? extends Page> page = MidPointApplication.get().getHomePage();
            setResponsePage(page);
        }
    };
    customLogo.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isCustomLogoVisible();
        }
    });
    mainHeader.add(customLogo);
    WebMarkupContainer navigation = new WebMarkupContainer(ID_NAVIGATION);
    navigation.setOutputMarkupId(true);
    mainHeader.add(navigation);
    IModel<IconType> logoModel = new IModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        public IconType getObject() {
            DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
            return info != null ? info.getLogo() : null;
        }
    };
    ExternalImage customLogoImgSrc = new ExternalImage(ID_CUSTOM_LOGO_IMG_SRC) {

        @Override
        protected void buildSrcAttribute(ComponentTag tag, IModel<?> srcModel) {
            tag.put("src", WebComponentUtil.getIconUrlModel(logoModel.getObject()).getObject());
        }
    };
    customLogoImgSrc.add(new VisibleBehaviour(() -> logoModel.getObject() != null && StringUtils.isEmpty(logoModel.getObject().getCssClass())));
    WebMarkupContainer customLogoImgCss = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_CSS);
    customLogoImgCss.add(new VisibleBehaviour(() -> logoModel.getObject() != null && StringUtils.isNotEmpty(logoModel.getObject().getCssClass())));
    customLogoImgCss.add(new AttributeAppender("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return logoModel.getObject() != null ? logoModel.getObject().getCssClass() : null;
        }
    }));
    mainHeader.add(new AttributeAppender("style", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return logoModel.getObject() != null ? "background-color: " + GuiStyleConstants.DEFAULT_BG_COLOR + " !important;" : null;
        }
    }));
    customLogo.add(customLogoImgSrc);
    customLogo.add(customLogoImgCss);
    Label title = new Label(ID_TITLE, createPageTitleModel());
    title.setRenderBodyOnly(true);
    add(title);
    initHeaderLayout(navigation);
    initTitleLayout(navigation);
    logo.add(createHeaderColorStyleModel(false));
    customLogo.add(createHeaderColorStyleModel(false));
    mainHeader.add(createHeaderColorStyleModel(false));
    navigation.add(createHeaderColorStyleModel(true));
    initDebugBarLayout();
    LeftMenuPanel sidebarMenu = new LeftMenuPanel(ID_SIDEBAR_MENU);
    sidebarMenu.add(createUserStatusBehaviour());
    add(sidebarMenu);
    WebMarkupContainer footerContainer = new WebMarkupContainer(ID_FOOTER_CONTAINER);
    footerContainer.add(new VisibleBehaviour(() -> !isErrorPage() && isFooterVisible()));
    add(footerContainer);
    WebMarkupContainer version = new WebMarkupContainer(ID_VERSION) {

        private static final long serialVersionUID = 1L;

        @Deprecated
        public String getDescribe() {
            return PageBase.this.getDescribe();
        }
    };
    version.add(new VisibleBehaviour(() -> isFooterVisible() && RuntimeConfigurationType.DEVELOPMENT.equals(getApplication().getConfigurationType())));
    footerContainer.add(version);
    WebMarkupContainer copyrightMessage = new WebMarkupContainer(ID_COPYRIGHT_MESSAGE);
    copyrightMessage.add(getFooterVisibleBehaviour());
    footerContainer.add(copyrightMessage);
    Label subscriptionMessage = new Label(ID_SUBSCRIPTION_MESSAGE, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            String subscriptionId = getSubscriptionId();
            if (StringUtils.isEmpty(subscriptionId)) {
                return "";
            }
            if (!WebComponentUtil.isSubscriptionIdCorrect(subscriptionId)) {
                return " " + createStringResource("PageBase.nonActiveSubscriptionMessage").getString();
            }
            if (SubscriptionType.DEMO_SUBSRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))) {
                return " " + createStringResource("PageBase.demoSubscriptionMessage").getString();
            }
            return "";
        }
    });
    subscriptionMessage.setOutputMarkupId(true);
    subscriptionMessage.add(getFooterVisibleBehaviour());
    footerContainer.add(subscriptionMessage);
    WebMarkupContainer feedbackContainer = new WebMarkupContainer(ID_FEEDBACK_CONTAINER);
    feedbackContainer.setOutputMarkupId(true);
    feedbackContainer.setOutputMarkupPlaceholderTag(true);
    add(feedbackContainer);
    FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
    feedbackList.setOutputMarkupId(true);
    feedbackList.setOutputMarkupPlaceholderTag(true);
    feedbackContainer.add(feedbackList);
    MainPopupDialog mainPopup = new MainPopupDialog(ID_MAIN_POPUP);
    // mainPopup.showUnloadConfirmation(false);
    // mainPopup.setResizable(false);
    add(mainPopup);
}
Also used : IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) LeftMenuPanel(com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel) MainPopupDialog(com.evolveum.midpoint.web.component.dialog.MainPopupDialog) Label(org.apache.wicket.markup.html.basic.Label) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) FeedbackAlerts(com.evolveum.midpoint.web.component.message.FeedbackAlerts) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) ComponentTag(org.apache.wicket.markup.ComponentTag) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ExternalImage(org.apache.wicket.markup.html.image.ExternalImage) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 2 with LeftMenuPanel

use of com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel in project midpoint by Evolveum.

the class PageBase method getActiveMenu.

private <MI extends BaseMenuItem> MI getActiveMenu() {
    LeftMenuPanel sideBarMenu = getSideBarMenuPanel();
    if (sideBarMenu == null || !sideBarMenu.isVisible()) {
        return null;
    }
    List<SideBarMenuItem> sideMenuItems = sideBarMenu.getItems();
    if (CollectionUtils.isEmpty(sideMenuItems)) {
        return null;
    }
    for (SideBarMenuItem sideBarMenuItem : sideMenuItems) {
        MI activeMenu = sideBarMenuItem.getActiveMenu(PageBase.this);
        if (activeMenu != null) {
            return activeMenu;
        }
    }
    return null;
}
Also used : SideBarMenuItem(com.evolveum.midpoint.web.component.menu.SideBarMenuItem) LeftMenuPanel(com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel)

Aggregations

LeftMenuPanel (com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 MainPopupDialog (com.evolveum.midpoint.web.component.dialog.MainPopupDialog)1 SideBarMenuItem (com.evolveum.midpoint.web.component.menu.SideBarMenuItem)1 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)1 ComponentTag (org.apache.wicket.markup.ComponentTag)1 TransparentWebMarkupContainer (org.apache.wicket.markup.html.TransparentWebMarkupContainer)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 ExternalImage (org.apache.wicket.markup.html.image.ExternalImage)1 IModel (org.apache.wicket.model.IModel)1