2546: Endow Workspace Resources Explorer with filtering and display features
Task-Url: https://support.d4science.org/issues/2546 Added code to change properties and filters on-the-fly git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@128437 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3a75f96768
commit
19c9117877
|
@ -59,6 +59,10 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
private ScrollPanel southPanel = new ScrollPanel();
|
private ScrollPanel southPanel = new ScrollPanel();
|
||||||
private String folderId;
|
private String folderId;
|
||||||
private String folderName;
|
private String folderName;
|
||||||
|
private List<String> showProperties;
|
||||||
|
private FilterCriteria filterCriteria;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new workspace folder explorer select panel.
|
* Instantiates a new workspace folder explorer select panel.
|
||||||
|
@ -123,6 +127,8 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
private void initExplorer(String folderId, String folderName, ItemType[] selectableTypes, ItemType[] showableTypes, List<String> showProperties, FilterCriteria filter) throws Exception{
|
private void initExplorer(String folderId, String folderName, ItemType[] selectableTypes, ItemType[] showableTypes, List<String> showProperties, FilterCriteria filter) throws Exception{
|
||||||
this.folderId = folderId;
|
this.folderId = folderId;
|
||||||
this.folderName = folderName;
|
this.folderName = folderName;
|
||||||
|
this.showProperties = showProperties;
|
||||||
|
this.filterCriteria = filter;
|
||||||
bindEvents();
|
bindEvents();
|
||||||
wsExplorer = new WorkspaceExplorer(eventBus, filter, showableTypes, selectableTypes, showProperties, new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, DISPLAY_FIELD.CREATION_DATE});
|
wsExplorer = new WorkspaceExplorer(eventBus, filter, showableTypes, selectableTypes, showProperties, new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, DISPLAY_FIELD.CREATION_DATE});
|
||||||
Item item = new Item(folderId, folderName, true);
|
Item item = new Item(folderId, folderName, true);
|
||||||
|
@ -399,4 +405,82 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the filter criteria.
|
||||||
|
*
|
||||||
|
* @return the filterCriteria
|
||||||
|
*/
|
||||||
|
public FilterCriteria getFilterCriteria() {
|
||||||
|
|
||||||
|
return filterCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates filter criteria.
|
||||||
|
*
|
||||||
|
* @param filterCriteria the filter criteria
|
||||||
|
*/
|
||||||
|
public void updatesFilterCriteria(FilterCriteria filterCriteria) {
|
||||||
|
|
||||||
|
this.filterCriteria = filterCriteria;
|
||||||
|
wsExplorer.setNewFilterCriteria(filterCriteria);
|
||||||
|
try {
|
||||||
|
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
wsExplorer.setAlert("Sorry, an error occurred during filter update", AlertType.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates filter criteria.
|
||||||
|
*
|
||||||
|
* @param showProperties the show properties
|
||||||
|
*/
|
||||||
|
public void updatesShowProperties(List<String> showProperties) {
|
||||||
|
|
||||||
|
this.showProperties = showProperties;
|
||||||
|
wsExplorer.setNewShowProperties(showProperties);
|
||||||
|
try {
|
||||||
|
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
wsExplorer.setAlert("Sorry, an error occurred during show properties update", AlertType.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates filters and properties.
|
||||||
|
*
|
||||||
|
* @param filterCriteria the filter criteria
|
||||||
|
* @param showProperties the show properties
|
||||||
|
*/
|
||||||
|
public void updatesFiltersAndProperties(FilterCriteria filterCriteria, List<String> showProperties) {
|
||||||
|
|
||||||
|
this.filterCriteria = filterCriteria;
|
||||||
|
this.showProperties = showProperties;
|
||||||
|
wsExplorer.setNewFilterCriteria(filterCriteria);
|
||||||
|
wsExplorer.setNewShowProperties(showProperties);
|
||||||
|
try {
|
||||||
|
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
wsExplorer.setAlert("Sorry, an error occurred during filters or properties update", AlertType.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the show properties.
|
||||||
|
*
|
||||||
|
* @return the showProperties
|
||||||
|
*/
|
||||||
|
public List<String> getShowProperties() {
|
||||||
|
|
||||||
|
return showProperties;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,15 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
private DISPLAY_FIELD[] displayFields;
|
private DISPLAY_FIELD[] displayFields;
|
||||||
private HandlerManager eventBus;
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
private Item displayingFolderItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new workspace explorer.
|
||||||
|
*
|
||||||
|
* @param eventBus the event bus
|
||||||
|
* @param showableTypes the showable types
|
||||||
|
* @param selectableTypes the selectable types
|
||||||
|
*/
|
||||||
private WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes){
|
private WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes){
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
setShowableTypes(showableTypes);
|
setShowableTypes(showableTypes);
|
||||||
|
@ -162,15 +170,27 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
public void onSuccess(Item item) {
|
public void onSuccess(Item item) {
|
||||||
eventBus.fireEvent(new RootLoadedEvent(item));
|
eventBus.fireEvent(new RootLoadedEvent(item));
|
||||||
updateExplorer(item.getChildren());
|
updateExplorer(item.getChildren());
|
||||||
|
|
||||||
|
setDisplayingFolderItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the displaying folder item.
|
||||||
|
*
|
||||||
|
* @param item the new displaying folder item
|
||||||
|
*/
|
||||||
|
private void setDisplayingFolderItem(Item item) {
|
||||||
|
this.displayingFolderItem = item;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load folder.
|
* Load folder.
|
||||||
*
|
*
|
||||||
* @param item the item
|
* @param item the item
|
||||||
|
* @param loadGcubeProperties the load gcube properties
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public void loadFolder(final Item item, boolean loadGcubeProperties) throws Exception {
|
public void loadFolder(final Item item, boolean loadGcubeProperties) throws Exception {
|
||||||
|
@ -211,6 +231,8 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
item.setName(result.getName());
|
item.setName(result.getName());
|
||||||
|
|
||||||
updateExplorer(result.getChildren());
|
updateExplorer(result.getChildren());
|
||||||
|
|
||||||
|
setDisplayingFolderItem(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -246,8 +268,10 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Item items) {
|
public void onSuccess(Item item) {
|
||||||
updateExplorer(items.getChildren());
|
updateExplorer(item.getChildren());
|
||||||
|
|
||||||
|
setDisplayingFolderItem(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -270,7 +294,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
/**
|
/**
|
||||||
* Adds the item to explorer.
|
* Adds the item to explorer.
|
||||||
*
|
*
|
||||||
* @param items the items
|
* @param item the item
|
||||||
*/
|
*/
|
||||||
public void addItemToExplorer(Item item){
|
public void addItemToExplorer(Item item){
|
||||||
GWT.log("workspace explorer add item.."+item);
|
GWT.log("workspace explorer add item.."+item);
|
||||||
|
@ -372,4 +396,35 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
|
||||||
this.showableTypes.clear();
|
this.showableTypes.clear();
|
||||||
if (showableTypes!=null) for (ItemType type:showableTypes) this.showableTypes.add(type);
|
if (showableTypes!=null) for (ItemType type:showableTypes) this.showableTypes.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new filter criteria.
|
||||||
|
*
|
||||||
|
* @param filterCriteria the new new filter criteria
|
||||||
|
*/
|
||||||
|
public void setNewFilterCriteria(FilterCriteria filterCriteria) {
|
||||||
|
this.filterCriteria = filterCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the displaying folder item.
|
||||||
|
*
|
||||||
|
* @return the displayingFolderItem
|
||||||
|
*/
|
||||||
|
public Item getDisplayingFolderItem() {
|
||||||
|
|
||||||
|
return displayingFolderItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the new show properties.
|
||||||
|
*
|
||||||
|
* @param displayProperties the new new show properties
|
||||||
|
*/
|
||||||
|
public void setNewShowProperties(List<String> displayProperties) {
|
||||||
|
this.itTables.setDisplayProperties(displayProperties);
|
||||||
|
itTables.reInitColumnsTable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
Item extensionItem;
|
Item extensionItem;
|
||||||
String value = null;
|
String value = null;
|
||||||
if(object instanceof Item){
|
if(object instanceof Item){
|
||||||
extensionItem = (Item) object;
|
extensionItem = object;
|
||||||
value = extensionItem.getGcubeProperties().get(column);
|
value = extensionItem.getGcubeProperties().get(column);
|
||||||
}
|
}
|
||||||
return value==null?"":value;
|
return value==null?"":value;
|
||||||
|
@ -241,8 +241,8 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
Item e1 = (Item) o1;
|
Item e1 = o1;
|
||||||
Item e2 = (Item) o2;
|
Item e2 = o2;
|
||||||
|
|
||||||
String v1 = e1.getGcubeProperties().get(column);
|
String v1 = e1.getGcubeProperties().get(column);
|
||||||
String v2 = e2.getGcubeProperties().get(column);
|
String v2 = e2.getGcubeProperties().get(column);
|
||||||
|
@ -286,6 +286,18 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
this.displayProperties = properties;
|
this.displayProperties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset columns table.
|
||||||
|
*/
|
||||||
|
public void reInitColumnsTable(){
|
||||||
|
int count = cellTable.getColumnCount();
|
||||||
|
for(int i=0;i<count;i++){
|
||||||
|
cellTable.removeColumn(0);
|
||||||
|
}
|
||||||
|
initTable(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the display fields.
|
* Gets the display fields.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
///**
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//package org.gcube.portlets.widgets.wsexplorer.shared;
|
|
||||||
//
|
|
||||||
//import java.io.Serializable;
|
|
||||||
//import java.util.HashMap;
|
|
||||||
//import java.util.Map;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * The Class ExtensionItem.
|
|
||||||
// *
|
|
||||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
||||||
// * Apr 28, 2016
|
|
||||||
// */
|
|
||||||
//public class ExtensionItem extends Item implements Serializable{
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
// private static final long serialVersionUID = -4697549410044199051L;
|
|
||||||
//
|
|
||||||
// private Map<String, String> gcubeProperties;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Instantiates a new extension item.
|
|
||||||
// *
|
|
||||||
// * @param id the id
|
|
||||||
// * @param name the name
|
|
||||||
// * @param isFolder the is folder
|
|
||||||
// * @param gcubeProperties the gcube properties
|
|
||||||
// */
|
|
||||||
// public ExtensionItem(String id, String name, boolean isFolder, Map<String, String> gcubeProperties) {
|
|
||||||
// super(id,name,isFolder);
|
|
||||||
// this.gcubeProperties = new HashMap<String, String>(1);
|
|
||||||
// this.gcubeProperties = gcubeProperties;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the gcube properties.
|
|
||||||
// *
|
|
||||||
// * @return the gcubeProperties
|
|
||||||
// */
|
|
||||||
// public Map<String, String> getGcubeProperties() {
|
|
||||||
//
|
|
||||||
// return gcubeProperties;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Sets the gcube properties.
|
|
||||||
// *
|
|
||||||
// * @param gcubeProperties the gcubeProperties to set
|
|
||||||
// */
|
|
||||||
// public void setGcubeProperties(Map<String, String> gcubeProperties) {
|
|
||||||
//
|
|
||||||
// this.gcubeProperties = gcubeProperties;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /* (non-Javadoc)
|
|
||||||
// * @see java.lang.Object#toString()
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public String toString() {
|
|
||||||
//
|
|
||||||
// StringBuilder builder = new StringBuilder();
|
|
||||||
// builder.append("ExtensionItem [gcubeProperties=");
|
|
||||||
// builder.append(gcubeProperties);
|
|
||||||
// builder.append("]");
|
|
||||||
// return builder.toString();
|
|
||||||
// }
|
|
||||||
//}
|
|
Loading…
Reference in New Issue