List of usage examples for org.apache.wicket.ajax.markup.html.navigation.paging AjaxPagingNavigator setVisible
public final Component setVisible(final boolean visible)
From source file:au.org.theark.study.web.component.subjectcustomdata.SubjectCustomDataEditorPanel.java
License:Open Source License
public SubjectCustomDataEditorPanel initialisePanel() { customDataEditorForm = new CustomDataEditorForm("customDataEditorForm", cpModel, feedbackPanel) .initialiseForm();/* w w w . j a v a 2 s .com*/ Collection<CustomFieldCategory> customFieldCategoryCollection = getAvailableAllCategoryListInStudyByCustomFieldType(); List<CustomFieldCategory> customFieldCatLst = CustomFieldCategoryOrderingHelper.getInstance() .orderHierarchicalyCustomFieldCategories((List<CustomFieldCategory>) customFieldCategoryCollection); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID) { @Override public Object getDisplayValue(Object object) { CustomFieldCategory cuscat = (CustomFieldCategory) object; return CustomFieldCategoryOrderingHelper.getInstance().preTextDecider(cuscat) + super.getDisplayValue(object); } }; customeFieldCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELD_CUSTOEMFIELDCATEGORY, customFieldCatLst, customfieldCategoryRenderer); customeFieldCategoryDdc.setOutputMarkupId(true); customeFieldCategoryDdc.setNullValid(true); customeFieldCategoryDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { customDataEditorForm.getDataViewWMC().remove(dataViewPanel); dataViewPanel = new SubjectCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(null, customeFieldCategoryDdc.getModelObject()); customDataEditorForm.getDataViewWMC().add(dataViewPanel); target.add(dataViewPanel); target.add(customDataEditorForm); } }); //dataViewPanel = new SubjectCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(null); //initialise dataViewPanel = new SubjectCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(null, customeFieldCategoryDdc.getModelObject()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) { @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(customDataEditorForm.getDataViewWMC()); target.add(this); } }; pageNavigator.setVisible(false); customDataEditorForm.add(customeFieldCategoryDdc); customDataEditorForm.getDataViewWMC().add(dataViewPanel); warnSaveLabel = new Label("warnSaveLabel", new ResourceModel("warnSaveLabel")); warnSaveLabel.setVisible(ArkPermissionHelper.isActionPermitted(Constants.NEW)); add(customDataEditorForm); add(pageNavigator); add(warnSaveLabel); return this; }
From source file:org.sakaiproject.profile2.tool.pages.panels.ConfirmedFriends.java
License:Educational Community License
public ConfirmedFriends(final String id, final String userUuid) { super(id);/*from w ww .ja v a2s .c o m*/ log.debug("ConfirmedFriends()"); //setup model to store the actions in the modal windows final FriendAction friendActionModel = new FriendAction(); //get info for user viewing this page (will be the same if user is viewing own list, different if viewing someone else's) final String currentUserUuid = sakaiProxy.getCurrentUserId(); //User currentUser = sakaiProxy.getUserQuietly(currentUserUuid); //final String currentUserType = currentUser.getType(); //to be used for checking if connection between users is allowed, when this is added //if viewing own friends, you can manage them. if (userUuid.equals(currentUserUuid)) { ownList = true; } //get our list of confirmed friends as an IDataProvider ConfirmedFriendsDataProvider provider = new ConfirmedFriendsDataProvider(userUuid); //init number of friends numConfirmedFriends = (int) provider.size(); //model so we can update the number of friends IModel<Integer> numConfirmedFriendsModel = new Model<Integer>() { private static final long serialVersionUID = 1L; public Integer getObject() { return numConfirmedFriends; } }; //heading final WebMarkupContainer confirmedFriendsHeading = new WebMarkupContainer("confirmedFriendsHeading"); Label confirmedFriendsLabel = new Label("confirmedFriendsLabel"); //if viewing own list, "my friends", else, "their name's friends" if (ownList) { confirmedFriendsLabel.setDefaultModel(new ResourceModel("heading.friends.my")); } else { String displayName = sakaiProxy.getUserDisplayName(userUuid); confirmedFriendsLabel.setDefaultModel( new StringResourceModel("heading.friends.view", null, new Object[] { displayName })); } confirmedFriendsHeading.add(confirmedFriendsLabel); confirmedFriendsHeading.add(new Label("confirmedFriendsNumber", numConfirmedFriendsModel)); confirmedFriendsHeading.setOutputMarkupId(true); add(confirmedFriendsHeading); // actions Form<Void> confirmedFriendsButtonForm = new Form<Void>("confirmedFriendsButtonForm"); add(confirmedFriendsButtonForm); //create worksite panel final CreateWorksitePanel createWorksitePanel = new CreateWorksitePanel("createWorksitePanel", connectionsLogic.getConnectionsForUser(userUuid)); //create placeholder and set invisible initially createWorksitePanel.setOutputMarkupPlaceholderTag(true); createWorksitePanel.setVisible(false); confirmedFriendsButtonForm.add(createWorksitePanel); final AjaxButton createWorksiteButton = new AjaxButton("createWorksiteButton", confirmedFriendsButtonForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { createWorksitePanel.setVisible(true); target.add(createWorksitePanel); target.appendJavaScript("fixWindowVertical();"); } }; createWorksiteButton.setModel(new ResourceModel("link.worksite.create")); createWorksiteButton .add(new AttributeModifier("title", true, new ResourceModel("link.title.worksite.create"))); createWorksiteButton.setVisible(sakaiProxy.isUserAllowedAddSite(userUuid)); confirmedFriendsButtonForm.add(createWorksiteButton); //search for connections AjaxButton searchConnectionsButton = new AjaxButton("searchConnectionsButton", confirmedFriendsButtonForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { setResponsePage(new MySearch()); } }; searchConnectionsButton.setModel(new ResourceModel("link.my.friends.search")); confirmedFriendsButtonForm.add(searchConnectionsButton); //container which wraps list final WebMarkupContainer confirmedFriendsContainer = new WebMarkupContainer("confirmedFriendsContainer"); confirmedFriendsContainer.setOutputMarkupId(true); //connection window final ModalWindow connectionWindow = new ModalWindow("connectionWindow"); //results DataView<Person> confirmedFriendsDataView = new DataView<Person>("connections", provider) { private static final long serialVersionUID = 1L; protected void populateItem(final Item<Person> item) { Person person = (Person) item.getDefaultModelObject(); final String personUuid = person.getUuid(); //setup values String displayName = person.getDisplayName(); boolean friend; //get friend status if (ownList) { friend = true; //viewing own page of conenctions, must be friend! } else { friend = connectionsLogic.isUserXFriendOfUserY(userUuid, personUuid); //other person viewing, check if they are friends } //get other objects ProfilePrivacy privacy = person.getPrivacy(); ProfilePreferences prefs = person.getPreferences(); //image wrapper, links to profile Link<String> friendItem = new Link<String>("connectionPhotoWrap", new Model<String>(personUuid)) { private static final long serialVersionUID = 1L; public void onClick() { setResponsePage(new ViewProfile(getModelObject())); } }; //image ProfileImage connectionPhoto = new ProfileImage("connectionPhoto", new Model<String>(personUuid)); connectionPhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL); friendItem.add(connectionPhoto); item.add(friendItem); //name and link to profile Link<String> profileLink = new Link<String>("connectionLink", new Model<String>(personUuid)) { private static final long serialVersionUID = 1L; public void onClick() { setResponsePage(new ViewProfile(getModelObject())); } }; profileLink.add(new Label("connectionName", displayName)); item.add(profileLink); //status component ProfileStatusRenderer status = new ProfileStatusRenderer("connectionStatus", person, "connection-status-msg", "connection-status-date"); status.setOutputMarkupId(true); item.add(status); /* ACTIONS */ WebMarkupContainer c1 = new WebMarkupContainer("removeConnectionContainer"); c1.setOutputMarkupId(true); //REMOVE FRIEND LINK AND WINDOW final AjaxLink<String> removeConnectionLink = new AjaxLink<String>("removeConnectionLink", new Model<String>(personUuid)) { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { //get this item, and set content for modalwindow String friendUuid = getModelObject(); connectionWindow.setContent(new RemoveFriend(connectionWindow.getContentId(), connectionWindow, friendActionModel, userUuid, friendUuid)); //modalwindow handler connectionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { if (friendActionModel.isRemoved()) { //decrement number of friends numConfirmedFriends--; //remove friend item from display target.appendJavaScript("$('#" + item.getMarkupId() + "').slideUp();"); //update label target.add(confirmedFriendsHeading); //if none left, hide whole thing if (numConfirmedFriends == 0) { target.appendJavaScript( "$('#" + confirmedFriendsContainer.getMarkupId() + "').fadeOut();"); } } } }); connectionWindow.show(target); target.appendJavaScript("fixWindowVertical();"); } }; //ContextImage removeConnectionIcon = new ContextImage("removeConnectionIcon",new Model<String>(ProfileConstants.DELETE_IMG)); removeConnectionLink.add(new AttributeModifier("alt", true, new StringResourceModel( "accessibility.connection.remove", null, new Object[] { displayName }))); //removeConnectionLink.add(removeConnectionIcon); removeConnectionLink .add(new AttributeModifier("title", true, new ResourceModel("link.title.removefriend"))); removeConnectionLink .add(new Label("removeConnectionLabel", new ResourceModel("button.friend.remove")) .setOutputMarkupId(true)); c1.add(removeConnectionLink); item.add(c1); //can only delete if own connections if (!ownList) { removeConnectionLink.setEnabled(false); removeConnectionLink.setVisible(false); } WebMarkupContainer c2 = new WebMarkupContainer("viewFriendsContainer"); c2.setOutputMarkupId(true); final AjaxLink<String> viewFriendsLink = new AjaxLink<String>("viewFriendsLink") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { // always ViewFriends because a user isn't connected to himself setResponsePage(new ViewFriends(personUuid)); } }; final Label viewFriendsLabel = new Label("viewFriendsLabel", new ResourceModel("link.view.friends")); viewFriendsLink.add(viewFriendsLabel); //hide if not allowed if (!privacyLogic.isActionAllowed(userUuid, currentUserUuid, PrivacyType.PRIVACY_OPTION_MYFRIENDS)) { viewFriendsLink.setEnabled(false); c2.setVisible(false); } viewFriendsLink.setOutputMarkupId(true); c2.add(viewFriendsLink); item.add(c2); WebMarkupContainer c3 = new WebMarkupContainer("emailContainer"); c3.setOutputMarkupId(true); ExternalLink emailLink = new ExternalLink("emailLink", "mailto:" + person.getProfile().getEmail(), new ResourceModel("profile.email").getObject()); c3.add(emailLink); if (StringUtils.isBlank(person.getProfile().getEmail()) || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_CONTACTINFO)) { c3.setVisible(false); } item.add(c3); WebMarkupContainer c4 = new WebMarkupContainer("websiteContainer"); c4.setOutputMarkupId(true); // TODO home page, university profile URL or academic/research URL (see PRFL-35) ExternalLink websiteLink = new ExternalLink("websiteLink", person.getProfile().getHomepage(), new ResourceModel("profile.homepage").getObject()).setPopupSettings(new PopupSettings()); c4.add(websiteLink); if (StringUtils.isBlank(person.getProfile().getHomepage()) || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_CONTACTINFO)) { c4.setVisible(false); } item.add(c4); // basic info can be set to 'only me' so still need to check if (true == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid, PrivacyType.PRIVACY_OPTION_BASICINFO)) { item.add(new Label("connectionSummary", StringUtils .abbreviate(ProfileUtils.stripHtml(person.getProfile().getPersonalSummary()), 200))); } else { item.add(new Label("connectionSummary", "")); } item.setOutputMarkupId(true); } }; confirmedFriendsDataView.setOutputMarkupId(true); confirmedFriendsDataView.setItemsPerPage(ProfileConstants.MAX_CONNECTIONS_PER_PAGE); confirmedFriendsContainer.add(confirmedFriendsDataView); //add results container add(confirmedFriendsContainer); //add window add(connectionWindow); //add pager AjaxPagingNavigator pager = new AjaxPagingNavigator("navigator", confirmedFriendsDataView); add(pager); //initially, if no friends, hide container and pager if (numConfirmedFriends == 0) { confirmedFriendsContainer.setVisible(false); pager.setVisible(false); } //also, if num less than num required for pager, hide it if (numConfirmedFriends <= ProfileConstants.MAX_CONNECTIONS_PER_PAGE) { pager.setVisible(false); } }
From source file:org.sakaiproject.profile2.tool.pages.panels.MessageThreadsView.java
License:Educational Community License
public MessageThreadsView(final String id) { super(id);//from ww w .jav a 2 s . c o m log.debug("MessageThreads()"); //get current user final String currentUserUuid = sakaiProxy.getCurrentUserId(); //heading /* Label heading = new Label("messageThreadListHeading", new ResourceModel("heading.messages")); add(heading); */ //no messages label Label noMessagesLabel = new Label("noMessagesLabel"); noMessagesLabel.setOutputMarkupPlaceholderTag(true); add(noMessagesLabel); //container which wraps list final WebMarkupContainer messageThreadListContainer = new WebMarkupContainer("messageThreadListContainer"); messageThreadListContainer.setOutputMarkupId(true); //get our list of messages final MessageThreadsDataProvider provider = new MessageThreadsDataProvider(currentUserUuid); int numMessages = (int) provider.size(); //message list DataView<MessageThread> messageThreadList = new DataView<MessageThread>("messageThreadList", provider) { private static final long serialVersionUID = 1L; protected void populateItem(final Item<MessageThread> item) { final MessageThread thread = (MessageThread) item.getDefaultModelObject(); Message message = thread.getMostRecentMessage(); String messageFromUuid = message.getFrom(); //we need to know if this message has been read or not so we can style it accordingly //we only need this if we didn't send the message MessageParticipant participant = null; boolean messageOwner = false; if (StringUtils.equals(messageFromUuid, currentUserUuid)) { messageOwner = true; } if (!messageOwner) { participant = messagingLogic.getMessageParticipant(message.getId(), currentUserUuid); } //prefs and privacy ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(messageFromUuid); ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(messageFromUuid); //photo link AjaxLink<String> photoLink = new AjaxLink<String>("photoLink", new Model<String>(messageFromUuid)) { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { setResponsePage(new ViewProfile(getModelObject())); } }; //photo ProfileImage messagePhoto = new ProfileImage("messagePhoto", new Model<String>(messageFromUuid)); messagePhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL); photoLink.add(messagePhoto); item.add(photoLink); //name link AjaxLink<String> messageFromLink = new AjaxLink<String>("messageFromLink", new Model<String>(messageFromUuid)) { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { setResponsePage(new ViewProfile(getModelObject())); } }; messageFromLink.add(new Label("messageFromName", new Model<String>(sakaiProxy.getUserDisplayName(messageFromUuid)))); item.add(messageFromLink); //date item.add(new Label("messageDate", ProfileUtils.convertDateToString(message.getDatePosted(), ProfileConstants.MESSAGE_DISPLAY_DATE_FORMAT))); //subject link AjaxLink<MessageThread> messageSubjectLink = new AjaxLink<MessageThread>("messageSubjectLink", new Model<MessageThread>(thread)) { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { //load messageview panel //setResponsePage(new MyMessageView(id, currentUserUuid, getModelObject().getId(), getModelObject().getSubject())); //load MyMessages with some params that will then load a diff tab panel and show this message panel. setResponsePage(new MyMessages(thread.getId())); } }; messageSubjectLink.add(new Label("messageSubject", new Model<String>(thread.getSubject()))); item.add(messageSubjectLink); //message body item.add(new Label("messageBody", new Model<String>(StringUtils.abbreviate(message.getMessage(), ProfileConstants.MESSAGE_PREVIEW_MAX_LENGTH)))); //unread notice for accessibility, off unless its new. Label messageUnreadNotice = new Label("messageUnreadNotice", new ResourceModel("accessibility.messages.unread")); messageUnreadNotice.setVisible(false); item.add(messageUnreadNotice); //highlight if new, also render accessibility notice if (!messageOwner && !participant.isRead()) { item.add(new AttributeAppender("class", true, new Model<String>("unread-message"), " ")); messageUnreadNotice.setVisible(true); } item.setOutputMarkupId(true); } }; messageThreadList.setOutputMarkupId(true); messageThreadList.setItemsPerPage(ProfileConstants.MAX_MESSAGES_PER_PAGE); messageThreadListContainer.add(messageThreadList); add(messageThreadListContainer); //pager AjaxPagingNavigator pager = new AjaxPagingNavigator("navigator", messageThreadList); add(pager); //initially, if no message threads to show, hide container and pager, set and show label if (numMessages == 0) { messageThreadListContainer.setVisible(false); pager.setVisible(false); noMessagesLabel.setDefaultModel(new ResourceModel("text.messages.none")); noMessagesLabel.setVisible(true); } //also, if num less than num required for pager, hide it if (numMessages <= ProfileConstants.MAX_MESSAGES_PER_PAGE) { pager.setVisible(false); } }