Author: amarkhel
Date: 2009-03-11 06:48:53 -0400 (Wed, 11 Mar 2009)
New Revision: 12913
Removed:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
Log:
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-03-10
19:51:56 UTC (rev 12912)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-03-11
10:48:53 UTC (rev 12913)
@@ -1,415 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.realworld.util;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Synchronized;
-import org.jboss.seam.core.Events;
-import org.richfaces.component.UIDatascroller;
-import org.richfaces.component.UITree;
-import org.richfaces.component.html.HtmlTree;
-import org.richfaces.event.NodeSelectedEvent;
-import org.richfaces.model.TreeNode;
-import org.richfaces.model.TreeRowKey;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.MetaTag;
-import org.richfaces.realworld.domain.Shelf;
-import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.navigation.NavigationEnum;
-import org.richfaces.realworld.service.Constants;
-
-
-@Name("conversationState")
-(a)Scope(ScopeType.CONVERSATION)
-@Synchronized(timeout=200000)
-public class ConversationState implements Serializable{
-
- private static final long serialVersionUID = 5656562187249324512L;
-
- @In("#{messages['acess_not_granted']}")
- private String HAVENT_ACCESS;
-
- private Integer selectedImageIndex = 1;
-
- private Image selectedImage;
-
- private Album selectedAlbum;
-
- private User selectedUser;
-
- private Shelf selectedShelf;
-
- private User secondSelectedUser;
-
- private MetaTag selectedTag;
-
- private NavigationEnum mainArea;
-
- @In(create=true)
- private User user;
-
- public Integer getSelectedImageIndex() {
- return selectedImageIndex;
- }
-
- public NavigationEnum getMainArea() {
- return mainArea;
- }
-
- public void selectShelfs(){
- setMainArea(NavigationEnum.ALL_SHELFS);
- setSelectedAlbum(null);
- setSelectedShelf(null);
- setSelectedImage(null);
- setSelectedUser(user);
- }
-
- public void selectAlbums(){
- setMainArea(NavigationEnum.ALL_ALBUMS);
- setSelectedAlbum(null);
- setSelectedShelf(null);
- setSelectedImage(null);
- setSelectedUser(user);
- }
-
- public void selectImages(){
- setMainArea(NavigationEnum.ALL_IMAGES);
- setSelectedAlbum(null);
- setSelectedShelf(null);
- setSelectedImage(null);
- setSelectedUser(user);
- }
-
- @Observer(Constants.UPDATE_MAIN_AREA_EVENT)
- public void setMainArea(NavigationEnum mainArea) {
- this.mainArea = mainArea;
- if(mainArea.equals(NavigationEnum.FILE_UPLOAD)){
- Events.instance().raiseEvent(Constants.SHOW_FILE_UPLOAD_EVENT, true);
- }
- }
-
- public void incrementSlideShowIndex(){
- Integer index = getSelectedAlbum().getIndex(getSelectedImage());
- System.out.println("Slideshow execute");
- if(index == -1){
- if(getSelectedAlbum().getImages() != null &&
getSelectedAlbum().getImages().size() > 1){
- System.out.println("Slideshow index will be index of first image");
- index = getSelectedAlbum().getIndex(getSelectedAlbum().getImages().get(1));
- }else{
- Events.instance().raiseEvent("stopSlideshow");
- System.out.println("Slideshow stop");
- return;
- }
- }
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller =
(UIDatascroller)component.findComponent(Constants.DATASCROLLER2_ID);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
- if(index == getSelectedAlbum().getImages().size() - 1){
- index=-1;
- }
- setSelectedImageIndex(index+1);
- setSelectedImage(getSelectedAlbum().getImages().get(index + 1));
- }
-
- public void setSelectedImageIndex(Integer selectedImageIndex) {
- this.selectedImageIndex = selectedImageIndex;
- }
-
- public Image getSelectedImage() {
- return selectedImage;
- }
-
- public void setSelectedImage(Image selectedImage) {
- this.selectedImage = selectedImage;
- }
-
- public Album getSelectedAlbum() {
- return selectedAlbum;
- }
-
- public void setSelectedAlbum(Album selectedAlbum) {
- this.selectedAlbum = selectedAlbum;
- }
-
- public void setSelectedAlbumName(String selectedAlbumName) {
- selectedAlbumName = selectedAlbumName.substring(0, selectedAlbumName.length() -1);
- int lastIndexOf = selectedAlbumName.lastIndexOf(Constants.SLASH);
- String prevPathEnd = selectedAlbumName.substring(lastIndexOf+1);
- //this.selectedAlbum =
((TreeAlbumItem)treeMyAlbumsItem.getNode(prevPathEnd)).getAlbum();
- }
-
- public void showUserProfile(User user){
- setSelectedUser(user);
- setSecondSelectedUser(null);
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.USER_PREFS);
- }
-
- public void showSecondUserProfile(User user){
- setSecondSelectedUser(user);
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.USER_PREFS);
- }
-
- public void showImage(Image image){
- if(!image.getAlbum().isShared() && !image.getAlbum().getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.IMAGE_PREVIEW);
- setSelectedAlbum(image.getAlbum());
- setSelectedImage(image);
- Integer index = getSelectedAlbum().getIndex(getSelectedImage());
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller =
(UIDatascroller)component.findComponent(Constants.DATASCROLLER_ID);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
- setSelectedImageIndex(index+1);
- setSelectedUser(image.getAlbum().getOwner());
- }
-
- public void showUser(User u){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.IMAGE_PREVIEW);
- setSelectedAlbum(null);
- setSelectedImage(null);
- setSelectedUser(u);
- }
-
- public void showAlbum(Album album){
- if(!album.isShared() && !album.getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.IMAGE_PREVIEW);
- setSelectedAlbum(album);
- setSelectedImage(null);
- setSelectedShelf(album.getParent());
- setSelectedUser(album.getOwner());
- }
-
- public void showAlbumFromShelf(Album album){
- if(!album.isShared() && !album.getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_PREVIEW);
- setSelectedAlbum(album);
- setSelectedImage(null);
- setSelectedShelf(album.getParent());
- setSelectedUser(album.getOwner());
- }
-
- public void showImageFromShelf(Image image){
- if(!image.getAlbum().isShared() && !image.getAlbum().getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_IMAGE_PREVIEW);
- setSelectedAlbum(image.getAlbum());
- setSelectedImage(image);
- Integer index = getSelectedAlbum().getIndex(getSelectedImage());
- setSelectedImageIndex(index);
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller =
(UIDatascroller)component.findComponent(Constants.DATASCROLLER_ID);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
- setSelectedImageIndex(index+1);
- setSelectedUser(image.getAlbum().getOwner());
- }
-
- public void editImage(Image image){
- if(!image.getAlbum().isShared() && !image.getAlbum().getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_IMAGE_EDIT);
- }
-
- public void cancelEditImage(Image image){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_IMAGE_PREVIEW);
- }
-
- public void editAlbum(Album album){
- if(album.getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_EDIT);
- }
-
- public void cancelEditAlbum(Album album){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_PREVIEW);
- }
-
- public void editShelf(Shelf shelf){
- if(shelf.getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(HAVENT_ACCESS));
- return;
- }
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.SHELF_EDIT);
- }
-
- public void cancelEditShelf(Shelf shelf){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.SHELF_PREVIEW);
- }
-
- public void selectMyAlbums(){
- setSelectedAlbum(null);
- setSelectedImage(null);
- setSelectedShelf(null);
- setSelectedUser(user);
- }
-
- public void selectUser(User u){
- setSelectedAlbum(null);
- setSelectedImage(null);
- setSelectedUser(u);
- }
-
- public void selectAlbum(Album a){
- setSelectedAlbum(a);
- setSelectedShelf(a.getParent());
- setSelectedImage(null);
- setSelectedUser(a.getOwner());
- }
-
- public void selectShelf(Shelf s){
- setSelectedShelf(s);
- setSelectedAlbum(null);
- setSelectedImage(null);
- setSelectedUser(s.getOwner());
- }
-
- public void showFileUpload(Album item){
- Events.instance().raiseEvent(Constants.FILE_UPLOAD_CLEAR_EVENT);
- setSelectedAlbum(item);
- this.setMainArea(NavigationEnum.FILE_UPLOAD);
- }
-
- @SuppressWarnings("unchecked")
- public Boolean adviseNodeSelected(UITree tree) {
- Object currentNode = tree.getRowData();
- if (currentNode instanceof Album) {
- boolean selected = currentNode == getSelectedAlbum();
- return selected;
- }else if(currentNode instanceof Shelf){
- return currentNode == getSelectedShelf() && getSelectedAlbum() == null;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Boolean adviseNodeOpened(UITree tree) {
- Object currentNode = tree.getRowData();
- if (currentNode instanceof Album) {
- boolean selected = currentNode == getSelectedAlbum();
- return selected;
- }else if(currentNode instanceof Shelf){
- return currentNode == getSelectedShelf();
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public void processSelection(NodeSelectedEvent event) {
- HtmlTree tree = (HtmlTree) event.getComponent();
- Object currentNode = tree.getRowData();
- //TreeNode<Object> currentNode =
(TreeNode<Object>)tree.getModelTreeNode(tree.getRowKey());
- if(currentNode instanceof Album){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_PREVIEW);
- setSelectedAlbum((Album)currentNode);
- setSelectedShelf(((Album)currentNode).getParent());
- }else if(currentNode instanceof Shelf){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.SHELF_PREVIEW);
- setSelectedAlbum(null);
- setSelectedShelf((Shelf)currentNode);
- }
- setSelectedUser(user);
- setSelectedImage(null);
- }
-
- public boolean isSelectedImage(int index){
- return getSelectedAlbum().getIndex(getSelectedImage()) == index -1;
- }
-
- public void updateSelectedItems(Image image){
- setSelectedImage(image);
- Integer index = getSelectedAlbum().getIndex(getSelectedImage());
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller =
(UIDatascroller)component.findComponent(Constants.DATASCROLLER_ID);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
- setSelectedImageIndex(index+1);
- }
-
- public void generateError() {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("Is not
implemented yet!"));
- }
-
- public User getSelectedUser() {
- return selectedUser;
- }
-
- public void setSelectedUser(User selectedUser) {
- this.selectedUser = selectedUser;
- }
-
- public User getSecondSelectedUser() {
- return secondSelectedUser;
- }
-
- public void setSecondSelectedUser(User secondSelectedUser) {
- this.secondSelectedUser = secondSelectedUser;
- }
-
- public Shelf getSelectedShelf() {
- return selectedShelf;
- }
-
- public void setSelectedShelf(Shelf selectedShelf) {
- this.selectedShelf = selectedShelf;
- }
-
- public User getUser() {
- return user;
- }
-
-
-
- public MetaTag getSelectedTag() {
- return selectedTag;
- }
- @Observer("updateSelectedTag")
- public void setSelectedTag(MetaTag selectedTag) {
- this.selectedTag = selectedTag;
- }
-
-}
Show replies by date