256: Workspace explorer
Task-Url: https://support.d4science.org/issues/256 Upgraded to GWT 2.7 Added size formatter Updated css git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@117146 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7c473a0518
commit
ff0dbc8a57
2
pom.xml
2
pom.xml
|
@ -24,7 +24,7 @@
|
||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Convenience property to set the GWT version -->
|
<!-- Convenience property to set the GWT version -->
|
||||||
<gwtVersion>2.6.1</gwtVersion>
|
<gwtVersion>2.7.0</gwtVersion>
|
||||||
<distroDirectory>distro</distroDirectory>
|
<distroDirectory>distro</distroDirectory>
|
||||||
<!-- GWT needs at least java 1.6 -->
|
<!-- GWT needs at least java 1.6 -->
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
|
|
@ -202,15 +202,15 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
if(!item.isFolder())
|
if(!item.isFolder())
|
||||||
hp.add(labelMime);
|
hp.add(labelMime);
|
||||||
hp.add(labelACL);
|
hp.add(labelACL);
|
||||||
workspaceNavigatorService.loadSizeByItemId(item.getId(), new AsyncCallback<Long>() {
|
workspaceNavigatorService.getReadableSizeByItemId(item.getId(), new AsyncCallback<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Long result) {
|
public void onSuccess(String result) {
|
||||||
labelSize.setText("Size: " +Util.getFormattedSize(result));
|
labelSize.setText("Size: " +result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException;
|
import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
@ -13,85 +14,116 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client side stub for the RPC service.
|
* The client side stub for the RPC service.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Jul 10, 2015
|
||||||
*/
|
*/
|
||||||
@RemoteServiceRelativePath("WorkspaceExplorerService")
|
@RemoteServiceRelativePath("WorkspaceExplorerService")
|
||||||
public interface WorkspaceExplorerService extends RemoteService {
|
public interface WorkspaceExplorerService extends RemoteService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param itemIdentifier
|
* Gets the breadcrumbs by item identifier.
|
||||||
* @param includeItemAsParent
|
*
|
||||||
* @return
|
* @param itemIdentifier the item identifier
|
||||||
* @throws Exception
|
* @param includeItemAsParent the include item as parent
|
||||||
|
* @return the breadcrumbs by item identifier
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
List<Item> getBreadcrumbsByItemIdentifier(String itemIdentifier,
|
List<Item> getBreadcrumbsByItemIdentifier(String itemIdentifier,
|
||||||
boolean includeItemAsParent) throws Exception;
|
boolean includeItemAsParent) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* Check name.
|
||||||
* @return
|
*
|
||||||
* @throws WorkspaceNavigatorServiceException
|
* @param name the name
|
||||||
|
* @return true, if successful
|
||||||
|
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||||
*/
|
*/
|
||||||
boolean checkName(String name) throws WorkspaceNavigatorServiceException;
|
boolean checkName(String name) throws WorkspaceNavigatorServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param folderId
|
* Gets the folder.
|
||||||
* @param showableTypes
|
*
|
||||||
* @param purgeEmpyFolders
|
* @param folderId the folder id
|
||||||
* @param filterCriteria
|
* @param showableTypes the showable types
|
||||||
* @return
|
* @param purgeEmpyFolders the purge empy folders
|
||||||
* @throws WorkspaceNavigatorServiceException
|
* @param filterCriteria the filter criteria
|
||||||
|
* @return the folder
|
||||||
|
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||||
*/
|
*/
|
||||||
Item getFolder(String folderId, List<ItemType> showableTypes,
|
Item getFolder(String folderId, List<ItemType> showableTypes,
|
||||||
boolean purgeEmpyFolders, FilterCriteria filterCriteria)
|
boolean purgeEmpyFolders, FilterCriteria filterCriteria)
|
||||||
throws WorkspaceNavigatorServiceException;
|
throws WorkspaceNavigatorServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param showableTypes
|
* Gets the root.
|
||||||
* @param purgeEmpyFolders
|
*
|
||||||
* @param filterCriteria
|
* @param showableTypes the showable types
|
||||||
* @return
|
* @param purgeEmpyFolders the purge empy folders
|
||||||
* @throws WorkspaceNavigatorServiceException
|
* @param filterCriteria the filter criteria
|
||||||
|
* @return the root
|
||||||
|
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||||
*/
|
*/
|
||||||
Item getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders,
|
Item getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders,
|
||||||
FilterCriteria filterCriteria)
|
FilterCriteria filterCriteria)
|
||||||
throws WorkspaceNavigatorServiceException;
|
throws WorkspaceNavigatorServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param showableTypes
|
* Gets the my special folder.
|
||||||
* @param purgeEmpyFolders
|
*
|
||||||
* @param filterCriteria
|
* @param showableTypes the showable types
|
||||||
* @return
|
* @param purgeEmpyFolders the purge empy folders
|
||||||
* @throws WorkspaceNavigatorServiceException
|
* @param filterCriteria the filter criteria
|
||||||
|
* @return the my special folder
|
||||||
|
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||||
*/
|
*/
|
||||||
Item getMySpecialFolder(List<ItemType> showableTypes,
|
Item getMySpecialFolder(List<ItemType> showableTypes,
|
||||||
boolean purgeEmpyFolders, FilterCriteria filterCriteria)
|
boolean purgeEmpyFolders, FilterCriteria filterCriteria)
|
||||||
throws WorkspaceNavigatorServiceException;
|
throws WorkspaceNavigatorServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param category
|
* Gets the item by category.
|
||||||
* @return
|
*
|
||||||
* @throws WorkspaceNavigatorServiceException
|
* @param category the category
|
||||||
|
* @return the item by category
|
||||||
|
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
|
||||||
*/
|
*/
|
||||||
Item getItemByCategory(ItemCategory category)throws WorkspaceNavigatorServiceException;
|
Item getItemByCategory(ItemCategory category)throws WorkspaceNavigatorServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param itemId
|
* Gets the size by item id.
|
||||||
* @return
|
*
|
||||||
* @throws Exception
|
* @param itemId the item id
|
||||||
|
* @return the size by item id
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
Long loadSizeByItemId(String itemId) throws Exception;
|
Long getSizeByItemId(String itemId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param itemId
|
* Gets the mime type.
|
||||||
* @return
|
*
|
||||||
* @throws Exception
|
* @param itemId the item id
|
||||||
|
* @return the mime type
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
String getMimeType(String itemId) throws Exception;
|
String getMimeType(String itemId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param folderId
|
* Gets the user acl for folder id.
|
||||||
* @return
|
*
|
||||||
* @throws Exception
|
* @param folderId the folder id
|
||||||
|
* @return the user acl for folder id
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
String getUserACLForFolderId(String folderId) throws Exception;
|
String getUserACLForFolderId(String folderId) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the readable size by item id.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @return the readable size by item id
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
String getReadableSizeByItemId(String id) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
@ -99,20 +100,39 @@ public interface WorkspaceExplorerServiceAsync {
|
||||||
public void getItemByCategory(ItemCategory category, AsyncCallback<Item> asyncCallback);
|
public void getItemByCategory(ItemCategory category, AsyncCallback<Item> asyncCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* Gets the size by item id.
|
||||||
* @param asyncCallback
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param asyncCallback the async callback
|
||||||
|
* @return the size by item id
|
||||||
*/
|
*/
|
||||||
public void loadSizeByItemId(String id, AsyncCallback<Long> asyncCallback);
|
public void getSizeByItemId(String id, AsyncCallback<Long> asyncCallback);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* Gets the readable size by item id.
|
||||||
* @param asyncCallback
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param asyncCallback the async callback
|
||||||
|
* @return the readable size by item id
|
||||||
|
*/
|
||||||
|
public void getReadableSizeByItemId(String id, AsyncCallback<String> asyncCallback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mime type.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param asyncCallback the async callback
|
||||||
|
* @return the mime type
|
||||||
*/
|
*/
|
||||||
public void getMimeType(String id, AsyncCallback<String> asyncCallback);
|
public void getMimeType(String id, AsyncCallback<String> asyncCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* Gets the user acl for folder id.
|
||||||
* @param asyncCallback
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param asyncCallback the async callback
|
||||||
|
* @return the user acl for folder id
|
||||||
*/
|
*/
|
||||||
public void getUserACLForFolderId(String id,
|
public void getUserACLForFolderId(String id,
|
||||||
AsyncCallback<String> asyncCallback);
|
AsyncCallback<String> asyncCallback);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
width: 550px;
|
width: 550px;
|
||||||
|
font-size: 12px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footerHP{
|
.footerHP{
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ItemBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item.
|
* Gets the item
|
||||||
*
|
*
|
||||||
* @param parent the parent
|
* @param parent the parent
|
||||||
* @param workspaceItem the workspace item
|
* @param workspaceItem the workspace item
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.portlets.widgets.wsexplorer.server;
|
package org.gcube.portlets.widgets.wsexplorer.server;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,6 +27,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException;
|
import org.gcube.portlets.widgets.wsexplorer.shared.WorkspaceNavigatorServiceException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -45,7 +48,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
||||||
*/
|
*/
|
||||||
public static final Logger _log = LoggerFactory.getLogger(WorkspaceExplorerServiceImpl.class);
|
public static final Logger _log = LoggerFactory.getLogger(WorkspaceExplorerServiceImpl.class);
|
||||||
public static final String USERNAME_ATTRIBUTE = "username";
|
public static final String USERNAME_ATTRIBUTE = "username";
|
||||||
public static final String TEST_USER = "francesco.mangiacrapa";
|
public static final String TEST_USER = "test.user";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +352,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
||||||
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#loadSizeByItemId(java.lang.String)
|
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#loadSizeByItemId(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long loadSizeByItemId(String itemId) throws Exception {
|
public Long getSizeByItemId(String itemId) throws Exception {
|
||||||
|
|
||||||
_log.info("get Size By ItemId "+ itemId);
|
_log.info("get Size By ItemId "+ itemId);
|
||||||
try {
|
try {
|
||||||
|
@ -451,4 +454,29 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getFormattedSizeByItemId(java.lang.String, org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getReadableSizeByItemId(String itemId) throws Exception {
|
||||||
|
|
||||||
|
try{
|
||||||
|
_log.info("getFormattedSize ByItemId "+ itemId);
|
||||||
|
long size = getSizeByItemId(itemId);
|
||||||
|
return readableFileSize(size);
|
||||||
|
} catch (Exception e) {
|
||||||
|
_log.error("getFormattedSize By ItemId ", e);
|
||||||
|
throw new Exception(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readableFileSize(long size) {
|
||||||
|
if(size < 0) return "Unknown";
|
||||||
|
if(size == 0) return "Empty";
|
||||||
|
final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
|
||||||
|
int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
|
||||||
|
return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.widgets.wsexplorer.shared;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Jul 10, 2015
|
||||||
|
*/
|
||||||
|
public enum SizeFormatter {
|
||||||
|
|
||||||
|
|
||||||
|
KB("KB", 1024),
|
||||||
|
MB("MB", 1048576);
|
||||||
|
|
||||||
|
private long value;
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private SizeFormatter(String unit, long value) {
|
||||||
|
this.unit = unit;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
public long getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the unit
|
||||||
|
*/
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue