From fd8fc0f6472873d061f9f56fd614e85e594286ed Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Wed, 4 Sep 2013 09:26:10 +0000 Subject: [PATCH] - Open a workspace item with safari and chrome is fixed - Owner view in the grid was optimized git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@81039 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/AppControllerExplorer.java | 5 +++- .../workspace/client/model/FileModel.java | 8 +++-- .../RequestBuilderWorkspaceValidateItem.java | 16 ++++++---- .../client/util/WindowOpenParameter.java | 21 +++++++++++-- .../client/view/windows/NewBrowserWindow.java | 30 +++++++++++++++++++ .../workspace/server/GWTWorkspaceBuilder.java | 22 ++++++++++---- .../server/GWTWorkspaceServiceImpl.java | 6 ++-- 7 files changed, 88 insertions(+), 20 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/workspace/client/view/windows/NewBrowserWindow.java 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 37278e0..c71f47b 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 @@ -2041,7 +2041,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt params+=ConstantsExplorer.REDIRECTONERROR+"="+windowOpenParam.isRedirectOnError(); - com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params, windowOpenParam.getOption(), ""); + windowOpenParam.getBrowserWindow().setUrl(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params); + + +// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params, windowOpenParam.getOption(), ""); } }; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java index 40be01a..6761791 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java @@ -137,8 +137,12 @@ public class FileModel extends BaseModelData implements Serializable { public void setOwner(InfoContactModel owner){ set(ConstantsExplorer.OWNER, owner); - if(owner!=null) - set(ConstantsExplorer.OWNERFULLNAME, owner.getName()); +// if(owner!=null) +// set(ConstantsExplorer.OWNERFULLNAME, owner.getName()); + } + + public void setOwnerFullName(String fullName){ + set(ConstantsExplorer.OWNERFULLNAME, fullName); } public void setMarkAsRead(boolean mark){ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java b/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java index b6b40cc..3f93bda 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java @@ -6,6 +6,7 @@ package org.gcube.portlets.user.workspace.client.util; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; 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.NewBrowserWindow; import com.google.gwt.core.client.GWT; import com.google.gwt.http.client.Request; @@ -34,14 +35,16 @@ public class RequestBuilderWorkspaceValidateItem { * @param method * @param servletName the name of the servlet that must be called * @param params param=value¶m1=value1&... - * @param name the name of the window (e.g. "_blank") + * @param targetWindow the target of the window (e.g. "_blank") * @param callback * @throws Exception */ - public RequestBuilderWorkspaceValidateItem(RequestBuilder.Method method, String servletName, final String params, final String name, final AsyncCallback callback) throws Exception{ + public RequestBuilderWorkspaceValidateItem(RequestBuilder.Method method, String servletName, final String params, final String targetWindow, final AsyncCallback callback) throws Exception{ this.callback = callback; + final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open(null, targetWindow, null); + this.parameters = params; if(servletName==null) @@ -75,24 +78,27 @@ public class RequestBuilderWorkspaceValidateItem { // System.out.println("status code is "+status); if(!(status==200) && !(status==202)){ //NOT IS STATUS SC_ACCEPTED + + newBrowserWindow.close(); handleError("Sorry, an error occurred on retriving the file. "+response.getText()); //ERROR STATUS - + }else{ //OK STATUS if(callback!=null) - callback.onSuccess(new WindowOpenParameter(name, "", params, true)); + callback.onSuccess(new WindowOpenParameter(targetWindow, "", params, true, newBrowserWindow)); } } @Override public void onError(Request request, Throwable exception) { - + newBrowserWindow.close(); // System.out.println("exception message is "+exception.getMessage()); handleError(exception.getMessage()); } }); } catch (RequestException e) { + newBrowserWindow.close(); throw new Exception("Sorry, an error occurred while contacting server, try again"); } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/util/WindowOpenParameter.java b/src/main/java/org/gcube/portlets/user/workspace/client/util/WindowOpenParameter.java index 95c8b4f..93da797 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/util/WindowOpenParameter.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/util/WindowOpenParameter.java @@ -3,6 +3,8 @@ */ package org.gcube.portlets.user.workspace.client.util; +import org.gcube.portlets.user.workspace.client.view.windows.NewBrowserWindow; + /** * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @Jun 25, 2013 @@ -14,6 +16,7 @@ public class WindowOpenParameter { private String parameters; private String itemName; private boolean redirectOnError; + private NewBrowserWindow browserWindow; /** * @@ -24,17 +27,19 @@ public class WindowOpenParameter { /** * - * @param option the name of the window (e.g. "_blank") + * @param target the target of the window (e.g. "_blank") * @param itemName * @param parameters param=value¶m1=value1&... * @param redirectOnError if true execute a redirect on fake URL + * @param browserWindow an instance of NewBrowserWindow */ - public WindowOpenParameter(String option, String itemName, String parameters, boolean redirectOnError) { + public WindowOpenParameter(String target, String itemName, String parameters, boolean redirectOnError, NewBrowserWindow browserWindow) { super(); - this.option = option; + this.option = target; this.itemName = itemName; this.parameters = parameters; this.redirectOnError = redirectOnError; + this.browserWindow = browserWindow; } @@ -73,6 +78,16 @@ public class WindowOpenParameter { public void setRedirectOnError(boolean redirectOnError) { this.redirectOnError = redirectOnError; } + + + public NewBrowserWindow getBrowserWindow() { + return browserWindow; + } + + + public void setBrowserWindow(NewBrowserWindow browserWindow) { + this.browserWindow = browserWindow; + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/NewBrowserWindow.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/NewBrowserWindow.java new file mode 100644 index 0000000..7c4f2f2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/NewBrowserWindow.java @@ -0,0 +1,30 @@ +package org.gcube.portlets.user.workspace.client.view.windows; + +import com.google.gwt.core.client.JavaScriptObject; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Sep 4, 2013 + * + */ +public final class NewBrowserWindow extends JavaScriptObject { + // All types that extend JavaScriptObject must have a protected, + // no-args constructor. + protected NewBrowserWindow() { + } + + public static native NewBrowserWindow open(String url, String target, + String options) /*-{ + return $wnd.open(url, target, options); + }-*/; + + public native void close() /*-{ + this.close(); + }-*/; + + public native void setUrl(String url) /*-{ + if (this.location) { + this.location = url; + } + }-*/; +} 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 7e05e64..7fbb9ae 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 @@ -1052,7 +1052,7 @@ public class GWTWorkspaceBuilder { Long endTime = System.currentTimeMillis() - startTime; String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - logger.trace("gxt grid objects getChildren() returning "+listWorkspaceItems.size()+" elements in " + time); + logger.trace("##GRID FILLING: gxt grid objects getChildren() returning "+listWorkspaceItems.size()+" elements in " + time); return listFileGridModel; @@ -1103,20 +1103,30 @@ public class GWTWorkspaceBuilder { } //OWNER - if(item.isShared()){ //IS READ FROM HL ONLY IF THE ITEM IS SHARED - if(item.getOwner()!=null){ - String portalLogin = item.getOwner().getPortalLogin(); + if(fileGridModel.isShared()){ //IS READ FROM HL ONLY IF THE ITEM IS SHARED + User owner = item.getOwner(); + if(owner!=null){ + +// System.out.println("++++reading owner"); + + String portalLogin = owner.getPortalLogin(); + +// String portalLogin = "puppa"; + String fullName = portalLogin; if(!WsUtil.withoutPortal) //INTO PORTAL fullName = UserUtil.getUserFullName(portalLogin); - fileGridModel.setOwner(new InfoContactModel(item.getOwner().getId(), portalLogin, fullName)); +// fileGridModel.setOwner(new InfoContactModel(item.getOwner().getId(), portalLogin, fullName)); + + fileGridModel.setOwnerFullName(fullName); } } else{ if(userLogged!=null) - fileGridModel.setOwner(new InfoContactModel(userLogged.getId(), userLogged.getLogin(), userLogged.getName())); +// fileGridModel.setOwner(new InfoContactModel(userLogged.getId(), userLogged.getLogin(), userLogged.getName())); + fileGridModel.setOwnerFullName(userLogged.getName()); } //// fileGridModel.setShared(item.isShared()); // fileGridModel.setMarkAsRead(item.isMarkedAsRead()); 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 81bac21..457fcb0 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 @@ -287,11 +287,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT Long endTime = System.currentTimeMillis() - startTime; String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - logger.trace("grid getChildren() returning "+listItems.size()+" elements in " + time); - - + logger.trace("##HL FILLING: grid getChildren() returning "+listItems.size()+" elements in " + time); + listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder); + return listFileGridModels; } catch (Exception e) {