diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index b32d6af..f7ee3af 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -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; @@ -1491,7 +1491,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt public void onClickPreview(ImagePreviewEvent imagePreviewEvent) { if(imagePreviewEvent.getClientX() > 0 && imagePreviewEvent.getClientY() > 0) - doClickPreview(imagePreviewEvent, imagePreviewEvent.getClientX(), imagePreviewEvent.getClientY() ); + doClickPreview(imagePreviewEvent, imagePreviewEvent.getClientX(), imagePreviewEvent.getClientY()); else doClickPreview(imagePreviewEvent, 50, 50); @@ -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); } }); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index c3a6bac..5343b8a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -766,4 +766,16 @@ public interface GWTWorkspaceService extends RemoteService{ * @throws Exception the exception */ List 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 getImagesForFolder(String folderId, String currentImageId) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 89a3f8b..757164c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -753,4 +753,7 @@ public interface GWTWorkspaceServiceAsync { WorkspaceVersioningOperation operation, AsyncCallback> callback); + void getImagesForFolder( + String folderId, String currentImageId, AsyncCallback> asyncCallback); + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/ImagesPreviewController.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/ImagesPreviewController.java new file mode 100644 index 0000000..d3a1331 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/ImagesPreviewController.java @@ -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 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>() { + + @Override + public void onFailure(Throwable caught) { + + parentImages = null; + + } + + @Override + public void onSuccess(List 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 list = new ArrayList(); + 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); + }-*/; + +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowImagePreview.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowImagePreview.java deleted file mode 100644 index 2b84df3..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/WindowImagePreview.java +++ /dev/null @@ -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 list = new ArrayList(); - 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); - }-*/; - -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/workspace/GWTWorkspaceItem.java b/src/main/java/org/gcube/portlets/user/workspace/client/workspace/GWTWorkspaceItem.java index b71f2b7..a68fdaf 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/workspace/GWTWorkspaceItem.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/workspace/GWTWorkspaceItem.java @@ -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 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() { diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/workspace/folder/item/GWTExternalImage.java b/src/main/java/org/gcube/portlets/user/workspace/client/workspace/folder/item/GWTExternalImage.java index 8960b93..ad7477d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/workspace/folder/item/GWTExternalImage.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/workspace/folder/item/GWTExternalImage.java @@ -1,5 +1,5 @@ /** - * + * */ package org.gcube.portlets.user.workspace.client.workspace.folder.item; @@ -16,44 +16,56 @@ 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{ - + protected String imageUrl; protected String thumbnailUrl; - + protected int thumbnailWidth; protected int thumbnailHeight; protected long thumbnailLenght; - + protected int width; protected int height; protected String mimeType; - + + /** + * Instantiates a new GWT external image. + */ protected GWTExternalImage() {} - - public GWTExternalImage(Date creationTime, String id, GWTProperties properties, String name, String owner, + + /** + * 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) { super(id, name, description, owner, creationTime, properties, lastModificationTime, lastAction, parent, length); - - this.imageUrl = imageUrl; - this.thumbnailUrl = thumbnailUrl; - this.width = width; - this.height = height; - this.mimeType = mimeType; - this.thumbnailHeight = thumbnailHeight; - this.thumbnailWidth = thumbnailWidth; - 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); - + this.imageUrl = imageUrl; this.thumbnailUrl = thumbnailUrl; this.width = width; @@ -64,6 +76,40 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G this.thumbnailLenght = thumbnailLenght; } + + + /** + * 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; + this.height = height; + this.mimeType = mimeType; + this.thumbnailHeight = thumbnailHeight; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailLenght = thumbnailLenght; + } + + /* (non-Javadoc) + * @see org.gcube.portlets.user.workspace.client.workspace.folder.GWTFolderItem#getFolderItemType() + */ @Override public GWTFolderItemType getFolderItemType() { return GWTFolderItemType.EXTERNAL_IMAGE; @@ -75,7 +121,7 @@ public class GWTExternalImage extends GWTFolderItem implements IsSerializable, G public String getThumbnailUrl(){ return GWT.getModuleBaseURL()+thumbnailUrl; } - + /** * {@inheritDoc} */ diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index edd618e..299f1bc 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -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(), diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index d73499a..efb94f8 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -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 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 images = new ArrayList(); + + if (item.isFolder()){ + WorkspaceFolder folder = (WorkspaceFolder) item; + GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); + PortalContextInfo context = WsUtil.getPortalContext(this.getThreadLocalRequest()); + GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); + List 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()); + } + } }