Author: amarkhel
Date: 2009-01-26 10:55:56 -0500 (Mon, 26 Jan 2009)
New Revision: 12425
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java
Removed:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/singleMode.xhtml
trunk/test-applications/realworld/web/src/main/webapp/includes/search/advancedSearch.xhtml
Log:
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -83,7 +83,7 @@
public static final String USER_AVAILABLE_USERS_QUERY =
"user-availableUsers";
public static final String USER_EXIST_QUERY = "user-exist";
public static final String USER_LOGIN_QUERY = "user-login";
- public static final String USER_ROOT_ALBUMS_QUERY = "user-login";
+ public static final String USER_ROOT_ALBUMS_QUERY = "user-rootAlbums";
public static final String FRIEND_PARAMETER = "friend";
public static final String PERCENT = "%";
public static final String LOGIN_PARAMETER = "login";
@@ -126,6 +126,21 @@
public static final String USER_COUNT_MESSAGES_QUERY = "user-countMessages";
public static final String ALBUM_BY_ALBUM_NAME_AND_LOGIN_QUERY =
"album-byAlbumNameAndLogin";
public static final String ALBUM_NAME_PARAMETER = "albumName";
+ public static final String EQUALS = "= ";
+ public static final String LESSTHEN = "< ";
+ public static final String GREATTHEN = "> ";
+ public static final String DATE_ADDON = " and i.created";
+ public static final String UPLOAD_ADDON = " and i.upload";
+ public static final String HEIGHT_ADDON = " and i.height";
+ public static final String SIZE_ADDON = " and i.size";
+ public static final String WIDTH_ADDON = " and i.width";
+ public static final String CAMERA_ADDON = " and i.cameraModel";
+ public static final String VOTES_ADDON = " and i.rank.hits";
+ public static final String SPINNER_ADDON = " and i.rank.total/i.rank.hits";
+ public static final String STRICT = "STRICT";
+ public static final String INCLUDE = "INCLUDE";
+ public static final String END = "END";
+ public static final String START = "START";
private Constants(){
}
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ISearchService.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -31,9 +31,9 @@
public abstract List<Image> searchImages(String searchPattern, String
additionalParams, Map<String, Object> paramMap);
- public List<Image> popularImages(String additionalParams, Map<String,
Object> paramMap);
+ public List<Image> popularImages();
- public List<Image> worstImages(String additionalParams, Map<String, Object>
paramMap);
+ public List<Image> worstImages();
public abstract List<String> getAllCameras();
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -65,49 +65,63 @@
additions.remove(0);
return filter(tempResult, additions, removals);
}
-
- private List<Image> filter(List<Image> tempResult, List<String>
additions,
- List<String> removals) {
- List<Image> result = new ArrayList<Image>();
- result.addAll(tempResult);
- for(Image i : tempResult){
- for(String a:additions){
- if(!i.containTag(a)){
- result.remove(i);
- break;
- }
- }
- }
- tempResult.clear();
- tempResult.addAll(result);
- for(Image i : result){
- for(String a:removals){
- if(i.containTag(a)){
- tempResult.remove(i);
- break;
- }
- }
- }
- return tempResult;
- }
@SuppressWarnings("unchecked")
- public List<Image> popularImages(String additionalParams, Map<String,
Object> paramMap){
- String fullQuery = Constants.SEARCH_RELEVANT_QUERY_BEGIN + additionalParams +
Constants.SEARCH_POPULAR_QUERY_END;
- Query prepared = prepareQuery(fullQuery, null, additionalParams, paramMap);
+ public List<Image> popularImages(){
+ String fullQuery = Constants.SEARCH_RELEVANT_QUERY_BEGIN +
Constants.SEARCH_POPULAR_QUERY_END;
+ Query prepared = em.createQuery(fullQuery).setMaxResults(20);
return prepared.getResultList();
}
@SuppressWarnings("unchecked")
- public List<Image> worstImages(String additionalParams, Map<String, Object>
paramMap){
- String fullQuery = Constants.SEARCH_RELEVANT_QUERY_BEGIN + additionalParams +
Constants.SEARCH_UNPOPULAR_QUERY_END;
- Query prepared = prepareQuery(fullQuery, null, additionalParams, paramMap);
+ public List<Image> worstImages(){
+ String fullQuery = Constants.SEARCH_RELEVANT_QUERY_BEGIN +
Constants.SEARCH_UNPOPULAR_QUERY_END;
+ Query prepared = em.createQuery(fullQuery).setMaxResults(20);
return prepared.getResultList();
}
+
+ @SuppressWarnings("unchecked")
+ public List<String> getAllCameras() {
+ Query query = em.createNamedQuery(Constants.IMAGE_CAMERA_QUERY);
+ return (List<String>)query.getResultList();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<String> getAllMetatags() {
+ Query query = em.createNamedQuery(Constants.IMAGE_TAGS_QUERY);
+ return (List<String>)query.getResultList();
+ }
private Query prepareQuery(String fullQuery ,String searchPattern, String
additionalParams,
Map<String, Object> paramMap) {
Query prepared = em.createQuery(fullQuery);
+ setPattern(searchPattern, paramMap, prepared);
+ setParameters(paramMap, prepared);
+ prepared.setMaxResults(20);
+ return prepared;
+ }
+
+ private void setParameters(Map<String, Object> paramMap, Query prepared) {
+ if(paramMap != null){
+ setParameter(paramMap, prepared, Constants.SPINNER_VALUE_NAMED_PARAMETER,
Constants.SPINNER_VALUE_PARAMETER);
+ setParameter(paramMap, prepared, Constants.CHOICE_NAMED_PARAMETER,
Constants.CHOICE_PARAMETER);
+ setParameter(paramMap, prepared, Constants.DATE_NAMED_PARAMETER,
Constants.DATE_PARAMETER);
+ setParameter(paramMap, prepared, Constants.UPLOAD_NAMED_PARAMETER,
Constants.UPLOAD_PARAMETER);
+ setParameter(paramMap, prepared, Constants.WIDTH_NAMED_PARAMETER,
Constants.WIDTH_PARAMETER);
+ setParameter(paramMap, prepared, Constants.HEIGHT_NAMED_PARAMETER,
Constants.HEIGHT_PARAMETER);
+ setParameter(paramMap, prepared, Constants.SIZE_NAMED_PARAMETER,
Constants.SIZE_PARAMETER);
+ setParameter(paramMap, prepared, Constants.CAMERA_NAMED_PARAMETER,
Constants.CAMERA_PARAMETER);
+ }
+ }
+
+ private void setParameter(Map<String, Object> paramMap, Query prepared, String
parameter, String holder){
+ if(paramMap.get(parameter) != null){
+ prepared.setParameter(holder, paramMap.get(parameter));
+ }
+ }
+
+ private void setPattern(String searchPattern, Map<String, Object> paramMap,
+ Query prepared) {
if(searchPattern != null){
if(paramMap != null && paramMap.get(Constants.STRICT_PARAMETER) != null){
String strict = paramMap.get(Constants.STRICT_PARAMETER).toString();
@@ -124,45 +138,32 @@
prepared.setParameter(Constants.METATAG_PARAMETER,
searchPattern.toUpperCase()+Constants.PERCENT);
}
}
- if(paramMap != null && paramMap.get(Constants.SPINNER_VALUE_NAMED_PARAMETER) !=
null){
- prepared.setParameter(Constants.SPINNER_VALUE_PARAMETER,
paramMap.get(Constants.SPINNER_VALUE_NAMED_PARAMETER));
+ }
+
+ private List<Image> filter(List<Image> tempResult, List<String>
additions,
+ List<String> removals) {
+ List<Image> result = new ArrayList<Image>();
+ result.addAll(tempResult);
+ for(Image i : tempResult){
+ for(String a:additions){
+ if(!i.containTag(a)){
+ result.remove(i);
+ break;
+ }
+ }
}
- if(paramMap != null && paramMap.get(Constants.CHOICE_NAMED_PARAMETER) !=
null){
- prepared.setParameter(Constants.CHOICE_PARAMETER,
paramMap.get(Constants.CHOICE_NAMED_PARAMETER));
+ tempResult.clear();
+ tempResult.addAll(result);
+ for(Image i : result){
+ for(String a:removals){
+ if(i.containTag(a)){
+ tempResult.remove(i);
+ break;
+ }
+ }
}
- if(paramMap != null && paramMap.get(Constants.DATE_NAMED_PARAMETER) != null){
- prepared.setParameter(Constants.DATE_PARAMETER,
paramMap.get(Constants.DATE_NAMED_PARAMETER));
- }
- if(paramMap != null && paramMap.get(Constants.UPLOAD_NAMED_PARAMETER) !=
null){
- prepared.setParameter(Constants.UPLOAD_PARAMETER,
paramMap.get(Constants.UPLOAD_NAMED_PARAMETER));
- }
- if(paramMap != null && paramMap.get(Constants.WIDTH_NAMED_PARAMETER) != null){
- prepared.setParameter(Constants.WIDTH_PARAMETER,
paramMap.get(Constants.WIDTH_NAMED_PARAMETER));
- }
- if(paramMap != null && paramMap.get(Constants.HEIGHT_NAMED_PARAMETER) !=
null){
- prepared.setParameter(Constants.HEIGHT_PARAMETER,
paramMap.get(Constants.HEIGHT_NAMED_PARAMETER));
- }
- if(paramMap != null && paramMap.get(Constants.SIZE_NAMED_PARAMETER) != null){
- prepared.setParameter(Constants.SIZE_PARAMETER,
paramMap.get(Constants.SIZE_NAMED_PARAMETER));
- }
- if(paramMap != null && paramMap.get(Constants.CAMERA_NAMED_PARAMETER) !=
null){
- prepared.setParameter(Constants.CAMERA_PARAMETER,
paramMap.get(Constants.CAMERA_NAMED_PARAMETER));
- }
- prepared.setMaxResults(20);
- return prepared;
+ return tempResult;
}
-
- @SuppressWarnings("unchecked")
- public List<String> getAllCameras() {
- Query query = em.createNamedQuery(Constants.IMAGE_CAMERA_QUERY);
- return (List<String>)query.getResultList();
- }
-
- @SuppressWarnings("unchecked")
- public List<String> getAllMetatags() {
- Query query = em.createNamedQuery(Constants.IMAGE_TAGS_QUERY);
- return (List<String>)query.getResultList();
- }
private boolean parse(String str, List<String> adds, List<String> removes){
str = str.trim();
@@ -200,7 +201,6 @@
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(Constants.INVALID_SYNTAX));
return false;
}
-
}else if(c == Constants.MINUS_SIGN){
if(signedPreviousChar == false){
curIndex = i;
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
===================================================================
---
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -67,7 +67,7 @@
@SuppressWarnings("unchecked")
public List<Album> getRootAlbums(User user) {
List<Album> albums = em.createNamedQuery(Constants.USER_ROOT_ALBUMS_QUERY)
- .setParameter("login", user.getLogin())
+ .setParameter(Constants.LOGIN_PARAMETER, user.getLogin())
.getResultList();
return albums;
}
@@ -81,7 +81,7 @@
@SuppressWarnings("unchecked")
public List<Message> getOutgoingMessages(){
List<Message> messages = em.createNamedQuery(Constants.USER_OUTCOMING_MESSAGES)
- .setParameter("login", user.getLogin())
+ .setParameter(Constants.LOGIN_PARAMETER, user.getLogin())
.getResultList();
return messages;
}
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -83,18 +83,20 @@
}
}
- public void renameDirectory(String directoryOld, String directoryNew) throws Exception{
+ public boolean renameDirectory(String directoryOld, String directoryNew){
String fullPath = getAbsolutePath(directoryOld);
File fileOld = new File(fullPath);
File fileNew = new File(getUploadRoot() + directoryNew);
createDirectoryIfNotExist(directoryNew);
if(fileNew.exists())
if( fileNew.isDirectory() ){
- throw new Exception(Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
+ //throw new Exception(Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
+ return false;
}else{
fileNew.delete();
}
fileOld.renameTo(fileNew);
+ return true;
}
public void addDirectory(String directory) {
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -63,8 +63,6 @@
@Scope(ScopeType.CONVERSATION)
public class FileUploadBean implements Serializable {
-
-
@In
private User user;
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -42,8 +42,6 @@
@Scope(ScopeType.CONVERSATION)
public class ImageLoader implements Serializable{
-
-
private static final long serialVersionUID = -1572789608594870285L;
@In(create=true)
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -60,8 +60,6 @@
@In @Out
private ConversationState conversationState;
- private static final String ADD_ERROR_EVENT = "addErrorEvent";
-
public void addAlbum(){
//Update domain model
albumAction.addAlbum(album);
@@ -95,10 +93,8 @@
String directoryOld = user.getLogin() + fileManager.getFileSeparator() +
album.getAlbumPathFromParents(album, new
ArrayList<String>(),fileManager.getFileSeparator() )+album.getName();
Album oldAlbum =
((TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName())).getAlbum();
String directoryNew = user.getLogin() + fileManager.getFileSeparator() +
oldAlbum.getAlbumPathFromParents(oldAlbum, new
ArrayList<String>(),fileManager.getFileSeparator() )+album.getChangedName();
- try {
- fileManager.renameDirectory(directoryOld, directoryNew);
- } catch (Exception e) {
- Events.instance().raiseEvent(ADD_ERROR_EVENT, e);
+ if(!fileManager.renameDirectory(directoryOld, directoryNew)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return;
}
String albumOld = user.getLogin() + Constants.SLASH +
album.getAlbumPathFromParents(album, new ArrayList<String>(),Constants.SLASH
)+album.getName();
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -83,10 +83,8 @@
}
String directoryOld = user.getLogin() + fileManager.getFileSeparator() +
dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(),
fileManager.getFileSeparator() )+ dragValue.getName();
String directoryNew = user.getLogin() + fileManager.getFileSeparator() +
dragValue.getName();
- try{
- fileManager.renameDirectory(directoryOld, directoryNew);
- } catch (Exception e) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, e);
+ if(!fileManager.renameDirectory(directoryOld, directoryNew)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return;
}
String albumOld = user.getLogin() + Constants.SLASH +
dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(),
Constants.SLASH );
@@ -132,10 +130,8 @@
TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
itemParent.removeChild(item.getId());
itemParentNew.addAlbum(item);
- try{
- fileManager.renameDirectory(directoryOld, directoryNew);
- } catch (Exception e) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, e);
+ if(!fileManager.renameDirectory(directoryOld, directoryNew)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return;
}
albumAction.renameAllImagesFromAlbumAndChilds(dragValue, albumOld, albumNew);
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -27,390 +27,135 @@
import java.util.List;
import java.util.Map;
-import javax.faces.model.SelectItem;
-
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.ISearchService;
-import org.richfaces.realworld.service.SearchService;
@Name("searchBean")
@Scope(ScopeType.CONVERSATION)
public class SearchBean implements Serializable {
- @In("#{messages['equals']}") private String EQUALS_CHOICE;
- @In("#{messages['less']}") private String LESS_CHOICE;
- @In("#{messages['more']}") private String MORE_CHOICE;
- @In("#{messages['nomatter']}") private String NO_MATTER_CHOICE;
+ @In(required = false)
+ private SearchBeanHelper helper;
- private static final String EQUALS = "= ";
+ @In(required = false)
+ private SearchParamHolder searchParams;
- private static final String LESSTHEN = "< ";
-
- private static final String GREATTHEN = "> ";
-
- private static final String DATE_ADDON = " and i.created";
-
- private static final String UPLOAD_ADDON = " and i.upload";
-
- private static final String HEIGHT_ADDON = " and i.height";
-
- private static final String SIZE_ADDON = " and i.size";
-
- private static final String WIDTH_ADDON = " and i.width";
-
- private static final String CAMERA_ADDON = " and i.cameraModel";
-
- private static final String VOTES_ADDON = " and i.rank.hits";
-
- private static final String SPINNER_ADDON = " and i.rank.total/i.rank.hits";
-
private static final long serialVersionUID = 5071655218132021316L;
- private boolean caseSensitive;
-
- @In(required=false)
- private SearchBeanHelper helper;
-
@In(create=true)
private ISearchService searchService;
- private String searchPattern;
-
- private Long matcherChoice;
-
- private Long spinnerChoice;
-
- private Long uploadChoice;
-
- private Long sizeChoice;
-
- private Long widthChoice;
-
- private Long heightChoice;
-
- private Long dateChoice;
-
- private Long votesChoice;
-
- private Long numberOfVotes;
-
- private Date date;
-
- private String camera;
-
- private int height;
-
- private double size;
-
- private int width;
-
- private Date uploadDate;
-
private List<Image> findedImages = new ArrayList<Image>();
- public List<SelectItem> getItems() {
- List<SelectItem> list = new ArrayList<SelectItem>(4);
- list.add(new SelectItem(Long.valueOf(0L), NO_MATTER_CHOICE));
- list.add(new SelectItem(Long.valueOf(1L), MORE_CHOICE));
- list.add(new SelectItem(Long.valueOf(2L), LESS_CHOICE));
- list.add(new SelectItem(Long.valueOf(3L), EQUALS_CHOICE));
- return list;
- }
-
- public List<SelectItem> getMatchItems() {
- List<SelectItem> list = new ArrayList<SelectItem>(4);
- list.add(new SelectItem(Long.valueOf(0L), "Strict"));
- list.add(new SelectItem(Long.valueOf(1L), "Start with"));
- list.add(new SelectItem(Long.valueOf(2L), "End with"));
- list.add(new SelectItem(Long.valueOf(3L), "Include"));
- return list;
- }
-
- private String getAstFromIndex(Long item){
- if(item == 1L){
- return GREATTHEN;
- }else if(item == 2L){
- return LESSTHEN;
- }else if(item == 3L){
- return EQUALS;
- }
- return null;
+ public List<String> getAllCameras(){
+ return searchService.getAllCameras();
}
- private String getMatcher(Long item){
- if(item == 1L){
- return "START";
- }else if(item == 2L){
- return "END";
- }else if(item == 3L){
- return "INCLUDE";
- }else if(item == 0L){
- return "STRICT";
- }
- return null;
+ public List<String> getAllMetatags(){
+ return searchService.getAllMetatags();
}
public List<Image> searchImages(){
String additionalParams = populateAdditionalParams();
- Map<String, Object> paramMap = null;
- paramMap = populateMap(additionalParams);
- findedImages = searchService.searchImages(this.searchPattern, additionalParams,
paramMap);
+ findedImages = searchService.searchImages(searchParams.getSearchPattern(),
additionalParams, populateMap(additionalParams));
return findedImages;
}
public List<Image> popularImages(){
- String additionalParams = populateAdditionalParams();
- Map<String, Object> paramMap = null;
- paramMap = populateMap(additionalParams);
- findedImages = searchService.popularImages(additionalParams, paramMap);
- return findedImages;
+ return searchService.popularImages();
}
+ public List<Image> worstImages(){
+ return searchService.worstImages();
+ }
+
private Map<String, Object> populateMap(String additionalParams) {
Map<String, Object> map = new HashMap<String, Object>();
- if(additionalParams.lastIndexOf(SearchService.SPINNER_VALUE_NAMED_PARAMETER) != -1){
- map.put(SearchService.SPINNER_VALUE_NAMED_PARAMETER,
Long.valueOf(helper.getInputSpinner().getValue().toString()));
+ populateParameter(map, additionalParams, Constants.SPINNER_VALUE_NAMED_PARAMETER,
Long.valueOf(helper.getInputSpinner().getValue().toString()));
+ populateParameter(map, additionalParams, Constants.CHOICE_NAMED_PARAMETER,
searchParams.getNumberOfVotes());
+ populateParameter(map, additionalParams, Constants.DATE_NAMED_PARAMETER,
searchParams.getDate());
+ populateParameter(map, additionalParams, Constants.UPLOAD_NAMED_PARAMETER,
searchParams.getUploadDate());
+ populateParameter(map, additionalParams, Constants.SIZE_NAMED_PARAMETER,
searchParams.getSize());
+ populateParameter(map, additionalParams, Constants.WIDTH_NAMED_PARAMETER,
searchParams.getWidth());
+ populateParameter(map, additionalParams, Constants.HEIGHT_NAMED_PARAMETER,
searchParams.getHeight());
+ populateParameter(map, additionalParams, Constants.CAMERA_NAMED_PARAMETER,
searchParams.getCamera());
+ if(searchParams.getMatcherChoice() != null){
+ map.put(Constants.STRICT_PARAMETER, getMatcher(searchParams.getMatcherChoice()));
}
- if(additionalParams.lastIndexOf(SearchService.CHOICE_NAMED_PARAMETER) != -1){
- map.put(SearchService.CHOICE_NAMED_PARAMETER, numberOfVotes);
- }
- if(additionalParams.lastIndexOf(SearchService.DATE_NAMED_PARAMETER) != -1){
- map.put(SearchService.DATE_NAMED_PARAMETER, date);
- }
- if(additionalParams.lastIndexOf(SearchService.UPLOAD_NAMED_PARAMETER) != -1){
- map.put(SearchService.UPLOAD_NAMED_PARAMETER, uploadDate);
- }
- if(additionalParams.lastIndexOf(SearchService.SIZE_NAMED_PARAMETER) != -1){
- map.put(SearchService.SIZE_NAMED_PARAMETER, size);
- }
- if(additionalParams.lastIndexOf(SearchService.WIDTH_NAMED_PARAMETER) != -1){
- map.put(SearchService.WIDTH_NAMED_PARAMETER, width);
- }
- if(additionalParams.lastIndexOf(SearchService.HEIGHT_NAMED_PARAMETER) != -1){
- map.put(SearchService.HEIGHT_NAMED_PARAMETER, height);
- }
- if(additionalParams.lastIndexOf(SearchService.CAMERA_NAMED_PARAMETER) != -1){
- map.put(SearchService.CAMERA_NAMED_PARAMETER, camera);
- }
- if(matcherChoice != null){
- map.put(SearchService.STRICT_PARAMETER, getMatcher(matcherChoice));
- }
- map.put(SearchService.CASE_SENSITIVE_PARAMETER, caseSensitive);
+ map.put(Constants.CASE_SENSITIVE_PARAMETER, searchParams.isCaseSensitive());
return map;
}
private String populateAdditionalParams() {
StringBuilder additionalParams = new StringBuilder("");
- if(spinnerChoice != null && spinnerChoice > 0L){
- additionalParams.append(SPINNER_ADDON);
- additionalParams.append(getAstFromIndex(spinnerChoice));
- additionalParams.append(SearchService.SPINNER_VALUE_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getSpinnerChoice(),
Constants.SPINNER_ADDON, Constants.SPINNER_VALUE_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getVotesChoice(),
Constants.VOTES_ADDON, Constants.CHOICE_NAMED_PARAMETER);
+ populateDateAddon(additionalParams, searchParams.getDateChoice(), Constants.DATE_ADDON,
Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
+ populateDateAddon(additionalParams, searchParams.getUploadChoice(),
Constants.UPLOAD_ADDON, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
+ populateChoiceAddon(additionalParams, searchParams.getWidthChoice(),
Constants.WIDTH_ADDON, Constants.WIDTH_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getHeightChoice(),
Constants.HEIGHT_ADDON, Constants.HEIGHT_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getSizeChoice(),
Constants.SIZE_ADDON, Constants.SIZE_NAMED_PARAMETER);
+ if(searchParams.getCamera()!= null &&
!searchParams.getCamera().equals("")){
+ additionalParams.append(Constants.CAMERA_ADDON);
+ additionalParams.append(Constants.EQUALS);
+ additionalParams.append(Constants.CAMERA_NAMED_PARAMETER);
}
- if(votesChoice != null && votesChoice > 0L){
- additionalParams.append(VOTES_ADDON);
- additionalParams.append(getAstFromIndex(votesChoice));
- additionalParams.append(SearchService.CHOICE_NAMED_PARAMETER);
- }
- if(dateChoice != null && dateChoice > 0L && date != null){
- additionalParams.append(DATE_ADDON);
- additionalParams.append(getAstFromIndex(dateChoice));
- additionalParams.append(SearchService.DATE_NAMED_PARAMETER);
- }
- if(uploadChoice != null && uploadChoice > 0L && uploadDate !=
null){
- additionalParams.append(UPLOAD_ADDON);
- additionalParams.append(getAstFromIndex(uploadChoice));
- additionalParams.append(SearchService.UPLOAD_NAMED_PARAMETER);
- }
- if(widthChoice != null && widthChoice > 0L){
- additionalParams.append(WIDTH_ADDON);
- additionalParams.append(getAstFromIndex(widthChoice));
- additionalParams.append(SearchService.WIDTH_NAMED_PARAMETER);
- }
- if(heightChoice != null && heightChoice > 0L){
- additionalParams.append(HEIGHT_ADDON);
- additionalParams.append(getAstFromIndex(heightChoice));
- additionalParams.append(SearchService.HEIGHT_NAMED_PARAMETER);
- }
- if(sizeChoice != null && sizeChoice > 0L){
- additionalParams.append(SIZE_ADDON);
- additionalParams.append(getAstFromIndex(sizeChoice));
- additionalParams.append(SearchService.SIZE_NAMED_PARAMETER);
- }
- if(camera!= null && !camera.equals("")){
- additionalParams.append(CAMERA_ADDON);
- additionalParams.append(EQUALS);
- additionalParams.append(SearchService.CAMERA_NAMED_PARAMETER);
- }
return additionalParams.toString();
}
- public List<Image> worstImages(){
- String additionalParams = populateAdditionalParams();
- Map<String, Object> paramMap = null;
- if(!additionalParams.equals("")){
- paramMap = populateMap(additionalParams);
+ private String getAstFromIndex(Long item){
+ if(item == 1L){
+ return Constants.GREATTHEN;
+ }else if(item == 2L){
+ return Constants.LESSTHEN;
+ }else if(item == 3L){
+ return Constants.EQUALS;
}
- findedImages = searchService.worstImages(additionalParams, paramMap);
- return findedImages;
+ return null;
}
-
- public List<String> getAllCameras(){
- List<String> cameras = new ArrayList<String>();
- cameras = searchService.getAllCameras();
- return cameras;
+
+ private String getMatcher(Long item){
+ if(item == 1L){
+ return Constants.START;
+ }else if(item == 2L){
+ return Constants.END;
+ }else if(item == 3L){
+ return Constants.INCLUDE;
+ }else if(item == 0L){
+ return Constants.STRICT;
+ }
+ return null;
}
- public List<String> getAllMetatags(){
- List<String> metatags = new ArrayList<String>();
- metatags = searchService.getAllMetatags();
- return metatags;
+ private void populateParameter(Map<String, Object> map, String additionalParams,
String parameter, Object value){
+ if(additionalParams.lastIndexOf(parameter) != -1){
+ map.put(parameter, value);
+ }
}
- public String getSearchPattern() {
- return searchPattern;
+ private void populateChoiceAddon(StringBuilder additionalParams, Long choice, String
addon, String namedParameter){
+ if(choice != null && choice > 0L){
+ additionalParams.append(addon);
+ additionalParams.append(getAstFromIndex(choice));
+ additionalParams.append(namedParameter);
+ }
}
-
- public void setSearchPattern(String searchPattern) {
- this.searchPattern = searchPattern;
+
+ private void populateDateAddon(StringBuilder additionalParams, Long choice, String
addon, String namedParameter, Date date){
+ if(choice != null && choice > 0L && date != null ){
+ additionalParams.append(addon);
+ additionalParams.append(getAstFromIndex(choice));
+ additionalParams.append(namedParameter);
+ }
}
- public Long getSpinnerChoice() {
- return spinnerChoice;
- }
-
- public void setSpinnerChoice(Long spinnerChoice) {
- this.spinnerChoice = spinnerChoice;
- }
-
- public Long getDateChoice() {
- return dateChoice;
- }
-
- public void setDateChoice(Long dateChoice) {
- this.dateChoice = dateChoice;
- }
-
- public Long getVotesChoice() {
- return votesChoice;
- }
-
- public void setVotesChoice(Long votesChoice) {
- this.votesChoice = votesChoice;
- }
-
- public Long getNumberOfVotes() {
- return numberOfVotes;
- }
-
- public void setNumberOfVotes(Long numberOfVotes) {
- this.numberOfVotes = numberOfVotes;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
public List<Image> getFindedImages() {
return findedImages;
}
-
- public void setFindedImages(List<Image> findedImages) {
- this.findedImages = findedImages;
- }
-
- public String getCamera() {
- return camera;
- }
-
- public void setCamera(String camera) {
- this.camera = camera;
- }
-
- public int getHeight() {
- return height;
- }
-
- public void setHeight(int height) {
- this.height = height;
- }
-
- public double getSize() {
- return size;
- }
-
- public void setSize(double size) {
- this.size = size;
- }
-
- public int getWidth() {
- return width;
- }
-
- public void setWidth(int width) {
- this.width = width;
- }
-
- public Date getUploadDate() {
- return uploadDate;
- }
-
- public void setUploadDate(Date uploadDate) {
- this.uploadDate = uploadDate;
- }
-
- public Long getUploadChoice() {
- return uploadChoice;
- }
-
- public void setUploadChoice(Long uploadChoice) {
- this.uploadChoice = uploadChoice;
- }
-
- public Long getSizeChoice() {
- return sizeChoice;
- }
-
- public void setSizeChoice(Long sizeChoice) {
- this.sizeChoice = sizeChoice;
- }
-
- public Long getWidthChoice() {
- return widthChoice;
- }
-
- public void setWidthChoice(Long widthChoice) {
- this.widthChoice = widthChoice;
- }
-
- public Long getHeightChoice() {
- return heightChoice;
- }
-
- public void setHeightChoice(Long heightChoice) {
- this.heightChoice = heightChoice;
- }
-
- public boolean isCaseSensitive() {
- return caseSensitive;
- }
-
- public void setCaseSensitive(boolean caseSensitive) {
- this.caseSensitive = caseSensitive;
- }
-
- public Long getMatcherChoice() {
- return matcherChoice;
- }
-
- public void setMatcherChoice(Long matcherChoice) {
- this.matcherChoice = matcherChoice;
- }
-}
+
+}
\ No newline at end of file
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java
(rev 0)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -0,0 +1,218 @@
+package org.richfaces.realworld.search;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+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.Scope;
+
+@Name("searchParams")
+(a)Scope(ScopeType.CONVERSATION)
+public class SearchParamHolder {
+
+ private static final String INCLUDE = "Include";
+ private static final String END_WITH = "End with";
+ private static final String START_WITH = "Start with";
+ private static final String STRICT = "Strict";
+ @In("#{messages['equals']}")
+ private String EQUALS_CHOICE;
+ @In("#{messages['less']}")
+ private String LESS_CHOICE;
+ @In("#{messages['more']}")
+ private String MORE_CHOICE;
+ @In("#{messages['nomatter']}")
+ private String NO_MATTER_CHOICE;
+
+ private boolean caseSensitive;
+
+ private String searchPattern;
+
+ private Long matcherChoice;
+
+ private Long spinnerChoice;
+
+ private Long uploadChoice;
+
+ private Long sizeChoice;
+
+ private Long widthChoice;
+
+ private Long heightChoice;
+
+ private Long dateChoice;
+
+ private Long votesChoice;
+
+ private Long numberOfVotes;
+
+ private Date date;
+
+ private String camera;
+
+ private int height;
+
+ private double size;
+
+ private int width;
+
+ private Date uploadDate;
+
+ public List<SelectItem> getItems() {
+ List<SelectItem> list = new ArrayList<SelectItem>(4);
+ list.add(new SelectItem(Long.valueOf(0L), NO_MATTER_CHOICE));
+ list.add(new SelectItem(Long.valueOf(1L), MORE_CHOICE));
+ list.add(new SelectItem(Long.valueOf(2L), LESS_CHOICE));
+ list.add(new SelectItem(Long.valueOf(3L), EQUALS_CHOICE));
+ return list;
+ }
+
+ public List<SelectItem> getMatchItems() {
+ List<SelectItem> list = new ArrayList<SelectItem>(4);
+ list.add(new SelectItem(Long.valueOf(0L), STRICT));
+ list.add(new SelectItem(Long.valueOf(1L), START_WITH));
+ list.add(new SelectItem(Long.valueOf(2L), END_WITH));
+ list.add(new SelectItem(Long.valueOf(3L), INCLUDE));
+ return list;
+ }
+
+ public String getSearchPattern() {
+ return searchPattern;
+ }
+
+ public void setSearchPattern(String searchPattern) {
+ this.searchPattern = searchPattern;
+ }
+
+ public Long getSpinnerChoice() {
+ return spinnerChoice;
+ }
+
+ public void setSpinnerChoice(Long spinnerChoice) {
+ this.spinnerChoice = spinnerChoice;
+ }
+
+ public Long getDateChoice() {
+ return dateChoice;
+ }
+
+ public void setDateChoice(Long dateChoice) {
+ this.dateChoice = dateChoice;
+ }
+
+ public Long getVotesChoice() {
+ return votesChoice;
+ }
+
+ public void setVotesChoice(Long votesChoice) {
+ this.votesChoice = votesChoice;
+ }
+
+ public Long getNumberOfVotes() {
+ return numberOfVotes;
+ }
+
+ public void setNumberOfVotes(Long numberOfVotes) {
+ this.numberOfVotes = numberOfVotes;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public String getCamera() {
+ return camera;
+ }
+
+ public void setCamera(String camera) {
+ this.camera = camera;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public double getSize() {
+ return size;
+ }
+
+ public void setSize(double size) {
+ this.size = size;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public Date getUploadDate() {
+ return uploadDate;
+ }
+
+ public void setUploadDate(Date uploadDate) {
+ this.uploadDate = uploadDate;
+ }
+
+ public Long getUploadChoice() {
+ return uploadChoice;
+ }
+
+ public void setUploadChoice(Long uploadChoice) {
+ this.uploadChoice = uploadChoice;
+ }
+
+ public Long getSizeChoice() {
+ return sizeChoice;
+ }
+
+ public void setSizeChoice(Long sizeChoice) {
+ this.sizeChoice = sizeChoice;
+ }
+
+ public Long getWidthChoice() {
+ return widthChoice;
+ }
+
+ public void setWidthChoice(Long widthChoice) {
+ this.widthChoice = widthChoice;
+ }
+
+ public Long getHeightChoice() {
+ return heightChoice;
+ }
+
+ public void setHeightChoice(Long heightChoice) {
+ this.heightChoice = heightChoice;
+ }
+
+ public boolean isCaseSensitive() {
+ return caseSensitive;
+ }
+
+ public void setCaseSensitive(boolean caseSensitive) {
+ this.caseSensitive = caseSensitive;
+ }
+
+ public Long getMatcherChoice() {
+ return matcherChoice;
+ }
+
+ public void setMatcherChoice(Long matcherChoice) {
+ this.matcherChoice = matcherChoice;
+ }
+}
Property changes on:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Deleted:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeManager.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeManager.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeManager.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -1,246 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.realworld.tree;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-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.Observer;
-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.component.UITree;
-import org.richfaces.component.html.HtmlTree;
-import org.richfaces.event.DataScrollerEvent;
-import org.richfaces.event.NodeSelectedEvent;
-import org.richfaces.model.TreeNode;
-import org.richfaces.model.TreeRowKey;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.fileupload.FileManager;
-import org.richfaces.realworld.manager.ImageManager;
-import org.richfaces.realworld.navigation.NavigationEnum;
-import org.richfaces.realworld.ui.ConversationState;
-
-@Name("treeManager")
-(a)Scope(ScopeType.CONVERSATION)
-@Synchronized(timeout=200000)
-public class TreeManager implements Serializable{
-
- private static final String DATASCROLLER_ID = "mainform:imageScroller";
-
- private static final String IMAGE_DATATABLE_ID = "mainform:mainImage";
-
- private static final String FIRST = "first";
-
- private static final String NEXT = "next";
-
- private static final String LAST = "last";
-
- private static final String UPDATE_MAIN_AREA_EVENT = "updateMainArea";
-
- private static final String PREVIOUS = "previous";
-
- private static final long serialVersionUID = -6072049677194472463L;
-
- private NavigationEnum mainArea;
-
- @In(required=false) @Out(required=false)
- private ConversationState conversationState;
-
- @In(create=true)
- FileManager fileManager;
-
- @In User user;
-
- @In(required=false)
- ImageManager imageManager;
-
- public void showFileUpload(TreeAlbumItem item, boolean singleMode){
- String i;
- if(singleMode){
- i="single";
- }else{
- i="multy";
- }
- Events.instance().raiseEvent("changeMode", i);
- Events.instance().raiseEvent("fileUploadClear");
- conversationState.setSelectedAlbum(item.getAlbum());
- this.setMainArea(NavigationEnum.FILE_UPLOAD);
- }
-
- public void showFileUpload(Album item, boolean singleMode){
- String i;
- if(singleMode){
- i="single";
- }else{
- i="multy";
- }
- Events.instance().raiseEvent("changeMode", i);
- Events.instance().raiseEvent("fileUploadClear");
- conversationState.setSelectedAlbum(item);
- this.setMainArea(NavigationEnum.FILE_UPLOAD);
- }
-
- public void scrollerListener(DataScrollerEvent event) {
- List<Image> images = conversationState.getSelectedAlbum().getImages();
- if (event.getNewScrolVal().equals(PREVIOUS)) {
- for(int index = 0 ; index < images.size(); index++){
- if(images.get(index) == conversationState.getSelectedImage()){
- conversationState.setSelectedImage(images.get(index - 1));
- conversationState.setSelectedImageIndex(index);
- }
- }
- } else if (event.getNewScrolVal().equals(LAST)) {
- conversationState.setSelectedImage(images.get(images.size() - 1));
- conversationState.setSelectedImageIndex(images.size());
- } else if (event.getNewScrolVal().equals(NEXT)) {
- for(int index = 0 ; index < images.size(); index++){
- if(images.get(index) == conversationState.getSelectedImage()){
- conversationState.setSelectedImage(images.get(index + 1));
- conversationState.setSelectedImageIndex(index + 2);
- return;
- }
- }
- } else if (event.getNewScrolVal().equals(FIRST)) {
- conversationState.setSelectedImage(images.get(0));
- conversationState.setSelectedImageIndex(1);
- }
-
- }
-
- public Boolean adviseNodeSelected(UITree tree) {
- TreeRowKey treeRowKey = (TreeRowKey) tree.getRowKey();
- TreeNode treeNode = (TreeNode) tree.getRowData(treeRowKey);
- if (treeNode instanceof TreeAlbumItem) {
- TreeAlbumItem currentNode = (TreeAlbumItem) treeNode;
- boolean selected = currentNode.getAlbum() == conversationState.getSelectedAlbum() ||
currentNode.containAlbum(conversationState.getSelectedAlbum());
- return selected;
- }
- return null;
- }
-
- public Boolean adviseNodeOpened(UITree tree) {
- TreeRowKey treeRowKey = (TreeRowKey) tree.getRowKey();
- TreeNode treeNode = (TreeNode) tree.getRowData(treeRowKey);
- if (treeNode instanceof TreeAlbumItem) {
- TreeAlbumItem currentNode = (TreeAlbumItem) treeNode;
- boolean selected = currentNode.getAlbum() == conversationState.getSelectedAlbum() ||
currentNode.containAlbum(conversationState.getSelectedAlbum());
- return selected;
- }
- return null;
- }
-
- public void processSelection(NodeSelectedEvent event) {
- Events.instance().raiseEvent(UPDATE_MAIN_AREA_EVENT, NavigationEnum.IMAGE_PREVIEW);
- HtmlTree tree = (HtmlTree) event.getComponent();
- TreeNode<String> currentNode = tree.getModelTreeNode(tree.getRowKey());
- if(currentNode instanceof TreeAlbumItem){
- TreeAlbumItem node = (TreeAlbumItem)currentNode;
- Album album = node.getAlbum();
- conversationState.setSelectedAlbum(album);
- }else if(currentNode instanceof TreeMyAlbumsItem){
- conversationState.setSelectedAlbum(null);
- }
- conversationState.setSelectedUser(user);
- conversationState.setSelectedImage(null);
- }
-
- public void processSelectionFriends(NodeSelectedEvent event) {
- Events.instance().raiseEvent(UPDATE_MAIN_AREA_EVENT, NavigationEnum.IMAGE_PREVIEW);
- HtmlTree tree = (HtmlTree) event.getComponent();
- TreeNode<String> currentNode = tree.getModelTreeNode(tree.getRowKey());
- if(currentNode instanceof TreeAlbumItem){
- TreeAlbumItem node = (TreeAlbumItem)currentNode;
- conversationState.setSelectedUser(((TreeAlbumItem)currentNode).getAlbum().getOwner());
- Album album = node.getAlbum();
- conversationState.setSelectedAlbum(album);
- }else if(currentNode instanceof TreeFriendsItem){
- conversationState.setSelectedUser(null);
- conversationState.setSelectedAlbum(null);
- }else if(currentNode instanceof TreeFriendItem){
- conversationState.setSelectedUser(((TreeFriendItem)currentNode).getFriend());
- conversationState.setSelectedAlbum(null);
- }
- conversationState.setSelectedImage(null);
- }
-
- private void setDataScrollerIndex(int index) {
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller = (UIDatascroller)component.findComponent(DATASCROLLER_ID);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+1);
- conversationState.setSelectedImageIndex(index+1);
- }
-
-
- public void incrementSlideshowIndex() {
- int index =
conversationState.getSelectedAlbum().getIndex(conversationState.getSelectedImage());
- if(conversationState.getSelectedAlbum().getImages().size() == index +1){
- index = -1;
- }
- conversationState.setSelectedImage(conversationState.getSelectedAlbum().getImages().get(index
+1));
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
- UIDatascroller scroller = (UIDatascroller)component.findComponent(DATASCROLLER_ID);
- Map<String, Object> attributes = scroller.getDataTable().getAttributes();
- attributes.put(UIDatascroller.SCROLLER_STATE_ATTRIBUTE, index+2);
- conversationState.setSelectedImageIndex(index+2);
- }
-
- public NavigationEnum getMainArea() {
- return mainArea;
- }
-
- @Observer("updateMainArea")
- public void setMainArea(NavigationEnum mainArea) {
- this.mainArea = mainArea;
- if(mainArea.equals(NavigationEnum.FILE_UPLOAD)){
- Events.instance().raiseEvent("showFileUpload", true);
- }
- }
-
- public SelectItem[] getAvailableIndexOfImages(){
- SelectItem[] group = new
SelectItem[conversationState.getSelectedAlbum().getImages().size()];
- for(int i = 0; i < conversationState.getSelectedAlbum().getImages().size(); i++){
- group[i] = new SelectItem(i+1);
- }
- return group;
- }
-
- public void updateSelectedItems(Image image){
- conversationState.setSelectedImage(image);
- Integer index =
conversationState.getSelectedAlbum().getIndex(conversationState.getSelectedImage());
- setDataScrollerIndex(index);
- }
-}
Deleted:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/ConversationState.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -1,106 +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.ui;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.tree.TreeMyAlbumsItem;
-
-@Name("conversationState")
-(a)Scope(ScopeType.CONVERSATION)
-public class ConversationState implements Serializable{
-
- private static final long serialVersionUID = 5656562187249324512L;
-
- private Integer selectedImageIndex = 1;
-
- private Image selectedImage;
-
- private Album selectedAlbum;
-
- private User selectedUser;
-
- private User secondSelectedUser;
-
- @In(required=false) private TreeMyAlbumsItem treeMyAlbumsItem;
-
- public Integer getSelectedImageIndex() {
- return selectedImageIndex;
- }
-
- public void setSelectedImageIndex(Integer selectedImageIndex) {
- this.selectedImageIndex = selectedImageIndex;
- }
-
- public Image getSelectedImage() {
- return selectedImage;
- }
-
- public void setSelectedImage(Image selectedImage) {
- this.selectedImage = selectedImage;
- }
-
- public Album getSelectedAlbum() {
- return selectedAlbum;
- }
-
- public void setSelectedAlbum(Album selectedAlbum) {
- this.selectedAlbum = selectedAlbum;
- }
-
- public String getSelectedAlbumName() {
- if(null == selectedAlbum){
- return "";
- }
- return selectedAlbum.getAlbumPathFromParents(selectedAlbum, new
ArrayList<String>(), "/");
- }
-
- public void setSelectedAlbumName(String selectedAlbumName) {
- selectedAlbumName = selectedAlbumName.substring(0, selectedAlbumName.length() -1);
- int lastIndexOf = selectedAlbumName.lastIndexOf("/");
- String prevPathEnd = selectedAlbumName.substring(lastIndexOf+1);
- this.selectedAlbum = treeMyAlbumsItem.getAlbumByName(prevPathEnd).getAlbum();
- }
-
- public User getSelectedUser() {
- return selectedUser;
- }
-
- public void setSelectedUser(User selectedUser) {
- this.selectedUser = selectedUser;
- }
-
- public User getSecondSelectedUser() {
- return secondSelectedUser;
- }
-
- public void setSecondSelectedUser(User secondSelectedUser) {
- this.secondSelectedUser = secondSelectedUser;
- }
-}
Deleted:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java 2009-01-26
15:25:08 UTC (rev 12424)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/ui/RenderLogic.java 2009-01-26
15:55:56 UTC (rev 12425)
@@ -1,107 +0,0 @@
-package org.richfaces.realworld.ui;
-
-import java.io.Serializable;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.security.Identity;
-import org.richfaces.realworld.domain.Album;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.User;
-
-@Name("renderLogic")
-(a)Scope(ScopeType.CONVERSATION)
-public class RenderLogic implements Serializable{
-
- @In User user;
- @In Identity identity;
- @In ConversationState conversationState;
-
- private static final long serialVersionUID = 5656562187249324512L;
-
- public boolean shouldRenderFriendFolders(){
- return conversationState.getSelectedUser() == null;
- }
-
- public boolean shouldRenderFolders(){
- return conversationState.getSelectedUser()!=null &&
conversationState.getSelectedImage() == null;
- }
-
- public boolean shouldRenderImage(){
- return conversationState.getSelectedUser()!=null &&
conversationState.getSelectedAlbum()!=null && conversationState.getSelectedImage()
!= null;
- }
-
- public boolean shouldRenderImageList(){
- return conversationState.getSelectedUser()!=null &&
conversationState.getSelectedAlbum()!=null;
- }
-
- public boolean isCurrentUserProfileSelected(){
- return user.equals(conversationState.getSelectedUser());
- }
-
- public boolean isSecondUserProfileSelected(){
- return conversationState.getSecondSelectedUser() != null;
- }
-
- public boolean isUserAlbumSelected(){
- return conversationState.getSelectedAlbum() != null &&
conversationState.getSelectedAlbum().getOwner().equals(user);
- }
-
- public boolean isUserGuest(){
- return identity.hasRole("guest");
- }
-
- public boolean shouldRenderFileUpload(){
- return conversationState.getSelectedAlbum()!=null &&
conversationState.getSelectedAlbum().getOwner().equals(user);
- }
-
- public boolean isUserSelected(){
- return user.equals(conversationState.getSelectedUser());
- }
-
- public boolean isFriendSelected(){
- return conversationState.getSelectedUser() == null || isUserFriend();
- }
-
- public boolean isNotFriendSelected(){
- return !isUserSelected() && !isUserFriend();
- }
-
- public boolean isUserFriend(){
- return user.getFriends() != null &&
user.getFriends().contains(conversationState.getSelectedUser());
- }
-
- public boolean isUserFriend(User u){
- return user.getFriends() != null && user.getFriends().contains(u);
- }
-
- public boolean isAlbumSelected(){
- return conversationState.getSelectedAlbum() != null;
- }
-
- public boolean isImageSelected(){
- return conversationState.getSelectedImage() != null;
- }
-
- public boolean isAccessToAlbumGranted(Album album){
- return album.getOwner().equals(user) || album.isShared() ||
isUserFriend(album.getOwner());
- }
-
- public boolean isUserAlbum(Album album){
- if(album == null){
- return false;
- }
- return album.getOwner().equals(user);
- }
-
- public boolean isFavoriteAlbum(Album album){
- return user.getFavoriteAlbums().contains(album);
- }
-
- public boolean isFavoriteImage(Image image){
- return user.getFavoriteImages().contains(image);
- }
-
-}
Modified:
trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/singleMode.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld/web/src/main/webapp/includes/search/advancedSearch.xhtml
===================================================================
(Binary files differ)