Author: amarkhel
Date: 2009-03-23 09:58:14 -0400 (Mon, 23 Mar 2009)
New Revision: 13102
Removed:
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/ui/SlideshowHelper.java
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/Model.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/ui/FileWrapper.java
Log:
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-23
13:58:01 UTC (rev 13101)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-03-23
13:58:14 UTC (rev 13102)
@@ -55,13 +55,13 @@
handleImage((Image)dragValue, (Album)dropValue);
}else if(dragValue instanceof Album){
handleAlbum((Album)dragValue, (Shelf)dropValue);
- }else if(dragValue instanceof FileItem){
+ }/*else if(dragValue instanceof FileItem){
if(!((Album)dropValue).getOwner().equals(user)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("You
can't add photo's to that album"));
return;
}
handleUploadedImage((FileItem)dragValue, (Album)dropValue);
- }
+ }*/
}
/*private void addTreeToRerender() {
@@ -103,7 +103,7 @@
}
}
- private void handleUploadedImage(FileItem dragValue, Album dropValue) {
+ /*private void handleUploadedImage(FileItem dragValue, Album dropValue) {
String newPath = generateNewPath(dragValue.getName(), dropValue);
dragValue.getImage().setPath(newPath);
dropValue.addImage(dragValue.getImage());
@@ -112,7 +112,7 @@
}
fileManager.addImage(newPath, dragValue.getFile().getPath());
Events.instance().raiseEvent("fileAdded", dragValue);
- }
+ }*/
private String getNewPathOfImage(Image dragValue, Album dropValue) {
String fileNameOld = dragValue.getPath();
@@ -123,8 +123,8 @@
return fileNameNew;
}
- private String generateNewPath(String path, Album dropValue) {
+ /*private String generateNewPath(String path, Album dropValue) {
String fileNameNew =
user.getLogin()+"/"+dropValue.getId()+"/"+path;
return fileNameNew;
- }
+ }*/
}
Deleted:
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 2009-03-23
13:58:01 UTC (rev 13101)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java 2009-03-23
13:58:14 UTC (rev 13102)
@@ -1,77 +0,0 @@
-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.service.Constants;
-import org.richfaces.realworld.ui.FileItem;
-import org.richfaces.realworld.ui.FileWrapper;
-
-@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.ALBUM_IMAGE_PREVIEW);
- }
-}
Modified:
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/Model.java 2009-03-23
13:58:01 UTC (rev 13101)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java 2009-03-23
13:58:14 UTC (rev 13102)
@@ -4,6 +4,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.MetaTag;
@@ -39,6 +40,9 @@
@Observer(Constants.UPDATE_MAIN_AREA_EVENT)
public void setMainArea(NavigationEnum mainArea) {
+ if(this.mainArea.equals(NavigationEnum.FILE_UPLOAD)){
+ Events.instance().raiseEvent("clearFileUpload");
+ }
this.mainArea = mainArea;
}
Modified:
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/ui/FileUploadBean.java 2009-03-23
13:58:01 UTC (rev 13101)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-03-23
13:58:14 UTC (rev 13102)
@@ -37,6 +37,7 @@
import org.richfaces.model.UploadItem;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.manager.FileManager;
+import org.richfaces.realworld.manager.Model;
import org.richfaces.realworld.service.Constants;
import com.drew.imaging.jpeg.JpegMetadataReader;
@@ -58,15 +59,14 @@
@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 Model model;
+ @In private FileManager fileManager;
@In("#{messages['samplename']}")
private String SAMPLE_NAME;
@@ -94,19 +94,13 @@
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_PROCESSING_ERROR));
return;
}
+ image.setAlbum(model.getSelectedAlbum());
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(!fileManager.addImage(file.getName(), file.getFile().getPath())){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_SAVE_ERROR));
}
- if(fileWrapper.getFiles().size()-3 >=0){
- file3 = fileWrapper.getFiles().get(fileWrapper.getFiles().size()-3);
- }
+ file.getFile().delete();
}
private Image constructImage(UploadItem item, FileItem file) {
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-03-23
13:58:01 UTC (rev 13101)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-03-23
13:58:14 UTC (rev 13102)
@@ -44,8 +44,8 @@
this.files = files;
}
- @Observer("fileAdded")
- public void removeFile(FileItem file){
- files.remove(file);
+ @Observer("clearFileUpload")
+ public void clear(){
+ files.clear();
}
}
Deleted:
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/SlideshowHelper.java 2009-03-23
13:58:01 UTC (rev 13101)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/SlideshowHelper.java 2009-03-23
13:58:14 UTC (rev 13102)
@@ -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.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;
- }
-
-
-}