Java Code Examples for org.apache.wicket.markup.html.basic.Label#setDefaultModel()

The following examples show how to use org.apache.wicket.markup.html.basic.Label#setDefaultModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KudosPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public KudosPanel(String id, final String ownerUserId, final String viewingUserId, final int score) {
	super(id);
	
	log.debug("KudosPanel()");
	
	//heading	
	Label heading = new Label("heading");
	
	if(viewingUserId.equals(ownerUserId)) {
		heading.setDefaultModel(new ResourceModel("heading.widget.my.kudos"));
	} else {
		String displayName = sakaiProxy.getUserDisplayName(ownerUserId);
		heading.setDefaultModel(new StringResourceModel("heading.widget.view.kudos", null, new Object[]{ displayName } ));
	}
	add(heading);
	
	//score
	add(new Label("kudosRating", String.valueOf(score)));
	
	String img = getImage(score);
	
	//images
	add(new ContextImage("kudosImgLeft", img));
	add(new ContextImage("kudosImgRight", img));

}
 
Example 2
Source File: KudosPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public KudosPanel(String id, final String ownerUserId, final String viewingUserId, final int score) {
	super(id);
	
	log.debug("KudosPanel()");
	
	//heading	
	Label heading = new Label("heading");
	
	if(viewingUserId.equals(ownerUserId)) {
		heading.setDefaultModel(new ResourceModel("heading.widget.my.kudos"));
	} else {
		String displayName = sakaiProxy.getUserDisplayName(ownerUserId);
		heading.setDefaultModel(new StringResourceModel("heading.widget.view.kudos", null, new Object[]{ displayName } ));
	}
	add(heading);
	
	//score
	add(new Label("kudosRating", String.valueOf(score)));
	
	String img = getImage(score);
	
	//images
	add(new ContextImage("kudosImgLeft", img));
	add(new ContextImage("kudosImgRight", img));

}
 
Example 3
Source File: LastJobRun.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void renderBody() {
	StatsManager statsManager = Locator.getFacade().getStatsManager();
	StatsUpdateManager statsUpdateManager = Locator.getFacade().getStatsUpdateManager();
	
	setRenderBodyOnly(true);
	
	final WebMarkupContainer lastJobRun = new WebMarkupContainer("lastJobRun");
	boolean lastJobRunVisible = !statsUpdateManager.isCollectThreadEnabled() && statsManager.isLastJobRunDateVisible(); 
	lastJobRun.setVisible(lastJobRunVisible);
	add(lastJobRun);
	final Label lastJobRunDate = new Label("lastJobRunDate");
	final Label lastJobRunServerDate = new Label("lastJobRunServerDate");
	if(lastJobRunVisible) {
		try{
			Date d = statsUpdateManager.getEventDateFromLatestJobRun();
			UserTimeService timeServ = Locator.getFacade().getUserTimeService();
			String dStr = timeServ.shortLocalizedTimestamp(d.toInstant(), getSession().getLocale());
			String serverDateStr = timeServ.shortLocalizedTimestamp(d.toInstant(), TimeZone.getDefault(), getSession().getLocale());
			lastJobRunDate.setDefaultModel(new Model(dStr));
			String localSakaiName = Locator.getFacade().getStatsManager().getLocalSakaiName();
			StringResourceModel model = new StringResourceModel("lastJobRun_server_time", getPage(), null,
					new Object[] {localSakaiName, serverDateStr});
			lastJobRunServerDate.setDefaultModel(model);
		}catch(Exception e){
			lastJobRunDate.setDefaultModel(new Model());
			lastJobRunServerDate.setDefaultModel(new Model());
		}
	}
	lastJobRun.add(lastJobRunDate);
	lastJobRun.add(lastJobRunServerDate);
}
 
Example 4
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example 5
Source File: BaseTreePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected AjaxLink getExpandCollapseLink(){
	//Expand Collapse Link:
	final Label expandCollapse = new Label("expandCollapse", new StringResourceModel("exapndNodes", null));
	expandCollapse.setOutputMarkupId(true);
	AjaxLink expandLink  = new AjaxLink("expandAll")
	{
		boolean expand = true;
		@Override
		public void onClick(AjaxRequestTarget target)
		{
			if(expand){
				getTree().getTreeState().expandAll();
				expandCollapse.setDefaultModel(new StringResourceModel("collapseNodes", null));
				collapseEmptyFolders();
			}else{
				getTree().getTreeState().collapseAll();
				expandCollapse.setDefaultModel(new StringResourceModel("exapndNodes", null));
			}
			target.add(expandCollapse);
			getTree().updateTree(target);
			expand = !expand;

		}
		@Override
		public boolean isVisible() {
			return getTree().getDefaultModelObject() != null;
		}
	};
	expandLink.add(expandCollapse);
	return expandLink;
}
 
Example 6
Source File: LastJobRun.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private void renderBody() {
	StatsManager statsManager = Locator.getFacade().getStatsManager();
	StatsUpdateManager statsUpdateManager = Locator.getFacade().getStatsUpdateManager();
	
	setRenderBodyOnly(true);
	
	final WebMarkupContainer lastJobRun = new WebMarkupContainer("lastJobRun");
	boolean lastJobRunVisible = !statsUpdateManager.isCollectThreadEnabled() && statsManager.isLastJobRunDateVisible(); 
	lastJobRun.setVisible(lastJobRunVisible);
	add(lastJobRun);
	final Label lastJobRunDate = new Label("lastJobRunDate");
	final Label lastJobRunServerDate = new Label("lastJobRunServerDate");
	if(lastJobRunVisible) {
		try{
			Date d = statsUpdateManager.getEventDateFromLatestJobRun();
			UserTimeService timeServ = Locator.getFacade().getUserTimeService();
			String dStr = timeServ.shortLocalizedTimestamp(d.toInstant(), getSession().getLocale());
			String serverDateStr = timeServ.shortLocalizedTimestamp(d.toInstant(), TimeZone.getDefault(), getSession().getLocale());
			lastJobRunDate.setDefaultModel(new Model(dStr));
			String localSakaiName = Locator.getFacade().getStatsManager().getLocalSakaiName();
			StringResourceModel model = new StringResourceModel("lastJobRun_server_time", getPage(), null,
					new Object[] {localSakaiName, serverDateStr});
			lastJobRunServerDate.setDefaultModel(model);
		}catch(Exception e){
			lastJobRunDate.setDefaultModel(new Model());
			lastJobRunServerDate.setDefaultModel(new Model());
		}
	}
	lastJobRun.add(lastJobRunDate);
	lastJobRun.add(lastJobRunServerDate);
}
 
Example 7
Source File: GalleryImageEdit.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private AjaxFallbackButton createRemoveConfirmButton(
		final String userId,
		final GalleryImage image, final int galleryPageIndex,
		final Label formFeedback, Form imageEditForm) {
	AjaxFallbackButton removeConfirmButton = new AjaxFallbackButton(
			"galleryRemoveImageConfirmButton", new ResourceModel(
					"button.gallery.remove.confirm"), imageEditForm) {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			if (imageLogic.removeGalleryImage(
					userId, image.getId())) {

				setResponsePage(new MyPictures(galleryPageIndex));
				
			} else {
				// user alert
				formFeedback.setDefaultModel(new ResourceModel(
						"error.gallery.remove.failed"));
				formFeedback.add(new AttributeModifier("class", true,
						new Model("alertMessage")));

				target.add(formFeedback);
			}
		}
	};
	return removeConfirmButton;
}
 
Example 8
Source File: GalleryImageEdit.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private AjaxFallbackButton createRemoveConfirmButton(
		final String userId,
		final GalleryImage image, final int galleryPageIndex,
		final Label formFeedback, Form imageEditForm) {
	AjaxFallbackButton removeConfirmButton = new AjaxFallbackButton(
			"galleryRemoveImageConfirmButton", new ResourceModel(
					"button.gallery.remove.confirm"), imageEditForm) {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			if (imageLogic.removeGalleryImage(
					userId, image.getId())) {

				setResponsePage(new MyPictures(galleryPageIndex));
				
			} else {
				// user alert
				formFeedback.setDefaultModel(new ResourceModel(
						"error.gallery.remove.failed"));
				formFeedback.add(new AttributeModifier("class", true,
						new Model("alertMessage")));

				target.add(formFeedback);
			}
		}
	};
	return removeConfirmButton;
}
 
Example 9
Source File: BatchResponseColumn.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public Component getHeader(final String componentId) {
    Label label = new Label(componentId, new Model<>());
    label.setDefaultModel(new StringResourceModel("batch.result.header", label, new Model<>("Result")));
    return label;
}
 
Example 10
Source File: AdministratePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public AdministratePage(){
	disableLink(administrateLink);
	
	//Form Feedback (Saved/Error)
	final Label formFeedback = new Label("formFeedback");
	formFeedback.setOutputMarkupPlaceholderTag(true);
	final String formFeedbackId = formFeedback.getMarkupId();
	add(formFeedback);
	
	//Add Delegated Access to My Workspaces:
	final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() {
		@Override
		public String getObject() {
			String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus();
			if(lastRanInfoStr == null){
				lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject();
			}else{
				try{
					long lastRanInfoInt = Long.parseLong(lastRanInfoStr);
					if(lastRanInfoInt == -1){
						return new ResourceModel("addDaMyworkspace.job.status.failed").getObject();
					}else if(lastRanInfoInt == 0){
						return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject();
					}else{
						Date successDate = new Date(lastRanInfoInt);
						return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate);
					}
				}catch (Exception e) {
					return new ResourceModel("na").getObject();
				}
			}
			return lastRanInfoStr;
		}
	});
	addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true);
	final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId();
	
	add(addDaMyworkspaceStatusLabel);
	
	Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm");
	
	AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)){
		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) {
			projectLogic.scheduleAddDAMyworkspaceJobStatus();
			
			//display a "saved" message
			formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace"));
			formFeedback.add(new AttributeModifier("class", true, new Model("success")));
			target.add(formFeedback);
			
			target.appendJavaScript("hideFeedbackTimer('" + formFeedbackId + "');");
			
			target.add(addDaMyworkspaceStatusLabel,addDaMyworkspaceStatusLabelId);
		}
	};
	addDaMyworkspaceForm.add(addDaMyworkspaceButton);
	
	add(addDaMyworkspaceForm);
}
 
Example 11
Source File: MyBusinessEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public MyBusinessEdit(final String id, final UserProfile userProfile,
		List<CompanyProfile> companyProfilesToAdd,
		List<CompanyProfile> companyProfilesToRemove,
		TabDisplay tabDisplay) {

	super(id);

	log.debug("MyBusinessEdit()");

	this.companyProfilesToAdd = companyProfilesToAdd;
	this.companyProfilesToRemove = companyProfilesToRemove;

	// heading
	add(new Label("heading", new ResourceModel("heading.business.edit")));

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

	// form submit feedback
	final Label formFeedback = new Label("formFeedback");
	formFeedback.setOutputMarkupPlaceholderTag(true);
	form.add(formFeedback);

	// add warning message if superUser and not editing own profile
	Label editWarning = new Label("editWarning");
	editWarning.setVisible(false);
	if (sakaiProxy.isSuperUserAndProxiedToUser(
			userProfile.getUserUuid())) {
		editWarning.setDefaultModel(new StringResourceModel(
				"text.edit.other.warning", null, new Object[] { userProfile
						.getDisplayName() }));
		editWarning.setEscapeModelStrings(false);
		editWarning.setVisible(true);
	}
	form.add(editWarning);

	// business biography
	WebMarkupContainer businessBiographyContainer = new WebMarkupContainer(
			"businessBiographyContainer");
	businessBiographyContainer.add(new Label("businessBiographyLabel",
			new ResourceModel("profile.business.bio")));
	TextArea businessBiography = new TextArea(
			"businessBiography", new PropertyModel<String>(userProfile,
					"businessBiography"));
	businessBiography.setMarkupId("businessbioinput");
	businessBiography.setOutputMarkupId(true);
	//businessBiography.setEditorConfig(CKEditorConfig.createCkConfig());
	businessBiographyContainer.add(businessBiography);
	form.add(businessBiographyContainer);

	// company profiles
	WebMarkupContainer companyProfileEditsContainer = createCompanyProfileEditsContainer(userProfile, tabDisplay);
	form.add(companyProfileEditsContainer);

	AjaxFallbackButton addCompanyProfileButton = createAddCompanyProfileButton(
			id, userProfile, form, formFeedback);
	form.add(addCompanyProfileButton);

	AjaxFallbackButton removeCompanyProfileButton = createRemoveCompanyProfileButton(
			id, userProfile, form);
	form.add(removeCompanyProfileButton);

	AjaxFallbackButton submitButton = createSaveChangesButton(id,
			userProfile, form, formFeedback);
	//submitButton.add(new CKEditorTextArea.CKEditorAjaxSubmitModifier());
	form.add(submitButton);

	AjaxFallbackButton cancelButton = createCancelChangesButton(id,
			userProfile, form);
	form.add(cancelButton);

	add(form);
}
 
Example 12
Source File: TwitterPrefsPane.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * Fragment which returns the components for the linked view
 * @return
 */
private Fragment linkedFragment() {
	
	Fragment frag = new Fragment("fragmentContainer", "linked", this);
	
	//label
	frag.add(new Label("twitterAuthLabel", new ResourceModel("twitter.auth.linked")));
	
	//screen name
	String twitterName = externalIntegrationLogic.getTwitterName(externalIntegrationInfo);
	Label twitterAuthName = new Label("twitterAuthName", new Model<String>(twitterName));
	
	if(StringUtils.isBlank(twitterName)){
		twitterAuthName.setDefaultModel(new ResourceModel("error.twitter.details.invalid"));
	}
	frag.add(twitterAuthName);

	//remove link
	IndicatingAjaxLink<String> twitterAuthRemoveLink  = new IndicatingAjaxLink<String>("twitterAuthRemoveLink") {
		private static final long serialVersionUID = 1L;

		public void onClick(AjaxRequestTarget target) {
			externalIntegrationInfo.setTwitterToken(null);
			externalIntegrationInfo.setTwitterSecret(null);
			
			//remove details
			if(externalIntegrationLogic.updateExternalIntegrationInfo(externalIntegrationInfo)) {
				switchContentFragments(unlinkedFragment(), target);
			} else {
				target.appendJavaScript("alert('Couldn't remove info');");
				return;
			}
		}
	};
	
	ContextImage twitterAuthRemoveIcon = new ContextImage("twitterAuthRemoveIcon",new Model<String>(ProfileConstants.CROSS_IMG));
	twitterAuthRemoveLink.add(twitterAuthRemoveIcon);
	twitterAuthRemoveLink.add(new AttributeModifier("title", true,new ResourceModel("link.title.unlinktwitter")));
	frag.add(twitterAuthRemoveLink);
	
	frag.setOutputMarkupId(true);
	
	return frag;
}
 
Example 13
Source File: GalleryImageEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private AjaxFallbackButton createSetProfileImageConfirmButton(
		final String userId,
		final GalleryImage image, final int galleryPageIndex,
		final Label formFeedback, Form imageEditForm) {

	AjaxFallbackButton setProfileImageButton = new AjaxFallbackButton(
			"gallerySetProfileImageConfirmButton", new ResourceModel(
					"button.gallery.setprofile.confirm"), imageEditForm) {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form form) {

			if (imageLogic.setUploadedProfileImage(
					userId,
					sakaiProxy.getResource(
							image.getMainResource()).getBytes(), "", "")) {

				sakaiProxy.postEvent(
						ProfileConstants.EVENT_PROFILE_IMAGE_CHANGE_UPLOAD,
						"/profile/" + userId, true);

				if (true == sakaiProxy.isWallEnabledGlobally()) {
					wallLogic
							.addNewEventToWall(
									ProfileConstants.EVENT_PROFILE_IMAGE_CHANGE_UPLOAD,
									sakaiProxy.getCurrentUserId());
				}
				
				if (sakaiProxy.isSuperUserAndProxiedToUser(
						userId)) {
					setResponsePage(new MyProfile(userId));
				} else {
					setResponsePage(new MyProfile());
				}

			} else {
				// user alert
				formFeedback.setDefaultModel(new ResourceModel(
						"error.gallery.setprofile.failed"));
				formFeedback.add(new AttributeModifier("class", true,
						new Model("alertMessage")));

				target.add(formFeedback);
			}
		}
	};
	return setProfileImageButton;
}
 
Example 14
Source File: AdministratePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public AdministratePage(){
	disableLink(administrateLink);
	
	//Form Feedback (Saved/Error)
	final Label formFeedback = new Label("formFeedback");
	formFeedback.setOutputMarkupPlaceholderTag(true);
	final String formFeedbackId = formFeedback.getMarkupId();
	add(formFeedback);
	
	//Add Delegated Access to My Workspaces:
	final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() {
		@Override
		public String getObject() {
			String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus();
			if(lastRanInfoStr == null){
				lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject();
			}else{
				try{
					long lastRanInfoInt = Long.parseLong(lastRanInfoStr);
					if(lastRanInfoInt == -1){
						return new ResourceModel("addDaMyworkspace.job.status.failed").getObject();
					}else if(lastRanInfoInt == 0){
						return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject();
					}else{
						Date successDate = new Date(lastRanInfoInt);
						return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate);
					}
				}catch (Exception e) {
					return new ResourceModel("na").getObject();
				}
			}
			return lastRanInfoStr;
		}
	});
	addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true);
	final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId();
	
	add(addDaMyworkspaceStatusLabel);
	
	Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm");
	
	AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)){
		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) {
			projectLogic.scheduleAddDAMyworkspaceJobStatus();
			
			//display a "saved" message
			formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace"));
			formFeedback.add(new AttributeModifier("class", true, new Model("success")));
			target.add(formFeedback);
			
			target.appendJavaScript("hideFeedbackTimer('" + formFeedbackId + "');");
			
			target.add(addDaMyworkspaceStatusLabel,addDaMyworkspaceStatusLabelId);
		}
	};
	addDaMyworkspaceForm.add(addDaMyworkspaceButton);
	
	add(addDaMyworkspaceForm);
}
 
Example 15
Source File: MyBusinessEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public MyBusinessEdit(final String id, final UserProfile userProfile,
		List<CompanyProfile> companyProfilesToAdd,
		List<CompanyProfile> companyProfilesToRemove,
		TabDisplay tabDisplay) {

	super(id);

	log.debug("MyBusinessEdit()");

	this.companyProfilesToAdd = companyProfilesToAdd;
	this.companyProfilesToRemove = companyProfilesToRemove;

	// heading
	add(new Label("heading", new ResourceModel("heading.business.edit")));

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

	// form submit feedback
	final Label formFeedback = new Label("formFeedback");
	formFeedback.setOutputMarkupPlaceholderTag(true);
	form.add(formFeedback);

	// add warning message if superUser and not editing own profile
	Label editWarning = new Label("editWarning");
	editWarning.setVisible(false);
	if (sakaiProxy.isSuperUserAndProxiedToUser(
			userProfile.getUserUuid())) {
		editWarning.setDefaultModel(new StringResourceModel(
				"text.edit.other.warning", null, new Object[] { userProfile
						.getDisplayName() }));
		editWarning.setEscapeModelStrings(false);
		editWarning.setVisible(true);
	}
	form.add(editWarning);

	// business biography
	WebMarkupContainer businessBiographyContainer = new WebMarkupContainer(
			"businessBiographyContainer");
	businessBiographyContainer.add(new Label("businessBiographyLabel",
			new ResourceModel("profile.business.bio")));
	TextArea businessBiography = new TextArea(
			"businessBiography", new PropertyModel<String>(userProfile,
					"businessBiography"));
	businessBiography.setMarkupId("businessbioinput");
	businessBiography.setOutputMarkupId(true);
	//businessBiography.setEditorConfig(CKEditorConfig.createCkConfig());
	businessBiographyContainer.add(businessBiography);
	form.add(businessBiographyContainer);

	// company profiles
	WebMarkupContainer companyProfileEditsContainer = createCompanyProfileEditsContainer(userProfile, tabDisplay);
	form.add(companyProfileEditsContainer);

	AjaxFallbackButton addCompanyProfileButton = createAddCompanyProfileButton(
			id, userProfile, form, formFeedback);
	form.add(addCompanyProfileButton);

	AjaxFallbackButton removeCompanyProfileButton = createRemoveCompanyProfileButton(
			id, userProfile, form);
	form.add(removeCompanyProfileButton);

	AjaxFallbackButton submitButton = createSaveChangesButton(id,
			userProfile, form, formFeedback);
	//submitButton.add(new CKEditorTextArea.CKEditorAjaxSubmitModifier());
	form.add(submitButton);

	AjaxFallbackButton cancelButton = createCancelChangesButton(id,
			userProfile, form);
	form.add(cancelButton);

	add(form);
}
 
Example 16
Source File: TwitterPrefsPane.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * Fragment which returns the components for the linked view
 * @return
 */
private Fragment linkedFragment() {
	
	Fragment frag = new Fragment("fragmentContainer", "linked", this);
	
	//label
	frag.add(new Label("twitterAuthLabel", new ResourceModel("twitter.auth.linked")));
	
	//screen name
	String twitterName = externalIntegrationLogic.getTwitterName(externalIntegrationInfo);
	Label twitterAuthName = new Label("twitterAuthName", new Model<String>(twitterName));
	
	if(StringUtils.isBlank(twitterName)){
		twitterAuthName.setDefaultModel(new ResourceModel("error.twitter.details.invalid"));
	}
	frag.add(twitterAuthName);

	//remove link
	IndicatingAjaxLink<String> twitterAuthRemoveLink  = new IndicatingAjaxLink<String>("twitterAuthRemoveLink") {
		private static final long serialVersionUID = 1L;

		public void onClick(AjaxRequestTarget target) {
			externalIntegrationInfo.setTwitterToken(null);
			externalIntegrationInfo.setTwitterSecret(null);
			
			//remove details
			if(externalIntegrationLogic.updateExternalIntegrationInfo(externalIntegrationInfo)) {
				switchContentFragments(unlinkedFragment(), target);
			} else {
				target.appendJavaScript("alert('Couldn't remove info');");
				return;
			}
		}
	};
	
	ContextImage twitterAuthRemoveIcon = new ContextImage("twitterAuthRemoveIcon",new Model<String>(ProfileConstants.CROSS_IMG));
	twitterAuthRemoveLink.add(twitterAuthRemoveIcon);
	twitterAuthRemoveLink.add(new AttributeModifier("title", true,new ResourceModel("link.title.unlinktwitter")));
	frag.add(twitterAuthRemoveLink);
	
	frag.setOutputMarkupId(true);
	
	return frag;
}
 
Example 17
Source File: GalleryImageEdit.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private AjaxFallbackButton createSetProfileImageConfirmButton(
		final String userId,
		final GalleryImage image, final int galleryPageIndex,
		final Label formFeedback, Form imageEditForm) {

	AjaxFallbackButton setProfileImageButton = new AjaxFallbackButton(
			"gallerySetProfileImageConfirmButton", new ResourceModel(
					"button.gallery.setprofile.confirm"), imageEditForm) {

		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form form) {

			if (imageLogic.setUploadedProfileImage(
					userId,
					sakaiProxy.getResource(
							image.getMainResource()).getBytes(), "", "")) {

				sakaiProxy.postEvent(
						ProfileConstants.EVENT_PROFILE_IMAGE_CHANGE_UPLOAD,
						"/profile/" + userId, true);

				if (true == sakaiProxy.isWallEnabledGlobally()) {
					wallLogic
							.addNewEventToWall(
									ProfileConstants.EVENT_PROFILE_IMAGE_CHANGE_UPLOAD,
									sakaiProxy.getCurrentUserId());
				}
				
				if (sakaiProxy.isSuperUserAndProxiedToUser(
						userId)) {
					setResponsePage(new MyProfile(userId));
				} else {
					setResponsePage(new MyProfile());
				}

			} else {
				// user alert
				formFeedback.setDefaultModel(new ResourceModel(
						"error.gallery.setprofile.failed"));
				formFeedback.add(new AttributeModifier("class", true,
						new Model("alertMessage")));

				target.add(formFeedback);
			}
		}
	};
	return setProfileImageButton;
}