List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setResizable
public ModalWindow setResizable(final boolean resizable)
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 a 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);/* w w w . j a v a 2s . 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.QuickMessageTo.java
License:Educational Community License
public QuickMessageTo(String id, final ModalWindow window, final String uuidTo) { super(id);/*w w w . j av a 2s .c o m*/ //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);// w w w . ja v a 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.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.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:ro.nextreports.server.web.schedule.TemplatePanel.java
License:Apache License
private void init() { validator = createValidator();/* ww w. jav a 2 s .c o m*/ add(new Label("templateLabel", getString("ActionContributor.Run.template.name"))); ChoiceRenderer<ReportRuntimeTemplate> nameRenderer = new ChoiceRenderer<ReportRuntimeTemplate>("name") { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(ReportRuntimeTemplate template) { if (template == null) { return getString("nullValid"); } return template.getName(); } }; final DropDownChoice<ReportRuntimeTemplate> templateChoice = new DropDownChoice<ReportRuntimeTemplate>( "template", new PropertyModel<ReportRuntimeTemplate>(this, "template"), new LoadableDetachableModel<List<ReportRuntimeTemplate>>() { @Override protected List<ReportRuntimeTemplate> load() { List<ReportRuntimeTemplate> templates = new ArrayList<ReportRuntimeTemplate>(); try { templates = reportService.getReportTemplatesById(report.getId()); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); error(e.getMessage()); } return templates; } }, nameRenderer); templateChoice.setNullValid(true); templateChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { if (template != null) { new ChangeValuesTemplateEvent(templateChoice, report, template.getReportRuntime(), template.getShortcutType(), target).fire(); runtimeModel.setShortcutType(template.getShortcutType()); target.add(shortcutChoice); // when a template is changed then the shortcut is changed ShortcutType shortcutType = runtimeModel.getShortcutType(); new ChangeShortcutTemplateEvent(shortcutChoice, shortcutType, target).fire(); timeType = TimeShortcutType.getTypeName(runtimeModel.getShortcutType().getTimeType()); boolean visible = (runtimeModel.getShortcutType().getType() == -1); shortcutLastContainer.setVisible(visible); target.add(shortcutLastContainer); } else { runtimeModel.setShortcutType(ShortcutType.NONE); shortcutLastContainer.setVisible(false); target.add(shortcutChoice); target.add(shortcutLastContainer); } } }); add(templateChoice); final TextField<String> nameField = new TextField<String>("name", new PropertyModel<String>(this, "runtimeModel.templateName")); nameField.setRequired(false); nameField.setEnabled(false); nameField.setOutputMarkupId(true); nameField.setLabel(Model.of(getString("ActionContributor.Run.template.info"))); add(nameField); add(new Label("saveTemplateLabel", getString("ActionContributor.Run.template.save"))); final CheckBox saveTemplate = new CheckBox("saveTemplate", new PropertyModel<Boolean>(this, "runtimeModel.saveTemplate")); saveTemplate.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { boolean save = runtimeModel.isSaveTemplate(); nameField.setEnabled(save); nameField.setRequired(save); if (save) { nameField.add(validator); } else { nameField.remove(validator); } target.add(nameField); } }); add(saveTemplate); WebMarkupContainer shortcutContainer = new WebMarkupContainer("shortcutContainer"); boolean visible = ReportUtil.hasIntervalParameters(storageService.getSettings(), report); shortcutContainer.setVisible(visible); add(shortcutContainer); shortcutContainer.add(new Label("withShortcut", getString("ActionContributor.Run.template.interval"))); ChoiceRenderer<ShortcutType> shortcutRenderer = new ChoiceRenderer<ShortcutType>("name") { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(ShortcutType shortcut) { return getString( "ActionContributor.Run.template.interval." + ShortcutType.getName(shortcut.getType())); } }; shortcutChoice = new DropDownChoice<ShortcutType>("shortcutType", new PropertyModel<ShortcutType>(this, "runtimeModel.shortcutType"), ShortcutType.getTypes(), shortcutRenderer); shortcutChoice.setNullValid(false); shortcutChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { ShortcutType shortcutType = runtimeModel.getShortcutType(); new ChangeShortcutTemplateEvent(shortcutChoice, shortcutType, target).fire(); boolean visible = (runtimeModel.getShortcutType().getType() == -1); shortcutLastContainer.setVisible(visible); target.add(shortcutLastContainer); } }); shortcutChoice.setOutputMarkupId(true); shortcutContainer.add(shortcutChoice); shortcutLastContainer = new WebMarkupContainer("shortcutLastContainer"); shortcutLastContainer.setVisible(false); shortcutLastContainer.setOutputMarkupPlaceholderTag(true); shortcutContainer.add(shortcutLastContainer); timeUnitsField = new TextField<Integer>("timeUnits", new PropertyModel<Integer>(this, "runtimeModel.shortcutType.timeUnits")); timeUnitsField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { new ChangeShortcutTemplateEvent(shortcutChoice, runtimeModel.getShortcutType(), target).fire(); } }); timeUnitsField.setRequired(false); shortcutLastContainer.add(timeUnitsField); ChoiceRenderer<String> timeTypeRenderer = new ChoiceRenderer<String>() { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(String type) { return getString(type.toLowerCase()); } }; timeTypeChoice = new DropDownChoice<String>("timeType", new PropertyModel<String>(this, "timeType"), TimeShortcutType.getTypeNames(), timeTypeRenderer); timeTypeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { runtimeModel.getShortcutType().setTimeType(TimeShortcutType.getTypeUnit(timeType)); new ChangeShortcutTemplateEvent(shortcutChoice, runtimeModel.getShortcutType(), target).fire(); } }); shortcutLastContainer.add(timeTypeChoice); if (runtimeModel.getShortcutType().getType() == -1) { shortcutLastContainer.setVisible(true); } add(new AjaxLink<Void>("removeTemplate") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(getString("ActionContributor.Run.template.remove")); dialog.setInitialWidth(350); dialog.setInitialHeight(200); dialog.setResizable(true); final ManageTemplatesPanel panel = new ManageTemplatesPanel(dialog.getContentId(), report) { private static final long serialVersionUID = 1L; @Override public void onDelete(AjaxRequestTarget target, List<ReportRuntimeTemplate> selected) { ModalWindow.closeCurrent(target); if (selected.size() == 0) { return; } List<String> ids = new ArrayList<String>(); for (ReportRuntimeTemplate rt : selected) { ids.add(rt.getId()); } try { storageService.removeEntitiesById(ids); } catch (NotFoundException e) { e.printStackTrace(); LOG.error(e.getMessage(), e); error(e.getMessage()); } template = null; target.add(templateChoice); } @Override public void onCancel(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); } }; dialog.setContent(panel); dialog.show(target); } }); }