use of org.santfeliu.web.UserPreferences in project gdmatrix by gdmatrix.
the class MeetingFinderBean method getRooms.
public Collection<Room> getRooms() {
if (rooms == null || rooms.isEmpty()) {
UserPreferences userPreferences = UserSessionBean.getCurrentInstance().getUserPreferences();
RoomBean roomBean = (RoomBean) getBean("roomBean");
try {
List<String> favRoomIds = userPreferences.getPreferences(roomBean.getObjectTypeId());
for (String favRoomId : favRoomIds) {
Room roomView = new Room();
roomView.setRoomId(favRoomId);
roomView.setDescription(roomBean.getDescription(favRoomId));
roomView.setSelected(false);
this.rooms.put(favRoomId, roomView);
}
} catch (Exception ex) {
error(ex);
}
}
return rooms.values();
}
use of org.santfeliu.web.UserPreferences in project gdmatrix by gdmatrix.
the class ObjectBean method getSelectItems.
public List<SelectItem> getSelectItems() {
// TODO: when 2 descriptions are identical, put objectId before
List<SelectItem> items = new LinkedList<SelectItem>();
// blank row
items.add(new SelectItem(ControllerBean.NEW_OBJECT_ID, " "));
ObjectDescriptionCache cache = ObjectDescriptionCache.getInstance();
for (String historyObjectId : objectHistory) {
SelectItem item = new SelectItem();
item.setValue(historyObjectId);
String description = cache.getDescription(this, historyObjectId);
item.setLabel(("".equals(description)) ? " " : description);
item.setDescription(description);
items.add(item);
}
try {
UserPreferences userPreferences = UserSessionBean.getCurrentInstance().getUserPreferences();
List<String> favoriteIdList = userPreferences.getPreferences(getObjectTypeId());
if (!favoriteIdList.isEmpty()) {
boolean purge = userPreferences.mustPurgePreferences();
List<SelectItem> favorites = new ArrayList<SelectItem>();
for (String favoriteObjectId : favoriteIdList) {
String description = cache.getDescription(this, favoriteObjectId);
if (description != null && !description.isEmpty()) {
SelectItem item = new SelectItem();
item.setValue(favoriteObjectId);
item.setLabel(description);
item.setDescription(description);
favorites.add(item);
} else // Non existing favorite
{
if (purge) {
userPreferences.removePreference(getObjectTypeId(), favoriteObjectId);
}
}
}
if (!favorites.isEmpty()) {
Collections.sort(favorites, new Comparator() {
public int compare(Object o1, Object o2) {
SelectItem item1 = (SelectItem) o1;
SelectItem item2 = (SelectItem) o2;
return item1.getLabel().compareToIgnoreCase(item2.getLabel());
}
});
// separator row
SelectItem separator = new SelectItem(ControllerBean.SEPARATOR_ID, "---------------------------");
separator.setDisabled(true);
items.add(separator);
items.addAll(favorites);
}
}
} catch (Exception ex) {
}
return items;
}
use of org.santfeliu.web.UserPreferences in project gdmatrix by gdmatrix.
the class FCKFaceEditor method encodeEnd.
/**
* Moved to encode end so that the inline java script will run after the textArea was rendered before this script is run
* @param context
* @throws IOException
*/
public void encodeEnd(FacesContext context) throws IOException {
String editorRenderer = DEFAULT_RENDERER_TYPE;
try {
UserPreferences userPreferences = UserSessionBean.getCurrentInstance().getUserPreferences();
editorRenderer = userPreferences.getPreference("ckEditor");
} catch (Exception ex) {
}
if (editorRenderer == null)
editorRenderer = DEFAULT_RENDERER_TYPE;
RenderKit renderKit = context.getRenderKit();
Renderer renderer = renderKit.getRenderer(getFamily(), editorRenderer);
if (renderer != null)
renderer.encodeEnd(context, this);
else
getRenderer(context).encodeEnd(context, this);
}
Aggregations