JBoss Rich Faces SVN: r12925 - trunk/test-applications/realworld2/web/src/main/webapp/includes/image.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-03-11 12:42:51 -0400 (Wed, 11 Mar 2009)
New Revision: 12925
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/userImagePreviewBlock.xhtml
Log:
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/image/userImagePreviewBlock.xhtml
===================================================================
(Binary files differ)
15 years, 10 months
JBoss Rich Faces SVN: r12924 - in trunk/test-applications/realworld2: ejb/src/main/java/org/richfaces/realworld/service and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-03-11 12:37:33 -0400 (Wed, 11 Mar 2009)
New Revision: 12924
Removed:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/utils/
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/Noname/26/Thumbs.db
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/Viking/15/Thumbs.db
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/amarkhel/20/Thumbs.db
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/amarkhel/23/Thumbs.db
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/amarkhel/25/Thumbs.db
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByAlbumTemplate.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByImageTemplate.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/whatNew.xhtml
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/search.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/tagsResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
Log:
Modified: trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -24,15 +24,19 @@
private User user;
public List<Image> searchByAlbum(String searchQuery, boolean searchInMyAlbums, boolean searchInShared) {
- StringBuilder b = new StringBuilder("from Album a where a.name=:name and a.shelf.shared=:shared");
+ StringBuilder b = new StringBuilder("from Album a where lower(a.name) like :name or lower(a.description) like :name");
if (searchInMyAlbums) {
b.append(" and a.owner.login=:login");
}
+ if(searchInShared){
+ b.append(" and a.shelf.shared=:shared");
+ }
Query query = em.createQuery(b.toString());
- query.setParameter("name", searchQuery);
- query.setParameter("shared", searchInShared);
-
+ query.setParameter("name", "%" + searchQuery.toLowerCase() + "%");
+ if(searchInShared){
+ query.setParameter("shared", searchInShared);
+ }
if (searchInMyAlbums) {
query.setParameter("login", user.getLogin());
}
@@ -40,15 +44,21 @@
}
public List<Image> searchByImage(String searchQuery, boolean searchInMyAlbums, boolean searchInShared) {
- StringBuilder b = new StringBuilder("from Image i where i.name=:name and i.album.shelf.shared=:shared");
+ StringBuilder b = new StringBuilder("from Image i where lower(i.name) like :name or lower(i.description) like :name or lower(i.cameraModel) like :name");
if (searchInMyAlbums) {
b.append(" and i.album.owner.login=:login");
}
+ if(searchInShared){
+ b.append(" and i.album.shelf.shared=:shared");
+ }
Query query = em.createQuery(b.toString());
- query.setParameter("name", searchQuery);
- query.setParameter("shared", searchInShared);
+ query.setParameter("name", "%" + searchQuery.toLowerCase() + "%");
+ if(searchInShared){
+ query.setParameter("shared", searchInShared);
+ }
+
if (searchInMyAlbums) {
query.setParameter("login", user.getLogin());
}
@@ -56,22 +66,19 @@
}
public List<Image> searchByUsers(String searchQuery, boolean searchInMyAlbums, boolean searchInShared) {
- StringBuilder b = new StringBuilder("select distinct u from User u, Album a where u.login=:name");
- if (searchInShared) {
- b.append(" and a.owner=u and a.shelf.shared=true");
- }
+ StringBuilder b = new StringBuilder("select u from User u where lower(u.login) like :name or lower(u.firstName) like :name or lower(u.secondName) like :name");
Query query = em.createQuery(b.toString());
- query.setParameter("name", searchQuery);
+ query.setParameter("name", "%" + searchQuery.toLowerCase() + "%");
return query.getResultList();
}
public List<Image> searchByTags(String searchQuery, boolean searchInMyAlbums, boolean searchInShared) {
- StringBuilder b = new StringBuilder("from MetaTag t where t.tag=:name");
+ StringBuilder b = new StringBuilder("from MetaTag t where lower(t.tag) like :name");
Query query = em.createQuery(b.toString());
- query.setParameter("name", searchQuery);
+ query.setParameter("name", "%" + searchQuery.toLowerCase() + "%");
return query.getResultList();
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -36,6 +36,7 @@
import org.richfaces.component.UIDatascroller;
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.service.Constants;
@@ -161,6 +162,11 @@
model.setSelectedUser(user);
}
+ public void showTag(MetaTag metatag){
+ model.setMainArea(NavigationEnum.TAGS);
+ model.setSelectedTag(metatag);
+ }
+
private void updateDataScroller(Integer index, String dataScrollerId) {
UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
UIDatascroller scroller = (UIDatascroller)component.findComponent(dataScrollerId);
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -26,7 +26,6 @@
FILE_UPLOAD("includes/fileUpload.xhtml"),
USER_PREFS("includes/userPrefs.xhtml"),
SEARCH("includes/search.xhtml"),
- WHAT_NEW("includes/recent.xhtml"),
ALBUM_PREVIEW("includes/userAlbum.xhtml"),
ALBUM_IMAGE_PREVIEW("/includes/userImage.xhtml"),
SHELF_PREVIEW("/includes/userShelf.xhtml"),
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -10,6 +10,7 @@
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;
@@ -30,7 +31,7 @@
ISearchOption selectedOption;
List<ISearchOption> options;
-
+ private boolean searchSuccess;
String selectedTab;
String searchQuery;
@@ -50,6 +51,7 @@
public void search() {
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.SEARCH);
Iterator<ISearchOption> it = options.iterator();
+ setSearchSuccess(false);
while (it.hasNext()) {
ISearchOption option = it.next();
if (option.getSelected()) {
@@ -74,13 +76,9 @@
}
}
}
-
- public void back() {
- Iterator<ISearchOption> it = options.iterator();
- while (it.hasNext()) {
- it.next().setSelected(false);
- }
- selectedOption = null;
+ @Observer("searchSuccess")
+ public void setSearchSuccess(){
+ setSearchSuccess(true);
}
@Out
@@ -105,14 +103,6 @@
this.options = options;
}
- public String getSelectedTab() {
- return selectedTab;
- }
-
- public void setSelectedTab(String selectedTab) {
- this.selectedTab = selectedTab;
- }
-
public String getSearchQuery() {
return searchQuery;
}
@@ -136,5 +126,13 @@
public void setSearchInShared(boolean searchInShared) {
this.searchInShared = searchInShared;
}
+
+ public boolean isSearchSuccess() {
+ return searchSuccess;
+ }
+
+ public void setSearchSuccess(boolean searchSuccess) {
+ this.searchSuccess = searchSuccess;
+ }
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -1,8 +1,11 @@
package org.richfaces.realworld.search;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.ISearchAction;
@@ -23,7 +26,11 @@
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean searchInShared) {
- setSearchResult(action.searchByAlbum(q, searchInMyAlbums, searchInShared));
+ List<Image> searchByAlbum = action.searchByAlbum(q, searchInMyAlbums, searchInShared);
+ if(searchByAlbum.size() > 0){
+ Events.instance().raiseEvent("searchSuccess");
+ }
+ setSearchResult(searchByAlbum);
}
@Override
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -5,9 +5,12 @@
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.jboss.seam.annotations.In;
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.ISearchAction;
/**
@@ -32,7 +35,11 @@
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean searchInShared) {
- setSearchResult(action.searchByImage(q, searchInMyAlbums, searchInShared));
+ List<Image> searchByImage = action.searchByImage(q, searchInMyAlbums, searchInShared);
+ if(searchByImage.size() > 0){
+ Events.instance().raiseEvent("searchSuccess");
+ }
+ setSearchResult(searchByImage);
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -3,6 +3,10 @@
*/
package org.richfaces.realworld.search;
+import java.util.List;
+
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.ISearchAction;
/**
@@ -50,7 +54,11 @@
@Override
public void search(ISearchAction action, String searchQuery,
boolean searchInMyAlbums, boolean searchInShared) {
- setSearchResult(action.searchByTags(searchQuery, searchInMyAlbums, searchInShared));
+ List<Image> searchByTags = action.searchByTags(searchQuery, searchInMyAlbums, searchInShared);
+ if(searchByTags.size() > 0){
+ Events.instance().raiseEvent("searchSuccess");
+ }
+ setSearchResult(searchByTags);
}
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java 2009-03-11 16:37:33 UTC (rev 12924)
@@ -3,6 +3,10 @@
*/
package org.richfaces.realworld.search;
+import java.util.List;
+
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.ISearchAction;
/**
@@ -48,7 +52,11 @@
*/
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean searchInShared) {
- setSearchResult(action.searchByUsers(q, searchInMyAlbums, searchInShared));
+ List<Image> searchByUsers = action.searchByUsers(q, searchInMyAlbums, searchInShared);
+ if(searchByUsers.size() > 0){
+ Events.instance().raiseEvent("searchSuccess");
+ }
+ setSearchResult(searchByUsers);
}
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/Noname/26/Thumbs.db
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/Viking/15/Thumbs.db
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/amarkhel/20/Thumbs.db
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/amarkhel/23/Thumbs.db
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/Upload/amarkhel/25/Thumbs.db
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml 2009-03-11 16:37:33 UTC (rev 12924)
@@ -4,25 +4,40 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <rich:dataGrid id="album"
- value="#{result}"
- columns="5" style="width:500px;" var="album" border="0">
-
- <h:panelGrid id="grid" columns="1">
- <h:panelGroup id="group">
- <a4j:commandLink
- action="#{model.setMainArea(navigationHelper.navigationEnumImagePreview)}"
- actionListener="#{model.setSelectedAlbum(album)}"
- reRender="mainArea, tree">
- <h:graphicImage
- style="width:100px;height:100px" id="image" value="/img/folder.jpg" />
- </a4j:commandLink>
- </h:panelGroup>
- <a4j:commandLink
- action="#{model.setMainArea(navigationHelper.navigationEnumImagePreview)}"
- actionListener="#{model.setSelectedAlbum(album)}"
- reRender="mainArea, tree" value="#{album.name}">
- </a4j:commandLink>
- </h:panelGrid>
- </rich:dataGrid>
+ <a4j:repeat id="albumsList" value="#{result}" var="album" >
+ <h:panelGroup layout="block" styleClass="preview_box_album_120">
+ <h:graphicImage styleClass="pr_album_bg" value="/img/shell/frame_album_200.png" />
+ <h:panelGrid cellpadding="0">
+ <h:panelGroup>
+ <a4j:commandLink
+ rendered="#{controller.isAccessToAlbumGranted(album)}"
+ actionListener="#{controller.showAlbum(album)}"
+ reRender="mainArea, tree">
+ <a4j:mediaOutput rendered="#{!album.isEmpty()}" id="img" element="img"
+ createContent="#{imageLoader.paintImage}"
+ styleClass="album-cover-image"
+ style="#{richx:rectangle(album.lastImage.width, album.lastImage.height, 120)}"
+ value="#{fileManager.transformPath(album.lastImage.path, '_mini')}">
+ </a4j:mediaOutput>
+ <h:graphicImage rendered="#{album.isEmpty()}"
+ style="width:80px; height:80px;"
+ value="img/shell/frame_album_200.png"
+ styleClass="album-cover-image">
+ </h:graphicImage>
+ <rich:toolTip followMouse="true" direction="top-right"
+ showDelay="500" styleClass="tooltip">
+ <span style="white-space: nowrap"> #{album.name} </span>
+ </rich:toolTip>
+ </a4j:commandLink>
+ <br/>
+ </h:panelGroup>
+ </h:panelGrid>
+ <h:panelGroup layout="block" styleClass="album_name">#{album.name}</h:panelGroup>
+ <h:panelGroup layout="block" styleClass="album_data">
+ <h:outputText value="#{album.created}">
+ <f:convertDateTime />
+ </h:outputText>
+ </h:panelGroup>
+ </h:panelGroup>
+ </a4j:repeat>
</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-03-11 16:37:33 UTC (rev 12924)
@@ -4,33 +4,30 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- hhh
- <a4j:repeat id="previewList" value="#{result}" var="item">
- <table cellpadding="0" cellspacing="0" border="0" width="170" height="170" style="float: left; margin: 0px 10px 10px 0px;" >
- <tr>
- <td style="text-align: center;vertical-align: middle; background: white;border: 1px solid #909090">
+ <a4j:repeat value="#{result}" var="image">
+ <h:panelGroup layout="block" styleClass="preview_box_photo_120">
+ <h:graphicImage styleClass="pr_photo_bg" value="/img/shell/frame_photo_200.png" />
+ <h:panelGrid cellpadding="0">
+ <h:panelGroup>
<a4j:commandLink
- actionListener="#{controller.showImage(item)}"
- reRender="mainArea">
- <a4j:mediaOutput element="img" createContent="#{imageLoader.paintImage}"
- styleClass="all-images"
- value="#{fileManager.transformPath(item.path, '_mini')}">
- <rich:dragSupport rendered="#{controller.isUserAlbum(item.album)}"
- dragIndicator="dragIndicator" dragType="image" dragValue="#{item}"
- reRender=" mainArea">
- <rich:dndParam name="label" value="#{item.name}" />
- </rich:dragSupport>
- <ui:include src="/includes/contextMenu/CMForImage.xhtml" >
- <ui:param name="CMImage" value="#{item}" />
- </ui:include>
- <rich:toolTip followMouse="true" direction="top-right"
- showDelay="500" styleClass="tooltip">
- <span style="white-space: nowrap"> #{item.description} </span>
- </rich:toolTip>
- </a4j:mediaOutput>
+ actionListener="#{controller.showImage(image)}"
+ reRender="mainArea, tree">
+ <a4j:mediaOutput id="img" element="img"
+ createContent="#{imageLoader.paintImage}"
+ style="border : 2px solid #FFFFFF; #{richx:rectangle(image.width, image.height, imageSizeHelper.currentDimension.x)};"
+ value="#{fileManager.transformPath(image.path, imageSizeHelper.currentDimension.filePostfix)}">
+ <f:param value="#{imageSizeHelper.currentDimension.x}" name="x" />
+ </a4j:mediaOutput>
</a4j:commandLink>
- </td>
- </tr>
- </table>
+ <br/>
+ </h:panelGroup>
+ </h:panelGrid>
+ <h:panelGroup layout="block" styleClass="photo_name">#{image.name}</h:panelGroup>
+ <h:panelGroup layout="block" styleClass="photo_data">
+ <h:outputText value="#{image.created}">
+ <f:convertDateTime />
+ </h:outputText>
+ </h:panelGroup>
+ </h:panelGroup>
</a4j:repeat>
</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/tagsResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/tagsResult.xhtml 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/tagsResult.xhtml 2009-03-11 16:37:33 UTC (rev 12924)
@@ -4,7 +4,7 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <a4j:repeat id="previewList" value="#{result}" var="tag">
- <h:outputText value="#{tag.tag}"></h:outputText><br/>
+ <a4j:repeat id="tagList" value="#{result}" var="tag">
+ <a4j:commandLink reRender="mainArea" actionListener="#{controller.showTag(tag)}" value="#{tag.tag}"></a4j:commandLink><br/>
</a4j:repeat>
</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-03-11 16:37:33 UTC (rev 12924)
@@ -4,9 +4,10 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <a4j:repeat id="previewList" value="#{result}" var="user">
- <div>
- <img src="" width="50" height="50" /><h:outputText value="#{user.firstName}"></h:outputText>
- </div>
+ <a4j:repeat id="userList" value="#{result}" var="user">
+ <a4j:mediaOutput rendered="#{user.hasAvatar}" element="img" createContent="#{imageLoader.paintImage}"
+ styleClass="avatar"
+ value="/#{user.login}/avatar.jpg" />
+ <a4j:commandLink reRender="mainArea" actionListener="#{controller.showUser(user)}" value="#{user.login}"></a4j:commandLink><br/>
</a4j:repeat>
</ui:composition>
\ No newline at end of file
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByAlbumTemplate.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByAlbumTemplate.xhtml 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByAlbumTemplate.xhtml 2009-03-11 16:37:33 UTC (rev 12924)
@@ -1,20 +0,0 @@
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
-
- <h:panelGrid columns="2">
- <h:outputText value="Name"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['name']}" />
- <h:outputText value="Description"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['description']}"></h:inputText>
- <h:outputText value="Owner Name"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['owner.login']}" />
- <h:outputText value="Shared"></h:outputText>
- <h:selectBooleanCheckbox value="#{searchImageHelper.selectedOption.params['shared']}"></h:selectBooleanCheckbox>
- </h:panelGrid>
-
-
-</ui:composition>
\ No newline at end of file
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByImageTemplate.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByImageTemplate.xhtml 2009-03-11 15:23:52 UTC (rev 12923)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchByImageTemplate.xhtml 2009-03-11 16:37:33 UTC (rev 12924)
@@ -1,27 +0,0 @@
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
-
- <h:panelGrid columns="2">
- <h:outputText value="Name"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['name']}" />
- <h:outputText value="Description"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['description']}" />
- <h:outputText value="Path"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['path']}" />
- <h:outputText value="Size"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['size']}" converter="javax.faces.Integer" />
- <h:outputText value="Width"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['width']}" converter="javax.faces.Integer" />
- <h:outputText value="Height"></h:outputText>
- <h:inputText value="#{searchImageHelper.selectedOption.params['height']}" converter="javax.faces.Integer"/>
- <h:outputText value="Uploaded Date"></h:outputText>
- <rich:calendar value="#{searchImageHelper.selectedOption.params['uploaded']}" />
- <h:outputText value="Created Date"></h:outputText>
- <rich:calendar value="#{searchImageHelper.selectedOption.params['created']}" />
-
- </h:panelGrid>
-</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/includes/whatNew.xhtml
===================================================================
(Binary files differ)
15 years, 10 months
JBoss Rich Faces SVN: r12923 - trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2009-03-11 11:23:52 -0400 (Wed, 11 Mar 2009)
New Revision: 12923
Modified:
trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
Log:
https://jira.jboss.org/jira/browse/RF-6487
Modified: trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js
===================================================================
--- trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2009-03-11 14:24:18 UTC (rev 12922)
+++ trunk/ui/tooltip/src/main/resources/org/richfaces/renderkit/html/scripts/tooltip.js 2009-03-11 15:23:52 UTC (rev 12923)
@@ -250,6 +250,8 @@
this.toolTip.style.visibility = "hidden";
this.toolTip.style.display = 'block';
this.setToolTipPosition(e);
+ } else {
+ this.toolTipContent.innerHTML = "";
}
var event = A4J.AJAX.CloneObject(e, false);
var ajaxOptions = this.ajaxOptions;
15 years, 10 months
JBoss Rich Faces SVN: r12922 - in trunk/test-applications/realworld2/web/src/main: java/org/richfaces/realworld/listener and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-03-11 10:24:18 -0400 (Wed, 11 Mar 2009)
New Revision: 12922
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java
Removed:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/news/
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/listener/CopyImagesStuff.java
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/ui/TagList.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/contextMenu/CMForShelf.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/multyMode.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/login.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/register/regInfo.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefs.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/menu.xhtml
Log:
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -79,5 +79,4 @@
public void setFile(File file) {
this.file = file;
}
-
-}
+}
\ No newline at end of file
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -1,367 +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.fileupload;
-
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.Transparency;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageReader;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageInputStream;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.realworld.service.Constants;
-
-@Name("fileManager")
-(a)Scope(ScopeType.CONVERSATION)
-public class FileManager {
-
- private static final String _SMALL160 = "_small160";
- private static final String _SMALL120 = "_small120";
- private static final String _SMALL80 = "_small80";
- private static final String _MEDIUM = "_medium";
- private static final String _MINI = "_mini";
-
- private File uploadRoot;
- private String uploadRootPath;
-
- public File getUploadRoot() {
- return uploadRoot;
- }
-
- public void setUploadRoot(String uploadRootPath) throws IOException {
- if (uploadRootPath != null) {
- this.uploadRoot = new File(uploadRootPath);
- this.uploadRootPath = this.uploadRoot.getCanonicalPath()
- + File.separator;
- } else {
- this.uploadRoot = null;
- this.uploadRootPath = null;
- }
- }
-
- public FileManager() throws IOException {
- FacesContext fc = FacesContext.getCurrentInstance();
- if (fc != null) {
- // TODO nick - ask Andrei if we can throw exception here
- this.setUploadRoot(fc.getExternalContext().getInitParameter(
- Constants.UPLOAD_ROOT));
- }
- }
-
- private File getFileByPath(String path) {
- if (this.uploadRoot != null) {
- File result = new File(this.uploadRoot, path);
-
- try {
- String resultCanonicalPath = result.getCanonicalPath();
- if (!resultCanonicalPath.startsWith(this.uploadRootPath)) {
- // TODO log error
- result = null;
- }
-
- return result;
- } catch (IOException e) {
- // TODO: handle exception
- result = null;
- }
-
- return result;
- }
-
- return null;
- }
-
- public boolean isDirectoryPresent(String directory) {
- File file = getFileByPath(directory);
- return file.exists() && file.isDirectory();
- }
-
- public void deleteDirectory(String... directories) {
- String directory = new String();
- for (String chunk : directories) {
- directory += chunk + File.separator;
- }
- File file = getFileByPath(directory);
- if (file.exists()) {
- for (String f : file.list()) {
- File temp = new File(file, f);
- temp.delete();
- }
- file.delete();
- }
- }
-
- public boolean renameDirectory(String directoryOld, String directoryNew) {
- File fileOld = getFileByPath(directoryOld);
- File fileNew = getFileByPath(directoryNew);
-
- createDirectoryIfNotExist(directoryNew);
- if (fileNew.exists()) {
- if (fileNew.isDirectory()) {
- return false;
- } else {
- fileNew.delete();
- }
- }
- fileOld.renameTo(fileNew);
- return true;
- }
-
- public void addDirectory(String... directories) {
- String directory = new String();
- for (String chunk : directories) {
- directory += chunk;
- }
- File file = getFileByPath(directory);
- file.mkdirs();
- }
-
- public boolean addImage(String fileName, String tempFilePath) {
- createDirectoryIfNotExist(fileName);
- writeFile(fileName, tempFilePath, _SMALL80, 80, true);
- writeFile(fileName, tempFilePath, _SMALL120, 120, true);
- writeFile(fileName, tempFilePath, _SMALL160, 160, true);
- writeFile(fileName, tempFilePath, _MINI, 150, true);
- writeFile(fileName, tempFilePath, _MEDIUM, 600, true);
- return true;
- }
-
- public static BufferedImage bitmapToImage(String data, String format) throws IOException {
- InputStream inb = new FileInputStream(data);
- ImageReader rdr = (ImageReader) ImageIO.getImageReadersByFormatName(format).next();
- ImageInputStream imageInput = ImageIO.createImageInputStream(inb);
- rdr.setInput(imageInput);
- BufferedImage image = rdr.read(0);
- inb.close();
- return image;
- }
-
- public static void imageToBitmap(BufferedImage image, String data, String format) throws IOException {
- OutputStream inb = new FileOutputStream(data);
- ImageWriter wrt = (ImageWriter) ImageIO.getImageWritersByFormatName(format).next();
- ImageInputStream imageInput = ImageIO.createImageOutputStream(inb);
- wrt.setOutput(imageInput);
- wrt.write(image);
- inb.close();
- }
-
- /**
- * Convenience method that returns a scaled instance of the
- * provided {@code BufferedImage}.
- *
- * @param img the original image to be scaled
- * @param targetWidth the desired width of the scaled instance,
- * in pixels
- * @param targetHeight the desired height of the scaled instance,
- * in pixels
- * @param hint one of the rendering hints that corresponds to
- * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
- * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
- * @param higherQuality if true, this method will use a multi-step
- * scaling technique that provides higher quality than the usual
- * one-step technique (only useful in downscaling cases, where
- * {@code targetWidth} or {@code targetHeight} is
- * smaller than the original dimensions, and generally only when
- * the {@code BILINEAR} hint is specified)
- * @return a scaled version of the original {@code BufferedImage}
- */
- public static BufferedImage getScaledInstance(BufferedImage img,
- int targetWidth,
- int targetHeight,
- Object hint,
- boolean higherQuality)
- {
- int type = (img.getTransparency() == Transparency.OPAQUE) ?
- BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
- BufferedImage ret = (BufferedImage)img;
- int w, h;
- if (higherQuality) {
- // Use multi-step technique: start with original size, then
- // scale down in multiple passes with drawImage()
- // until the target size is reached
- w = img.getWidth();
- h = img.getHeight();
- } else {
- // Use one-step technique: scale directly from original
- // size to target size with a single drawImage() call
- w = targetWidth;
- h = targetHeight;
- }
-
- do {
- if (higherQuality && w > targetWidth) {
- w /= 2;
- if (w < targetWidth) {
- w = targetWidth;
- }
- }
-
- if (higherQuality && h > targetHeight) {
- h /= 2;
- if (h < targetHeight) {
- h = targetHeight;
- }
- }
-
- BufferedImage tmp = new BufferedImage(w, h, type);
- Graphics2D g2 = tmp.createGraphics();
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
- g2.drawImage(ret, 0, 0, w, h, null);
- g2.dispose();
-
- ret = tmp;
- } while (w != targetWidth || h != targetHeight);
-
- return ret;
- }
-
- public void writeFile(String newFileName, String fileName,String pattern, int size, boolean includeUploadRoot) {
- BufferedImage bsrc =null;
- try {
- bsrc = bitmapToImage(fileName, "JPG");
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- int i = bsrc.getWidth() > bsrc.getHeight()? bsrc.getWidth(): bsrc.getHeight();
- double d = (double) size
- / i;
- Double yy = ((Double)d*bsrc.getWidth());
- int width = yy.intValue();
- yy = ((Double)d*bsrc.getHeight());
- int height= yy.intValue();
- BufferedImage bdest = getScaledInstance(bsrc, width, height, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
- String dest = includeUploadRoot? this.uploadRootPath + transformPath(newFileName, pattern) : transformPath(newFileName, pattern);
- try {
- imageToBitmap(bdest, dest, "JPG");
- } catch (IOException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- }
-
- public String transformPath(String target, String substitute) {
- String begin = target.substring(0, target.lastIndexOf(Constants.DOT));
- String end = target.substring(target.lastIndexOf(Constants.DOT));
- return begin + substitute + end;
- }
-
- public String transformFileUploadPath(String target, String substitute) {
- String begin = target.substring(0, target.lastIndexOf(Constants.DOT));
- String end = target.substring(target.lastIndexOf(Constants.DOT));
- return begin + substitute + end ;
- }
-
- public void deleteImage(String fileName) {
- deleteImage(getFileByPath(fileName));
- deleteImage(getFileByPath(transformPath(fileName, _MINI)));
- deleteImage(getFileByPath(transformPath(fileName, _MEDIUM)));
- deleteImage(getFileByPath(transformPath(fileName, _SMALL80)));
- deleteImage(getFileByPath(transformPath(fileName, _SMALL120)));
- deleteImage(getFileByPath(transformPath(fileName, _SMALL160)));
- }
-
- private void deleteImage(File file) {
- if (file.exists()) {
- file.delete();
- }
- }
-
- public String getPathOfImage(String path) {
- int i = path.lastIndexOf(Constants.SLASH);
- return path.substring(i);
- }
-
- public void renameImage(String fileNameOld, String fileNameNew) {
- createDirectoryIfNotExist(fileNameNew);
- renameImage(getFileByPath(fileNameNew), getFileByPath(fileNameOld));
-
- renameImage(getFileByPath(transformPath(fileNameNew, _MINI)),
- getFileByPath(transformPath(fileNameOld, _MINI)));
-
- renameImage(getFileByPath(transformPath(fileNameNew, _MEDIUM)),
- getFileByPath(transformPath(fileNameOld, _MEDIUM)));
-
- renameImage(getFileByPath(transformPath(fileNameNew, _SMALL80)),
- getFileByPath(transformPath(fileNameOld, _SMALL80)));
-
- renameImage(getFileByPath(transformPath(fileNameNew, _SMALL120)),
- getFileByPath(transformPath(fileNameOld, _SMALL120)));
-
- renameImage(getFileByPath(transformPath(fileNameNew, _SMALL160)),
- getFileByPath(transformPath(fileNameOld, _SMALL160)));
- }
-
- private void renameImage(File fileNew, File fileOld) {
- if (fileNew.exists()) {
- fileNew.delete();
- }
- fileOld.renameTo(fileNew);
- }
-
- private void createDirectoryIfNotExist(String fileNameNew) {
- int lastIndexOf = fileNameNew.lastIndexOf("/");
- if (lastIndexOf > 0) {
- String directory = fileNameNew.substring(0, lastIndexOf);
- File file = getFileByPath(directory);
- if (!file.exists()) {
- file.mkdirs();
- }
- }
- }
-
- public boolean isImagePresent(String fileName) {
- return getFileByPath(fileName) != null && getFileByPath(fileName).exists() && !getFileByPath(fileName).isDirectory();
- }
-
- public File getImage(String fileName) {
- if (isImagePresent(fileName)) {
- return getFileByPath(fileName);
- }
- return null;
- }
-
- public File getDirectImage(String fileName) {
- return new File(fileName);
- }
-
- public void deleteDirectories(List<String> directoriesToDelete) {
- for (String directory : directoriesToDelete) {
- deleteDirectory(directory);
- }
- }
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -1,135 +0,0 @@
-package org.richfaces.realworld.fileupload;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-public class FileManagerTest extends TestCase {
-
- protected void setUp() throws Exception {
- fileManager=new FileManager();
- fileManager.setUploadRoot("C:/Upload/");
- }
-
- protected void tearDown() throws Exception {
- }
-
-private byte[] image = new byte[40];
- private FileManager fileManager;
- public void testIsDirectoryPresent() {
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- assertEquals(fileManager.isDirectoryPresent("amarkhel2"), false);
- fileManager.deleteDirectory("amarkhel");
- }
-
- public void testDeleteDirectory() {
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- fileManager.deleteDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
- }
-
- public void testRenameDirectory() throws Exception {
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- fileManager.renameDirectory("amarkhel", "amarkhel2");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
- assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
- fileManager.deleteDirectory("amarkhel2");
- }
-
- public void testRenameDirectory2(){
- fileManager.addDirectory("amarkhel");
- fileManager.addDirectory("amarkhel2");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- try {
- fileManager.renameDirectory("amarkhel", "amarkhel2");
- } catch (Exception e) {
- assertTrue(true);
- }
-
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
- fileManager.deleteDirectory("amarkhel");
- fileManager.deleteDirectory("amarkhel2");
- }
-
- public void testRenameDirectory3() throws Exception {
- fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), true);
- fileManager.renameDirectory("a"+System.getProperty("file.separator")+"amarkhel", "b"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), false);
- assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"amarkhel"), true);
- fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"amarkhel");
- }
-
- public void testRenameDirectory4() throws Exception {
- fileManager.addDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"), true);
- fileManager.renameDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel", "b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"), false);
- assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel"), true);
- fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
- }
-
- public void testAddDirectory() {
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- fileManager.deleteDirectory("amarkhel");
- }
-
- public void testAddDirectory2() {
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), false);
- fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), true);
- fileManager.deleteDirectory("a"+System.getProperty("file.separator")+"amarkhel");
- }
-
- /*public void testAddImage() throws IOException {
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- fileManager.deleteImage("amarkhel.gif");
- }
-
- public void testDeleteImage() throws IOException {
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- fileManager.deleteImage("amarkhel.gif");
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
- }
-
- public void testRenameImage() throws IOException {
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- fileManager.renameImage("amarkhel.gif", "amarkhel2.gif");
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
- assertEquals(fileManager.isImagePresent("amarkhel2.gif"), true);
- fileManager.deleteImage("amarkhel2.gif");
- }
-
- public void testRenameImage2() throws IOException {
- fileManager.addImage("a"+System.getProperty("file.separator")+"amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"), true);
- fileManager.renameImage("a"+System.getProperty("file.separator")+"amarkhel.gif", "b"+System.getProperty("file.separator")+"amarkhel2.gif");
- assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"), false);
- assertEquals(fileManager.isImagePresent("b"+System.getProperty("file.separator")+"amarkhel2.gif"), true);
- fileManager.deleteImage("b"+System.getProperty("file.separator")+"amarkhel2.gif");
- fileManager.deleteDirectory("b");
- fileManager.deleteDirectory("a");
- }
-
- public void testIsImagePresent() throws IOException {
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- assertEquals(fileManager.isImagePresent("amarkhel3.gif"), false);
- fileManager.deleteImage("amarkhel.gif");
- fileManager.addImage("am"+System.getProperty("file.separator")+"amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("am"+System.getProperty("file.separator")+"amarkhel.gif"), true);
- fileManager.deleteImage("am"+System.getProperty("file.separator")+"amarkhel.gif");
- fileManager.deleteDirectory("am");
- }*/
-
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -1,230 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.fileupload;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-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.Observer;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Events;
-import org.richfaces.event.UploadEvent;
-import org.richfaces.model.UploadItem;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.manager.NavigationEnum;
-import org.richfaces.realworld.service.Constants;
-
-import com.drew.imaging.jpeg.JpegMetadataReader;
-import com.drew.imaging.jpeg.JpegProcessingException;
-import com.drew.metadata.Directory;
-import com.drew.metadata.Metadata;
-import com.drew.metadata.MetadataException;
-import com.drew.metadata.exif.ExifDirectory;
-import com.drew.metadata.jpeg.JpegDirectory;
-
-/**
- * @author $Autor$
- *
- */
-@Name("fileUploadBean")
-(a)Scope(ScopeType.CONVERSATION)
-public class FileUploadBean implements Serializable {
-
- @In("#{messages['file_processing_error']}")
- private String FILE_PROCESSING_ERROR;
- @In("#{messages['file_saving_error']}")
- private String FILE_SAVE_ERROR;
- @In(create = true) @Out
- FileWrapper fileWrapper;
-
- @Out(required=false) FileItem file1;
- @Out(required=false) FileItem file2;
- @Out(required=false) FileItem file3;
-
- @In(create = true)
- private FileManager fileManager;
-
- @In("#{messages['samplename']}")
- private String SAMPLE_NAME;
-
- @In("#{messages['sampledesc']}")
- private String SAMPLE_DESCRIPTION;
-
- private static final long serialVersionUID = 4969087557225414955L;
-
- private boolean fileUploadRendered;
-
- public synchronized void listener(UploadEvent event) throws Exception {
- UploadItem item = event.getUploadItem();
- FileItem file = new FileItem();
- file.setLength(item.getFileSize());
- file.setFile(item.getFile());
- file.setSelected(false);
- file.setName(event.getUploadItem().getFileName());
- Image image = constructImage(item, file);
- fileManager.writeFile(file.getFile().getPath(), file.getFile().getPath(), "_mini", 100, false);
- try {
- extractMetadata(file, image);
- } catch (JpegProcessingException e1) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
- return;
- } catch (MetadataException me) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
- return;
- }
- file.setImage(image);
- fileWrapper.getFiles().add(file);
- file1 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-1);
- if(fileWrapper.getFiles().size()-2 >=0){
- file2 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-2);
- }
- if(fileWrapper.getFiles().size()-3 >=0){
- file3 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-3);
- }
- }
-
- @Observer(Constants.FILE_UPLOAD_CLEAR_EVENT)
- public void clearUploadData() {
- fileWrapper.getFiles().clear();
- }
-
- public void clearSelectedData() {
- for (int i = 0; i < fileWrapper.getFiles().size(); i++) {
- if (fileWrapper.getFiles().get(i).isSelected()) {
- fileWrapper.getFiles().remove(i);
- }
- }
- }
-
- public void storeSelectedData() {
- List<FileItem> temp = new ArrayList<FileItem>();
- for (FileItem file : fileWrapper.getFiles()) {
- if (file.isSelected()) {
- // Save file to disk
- String fileName = file.getFile().getPath();
- if(!fileManager.addImage(file.getName(), fileName)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_SAVE_ERROR));
- }
- // Update domain model
- Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
- } else {
- temp.add(file);
- }
- }
- fileWrapper.getFiles().clear();
- fileWrapper.getFiles().addAll(temp);
- }
-
- public void storeAll() {
- for (FileItem file : fileWrapper.getFiles()) {
- // Save file to disk
- String fileName = file.getFile()
- .getPath();
- if(!fileManager.addImage(file.getName(), fileName)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_SAVE_ERROR));
- }
- // Update domain model
- Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
- }
- fileWrapper.getFiles().clear();
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,NavigationEnum.IMAGE_PREVIEW);
- }
-
- public boolean isFileUploadRendered() {
- return fileUploadRendered;
- }
-
- public void setFileUploadRendered(boolean fileUploadRendered) {
- this.fileUploadRendered = fileUploadRendered;
- }
-
- @Observer(Constants.SHOW_FILE_UPLOAD_EVENT)
- public void showFileUpload(boolean result) {
- this.setFileUploadRendered(result);
- clearUploadData();
- }
-
-
- private Image constructImage(UploadItem item, FileItem file) {
- Image image = new Image();
- image.setUploaded(new Date());
- image.setDescription(SAMPLE_DESCRIPTION);
- image.setName(SAMPLE_NAME);
- image.setSize(file.getLength());
- return image;
- }
-
- private void extractMetadata(FileItem file, Image image)
- throws JpegProcessingException, MetadataException, FileNotFoundException {
- InputStream in = new FileInputStream(file.getFile());
- Metadata metadata = JpegMetadataReader.readMetadata(in);
- Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
- Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
- setupCameraModel(image, exifDirectory);
- setupDimensions(image, exifDirectory, jpgDirectory);
- setupCreatedDate(image, exifDirectory);
- }
-
- private void setupCreatedDate(Image image, Directory exifDirectory)
- throws MetadataException {
- if (exifDirectory.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)) {
- Date time = exifDirectory.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL);
- image.setCreated(time);
- }
- }
-
- private void setupDimensions(Image image, Directory exifDirectory,
- Directory jpgDirectory) throws MetadataException {
- if (exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_WIDTH) && exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
- int width = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_WIDTH);
- image.setWidth(width);
- int height = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT);
- image.setHeight(height);
- } else {
- if (jpgDirectory.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) {
- int width = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
- image.setWidth(width);
- int height = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
- image.setHeight(height);
- }
- }
- }
-
- private void setupCameraModel(Image image, Directory exifDirectory) {
- if (exifDirectory.containsTag(ExifDirectory.TAG_MODEL)) {
- String cameraModel = exifDirectory.getString(ExifDirectory.TAG_MODEL);
- image.setCameraModel(cameraModel);
- }else{
- image.setCameraModel("");
- }
- }
-}
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -24,7 +24,6 @@
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -37,6 +36,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Events;
+import org.richfaces.realworld.manager.FileManager;
import org.richfaces.realworld.service.Constants;
@Name("imageLoader")
@@ -49,52 +49,7 @@
FileManager fileManager;
@In("#{messages['file_processing_error']}")
private String FILE_PROCESSING_ERROR;
- @In(create=true)
- FileWrapper fileWrapper;
- public synchronized void paintImageFromByteArray(OutputStream stream, Object data) throws IOException {
- int index;
- if(data instanceof Integer){
- index = (Integer)data;
- }else{
- index = ((Long)data).intValue();
- }
- FileInputStream fileInputStream = new FileInputStream(fileWrapper.getFiles().get(index).getFile());
- int read = -1;
- byte [] bytes = new byte [4096];
- while ((read = fileInputStream.read(bytes)) != -1) {
- if (read == 0) {
- break;
- }
- stream.write(bytes);
- }
- // stream.write(fileWrapper.getFiles().get(index).getData());
- }
- public synchronized void paintSearchImage(OutputStream stream, Object object)
- throws IOException {
- File image = fileManager.getImage(object.toString());
- InputStream paintData = null;
- byte[] data = new byte[(int) image.length() - 1];
- FileInputStream fileInputStream = null;
- BufferedInputStream bufferedInputStream = null;
- if (image != null) {
- try {
- fileInputStream = new FileInputStream(image);
- bufferedInputStream = new BufferedInputStream(fileInputStream);
- paintData = bufferedInputStream;
- paintData.read(data);
- } catch (FileNotFoundException e) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
- return;
- } finally {
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
- stream.write(data);
- }
-
public synchronized void paintImage(OutputStream out, Object data) throws IOException{
if (null == data) {
return;
@@ -122,11 +77,11 @@
}
}
- public synchronized void paintImage2(OutputStream out, Object data) throws IOException{
+ public synchronized void paintImageFromFile(OutputStream out, Object data) throws IOException{
if (null == data) {
return;
}
- File imageResource = fileManager.getDirectImage(data.toString());
+ File imageResource = fileManager.getImageFile(data.toString());
if (imageResource != null) {
FileInputStream fileInputStream = new FileInputStream(imageResource);
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
@@ -148,27 +103,4 @@
}
}
}
-
- public synchronized void paintImageFromFile(OutputStream out, Object data) throws IOException{
- if (null == data || !(data instanceof File)) {
- return;
- }
- File file = (File) data;
-
- FileInputStream paintData = new FileInputStream(file);
- if (null == paintData) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
- return;
- }
- try {
- BufferedImage images = ImageIO.read(paintData);
- ImageIO.write(images, Constants.JPEG, out);
- } catch (Exception e) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
- return;
- } finally {
- paintData.close();
- }
-
- }
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/listener/CopyImagesStuff.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/listener/CopyImagesStuff.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/listener/CopyImagesStuff.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -5,15 +5,10 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.net.URL;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.web.LoggingFilter;
-
/**
* @author Andrey Markavtsov
*
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-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -31,7 +31,6 @@
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.service.Constants;
import org.richfaces.realworld.service.IAlbumAction;
@@ -42,21 +41,10 @@
private static final long serialVersionUID = 2631634926126857691L;
private String oncomplete = ";";
+
@In(create=true, required=true)
private IAlbumAction albumAction;
- private void setOncomplete() {
- oncomplete = "$('albumModalPanel').component.hide()";
- }
-
- public String getOncomplete() {
- return oncomplete;
- }
-
- public void setOncomplete(String oncomplete) {
- this.oncomplete = oncomplete;
- }
-
@In(create=true, required=true) @Out
private Album album;
@@ -71,7 +59,6 @@
public void addAlbum(Album album){
albumAction.addAlbum(album);
addDirectory();
- //Update conversation state
model.setSelectedImage(null);
model.setSelectedAlbum(album);
Events.instance().raiseEvent("albumAdded");
@@ -102,6 +89,18 @@
Events.instance().raiseEvent("clearTree");
}
+ private void setOncomplete() {
+ oncomplete = "$('albumModalPanel').component.hide()";
+ }
+
+ public String getOncomplete() {
+ return oncomplete;
+ }
+
+ public void setOncomplete(String oncomplete) {
+ this.oncomplete = oncomplete;
+ }
+
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-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -36,14 +36,12 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.core.Conversation;
-import org.jboss.seam.core.Events;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
import org.jboss.seam.web.Session;
import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.IUserAction;
import org.richfaces.realworld.ui.PasswordHolder;
import org.richfaces.realworld.service.Constants;
@@ -54,19 +52,16 @@
{
@In(create=true) ShelfManager shelfManager;
+
@In("#{messages['invalid_login']}")
private String INVALID_LOGIN_OR_PASSWORD;
- @In("#{messages['login_success']}")
- private String LOGIN_SUCCESS;
- @In(create=true) PasswordHolder passwordHolder;
- @In("#{messages['user.exist']}") private String USER_WITH_THIS_LOGIN_ALREADY_EXIST;
- @In("#{messages['user.confirm.error']}") private String CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD;
-
@RequestParameter protected Long startConversation;
private static final long serialVersionUID = -4585673256547342140L;
+ @In(create=true) PasswordHolder passwordHolder;
+
@Logger Log log;
@In Identity identity;
@@ -126,17 +121,6 @@
}
return false;
}
-
- @End
- public String register(User user){
- if(checkPassword(user) || checkUserExist(user)){
- return "";
- }
- user.setPasswordHash(passwordHolder.hash(user.getPassword()));
- userAction.register(user);
- facesMessages.add(LOGIN_SUCCESS);
- return "main";
- }
public String logout(){
identity.logout();
@@ -146,14 +130,6 @@
return "logout";
}
- public String goToRegister(){
- identity.logout();
- identity.unAuthenticate();
- credentials.clear();
- credentials.invalidate();
- return "register";
- }
-
public String loginAnonymous(){
credentials.setUsername(null);
credentials.setPassword(null);
@@ -189,29 +165,7 @@
private boolean wantLoginAnonymous() {
return null == credentials.getUsername() || credentials.getUsername().equals("");
}
-
- private boolean checkUserExist(User user) {
- if(userAction.isUserExist(user.getLogin())){
- UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
- UIComponent component = root.findComponent(Constants.REGISTER_LOGIN_NAME_ID);
- FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()), new FacesMessage(
- FacesMessage.SEVERITY_ERROR, USER_WITH_THIS_LOGIN_ALREADY_EXIST , USER_WITH_THIS_LOGIN_ALREADY_EXIST));
- return true;
- }
- return false;
- }
- private boolean checkPassword(User user) {
- if(!user.getPassword().equals(user.getConfirmPassword())){
- UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
- UIComponent component = root.findComponent(Constants.REGISTER_CONFIRM_PASSWORD_ID);
- FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()), new FacesMessage(
- FacesMessage.SEVERITY_ERROR, CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD , CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD));
- return true;
- }
- return false;
- }
-
public Long getStartConversation() {
return startConversation;
}
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-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -35,7 +35,6 @@
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileItem;
-import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IAlbumAction;
@@ -105,7 +104,7 @@
}
private void handleUploadedImage(FileItem dragValue, Album dropValue) {
- String newPath = getNewPathOfImage2(dragValue.getName(), dropValue);
+ String newPath = generateNewPath(dragValue.getName(), dropValue);
dragValue.getImage().setPath(newPath);
dropValue.addImage(dragValue.getImage());
albumAction.flush();
@@ -122,7 +121,7 @@
return fileNameNew;
}
- private String getNewPathOfImage2(String path, Album dropValue) {
+ private String generateNewPath(String path, Album dropValue) {
String fileNameNew = user.getLogin()+"/"+dropValue.getId()+"/"+path;
return fileNameNew;
}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java (from rev 12917, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -0,0 +1,361 @@
+/**
+ * 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.manager;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageInputStream;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.service.Constants;
+
+@Name("fileManager")
+(a)Scope(ScopeType.CONVERSATION)
+public class FileManager {
+
+ private static final String _SMALL160 = "_small160";
+ private static final String _SMALL120 = "_small120";
+ private static final String _SMALL80 = "_small80";
+ private static final String _MEDIUM = "_medium";
+ private static final String _MINI = "_mini";
+
+ private File uploadRoot;
+ private String uploadRootPath;
+
+ public File getUploadRoot() {
+ return uploadRoot;
+ }
+
+ public void setUploadRoot(String uploadRootPath) throws IOException {
+ if (uploadRootPath != null) {
+ this.uploadRoot = new File(uploadRootPath);
+ this.uploadRootPath = this.uploadRoot.getCanonicalPath()
+ + File.separator;
+ } else {
+ this.uploadRoot = null;
+ this.uploadRootPath = null;
+ }
+ }
+
+ public FileManager() throws IOException {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ if (fc != null) {
+ // TODO nick - ask Andrei if we can throw exception here
+ this.setUploadRoot(fc.getExternalContext().getInitParameter(
+ Constants.UPLOAD_ROOT));
+ }
+ }
+
+ private File getFileByPath(String path) {
+ if (this.uploadRoot != null) {
+ File result = new File(this.uploadRoot, path);
+
+ try {
+ String resultCanonicalPath = result.getCanonicalPath();
+ if (!resultCanonicalPath.startsWith(this.uploadRootPath)) {
+ // TODO log error
+ result = null;
+ }
+
+ return result;
+ } catch (IOException e) {
+ // TODO: handle exception
+ result = null;
+ }
+
+ return result;
+ }
+
+ return null;
+ }
+
+ public boolean isDirectoryPresent(String directory) {
+ File file = getFileByPath(directory);
+ return file.exists() && file.isDirectory();
+ }
+
+ public void deleteDirectory(String... directories) {
+ String directory = new String();
+ for (String chunk : directories) {
+ directory += chunk + File.separator;
+ }
+ File file = getFileByPath(directory);
+ if (file.exists()) {
+ for (String f : file.list()) {
+ File temp = new File(file, f);
+ temp.delete();
+ }
+ file.delete();
+ }
+ }
+
+ public boolean renameDirectory(String directoryOld, String directoryNew) {
+ File fileOld = getFileByPath(directoryOld);
+ File fileNew = getFileByPath(directoryNew);
+
+ createDirectoryIfNotExist(directoryNew);
+ if (fileNew.exists()) {
+ if (fileNew.isDirectory()) {
+ return false;
+ } else {
+ fileNew.delete();
+ }
+ }
+ fileOld.renameTo(fileNew);
+ return true;
+ }
+
+ public void addDirectory(String... directories) {
+ String directory = new String();
+ for (String chunk : directories) {
+ directory += chunk;
+ }
+ File file = getFileByPath(directory);
+ file.mkdirs();
+ }
+
+ public boolean addImage(String fileName, String tempFilePath) {
+ createDirectoryIfNotExist(fileName);
+ writeFile(fileName, tempFilePath, _SMALL80, 80, true);
+ writeFile(fileName, tempFilePath, _SMALL120, 120, true);
+ writeFile(fileName, tempFilePath, _SMALL160, 160, true);
+ writeFile(fileName, tempFilePath, _MINI, 150, true);
+ writeFile(fileName, tempFilePath, _MEDIUM, 600, true);
+ return true;
+ }
+
+ public static BufferedImage bitmapToImage(String data, String format) throws IOException {
+ InputStream inb = new FileInputStream(data);
+ ImageReader rdr = (ImageReader) ImageIO.getImageReadersByFormatName(format).next();
+ ImageInputStream imageInput = ImageIO.createImageInputStream(inb);
+ rdr.setInput(imageInput);
+ BufferedImage image = rdr.read(0);
+ inb.close();
+ return image;
+ }
+
+ public static void imageToBitmap(BufferedImage image, String data, String format) throws IOException {
+ OutputStream inb = new FileOutputStream(data);
+ ImageWriter wrt = (ImageWriter) ImageIO.getImageWritersByFormatName(format).next();
+ ImageInputStream imageInput = ImageIO.createImageOutputStream(inb);
+ wrt.setOutput(imageInput);
+ wrt.write(image);
+ inb.close();
+ }
+
+ /**
+ * Convenience method that returns a scaled instance of the
+ * provided {@code BufferedImage}.
+ *
+ * @param img the original image to be scaled
+ * @param targetWidth the desired width of the scaled instance,
+ * in pixels
+ * @param targetHeight the desired height of the scaled instance,
+ * in pixels
+ * @param hint one of the rendering hints that corresponds to
+ * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
+ * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
+ * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
+ * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
+ * @param higherQuality if true, this method will use a multi-step
+ * scaling technique that provides higher quality than the usual
+ * one-step technique (only useful in downscaling cases, where
+ * {@code targetWidth} or {@code targetHeight} is
+ * smaller than the original dimensions, and generally only when
+ * the {@code BILINEAR} hint is specified)
+ * @return a scaled version of the original {@code BufferedImage}
+ */
+ public static BufferedImage getScaledInstance(BufferedImage img,
+ int targetWidth,
+ int targetHeight,
+ Object hint,
+ boolean higherQuality)
+ {
+ int type = (img.getTransparency() == Transparency.OPAQUE) ?
+ BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
+ BufferedImage ret = (BufferedImage)img;
+ int w, h;
+ if (higherQuality) {
+ // Use multi-step technique: start with original size, then
+ // scale down in multiple passes with drawImage()
+ // until the target size is reached
+ w = img.getWidth();
+ h = img.getHeight();
+ } else {
+ // Use one-step technique: scale directly from original
+ // size to target size with a single drawImage() call
+ w = targetWidth;
+ h = targetHeight;
+ }
+
+ do {
+ if (higherQuality && w > targetWidth) {
+ w /= 2;
+ if (w < targetWidth) {
+ w = targetWidth;
+ }
+ }
+
+ if (higherQuality && h > targetHeight) {
+ h /= 2;
+ if (h < targetHeight) {
+ h = targetHeight;
+ }
+ }
+
+ BufferedImage tmp = new BufferedImage(w, h, type);
+ Graphics2D g2 = tmp.createGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
+ g2.drawImage(ret, 0, 0, w, h, null);
+ g2.dispose();
+
+ ret = tmp;
+ } while (w != targetWidth || h != targetHeight);
+
+ return ret;
+ }
+
+ public void writeFile(String newFileName, String fileName,String pattern, int size, boolean includeUploadRoot) {
+ BufferedImage bsrc =null;
+ try {
+ bsrc = bitmapToImage(fileName, "JPG");
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ int i = bsrc.getWidth() > bsrc.getHeight()? bsrc.getWidth(): bsrc.getHeight();
+ double d = (double) size
+ / i;
+ Double yy = ((Double)d*bsrc.getWidth());
+ int width = yy.intValue();
+ yy = ((Double)d*bsrc.getHeight());
+ int height= yy.intValue();
+ BufferedImage bdest = getScaledInstance(bsrc, width, height, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
+ String dest = includeUploadRoot? this.uploadRootPath + transformPath(newFileName, pattern) : transformPath(newFileName, pattern);
+ try {
+ imageToBitmap(bdest, dest, "JPG");
+ } catch (IOException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ }
+
+ public String transformPath(String target, String substitute) {
+ String begin = target.substring(0, target.lastIndexOf(Constants.DOT));
+ String end = target.substring(target.lastIndexOf(Constants.DOT));
+ return begin + substitute + end;
+ }
+
+ public void deleteImage(String fileName) {
+ deleteImage(getFileByPath(fileName));
+ deleteImage(getFileByPath(transformPath(fileName, _MINI)));
+ deleteImage(getFileByPath(transformPath(fileName, _MEDIUM)));
+ deleteImage(getFileByPath(transformPath(fileName, _SMALL80)));
+ deleteImage(getFileByPath(transformPath(fileName, _SMALL120)));
+ deleteImage(getFileByPath(transformPath(fileName, _SMALL160)));
+ }
+
+ private void deleteImage(File file) {
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+
+ public String getPathOfImage(String path) {
+ int i = path.lastIndexOf(Constants.SLASH);
+ return path.substring(i);
+ }
+
+ public void renameImage(String fileNameOld, String fileNameNew) {
+ createDirectoryIfNotExist(fileNameNew);
+ renameImage(getFileByPath(fileNameNew), getFileByPath(fileNameOld));
+
+ renameImage(getFileByPath(transformPath(fileNameNew, _MINI)),
+ getFileByPath(transformPath(fileNameOld, _MINI)));
+
+ renameImage(getFileByPath(transformPath(fileNameNew, _MEDIUM)),
+ getFileByPath(transformPath(fileNameOld, _MEDIUM)));
+
+ renameImage(getFileByPath(transformPath(fileNameNew, _SMALL80)),
+ getFileByPath(transformPath(fileNameOld, _SMALL80)));
+
+ renameImage(getFileByPath(transformPath(fileNameNew, _SMALL120)),
+ getFileByPath(transformPath(fileNameOld, _SMALL120)));
+
+ renameImage(getFileByPath(transformPath(fileNameNew, _SMALL160)),
+ getFileByPath(transformPath(fileNameOld, _SMALL160)));
+ }
+
+ private void renameImage(File fileNew, File fileOld) {
+ if (fileNew.exists()) {
+ fileNew.delete();
+ }
+ fileOld.renameTo(fileNew);
+ }
+
+ private void createDirectoryIfNotExist(String fileNameNew) {
+ int lastIndexOf = fileNameNew.lastIndexOf("/");
+ if (lastIndexOf > 0) {
+ String directory = fileNameNew.substring(0, lastIndexOf);
+ File file = getFileByPath(directory);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ }
+ }
+
+ public boolean isImagePresent(String fileName) {
+ return getFileByPath(fileName) != null && getFileByPath(fileName).exists() && !getFileByPath(fileName).isDirectory();
+ }
+
+ public File getImage(String fileName) {
+ if (isImagePresent(fileName)) {
+ return getFileByPath(fileName);
+ }
+ return null;
+ }
+
+ public File getImageFile(String fileName) {
+ return new File(fileName);
+ }
+
+ public void deleteDirectories(List<String> directoriesToDelete) {
+ for (String directory : directoriesToDelete) {
+ deleteDirectory(directory);
+ }
+ }
+}
Added: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -0,0 +1,77 @@
+package org.richfaces.realworld.manager;
+
+import java.util.ArrayList;
+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.Observer;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.fileupload.FileItem;
+import org.richfaces.realworld.fileupload.FileWrapper;
+import org.richfaces.realworld.service.Constants;
+
+@Name("fileUploadManager")
+(a)Scope(ScopeType.CONVERSATION)
+public class FileUploadManager {
+
+ @In("#{messages['file_saving_error']}")
+ private String FILE_SAVE_ERROR;
+
+ @Out(required=false) FileItem file1;
+ @Out(required=false) FileItem file2;
+ @Out(required=false) FileItem file3;
+
+ @In(create = true)
+ private FileManager fileManager;
+
+ @In(create = true) @Out
+ FileWrapper fileWrapper;
+
+ @Observer(Constants.FILE_UPLOAD_CLEAR_EVENT)
+ public void clearUploadData() {
+ fileWrapper.getFiles().clear();
+ }
+
+ public void clearSelectedData() {
+ for (int i = 0; i < fileWrapper.getFiles().size(); i++) {
+ if (fileWrapper.getFiles().get(i).isSelected()) {
+ fileWrapper.getFiles().remove(i);
+ }
+ }
+ }
+
+ public void storeSelectedData() {
+ List<FileItem> temp = new ArrayList<FileItem>();
+ for (FileItem file : fileWrapper.getFiles()) {
+ if (file.isSelected()) {
+ // Save file to disk
+ String fileName = file.getFile().getPath();
+ if(!fileManager.addImage(file.getName(), fileName)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_SAVE_ERROR));
+ }
+ Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
+ } else {
+ temp.add(file);
+ }
+ }
+ fileWrapper.getFiles().clear();
+ fileWrapper.getFiles().addAll(temp);
+ }
+
+ public void storeAll() {
+ for (FileItem file : fileWrapper.getFiles()) {
+ // Save file to disk
+ String fileName = file.getFile().getPath();
+ if(!fileManager.addImage(file.getName(), fileName)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_SAVE_ERROR));
+ }
+ Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
+ }
+ fileWrapper.getFiles().clear();
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,NavigationEnum.IMAGE_PREVIEW);
+ }
+}
Property changes on: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
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-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -32,7 +32,6 @@
import org.richfaces.realworld.domain.Comment;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IImageAction;
import org.richfaces.realworld.util.DirectLinkHelper;
Added: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -0,0 +1,86 @@
+package org.richfaces.realworld.manager;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.Credentials;
+import org.jboss.seam.security.Identity;
+import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.service.IUserAction;
+import org.richfaces.realworld.ui.PasswordHolder;
+
+@Name("registerManager")
+(a)Scope(ScopeType.CONVERSATION)
+public class RegistrationManager {
+
+ @In("#{messages['login_success']}")
+ private String LOGIN_SUCCESS;
+
+ @In("#{messages['user.exist']}") private String USER_WITH_THIS_LOGIN_ALREADY_EXIST;
+
+ @In("#{messages['user.confirm.error']}") private String CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD;
+
+ @Logger Log log;
+
+ @In Identity identity;
+
+ @In Credentials credentials;
+
+ @In FacesMessages facesMessages;
+
+ @In(create=true) PasswordHolder passwordHolder;
+
+ @In(create = true)
+ IUserAction userAction;
+
+ @End
+ public String register(User user){
+ if(checkPassword(user) || checkUserExist(user)){
+ return "";
+ }
+ user.setPasswordHash(passwordHolder.hash(user.getPassword()));
+ userAction.register(user);
+ facesMessages.add(LOGIN_SUCCESS);
+ return "main";
+ }
+
+ public String goToRegister(){
+ identity.logout();
+ identity.unAuthenticate();
+ credentials.clear();
+ credentials.invalidate();
+ return "register";
+ }
+
+ private boolean checkUserExist(User user) {
+ if(userAction.isUserExist(user.getLogin())){
+ UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
+ UIComponent component = root.findComponent(Constants.REGISTER_LOGIN_NAME_ID);
+ FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()), new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, USER_WITH_THIS_LOGIN_ALREADY_EXIST , USER_WITH_THIS_LOGIN_ALREADY_EXIST));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean checkPassword(User user) {
+ if(!user.getPassword().equals(user.getConfirmPassword())){
+ UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
+ UIComponent component = root.findComponent(Constants.REGISTER_CONFIRM_PASSWORD_ID);
+ FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()), new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD , CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD));
+ return true;
+ }
+ return false;
+ }
+}
Property changes on: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
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-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -34,7 +34,6 @@
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.service.Constants;
import org.richfaces.realworld.service.IShelfAction;
@@ -49,25 +48,9 @@
@In(create=true, required=true)
private IShelfAction shelfAction;
private String oncomplete = ";";
- private void setOncomplete() {
- oncomplete = "$('shelfModalPanel').component.hide()";
- }
- public String getOncomplete() {
- return oncomplete;
- }
-
- public void initEdit(){
- shelf = new Shelf();
- }
-
- public void setOncomplete(String oncomplete) {
- this.oncomplete = oncomplete;
- }
-
- @In(create=true, required=true) @Out
- private Shelf shelf;
@In @Out Model model;
+
@In
private User user;
@@ -116,4 +99,16 @@
public void clearShelfs(){
shelfs = null;
}
+
+ private void setOncomplete() {
+ oncomplete = "$('shelfModalPanel').component.hide()";
+ }
+
+ public String getOncomplete() {
+ return oncomplete;
+ }
+
+ public void setOncomplete(String oncomplete) {
+ this.oncomplete = oncomplete;
+ }
}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java (from rev 12917, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -0,0 +1,167 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Date;
+
+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.jboss.seam.core.Events;
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.fileupload.FileItem;
+import org.richfaces.realworld.fileupload.FileWrapper;
+import org.richfaces.realworld.manager.FileManager;
+import org.richfaces.realworld.service.Constants;
+
+import com.drew.imaging.jpeg.JpegMetadataReader;
+import com.drew.imaging.jpeg.JpegProcessingException;
+import com.drew.metadata.Directory;
+import com.drew.metadata.Metadata;
+import com.drew.metadata.MetadataException;
+import com.drew.metadata.exif.ExifDirectory;
+import com.drew.metadata.jpeg.JpegDirectory;
+
+/**
+ * @author $Autor$
+ *
+ */
+@Name("fileUploadBean")
+(a)Scope(ScopeType.CONVERSATION)
+public class FileUploadBean implements Serializable {
+
+ @In("#{messages['file_processing_error']}")
+ private String FILE_PROCESSING_ERROR;
+
+ @In(create = true) @Out
+ FileWrapper fileWrapper;
+
+ @Out(required=false) FileItem file1;
+ @Out(required=false) FileItem file2;
+ @Out(required=false) FileItem file3;
+
+ @In(create = true)
+ private FileManager fileManager;
+
+ @In("#{messages['samplename']}")
+ private String SAMPLE_NAME;
+
+ @In("#{messages['sampledesc']}")
+ private String SAMPLE_DESCRIPTION;
+
+ private static final long serialVersionUID = 4969087557225414955L;
+
+ public synchronized void listener(UploadEvent event) throws Exception {
+ UploadItem item = event.getUploadItem();
+ FileItem file = new FileItem();
+ file.setLength(item.getFileSize());
+ file.setFile(item.getFile());
+ file.setSelected(false);
+ file.setName(event.getUploadItem().getFileName());
+ Image image = constructImage(item, file);
+ fileManager.writeFile(file.getFile().getPath(), file.getFile().getPath(), "_mini", 100, false);
+ try {
+ extractMetadata(file, image);
+ } catch (JpegProcessingException e1) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
+ return;
+ } catch (MetadataException me) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(FILE_PROCESSING_ERROR));
+ return;
+ }
+ file.setImage(image);
+ fileWrapper.getFiles().add(file);
+ outJectLastThreeImages();
+ }
+
+ private void outJectLastThreeImages() {
+ file1 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-1);
+ if(fileWrapper.getFiles().size()-2 >=0){
+ file2 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-2);
+ }
+ if(fileWrapper.getFiles().size()-3 >=0){
+ file3 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-3);
+ }
+ }
+
+ private Image constructImage(UploadItem item, FileItem file) {
+ Image image = new Image();
+ image.setUploaded(new Date());
+ image.setDescription(SAMPLE_DESCRIPTION);
+ image.setName(SAMPLE_NAME);
+ image.setSize(file.getLength());
+ return image;
+ }
+
+ private void extractMetadata(FileItem file, Image image)
+ throws JpegProcessingException, MetadataException, FileNotFoundException {
+ InputStream in = new FileInputStream(file.getFile());
+ Metadata metadata = JpegMetadataReader.readMetadata(in);
+ Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
+ Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
+ setupCameraModel(image, exifDirectory);
+ setupDimensions(image, exifDirectory, jpgDirectory);
+ setupCreatedDate(image, exifDirectory);
+ }
+
+ private void setupCreatedDate(Image image, Directory exifDirectory)
+ throws MetadataException {
+ if (exifDirectory.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)) {
+ Date time = exifDirectory.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL);
+ image.setCreated(time);
+ }
+ }
+
+ private void setupDimensions(Image image, Directory exifDirectory,
+ Directory jpgDirectory) throws MetadataException {
+ if (exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_WIDTH) && exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
+ int width = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_WIDTH);
+ image.setWidth(width);
+ int height = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT);
+ image.setHeight(height);
+ } else {
+ if (jpgDirectory.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) {
+ int width = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
+ image.setWidth(width);
+ int height = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
+ image.setHeight(height);
+ }
+ }
+ }
+
+ private void setupCameraModel(Image image, Directory exifDirectory) {
+ if (exifDirectory.containsTag(ExifDirectory.TAG_MODEL)) {
+ String cameraModel = exifDirectory.getString(ExifDirectory.TAG_MODEL);
+ image.setCameraModel(cameraModel);
+ }else{
+ image.setCameraModel("");
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagList.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagList.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagList.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -58,19 +58,4 @@
public void ImageDeleted(){
fetchTags();
}
-
- @Observer(value = "albumEdited", create = false)
- public void AlbumEdited(){
- fetchTags();
- }
-
- @Observer(value = "albumDeleted", create = false)
- public void AlbumDeleted(){
- fetchTags();
- }
-
- @Observer(value = "albumAdded", create = false)
- public void AlbumAdded(){
- fetchTags();
- }
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -19,7 +19,7 @@
import org.richfaces.model.UploadItem;
import org.richfaces.realworld.domain.Sex;
import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.manager.FileManager;
import org.richfaces.realworld.manager.Model;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IUserAction;
@@ -58,8 +58,7 @@
avatarData = item.getFile();
}
- public void saveUser(){
- User user = model.getSelectedUser();
+ public void saveUser(User user){
if (avatarData != null) {
try {
BufferedImage image = fileManager.bitmapToImage(avatarData.getPath(),"JPG" );
@@ -75,12 +74,6 @@
userAction.updateUser(user);
}
- public void registerUser() {
- if (user != null) {
- userAction.register(user);
- }
- }
-
public void cancel() {
avatarData = null;
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -21,7 +21,7 @@
import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.manager.FileManager;
import org.richfaces.realworld.service.Constants;
@Name("directLink")
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java (from rev 12917, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManagerTest.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -0,0 +1,137 @@
+package org.richfaces.realworld.util;
+
+import java.io.IOException;
+
+import org.richfaces.realworld.manager.FileManager;
+
+import junit.framework.TestCase;
+
+public class FileManagerTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ fileManager=new FileManager();
+ fileManager.setUploadRoot("C:/Upload/");
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+private byte[] image = new byte[40];
+ private FileManager fileManager;
+ public void testIsDirectoryPresent() {
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ assertEquals(fileManager.isDirectoryPresent("amarkhel2"), false);
+ fileManager.deleteDirectory("amarkhel");
+ }
+
+ public void testDeleteDirectory() {
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ fileManager.deleteDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
+ }
+
+ public void testRenameDirectory() throws Exception {
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ fileManager.renameDirectory("amarkhel", "amarkhel2");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
+ assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
+ fileManager.deleteDirectory("amarkhel2");
+ }
+
+ public void testRenameDirectory2(){
+ fileManager.addDirectory("amarkhel");
+ fileManager.addDirectory("amarkhel2");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ try {
+ fileManager.renameDirectory("amarkhel", "amarkhel2");
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
+ fileManager.deleteDirectory("amarkhel");
+ fileManager.deleteDirectory("amarkhel2");
+ }
+
+ public void testRenameDirectory3() throws Exception {
+ fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), true);
+ fileManager.renameDirectory("a"+System.getProperty("file.separator")+"amarkhel", "b"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), false);
+ assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"amarkhel"), true);
+ fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"amarkhel");
+ }
+
+ public void testRenameDirectory4() throws Exception {
+ fileManager.addDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"), true);
+ fileManager.renameDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel", "b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"), false);
+ assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel"), true);
+ fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
+ }
+
+ public void testAddDirectory() {
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
+ fileManager.addDirectory("amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
+ fileManager.deleteDirectory("amarkhel");
+ }
+
+ public void testAddDirectory2() {
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), false);
+ fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
+ assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"), true);
+ fileManager.deleteDirectory("a"+System.getProperty("file.separator")+"amarkhel");
+ }
+
+ /*public void testAddImage() throws IOException {
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ fileManager.deleteImage("amarkhel.gif");
+ }
+
+ public void testDeleteImage() throws IOException {
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ fileManager.deleteImage("amarkhel.gif");
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
+ }
+
+ public void testRenameImage() throws IOException {
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ fileManager.renameImage("amarkhel.gif", "amarkhel2.gif");
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
+ assertEquals(fileManager.isImagePresent("amarkhel2.gif"), true);
+ fileManager.deleteImage("amarkhel2.gif");
+ }
+
+ public void testRenameImage2() throws IOException {
+ fileManager.addImage("a"+System.getProperty("file.separator")+"amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"), true);
+ fileManager.renameImage("a"+System.getProperty("file.separator")+"amarkhel.gif", "b"+System.getProperty("file.separator")+"amarkhel2.gif");
+ assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"), false);
+ assertEquals(fileManager.isImagePresent("b"+System.getProperty("file.separator")+"amarkhel2.gif"), true);
+ fileManager.deleteImage("b"+System.getProperty("file.separator")+"amarkhel2.gif");
+ fileManager.deleteDirectory("b");
+ fileManager.deleteDirectory("a");
+ }
+
+ public void testIsImagePresent() throws IOException {
+ fileManager.addImage("amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
+ assertEquals(fileManager.isImagePresent("amarkhel3.gif"), false);
+ fileManager.deleteImage("amarkhel.gif");
+ fileManager.addImage("am"+System.getProperty("file.separator")+"amarkhel.gif", image);
+ assertEquals(fileManager.isImagePresent("am"+System.getProperty("file.separator")+"amarkhel.gif"), true);
+ fileManager.deleteImage("am"+System.getProperty("file.separator")+"amarkhel.gif");
+ fileManager.deleteDirectory("am");
+ }*/
+
+}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -45,7 +45,6 @@
e1.printStackTrace();
}
int i = bsrc.getWidth() > bsrc.getHeight()? bsrc.getWidth(): bsrc.getHeight();
- int width2 = bsrc.getWidth();
double d = (double) size
/ i;
Double yy = ((Double)d*bsrc.getWidth());
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java 2009-03-11 13:49:58 UTC (rev 12921)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java 2009-03-11 14:24:18 UTC (rev 12922)
@@ -1,113 +0,0 @@
-package org.richfaces.realworld.util;
-
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.Transparency;
-import java.awt.image.BufferedImage;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-import javax.imageio.ImageReader;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageInputStream;
-public class test2 {
- public static BufferedImage bitmapToImage(String data, String format) throws IOException {
- InputStream inb = new FileInputStream(data);
- ImageReader rdr = (ImageReader) ImageIO.getImageReadersByFormatName(format).next();
- ImageInputStream imageInput = ImageIO.createImageInputStream(inb);
- rdr.setInput(imageInput);
- BufferedImage image = rdr.read(0);
- inb.close();
- return image;
- }
-
- public static void imageToBitmap(BufferedImage image, String data, String format) throws IOException {
- OutputStream inb = new FileOutputStream(data);
- ImageWriter wrt = (ImageWriter) ImageIO.getImageWritersByFormatName(format).next();
- ImageInputStream imageInput = ImageIO.createImageOutputStream(inb);
- wrt.setOutput(imageInput);
- wrt.write(image);
- inb.close();
- }
-
- /**
- * Convenience method that returns a scaled instance of the
- * provided {@code BufferedImage}.
- *
- * @param img the original image to be scaled
- * @param targetWidth the desired width of the scaled instance,
- * in pixels
- * @param targetHeight the desired height of the scaled instance,
- * in pixels
- * @param hint one of the rendering hints that corresponds to
- * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
- * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
- * @param higherQuality if true, this method will use a multi-step
- * scaling technique that provides higher quality than the usual
- * one-step technique (only useful in downscaling cases, where
- * {@code targetWidth} or {@code targetHeight} is
- * smaller than the original dimensions, and generally only when
- * the {@code BILINEAR} hint is specified)
- * @return a scaled version of the original {@code BufferedImage}
- */
- public static BufferedImage getScaledInstance(BufferedImage img,
- int targetWidth,
- int targetHeight,
- Object hint,
- boolean higherQuality)
- {
- int type = (img.getTransparency() == Transparency.OPAQUE) ?
- BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
- BufferedImage ret = (BufferedImage)img;
- int w, h;
- if (higherQuality) {
- // Use multi-step technique: start with original size, then
- // scale down in multiple passes with drawImage()
- // until the target size is reached
- w = img.getWidth();
- h = img.getHeight();
- } else {
- // Use one-step technique: scale directly from original
- // size to target size with a single drawImage() call
- w = targetWidth;
- h = targetHeight;
- }
-
- do {
- if (higherQuality && w > targetWidth) {
- w /= 2;
- if (w < targetWidth) {
- w = targetWidth;
- }
- }
-
- if (higherQuality && h > targetHeight) {
- h /= 2;
- if (h < targetHeight) {
- h = targetHeight;
- }
- }
-
- BufferedImage tmp = new BufferedImage(w, h, type);
- Graphics2D g2 = tmp.createGraphics();
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
- g2.drawImage(ret, 0, 0, w, h, null);
- g2.dispose();
-
- ret = tmp;
- } while (w != targetWidth || h != targetHeight);
-
- return ret;
- }
- public static void main(String[] args) throws Exception {
- BufferedImage bitmapToImage = bitmapToImage("E:\\realworldnew\\web\\src\\main\\webapp\\WEB-INF\\Upload\\amarkhel\\20\\sport (14).jpg", "JPG");
- BufferedImage scaledInstance = getScaledInstance(bitmapToImage, 80, 60, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
- imageToBitmap(scaledInstance, "E:\\realworldnew\\web\\src\\main\\webapp\\WEB-INF\\Upload\\amarkhel\\20\\sport (14)_copy.jpg", "JPG");
- }
-}
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/contextMenu/CMForShelf.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/multyMode.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/index/login.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/register/regInfo.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefs.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/layout/menu.xhtml
===================================================================
(Binary files differ)
15 years, 10 months
JBoss Rich Faces SVN: r12921 - in trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld: util and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2009-03-11 09:49:58 -0400 (Wed, 11 Mar 2009)
New Revision: 12921
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/util/DirectLinkHelper.java
Log:
getDirectImageLink method added
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-11 13:44:03 UTC (rev 12920)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-03-11 13:49:58 UTC (rev 12921)
@@ -35,6 +35,7 @@
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IImageAction;
+import org.richfaces.realworld.util.DirectLinkHelper;
@Name("imageManager")
@Scope(ScopeType.CONVERSATION)
@@ -51,6 +52,9 @@
@In
private User user;
+ @In(create=true)
+ private DirectLinkHelper directLink;
+
public void deleteImage(Image image){
String imagePath = image.getPath();
imageAction.deleteImage(image);
@@ -86,4 +90,8 @@
Events.instance().raiseEvent(Constants.CLEAR_EDITOR_EVENT, "");
}
+ public String getImageDirectLink(Image image) {
+ return directLink.getDirectImageLink(image.getId());
+ }
+
}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-03-11 13:44:03 UTC (rev 12920)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-03-11 13:49:58 UTC (rev 12921)
@@ -8,8 +8,11 @@
import java.io.InputStream;
import java.io.OutputStream;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
import javax.imageio.ImageIO;
import javax.persistence.EntityManager;
+import javax.servlet.http.HttpServletRequest;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
@@ -32,7 +35,12 @@
protected Long imageId;
private Long id;
+
+ private static final String IMAGE_DIRECT_LINK = "/includes/directImage.seam?imageId=";
+
+ private static String imageDirectLinkPrefix;
+
public synchronized void paintImage(OutputStream out, Object data)
throws IOException {
Image im = em.find(Image.class, id);
@@ -64,4 +72,30 @@
public void start(){
id=imageId;
}
+
+ public String getDirectImageLink(Long id) {
+ if (imageDirectLinkPrefix == null) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context == null) {
+ return null;
+ }
+ ExternalContext extc = context.getExternalContext();
+ if (extc == null) {
+ return null;
+ }
+
+ Object request = extc.getRequest();
+
+ if (request instanceof HttpServletRequest) {
+ HttpServletRequest servletRequest = (HttpServletRequest)request;
+ String contextPath = servletRequest.getContextPath();
+ StringBuffer url = servletRequest.getRequestURL();
+ int i = url.indexOf(contextPath);
+ if (i > 0) {
+ imageDirectLinkPrefix = url.substring(0, i) + contextPath + IMAGE_DIRECT_LINK;
+ }
+ }
+ }
+ return imageDirectLinkPrefix + id;
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Rich Faces SVN: r12920 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-03-11 09:44:03 -0400 (Wed, 11 Mar 2009)
New Revision: 12920
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
Log:
Add reseting all fields of AutoTesterBean after rendering page.
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-03-11 13:43:22 UTC (rev 12919)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-03-11 13:44:03 UTC (rev 12920)
@@ -73,6 +73,8 @@
public void renderPage(Template template, String resetMethodName) {
base.renderAutoTestPage(template, resetMethodName);
+ reset();
+ clickLoad();
}
public void renderPage(String url, Template template, String resetMethodName) {
15 years, 10 months
JBoss Rich Faces SVN: r12919 - trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-03-11 09:43:22 -0400 (Wed, 11 Mar 2009)
New Revision: 12919
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
Log:
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2009-03-11 13:06:02 UTC (rev 12918)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2009-03-11 13:43:22 UTC (rev 12919)
@@ -207,6 +207,7 @@
public void currectDateChangeListener(CurrentDateChangeEvent event) {
status = getStatus() + currentDateChangeListener;
+
}
public String testClientMode() {
@@ -226,18 +227,18 @@
public void reset() {
- mode = UICalendar.AJAX_MODE;
- status = "";
- selectedDate = new Date();
- isPopup = false;
- currentDate = new Date();
- locale = Locale.US;
- required = false;
- enableManualInput = false;
- NULLModel = false;
- firstWeekDay = 0;
- disabled = false;
- datePattern = DATE_PATTERN;
+ mode = UICalendar.AJAX_MODE;
+ status = "";
+ selectedDate = new Date();
+ isPopup = false;
+ currentDate = new Date();
+ locale = Locale.US;
+ required = false;
+ enableManualInput = false;
+ NULLModel = false;
+ firstWeekDay = 0;
+ disabled = false;
+ datePattern = DATE_PATTERN;
}
public void reset2() {
@@ -256,7 +257,22 @@
preloadDateRangeEnd = c.getTime(); // Set preloadEnd by the last day of the next month
isPopup = true;
}
-
+
+ public void reset3() {
+ mode = UICalendar.CLIENT_MODE;
+ status = "";
+ selectedDate = new Date();
+ isPopup = false;
+ currentDate = new Date();
+ locale = Locale.US;
+ required = false;
+ enableManualInput = false;
+ NULLModel = true;
+ firstWeekDay = 0;
+ disabled = false;
+ datePattern = DATE_PATTERN;
+ }
+
public String resetAction() {
reset();
return null;
15 years, 10 months
JBoss Rich Faces SVN: r12918 - trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-03-11 09:06:02 -0400 (Wed, 11 Mar 2009)
New Revision: 12918
Removed:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/error/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/servlet/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tree/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/user/
Log:
15 years, 10 months
JBoss Rich Faces SVN: r12917 - in trunk/test-applications/realworld2/web/src/main: java/org/richfaces/realworld/fileupload and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-03-11 09:03:18 -0400 (Wed, 11 Mar 2009)
New Revision: 12917
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/SlideshowHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagCloudHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java
Removed:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/error/ErrorHandlerBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Controller.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Model.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RenderLogic.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/TreeManager.java
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
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/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/search/ImageSearchHelper.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/userAlbumsPreview.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imagePreview.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/shelf.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/userShelfPreview.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/template3.xhtml
Log:
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/error/ErrorHandlerBean.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/error/ErrorHandlerBean.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/error/ErrorHandlerBean.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,66 +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.error;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.context.AjaxContext;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.realworld.service.Constants;
-
-@Name("errorHandlerBean")
-(a)Scope(ScopeType.EVENT)
-@AutoCreate
-public class ErrorHandlerBean {
- private List<Exception> errors = new ArrayList<Exception>();
-
- public List<Exception> getErrors() {
- return errors;
- }
-
- public void setErrors(List<Exception> errors) {
- this.errors = errors;
- }
-
- public boolean isErrorExist(){
- return errors.size() > 0 ;
- }
-
- @Observer(Constants.CLEAR_ERROR_EVENT)
- public void clearEvents(){
- errors.clear();
- }
-
- @Observer(Constants.ADD_ERROR_EVENT)
- public void addToErrors(Exception e){
- FacesContext context = FacesContext.getCurrentInstance();
- AjaxContext ac = AjaxContext.getCurrentInstance(context);
- ac.addRenderedArea(Constants.ERROR_ID);
- errors.add(e);
- }
-}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -150,11 +150,11 @@
public boolean addImage(String fileName, String tempFilePath) {
createDirectoryIfNotExist(fileName);
- writeFile(fileName, tempFilePath, _SMALL80, 80);
- writeFile(fileName, tempFilePath, _SMALL120, 120);
- writeFile(fileName, tempFilePath, _SMALL160, 160);
- writeFile(fileName, tempFilePath, _MINI, 150);
- writeFile(fileName, tempFilePath, _MEDIUM, 600);
+ writeFile(fileName, tempFilePath, _SMALL80, 80, true);
+ writeFile(fileName, tempFilePath, _SMALL120, 120, true);
+ writeFile(fileName, tempFilePath, _SMALL160, 160, true);
+ writeFile(fileName, tempFilePath, _MINI, 150, true);
+ writeFile(fileName, tempFilePath, _MEDIUM, 600, true);
return true;
}
@@ -249,7 +249,7 @@
return ret;
}
- private void writeFile(String newFileName, String fileName,String pattern, int size) {
+ public void writeFile(String newFileName, String fileName,String pattern, int size, boolean includeUploadRoot) {
BufferedImage bsrc =null;
try {
bsrc = bitmapToImage(fileName, "JPG");
@@ -265,7 +265,7 @@
yy = ((Double)d*bsrc.getHeight());
int height= yy.intValue();
BufferedImage bdest = getScaledInstance(bsrc, width, height, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
- String dest = this.uploadRootPath + transformPath(newFileName, pattern);
+ String dest = includeUploadRoot? this.uploadRootPath + transformPath(newFileName, pattern) : transformPath(newFileName, pattern);
try {
imageToBitmap(bdest, dest, "JPG");
} catch (IOException ex) {
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -40,9 +40,8 @@
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.manager.NavigationEnum;
import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.util.ImageUtils;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.imaging.jpeg.JpegProcessingException;
@@ -92,7 +91,7 @@
file.setSelected(false);
file.setName(event.getUploadItem().getFileName());
Image image = constructImage(item, file);
- resizeImages(item,file.getFile().getPath());
+ fileManager.writeFile(file.getFile().getPath(), file.getFile().getPath(), "_mini", 100, false);
try {
extractMetadata(file, image);
} catch (JpegProcessingException e1) {
@@ -113,10 +112,6 @@
}
}
- private void resizeImages(UploadItem src, String pathToUpload) throws IOException {
- ImageUtils.resizeImage(src, pathToUpload, ImageUtils.MINI);
- }
-
@Observer(Constants.FILE_UPLOAD_CLEAR_EVENT)
public void clearUploadData() {
fileWrapper.getFiles().clear();
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-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -32,11 +32,8 @@
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.IAlbumAction;
-import org.richfaces.realworld.util.Controller;
-import org.richfaces.realworld.util.Model;
@Name("albumManager")
@Scope(ScopeType.CONVERSATION)
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-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -44,11 +44,8 @@
import org.jboss.seam.web.Session;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileManager;
-import org.richfaces.realworld.navigation.NavigationEnum;
import org.richfaces.realworld.service.IUserAction;
import org.richfaces.realworld.ui.PasswordHolder;
-import org.richfaces.realworld.util.Controller;
-import org.richfaces.realworld.util.Model;
import org.richfaces.realworld.service.Constants;
@Name("authenticator")
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java (from rev 12915, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Controller.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,186 @@
+/**
+ * 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.manager;
+
+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.Out;
+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.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.Constants;
+
+@Name("controller")
+(a)Scope(ScopeType.CONVERSATION)
+@Synchronized(timeout=200000)
+public class Controller implements Serializable{
+
+ private static final long serialVersionUID = 5656562187249324512L;
+
+ @In("#{messages['acess_not_granted']}")
+ private String HAVENT_ACCESS;
+
+ @In @Out Model model;
+
+ @In(create=true)
+ private User user;
+
+ public void selectShelfs(){
+ model.resetModel(NavigationEnum.ALL_SHELFS, user, null, null, null, null );
+ }
+
+ public void selectAlbums(){
+ model.resetModel(NavigationEnum.ALL_ALBUMS, user, null, null, null, null );
+ }
+
+ public void selectImages(){
+ model.resetModel(NavigationEnum.ALL_IMAGES, user, null, null, null, null );
+ }
+
+ public void incrementSlideShowIndex(){
+ Integer index = model.getSelectedAlbum().getIndex(model.getSelectedImage());
+ if(index == -1){
+ if(model.getSelectedAlbum().getImages() != null && model.getSelectedAlbum().getImages().size() > 1){
+ index = model.getSelectedAlbum().getIndex(model.getSelectedAlbum().getImages().get(1));
+ }else{
+ pushEvent("stopSlideshow");
+ return;
+ }
+ }
+ updateDataScroller(index, Constants.DATASCROLLER2_ID);
+ if(index == model.getSelectedAlbum().getImages().size() - 1){
+ index=-1;
+ }
+ model.setSelectedImageIndex(index+1);
+ model.setSelectedImage(model.getSelectedAlbum().getImages().get(index + 1));
+ }
+
+ public void startEditShelf(Shelf shelf){
+ if(!canViewShelf(shelf)){
+ pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ return;
+ }
+ model.resetModel(NavigationEnum.SHELF_EDIT, shelf.getOwner(), shelf, null, null, null );
+ }
+
+ public void cancelEditShelf(Shelf shelf){
+ model.setMainArea(NavigationEnum.SHELF_PREVIEW);
+ }
+
+ public void showAlbum(Album album){
+ if(!canViewAlbum(album)){
+ pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ return;
+ }
+ model.resetModel(NavigationEnum.ALBUM_PREVIEW, album.getOwner(), album.getShelf(), album, null, null );
+ }
+
+ public void showImage(Image image){
+ if(!canViewImage(image)){
+ pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ return;
+ }
+ model.resetModel(NavigationEnum.ALBUM_IMAGE_PREVIEW, image.getAlbum().getOwner(), image.getAlbum().getShelf(), image.getAlbum(), null, null );
+ model.setSelectedImage(image);
+ Integer index = model.getSelectedAlbum().getIndex(model.getSelectedImage());
+ updateDataScroller(index, Constants.DATASCROLLER_ID);
+ model.setSelectedImageIndex(index+1);
+ }
+
+ public void startEditImage(Image image){
+ if(!canViewImage(image)){
+ pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ return;
+ }
+ model.setMainArea(NavigationEnum.ALBUM_IMAGE_EDIT);
+ }
+
+ public void cancelEditImage(Image image){
+ model.setMainArea(NavigationEnum.ALBUM_IMAGE_PREVIEW);
+ }
+
+ public void startEditAlbum(Album album){
+ if(!album.getOwner().equals(user)){
+ pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ return;
+ }
+ model.setMainArea(NavigationEnum.ALBUM_EDIT);
+ }
+
+ public void cancelEditAlbum(Album album){
+ model.setMainArea(NavigationEnum.ALBUM_PREVIEW);
+ }
+
+ public void showFileUpload(){
+ model.setMainArea(NavigationEnum.FILE_UPLOAD);
+ }
+
+ public boolean isAccessToAlbumGranted(Album album){
+ return album.getOwner().equals(user) || album.getShelf().isShared();
+ }
+
+ public boolean isUserAlbum(Album album){
+ if(album == null || album.getOwner() == null){
+ return false;
+ }
+ return album.getOwner().equals(user);
+ }
+
+ public void showUser(User user){
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.USER_PREFS);
+ model.setSelectedUser(user);
+ }
+
+ private void updateDataScroller(Integer index, String dataScrollerId) {
+ UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
+ UIDatascroller scroller = (UIDatascroller)component.findComponent(dataScrollerId);
+ Map<String, Object> attributes = scroller.getDataTable().getAttributes();
+ attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
+ }
+
+ private boolean canViewShelf(Shelf shelf) {
+ return shelf.getOwner().equals(user);
+ }
+
+ private boolean canViewImage(Image image) {
+ return image.getAlbum().getShelf().isShared() || image.getAlbum().getOwner().equals(user);
+ }
+
+ private boolean canViewAlbum(Album album) {
+ return album.getShelf().isShared() || album.getOwner().equals(user);
+ }
+
+ private void pushEvent(String type, Object... parameters) {
+ Events.instance().raiseEvent(type, parameters);
+ }
+}
\ No newline at end of file
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-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -33,11 +33,8 @@
import org.richfaces.realworld.domain.Image;
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.IImageAction;
-import org.richfaces.realworld.util.Controller;
-import org.richfaces.realworld.util.Model;
@Name("imageManager")
@Scope(ScopeType.CONVERSATION)
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java (from rev 12915, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Model.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,98 @@
+package org.richfaces.realworld.manager;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.annotations.Scope;
+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.service.Constants;
+
+@Name("model")
+(a)Scope(ScopeType.CONVERSATION)
+public class Model {
+
+private Integer selectedImageIndex = 1;
+
+ private Image selectedImage;
+
+ private Album selectedAlbum;
+
+ private User selectedUser;
+
+ private Shelf selectedShelf;
+
+ private MetaTag selectedTag;
+
+ private NavigationEnum mainArea;
+
+ public void resetModel(NavigationEnum mainArea, User selectedUser, Shelf selectedShelf, Album selectedAlbum, Image selectedImage, MetaTag selectedTag){
+ this.setMainArea(mainArea);
+ this.setSelectedAlbum(selectedAlbum);
+ this.setSelectedImage(selectedImage);
+ this.setSelectedShelf(selectedShelf);
+ this.setSelectedTag(selectedTag);
+ this.setSelectedUser(selectedUser);
+ }
+
+ @Observer(Constants.UPDATE_MAIN_AREA_EVENT)
+ public void setMainArea(NavigationEnum mainArea) {
+ this.mainArea = mainArea;
+ }
+
+ public Integer getSelectedImageIndex() {
+ return selectedImageIndex;
+ }
+
+ public NavigationEnum getMainArea() {
+ return mainArea;
+ }
+
+ 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 User getSelectedUser() {
+ return selectedUser;
+ }
+
+ public void setSelectedUser(User selectedUser) {
+ this.selectedUser = selectedUser;
+ }
+
+ public Shelf getSelectedShelf() {
+ return selectedShelf;
+ }
+
+ public void setSelectedShelf(Shelf selectedShelf) {
+ this.selectedShelf = selectedShelf;
+ }
+
+ public MetaTag getSelectedTag() {
+ return selectedTag;
+ }
+
+ @Observer("updateSelectedTag")
+ public void setSelectedTag(MetaTag selectedTag) {
+ this.selectedTag = selectedTag;
+ }
+}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java (from rev 12909, 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/manager/NavigationEnum.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/NavigationEnum.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,49 @@
+/**
+ * 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.manager;
+
+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"),
+ WHAT_NEW("includes/recent.xhtml"),
+ ALBUM_PREVIEW("includes/userAlbum.xhtml"),
+ ALBUM_IMAGE_PREVIEW("/includes/userImage.xhtml"),
+ SHELF_PREVIEW("/includes/userShelf.xhtml"),
+ ALL_SHELFS("/includes/userShelfs.xhtml"),
+ TAGS("includes/tag.xhtml"),
+ ALL_ALBUMS("/includes/userAlbums.xhtml"),
+ ALL_IMAGES("/includes/userImages.xhtml"),
+ ALBUM_IMAGE_EDIT("/includes/userImageEdit.xhtml"),
+ ALBUM_EDIT("/includes/userAlbumEdit.xhtml"),
+ SHELF_EDIT("/includes/userShelfEdit.xhtml");
+
+
+ private NavigationEnum(String t){
+ template=t;
+ }
+ private String template;
+ public String getTemplate() {
+ return template;
+ }
+}
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-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -35,10 +35,8 @@
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.util.Model;
@Name("shelfManager")
@Scope(ScopeType.CONVERSATION)
Added: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,73 @@
+/**
+ * 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.manager;
+
+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.Out;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.ui.SlideshowHelper;
+
+@Name("slideshow")
+(a)Scope(ScopeType.CONVERSATION)
+public class SlideshowManager implements Serializable{
+
+ private static final long serialVersionUID = 7801877176558409702L;
+
+ @In(required=false) @Out(required=false)
+ SlideshowHelper slideshowHelper;
+
+ private boolean active;
+
+ private int interval = Constants.INITIAL_DELAY;
+
+ public int getInterval() {
+ return interval;
+ }
+
+ public void setInterval(int interval) {
+ this.interval = interval;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public void startSlideshow(){
+ active = true;
+ }
+
+ public void stopSlideshow(){
+ active = false;
+ }
+
+ public void updateInterval(){
+ this.setInterval((int)(Constants.DELAY * Long.valueOf(slideshowHelper.getInputSlider().getValue().toString())));
+ }
+}
Property changes on: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java (from rev 12915, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/TreeManager.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,68 @@
+package org.richfaces.realworld.manager;
+
+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.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
+import org.richfaces.component.UITree;
+import org.richfaces.component.html.HtmlTree;
+import org.richfaces.event.NodeSelectedEvent;
+import org.richfaces.realworld.domain.Album;
+import org.richfaces.realworld.domain.Shelf;
+import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.service.Constants;
+
+@Name("treeManager")
+(a)Scope(ScopeType.CONVERSATION)
+public class TreeManager implements Serializable{
+
+ @In
+ private User user;
+ @In @Out Model model;
+ private static final long serialVersionUID = 5656562187249324512L;
+
+ @SuppressWarnings("unchecked")
+ public Boolean adviseNodeSelected(UITree tree) {
+ Object currentNode = tree.getRowData();
+ if (currentNode instanceof Album) {
+ boolean selected = currentNode == model.getSelectedAlbum();
+ return selected;
+ }else if(currentNode instanceof Shelf){
+ return currentNode == model.getSelectedShelf() && model.getSelectedAlbum() == null;
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Boolean adviseNodeOpened(UITree tree) {
+ Object currentNode = tree.getRowData();
+ if (currentNode instanceof Album) {
+ boolean selected = currentNode == model.getSelectedAlbum();
+ return selected;
+ }else if(currentNode instanceof Shelf){
+ return currentNode == model.getSelectedShelf();
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void processSelection(NodeSelectedEvent event) {
+ HtmlTree tree = (HtmlTree) event.getComponent();
+ Object currentNode = tree.getRowData();
+ if(currentNode instanceof Album){
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.ALBUM_PREVIEW);
+ model.setSelectedAlbum((Album)currentNode);
+ model.setSelectedShelf(((Album)currentNode).getShelf());
+ }else if(currentNode instanceof Shelf){
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.SHELF_PREVIEW);
+ model.setSelectedAlbum(null);
+ model.setSelectedShelf((Shelf)currentNode);
+ }
+ model.setSelectedUser(user);
+ model.setSelectedImage(null);
+ }
+}
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -13,10 +13,10 @@
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Events;
-import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.manager.Controller;
+import org.richfaces.realworld.manager.NavigationEnum;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.ISearchAction;
-import org.richfaces.realworld.util.Controller;
@Name("searchImageHelper")
@Scope(ScopeType.CONVERSATION)
@@ -47,7 +47,7 @@
options.add(new SearchOptionByTag());
}
- public void search(ActionEvent event) {
+ public void search() {
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.SEARCH);
Iterator<ISearchOption> it = options.iterator();
while (it.hasNext()) {
@@ -64,7 +64,7 @@
return selectedOption != null;
}
- public void processSelection(ActionEvent event) {
+ public void processSelection() {
Iterator<ISearchOption> it = options.iterator();
while (it.hasNext()) {
ISearchOption option = it.next();
@@ -75,7 +75,7 @@
}
}
- public void back(ActionEvent event) {
+ public void back() {
Iterator<ISearchOption> it = options.iterator();
while (it.hasNext()) {
it.next().setSelected(false);
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowBean.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowBean.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowBean.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,74 +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.slideshow;
-
-import java.io.Serializable;
-
-import javax.faces.event.ActionEvent;
-
-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.realworld.service.Constants;
-
-@Name("slideshow")
-(a)Scope(ScopeType.CONVERSATION)
-public class SlideshowBean implements Serializable{
-
- private static final long serialVersionUID = 7801877176558409702L;
-
- @In(required=false) @Out(required=false)
- SlideshowHelper slideshowHelper;
-
- private boolean active;
-
- private int interval = Constants.INITIAL_DELAY;
-
- public int getInterval() {
- return interval;
- }
-
- public void setInterval(int interval) {
- this.interval = interval;
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- public void startSlideshow(ActionEvent event){
- active = true;
- }
-
- public void stopSlideshow(ActionEvent event){
- active = false;
- }
-
- public void updateInterval(ActionEvent event){
- this.setInterval((int)(Constants.DELAY * Long.valueOf(slideshowHelper.getInputSlider().getValue().toString())));
- }
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowHelper.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,43 +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.slideshow;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.component.UIInputNumberSlider;
-
-@Name("slideshowHelper")
-(a)Scope(ScopeType.EVENT)
-public class SlideshowHelper {
-
- private UIInputNumberSlider inputSlider;
-
- public UIInputNumberSlider getInputSlider() {
- return inputSlider;
- }
-
- public void setInputSlider(UIInputNumberSlider inputSlider) {
- this.inputSlider = inputSlider;
- }
-
-
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,66 +0,0 @@
-/**
- *
- */
-package org.richfaces.realworld.tagClound;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.event.ActionEvent;
-
-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.jboss.seam.core.Events;
-import org.richfaces.realworld.navigation.NavigationEnum;
-import org.richfaces.realworld.service.IImageAction;
-
-
-/**
- * Tag cloud backing bean
- * @author Andrey Markavtsov
- *
- */
-
-@Name("tagCloudBean")
-(a)Scope(ScopeType.CONVERSATION)
-public class TagCloudBean {
- @In(create=true) IImageAction imageAction;
- /** Min possible rank for tag */
- static final int MIN_RANK = 0;
-
- /** Max possible rank for tag */
- static final int MAX_RANK = 100;
-
- /** Scope of existed css classes for each rank. Should be defined ordered ASC by rank */
- static final String [] TAG_CSS_CLASSSES = new String []
- {"tag-cloud-rank1", "tag-cloud-rank2",
- "tag-cloud-rank3", "tag-cloud-rank4",
- "tag-cloud-rank5", "tag-cloud-rank6",
- "tag-cloud-rank7" } ;
-
- /** Count of possible ranks' css classes */
- static final int TAG_RANK_LEVELS_COUNT = TAG_CSS_CLASSSES.length;
-
- /** Defines the step to the neighbouring rank */
- int RANK_LEVEL_STEP = (MAX_RANK ) / TAG_RANK_LEVELS_COUNT;;
-
-
-
- /**
- * Calculates css class name for tag with rank defined
- * @param rank - tags rank
- * @return css class name
- */
- public String getTagCssClass(Integer rank) {
- int i = rank / RANK_LEVEL_STEP;
- return TAG_CSS_CLASSSES[i];
- }
-
- public void selectTag(String tag){
- Events.instance().raiseEvent("updateMainArea", NavigationEnum.TAGS);
- Events.instance().raiseEvent("updateSelectedTag",imageAction.getTagByName(tag));
- }
-}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java (from rev 12864, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/ConfirmationPopupHelper.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,115 @@
+/**
+ * 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 javax.faces.event.ActionEvent;
+
+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.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.manager.AlbumManager;
+import org.richfaces.realworld.manager.ImageManager;
+import org.richfaces.realworld.manager.ShelfManager;
+
+@Name("confirmationPopupHelper")
+(a)Scope(ScopeType.CONVERSATION)
+public class ConfirmationPopupHelper implements Serializable{
+
+ private static final long serialVersionUID = 2561824019376412988L;
+
+ private String caption;
+
+ private String actionName;
+
+ @In(create=true, required=true) @Out(required=false)
+ private Image image;
+
+ @In(create=true, required=true) @Out(required=false)
+ private Shelf shelf;
+
+ @In(create=true, required=true) @Out(required=false)
+ private Album album;
+
+ @In(create=true)
+ private AlbumManager albumManager;
+
+ @In(create=true)
+ private ShelfManager shelfManager;
+
+ @In(create=true)
+ private ImageManager imageManager;
+
+ public void initImagePopup( String actionName, String caption, Image image){
+ this.caption = caption;
+ this.actionName = actionName;
+ this.image = image;
+ }
+
+ public void initAlbumData( String actionName, String caption, Album album){
+ this.caption = caption;
+ this.actionName = actionName;
+ this.album = album;
+ }
+
+ public void initShelfData( String actionName, String caption, Shelf shelf){
+ this.caption = caption;
+ this.actionName = actionName;
+ this.shelf = shelf;
+ }
+
+ public void deleteAlbum(){
+ albumManager.deleteAlbum(this.album);
+ }
+
+ public void deleteShelf(){
+ shelfManager.deleteShelf(this.shelf);
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public String getActionName() {
+ return actionName;
+ }
+
+ public void setActionName(String actionName) {
+ this.actionName = actionName;
+ }
+
+ public void deleteImage(){
+ imageManager.deleteImage(this.image);
+ }
+
+}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/SlideshowHelper.java (from rev 12864, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/slideshow/SlideshowHelper.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/SlideshowHelper.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/SlideshowHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,43 @@
+/**
+ * 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 org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.component.UIInputNumberSlider;
+
+@Name("slideshowHelper")
+(a)Scope(ScopeType.EVENT)
+public class SlideshowHelper {
+
+ private UIInputNumberSlider inputSlider;
+
+ public UIInputNumberSlider getInputSlider() {
+ return inputSlider;
+ }
+
+ public void setInputSlider(UIInputNumberSlider inputSlider) {
+ this.inputSlider = inputSlider;
+ }
+
+
+}
Added: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagCloudHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagCloudHelper.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagCloudHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,60 @@
+/**
+ *
+ */
+package org.richfaces.realworld.ui;
+
+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.core.Events;
+import org.richfaces.realworld.manager.NavigationEnum;
+import org.richfaces.realworld.service.IImageAction;
+
+
+/**
+ * Tag cloud backing bean
+ * @author Andrey Markavtsov
+ *
+ */
+
+@Name("tagCloudBean")
+(a)Scope(ScopeType.CONVERSATION)
+public class TagCloudHelper {
+ @In(create=true) IImageAction imageAction;
+ /** Min possible rank for tag */
+ static final int MIN_RANK = 0;
+
+ /** Max possible rank for tag */
+ static final int MAX_RANK = 100;
+
+ /** Scope of existed css classes for each rank. Should be defined ordered ASC by rank */
+ static final String [] TAG_CSS_CLASSSES = new String []
+ {"tag-cloud-rank1", "tag-cloud-rank2",
+ "tag-cloud-rank3", "tag-cloud-rank4",
+ "tag-cloud-rank5", "tag-cloud-rank6",
+ "tag-cloud-rank7" } ;
+
+ /** Count of possible ranks' css classes */
+ static final int TAG_RANK_LEVELS_COUNT = TAG_CSS_CLASSSES.length;
+
+ /** Defines the step to the neighbouring rank */
+ int RANK_LEVEL_STEP = (MAX_RANK ) / TAG_RANK_LEVELS_COUNT;;
+
+
+
+ /**
+ * Calculates css class name for tag with rank defined
+ * @param rank - tags rank
+ * @return css class name
+ */
+ public String getTagCssClass(Integer rank) {
+ int i = rank / RANK_LEVEL_STEP;
+ return TAG_CSS_CLASSSES[i];
+ }
+
+ public void selectTag(String tag){
+ Events.instance().raiseEvent("updateMainArea", NavigationEnum.TAGS);
+ Events.instance().raiseEvent("updateSelectedTag",imageAction.getTagByName(tag));
+ }
+}
Property changes on: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/TagCloudHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,107 @@
+/**
+ *
+ */
+package org.richfaces.realworld.ui;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+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.jboss.seam.core.Events;
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+import org.richfaces.realworld.domain.Sex;
+import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.manager.Model;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.service.IUserAction;
+
+/**
+ * @author Andrey Markavtsov
+ *
+ */
+@Name("userPrefsBean")
+(a)Scope(ScopeType.CONVERSATION)
+public class UserPrefsHelper {
+
+ @In(create=true)
+ IUserAction userAction;
+
+ @In(create=true)
+ FileManager fileManager;
+
+ @In @Out Model model;
+
+ @In
+ User user;
+
+ Boolean avatarModalOpened = false;
+
+ File avatarData = null;
+
+ static final SelectItem [] sexs = new SelectItem []
+ {
+ new SelectItem(Sex.MALE, "Male"),
+ new SelectItem(Sex.FEMALE, "Female")
+ };
+
+ public void uploadAvatar(UploadEvent event) {
+ UploadItem item = event.getUploadItem();
+ avatarData = item.getFile();
+ }
+
+ public void saveUser(){
+ User user = model.getSelectedUser();
+ if (avatarData != null) {
+ try {
+ BufferedImage image = fileManager.bitmapToImage(avatarData.getPath(),"JPG" );
+ fileManager.imageToBitmap(image, fileManager.getUploadRoot() + user.getLogin() +
+ "/avatar.jpg", "JPG");
+ } catch (IOException e) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("File IO Error"));
+ }
+ avatarData.delete();
+ avatarData = null;
+ user.setHasAvatar(true);
+ }
+ userAction.updateUser(user);
+ }
+
+ public void registerUser() {
+ if (user != null) {
+ userAction.register(user);
+ }
+ }
+
+ public void cancel() {
+ avatarData = null;
+ }
+
+ public SelectItem [] getSexs () {
+ return sexs;
+ }
+
+ public Boolean getAvatarModalOpened() {
+ return avatarModalOpened;
+ }
+
+ public void setAvatarModalOpened(Boolean avatarModalOpened) {
+ this.avatarModalOpened = avatarModalOpened;
+ }
+
+ public File getAvatarData() {
+ return avatarData;
+ }
+
+ public void setAvatarData(File avatarData) {
+ this.avatarData = avatarData;
+ }
+}
Property changes on: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Controller.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Controller.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Controller.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,171 +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.Out;
-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.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.navigation.NavigationEnum;
-import org.richfaces.realworld.service.Constants;
-
-@Name("controller")
-(a)Scope(ScopeType.CONVERSATION)
-@Synchronized(timeout=200000)
-public class Controller implements Serializable{
-
- private static final long serialVersionUID = 5656562187249324512L;
-
- @In("#{messages['acess_not_granted']}")
- private String HAVENT_ACCESS;
-
- @In @Out Model model;
-
- @In(create=true)
- private User user;
-
- public void selectShelfs(){
- model.resetModel(NavigationEnum.ALL_SHELFS, user, null, null, null, null );
- }
-
- public void selectAlbums(){
- model.resetModel(NavigationEnum.ALL_ALBUMS, user, null, null, null, null );
- }
-
- public void selectImages(){
- model.resetModel(NavigationEnum.ALL_IMAGES, user, null, null, null, null );
- }
-
- public void incrementSlideShowIndex(){
- Integer index = model.getSelectedAlbum().getIndex(model.getSelectedImage());
- if(index == -1){
- if(model.getSelectedAlbum().getImages() != null && model.getSelectedAlbum().getImages().size() > 1){
- index = model.getSelectedAlbum().getIndex(model.getSelectedAlbum().getImages().get(1));
- }else{
- pushEvent("stopSlideshow");
- return;
- }
- }
- updateDataScroller(index, Constants.DATASCROLLER2_ID);
- if(index == model.getSelectedAlbum().getImages().size() - 1){
- index=-1;
- }
- model.setSelectedImageIndex(index+1);
- model.setSelectedImage(model.getSelectedAlbum().getImages().get(index + 1));
- }
-
- public void startEditShelf(Shelf shelf){
- if(!canViewShelf(shelf)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
- return;
- }
- model.setMainArea(NavigationEnum.SHELF_EDIT);
- }
-
- public void cancelEditShelf(Shelf shelf){
- model.setMainArea(NavigationEnum.SHELF_PREVIEW);
- }
-
- public void showAlbum(Album album){
- if(!canViewAlbum(album)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
- return;
- }
- model.resetModel(NavigationEnum.ALBUM_PREVIEW, album.getOwner(), album.getShelf(), album, null, null );
- }
-
- public void showImage(Image image){
- if(!canViewImage(image)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
- return;
- }
- model.resetModel(NavigationEnum.ALBUM_IMAGE_PREVIEW, image.getAlbum().getOwner(), image.getAlbum().getShelf(), image.getAlbum(), null, null );
- model.setSelectedImage(image);
- Integer index = model.getSelectedAlbum().getIndex(model.getSelectedImage());
- updateDataScroller(index, Constants.DATASCROLLER_ID);
- model.setSelectedImageIndex(index+1);
- }
-
- public void startEditImage(Image image){
- if(!canViewImage(image)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
- return;
- }
- model.setMainArea(NavigationEnum.ALBUM_IMAGE_EDIT);
- }
-
- public void cancelEditImage(Image image){
- model.setMainArea(NavigationEnum.ALBUM_IMAGE_PREVIEW);
- }
-
- public void startEditAlbum(Album album){
- if(album.getOwner().equals(user)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
- return;
- }
- model.setMainArea(NavigationEnum.ALBUM_EDIT);
- }
-
- public void cancelEditAlbum(Album album){
- model.setMainArea(NavigationEnum.ALBUM_PREVIEW);
- }
-
- public void showFileUpload(){
- model.setMainArea(NavigationEnum.FILE_UPLOAD);
- }
-
- private void updateDataScroller(Integer index, String dataScrollerId) {
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller = (UIDatascroller)component.findComponent(dataScrollerId);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
- }
-
- private boolean canViewShelf(Shelf shelf) {
- return shelf.isShared() || shelf.getOwner().equals(user);
- }
-
- private boolean canViewImage(Image image) {
- return image.getAlbum().getShelf().isShared() || image.getAlbum().getOwner().equals(user);
- }
-
- private boolean canViewAlbum(Album album) {
- return album.getShelf().isShared() || album.getOwner().equals(user);
- }
-
- private void pushEvent(String type, Object... parameters) {
- Events.instance().raiseEvent(type, parameters);
- }
-}
\ No newline at end of file
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,67 +0,0 @@
-package org.richfaces.realworld.util;
-
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-import javax.persistence.EntityManager;
-
-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.annotations.web.RequestParameter;
-import org.jboss.seam.core.Events;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.fileupload.FileManager;
-import org.richfaces.realworld.service.Constants;
-
-@Name("directLink")
-(a)Scope(ScopeType.SESSION)
-public class DirectLink {
- @In(value="entityManager")
- protected EntityManager em;
- @In(create = true)
- FileManager fileManager;
- @RequestParameter
- protected Long imageId;
-
- private Long id;
-
- public synchronized void paintImage(OutputStream out, Object data)
- throws IOException {
- Image im = em.find(Image.class, id);
- File imageResource = fileManager.getImage(im.getPath());
- if (imageResource != null) {
- FileInputStream fileInputStream = new FileInputStream(imageResource);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(
- fileInputStream);
- InputStream paintData = bufferedInputStream;
- if (null == paintData) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
- new Exception(""));
- return;
- }
- try {
- BufferedImage images = ImageIO.read(paintData);
- ImageIO.write(images, Constants.JPEG, out);
- } catch (Exception e) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
- new Exception(""));
- return;
- } finally {
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
- }
- public void start(){
- id=imageId;
- }
-}
\ No newline at end of file
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java (from rev 12864, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,67 @@
+package org.richfaces.realworld.util;
+
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+import javax.persistence.EntityManager;
+
+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.annotations.web.RequestParameter;
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.service.Constants;
+
+@Name("directLink")
+(a)Scope(ScopeType.SESSION)
+public class DirectLinkHelper {
+ @In(value="entityManager")
+ protected EntityManager em;
+ @In(create = true)
+ FileManager fileManager;
+ @RequestParameter
+ protected Long imageId;
+
+ private Long id;
+
+ public synchronized void paintImage(OutputStream out, Object data)
+ throws IOException {
+ Image im = em.find(Image.class, id);
+ File imageResource = fileManager.getImage(im.getPath());
+ if (imageResource != null) {
+ FileInputStream fileInputStream = new FileInputStream(imageResource);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(
+ fileInputStream);
+ InputStream paintData = bufferedInputStream;
+ if (null == paintData) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
+ new Exception(""));
+ return;
+ }
+ try {
+ BufferedImage images = ImageIO.read(paintData);
+ ImageIO.write(images, Constants.JPEG, out);
+ } catch (Exception e) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
+ new Exception(""));
+ return;
+ } finally {
+ fileInputStream.close();
+ bufferedInputStream.close();
+ paintData.close();
+ }
+ }
+ }
+ public void start(){
+ id=imageId;
+ }
+}
\ No newline at end of file
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java (from rev 12864, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/error/ErrorHandlerBean.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,66 @@
+/**
+ * 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.util.ArrayList;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.service.Constants;
+
+@Name("errorHandlerBean")
+(a)Scope(ScopeType.EVENT)
+@AutoCreate
+public class ErrorHandlerBean {
+ private List<Exception> errors = new ArrayList<Exception>();
+
+ public List<Exception> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(List<Exception> errors) {
+ this.errors = errors;
+ }
+
+ public boolean isErrorExist(){
+ return errors.size() > 0 ;
+ }
+
+ @Observer(Constants.CLEAR_ERROR_EVENT)
+ public void clearEvents(){
+ errors.clear();
+ }
+
+ @Observer(Constants.ADD_ERROR_EVENT)
+ public void addToErrors(Exception e){
+ FacesContext context = FacesContext.getCurrentInstance();
+ AjaxContext ac = AjaxContext.getCurrentInstance(context);
+ ac.addRenderedArea(Constants.ERROR_ID);
+ errors.add(e);
+ }
+}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,148 +0,0 @@
-/**
- *
- */
-package org.richfaces.realworld.util;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-
-import javax.imageio.ImageIO;
-import javax.imageio.stream.FileImageInputStream;
-import javax.imageio.stream.ImageInputStream;
-
-import org.richfaces.model.UploadItem;
-import org.richfaces.realworld.service.Constants;
-
-/**
- * @author Andrey Markavtsov
- *
- */
-public class ImageUtils {
-
- public static class ImageDimension {
- public int WIDTH;
- public int HEIGHT;
- public String POSTFIX_NAME;
- public ImageDimension(int width, int height, String postfix_name) {
- super();
- WIDTH = width;
- HEIGHT = height;
- POSTFIX_NAME = postfix_name;
- }
- };
-
- public static final String _MEDIUM = "_medium";
- public static final String _MINI = "_mini";
-
-
- public static ImageDimension MINI = new ImageDimension(100, 100, _MINI);
- public static ImageDimension MEDIUM = new ImageDimension(640, 480, _MEDIUM);
-
-
- BufferedImage bufferedImage;
-
- double width;
- double height;
-
- public ImageUtils(BufferedImage bufferedImage) {
- if (bufferedImage == null) {
- throw new NullPointerException("Buffered image is null");
- }
-
- this.height = bufferedImage.getHeight();
- this.width = bufferedImage.getWidth();
- this.bufferedImage = bufferedImage;
- }
-
- private BufferedImage scaleToWidth(int width) throws IOException {
- double height = width * this.height / this.width;
- BufferedImage newImage = new BufferedImage(width, (int) height,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics2D = createGraphics(newImage);
- graphics2D.drawImage(bufferedImage, 0, 0, (int) width, (int) height,
- null);
- return newImage;
- }
-
- private BufferedImage scaleToHeight(int height) throws IOException {
- double width = height * this.width / this.height;
- BufferedImage newImage = new BufferedImage((int) width, (int) height,
- BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics2D = createGraphics(newImage);
- graphics2D.drawImage(bufferedImage, 0, 0, (int) width, (int) height,
- null);
- return newImage;
- }
-
- private Graphics2D createGraphics(BufferedImage image) {
- Graphics2D graphics2D = image.createGraphics();
- graphics2D.setBackground(new Color(255, 255, 255));
- graphics2D.clearRect(0, 0, image.getWidth(), image.getHeight());
- graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- return graphics2D;
- }
-
- public BufferedImage resizeImage(double width, double height)
- throws IOException {
-
- if (width > height) {
- if (this.bufferedImage.getWidth() < width) {
- return bufferedImage;
- }
- return scaleToWidth((int) width);
- } else {
- if (this.bufferedImage.getHeight() < height) {
- return bufferedImage;
- }
- return scaleToHeight((int) height);
- }
-
- }
-
- public static void resizeImage(UploadItem image, String pathToUpload, ImageDimension ... dimensions)
- throws IOException {
-
- BufferedImage bufferedImage = ImageIO.read(new FileImageInputStream(image.getFile()));
-
- ImageUtils utils = new ImageUtils(bufferedImage);
- int width, height;
-
- ImageIO.write(bufferedImage, Constants.JPG, new File(pathToUpload));
-
- for (ImageDimension dimension : dimensions) {
- String fileName = transformPath(pathToUpload,dimension.POSTFIX_NAME);
- width = dimension.WIDTH;
- height = dimension.HEIGHT;
- BufferedImage resizedBuffer = bufferedImage;
-
- if (width > height) {
- if (bufferedImage.getWidth() > width) {
- resizedBuffer = utils.scaleToWidth((int) width);
- }
- } else {
- if (bufferedImage.getHeight() > height) {
- resizedBuffer = utils.scaleToHeight((int) height);
- }
- }
-
- if (resizedBuffer != null) {
- ImageIO.write(resizedBuffer, Constants.JPG, new File(fileName));
- }
-
- }
-
- }
-
- public static String transformPath(String target, String substitute){
- String begin = target.substring(0, target.lastIndexOf(Constants.DOT));
- String end = target.substring(target.lastIndexOf(Constants.DOT));
- return begin + substitute + end;
- }
-
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Model.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Model.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Model.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,99 +0,0 @@
-package org.richfaces.realworld.util;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-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("model")
-(a)Scope(ScopeType.CONVERSATION)
-public class Model {
-
-private Integer selectedImageIndex = 1;
-
- private Image selectedImage;
-
- private Album selectedAlbum;
-
- private User selectedUser;
-
- private Shelf selectedShelf;
-
- private MetaTag selectedTag;
-
- private NavigationEnum mainArea;
-
- public void resetModel(NavigationEnum mainArea, User selectedUser, Shelf selectedShelf, Album selectedAlbum, Image selectedImage, MetaTag selectedTag){
- this.setMainArea(mainArea);
- this.setSelectedAlbum(selectedAlbum);
- this.setSelectedImage(selectedImage);
- this.setSelectedShelf(selectedShelf);
- this.setSelectedTag(selectedTag);
- this.setSelectedUser(selectedUser);
- }
-
- @Observer(Constants.UPDATE_MAIN_AREA_EVENT)
- public void setMainArea(NavigationEnum mainArea) {
- this.mainArea = mainArea;
- }
-
- public Integer getSelectedImageIndex() {
- return selectedImageIndex;
- }
-
- public NavigationEnum getMainArea() {
- return mainArea;
- }
-
- 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 User getSelectedUser() {
- return selectedUser;
- }
-
- public void setSelectedUser(User selectedUser) {
- this.selectedUser = selectedUser;
- }
-
- public Shelf getSelectedShelf() {
- return selectedShelf;
- }
-
- public void setSelectedShelf(Shelf selectedShelf) {
- this.selectedShelf = selectedShelf;
- }
-
- public MetaTag getSelectedTag() {
- return selectedTag;
- }
-
- @Observer("updateSelectedTag")
- public void setSelectedTag(MetaTag selectedTag) {
- this.selectedTag = selectedTag;
- }
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RenderLogic.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RenderLogic.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RenderLogic.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,57 +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 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.User;
-import org.richfaces.realworld.service.Constants;
-
-@Name("renderLogic")
-(a)Scope(ScopeType.CONVERSATION)
-public class RenderLogic implements Serializable{
-
- @In User user;
- @In Identity identity;
-
- private static final long serialVersionUID = 5656562187249324512L;
-
- public boolean isUserGuest(){
- return !identity.hasRole(Constants.ADMIN_ROLE);
- }
-
- public boolean isAccessToAlbumGranted(Album album){
- return album.getOwner().equals(user) || album.getShelf().isShared();
- }
-
- public boolean isUserAlbum(Album album){
- if(album == null || album.getOwner() == null){
- return false;
- }
- return album.getOwner().equals(user);
- }
-}
Deleted: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/TreeManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/TreeManager.java 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/TreeManager.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -1,69 +0,0 @@
-package org.richfaces.realworld.util;
-
-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.Out;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Events;
-import org.richfaces.component.UITree;
-import org.richfaces.component.html.HtmlTree;
-import org.richfaces.event.NodeSelectedEvent;
-import org.richfaces.realworld.domain.Album;
-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("treeManager")
-(a)Scope(ScopeType.CONVERSATION)
-public class TreeManager implements Serializable{
-
- @In
- private User user;
- @In @Out Model model;
- private static final long serialVersionUID = 5656562187249324512L;
-
- @SuppressWarnings("unchecked")
- public Boolean adviseNodeSelected(UITree tree) {
- Object currentNode = tree.getRowData();
- if (currentNode instanceof Album) {
- boolean selected = currentNode == model.getSelectedAlbum();
- return selected;
- }else if(currentNode instanceof Shelf){
- return currentNode == model.getSelectedShelf() && model.getSelectedAlbum() == null;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public Boolean adviseNodeOpened(UITree tree) {
- Object currentNode = tree.getRowData();
- if (currentNode instanceof Album) {
- boolean selected = currentNode == model.getSelectedAlbum();
- return selected;
- }else if(currentNode instanceof Shelf){
- return currentNode == model.getSelectedShelf();
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public void processSelection(NodeSelectedEvent event) {
- HtmlTree tree = (HtmlTree) event.getComponent();
- Object currentNode = tree.getRowData();
- if(currentNode instanceof Album){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.ALBUM_PREVIEW);
- model.setSelectedAlbum((Album)currentNode);
- model.setSelectedShelf(((Album)currentNode).getShelf());
- }else if(currentNode instanceof Shelf){
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.SHELF_PREVIEW);
- model.setSelectedAlbum(null);
- model.setSelectedShelf((Shelf)currentNode);
- }
- model.setSelectedUser(user);
- model.setSelectedImage(null);
- }
-}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java (from rev 12864, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/test.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,181 @@
+package org.richfaces.realworld.util;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageInputStream;
+
+public class test {
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+ String directory ="E:\\realworldnew\\web\\src\\main\\webapp\\WEB-INF\\Upload\\Viking\\15";
+ writeFiles(directory, "_small80", 80);
+ writeFiles(directory, "_small120", 120);
+ writeFiles(directory, "_small160", 160);
+ writeFiles(directory, "_mini", 150);
+ writeFiles(directory, "_medium", 600);
+ }
+
+ private static void writeFiles(String directory, String pattern, int size) {
+ File f = new File(directory);
+ for(String s: f.list()){
+ if(s.endsWith(".jpg") && !s.endsWith("_mini.jpg")&& !s.endsWith("_medium.jpg")&& !s.endsWith("_small80.jpg")&& !s.endsWith("_small120.jpg") && !s.endsWith("_small160.jpg")){
+ BufferedImage bsrc =null;
+ try {
+ bsrc = bitmapToImage(directory +"\\"+ s, "JPG");
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ int i = bsrc.getWidth() > bsrc.getHeight()? bsrc.getWidth(): bsrc.getHeight();
+ int width2 = bsrc.getWidth();
+ double d = (double) size
+ / i;
+ Double yy = ((Double)d*bsrc.getWidth());
+ int width = yy.intValue();
+ yy = ((Double)d*bsrc.getHeight());
+ int height= yy.intValue();
+ BufferedImage bdest = getScaledInstance(bsrc, width, height, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
+ String dest = transformPath(directory +"\\"+ s, pattern);
+ try {
+ imageToBitmap(bdest, dest, "JPG");
+ } catch (IOException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private static String transformPath(String target, String substitute){
+ String begin = target.substring(0, target.lastIndexOf("."));
+ String end = target.substring(target.lastIndexOf("."));
+ return begin + substitute + end;
+ }
+
+ private static void generateTags(){
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("C:\\1114.txt"));
+ //String a ="INSERT INTO comments(comment_id, date, message, image_comment_id, from_user_id) VALUES ("+commentId+", '1985-01-08', 'Hello I am user',"+ imageId+", 2);\n"+ "INSERT INTO comments(comment_id, date, message, image_comment_id, from_user_id) VALUES ("+commentId2+", '1985-01-08', 'Hello I am user2',"+ imageId+", 3);\n";
+
+ //out.write("INSERT INTO IMAGES_METATAGS(CI_IMAGE_ID, CI_METATAG_ID) VALUES("+"1"+"," +"1"+ ");\n");
+ for(int i =2; i<84; i++){
+ String imageId =(new Integer(i)).toString();
+ String commentId = (new Integer(i*2 -1)).toString();
+ String commentId2 = (new Integer(i*2)).toString();
+ out.append("INSERT INTO comments(comment_id, date, message, image_comment_id, from_user_id) VALUES ("+commentId +", '1985-01-08', 'Hello I am user',"+ imageId+", 2);\n"+ "INSERT INTO comments(comment_id, date, message, image_comment_id, from_user_id) VALUES ("+commentId2+", '1985-01-08', 'Hello I am user2',"+ imageId+", 3);\n");
+ }
+ out.close();
+ } catch (IOException e) {
+ }
+
+ }
+
+ public static BufferedImage bitmapToImage(String data, String format) throws IOException {
+ InputStream inb = new FileInputStream(data);
+ ImageReader rdr = (ImageReader) ImageIO.getImageReadersByFormatName(format).next();
+ ImageInputStream imageInput = ImageIO.createImageInputStream(inb);
+ rdr.setInput(imageInput);
+ BufferedImage image = rdr.read(0);
+ inb.close();
+ return image;
+ }
+
+ public static void imageToBitmap(BufferedImage image, String data, String format) throws IOException {
+ OutputStream inb = new FileOutputStream(data);
+ ImageWriter wrt = (ImageWriter) ImageIO.getImageWritersByFormatName(format).next();
+ ImageInputStream imageInput = ImageIO.createImageOutputStream(inb);
+ wrt.setOutput(imageInput);
+ wrt.write(image);
+ inb.close();
+ }
+
+ /**
+ * Convenience method that returns a scaled instance of the
+ * provided {@code BufferedImage}.
+ *
+ * @param img the original image to be scaled
+ * @param targetWidth the desired width of the scaled instance,
+ * in pixels
+ * @param targetHeight the desired height of the scaled instance,
+ * in pixels
+ * @param hint one of the rendering hints that corresponds to
+ * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
+ * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
+ * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
+ * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
+ * @param higherQuality if true, this method will use a multi-step
+ * scaling technique that provides higher quality than the usual
+ * one-step technique (only useful in downscaling cases, where
+ * {@code targetWidth} or {@code targetHeight} is
+ * smaller than the original dimensions, and generally only when
+ * the {@code BILINEAR} hint is specified)
+ * @return a scaled version of the original {@code BufferedImage}
+ */
+ public static BufferedImage getScaledInstance(BufferedImage img,
+ int targetWidth,
+ int targetHeight,
+ Object hint,
+ boolean higherQuality)
+ {
+ int type = (img.getTransparency() == Transparency.OPAQUE) ?
+ BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
+ BufferedImage ret = (BufferedImage)img;
+ int w, h;
+ if (higherQuality) {
+ // Use multi-step technique: start with original size, then
+ // scale down in multiple passes with drawImage()
+ // until the target size is reached
+ w = img.getWidth();
+ h = img.getHeight();
+ } else {
+ // Use one-step technique: scale directly from original
+ // size to target size with a single drawImage() call
+ w = targetWidth;
+ h = targetHeight;
+ }
+
+ do {
+ if (higherQuality && w > targetWidth) {
+ w /= 2;
+ if (w < targetWidth) {
+ w = targetWidth;
+ }
+ }
+
+ if (higherQuality && h > targetHeight) {
+ h /= 2;
+ if (h < targetHeight) {
+ h = targetHeight;
+ }
+ }
+
+ BufferedImage tmp = new BufferedImage(w, h, type);
+ Graphics2D g2 = tmp.createGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
+ g2.drawImage(ret, 0, 0, w, h, null);
+ g2.dispose();
+
+ ret = tmp;
+ } while (w != targetWidth || h != targetHeight);
+
+ return ret;
+ }
+}
Copied: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java (from rev 12864, trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/test2.java)
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java (rev 0)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test2.java 2009-03-11 13:03:18 UTC (rev 12917)
@@ -0,0 +1,113 @@
+package org.richfaces.realworld.util;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageInputStream;
+public class test2 {
+ public static BufferedImage bitmapToImage(String data, String format) throws IOException {
+ InputStream inb = new FileInputStream(data);
+ ImageReader rdr = (ImageReader) ImageIO.getImageReadersByFormatName(format).next();
+ ImageInputStream imageInput = ImageIO.createImageInputStream(inb);
+ rdr.setInput(imageInput);
+ BufferedImage image = rdr.read(0);
+ inb.close();
+ return image;
+ }
+
+ public static void imageToBitmap(BufferedImage image, String data, String format) throws IOException {
+ OutputStream inb = new FileOutputStream(data);
+ ImageWriter wrt = (ImageWriter) ImageIO.getImageWritersByFormatName(format).next();
+ ImageInputStream imageInput = ImageIO.createImageOutputStream(inb);
+ wrt.setOutput(imageInput);
+ wrt.write(image);
+ inb.close();
+ }
+
+ /**
+ * Convenience method that returns a scaled instance of the
+ * provided {@code BufferedImage}.
+ *
+ * @param img the original image to be scaled
+ * @param targetWidth the desired width of the scaled instance,
+ * in pixels
+ * @param targetHeight the desired height of the scaled instance,
+ * in pixels
+ * @param hint one of the rendering hints that corresponds to
+ * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
+ * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
+ * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
+ * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
+ * @param higherQuality if true, this method will use a multi-step
+ * scaling technique that provides higher quality than the usual
+ * one-step technique (only useful in downscaling cases, where
+ * {@code targetWidth} or {@code targetHeight} is
+ * smaller than the original dimensions, and generally only when
+ * the {@code BILINEAR} hint is specified)
+ * @return a scaled version of the original {@code BufferedImage}
+ */
+ public static BufferedImage getScaledInstance(BufferedImage img,
+ int targetWidth,
+ int targetHeight,
+ Object hint,
+ boolean higherQuality)
+ {
+ int type = (img.getTransparency() == Transparency.OPAQUE) ?
+ BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
+ BufferedImage ret = (BufferedImage)img;
+ int w, h;
+ if (higherQuality) {
+ // Use multi-step technique: start with original size, then
+ // scale down in multiple passes with drawImage()
+ // until the target size is reached
+ w = img.getWidth();
+ h = img.getHeight();
+ } else {
+ // Use one-step technique: scale directly from original
+ // size to target size with a single drawImage() call
+ w = targetWidth;
+ h = targetHeight;
+ }
+
+ do {
+ if (higherQuality && w > targetWidth) {
+ w /= 2;
+ if (w < targetWidth) {
+ w = targetWidth;
+ }
+ }
+
+ if (higherQuality && h > targetHeight) {
+ h /= 2;
+ if (h < targetHeight) {
+ h = targetHeight;
+ }
+ }
+
+ BufferedImage tmp = new BufferedImage(w, h, type);
+ Graphics2D g2 = tmp.createGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
+ g2.drawImage(ret, 0, 0, w, h, null);
+ g2.dispose();
+
+ ret = tmp;
+ } while (w != targetWidth || h != targetHeight);
+
+ return ret;
+ }
+ public static void main(String[] args) throws Exception {
+ BufferedImage bitmapToImage = bitmapToImage("E:\\realworldnew\\web\\src\\main\\webapp\\WEB-INF\\Upload\\amarkhel\\20\\sport (14).jpg", "JPG");
+ BufferedImage scaledInstance = getScaledInstance(bitmapToImage, 80, 60, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
+ imageToBitmap(scaledInstance, "E:\\realworldnew\\web\\src\\main\\webapp\\WEB-INF\\Upload\\amarkhel\\20\\sport (14)_copy.jpg", "JPG");
+ }
+}
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/album/userAlbumsPreview.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imagePreview.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/image/shelf.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-03-11 10:56:05 UTC (rev 12916)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-03-11 13:03:18 UTC (rev 12917)
@@ -15,7 +15,7 @@
<a4j:mediaOutput element="img" createContent="#{imageLoader.paintImage}"
styleClass="all-images"
value="#{fileManager.transformPath(item.path, '_mini')}">
- <rich:dragSupport rendered="#{renderLogic.isUserAlbum(item.album)}"
+ <rich:dragSupport rendered="#{controller.isUserAlbum(item.album)}"
dragIndicator="dragIndicator" dragType="image" dragValue="#{item}"
reRender=" mainArea">
<rich:dndParam name="label" value="#{item.name}" />
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/userShelfPreview.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/layout/template3.xhtml
===================================================================
(Binary files differ)
15 years, 10 months
JBoss Rich Faces SVN: r12916 - trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-03-11 06:56:05 -0400 (Wed, 11 Mar 2009)
New Revision: 12916
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree.xhtml
Removed:
trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree2.xhtml
Log:
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree.xhtml
===================================================================
(Binary files differ)
Copied: trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree.xhtml (from rev 12895, trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree2.xhtml)
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/includes/panelBar/tree2.xhtml
===================================================================
(Binary files differ)
15 years, 10 months