Search in sources :

Example 1 with UserPreferences

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();
}
Also used : UserPreferences(org.santfeliu.web.UserPreferences) RoomBean(org.santfeliu.kernel.web.RoomBean) MessagingException(javax.mail.MessagingException)

Example 2 with UserPreferences

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;
}
Also used : UserPreferences(org.santfeliu.web.UserPreferences) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Comparator(java.util.Comparator)

Example 3 with UserPreferences

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);
}
Also used : UserPreferences(org.santfeliu.web.UserPreferences) RenderKit(javax.faces.render.RenderKit) Renderer(javax.faces.render.Renderer) IOException(java.io.IOException)

Aggregations

UserPreferences (org.santfeliu.web.UserPreferences)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 LinkedList (java.util.LinkedList)1 SelectItem (javax.faces.model.SelectItem)1 RenderKit (javax.faces.render.RenderKit)1 Renderer (javax.faces.render.Renderer)1 MessagingException (javax.mail.MessagingException)1 RoomBean (org.santfeliu.kernel.web.RoomBean)1