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
This commit is contained in:
Francesco Mangiacrapa 2013-03-26 11:35:58 +00:00
parent d1c7b8d93e
commit 3c19103216
4 changed files with 71 additions and 4 deletions

View File

@ -126,4 +126,6 @@ public interface GWTWorkspaceService extends RemoteService{
Long loadSizeByItemId(String itemId) throws Exception;
Date loadLastModificationDateById(String itemId) throws Exception;
}

View File

@ -134,5 +134,8 @@ public interface GWTWorkspaceServiceAsync {
void loadSizeByItemId(String itemId, AsyncCallback<Long> asyncCallback);
void loadLastModificationDateById(String itemId,
AsyncCallback<Date> callback);
}

View File

@ -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<String> txtName = new TextField<String>();
private TextField<String> txtType = new TextField<String>();
private TextField<String> txtCategory = new TextField<String>();
private TextField<String> txtOwner = new TextField<String>();
private TextField<String> txtLastMofication = new TextField<String>();
private TextField<String> txtCreated = new TextField<String>();
private TextField<String> txtSize = new TextField<String>();
private TextField<String> txtLocation = new TextField<String>();
@ -103,6 +104,13 @@ public class DialogGetInfo extends Dialog {
loadCreationDate(fileModel.getIdentifier());
add(txtCreated);
txtLastMofication = new TextField<String>();
txtLastMofication.setFieldLabel("Last Mofication");
txtLastMofication.setReadOnly(true);
loadLastModificationDate(fileModel.getIdentifier());
add(txtLastMofication);
txtSize = new TextField<String>();
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<Date>() {
@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<String> field, String value){
if(value==null || value.isEmpty())
field.setValue("unknown");
field.setValue(UNKNOWN);
else
field.setValue(value);
}

View File

@ -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());
}
}
}