001: package org.contineo.web;
002:
003: import org.contineo.core.security.Group;
004: import org.contineo.core.security.dao.GroupDAO;
005:
006: import org.contineo.util.Context;
007: import org.contineo.util.config.LoggingConfigurator;
008:
009: import org.contineo.web.i18n.Messages;
010:
011: import java.util.Collection;
012: import java.util.Iterator;
013:
014: import javax.faces.model.SelectItem;
015:
016: /**
017: * <p>
018: * The SelectionTagsBean Class is the backing bean for selection lists. It is
019: * used to store the options of the various selection components.
020: * <p>
021: */
022: public class SelectionTagsBean {
023: /**
024: * Gets the option items for languages
025: */
026: public SelectItem[] getLanguages() {
027: return new SelectItem[] {
028: new SelectItem("en", Messages
029: .getMessage("msg.jsp.login.language.english")),
030: new SelectItem("it", Messages
031: .getMessage("msg.jsp.login.language.italian")),
032: new SelectItem("de", Messages
033: .getMessage("msg.jsp.login.language.german")),
034: new SelectItem("fr", Messages
035: .getMessage("msg.jsp.login.language.french")),
036: new SelectItem("es", Messages
037: .getMessage("msg.jsp.login.language.spanish")) };
038: }
039:
040: /**
041: * Gets the option items for yes/no flags
042: */
043: public SelectItem[] getYesNo() {
044: return new SelectItem[] {
045: new SelectItem(1, Messages.getMessage("yes")),
046: new SelectItem(0, Messages.getMessage("no")) };
047: }
048:
049: /**
050: * Gets the option items for version types
051: */
052: public SelectItem[] getVersionTypes() {
053: return new SelectItem[] {
054: new SelectItem("release", Messages
055: .getMessage("msg.jsp.newrelease")),
056: new SelectItem("oldversion", Messages
057: .getMessage("msg.jsp.oldversion")),
058: new SelectItem("subversion", Messages
059: .getMessage("msg.jsp.newsubversion")) };
060: }
061:
062: /**
063: * Gets the option items for groups selection
064: */
065: public SelectItem[] getGroups() {
066: // gets available groups
067: GroupDAO dao = (GroupDAO) Context.getInstance().getBean(
068: GroupDAO.class);
069: Collection coll = dao.findAll();
070:
071: SelectItem[] items = new SelectItem[coll.size() - 1];
072:
073: int i = 0;
074:
075: for (Iterator iter = coll.iterator(); iter.hasNext();) {
076: Group currGroup = (Group) iter.next();
077:
078: // do not include admin group in list
079: if (!currGroup.getGroupName().equals("admin")) {
080: items[i++] = new SelectItem(currGroup.getGroupName());
081: }
082: }
083:
084: return items;
085: }
086:
087: /**
088: * Gets the option items for relations
089: */
090: public SelectItem[] getRelations() {
091: return new SelectItem[] {
092: new SelectItem("gt", Messages
093: .getMessage("msg.jsp.greater")),
094: new SelectItem("eq", Messages
095: .getMessage("msg.jsp.equals")),
096: new SelectItem("lt", Messages
097: .getMessage("msg.jsp.less")) };
098: }
099:
100: /**
101: * Gets the option items for relations regarding dates
102: */
103: public SelectItem[] getDateRelations() {
104: return new SelectItem[] {
105: new SelectItem("gt", Messages
106: .getMessage("msg.jsp.after")),
107: new SelectItem("eq", Messages.getMessage("msg.jsp.at")),
108: new SelectItem("lt", Messages
109: .getMessage("msg.jsp.before")) };
110: }
111:
112: /**
113: * Gets the option items for file formats
114: */
115: public SelectItem[] getFormats() {
116: return new SelectItem[] {
117: new SelectItem("html", Messages
118: .getMessage("msg.jsp.internetpage")
119: + " (.html)"),
120: new SelectItem("xml", Messages
121: .getMessage("msg.jsp.xmlfile")
122: + " (.xml)"),
123: new SelectItem("pdf", "Adobe Acrobat (.pdf)"),
124: new SelectItem("ps", "Adobe Postscript (.ps)"),
125: new SelectItem("doc", "Microsoft Word (.doc)"),
126: new SelectItem("sxw", "OpenOffice Writer (.sxw)"),
127: new SelectItem("sxc", "OpenOffice Calc (.sxc)"),
128: new SelectItem("sxi", "OpenOffice Impress (.sxi)"),
129: new SelectItem("wpd", "Word Perfect (.wpd)"),
130: new SelectItem("rtf", "Rich Text Format (.rtf)"),
131: new SelectItem("txt", Messages
132: .getMessage("msg.jsp.textfile")
133: + " (.txt)") };
134: }
135:
136: /**
137: * Gets the option items for message priorities
138: */
139: public SelectItem[] getMessagePriorities() {
140: return new SelectItem[] {
141: new SelectItem(0, Messages.getMessage("msg.jsp.low")),
142: new SelectItem(1, Messages.getMessage("msg.jsp.normal")),
143: new SelectItem(2, Messages.getMessage("msg.jsp.high")) };
144: }
145:
146: /**
147: * Gets the option items for web log appenders
148: */
149: public SelectItem[] getWebAppenders() {
150: LoggingConfigurator conf = new LoggingConfigurator();
151: Collection<String> loggings = conf.getWebLoggingFiles();
152: SelectItem[] items = new SelectItem[loggings.size()];
153: int i = 0;
154:
155: for (String logfile : loggings) {
156: items[i++] = new SelectItem(logfile, logfile);
157: }
158:
159: return items;
160: }
161: }
|