Feature #5207 updated. Image Preview is available for any image of a folder using arrows previous/next
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@148959 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8ef26bdf7a
commit
2de99d605f
|
@ -128,7 +128,7 @@ import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplayMessage;
|
|||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxConfirm;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.NewBrowserWindow;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.WindowImagePreview;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.ImagesPreviewController;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.accounting.WindowAccountingInfo;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
|
||||
|
@ -1521,9 +1521,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
public void onSuccess(GWTWorkspaceItem item) {
|
||||
GWT.log("Image loaded: "+item.getName() + " label: "+item.getLabel());
|
||||
if(fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT))
|
||||
new WindowImagePreview(fileModel.getName(), (GWTImageDocument) item, positionX, positionY);
|
||||
new ImagesPreviewController(fileModel.getName(), fileModel.getParentFileModel(), (GWTImageDocument) item, positionX, positionY);
|
||||
else
|
||||
new WindowImagePreview(fileModel.getName(), (GWTExternalImage) item, positionX, positionY);
|
||||
new ImagesPreviewController(fileModel.getName(), fileModel.getParentFileModel(), (GWTExternalImage) item, positionX, positionY);
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -766,4 +766,16 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
List<FileVersionModel> getVersionHistory(String fileIdentifier) throws Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the images for folder.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param currentImageId the current image id
|
||||
* @return the images for folder
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<GWTWorkspaceItem> getImagesForFolder(String folderId, String currentImageId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -753,4 +753,7 @@ public interface GWTWorkspaceServiceAsync {
|
|||
WorkspaceVersioningOperation operation,
|
||||
AsyncCallback<List<FileVersionModel>> callback);
|
||||
|
||||
void getImagesForFolder(
|
||||
String folderId, String currentImageId, AsyncCallback<List<GWTWorkspaceItem>> asyncCallback);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,206 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.EnhancedImage;
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
||||
|
||||
import com.extjs.gxt.ui.client.widget.Window;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class ImagesPreviewController.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* May 24, 2017
|
||||
*/
|
||||
public class ImagesPreviewController {
|
||||
|
||||
private Window window = new Window();
|
||||
|
||||
private Image loader = Resources.getIconLoading().createImage();
|
||||
|
||||
private List<GWTWorkspaceItem> parentImages = null;
|
||||
|
||||
private Carousel carousel;
|
||||
|
||||
private FileModel folderParent;
|
||||
|
||||
int currentIndex = 0;
|
||||
|
||||
/**
|
||||
* Instantiates a new window image preview.
|
||||
*
|
||||
* @param folderParent the folder parent
|
||||
*/
|
||||
private ImagesPreviewController(FileModel folderParent){
|
||||
this.folderParent = folderParent;
|
||||
|
||||
carousel = new Carousel(){
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel#onClickPrev()
|
||||
*/
|
||||
@Override
|
||||
public void onClickPrev() {
|
||||
|
||||
if(parentImages==null)
|
||||
return;
|
||||
|
||||
if(currentIndex>0){
|
||||
currentIndex--;
|
||||
}else {
|
||||
currentIndex = parentImages.size() - 1;
|
||||
}
|
||||
|
||||
GWTWorkspaceItem wi = parentImages.get(currentIndex);
|
||||
EnhancedImage ei = toEnhancedImage(wi);
|
||||
if(ei!=null)
|
||||
show(ei);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel#onClickNext()
|
||||
*/
|
||||
@Override
|
||||
public void onClickNext() {
|
||||
|
||||
if(parentImages==null)
|
||||
return;
|
||||
|
||||
if(currentIndex<parentImages.size()-1){
|
||||
currentIndex++;
|
||||
}else {
|
||||
currentIndex = 0;
|
||||
}
|
||||
|
||||
GWTWorkspaceItem wi = parentImages.get(currentIndex);
|
||||
EnhancedImage ei = toEnhancedImage(wi);
|
||||
if(ei!=null)
|
||||
show(ei);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* To enhanced image.
|
||||
*
|
||||
* @param wi the wi
|
||||
* @return the enhanced image
|
||||
*/
|
||||
private EnhancedImage toEnhancedImage(GWTWorkspaceItem wi){
|
||||
if(wi instanceof GWTImageDocument){
|
||||
GWTImageDocument image = (GWTImageDocument) wi;
|
||||
return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl());
|
||||
}else if(wi instanceof GWTExternalImage){
|
||||
GWTExternalImage image = (GWTExternalImage) wi;
|
||||
return new EnhancedImage(image.getThumbnailUrl(), image.getName(), image.getName(), image.getImageUrl());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new window image preview.
|
||||
*
|
||||
* @param name the name
|
||||
* @param folderParent the folder parent
|
||||
* @param image the image
|
||||
* @param positionX the position x
|
||||
* @param positionY the position y
|
||||
*/
|
||||
public ImagesPreviewController(String name, FileModel folderParent, GWTImageDocument image, int positionX, int positionY) {
|
||||
this(folderParent);
|
||||
showCarousel(name, image.getThumbnailUrl(), image.getImageUrl());
|
||||
preloadImagesForFolderParent(folderParent, image.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new window image preview.
|
||||
*
|
||||
* @param name the name
|
||||
* @param folderParent the folder parent
|
||||
* @param image the image
|
||||
* @param positionX the position x
|
||||
* @param positionY the position y
|
||||
*/
|
||||
public ImagesPreviewController(String name, FileModel folderParent, GWTExternalImage image, int positionX, int positionY){
|
||||
this(folderParent);
|
||||
showCarousel(name, image.getThumbnailUrl(), image.getImageUrl());
|
||||
preloadImagesForFolderParent(folderParent, image.getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Preload images for folder parent.
|
||||
*
|
||||
* @param folderParent the folder parent
|
||||
* @param currentImageId the current image id
|
||||
*/
|
||||
private void preloadImagesForFolderParent(FileModel folderParent, String currentImageId){
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.getImagesForFolder(folderParent.getIdentifier(), currentImageId, new AsyncCallback<List<GWTWorkspaceItem>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
parentImages = null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GWTWorkspaceItem> result) {
|
||||
|
||||
GWT.log("Preloaded: "+result +" image/s");
|
||||
|
||||
parentImages = result;
|
||||
|
||||
if(parentImages.size()>0)
|
||||
carousel.showArrows(true);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show carousel.
|
||||
*
|
||||
* @param imageTitle the image title
|
||||
* @param thumbnailURL the thumbnail url
|
||||
* @param imageURL the image url
|
||||
*/
|
||||
private void showCarousel(String imageTitle, String thumbnailURL, String imageURL) {
|
||||
List<EnhancedImage> list = new ArrayList<EnhancedImage>();
|
||||
GWT.log("Generating imageURL: "+thumbnailURL);
|
||||
EnhancedImage myimg = new EnhancedImage(thumbnailURL, imageTitle, imageTitle);
|
||||
list.add(myimg);
|
||||
carousel.updateImages(list);
|
||||
carousel.showArrows(false);
|
||||
carousel.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log.
|
||||
*
|
||||
* @param msg the msg
|
||||
*/
|
||||
public static native void log(String msg) /*-{
|
||||
console.log(msg);
|
||||
}-*/;
|
||||
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.EnhancedImage;
|
||||
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
||||
|
||||
import com.extjs.gxt.ui.client.widget.Window;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.event.dom.client.LoadEvent;
|
||||
import com.google.gwt.event.dom.client.LoadHandler;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
|
||||
/**
|
||||
* The Class WindowImagePreview.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Nov 30, 2016
|
||||
*/
|
||||
public class WindowImagePreview {
|
||||
|
||||
Window window = new Window();
|
||||
|
||||
Image loader = Resources.getIconLoading().createImage();
|
||||
|
||||
/**
|
||||
* Instantiates a new window image preview.
|
||||
*
|
||||
* @param name the name
|
||||
* @param image the image
|
||||
* @param positionX the position x
|
||||
* @param positionY the position y
|
||||
*/
|
||||
public WindowImagePreview(String name, GWTImageDocument image, int positionX, int positionY) {
|
||||
initWindow(name, positionX, positionY);
|
||||
window.add(loader);
|
||||
Image img = new Image(image.getThumbnailUrl());
|
||||
|
||||
img.setWidth(String.valueOf(image.getThumbnailWidth()));
|
||||
img.setHeight(String.valueOf(image.getThumbnailHeight()));
|
||||
GWT.log("Thumbnail URL 1: "+image.getThumbnailUrl());
|
||||
Image loadImg = new Image(image.getThumbnailUrl());
|
||||
|
||||
loadImg.addLoadHandler(new LoadHandler() {
|
||||
|
||||
@Override
|
||||
public void onLoad(LoadEvent event) {
|
||||
GWT.log("Image Load event fired");
|
||||
window.remove(loader);
|
||||
}
|
||||
});
|
||||
window.add(loadImg);
|
||||
window.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new window image preview.
|
||||
*
|
||||
* @param name the name
|
||||
* @param image the image
|
||||
* @param positionX the position x
|
||||
* @param positionY the position y
|
||||
*/
|
||||
public WindowImagePreview(String name, GWTExternalImage image, int positionX, int positionY){
|
||||
|
||||
initWindow(name, positionX, positionY);
|
||||
|
||||
// System.out.println("URL.................." + image.getThumbnailUrl());
|
||||
// System.out.println("W.................." + String.valueOf(image.getThumbnailWidth()));
|
||||
// System.out.println("H.................." + String.valueOf(image.getThumbnailHeight()));
|
||||
// System.out.println("postionX.................." + positionX);
|
||||
// System.out.println("positionY.................." + positionY);
|
||||
|
||||
// Image img = new Image(image.getThumbnailUrl());
|
||||
// GWT.log("Thumbnail URL 2: "+image.getThumbnailUrl());
|
||||
//// img.setWidth(String.valueOf(image.getThumbnailWidth()));
|
||||
//// img.setHeight(String.valueOf(image.getThumbnailHeight()));
|
||||
// window.add(img);
|
||||
// window.show();
|
||||
|
||||
showCarousel(name, image.getThumbnailUrl(), positionX, positionY);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the window.
|
||||
*
|
||||
* @param name the name
|
||||
* @param positionX the position x
|
||||
* @param positionY the position y
|
||||
*/
|
||||
private void initWindow(String name, int positionX, int positionY) {
|
||||
|
||||
window.setHeaderVisible(true);
|
||||
window.setHeading(ConstantsExplorer.PREVIEWOF + " " + name);
|
||||
window.setMaximizable(false);
|
||||
window.setResizable(false);
|
||||
window.setAutoWidth(true);
|
||||
window.setAutoHeight(true);
|
||||
window.setPosition(positionX, positionY);
|
||||
}
|
||||
|
||||
private void showCarousel(
|
||||
String imageTitle, String imageURL, int positionX, int positionY) {
|
||||
Carousel carousel = new Carousel();
|
||||
List<EnhancedImage> list = new ArrayList<EnhancedImage>();
|
||||
GWT.log("Generating imageURL: "+imageURL);
|
||||
EnhancedImage myimg = new EnhancedImage(imageURL, imageTitle, imageTitle);
|
||||
list.add(myimg);
|
||||
carousel.updateImages(list);
|
||||
carousel.hideArrows();
|
||||
carousel.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log.
|
||||
*
|
||||
* @param msg the msg
|
||||
*/
|
||||
public static native void log(String msg) /*-{
|
||||
console.log(msg);
|
||||
}-*/;
|
||||
|
||||
}
|
|
@ -10,8 +10,9 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
|||
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
* The Class GWTWorkspaceItem.
|
||||
*
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*/
|
||||
public abstract class GWTWorkspaceItem implements IsSerializable {
|
||||
|
||||
|
@ -27,9 +28,25 @@ public abstract class GWTWorkspaceItem implements IsSerializable {
|
|||
|
||||
protected boolean isLoading = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new GWT workspace item.
|
||||
*/
|
||||
protected GWTWorkspaceItem()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Instantiates a new GWT workspace item.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @param id the id
|
||||
* @param name the name
|
||||
* @param description the description
|
||||
* @param owner the owner
|
||||
* @param creationTime the creation time
|
||||
* @param properties the properties
|
||||
* @param lastModificationTime the last modification time
|
||||
* @param lastAction the last action
|
||||
*/
|
||||
public GWTWorkspaceItem(GWTWorkspaceFolder parent, String id, String name,
|
||||
String description, String owner, Date creationTime,
|
||||
GWTProperties properties, Date lastModificationTime, GWTWorkspaceItemAction lastAction) {
|
||||
|
@ -45,63 +62,154 @@ public abstract class GWTWorkspaceItem implements IsSerializable {
|
|||
this.lastAction = lastAction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
public GWTWorkspaceFolder getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the creation time.
|
||||
*
|
||||
* @return the creation time
|
||||
*/
|
||||
public Date getCreationTime(){
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the properties.
|
||||
*
|
||||
* @return the properties
|
||||
*/
|
||||
public GWTProperties getProperties(){
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public String getOwner(){
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last modification time.
|
||||
*
|
||||
* @return the last modification time
|
||||
*/
|
||||
public Date getLastModificationTime() {
|
||||
return lastModificationTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last action.
|
||||
*
|
||||
* @return the last action
|
||||
*/
|
||||
public GWTWorkspaceItemAction getLastAction() {
|
||||
return lastAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item description.
|
||||
*
|
||||
* @return the item description
|
||||
*/
|
||||
public abstract GWTItemDescription getItemDescription();
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return getItemDescription().getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon class.
|
||||
*
|
||||
* @return the icon class
|
||||
*/
|
||||
public String getIconClass(){
|
||||
return getItemDescription().getIconClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public abstract GWTWorkspaceItemType getType();
|
||||
|
||||
/**
|
||||
* Gets the children.
|
||||
*
|
||||
* @return the children
|
||||
*/
|
||||
public abstract List<? extends GWTWorkspaceItem> getChildren();
|
||||
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
* @param parent the new parent
|
||||
*/
|
||||
protected void setParent(GWTWorkspaceFolder parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count sub tree children.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public int countSubTreeChildren()
|
||||
{
|
||||
int total = 0;
|
||||
|
@ -113,6 +221,13 @@ public abstract class GWTWorkspaceItem implements IsSerializable {
|
|||
return total;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Count sub tree children.
|
||||
*
|
||||
* @param type the type
|
||||
* @return the int
|
||||
*/
|
||||
public int countSubTreeChildren(GWTWorkspaceItemType type)
|
||||
{
|
||||
int total = 0;
|
||||
|
@ -126,37 +241,69 @@ public abstract class GWTWorkspaceItem implements IsSerializable {
|
|||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
protected void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description.
|
||||
*
|
||||
* @param description the new description
|
||||
*/
|
||||
protected void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is root.
|
||||
*
|
||||
* @return true, if is root
|
||||
*/
|
||||
public boolean isRoot()
|
||||
{
|
||||
return getParent() == null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Item: "+this.name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof GWTWorkspaceItem)) return false;
|
||||
return this.id.equals(((GWTWorkspaceItem)obj).getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path.
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
if (isRoot()) return "/"+name;
|
||||
return getParent().getPath()+"/"+name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is ancestor.
|
||||
*
|
||||
* @param item the item
|
||||
* @return true, if is ancestor
|
||||
*/
|
||||
public boolean isAncestor(GWTWorkspaceItem item)
|
||||
{
|
||||
if (id.equals(item.getId())) return true;
|
||||
|
@ -167,6 +314,8 @@ public abstract class GWTWorkspaceItem implements IsSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if is loading.
|
||||
*
|
||||
* @return the isLoading
|
||||
*/
|
||||
public boolean isLoading() {
|
||||
|
|
|
@ -16,8 +16,9 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
|||
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
* The Class GWTExternalImage.
|
||||
*
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*/
|
||||
public class GWTExternalImage extends GWTFolderItem implements IsSerializable, GWTImage{
|
||||
|
||||
|
@ -32,9 +33,34 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G
|
|||
protected int height;
|
||||
protected String mimeType;
|
||||
|
||||
/**
|
||||
* Instantiates a new GWT external image.
|
||||
*/
|
||||
protected GWTExternalImage()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Instantiates a new GWT external image.
|
||||
*
|
||||
* @param creationTime the creation time
|
||||
* @param id the id
|
||||
* @param properties the properties
|
||||
* @param name the name
|
||||
* @param owner the owner
|
||||
* @param description the description
|
||||
* @param lastModificationTime the last modification time
|
||||
* @param lastAction the last action
|
||||
* @param parent the parent
|
||||
* @param imageUrl the image url
|
||||
* @param thumbnailUrl the thumbnail url
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
* @param length the length
|
||||
* @param thumbnailWidth the thumbnail width
|
||||
* @param thumbnailHeight the thumbnail height
|
||||
* @param thumbnailLenght the thumbnail lenght
|
||||
* @param mimeType the mime type
|
||||
*/
|
||||
public GWTExternalImage(Date creationTime, String id, GWTProperties properties, String name, String owner,
|
||||
String description, Date lastModificationTime, GWTWorkspaceItemAction lastAction,
|
||||
GWTWorkspaceFolder parent, String imageUrl, String thumbnailUrl, int width, int height, long length, int thumbnailWidth, int thumbnailHeight, long thumbnailLenght, String mimeType) {
|
||||
|
@ -50,10 +76,27 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G
|
|||
this.thumbnailLenght = thumbnailLenght;
|
||||
}
|
||||
|
||||
//ADDED BY FRANCESCO
|
||||
public GWTExternalImage(String imageUrl, String thumbnailUrl, int width, int height, long length, int thumbnailWidth, int thumbnailHeight, long thumbnailLenght, String mimeType) {
|
||||
// super(id, name, description, owner, creationTime, null, null, null, parent, length);
|
||||
|
||||
|
||||
/**
|
||||
* ADDED by Francesco
|
||||
* Instantiates a new GWT external image.
|
||||
*
|
||||
* @param id the id
|
||||
* @param name the name
|
||||
* @param imageUrl the image url
|
||||
* @param thumbnailUrl the thumbnail url
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
* @param length the length
|
||||
* @param thumbnailWidth the thumbnail width
|
||||
* @param thumbnailHeight the thumbnail height
|
||||
* @param thumbnailLenght the thumbnail lenght
|
||||
* @param mimeType the mime type
|
||||
*/
|
||||
public GWTExternalImage(String id, String name, String imageUrl, String thumbnailUrl, int width, int height, long length, int thumbnailWidth, int thumbnailHeight, long thumbnailLenght, String mimeType) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.imageUrl = imageUrl;
|
||||
this.thumbnailUrl = thumbnailUrl;
|
||||
this.width = width;
|
||||
|
@ -64,6 +107,9 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G
|
|||
this.thumbnailLenght = thumbnailLenght;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.workspace.folder.GWTFolderItem#getFolderItemType()
|
||||
*/
|
||||
@Override
|
||||
public GWTFolderItemType getFolderItemType() {
|
||||
return GWTFolderItemType.EXTERNAL_IMAGE;
|
||||
|
|
|
@ -363,7 +363,7 @@ public class GWTWorkspaceBuilder {
|
|||
image.getMimeType());
|
||||
}else{
|
||||
|
||||
gwtImage = new GWTExternalImage(
|
||||
gwtImage = new GWTExternalImage(image.getId(), image.getName(),
|
||||
buildImageUrl(image.getId(), currentGroupId, currentUserId),
|
||||
buildThumbnailUrl(image.getId(), currentGroupId, currentUserId),
|
||||
image.getWidth(),
|
||||
|
|
|
@ -4107,4 +4107,69 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getImagesForFolder(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<GWTWorkspaceItem> getImagesForFolder(String folderId, String currentImageId) throws Exception {
|
||||
|
||||
if(folderId==null)
|
||||
return null;
|
||||
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
workspaceLogger.debug("get images for folder id: "+folderId);
|
||||
WorkspaceItem item = workspace.getItem(folderId); //get item from workspace
|
||||
List<GWTWorkspaceItem> images = new ArrayList<GWTWorkspaceItem>();
|
||||
|
||||
if (item.isFolder()){
|
||||
WorkspaceFolder folder = (WorkspaceFolder) item;
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
PortalContextInfo context = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
List<WorkspaceItem> children = folder.getChildren();
|
||||
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
boolean foundCurrentImage = false;
|
||||
if(workspaceItem.getType().compareTo(WorkspaceItemType.FOLDER_ITEM)==0){
|
||||
FolderItem file = (FolderItem) workspaceItem;
|
||||
GWTWorkspaceItem image = null;
|
||||
switch (file.getFolderItemType()) {
|
||||
case EXTERNAL_IMAGE:
|
||||
image = builder.buildGWTWorkspaceImage(workspaceItem, false, false, context.getCurrGroupId()+"", user.getUserId()+"");
|
||||
image.setId(workspaceItem.getId());
|
||||
break;
|
||||
case IMAGE_DOCUMENT:
|
||||
image = builder.buildGWTWorkspaceImage(workspaceItem, true, false, context.getCurrGroupId()+"", user.getUserId()+"");
|
||||
image.setId(workspaceItem.getId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(image!=null){
|
||||
if(!foundCurrentImage && image.getId().compareTo(currentImageId)==0){
|
||||
workspaceLogger.debug("It is current thumbnail adding to list as first element: "+image.getName());
|
||||
images.add(0, image);
|
||||
foundCurrentImage = true;
|
||||
}else{
|
||||
workspaceLogger.debug("Adding thumbnail name to list: "+image.getName());
|
||||
images.add(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
workspaceLogger.info("Returning "+images.size() +" images for folder id: "+folderId);
|
||||
return images;
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("Error in server get images by folder id: "+folderId, e);
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue