Author: amarkhel
Date: 2009-03-06 10:43:19 -0500 (Fri, 06 Mar 2009)
New Revision: 12862
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/anonimShelfs.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree2.xhtml
Removed:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeShelfItem.java
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java
trunk/test-applications/realworld2/ejb/src/main/resources/import.sql
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
trunk/test-applications/realworld2/web/src/main/webapp/index.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/menu.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/panelBar-backup.xhtml
Log:
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -56,6 +56,9 @@
@org.hibernate.annotations.OrderBy(clause = "NAME asc")
private List<Album> childAlbums = new ArrayList<Album>();
+ @NotNull
+ private boolean shared;
+
@Temporal(TemporalType.TIMESTAMP)
private Date created;
@@ -163,4 +166,12 @@
public void setCreated(Date created) {
this.created = created;
}
+
+ public boolean isShared() {
+ return shared;
+ }
+
+ public void setShared(boolean shared) {
+ this.shared = shared;
+ }
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IShelfAction.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -1,9 +1,12 @@
package org.richfaces.realworld.service;
+import java.util.List;
+
import javax.ejb.Local;
import org.richfaces.realworld.domain.Shelf;
+import org.richfaces.realworld.domain.User;
@Local
public interface IShelfAction {
@@ -13,4 +16,6 @@
public void deleteShelf(Shelf shelf);
public void editShelf(Shelf shelf);
+
+ public List<Shelf> getShelfs(User user);
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ShelfAction.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -20,7 +20,10 @@
*/
package org.richfaces.realworld.service;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
@@ -58,4 +61,14 @@
em.flush();
}
+ public List<Shelf> getShelfs(User user) {
+ Set<Shelf> sh = new HashSet<Shelf>();
+ List<Shelf> shelfs = em.createQuery("from Shelf s where
s.shared=true")
+ .getResultList();
+ sh.addAll(shelfs);
+ sh.addAll(user.getShelfs());
+ shelfs.clear();
+ shelfs.addAll(sh);
+ return shelfs;
+ }
}
Modified: trunk/test-applications/realworld2/ejb/src/main/resources/import.sql
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/resources/import.sql 2009-03-06
15:20:34 UTC (rev 12861)
+++ trunk/test-applications/realworld2/ejb/src/main/resources/import.sql 2009-03-06
15:43:19 UTC (rev 12862)
@@ -2,10 +2,10 @@
INSERT INTO Users(user_id, firstname, secondname, email, login, passwordHash, birthdate,
sex, doNotShowMail, informAboutNews, hasAvatar) VALUES (2, 'Nick',
'Curtis', 'nkurtis(a)iba.com', 'Viking',
'8cb2237d0679ca88db6464eac60da96345513964', '1978-01-08', 1, 1, 1, 0);
INSERT INTO Users(user_id, firstname, secondname, email, login, passwordHash, birthdate,
sex, doNotShowMail, informAboutNews, hasAvatar) VALUES (3, 'John',
'Smith', 'jsmith(a)jboss.com', 'Noname',
'8cb2237d0679ca88db6464eac60da96345513964', '1970-01-08', 1, 1, 1, 0);
-INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created) VALUES (1,
'Nature', 'Nature pictures', 1, '2008-12-18');
-INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created) VALUES (2,
'Sport', 'Nature pictures', 1, '2008-12-18');
-INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created) VALUES (3,
'Water', 'Nature pictures', 2, '2008-12-18');
-INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created) VALUES (4,
'Flowers', 'Nature pictures', 3, '2008-12-18');
+INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created, shared) VALUES
(1, 'Nature', 'Nature pictures', 1, '2008-12-18', true);
+INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created,shared) VALUES (2,
'Sport', 'Nature pictures', 1, '2008-12-18', true);
+INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created,shared) VALUES (3,
'Water', 'Nature pictures', 2, '2008-12-18', true);
+INSERT INTO shelfs(shelf_id, name, description, shelf_user_id, created,shared) VALUES (4,
'Flowers', 'Nature pictures', 3, '2008-12-18', true);
INSERT INTO albums(album_id, name, description, shared, album_user_id, parent_shelf_id,
created) VALUES (15, 'Water', 'Rivers pictures', true, 2, 3,
'2008-12-18');
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -39,8 +39,6 @@
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IAlbumAction;
-import org.richfaces.realworld.tree.TreeAlbumItem;
-import org.richfaces.realworld.tree.TreeRootItem;
import org.richfaces.realworld.util.ConversationState;
@Name("albumManager")
@@ -64,8 +62,6 @@
public void setOncomplete(String oncomplete) {
this.oncomplete = oncomplete;
}
-
- @In(required=false, create=false) @Out(required=false) TreeRootItem treeRoot;
@In(create=true, required=true) @Out
private Album album;
@@ -82,12 +78,12 @@
public void addAlbum(Album album){
albumAction.addAlbum(album);
- addAlbumToTree();
addDirectory();
//Update conversation state
conversationState.setSelectedImage(null);
conversationState.setSelectedAlbum(album);
Events.instance().raiseEvent("albumAdded");
+ Events.instance().raiseEvent("clearTree");
setOncomplete();
}
@@ -95,15 +91,6 @@
album = new Album();
album.setParent(shelf);
}
-
- private void addAlbumToTree() {
- if(album.getParent() != null){
- TreeNode shelf = treeRoot.findShelf(album.getParent());
- shelf.addChild(album.getId(), new TreeAlbumItem(album.getId(),shelf, album));
- }else{
- treeRoot.addChild(album.getId(), new TreeAlbumItem(album.getId(),treeRoot, album));
- }
- }
public void editAlbum(Album album){
albumAction.editAlbum(album);
@@ -114,23 +101,14 @@
public void deleteAlbum(Album album){
//Update domain model
String string = album.getId().toString();
- removeFromTree(album);
albumAction.deleteAlbum(album);
deleteDirectory(string);
conversationState.setSelectedImage(null);
conversationState.setSelectedAlbum(null);
Events.instance().raiseEvent("albumDeleted");
+ Events.instance().raiseEvent("clearTree");
}
- private void removeFromTree(Album album2) {
- if(album.getParent() != null){
- TreeNode shelf = treeRoot.findShelf(album.getParent());
- shelf.removeChild(album.getId());
- }else{
- treeRoot.removeChild(album.getId());
- }
- }
-
private void deleteDirectory(String albumName) {
fileManager.deleteDirectory(user.getLogin(), albumName);
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -54,6 +54,7 @@
public class Authenticator implements Serializable
{
+ @In(create=true) ShelfManager shelfManager;
@In("#{messages['invalid_login']}")
private String INVALID_LOGIN_OR_PASSWORD;
@In("#{messages['login_success']}")
@@ -96,6 +97,7 @@
credentials.setUsername(username);
try {
identity.authenticate();
+ shelfManager.clearShelfs();
} catch (LoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -109,6 +111,7 @@
if (wantLoginAnonymous()) {
identity.addRole(Constants.GUEST_ROLE);
userAction.loginAnonymous();
+ conversationState.setMainArea(NavigationEnum.ANONYM);
return true;
}
try {
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -27,6 +27,7 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
+import org.jboss.seam.core.Events;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DropEvent;
import org.richfaces.event.DropListener;
@@ -38,13 +39,10 @@
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IAlbumAction;
-import org.richfaces.realworld.tree.TreeAlbumItem;
-import org.richfaces.realworld.tree.TreeRootItem;
@Name("dndManager")
public class DnDManager implements DropListener {
- @In(required=false, create=false) @Out(required=false) TreeRootItem treeRoot;
@In("#{messages['album_present']}")
private String ALBUM_WITH_THIS_NAME_ALREADY_PRESENT;
@In User user;
@@ -76,17 +74,14 @@
}
private void handleShelf(Album dragValue, Shelf dropValue) {
- TreeNode<Object> itemParent = null;
- TreeNode<Object> itemParentNew = null;
if(dragValue.getParent() != null ){
- itemParent = treeRoot.findShelf(dragValue.getParent());
- itemParentNew = treeRoot.findShelf(dropValue);
if(dragValue.getParent().equals(dropValue)){
//Parent album contain this album
return;
}else{
- itemParent.removeChild(dragValue.getId());
- itemParentNew.addChild(dragValue.getId(), new TreeAlbumItem(dragValue.getId(),
itemParentNew, dragValue));
+ dropValue.addChildAlbum(dragValue);
+ albumAction.flush();
+ Events.instance().raiseEvent("clearTree");
}
}
addTreeToRerender();
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -36,7 +36,6 @@
import org.richfaces.realworld.navigation.NavigationEnum;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IImageAction;
-import org.richfaces.realworld.tree.TreeAlbumItem;
import org.richfaces.realworld.util.ConversationState;
@Name("imageManager")
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -29,15 +29,18 @@
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.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IShelfAction;
-import org.richfaces.realworld.tree.TreeRootItem;
-import org.richfaces.realworld.tree.TreeShelfItem;
+
import org.richfaces.realworld.util.ConversationState;
@Name("shelfManager")
@@ -46,6 +49,7 @@
private static final long serialVersionUID = 2631634926126857691L;
+ private List<Shelf> shelfs;
@In private FileManager fileManager;
@In(create=true, required=true)
private IShelfAction shelfAction;
@@ -65,7 +69,6 @@
public void setOncomplete(String oncomplete) {
this.oncomplete = oncomplete;
}
- @In(required=false, create=false) @Out(required=false) TreeRootItem treeRoot;
@In(create=true, required=true) @Out
private Shelf shelf;
@@ -78,17 +81,14 @@
public void addShelf(Shelf shelf){
shelfAction.addShelf(shelf);
- addShelfToTree();
//Update conversation state
conversationState.setSelectedImage(null);
conversationState.setSelectedAlbum(null);
conversationState.setSelectedShelf(shelf);
setOncomplete();
+ Events.instance().raiseEvent("clearTree");
}
- private void addShelfToTree() {
- treeRoot.addChild(shelf.getId(), new TreeShelfItem(shelf.getId(), treeRoot, shelf));
- }
public void editShelf(Shelf shelf){
shelfAction.editShelf(shelf);
@@ -102,18 +102,26 @@
directoriesToDelete.add(user.getLogin() + "/" +a.getId());
}
shelfAction.deleteShelf(shelf);
- removeFromTree(shelf);
deleteDirectories(directoriesToDelete);
conversationState.setSelectedImage(null);
conversationState.setSelectedAlbum(null);
conversationState.setSelectedShelf(null);
+ Events.instance().raiseEvent("clearTree");
}
private void deleteDirectories(List<String> directoriesToDelete) {
fileManager.deleteDirectories(directoriesToDelete);
}
-
- private void removeFromTree(Shelf shelf2) {
- treeRoot.removeChild(shelf2.getId());
+
+ public List<Shelf> getShelfs(){
+ if(shelfs == null){
+ shelfs = shelfAction.getShelfs(user);
+ }
+ return shelfs;
}
+
+ @Observer("clearTree")
+ public void clearShelfs(){
+ shelfs = null;
+ }
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -32,6 +32,7 @@
import org.jboss.seam.annotations.Scope;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.service.IUserAction;
@@ -107,4 +108,6 @@
countAlbums = i;
countImages = j;
}
+
+
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -22,6 +22,7 @@
public enum NavigationEnum {
IMAGE_PREVIEW("includes/imagePreview.xhtml"),
+ ANONYM("includes/anonimShelfs.xhtml"),
FILE_UPLOAD("includes/fileUpload.xhtml"),
USER_PREFS("includes/userPrefs.xhtml"),
SEARCH("includes/search.xhtml"),
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -1,111 +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.tree;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.model.SelectItem;
-
-import org.richfaces.model.TreeNode;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.service.Constants;
-
-public class TreeAlbumItem implements TreeNode<Object> {
-
- private static final String ALBUM_NODE_TYPE = "album";
-
- private static final long serialVersionUID = 6514596192023597908L;
-
- private long id;
- private Album album;
- TreeNode parent;
-
- public TreeAlbumItem(long id, TreeNode<Object> parent, Album album) {
- this.id = id;
- this.parent = parent;
- this.album = album;
- }
-
- public void addChild(Object identifier, TreeNode<Object> child) {
-
- }
-
- public TreeNode<Object> getChild(Object id) {
- return null;
- }
-
- public Iterator<Map.Entry<Object, TreeNode<Object>>> getChildren() {
- return null;
- }
-
- public Object getData() {
- return this;
- }
-
- public TreeNode<Object> getParent() {
- return parent;
- }
-
- public boolean isLeaf() {
- return true;
- }
-
- public void removeChild(Object id) {
-
- }
-
- public void setData(Object data) {
- }
-
- public void setParent(TreeNode<Object> parent) {
- this.parent = parent;
- }
-
- public long getId() {
- return id;
- }
-
- public Album getAlbum() {
- if(album == null){
- System.out.println();
- }
- return album;
- }
-
- public void setAlbum(Album album) {
- this.album = album;
- }
-
- public String getType() {
- return Constants.ALBUM_NODE_TYPE;
- }
-
- public String toString(){
- return this.getAlbum().getName();
- }
-
-}
-
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -1,130 +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.tree;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.model.SelectItem;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.model.TreeNode;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Shelf;
-import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.service.IUserAction;
-
-@Name("treeRoot")
-(a)Scope(ScopeType.CONVERSATION)
-public class TreeRootItem implements TreeNode {
-
- private static final String TREE_ROOT_NODE_TYPE = "treeRoot";
-
- @In IUserAction userAction;
- @In @Out
- private User user;
-
- private static final long serialVersionUID = -3530085227471752526L;
-
- private Map<Long, TreeNode> childs = null;
-
- public Map<Long, TreeNode> getChilds() {
- if (this.childs==null) {
- initData();
- }
- return this.childs;
- }
-
- public void addChild(Object identifier, TreeNode child) {
- getChilds().put((Long)identifier, (TreeNode)child);
- child.setParent(this);
- }
-
- public TreeNode getChild(Object id) {
- return (TreeNode) childs.get(id);
- }
-
- public Iterator getChildren() {
- return getChilds().entrySet().iterator();
- }
-
- public Object getData() {
- return this;
- }
-
- public TreeNode getParent() {
- return null;
- }
-
- public boolean isLeaf() {
- return getChilds().isEmpty();
- }
-
- public void removeChild(Object id) {
- childs.remove(id);
- }
-
- public void setData(Object data) {
- }
-
- public void setParent(TreeNode parent) {
- }
-
- public String getType() {
- return TREE_ROOT_NODE_TYPE;
- }
-
- private void initData() {
- transformAlbumsToMap();
- }
-
- private void transformAlbumsToMap() {
- childs = new HashMap<Long, TreeNode>();
- for(Shelf shelf:user.getShelfs()){
- TreeShelfItem shelfNode = new TreeShelfItem(shelf.getId(), this, shelf);
- addChild(shelf.getId(), shelfNode);
- }
- for(Album album:userAction.getRootAlbums(user)){
- TreeAlbumItem albumNode = new TreeAlbumItem(album.getId(), this, album);
- addChild(album.getId(), albumNode);
- }
- }
-
- public TreeAlbumItem getAlbumByName(String albumName) {
- for(Map.Entry<Long, TreeNode> entry : getChilds().entrySet()){
- if(entry.getValue() instanceof TreeAlbumItem &&
((TreeAlbumItem)entry.getValue()).getAlbum().getName().equals(albumName)){
- return (TreeAlbumItem)entry.getValue();
- }
- }
- return null;
- }
-
- public TreeNode findShelf(Shelf parent) {
- return childs.get(parent.getId());
- }
-}
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeShelfItem.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeShelfItem.java 2009-03-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/TreeShelfItem.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -1,96 +0,0 @@
-package org.richfaces.realworld.tree;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.richfaces.model.TreeNode;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Shelf;
-import org.richfaces.realworld.service.Constants;
-
-public class TreeShelfItem implements TreeNode<Object> {
-
-private static final long serialVersionUID = 6514596192023597908L;
-
- private long id;
- private Shelf shelf;
- TreeNode parent;
- private Map<Long, TreeNode> childs = null;
-
- public TreeShelfItem(long id, TreeNode<Object> parent, Shelf shelf) {
- this.id = id;
- this.parent = parent;
- this.shelf = shelf;
- init();
- }
-
- private void init() {
- childs = new HashMap<Long, TreeNode>();
- for(Album album:shelf.getChildAlbums()){
- TreeAlbumItem albumNode = new TreeAlbumItem(album.getId(), this, album);
- addChild(album.getId(), albumNode);
- }
- }
-
- public void addChild(Object identifier, TreeNode<Object> child) {
- getChilds().put((Long)identifier, (TreeNode)child);
- child.setParent(this);
- }
-
- public TreeNode getChild(Object id) {
- return (TreeNode) childs.get(id);
- }
-
- public Iterator getChildren() {
- return getChilds().entrySet().iterator();
- }
-
- public Object getData() {
- return this;
- }
-
- public TreeNode getParent() {
- return parent;
- }
-
- public boolean isLeaf() {
- return getChilds().isEmpty();
- }
-
- public void removeChild(Object id) {
- childs.remove(id);
- }
-
- public void setData(Object data) {
- shelf = (Shelf)data;
- }
-
- public void setParent(TreeNode parent) {
- this.parent = parent;
- }
-
- public String getType() {
- return "shelf";
- }
-
- public Map<Long, TreeNode> getChilds() {
- return childs;
- }
-
- public void setChilds(Map<Long, TreeNode> childs) {
- this.childs = childs;
- }
-
- public Shelf getShelf() {
- return shelf;
- }
-
- public void setShelf(Shelf shelf) {
- this.shelf = shelf;
- }
-
-}
Modified:
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-06
15:20:34 UTC (rev 12861)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-03-06
15:43:19 UTC (rev 12862)
@@ -46,9 +46,8 @@
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.navigation.NavigationEnum;
import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.tree.TreeAlbumItem;
-import org.richfaces.realworld.tree.TreeShelfItem;
+
@Name("conversationState")
@Scope(ScopeType.CONVERSATION)
@Synchronized(timeout=200000)
@@ -298,24 +297,24 @@
@SuppressWarnings("unchecked")
public Boolean adviseNodeSelected(UITree tree) {
- TreeRowKey<Object> treeRowKey = (TreeRowKey<Object>) tree.getRowKey();
- TreeNode<Object> treeNode = (TreeNode<Object>)
tree.getRowData(treeRowKey);
- if (treeNode instanceof TreeAlbumItem) {
- TreeAlbumItem currentNode = (TreeAlbumItem) treeNode;
- boolean selected = currentNode.getAlbum() == getSelectedAlbum();
+ 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) {
- TreeRowKey<Object> treeRowKey = (TreeRowKey<Object>) tree.getRowKey();
- TreeNode<Object> treeNode = (TreeNode<Object>)
tree.getRowData(treeRowKey);
- if (treeNode instanceof TreeAlbumItem) {
- TreeAlbumItem currentNode = (TreeAlbumItem) treeNode;
- boolean selected = currentNode.getAlbum() == getSelectedAlbum();
+ Object currentNode = tree.getRowData();
+ if (currentNode instanceof Album) {
+ boolean selected = currentNode == getSelectedAlbum();
return selected;
+ }else if(currentNode instanceof Shelf){
+ return currentNode == getSelectedShelf();
}
return null;
}
@@ -323,19 +322,16 @@
@SuppressWarnings("unchecked")
public void processSelection(NodeSelectedEvent event) {
HtmlTree tree = (HtmlTree) event.getComponent();
- TreeNode<Object> currentNode =
(TreeNode<Object>)tree.getModelTreeNode(tree.getRowKey());
- if(currentNode instanceof TreeAlbumItem){
+ 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);
- TreeAlbumItem node = (TreeAlbumItem)currentNode;
- Album album = node.getAlbum();
- setSelectedAlbum(album);
- setSelectedShelf(album.getParent());
- }else if(currentNode instanceof TreeShelfItem){
+ setSelectedAlbum((Album)currentNode);
+ setSelectedShelf(((Album)currentNode).getParent());
+ }else if(currentNode instanceof Shelf){
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.SHELF_PREVIEW);
- TreeShelfItem node = (TreeShelfItem)currentNode;
- Shelf shelf = node.getShelf();
setSelectedAlbum(null);
- setSelectedShelf(shelf);
+ setSelectedShelf((Shelf)currentNode);
}
setSelectedUser(user);
setSelectedImage(null);
Added: trunk/test-applications/realworld2/web/src/main/webapp/includes/anonimShelfs.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/anonimShelfs.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree2.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree2.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified: trunk/test-applications/realworld2/web/src/main/webapp/index.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/layout/menu.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/layout/panelBar-backup.xhtml
===================================================================
(Binary files differ)