Search in sources :

Example 6 with ExternalLink

use of org.apache.wicket.markup.html.link.ExternalLink in project midpoint by Evolveum.

the class UserMenuPanel method initLayout.

private void initLayout() {
    WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
    add(iconBox);
    NonCachingImage img = new NonCachingImage(ID_PHOTO, new AbstractReadOnlyModel<AbstractResource>() {

        @Override
        public AbstractResource getObject() {
            if (jpegPhoto == null) {
                return null;
            } else {
                return new ByteArrayResource("image/jpeg", jpegPhoto);
            }
        }
    });
    img.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto != null;
        }
    });
    iconBox.add(img);
    ContextImage icon = new ContextImage(ID_ICON, "img/placeholder.png");
    icon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto == null;
        }
    });
    iconBox.add(icon);
    Label usernameLink = new Label(ID_USERNAME_LINK, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getShortUserName();
        }
    });
    add(usernameLink);
    WebMarkupContainer panelIconBox = new WebMarkupContainer(ID_PANEL_ICON_BOX);
    add(panelIconBox);
    NonCachingImage panelImg = new NonCachingImage(ID_PANEL_PHOTO, new AbstractReadOnlyModel<AbstractResource>() {

        @Override
        public AbstractResource getObject() {
            if (jpegPhoto == null) {
                return null;
            } else {
                return new ByteArrayResource("image/jpeg", jpegPhoto);
            }
        }
    });
    panelImg.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto != null;
        }
    });
    panelIconBox.add(panelImg);
    ContextImage panelIcon = new ContextImage(ID_PANEL_ICON, "img/placeholder.png");
    panelIcon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto == null;
        }
    });
    panelIconBox.add(panelIcon);
    Label username = new Label(ID_USERNAME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getShortUserName();
        }
    });
    username.setRenderBodyOnly(true);
    add(username);
    ExternalLink logoutLink = new ExternalLink(ID_LOGOUT_LINK, new Model<>(RequestCycle.get().getRequest().getContextPath() + "/j_spring_security_logout"), createStringResource("UserMenuPanel.logout"));
    add(logoutLink);
    AjaxButton editPasswordQ = new AjaxButton(ID_PASSWORD_QUESTIONS, createStringResource("UserMenuPanel.editPasswordQuestions")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PageMyPasswordQuestions myPasswordQuestions = new PageMyPasswordQuestions(passwordQuestionsDtoIModel);
            setResponsePage(myPasswordQuestions);
        }
    };
    add(editPasswordQ);
    if (!isPasswordModelLoaded) {
        passwordQuestionsDtoIModel = new LoadableModel<PasswordQuestionsDto>(false) {

            private static final long serialVersionUID = 1L;

            @Override
            protected PasswordQuestionsDto load() {
                return loadModel(null);
            }
        };
        isPasswordModelLoaded = true;
    }
    securityPolicyQuestionsModel = new LoadableModel<List<SecurityQuestionDefinitionType>>(false) {

        @Override
        protected List<SecurityQuestionDefinitionType> load() {
            return loadSecurityPloicyQuestionsModel();
        }
    };
    editPasswordQ.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (securityPolicyQuestionsModel == null || securityPolicyQuestionsModel.getObject() == null) {
                loadSecurityPloicyQuestionsModel();
            }
            return hasQuestions() || (securityPolicyQuestionsModel.getObject() != null && securityPolicyQuestionsModel.getObject().size() > 0);
        }
    });
}
Also used : NonCachingImage(org.apache.wicket.markup.html.image.NonCachingImage) Label(org.apache.wicket.markup.html.basic.Label) ContextImage(org.apache.wicket.markup.html.image.ContextImage) PageMyPasswordQuestions(com.evolveum.midpoint.web.page.admin.home.PageMyPasswordQuestions) AbstractResource(org.apache.wicket.request.resource.AbstractResource) ByteArrayResource(org.apache.wicket.request.resource.ByteArrayResource) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ExternalLink(org.apache.wicket.markup.html.link.ExternalLink) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Aggregations

Label (org.apache.wicket.markup.html.basic.Label)6 ExternalLink (org.apache.wicket.markup.html.link.ExternalLink)6 RepositoryModel (com.gitblit.models.RepositoryModel)3 UserModel (com.gitblit.models.UserModel)3 ProjectModel (com.gitblit.models.ProjectModel)2 LinkPanel (com.gitblit.wicket.panels.LinkPanel)2 Component (org.apache.wicket.Component)2 PageParameters (org.apache.wicket.PageParameters)2 Fragment (org.apache.wicket.markup.html.panel.Fragment)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 PageMyPasswordQuestions (com.evolveum.midpoint.web.page.admin.home.PageMyPasswordQuestions)1 PasswordQuestionsDto (com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)1 SearchType (com.gitblit.Constants.SearchType)1 SearchResult (com.gitblit.models.SearchResult)1 TicketLabel (com.gitblit.tickets.TicketLabel)1 GitblitRedirectException (com.gitblit.wicket.GitblitRedirectException)1 SessionlessForm (com.gitblit.wicket.SessionlessForm)1 StringChoiceRenderer (com.gitblit.wicket.StringChoiceRenderer)1 FilterableRepositoryList (com.gitblit.wicket.panels.FilterableRepositoryList)1