Search in sources :

Example 1 with FeedbackAlerts

use of com.evolveum.midpoint.web.component.message.FeedbackAlerts in project midpoint by Evolveum.

the class PageBase method initLayout.

private void initLayout() {
    WebMarkupContainer mainHeader = new WebMarkupContainer(ID_MAIN_HEADER);
    mainHeader.setOutputMarkupId(true);
    add(mainHeader);
    AjaxLink 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() {

        @Override
        public boolean isVisible() {
            return !isCustomLogoVisible();
        }
    });
    mainHeader.add(logo);
    AjaxLink 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() {

        @Override
        public boolean isVisible() {
            return isCustomLogoVisible();
        }
    });
    mainHeader.add(customLogo);
    WebMarkupContainer navigation = new WebMarkupContainer(ID_NAVIGATION);
    mainHeader.add(navigation);
    WebMarkupContainer customLogoImgSrc = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_SRC);
    WebMarkupContainer customLogoImgCss = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_CSS);
    if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null && deploymentInfoModel.getObject().getLogo() != null) {
        if (StringUtils.isNotEmpty(deploymentInfoModel.getObject().getLogo().getCssClass())) {
            customLogoImgCss.add(new AttributeAppender("class", deploymentInfoModel.getObject().getLogo().getCssClass()));
            customLogoImgSrc.setVisible(false);
        } else {
            customLogoImgSrc.add(new AttributeAppender("src", deploymentInfoModel.getObject().getLogo().getImageUrl()));
            customLogoImgCss.setVisible(false);
        }
        mainHeader.add(new AttributeAppender("style", "background-color: " + GuiStyleConstants.DEFAULT_BG_COLOR + "; !important;"));
    }
    customLogo.add(customLogoImgSrc);
    customLogo.add(customLogoImgCss);
    Label title = new Label(ID_TITLE, createPageTitleModel());
    title.setRenderBodyOnly(true);
    add(title);
    initHeaderLayout(navigation);
    initTitleLayout(navigation);
    if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null && StringUtils.isNotEmpty(deploymentInfoModel.getObject().getHeaderColor())) {
        logo.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
        customLogo.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
        mainHeader.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
        navigation.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
    }
    initDebugBarLayout();
    List<SideBarMenuItem> menuItems = createMenuItems();
    SideBarMenuPanel sidebarMenu = new SideBarMenuPanel(ID_SIDEBAR_MENU, new Model((Serializable) menuItems));
    sidebarMenu.add(createUserStatusBehaviour(true));
    add(sidebarMenu);
    WebMarkupContainer footerContainer = new WebMarkupContainer(ID_FOOTER_CONTAINER);
    footerContainer.setOutputMarkupId(true);
    footerContainer.add(getFooterVisibleBehaviour());
    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 VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return 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 AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            String subscriptionId = getSubscriptionId();
            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);
    add(feedbackContainer);
    FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
    feedbackList.setOutputMarkupId(true);
    feedbackContainer.add(feedbackList);
    MainPopupDialog mainPopup = new MainPopupDialog(ID_MAIN_POPUP);
    mainPopup.setOutputMarkupId(true);
    add(mainPopup);
}
Also used : Serializable(java.io.Serializable) MainPopupDialog(com.evolveum.midpoint.web.component.dialog.MainPopupDialog) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) FeedbackAlerts(com.evolveum.midpoint.web.component.message.FeedbackAlerts) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 MainPopupDialog (com.evolveum.midpoint.web.component.dialog.MainPopupDialog)1 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 Serializable (java.io.Serializable)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 IModel (org.apache.wicket.model.IModel)1 Model (org.apache.wicket.model.Model)1 StringResourceModel (org.apache.wicket.model.StringResourceModel)1