Java Code Examples for javax.faces.model.SelectItem#setLabel()

The following examples show how to use javax.faces.model.SelectItem#setLabel() . 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: DisplayEvaluationsForStudentToEnrol.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<SelectItem> getExecutionPeriodsLabels() {
    if (this.executionPeriodsLabels == null) {
        this.executionPeriodsLabels = new ArrayList();

        final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods();
        final ComparatorChain comparatorChain = new ComparatorChain();
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year")));
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester")));
        Collections.sort(infoExecutionPeriods, comparatorChain);
        for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
            final SelectItem selectItem = new SelectItem();
            selectItem.setValue(infoExecutionPeriod.getExternalId());
            selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear());
            this.executionPeriodsLabels.add(selectItem);
        }
    }
    return this.executionPeriodsLabels;
}
 
Example 2
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public List getSelectRelativeWidthList() {
 List<SelectItem> list = new ArrayList();
 ResourceLoader rb = new ResourceLoader(
"org.sakaiproject.tool.assessment.bundle.AuthorMessages");
 
 final String[] widthLists = {
	  rb.getString("matrix_width_list_default"),
	  rb.getString("matrix_width_list_1"),
	  rb.getString("matrix_width_list_2"),
	  rb.getString("matrix_width_list_3"),
	  rb.getString("matrix_width_list_4"),
	  rb.getString("matrix_width_list_5"),
	  rb.getString("matrix_width_list_6"),
	  rb.getString("matrix_width_list_7"),
	  rb.getString("matrix_width_list_8"),
	  rb.getString("matrix_width_list_9")};
 
 for (int i=0; i<widthLists.length;i++)
 {
  SelectItem selectItem = new SelectItem();
  selectItem.setLabel(widthLists[i]);
  selectItem.setValue(Integer.toString(i));
  list.add(selectItem);
 }
 return list;
}
 
Example 3
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getTrueFalseAnswerSelectList() {
  List list = new ArrayList();

  String trueprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","true_msg");
  String falseprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","false_msg");
  String[] answerValues = {"true", "false"};  // not to be displayed in the UI
  String[] answerLabelText= {trueprop, falseprop};
  currentItem.setAnswers(answerValues);
  currentItem.setAnswerLabels(answerLabelText);

  for (int i = 0; i < answerValues.length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel(answerLabelText[i]);
    selection.setValue(answerValues[i]);
    list.add(selection);
  }

  return list;
}
 
Example 4
Source File: AuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getSectionSelectList()
{
  List list = new ArrayList();

  if (sections == null) return list;

  for (int i = 0; i < sections.size(); i++) {
    SelectItem selection = new SelectItem();
    SectionBean sBean = (SectionBean) sections.get(i);
    selection.setLabel(sBean.getSectionTitle());
    selection.setValue(sBean.getSectionIdent());
    list.add(selection);
  }

  return list;
}
 
Example 5
Source File: SectionBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Get a numerical sequence for all parts.
 * Derived property.
 * @return String[] in format "1", "2", "3"... up to the number of parts
 */
public List getSectionNumberList()
{
  List list = new ArrayList();

  if (assessmentSectionIdents==null) return list;

  for (int i = 0; i < assessmentSectionIdents.toArray().length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel("" + i);
    selection.setValue("" + i);
    list.add(selection);
  }

  return list;
}
 
Example 6
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public List getSelectRelativeWidthList() {
 List<SelectItem> list = new ArrayList();
 ResourceLoader rb = new ResourceLoader(
"org.sakaiproject.tool.assessment.bundle.AuthorMessages");
 
 final String[] widthLists = {
	  rb.getString("matrix_width_list_default"),
	  rb.getString("matrix_width_list_1"),
	  rb.getString("matrix_width_list_2"),
	  rb.getString("matrix_width_list_3"),
	  rb.getString("matrix_width_list_4"),
	  rb.getString("matrix_width_list_5"),
	  rb.getString("matrix_width_list_6"),
	  rb.getString("matrix_width_list_7"),
	  rb.getString("matrix_width_list_8"),
	  rb.getString("matrix_width_list_9")};
 
 for (int i=0; i<widthLists.length;i++)
 {
  SelectItem selectItem = new SelectItem();
  selectItem.setLabel(widthLists[i]);
  selectItem.setValue(Integer.toString(i));
  list.add(selectItem);
 }
 return list;
}
 
Example 7
Source File: CoordinatorEvaluationManagementBackingBean.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<SelectItem> getExecutionPeriodsLabels() {
    if (this.executionPeriodsLabels == null) {
        this.executionPeriodsLabels = new ArrayList();

        final List<InfoExecutionPeriod> infoExecutionPeriods = getExecutionPeriods();
        final ComparatorChain comparatorChain = new ComparatorChain();
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("infoExecutionYear.year")));
        comparatorChain.addComparator(new ReverseComparator(new BeanComparator("semester")));
        Collections.sort(infoExecutionPeriods, comparatorChain);
        for (final InfoExecutionPeriod infoExecutionPeriod : infoExecutionPeriods) {
            final SelectItem selectItem = new SelectItem();
            selectItem.setValue(infoExecutionPeriod.getExternalId());
            selectItem.setLabel(infoExecutionPeriod.getName() + " - " + infoExecutionPeriod.getInfoExecutionYear().getYear());
            this.executionPeriodsLabels.add(selectItem);
        }
    }
    return this.executionPeriodsLabels;
}
 
Example 8
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getTrueFalseAnswerSelectList() {
  List list = new ArrayList();

  String trueprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","true_msg");
  String falseprop= ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages","false_msg");
  String[] answerValues = {"true", "false"};  // not to be displayed in the UI
  String[] answerLabelText= {trueprop, falseprop};
  currentItem.setAnswers(answerValues);
  currentItem.setAnswerLabels(answerLabelText);

  for (int i = 0; i < answerValues.length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel(answerLabelText[i]);
    selection.setValue(answerValues[i]);
    list.add(selection);
  }

  return list;
}
 
Example 9
Source File: AuthorBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Derived property.
 * @return ArrayList of model SelectItems
 */

public List getSectionSelectList()
{
  List list = new ArrayList();

  if (sections == null) return list;

  for (int i = 0; i < sections.size(); i++) {
    SelectItem selection = new SelectItem();
    SectionBean sBean = (SectionBean) sections.get(i);
    selection.setLabel(sBean.getSectionTitle());
    selection.setValue(sBean.getSectionIdent());
    list.add(selection);
  }

  return list;
}
 
Example 10
Source File: SectionBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Get a numerical sequence for all parts.
 * Derived property.
 * @return String[] in format "1", "2", "3"... up to the number of parts
 */
public List getSectionNumberList()
{
  List list = new ArrayList();

  if (assessmentSectionIdents==null) return list;

  for (int i = 0; i < assessmentSectionIdents.toArray().length; i++) {
    SelectItem selection = new SelectItem();
    selection.setLabel("" + i);
    selection.setValue("" + i);
    list.add(selection);
  }

  return list;
}
 
Example 11
Source File: ApplicationBean.java    From development with Apache License 2.0 5 votes vote down vote up
public List<SelectItem> getAvailableLanguageItems() {
    List<SelectItem> availableLanguageItems = new ArrayList<SelectItem>();
    for (String isoCode : getActiveLocales()) {
        SelectItem selectItem = new SelectItem();
        Locale languageLocale = new Locale(isoCode);
        String translatedLocale = languageLocale.getDisplayLanguage(ui
                .getViewLocale());
        selectItem.setLabel(translatedLocale);
        selectItem.setValue(isoCode);
        availableLanguageItems.add(selectItem);
    }
    return availableLanguageItems;
}
 
Example 12
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
* Get a numerical sequence for all questions.
* Derived property.
* @return String[] in format "1", "2", "3"... up to the number of questions
*/

 public List getItemNumberList(){
   List list = new ArrayList();

   for (int i = 0; i < items.toArray().length; i++) {
     SelectItem selection = new SelectItem();
     selection.setLabel("" + i);
     selection.setValue("" + i);
     list.add(selection);
   }

   return list;
 }
 
Example 13
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public List<SelectItem> getAuthorTypeList()
{

  List<SelectItem> list = new ArrayList<SelectItem>();
  // cannot disable only one radio button in a list, so am generating the list again

  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");

  SelectItem selection = new SelectItem();
  selection.setLabel(rb.getString("type_onebyone"));
  selection.setValue("1");
  list.add(selection);
  
  SelectItem selection1 = new SelectItem();
  boolean disabled = false;
  String label = rb.getString("random_draw_from_que");
  
  if (hideRandom)
  {
      label += " " + rb.getString("random_draw_from_que_edit_disabled");
      disabled = true;
  }
  else if (getPoolsAvailable().isEmpty())
  {
      label += " " + rb.getString("randow_draw_from_que_no_pools_available");
      disabled = true;
  }
  
  selection1.setDisabled(disabled);
  selection1.setLabel(label);
  selection1.setValue("2");
  list.add(selection1);

  return list;
}
 
Example 14
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
* Get a numerical sequence for all questions.
* Derived property.
* @return String[] in format "1", "2", "3"... up to the number of questions
*/

 public List getItemNumberList(){
   List list = new ArrayList();

   for (int i = 0; i < items.toArray().length; i++) {
     SelectItem selection = new SelectItem();
     selection.setLabel("" + i);
     selection.setValue("" + i);
     list.add(selection);
   }

   return list;
 }
 
Example 15
Source File: SectionBean.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public List<SelectItem> getAuthorTypeList()
{

  List<SelectItem> list = new ArrayList<SelectItem>();
  // cannot disable only one radio button in a list, so am generating the list again

  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");

  SelectItem selection = new SelectItem();
  selection.setLabel(rb.getString("type_onebyone"));
  selection.setValue("1");
  list.add(selection);
  
  SelectItem selection1 = new SelectItem();
  boolean disabled = false;
  String label = rb.getString("random_draw_from_que");
  
  if (hideRandom)
  {
      label += " " + rb.getString("random_draw_from_que_edit_disabled");
      disabled = true;
  }
  else if (getPoolsAvailable().isEmpty())
  {
      label += " " + rb.getString("randow_draw_from_que_no_pools_available");
      disabled = true;
  }
  
  selection1.setDisabled(disabled);
  selection1.setLabel(label);
  selection1.setValue("2");
  list.add(selection1);

  return list;
}
 
Example 16
Source File: UpdateMarketplaceBean.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the label of the {@link SelectItem} matching the passed
 * {@link VOMarketplace}.
 *
 * @param mp
 *            the {@link VOMarketplace} to get the new label from
 * @param list
 *            the list of {@link SelectItem} to update
 */
void updateSelectionList(VOMarketplace mp, List<SelectItem> list) {
    if (list == null) {
        return;
    }
    for (SelectItem si : list) {
        if (mp.getMarketplaceId().equals(si.getValue())) {
            si.setLabel(getLabel(mp));
            break;
        }
    }
}
 
Example 17
Source File: OrganizerSignupMBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * This will load all the potential participants for an event/meeting and
 * wrap it for UI purpose. Due to efficiency issue, it will auto rolled back
 * to Eid-Input mode when the number of users are bigger thank 600 ( defined
 * by <I>MAX_NUM_ATTENDEES_ALLOWED_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE</I>}
 * value).
 * 
 * @param meeting
 *            a SignupMeeting object.
 */
public void loadAllAttendees(SignupMeeting meeting) {
	if(meeting.isEidInputMode()){
		setEidInputMode(true);
		return;
	}
		

	try {
		Site site = getSakaiFacade().getSiteService().getSite(getSakaiFacade().getCurrentLocationId());
		if(site !=null){
			int allMemeberSize = site.getMembers()!=null? site.getMembers().size() : 0;
			/*
			 * due to efficiency, user has to input EID instead of using dropdown
			 * user name list
			 */
			/*First check to avoid load all site member up if there is ten of thousends*/
			if(allMemeberSize > MAX_NUM_PARTICIPANTS_FOR_DROPDOWN_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE){
				setEidInputMode(true);		
				return;
			}
		}
	} catch (IdUnusedException e) {
		log.error(e.getMessage(), e);
	}
	
	this.allSignupUsers = sakaiFacade.getAllPossibleAttendees(meeting);
	/*
	 * due to efficiency, user has to input EID instead of using dropdown
	 * user name list
	 */
	if (allSignupUsers != null
			&& allSignupUsers.size() > MAX_NUM_PARTICIPANTS_FOR_DROPDOWN_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE) {
		setEidInputMode(true);
		return;
	}

	setEidInputMode(false);
	allAttendees = new ArrayList<SelectItem>();
	String previous_displayName ="";
	int index = 0;
	for (SignupUser user : allSignupUsers) {
		if(user.getDisplayName().equals(previous_displayName)){
			allAttendees.add(new SelectItem(user.getEid(), user.getDisplayName()+ "(" + user.getEid() +")"));
			SelectItem prev_sItem = allAttendees.get(index-1);
			//checking: not already has eid for triple duplicates case
			if(!prev_sItem.getLabel().contains("(")){
				prev_sItem.setLabel(prev_sItem.getLabel() + " (" + prev_sItem.getValue() +")");
			}
			
		}else {
			allAttendees.add(new SelectItem(user.getEid(), user.getDisplayName()));
		}
		
		previous_displayName = user.getDisplayName();
		index++;
	}
}
 
Example 18
Source File: NewSignupMeetingBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void loadAllAttendees(SignupMeeting meeting) {
    if (isEidInputMode())
        return;

    try {
        Site site = getSakaiFacade().getSiteService().getSite(getSakaiFacade().getCurrentLocationId());
        if (site != null) {
            int allMemeberSize = site.getMembers() != null ? site.getMembers().size() : 0;
            /*
             * due to efficiency, user has to input EID instead of using dropdown
             * user name list
             * First check to avoid load all site member up if there is ten of thousends
             */
            if (allMemeberSize > MAX_NUM_PARTICIPANTS_FOR_DROPDOWN_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE) {
                setEidInputMode(true);
                return;
            }
        }
    } catch (IdUnusedException e) {
        log.error(e.getMessage(), e);
    }

    allSignupUsers = sakaiFacade.getAllPossibleAttendees(meeting);

    if (allSignupUsers != null && allSignupUsers.size() > MAX_NUM_PARTICIPANTS_FOR_DROPDOWN_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE) {
        setEidInputMode(true);
        return;
    }

    setEidInputMode(false);
    allAttendees = new ArrayList<>();
    SelectItem sItem = new SelectItem("", " " + Utilities.rb.getString("label.select.attendee"));
    allAttendees.add(sItem);
    String previous_displayName = "";
    int index = 0;
    for (SignupUser user : allSignupUsers) {
        if (user.getDisplayName().equals(previous_displayName)) {
            allAttendees.add(new SelectItem(user.getEid(), user.getDisplayName() + "(" + user.getEid() + ")"));
            SelectItem prev_sItem = allAttendees.get(index);
            //checking: not already has eid for triple duplicates case
            if (!prev_sItem.getLabel().contains("(")) {
                prev_sItem.setLabel(prev_sItem.getLabel() + " (" + prev_sItem.getValue() + ")");
            }

        } else {
            allAttendees.add(new SelectItem(user.getEid(), user.getDisplayName()));
        }

        previous_displayName = user.getDisplayName();
        index++;
    }
}
 
Example 19
Source File: ItemAuthorBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public List getSectionSelectList() {
  List list = new ArrayList();
  
  ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");
  AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean");
  List<SectionContentsBean> sectionSet = assessbean.getSections();
  Iterator<SectionContentsBean> iter = sectionSet.iterator();
  int i =0;
  while (iter.hasNext()){
    i = i + 1;
    SectionContentsBean part = iter.next();
    SelectItem selection = new SelectItem();

    // need to filter out all the random draw parts
    if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) {
      // skip random draw parts, cannot add items to this part manually
    }
    else {
      if ("".equals(part.getTitle())) {
        selection.setLabel(rb.getString("p")+" "+ i );
      }
      else {
        selection.setLabel(rb.getString("p")+" " + i + " - " + ComponentManager.get(FormattedText.class).convertFormattedTextToPlaintext(part.getTitle()));
      }
      selection.setValue(part.getSectionId());
      list.add(selection);
    }

  }


  Collections.reverse(list);
  // create a new part if there are no non-randomDraw parts available
  if (list.size() <1) {
    i = i + 1;
    SelectItem temppart = new SelectItem();
    temppart.setLabel(rb.getString("p")+" "+ i );
    temppart.setValue("-1");  // use -1 to indicate this is a temporary part. if the user decides to cancel the operation, this part will not be created
    list.add(temppart);
  } 
  

  return list;
}
 
Example 20
Source File: OrganizerSignupMBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * This will load all the potential participants for an event/meeting and
 * wrap it for UI purpose. Due to efficiency issue, it will auto rolled back
 * to Eid-Input mode when the number of users are bigger thank 600 ( defined
 * by <I>MAX_NUM_ATTENDEES_ALLOWED_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE</I>}
 * value).
 * 
 * @param meeting
 *            a SignupMeeting object.
 */
public void loadAllAttendees(SignupMeeting meeting) {
	if(meeting.isEidInputMode()){
		setEidInputMode(true);
		return;
	}
		

	try {
		Site site = getSakaiFacade().getSiteService().getSite(getSakaiFacade().getCurrentLocationId());
		if(site !=null){
			int allMemeberSize = site.getMembers()!=null? site.getMembers().size() : 0;
			/*
			 * due to efficiency, user has to input EID instead of using dropdown
			 * user name list
			 */
			/*First check to avoid load all site member up if there is ten of thousends*/
			if(allMemeberSize > MAX_NUM_PARTICIPANTS_FOR_DROPDOWN_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE){
				setEidInputMode(true);		
				return;
			}
		}
	} catch (IdUnusedException e) {
		log.error(e.getMessage(), e);
	}
	
	this.allSignupUsers = sakaiFacade.getAllPossibleAttendees(meeting);
	/*
	 * due to efficiency, user has to input EID instead of using dropdown
	 * user name list
	 */
	if (allSignupUsers != null
			&& allSignupUsers.size() > MAX_NUM_PARTICIPANTS_FOR_DROPDOWN_BEFORE_AUTO_SWITCH_TO_EID_INPUT_MODE) {
		setEidInputMode(true);
		return;
	}

	setEidInputMode(false);
	allAttendees = new ArrayList<SelectItem>();
	String previous_displayName ="";
	int index = 0;
	for (SignupUser user : allSignupUsers) {
		if(user.getDisplayName().equals(previous_displayName)){
			allAttendees.add(new SelectItem(user.getEid(), user.getDisplayName()+ "(" + user.getEid() +")"));
			SelectItem prev_sItem = allAttendees.get(index-1);
			//checking: not already has eid for triple duplicates case
			if(!prev_sItem.getLabel().contains("(")){
				prev_sItem.setLabel(prev_sItem.getLabel() + " (" + prev_sItem.getValue() +")");
			}
			
		}else {
			allAttendees.add(new SelectItem(user.getEid(), user.getDisplayName()));
		}
		
		previous_displayName = user.getDisplayName();
		index++;
	}
}