From 3c1910321683faca1bd2eedfdf606f9079c1b4eb Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 26 Mar 2013 11:35:58 +0000 Subject: [PATCH] fixed get info git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@71779 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/rpc/GWTWorkspaceService.java | 2 + .../client/rpc/GWTWorkspaceServiceAsync.java | 3 ++ .../client/view/windows/DialogGetInfo.java | 38 ++++++++++++++++++- .../server/GWTWorkspaceServiceImpl.java | 32 +++++++++++++++- 4 files changed, 71 insertions(+), 4 deletions(-) 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 d18c7a3..ba3784f 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 @@ -126,4 +126,6 @@ public interface GWTWorkspaceService extends RemoteService{ Long loadSizeByItemId(String itemId) throws Exception; + Date loadLastModificationDateById(String itemId) 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 2689f8f..50278af 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 @@ -134,5 +134,8 @@ public interface GWTWorkspaceServiceAsync { void loadSizeByItemId(String itemId, AsyncCallback asyncCallback); + void loadLastModificationDateById(String itemId, + AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java index cd579ff..5f4dd74 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java @@ -26,13 +26,14 @@ import com.google.gwt.user.client.rpc.AsyncCallback; */ public class DialogGetInfo extends Dialog { + protected static final String UNKNOWN = "unknown"; private int widthDialog = 450; private int heightTextArea = 50; private TextField txtName = new TextField(); private TextField txtType = new TextField(); private TextField txtCategory = new TextField(); private TextField txtOwner = new TextField(); - + private TextField txtLastMofication = new TextField(); private TextField txtCreated = new TextField(); private TextField txtSize = new TextField(); private TextField txtLocation = new TextField(); @@ -103,6 +104,13 @@ public class DialogGetInfo extends Dialog { loadCreationDate(fileModel.getIdentifier()); add(txtCreated); + + txtLastMofication = new TextField(); + txtLastMofication.setFieldLabel("Last Mofication"); + txtLastMofication.setReadOnly(true); + loadLastModificationDate(fileModel.getIdentifier()); + add(txtLastMofication); + txtSize = new TextField(); txtSize.setFieldLabel("Size"); txtSize.setReadOnly(true); @@ -145,10 +153,36 @@ public class DialogGetInfo extends Dialog { this.show(); } + private void loadLastModificationDate(final String itemId) { + + txtLastMofication.mask(); + AppControllerExplorer.rpcWorkspaceService.loadLastModificationDateById(itemId, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + GWT.log("an error occured in loadLastModificationDateById "+itemId + " "+caught.getMessage()); + txtLastMofication.unmask(); + + } + + @Override + public void onSuccess(Date result) { + + if(result!=null) + txtLastMofication.setValue(result.toString()); + else + txtLastMofication.setValue(UNKNOWN); + + txtLastMofication.unmask(); + } + }); + + } + private void textFieldSetValue(TextField field, String value){ if(value==null || value.isEmpty()) - field.setValue("unknown"); + field.setValue(UNKNOWN); else field.setValue(value); } 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 86cd2de..b5168fc 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 @@ -1889,9 +1889,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { Workspace workspace = getWorkspace(); - + WorkspaceItem wsItem = workspace.getItem(itemId); - + Long size = new Long(-1); if(wsItem instanceof FolderItem){ @@ -1908,4 +1908,32 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } + + + @Override + public Date loadLastModificationDateById(String itemId) throws Exception { + + workspaceLogger.trace("get last modification date ItemId "+ itemId); + try { + + Workspace workspace = getWorkspace(); + + WorkspaceItem wsItem = workspace.getItem(itemId); + + wsItem.getLastModificationTime().getTime(); + + Date lastModification =null; + + if(wsItem.getLastModificationTime()!=null){ + + lastModification = wsItem.getLastModificationTime().getTime(); + } + + return lastModification; + + } catch (Exception e) { + workspaceLogger.error("get last modification date ItemId ", e); + throw new Exception(e.getMessage()); + } + } }