Example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialHeight

List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialHeight

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialHeight.

Prototype

public ModalWindow setInitialHeight(final int initialHeight) 

Source Link

Document

Sets the initial height of the window.

Usage

From source file:org.onexus.ui.api.utils.panels.HelpMark.java

License:Apache License

public HelpMark(final String panelId, final String title, final String displayLabel, final String helpText) {
    super(panelId);

    // Add modal window
    final ModalWindow modal = new ModalWindow("modalWindowEmbeeded");
    modal.setTitle(title);//from   ww  w.j  av  a 2s .c om
    modal.setInitialWidth(700);
    modal.setInitialHeight(500);
    add(modal);

    // Add mark label
    final WebMarkupContainer container = new WebMarkupContainer("displayLabel");
    container.add(new Label("label", displayLabel));
    add(container);

    // Add question mark icon
    Image img = null;
    container.add(img = new Image("imageHelp", Icons.HELP) {

        @Override
        protected boolean shouldAddAntiCacheParameter() {
            return false;
        }

    });
    img.add(new AjaxEventBehavior("onclick") {

        @Override
        protected void onEvent(final AjaxRequestTarget target) {

            if (modal != null) {
                modal.setInitialWidth(700);
                modal.setInitialHeight(500);
                modal.setContent(new HelpContentPanel(modal.getContentId(), helpText));
                modal.show(target);
            }

        }

    });

    // Visible only if there is some
    setVisible(helpText != null);

}

From source file:org.onexus.website.api.utils.panels.HelpMark.java

License:Apache License

public HelpMark(final String panelId, final String title, final String displayLabel, final String helpText) {
    super(panelId);

    // Add modal window
    final ModalWindow modal = new ModalWindow("modalWindowEmbeeded");
    modal.setTitle(title);/*from w w  w.ja v  a  2 s  .  c  o  m*/
    modal.setInitialWidth(700);
    modal.setInitialHeight(500);
    add(modal);

    // Add mark label
    final WebMarkupContainer container = new WebMarkupContainer("displayLabel");
    container.add(new Label("label", displayLabel));
    add(container);

    // Add question mark icon
    Image img = new Image("imageHelp", Icons.HELP) {

        @Override
        protected boolean shouldAddAntiCacheParameter() {
            return false;
        }

    };

    container.add(img);
    img.add(new AjaxEventBehavior("onclick") {

        @Override
        protected void onEvent(final AjaxRequestTarget target) {

            if (modal != null) {
                modal.setInitialWidth(700);
                modal.setInitialHeight(500);
                modal.setContent(new HelpContentPanel(modal.getContentId(), helpText));
                modal.show(target);
            }

        }

    });

    // Visible only if there is some
    setVisible(helpText != null);

}

From source file:org.sakaiproject.profile2.tool.pages.windows.AddFriend.java

License:Educational Community License

public AddFriend(String id, final ModalWindow window, final FriendAction friendActionModel, final String userX,
        final String userY) {
    super(id);//from w w  w.  j  a v  a2 s.c  o  m

    //get friendName
    final String friendName = FormattedText.processFormattedText(sakaiProxy.getUserDisplayName(userY),
            new StringBuffer());

    //window setup
    window.setTitle(new StringResourceModel("title.friend.add", null, new Object[] { friendName }));
    window.setInitialHeight(150);
    window.setInitialWidth(500);
    window.setResizable(false);

    //prefs and privacy
    ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(userY);
    ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(userY);

    //image
    ProfileImage image = new ProfileImage("image", new Model<String>(userY));
    image.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    add(image);

    //text
    final Label text = new Label("text",
            new StringResourceModel("text.friend.add", null, new Object[] { friendName }));
    text.setEscapeModelStrings(false);
    text.setOutputMarkupId(true);
    add(text);

    //setup form      
    Form form = new Form("form");
    form.setOutputMarkupId(true);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit", new ResourceModel("button.friend.add"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            /* double checking */

            //friend?
            if (connectionsLogic.isUserXFriendOfUserY(userX, userY)) {
                text.setDefaultModel(new StringResourceModel("error.friend.already.confirmed", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

            //has a friend request already been made to this person?
            if (connectionsLogic.isFriendRequestPending(userX, userY)) {
                text.setDefaultModel(new StringResourceModel("error.friend.already.pending", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

            //has a friend request been made from this person to the current user?
            if (connectionsLogic.isFriendRequestPending(userY, userX)) {
                text.setDefaultModel(new StringResourceModel("error.friend.already.pending", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

            //if ok, request friend
            if (connectionsLogic.requestFriend(userX, userY)) {
                friendActionModel.setRequested(true);

                //post event
                sakaiProxy.postEvent(ProfileConstants.EVENT_FRIEND_REQUEST, "/profile/" + userY, true);

                window.close(target);
            } else {
                text.setDefaultModel(
                        new StringResourceModel("error.friend.add.failed", null, new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

        }
    };
    //submitButton.add(new FocusOnLoadBehaviour());
    submitButton.add(new AttributeModifier("title", true,
            new StringResourceModel("accessibility.connection.add", null, new Object[] { friendName })));
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            friendActionModel.setRequested(false);
            window.close(target);
        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //add form
    add(form);
}

From source file:org.sakaiproject.profile2.tool.pages.windows.ConfirmFriend.java

License:Educational Community License

public ConfirmFriend(String id, final ModalWindow window, final FriendAction friendActionModel,
        final String userX, final String userY) {
    super(id);//w w w.  ja  v a 2 s.  c  om

    //get friendName
    final String friendName = FormattedText.processFormattedText(sakaiProxy.getUserDisplayName(userY),
            new StringBuffer());

    //window setup
    window.setTitle(new StringResourceModel("title.friend.confirm", null, new Object[] { friendName }));
    window.setInitialHeight(150);
    window.setInitialWidth(500);
    window.setResizable(false);

    //prefs and privacy
    ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(userY);
    ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(userY);

    //image
    ProfileImage image = new ProfileImage("image", new Model<String>(userY));
    image.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    add(image);

    //text
    final Label text = new Label("text",
            new StringResourceModel("text.friend.confirm", null, new Object[] { friendName }));
    text.setEscapeModelStrings(false);
    text.setOutputMarkupId(true);
    add(text);

    //setup form      
    Form form = new Form("form");
    form.setOutputMarkupId(true);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit",
            new ResourceModel("button.friend.confirm"), form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            /* double checking */

            //must exist a pending friend request FROM userY to userX in order to confirm it
            boolean friendRequestFromThisPerson = connectionsLogic.isFriendRequestPending(userY, userX);

            if (!friendRequestFromThisPerson) {
                text.setDefaultModel(new StringResourceModel("error.friend.not.pending.confirm", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

            //if ok, request friend
            if (connectionsLogic.confirmFriendRequest(userY, userX)) {
                friendActionModel.setConfirmed(true);

                //post event
                sakaiProxy.postEvent(ProfileConstants.EVENT_FRIEND_CONFIRM, "/profile/" + userY, true);

                window.close(target);
            } else {
                text.setDefaultModel(new StringResourceModel("error.friend.confirm.failed", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

        }
    };
    //submitButton.add(new FocusOnLoadBehaviour());
    submitButton.add(new AttributeModifier("title", true,
            new StringResourceModel("accessibility.connection.confirm", null, new Object[] { friendName })));
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            friendActionModel.setConfirmed(false);
            window.close(target);
        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //add form
    add(form);

}

From source file:org.sakaiproject.profile2.tool.pages.windows.IgnoreFriend.java

License:Educational Community License

public IgnoreFriend(String id, final ModalWindow window, final FriendAction friendActionModel,
        final String userX, final String userY) {
    super(id);//from w ww .  ja va 2  s.c  o  m

    //get friendName
    final String friendName = FormattedText.processFormattedText(sakaiProxy.getUserDisplayName(userY),
            new StringBuffer());

    //window setup
    window.setTitle(new ResourceModel("title.friend.ignore"));
    window.setInitialHeight(150);
    window.setInitialWidth(500);
    window.setResizable(false);

    //prefs and privacy
    ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(userY);
    ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(userY);

    //image
    ProfileImage image = new ProfileImage("image", new Model<String>(userY));
    image.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    add(image);

    //text
    final Label text = new Label("text",
            new StringResourceModel("text.friend.ignore", null, new Object[] { friendName }));
    text.setEscapeModelStrings(false);
    text.setOutputMarkupId(true);
    add(text);

    //setup form      
    Form form = new Form("form");
    form.setOutputMarkupId(true);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit",
            new ResourceModel("button.friend.ignore"), form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            /* double checking */

            //must exist a pending friend request FROM userY to userX in order to ignore it
            boolean friendRequestFromThisPerson = connectionsLogic.isFriendRequestPending(userY, userX);

            if (!friendRequestFromThisPerson) {
                text.setDefaultModel(new StringResourceModel("error.friend.not.pending.ignore", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

            //if ok, ignore friend request
            if (connectionsLogic.ignoreFriendRequest(userY, userX)) {
                friendActionModel.setIgnored(true);

                //post event
                sakaiProxy.postEvent(ProfileConstants.EVENT_FRIEND_IGNORE, "/profile/" + userY, true);

                window.close(target);
            } else {
                text.setDefaultModel(new StringResourceModel("error.friend.ignore.failed", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

        }
    };
    //submitButton.add(new FocusOnLoadBehaviour());
    submitButton.add(new AttributeModifier("title", true,
            new StringResourceModel("accessibility.connection.ignore", null, new Object[] { friendName })));
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            friendActionModel.setIgnored(false);
            window.close(target);
        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //add form
    add(form);

}

From source file:org.sakaiproject.profile2.tool.pages.windows.RemoveFriend.java

License:Educational Community License

public RemoveFriend(String id, final ModalWindow window, final FriendAction friendActionModel,
        final String userX, final String userY) {
    super(id);// www .  j  a  v  a 2  s .  c om

    //get friendName
    final String friendName = FormattedText.processFormattedText(sakaiProxy.getUserDisplayName(userY),
            new StringBuffer());

    //window setup
    window.setTitle(new ResourceModel("title.friend.remove"));
    window.setInitialHeight(150);
    window.setInitialWidth(500);
    window.setResizable(false);

    //prefs and privacy
    ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(userY);
    ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(userY);

    //image
    ProfileImage image = new ProfileImage("image", new Model<String>(userY));
    image.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    add(image);

    //text
    final Label text = new Label("text",
            new StringResourceModel("text.friend.remove", null, new Object[] { friendName }));
    text.setEscapeModelStrings(false);
    text.setOutputMarkupId(true);
    add(text);

    //setup form      
    Form form = new Form("form");
    form.setOutputMarkupId(true);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit",
            new ResourceModel("button.friend.remove"), form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            /* double checking */

            //must be friend in order to remove them
            boolean friend = connectionsLogic.isUserXFriendOfUserY(userX, userY);

            if (!friend) {
                text.setDefaultModel(
                        new StringResourceModel("error.friend.not.friend", null, new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

            //if ok, remove friend
            if (connectionsLogic.removeFriend(userX, userY)) {
                friendActionModel.setRemoved(true);

                //post event
                sakaiProxy.postEvent(ProfileConstants.EVENT_FRIEND_REMOVE, "/profile/" + userY, true);

                window.close(target);
            } else {
                text.setDefaultModel(new StringResourceModel("error.friend.remove.failed", null,
                        new Object[] { friendName }));
                this.setEnabled(false);
                this.add(new AttributeModifier("class", true, new Model("disabled")));
                target.add(text);
                target.add(this);
                return;
            }

        }
    };
    //submitButton.add(new FocusOnLoadBehaviour());
    submitButton.add(new AttributeModifier("title", true,
            new StringResourceModel("accessibility.connection.remove", null, new Object[] { friendName })));
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            friendActionModel.setRemoved(false);
            window.close(target);
        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //add form
    add(form);

}

From source file:org.sakaiproject.profile2.tool.pages.windows.RemoveWallItem.java

License:Educational Community License

public RemoveWallItem(String id, final ModalWindow window, final WallAction wallAction, final String userUuid,
        final WallItem wallItem) {

    super(id);//w  ww.ja va2  s .  c  o m

    window.setTitle(new ResourceModel("title.wall.remove"));
    window.setInitialHeight(150);
    window.setInitialWidth(500);
    window.setResizable(false);

    // add profile image of wall post creator
    ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(wallItem.getCreatorUuid());
    ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(wallItem.getCreatorUuid());

    ProfileImage image = new ProfileImage("image", new Model<String>(wallItem.getCreatorUuid()));
    image.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    add(image);

    final Label text;
    if (false == wallItem.getCreatorUuid().equals(userUuid)) {
        text = new Label("text", new StringResourceModel("text.wall.remove.other", null,
                new Object[] { sakaiProxy.getUserDisplayName(wallItem.getCreatorUuid()) }));
    } else {
        text = new Label("text", new StringResourceModel("text.wall.remove.mine", null, new Object[] {}));
    }
    text.setEscapeModelStrings(false);
    text.setOutputMarkupId(true);
    add(text);

    Form form = new Form("form");
    form.setOutputMarkupId(true);

    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit", new ResourceModel("button.wall.remove"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            wallAction.setItemRemoved(wallLogic.removeWallItemFromWall(wallItem));

            window.close(target);
        }
    };
    //submitButton.add(new FocusOnLoadBehaviour());

    final AttributeModifier accessibilityLabel;
    if (false == wallItem.getCreatorUuid().equals(userUuid)) {
        accessibilityLabel = new AttributeModifier("title", true,
                new StringResourceModel("accessibility.wall.remove.other", null, new Object[] {}));
    } else {
        accessibilityLabel = new AttributeModifier("title", true,
                new StringResourceModel("accessibility.wall.remove.mine", null, new Object[] {}));
    }
    submitButton.add(accessibilityLabel);
    form.add(submitButton);

    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            window.close(target);
        }
    };

    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    add(form);
}

From source file:org.syncope.console.pages.BasePage.java

License:Apache License

private void pageSetup() {
    ((SyncopeApplication) getApplication()).setupNavigationPane(this, xmlRolesReader, true, version);

    feedbackPanel = new FeedbackPanel("feedback");
    feedbackPanel.setOutputMarkupId(true);
    add(feedbackPanel);//from  ww  w. ja  v  a 2 s .co  m

    final String kind = getClass().getSimpleName().toLowerCase();
    final BookmarkablePageLink kindLink = (BookmarkablePageLink) get(kind);
    if (kindLink != null) {
        kindLink.add(new Behavior() {

            private static final long serialVersionUID = 1469628524240283489L;

            @Override
            public void onComponentTag(final Component component, final ComponentTag tag) {

                tag.put("class", kind);
            }
        });

        Component kindIcon = kindLink.get(0);
        if (kindIcon != null) {
            kindIcon.add(new Behavior() {

                private static final long serialVersionUID = 1469628524240283489L;

                @Override
                public void onComponentTag(final Component component, final ComponentTag tag) {

                    tag.put("src",
                            "../.." + SyncopeApplication.IMG_PREFIX + kind + SyncopeApplication.IMG_SUFFIX);
                }
            });
        }
    }

    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    add(editProfileModalWin);

    add(new Label("username", SyncopeSession.get().getUserId()));

    Fragment editProfileFrag;
    if ("admin".equals(SyncopeSession.get().getUserId())) {
        editProfileFrag = new Fragment("editProfile", "adminEmptyFrag", this);
    } else {
        final UserTO userTO = SyncopeSession.get().isAuthenticated() ? profileRestClient.readProfile()
                : new UserTO();

        editProfileFrag = new Fragment("editProfile", "editProfileFrag", this);

        AjaxLink editProfileLink = new IndicatingAjaxLink("link") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                    @Override
                    public Page createPage() {
                        return new UserRequestModalPage(BasePage.this.getPageReference(), editProfileModalWin,
                                userTO);
                    }
                });

                editProfileModalWin.show(target);
            }
        };
        editProfileLink.add(new Label("linkTitle", getString("editProfile")));

        Panel panel = new LinkPanel("editProfile", new ResourceModel("editProfile"));
        panel.add(editProfileLink);
        editProfileFrag.add(panel);
    }
    add(editProfileFrag);
}

From source file:org.syncope.console.pages.Login.java

License:Apache License

public Login(final PageParameters parameters) {
    super(parameters);

    form = new Form("login");

    userIdField = new TextField("userId", new Model());
    userIdField.setMarkupId("userId");
    form.add(userIdField);//  w ww. j a va  2s .  c om

    passwordField = new PasswordTextField("password", new Model());
    passwordField.setMarkupId("password");
    form.add(passwordField);

    languageSelect = new LocaleDropDown("language",
            Arrays.asList(new Locale[] { Locale.ENGLISH, Locale.ITALIAN }));

    form.add(languageSelect);

    Button submitButton = new Button("submit", new Model(getString("submit"))) {

        private static final long serialVersionUID = 429178684321093953L;

        @Override
        public void onSubmit() {
            String[] entitlements = authenticate(userIdField.getRawInput(), passwordField.getRawInput());

            if (entitlements == null) {
                error(getString("login-error"));
            } else {
                SyncopeSession.get().setUserId(userIdField.getRawInput());
                SyncopeSession.get().setEntitlements(entitlements);
                SyncopeSession.get().setCoreVersion(getCoreVersion());

                setResponsePage(WelcomePage.class, parameters);
            }
        }
    };

    submitButton.setDefaultFormProcessing(false);
    form.add(submitButton);

    add(form);
    add(new FeedbackPanel("feedback"));

    // Modal window for self registration
    final ModalWindow editProfileModalWin = new ModalWindow("selfRegModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(SELF_REG_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(SELF_REG_WIN_WIDTH);
    editProfileModalWin.setCookieName("self-reg-modal");
    add(editProfileModalWin);

    Fragment selfRegFrag;
    if (isSelfRegistrationAllowed()) {
        selfRegFrag = new Fragment("selfRegistration", "selfRegAllowed", this);

        AjaxLink selfRegLink = new IndicatingAjaxLink("link") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new UserRequestModalPage(Login.this.getPageReference(), editProfileModalWin,
                                new UserTO());
                    }
                });

                editProfileModalWin.show(target);
            }
        };
        selfRegLink.add(new Label("linkTitle", getString("selfRegistration")));

        Panel panel = new LinkPanel("selfRegistration", new ResourceModel("selfRegistration"));
        panel.add(selfRegLink);
        selfRegFrag.add(panel);
    } else {
        selfRegFrag = new Fragment("selfRegistration", "selfRegNotAllowed", this);
    }
    add(selfRegFrag);
}

From source file:org.syncope.console.pages.panels.PoliciesPanel.java

License:Apache License

public PoliciesPanel(final String id, final PolicyType policyType) {
    super(id);//from  ww  w . j a  v a  2 s  .co  m

    this.policyType = policyType;

    // Modal window for editing user attributes
    final ModalWindow mwindow = new ModalWindow("editModalWin");
    mwindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    mwindow.setInitialHeight(MODAL_WIN_HEIGHT);
    mwindow.setInitialWidth(MODAL_WIN_WIDTH);
    mwindow.setCookieName("policy-modal");
    add(mwindow);

    // Container for user list
    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    setWindowClosedCallback(mwindow, container);

    final List<IColumn> columns = new ArrayList<IColumn>();

    columns.add(new PropertyColumn(new ResourceModel("id"), "id", "id"));

    columns.add(new PropertyColumn(new ResourceModel("description"), "description", "description"));

    columns.add(new AbstractColumn<PolicyTO>(new ResourceModel("type")) {

        private static final long serialVersionUID = 8263694778917279290L;

        @Override
        public void populateItem(final Item<ICellPopulator<PolicyTO>> cellItem, final String componentId,
                final IModel<PolicyTO> model) {

            cellItem.add(new Label(componentId, getString(model.getObject().getType().name())));
        }
    });

    columns.add(new AbstractColumn<PolicyTO>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public String getCssClass() {
            return "action";
        }

        @Override
        public void populateItem(final Item<ICellPopulator<PolicyTO>> cellItem, final String componentId,
                final IModel<PolicyTO> model) {

            final PolicyTO accountPolicyTO = model.getObject();

            final ActionLinksPanel panel = new ActionLinksPanel(componentId, model);

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {

                    mwindow.setPageCreator(new ModalWindow.PageCreator() {

                        private static final long serialVersionUID = -7834632442532690940L;

                        @Override
                        public Page createPage() {
                            final PolicyModalPage page = new PolicyModalPage(mwindow, accountPolicyTO);
                            return page;
                        }
                    });

                    mwindow.show(target);
                }
            }, ActionLink.ActionType.EDIT, "Policies", "read");

            panel.add(new ActionLink() {

                private static final long serialVersionUID = -3722207913631435501L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    try {

                        policyRestClient.delete(accountPolicyTO.getId());
                        info(getString("operation_succeded"));

                    } catch (SyncopeClientCompositeErrorException e) {
                        error(getString("operation_error"));

                        LOG.error("While deleting resource {}({})",
                                new Object[] { accountPolicyTO.getId(), accountPolicyTO.getDescription() }, e);
                    }

                    target.add(container);
                    target.add(getPage().get("feedback"));
                }
            }, ActionLink.ActionType.DELETE, "Policies", "delete");

            cellItem.add(panel);
        }
    });

    final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("datatable", columns,
            new PolicyDataProvider(), paginatorRows);

    container.add(table);

    final IndicatingAjaxLink createButton = new IndicatingAjaxLink("createLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {

            mwindow.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    final PolicyModalPage page = new PolicyModalPage(mwindow, getPolicyTOInstance(policyType));
                    return page;
                }
            });

            mwindow.show(target);
        }
    };

    add(createButton);

    MetaDataRoleAuthorizationStrategy.authorize(createButton, ENABLE,
            xmlRolesReader.getAllAllowedRoles("Policies", "create"));

    final Form paginatorForm = new Form("PaginatorForm");

    final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser",
            new PropertyModel(this, "paginatorRows"), prefMan.getPaginatorChoices());

    rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            prefMan.set(getWebRequest(), (WebResponse) getResponse(), Constants.PREF_POLICY_PAGINATOR_ROWS,
                    String.valueOf(paginatorRows));
            table.setItemsPerPage(paginatorRows);

            target.add(container);
        }
    });

    paginatorForm.add(rowsChooser);
    add(paginatorForm);
}