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

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

Introduction

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

Prototype

public ModalWindow setTitle(IModel<String> title) 

Source Link

Document

Sets the title of window.

Usage

From source file:org.sakaiproject.attendance.tool.panels.EventInputPanel.java

License:Educational Community License

private void processSave(AjaxRequestTarget target, Form<?> form, boolean addAnother) {
    AttendanceEvent e = (AttendanceEvent) form.getModelObject();
    e.setAttendanceSite(attendanceLogic.getCurrentAttendanceSite());
    boolean result = attendanceLogic.updateAttendanceEvent(e);

    if (result) {
        StringResourceModel temp = new StringResourceModel("attendance.add.success", null,
                new String[] { e.getName() });
        getSession().success(temp.getString());
    } else {/*from w  w w . j  a  v a  2 s  . c o m*/
        error(getString("attendance.add.failure"));
        target.addChildren(form, FeedbackPanel.class);
    }

    final Class<? extends Page> currentPageClass = getPage().getPageClass();
    if (addAnother) {
        if (Overview.class.equals(currentPageClass)) {
            window.close(target);

            Overview overviewPage = (Overview) getPage();
            final ModalWindow window2 = overviewPage.getAddOrEditItemWindow();
            window2.setTitle(new ResourceModel("attendance.add.header"));
            window2.setContent(new EventInputPanel(window2.getContentId(), window2, null, true));
            target.addChildren(form, FeedbackPanel.class);
            window2.show(target);
        }
    } else {
        if (EventView.class.equals(currentPageClass)) {
            setResponsePage(new EventView(attendanceEvent, ((EventView) getPage()).getReturnPage()));
        } else {
            setResponsePage(currentPageClass);
        }
    }
}

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 ww .  j  a  va  2s. co  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  .j ava2s .  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);// ww  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 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.QuickMessageTo.java

License:Educational Community License

public QuickMessageTo(String id, final ModalWindow window, final String uuidTo) {
    super(id);//from  www. j a  va  2s.c  om

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

    //current userId
    final String userId = sakaiProxy.getCurrentUserId();

    //setup model
    NewMessageModel messageHelper = new NewMessageModel();
    messageHelper.setTo(uuidTo);
    messageHelper.setFrom(userId);

    //setup form   
    Form<Message> form = new Form<Message>("form");

    //to label
    form.add(new Label("toLabel", new ResourceModel("message.to")));
    //to label
    form.add(new Label("toContent", new Model<String>(sakaiProxy.getUserDisplayName(uuidTo))));

    //subject
    form.add(new Label("subjectLabel", new ResourceModel("message.subject")));
    TextField<String> subjectField = new TextField<String>("subjectField");
    form.add(subjectField);

    //body
    form.add(new Label("messageLabel", new ResourceModel("message.message")));
    final TextArea<String> messageField = new TextArea<String>("messageField");
    messageField.setRequired(true);
    form.add(messageField);

    //send button
    IndicatingAjaxButton sendButton = new IndicatingAjaxButton("sendButton", form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

        }

        protected void onError(AjaxRequestTarget target, Form form) {

        }
    };
    form.add(sendButton);
    sendButton.setModel(new ResourceModel("button.message.send"));

    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);/*from  www .  j a va 2s  .  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 w  w  .j  a  v a 2  s .  com

    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.ujorm.hotels.gui.booking.BookingEditor.java

License:Apache License

/** Create the editor dialog */
public static BookingEditor create(String componentId, int width, int height) {
    IModel<Booking> model = Model.of(new Booking());
    final ModalWindow modalWindow = new ModalWindow(componentId, model);
    modalWindow.setCssClassName(ModalWindow.CSS_CLASS_BLUE);

    final BookingEditor result = new BookingEditor(modalWindow, model);
    modalWindow.setInitialWidth(width);/*from   ww w .  jav  a2s .c  o  m*/
    modalWindow.setInitialHeight(height);
    modalWindow.setTitle(new LocalizedModel("dialog.booking.title"));
    //modalWindow.setCookieName("modal-dialog");

    return result;
}

From source file:org.ujorm.hotels.gui.customer.CustomerEditor.java

License:Apache License

/** Create the editor dialog */
public static CustomerEditor create(String componentId, int width, int height) {
    IModel<Customer> model = Model.of(new Customer());
    final ModalWindow modalWindow = new ModalWindow(componentId, model);
    modalWindow.setCssClassName(ModalWindow.CSS_CLASS_BLUE);

    final CustomerEditor result = new CustomerEditor(modalWindow, model);
    modalWindow.setInitialWidth(width);//from   w  ww.  j  a va 2 s  .com
    modalWindow.setInitialHeight(height);
    modalWindow.setTitle(new LocalizedModel("dialog.edit.title"));
    //modalWindow.setCookieName("modal-dialog");

    return result;
}

From source file:org.ujorm.hotels.gui.customer.LoginDialog.java

License:Apache License

/** Create the editor dialog */
public static LoginDialog create(String componentId, int width, int height) {
    IModel<Customer> model = Model.of(new Customer());
    final ModalWindow modalWindow = new ModalWindow(componentId, model);
    modalWindow.setCssClassName(ModalWindow.CSS_CLASS_BLUE);

    final LoginDialog result = new LoginDialog(modalWindow, model);
    modalWindow.setInitialWidth(width);//from   w w  w  .  ja  v  a  2s.c  o  m
    modalWindow.setInitialHeight(height);
    modalWindow.setTitle(new LocalizedModel("dialog.login.title"));
    //modalWindow.setCookieName("modal-dialog");

    return result;
}