[richfaces-svn-commits] JBoss Rich Faces SVN: r12390 - in trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld: ui and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Jan 23 08:33:50 EST 2009


Author: amarkhel
Date: 2009-01-23 08:33:50 -0500 (Fri, 23 Jan 2009)
New Revision: 12390

Added:
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/History.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/MetaInformationBinder.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RatingBinder.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java
Log:


Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java	2009-01-23 13:33:50 UTC (rev 12390)
@@ -0,0 +1,106 @@
+/**
+ * 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.ui;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Album;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.tree.TreeMyAlbumsItem;
+
+ at Name("conversationState")
+ at Scope(ScopeType.CONVERSATION)
+public class ConversationState implements Serializable{
+
+	private static final long serialVersionUID = 5656562187249324512L;
+	
+	private Integer selectedImageIndex = 1;
+	
+	private Image selectedImage;
+
+	private Album selectedAlbum;
+	
+	private User selectedUser;
+	
+	private User secondSelectedUser;
+
+	@In(required=false) private TreeMyAlbumsItem treeMyAlbumsItem;
+
+	public Integer getSelectedImageIndex() {
+		return selectedImageIndex;
+	}
+
+	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 String getSelectedAlbumName() {
+		if(null == selectedAlbum){
+			return "";
+		}
+		return selectedAlbum.getAlbumPathFromParents(selectedAlbum, new ArrayList<String>(), "/");
+	}
+
+	public void setSelectedAlbumName(String selectedAlbumName) {
+		selectedAlbumName = selectedAlbumName.substring(0, selectedAlbumName.length() -1);
+		int lastIndexOf = selectedAlbumName.lastIndexOf("/");
+		String prevPathEnd = selectedAlbumName.substring(lastIndexOf+1);
+		this.selectedAlbum = treeMyAlbumsItem.getAlbumByName(prevPathEnd).getAlbum();
+	}
+
+	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;
+	}
+}


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native

Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java	2009-01-23 13:33:50 UTC (rev 12390)
@@ -0,0 +1,36 @@
+package org.richfaces.realworld.ui;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+
+ at Name("editorBean")
+public class EditorBean {
+
+	private String currentConfiguration = "/org/richfaces/realworld/editor/advanced";
+	
+	private boolean liveUpdatesEnabled=false;
+	
+	private String message;
+	
+	public String getMessage() {
+		return message;
+	}
+
+	@Observer("clearEditor")
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public String getCurrentConfiguration() {
+		return currentConfiguration;
+	}
+
+	public boolean isLiveUpdatesEnabled() {
+		return liveUpdatesEnabled;
+	}
+
+	public void setLiveUpdatesEnabled(boolean liveUpdatesEnabled) {
+		this.liveUpdatesEnabled = liveUpdatesEnabled;
+	}	
+	
+}


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native

Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/History.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/History.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/History.java	2009-01-23 13:33:50 UTC (rev 12390)
@@ -0,0 +1,48 @@
+package org.richfaces.realworld.ui;
+
+import java.util.List;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Message;
+import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.service.IUserAction;
+
+ at Name("history")
+ at Scope(ScopeType.CONVERSATION)
+public class History {
+	
+	@In(create=true, required=true)
+	private IUserAction userAction;
+	
+	private User historyUser;
+	
+	private boolean selected;
+
+	public boolean isSelected() {
+		return selected;
+	}
+
+	public void setSelected(boolean selected) {
+		this.selected = selected;
+	}
+	
+	public void showHistory(User u){
+		this.setSelected(true);
+		this.setHistoryUser(u);
+	}
+
+	public List<Message> getHistory(){
+		return userAction.getHistory(this.getHistoryUser());
+	}
+	
+	public User getHistoryUser() {
+		return historyUser;
+	}
+
+	public void setHistoryUser(User historyUser) {
+		this.historyUser = historyUser;
+	}
+}


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/History.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native

Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/MetaInformationBinder.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/MetaInformationBinder.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/MetaInformationBinder.java	2009-01-23 13:33:50 UTC (rev 12390)
@@ -0,0 +1,89 @@
+/**
+ * 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.ui;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.UIRepeat;
+import org.jboss.seam.annotations.Name;
+import org.richfaces.component.html.HtmlInputText;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
+
+ at Name(value="metainfBinder")
+public class MetaInformationBinder {
+
+	HtmlInputText metaRef;
+    private UIRepeat repeater;
+    private Set<Integer> keys = null;
+    
+    public Set<Integer> getKeys() {
+        return keys;
+    }
+
+    public void setKeys(Set<Integer> keys) {
+        this.keys = keys;
+    }
+
+    public void setRepeater(UIRepeat repeater) {
+        this.repeater = repeater;
+    }
+
+    public UIRepeat getRepeater() {
+        return repeater;
+    }
+
+    public HtmlInputText getMetaRef() {
+        return metaRef;
+    }
+
+    public void setMetaRef(HtmlInputText metaRef) {
+        this.metaRef = metaRef;
+    }
+    
+    public String change(Image image){
+        Set<Integer> keys = new HashSet<Integer>();
+        int rowKey = getRepeater().getRowIndex();
+        keys.add(rowKey);
+        setKeys(keys);
+        metaRef.processValidators(FacesContext.getCurrentInstance());
+        metaRef.processUpdates(FacesContext.getCurrentInstance());
+        MetaTag metaTag = new MetaTag();
+		metaTag.setTag(metaRef.getValue().toString());
+		metaTag.setParent(image);
+        image.getMeta().add(metaTag);
+        return null;
+    }
+    
+    public void addTag(Image image){
+		MetaTag metaTag = new MetaTag();
+		metaTag.setTag("");
+		metaTag.setParent(image);
+		image.getMeta().add(metaTag);
+	}
+	
+	public void removeTag(MetaTag tag, Image image){
+		image.getMeta().remove(tag);
+	}
+}


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/MetaInformationBinder.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native

Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RatingBinder.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RatingBinder.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RatingBinder.java	2009-01-23 13:33:50 UTC (rev 12390)
@@ -0,0 +1,41 @@
+/**
+ * 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.ui;
+
+import java.io.Serializable;
+
+import org.jboss.seam.annotations.Name;
+import org.richfaces.component.UIInputNumberSlider;
+
+ at Name("ratingBinder")
+public class RatingBinder implements Serializable{
+
+	private static final long serialVersionUID = -7714638502390978362L;
+	private UIInputNumberSlider inputSlider;
+
+	public UIInputNumberSlider getInputSlider() {
+		return inputSlider;
+	}
+
+	public void setInputSlider(UIInputNumberSlider inputSlider) {
+		this.inputSlider = inputSlider;
+	}
+}


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RatingBinder.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native

Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java	2009-01-23 13:33:50 UTC (rev 12390)
@@ -0,0 +1,107 @@
+package org.richfaces.realworld.ui;
+
+import java.io.Serializable;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.security.Identity;
+import org.richfaces.realworld.domain.Album;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.User;
+
+ at Name("renderLogic")
+ at Scope(ScopeType.CONVERSATION)
+public class RenderLogic implements Serializable{
+
+	@In User user;
+	@In Identity identity;
+	@In ConversationState conversationState;
+	
+	private static final long serialVersionUID = 5656562187249324512L;
+	
+	public boolean shouldRenderFriendFolders(){
+		return conversationState.getSelectedUser() == null;
+	}
+	
+	public boolean shouldRenderFolders(){
+		return conversationState.getSelectedUser()!=null && conversationState.getSelectedImage() == null;
+	}
+	
+	public boolean shouldRenderImage(){
+		return conversationState.getSelectedUser()!=null && conversationState.getSelectedAlbum()!=null && conversationState.getSelectedImage() != null;
+	}
+	
+	public boolean shouldRenderImageList(){
+		return conversationState.getSelectedUser()!=null && conversationState.getSelectedAlbum()!=null;
+	}
+	
+	public boolean isCurrentUserProfileSelected(){
+		return user.equals(conversationState.getSelectedUser());
+	}
+	
+	public boolean isSecondUserProfileSelected(){
+		return conversationState.getSecondSelectedUser() != null;
+	}
+	
+	public boolean isUserAlbumSelected(){
+		return conversationState.getSelectedAlbum() != null && conversationState.getSelectedAlbum().getOwner().equals(user);
+	}
+	
+	public boolean isUserGuest(){
+		return identity.hasRole("guest");
+	}
+	
+	public boolean shouldRenderFileUpload(){
+		return conversationState.getSelectedAlbum()!=null && conversationState.getSelectedAlbum().getOwner().equals(user);
+	}
+	
+	public boolean isUserSelected(){
+		return user.equals(conversationState.getSelectedUser());
+	}
+	
+	public boolean isFriendSelected(){
+		return conversationState.getSelectedUser() == null || isUserFriend();
+	}
+	
+	public boolean isNotFriendSelected(){
+		return !isUserSelected() && !isUserFriend();
+	}
+	
+	public boolean isUserFriend(){
+		return user.getFriends() != null && user.getFriends().contains(conversationState.getSelectedUser());
+	}
+	
+	public boolean isUserFriend(User u){
+		return user.getFriends() != null && user.getFriends().contains(u);
+	}
+	
+	public boolean isAlbumSelected(){
+		return conversationState.getSelectedAlbum() != null;
+	}
+	
+	public boolean isImageSelected(){
+		return conversationState.getSelectedImage() != null;
+	}
+	
+	public boolean isAccessToAlbumGranted(Album album){
+		return album.getOwner().equals(user) || album.isShared() || isUserFriend(album.getOwner());
+	}
+	
+	public boolean isUserAlbum(Album album){
+		if(album == null){
+			return false;
+		}
+		return album.getOwner().equals(user);
+	}
+	
+	public boolean isFavoriteAlbum(Album album){
+		return user.getFavoriteAlbums().contains(album);
+	}
+	
+	public boolean isFavoriteImage(Image image){
+		return user.getFavoriteImages().contains(image);
+	}
+	
+}


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native




More information about the richfaces-svn-commits mailing list