Working on Pagination
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@150997 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
101fe8786a
commit
4a45f4bf85
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.wsexplorer.client;
|
package org.gcube.portlets.widgets.wsexplorer.client;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 18, 2015
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 18, 2015
|
||||||
*/
|
*/
|
||||||
public class Util {
|
public class Util {
|
||||||
|
|
||||||
// public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
|
// public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
|
||||||
|
|
||||||
public static final ItemType[] FOLDERS = new ItemType[] {ItemType.FOLDER};
|
public static final ItemType[] FOLDERS = new ItemType[] {ItemType.FOLDER};
|
||||||
|
@ -60,7 +60,7 @@ public class Util {
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the image based on the item type.
|
* Returns the image based on the item type.
|
||||||
|
@ -69,6 +69,9 @@ public class Util {
|
||||||
*/
|
*/
|
||||||
public static ImageResource getImage(Item item)
|
public static ImageResource getImage(Item item)
|
||||||
{
|
{
|
||||||
|
if(item==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
// case ROOT: return WorkspaceLightTreeResources.INSTANCE.root();
|
// case ROOT: return WorkspaceLightTreeResources.INSTANCE.root();
|
||||||
case FOLDER: {
|
case FOLDER: {
|
||||||
|
@ -95,9 +98,9 @@ public class Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -114,17 +117,17 @@ public class Util {
|
||||||
}else
|
}else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void adjustSize(Element el, SimplePanel panel, int offset){
|
public static void adjustSize(Element el, SimplePanel panel, int offset){
|
||||||
if(el!=null){
|
if(el!=null){
|
||||||
int heigth = el.getClientHeight();
|
int heigth = el.getClientHeight();
|
||||||
GWT.log("getClientHeight adjustSize el: "+heigth);
|
GWT.log("getClientHeight adjustSize el: "+heigth);
|
||||||
heigth = (heigth-offset>100)?heigth-offset:0;
|
heigth = heigth-offset>100?heigth-offset:0;
|
||||||
if(heigth>0){
|
if(heigth>0){
|
||||||
GWT.log("set new Explorer size: "+heigth);
|
GWT.log("set new Explorer size: "+heigth);
|
||||||
panel.setHeight(heigth+"px");
|
panel.setHeight(heigth+"px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class WorkspaceExplorerConstants.
|
* The Class WorkspaceExplorerConstants.
|
||||||
*
|
*
|
||||||
|
@ -38,5 +39,6 @@ public class WorkspaceExplorerConstants {
|
||||||
|
|
||||||
public static final WorkspaceExplorerServiceAsync workspaceNavigatorService = GWT.create(WorkspaceExplorerService.class);
|
public static final WorkspaceExplorerServiceAsync workspaceNavigatorService = GWT.create(WorkspaceExplorerService.class);
|
||||||
|
|
||||||
public static int ITEMS_PER_PAGE = 10;
|
public static int ITEMS_PER_PAGE = 20;
|
||||||
|
public static int ITEM_START_INDEX = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,9 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
public WorkspaceExplorerController(String heightPanel){
|
public WorkspaceExplorerController(String heightPanel){
|
||||||
bindEvents();
|
bindEvents();
|
||||||
//As default all items are showable and selectable
|
//As default all items are showable and selectable
|
||||||
wsExplorer = new WorkspaceExplorer(eventBus, ItemType.values(), ItemType.values(), new ListDataProvider<Item>());
|
wsExplorer = new WorkspaceExplorer(eventBus, ItemType.values(), ItemType.values());
|
||||||
workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation, heightPanel);
|
wsExplorer.initTable(new ListDataProvider<Item>());
|
||||||
|
initExplorerPanel(heightPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,8 +85,9 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
public WorkspaceExplorerController(FilterCriteria filterCriteria, String heightPanel) {
|
public WorkspaceExplorerController(FilterCriteria filterCriteria, String heightPanel) {
|
||||||
bindEvents();
|
bindEvents();
|
||||||
//As default all items are showable and selectable
|
//As default all items are showable and selectable
|
||||||
wsExplorer = new WorkspaceExplorer(eventBus, filterCriteria, ItemType.values(), ItemType.values(), null, false, null, new ListDataProvider<Item>());
|
wsExplorer = new WorkspaceExplorer(eventBus, filterCriteria, ItemType.values(), ItemType.values(), null, false, null);
|
||||||
workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation, heightPanel);
|
wsExplorer.initTable(new ListDataProvider<Item>());
|
||||||
|
initExplorerPanel(heightPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,8 +104,21 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
public WorkspaceExplorerController(FilterCriteria filterCriteria, List<String> showProperties, String heightPanel) {
|
public WorkspaceExplorerController(FilterCriteria filterCriteria, List<String> showProperties, String heightPanel) {
|
||||||
bindEvents();
|
bindEvents();
|
||||||
//As default all items are showable and selectable
|
//As default all items are showable and selectable
|
||||||
wsExplorer = new WorkspaceExplorer(eventBus, filterCriteria, ItemType.values(), ItemType.values(), showProperties, false, null, new ListDataProvider<Item>());
|
wsExplorer = new WorkspaceExplorer(eventBus, filterCriteria, ItemType.values(), ItemType.values(), showProperties, false, null);
|
||||||
|
wsExplorer.initTable(new ListDataProvider<Item>());
|
||||||
|
initExplorerPanel(heightPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the explorer panel.
|
||||||
|
*
|
||||||
|
* @param heightPanel the height panel
|
||||||
|
*/
|
||||||
|
private void initExplorerPanel(String heightPanel){
|
||||||
workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation, heightPanel);
|
workspaceExplorerPanel = new WorkspaceExplorerPanel(5, wsExplorer.getPanel(), breadcrumbs, navigation, heightPanel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +138,7 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
|
|
||||||
if(item.isFolder()){
|
if(item.isFolder()){
|
||||||
try {
|
try {
|
||||||
wsExplorer.loadFolder(item, false);
|
wsExplorer.loadFolder(item, false, -1, -1, true);
|
||||||
loadParentBreadcrumbByItemId(item.getId(), true);
|
loadParentBreadcrumbByItemId(item.getId(), true);
|
||||||
|
|
||||||
if(item.isSpecialFolder())
|
if(item.isSpecialFolder())
|
||||||
|
@ -465,6 +480,8 @@ public class WorkspaceExplorerController implements EventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the event bus.
|
||||||
|
*
|
||||||
* @return the eventBus
|
* @return the eventBus
|
||||||
*/
|
*/
|
||||||
public HandlerManager getEventBus() {
|
public HandlerManager getEventBus() {
|
||||||
|
|
|
@ -32,15 +32,17 @@ import com.google.gwt.user.client.ui.DockPanel;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.view.client.ListDataProvider;
|
import com.google.gwt.view.client.ListDataProvider;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class WorkspaceResourcesExplorerPanel.
|
* The Class WorkspaceResourcesExplorerPanel.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Dec 3, 2015
|
* Jul 11, 2017
|
||||||
*/
|
*/
|
||||||
public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWorskpaceExplorerSelectNotificationListener{
|
public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWorskpaceExplorerSelectNotificationListener{
|
||||||
|
|
||||||
|
protected static final int ITEMS_PER_PAGE = WorkspaceExplorerConstants.ITEMS_PER_PAGE;
|
||||||
|
protected static final int ITEM_START_INDEX = WorkspaceExplorerConstants.ITEM_START_INDEX;
|
||||||
|
|
||||||
public final HandlerManager eventBus = new HandlerManager(null);
|
public final HandlerManager eventBus = new HandlerManager(null);
|
||||||
protected Breadcrumbs breadcrumbs = new Breadcrumbs(eventBus);
|
protected Breadcrumbs breadcrumbs = new Breadcrumbs(eventBus);
|
||||||
protected boolean isSelect = false;
|
protected boolean isSelect = false;
|
||||||
|
@ -188,9 +190,10 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
protected void initExplorer(String folderId, String folderName, ItemType[] selectableTypes, ItemType[] showableTypes, List<String> showProperties, FilterCriteria filter, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn) throws Exception{
|
protected void initExplorer(String folderId, String folderName, ItemType[] selectableTypes, ItemType[] showableTypes, List<String> showProperties, FilterCriteria filter, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn) throws Exception{
|
||||||
setParameters(folderId, folderName, showProperties, filter);
|
setParameters(folderId, folderName, showProperties, filter);
|
||||||
bindEvents();
|
bindEvents();
|
||||||
wsExplorer = new WorkspaceExplorer(eventBus, filter, showableTypes, selectableTypes, showProperties, showGcubeInfo, sortByColumn, new ListDataProvider<Item>(), new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME,DISPLAY_FIELD.CREATION_DATE});
|
wsExplorer = new WorkspaceExplorer(eventBus, filter, showableTypes, selectableTypes, showProperties, showGcubeInfo, sortByColumn, new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME,DISPLAY_FIELD.CREATION_DATE});
|
||||||
|
wsExplorer.initTable(new ListDataProvider<Item>());
|
||||||
Item item = new Item(folderId, folderName, true);
|
Item item = new Item(folderId, folderName, true);
|
||||||
wsExplorer.loadFolder(item, true);
|
wsExplorer.loadFolder(item, true, -1, -1, false);
|
||||||
initPanel("");
|
initPanel("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +248,7 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
Item item = (Item) loadFolderEvent.getTargetItem();
|
Item item = (Item) loadFolderEvent.getTargetItem();
|
||||||
if(item.isFolder()){
|
if(item.isFolder()){
|
||||||
try {
|
try {
|
||||||
wsExplorer.loadFolder(item, true);
|
wsExplorer.loadFolder(item, true, ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||||
loadParentBreadcrumbByItemId(item.getId(), true);
|
loadParentBreadcrumbByItemId(item.getId(), true);
|
||||||
clearMoreInfo();
|
clearMoreInfo();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -460,7 +463,7 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
this.filterCriteria = filterCriteria;
|
this.filterCriteria = filterCriteria;
|
||||||
wsExplorer.setNewFilterCriteria(filterCriteria);
|
wsExplorer.setNewFilterCriteria(filterCriteria);
|
||||||
try {
|
try {
|
||||||
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true);
|
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true, ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
wsExplorer.setAlert("Sorry, an error occurred during filter update", AlertType.ERROR);
|
wsExplorer.setAlert("Sorry, an error occurred during filter update", AlertType.ERROR);
|
||||||
|
@ -477,7 +480,7 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
this.showProperties = showProperties;
|
this.showProperties = showProperties;
|
||||||
wsExplorer.setNewShowProperties(showProperties);
|
wsExplorer.setNewShowProperties(showProperties);
|
||||||
try {
|
try {
|
||||||
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true);
|
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true, ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
wsExplorer.setAlert("Sorry, an error occurred during show properties update", AlertType.ERROR);
|
wsExplorer.setAlert("Sorry, an error occurred during show properties update", AlertType.ERROR);
|
||||||
|
@ -497,7 +500,7 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
|
||||||
wsExplorer.setNewFilterCriteria(filterCriteria);
|
wsExplorer.setNewFilterCriteria(filterCriteria);
|
||||||
wsExplorer.setNewShowProperties(showProperties);
|
wsExplorer.setNewShowProperties(showProperties);
|
||||||
try {
|
try {
|
||||||
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true);
|
wsExplorer.loadFolder(wsExplorer.getDisplayingFolderItem(), true, ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
wsExplorer.setAlert("Sorry, an error occurred during filters or properties update", AlertType.ERROR);
|
wsExplorer.setAlert("Sorry, an error occurred during filters or properties update", AlertType.ERROR);
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.wsexplorer.client.explore;
|
package org.gcube.portlets.widgets.wsexplorer.client.explore;
|
||||||
|
|
||||||
|
import static org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel.ITEMS_PER_PAGE;
|
||||||
|
import static org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel.ITEM_START_INDEX;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants;
|
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.event.BreadcrumbClickEvent;
|
import org.gcube.portlets.widgets.wsexplorer.client.event.BreadcrumbClickEvent;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.event.BreadcrumbClickEventHandler;
|
import org.gcube.portlets.widgets.wsexplorer.client.event.BreadcrumbClickEventHandler;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.event.ClickItemEvent;
|
import org.gcube.portlets.widgets.wsexplorer.client.event.ClickItemEvent;
|
||||||
|
@ -30,9 +32,8 @@ import com.google.gwt.user.client.ui.DockPanel;
|
||||||
*/
|
*/
|
||||||
public class WorkspaceResourcesExplorerPanelPaginated extends WorkspaceResourcesExplorerPanel {
|
public class WorkspaceResourcesExplorerPanelPaginated extends WorkspaceResourcesExplorerPanel {
|
||||||
|
|
||||||
private static final int ITEMS_PER_PAGE = WorkspaceExplorerConstants.ITEMS_PER_PAGE;
|
|
||||||
protected WorkspaceExplorerPaginated wsExplorer;
|
protected WorkspaceExplorerPaginated wsExplorer;
|
||||||
public static int ITEM_START_INDEX = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new workspace resources explorer panel paginated.
|
* Instantiates a new workspace resources explorer panel paginated.
|
||||||
|
@ -71,22 +72,6 @@ public class WorkspaceResourcesExplorerPanelPaginated extends WorkspaceResources
|
||||||
super(folderId, showOnlyFolders, showProperties, filter);
|
super(folderId, showOnlyFolders, showProperties, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new workspace resources explorer panel paginated.
|
|
||||||
*
|
|
||||||
* @param folderId the folder id
|
|
||||||
* @param showOnlyFolders the show only folders
|
|
||||||
* @param showProperties the show properties
|
|
||||||
* @param filter the filter
|
|
||||||
* @param showGcubeInfo the show gcube info
|
|
||||||
* @param sortByColumn the sort by column
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public WorkspaceResourcesExplorerPanelPaginated(String folderId, boolean showOnlyFolders, List<String> showProperties, FilterCriteria filter, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn) throws Exception {
|
|
||||||
super(folderId, showOnlyFolders, showProperties, filter, showGcubeInfo, sortByColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inits the explorer.
|
* Inits the explorer.
|
||||||
*
|
*
|
||||||
|
@ -107,7 +92,7 @@ public class WorkspaceResourcesExplorerPanelPaginated extends WorkspaceResources
|
||||||
wsExplorer = new WorkspaceExplorerPaginated(eventBus, filter, showableTypes, selectableTypes, showProperties, showGcubeInfo, sortByColumn, new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, DISPLAY_FIELD.CREATION_DATE});
|
wsExplorer = new WorkspaceExplorerPaginated(eventBus, filter, showableTypes, selectableTypes, showProperties, showGcubeInfo, sortByColumn, new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, DISPLAY_FIELD.CREATION_DATE});
|
||||||
wsExplorer.initPagination(ITEMS_PER_PAGE);
|
wsExplorer.initPagination(ITEMS_PER_PAGE);
|
||||||
Item item = new Item(folderId, folderName, true);
|
Item item = new Item(folderId, folderName, true);
|
||||||
wsExplorer.loadFolder(item, true, ITEM_START_INDEX, ITEMS_PER_PAGE);
|
wsExplorer.loadFolder(item, true, ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||||
initPanel("");
|
initPanel("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +145,7 @@ public class WorkspaceResourcesExplorerPanelPaginated extends WorkspaceResources
|
||||||
Item item = (Item) loadFolderEvent.getTargetItem();
|
Item item = (Item) loadFolderEvent.getTargetItem();
|
||||||
if(item.isFolder()){
|
if(item.isFolder()){
|
||||||
try {
|
try {
|
||||||
wsExplorer.loadFolder(item, true, ITEM_START_INDEX, ITEMS_PER_PAGE);
|
wsExplorer.loadFolder(item, true, ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||||
loadParentBreadcrumbByItemId(item.getId(), true);
|
loadParentBreadcrumbByItemId(item.getId(), true);
|
||||||
clearMoreInfo();
|
clearMoreInfo();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -6,12 +6,11 @@ package org.gcube.portlets.widgets.wsexplorer.client.view;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface FolderLoader.
|
* The Interface FolderLoader.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Jul 5, 2017
|
* Jul 11, 2017
|
||||||
*/
|
*/
|
||||||
public interface FolderLoader {
|
public interface FolderLoader {
|
||||||
|
|
||||||
|
@ -20,18 +19,10 @@ public interface FolderLoader {
|
||||||
*
|
*
|
||||||
* @param item the item
|
* @param item the item
|
||||||
* @param loadGcubeProperties the load gcube properties
|
* @param loadGcubeProperties the load gcube properties
|
||||||
|
* @param startIdx the start idx. Used for pagination
|
||||||
|
* @param limit the limit. Used for pagination
|
||||||
|
* @param resetStore the reset store. Used for pagination
|
||||||
* @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, int startIdx, int limit, boolean resetStore) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Load folder.
|
|
||||||
*
|
|
||||||
* @param item the item
|
|
||||||
* @param loadGcubeProperties the load gcube properties
|
|
||||||
* @param startIdx the start idx
|
|
||||||
* @param limit the limit
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public void loadFolder(final Item item, boolean loadGcubeProperties, int startIdx, int limit) throws Exception;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,19 +76,28 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
|
||||||
* @param showGcubeInfo the show gcube info
|
* @param showGcubeInfo the show gcube info
|
||||||
* @param sortByColumn the sort by column
|
* @param sortByColumn the sort by column
|
||||||
* @param fields the columns to display
|
* @param fields the columns to display
|
||||||
* @param dataProvider the data provider
|
|
||||||
*/
|
*/
|
||||||
private WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes, List<String> displayProperties, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn, DISPLAY_FIELD[] fields, AbstractDataProvider<Item> dataProvider){
|
private WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes, List<String> displayProperties, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn, DISPLAY_FIELD[] fields){
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.showGcubeItemsInfo = showGcubeInfo;
|
this.showGcubeItemsInfo = showGcubeInfo;
|
||||||
this.displayFields = fields;
|
this.displayFields = fields;
|
||||||
this.sortByColumn = sortByColumn;
|
this.sortByColumn = sortByColumn;
|
||||||
this.displayProperties = displayProperties;
|
this.displayProperties = displayProperties;
|
||||||
this.dataProvider = dataProvider;
|
|
||||||
this.explorerPanel = new ScrollPanel();
|
this.explorerPanel = new ScrollPanel();
|
||||||
setShowableTypes(showableTypes);
|
setShowableTypes(showableTypes);
|
||||||
setSelectableTypes(selectableTypes);
|
setSelectableTypes(selectableTypes);
|
||||||
this.itTables = new ItemsTable<Item>(eventBus, true, displayFields, displayProperties, showGcubeItemsInfo, sortByColumn, dataProvider);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the data provider table.
|
||||||
|
*
|
||||||
|
* @param dataProvider the new data provider table
|
||||||
|
*/
|
||||||
|
public void initTable(AbstractDataProvider<Item> dataProvider){
|
||||||
|
this.dataProvider = dataProvider;
|
||||||
|
this.itTables = new ItemsTable<Item>(eventBus, true, displayFields, displayProperties, showGcubeItemsInfo, sortByColumn);
|
||||||
|
this.itTables.initTable(null, null, dataProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,12 +107,10 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
|
||||||
* @param eventBus the event bus
|
* @param eventBus the event bus
|
||||||
* @param showableTypes the showable types
|
* @param showableTypes the showable types
|
||||||
* @param selectableTypes the selectable types
|
* @param selectableTypes the selectable types
|
||||||
* @param dataProvider the data provider
|
|
||||||
* @param fields the fields
|
* @param fields the fields
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes, AbstractDataProvider<Item> dataProvider, DISPLAY_FIELD...fields) {
|
public WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes, DISPLAY_FIELD...fields) {
|
||||||
this(eventBus, showableTypes, selectableTypes, null, false, null, fields, dataProvider);
|
this(eventBus, showableTypes, selectableTypes, null, false, null, fields);
|
||||||
// itTables = new ItemsTable<Item>(eventBus, true, fields, null, showGcubeItemsInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,11 +121,10 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
|
||||||
* @param showableTypes the showable types
|
* @param showableTypes the showable types
|
||||||
* @param selectableTypes the selectable types
|
* @param selectableTypes the selectable types
|
||||||
* @param displayProperties the display properties
|
* @param displayProperties the display properties
|
||||||
* @param dataProvider the data provider
|
|
||||||
* @param fields the fields
|
* @param fields the fields
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes, List<String> displayProperties, AbstractDataProvider<Item> dataProvider, DISPLAY_FIELD...fields) {
|
public WorkspaceExplorer(HandlerManager eventBus, ItemType[] showableTypes, ItemType[] selectableTypes, List<String> displayProperties, DISPLAY_FIELD...fields) {
|
||||||
this(eventBus, showableTypes, selectableTypes, displayProperties, false, null, fields, dataProvider);
|
this(eventBus, showableTypes, selectableTypes, displayProperties, false, null, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,11 +139,10 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
|
||||||
* @param displayProperties the display properties
|
* @param displayProperties the display properties
|
||||||
* @param showGcubeInfo the show gcube info
|
* @param showGcubeInfo the show gcube info
|
||||||
* @param sortByColumn the sort by column
|
* @param sortByColumn the sort by column
|
||||||
* @param dataProvider the data provider
|
|
||||||
* @param fields the fields
|
* @param fields the fields
|
||||||
*/
|
*/
|
||||||
public WorkspaceExplorer(HandlerManager eventBus, FilterCriteria filterCriteria, ItemType[] showableTypes, ItemType[] selectableTypes, List<String> displayProperties, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn, AbstractDataProvider<Item> dataProvider, DISPLAY_FIELD...fields) {
|
public WorkspaceExplorer(HandlerManager eventBus, FilterCriteria filterCriteria, ItemType[] showableTypes, ItemType[] selectableTypes, List<String> displayProperties, boolean showGcubeInfo, DISPLAY_FIELD sortByColumn, DISPLAY_FIELD...fields) {
|
||||||
this(eventBus, showableTypes, selectableTypes, displayProperties, showGcubeInfo, sortByColumn, fields, dataProvider);
|
this(eventBus, showableTypes, selectableTypes, displayProperties, showGcubeInfo, sortByColumn, fields);
|
||||||
this.filterCriteria = filterCriteria;
|
this.filterCriteria = filterCriteria;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -211,56 +216,56 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
|
||||||
this.displayingFolderItem = item;
|
this.displayingFolderItem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Load folder.
|
// * Load folder.
|
||||||
*
|
// *
|
||||||
* @param item the item
|
// * @param item the item
|
||||||
* @param loadGcubeProperties the load gcube properties
|
// * @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 {
|
||||||
GWT.log("loading folder data");
|
// GWT.log("loading folder data");
|
||||||
setLoading();
|
// setLoading();
|
||||||
|
//
|
||||||
if(!item.isFolder())
|
// if(!item.isFolder())
|
||||||
throw new Exception("Item is not a folder");
|
// throw new Exception("Item is not a folder");
|
||||||
|
//
|
||||||
if(item.getId()==null || item.getId().isEmpty())
|
// if(item.getId()==null || item.getId().isEmpty())
|
||||||
throw new Exception("Item id is null or empty");
|
// throw new Exception("Item id is null or empty");
|
||||||
|
//
|
||||||
// we make a copy of showable types
|
// // we make a copy of showable types
|
||||||
List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
|
// List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
|
||||||
|
//
|
||||||
// we get sure that folders are displayed
|
// // we get sure that folders are displayed
|
||||||
for (ItemType folder : Util.FOLDERS) {
|
// for (ItemType folder : Util.FOLDERS) {
|
||||||
if (!showableTypesParam.contains(folder))
|
// if (!showableTypesParam.contains(folder))
|
||||||
showableTypesParam.add(folder);
|
// showableTypesParam.add(folder);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
boolean purgeEmpyFolders = !showEmptyFolders;
|
// boolean purgeEmpyFolders = !showEmptyFolders;
|
||||||
// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions);
|
//// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions);
|
||||||
|
//
|
||||||
GWT.log("loading workspace folder by item id from server: "+item.getId());
|
// GWT.log("loading workspace folder by item id from server: "+item.getId());
|
||||||
WorkspaceExplorerConstants.workspaceNavigatorService.getFolder(item, showableTypesParam, purgeEmpyFolders, filterCriteria, loadGcubeProperties, new AsyncCallback<Item>() {
|
// WorkspaceExplorerConstants.workspaceNavigatorService.getFolder(item, showableTypesParam, purgeEmpyFolders, filterCriteria, loadGcubeProperties, new AsyncCallback<Item>() {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onFailure(Throwable caught) {
|
// public void onFailure(Throwable caught) {
|
||||||
Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
setAlert(caught.getMessage(), AlertType.ERROR);
|
// setAlert(caught.getMessage(), AlertType.ERROR);
|
||||||
GWT.log("Error loading workspace folder from server",caught);
|
// GWT.log("Error loading workspace folder from server",caught);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onSuccess(Item result) {
|
// public void onSuccess(Item result) {
|
||||||
if(item.getName()==null || item.getName().isEmpty())
|
// if(item.getName()==null || item.getName().isEmpty())
|
||||||
item.setName(result.getName());
|
// item.setName(result.getName());
|
||||||
|
//
|
||||||
updateExplorer(result.getChildren());
|
// updateExplorer(result.getChildren());
|
||||||
|
//
|
||||||
setDisplayingFolderItem(result);
|
// setDisplayingFolderItem(result);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Workspace Tree.
|
* Load the Workspace Tree.
|
||||||
|
@ -465,21 +470,58 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
|
||||||
itTables.reInitColumnsTable();
|
itTables.reInitColumnsTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.widgets.wsexplorer.client.view.FolderLoader#loadFolder(org.gcube.portlets.widgets.wsexplorer.shared.Item, boolean, int, int)
|
* @see org.gcube.portlets.widgets.wsexplorer.client.view.FolderLoader#loadFolder(org.gcube.portlets.widgets.wsexplorer.shared.Item, boolean, int, int, boolean)
|
||||||
*/
|
* Pagination is not implemented here
|
||||||
/**
|
|
||||||
* This constructor is never used here. Use {@link WorkspaceExplorerPaginated} class if you want paginate the results
|
|
||||||
*
|
|
||||||
* @param item the item
|
|
||||||
* @param loadGcubeProperties the load gcube properties
|
|
||||||
* @param startIdx the start idx
|
|
||||||
* @param limit the limit
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadFolder(Item item, boolean loadGcubeProperties, int startIdx, int limit) throws Exception {
|
public void loadFolder(
|
||||||
this.loadFolder(item, loadGcubeProperties);
|
final Item item, boolean loadGcubeProperties, int startIdx, int limit,
|
||||||
|
boolean resetStore)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
GWT.log("loading folder data");
|
||||||
|
setLoading();
|
||||||
|
|
||||||
|
if(!item.isFolder())
|
||||||
|
throw new Exception("Item is not a folder");
|
||||||
|
|
||||||
|
if(item.getId()==null || item.getId().isEmpty())
|
||||||
|
throw new Exception("Item id is null or empty");
|
||||||
|
|
||||||
|
// we make a copy of showable types
|
||||||
|
List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
|
||||||
|
|
||||||
|
// we get sure that folders are displayed
|
||||||
|
for (ItemType folder : Util.FOLDERS) {
|
||||||
|
if (!showableTypesParam.contains(folder))
|
||||||
|
showableTypesParam.add(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean purgeEmpyFolders = !showEmptyFolders;
|
||||||
|
// FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes,requiredProperties, allowedFileExtensions);
|
||||||
|
|
||||||
|
GWT.log("loading workspace folder by item id from server: "+item.getId());
|
||||||
|
WorkspaceExplorerConstants.workspaceNavigatorService.getFolder(item, showableTypesParam, purgeEmpyFolders, filterCriteria, loadGcubeProperties, new AsyncCallback<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Window.alert(caught.getMessage());
|
||||||
|
setAlert(caught.getMessage(), AlertType.ERROR);
|
||||||
|
GWT.log("Error loading workspace folder from server",caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Item result) {
|
||||||
|
if(item.getName()==null || item.getName().isEmpty())
|
||||||
|
item.setName(result.getName());
|
||||||
|
|
||||||
|
updateExplorer(result.getChildren());
|
||||||
|
|
||||||
|
setDisplayingFolderItem(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,14 @@ import com.google.gwt.user.cellview.client.SimplePager;
|
||||||
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
|
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.Label;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.google.gwt.view.client.AsyncDataProvider;
|
import com.google.gwt.view.client.AsyncDataProvider;
|
||||||
import com.google.gwt.view.client.HasData;
|
import com.google.gwt.view.client.HasData;
|
||||||
import com.google.gwt.view.client.Range;
|
import com.google.gwt.view.client.Range;
|
||||||
|
import com.google.gwt.view.client.SelectionModel;
|
||||||
|
import com.google.gwt.view.client.SingleSelectionModel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,14 +41,18 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
|
|
||||||
private VerticalPanel vPanel = new VerticalPanel();
|
private VerticalPanel vPanel = new VerticalPanel();
|
||||||
|
|
||||||
private static WorkspaceExplorerPaginated INSTANCE;
|
private Boolean newLoading = false;
|
||||||
|
|
||||||
|
private Boolean justTest = false;
|
||||||
|
|
||||||
//private ListDataProvider<Item> dataProvider = new ListDataProvider<Item>();
|
//private ListDataProvider<Item> dataProvider = new ListDataProvider<Item>();
|
||||||
|
|
||||||
private static MyCustomDataProvider<Item> dataProvider = new MyCustomDataProvider<Item>();
|
private MyCustomDataProvider<Item> dataProvider = new MyCustomDataProvider<Item>();
|
||||||
|
|
||||||
protected boolean loadGcubeProperties = false;
|
protected boolean loadGcubeProperties = false;
|
||||||
|
|
||||||
|
protected Widget orginalLoadingIndicator = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new workspace explorer paginated.
|
* Instantiates a new workspace explorer paginated.
|
||||||
*
|
*
|
||||||
|
@ -62,8 +70,10 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
ItemType[] showableTypes, ItemType[] selectableTypes,
|
ItemType[] showableTypes, ItemType[] selectableTypes,
|
||||||
List<String> displayProperties, boolean showGcubeInfo,
|
List<String> displayProperties, boolean showGcubeInfo,
|
||||||
DISPLAY_FIELD sortByColumn, DISPLAY_FIELD[] fields) {
|
DISPLAY_FIELD sortByColumn, DISPLAY_FIELD[] fields) {
|
||||||
super(eventBus, filterCriteria, showableTypes, selectableTypes, displayProperties, showGcubeInfo, sortByColumn, dataProvider);
|
super(eventBus, filterCriteria, showableTypes, selectableTypes, displayProperties, showGcubeInfo, sortByColumn);
|
||||||
INSTANCE = this;
|
initTable(dataProvider);
|
||||||
|
newLoading = true;
|
||||||
|
orginalLoadingIndicator = getCellTable().getLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,10 +84,8 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
*/
|
*/
|
||||||
public AsyncDataProvider<Item> getAsycnDataProvider(){
|
public AsyncDataProvider<Item> getAsycnDataProvider(){
|
||||||
return (AsyncDataProvider<Item>) getCellTable().getDataProvider();
|
return (AsyncDataProvider<Item>) getCellTable().getDataProvider();
|
||||||
//return new MyCustomDataProvider<Item>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cell tale.
|
* Gets the cell tale.
|
||||||
*
|
*
|
||||||
|
@ -87,17 +95,13 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
return getItTables().getCellTable();
|
return getItTables().getCellTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load folder.
|
/* (non-Javadoc)
|
||||||
*
|
* @see org.gcube.portlets.widgets.wsexplorer.client.view.WorkspaceExplorer#loadFolder(org.gcube.portlets.widgets.wsexplorer.shared.Item, boolean, int, int, boolean)
|
||||||
* @param item the item
|
|
||||||
* @param loadGcubeProperties the load gcube properties
|
|
||||||
* @param startIdx the start idx
|
|
||||||
* @param limit the limit
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
*/
|
||||||
public void loadFolder(final Item item, final boolean loadGcubeProperties, final int startIdx, final int limit) throws Exception {
|
public void loadFolder(final Item item, final boolean loadGcubeProperties, final int startIdx, final int limit, final boolean resetStore) throws Exception {
|
||||||
GWT.log("loading folder data");
|
newLoading = resetStore;
|
||||||
|
GWT.log("loading folder data for Item: "+item.getId()+" [startIdx: "+startIdx +", limit: "+limit+", resetStore:"+resetStore+"]");
|
||||||
//super.loadFolder(item, loadGcubeProperties);
|
//super.loadFolder(item, loadGcubeProperties);
|
||||||
this.loadGcubeProperties = loadGcubeProperties;
|
this.loadGcubeProperties = loadGcubeProperties;
|
||||||
setLoading();
|
setLoading();
|
||||||
|
@ -118,8 +122,9 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
|
|
||||||
final boolean purgeEmpyFolders = !showEmptyFolders;
|
final boolean purgeEmpyFolders = !showEmptyFolders;
|
||||||
|
|
||||||
|
//IF IS INIT OR A DOUBLE CLICK
|
||||||
if(getDisplayingFolderItem()==null || getDisplayingFolderItem().getId()!=item.getId()){
|
if(getDisplayingFolderItem()==null || getDisplayingFolderItem().getId()!=item.getId()){
|
||||||
|
GWT.log("Performing Get Folder Children Count ");
|
||||||
WorkspaceExplorerConstants.workspaceNavigatorService.getFolderChildrenCount(item, new AsyncCallback<Integer>() {
|
WorkspaceExplorerConstants.workspaceNavigatorService.getFolderChildrenCount(item, new AsyncCallback<Integer>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,11 +132,20 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Integer result) {
|
public void onSuccess(final Integer result) {
|
||||||
GWT.log("Folder Children count: "+result);
|
GWT.log("Folder Children count: "+result);
|
||||||
getAsycnDataProvider().updateRowCount(result, false);
|
|
||||||
|
int newStartIndex = startIdx;
|
||||||
|
getAsycnDataProvider().updateRowCount(result, true);
|
||||||
|
|
||||||
|
if(newLoading){
|
||||||
|
GWT.log("Cleaning all data...");
|
||||||
|
newStartIndex = 0;
|
||||||
|
GWT.log("Store reset performed start index is: "+newStartIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//final Range range = display.getVisibleRange();
|
//final Range range = display.getVisibleRange();
|
||||||
perfomGetFolderChildren(item, loadGcubeProperties, startIdx, limit, purgeEmpyFolders, showableTypesParam);
|
perfomGetFolderChildren(item, loadGcubeProperties, newStartIndex, limit, purgeEmpyFolders, showableTypesParam);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else
|
}else
|
||||||
|
@ -142,6 +156,7 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perfom get folder children.
|
* Perfom get folder children.
|
||||||
*
|
*
|
||||||
|
@ -161,21 +176,49 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
Window.alert(caught.getMessage());
|
Window.alert(caught.getMessage());
|
||||||
setAlert(caught.getMessage(), AlertType.ERROR);
|
setAlert(caught.getMessage(), AlertType.ERROR);
|
||||||
GWT.log("Error loading workspace folder from server",caught);
|
GWT.log("Error loading workspace folder from server",caught);
|
||||||
|
newLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Item result) {
|
public void onSuccess(Item result) {
|
||||||
|
|
||||||
if(item.getName()==null || item.getName().isEmpty())
|
if(item.getName()==null || item.getName().isEmpty())
|
||||||
item.setName(result.getName());
|
item.setName(result.getName());
|
||||||
|
|
||||||
GWT.log("Returned "+result.getChildren().size() +" children");
|
//GWT.log("Returned "+result.getChildren().size() +" children");
|
||||||
//getItTables().updateItems(result.getChildren(), true);
|
//getItTables().updateItems(result.getChildren(), true);
|
||||||
|
|
||||||
|
if(newLoading){
|
||||||
|
getCellTable().setVisibleRangeAndClearData(new Range(startIdx, WorkspaceExplorerConstants.ITEMS_PER_PAGE), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectionModel<? super Item> sm = getCellTable().getSelectionModel();
|
||||||
|
|
||||||
|
if(sm instanceof SingleSelectionModel){
|
||||||
|
SingleSelectionModel ssm = (SingleSelectionModel) sm;
|
||||||
|
ssm.clear();
|
||||||
|
}
|
||||||
|
|
||||||
getAsycnDataProvider().updateRowData(startIdx, result.getChildren());
|
getAsycnDataProvider().updateRowData(startIdx, result.getChildren());
|
||||||
getCellTable().setPageSize(result.getChildren().size()+1);
|
|
||||||
//cellList.setVisibleRange(startIdx, result.getChildren().size());
|
if(result.getChildren().size()==0){
|
||||||
getCellTable().redraw();
|
getCellTable().setLoadingIndicator(new Label("No data"));
|
||||||
GWT.log("cellList size: "+getCellTable().getRowCount());
|
}else{
|
||||||
|
getCellTable().setLoadingIndicator(orginalLoadingIndicator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//getCellTable().setVisibleRangeAndClearData(new Range(startIdx, result.getChildren()).), false);
|
||||||
|
//getAsycnDataProvider().getDataDisplays().
|
||||||
|
GWT.log("Updating row data startIndex: "+startIdx + " size: "+result.getChildren().size());
|
||||||
|
|
||||||
|
//getCellTable().setPageSize(result.getChildren().size()+1);
|
||||||
|
//getCellTable().setVisibleRange(startIdx, result.getChildren().size());
|
||||||
|
//getCellTable().redraw();
|
||||||
|
//GWT.log("cellTable size: "+getCellTable().getRowCount());
|
||||||
setDisplayingFolderItem(result);
|
setDisplayingFolderItem(result);
|
||||||
|
newLoading = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -220,7 +263,7 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
* Jul 5, 2017
|
* Jul 5, 2017
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
public static class MyCustomDataProvider<T> extends AsyncDataProvider<T> {
|
public class MyCustomDataProvider<T> extends AsyncDataProvider<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link #onRangeChanged(HasData)} is called when the table requests a
|
* {@link #onRangeChanged(HasData)} is called when the table requests a
|
||||||
|
@ -235,45 +278,24 @@ public class WorkspaceExplorerPaginated extends WorkspaceExplorer{
|
||||||
// Get the new range.
|
// Get the new range.
|
||||||
final Range range = display.getVisibleRange();
|
final Range range = display.getVisibleRange();
|
||||||
|
|
||||||
// We are creating fake data. Normally, the data will come
|
|
||||||
// from a
|
|
||||||
// server.
|
|
||||||
// int start = range.getStart();
|
|
||||||
// int length = range.getLength();
|
|
||||||
// List<Item> newData = new ArrayList<Item>();
|
|
||||||
// for (int i = start; i < start + length; i++) {
|
|
||||||
// newData.add(new Item("Item "+i, "Item "+i, false));
|
|
||||||
// }
|
|
||||||
// // Push the data to the displays. AsyncDataProvider will
|
|
||||||
// // only update
|
|
||||||
// // displays that are within range of the data.
|
|
||||||
// updateRowData(start, newData);
|
|
||||||
|
|
||||||
int start = range.getStart();
|
int start = range.getStart();
|
||||||
int length = range.getLength();
|
int length = range.getLength();
|
||||||
GWT.log("Range changed: "+start +" "+length);
|
|
||||||
|
|
||||||
// try {
|
GWT.log("Range changed: "+start +" "+length + " visible count: "+display.getVisibleItemCount());
|
||||||
// GWT.log("qui");
|
|
||||||
// INSTANCE.loadFolder(INSTANCE.getItemSelected(), INSTANCE.loadGcubeProperties, start, length);
|
if(newLoading){
|
||||||
// GWT.log("qua");
|
GWT.log("OnLoading is true.. returning");
|
||||||
// }
|
return;
|
||||||
// catch (Exception e) {
|
}
|
||||||
// // TODO Auto-generated catch block
|
try {
|
||||||
// e.printStackTrace();
|
loadFolder(getDisplayingFolderItem(), loadGcubeProperties, start, length, false);
|
||||||
// }
|
}
|
||||||
// Item item = new Item(WorkspaceExplorerPaginated.this.getF, folderName, true);
|
catch (Exception e) {
|
||||||
// WorkspaceExplorerPaginated.this.loadFolder(WorkspaceExplorerPaginated.this.getItemSelected(), super.get,start, length);
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public MyCustomDataProvider() {
|
|
||||||
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,12 @@ import com.google.gwt.view.client.SelectionChangeEvent;
|
||||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||||
import com.google.gwt.view.client.SingleSelectionModel;
|
import com.google.gwt.view.client.SingleSelectionModel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class AbstractItemTable.
|
* The Class AbstractItemsCellTable.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 19, 2015
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Jul 11, 2017
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractItemsCellTable<T> {
|
public abstract class AbstractItemsCellTable<T> {
|
||||||
|
@ -39,7 +41,7 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
protected T itemContextMenu = null;
|
protected T itemContextMenu = null;
|
||||||
protected boolean showMoreInfo;
|
protected boolean showMoreInfo;
|
||||||
protected SingleSelectionModel<T> ssm;
|
protected SingleSelectionModel<T> ssm;
|
||||||
private HandlerManager eventBus;
|
protected HandlerManager eventBus;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,8 +49,9 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
*
|
*
|
||||||
* @param pager the pager
|
* @param pager the pager
|
||||||
* @param pagination the pagination
|
* @param pagination the pagination
|
||||||
|
* @param dataProvider the data provider
|
||||||
*/
|
*/
|
||||||
public abstract void initTable(final SimplePager pager, final Pagination pagination);
|
public abstract void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider<T> dataProvider);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +62,7 @@ public abstract class AbstractItemsCellTable<T> {
|
||||||
* @param dataProvider the data provider
|
* @param dataProvider the data provider
|
||||||
* @param pageSize the page size
|
* @param pageSize the page size
|
||||||
*/
|
*/
|
||||||
public void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider, int pageSize){
|
protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider, int pageSize){
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.showMoreInfo = fireOnClick;
|
this.showMoreInfo = fireOnClick;
|
||||||
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
|
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
public DateTimeFormat dtformat = DateTimeFormat.getFormat("dd MMM hh:mm aaa yyyy");
|
public DateTimeFormat dtformat = DateTimeFormat.getFormat("dd MMM hh:mm aaa yyyy");
|
||||||
public ImageResource info = WorkspaceExplorerResources.ICONS.infoSquare();
|
public ImageResource info = WorkspaceExplorerResources.ICONS.infoSquare();
|
||||||
|
|
||||||
public AbstractDataProvider<T> dataProvider;
|
private AbstractDataProvider<T> dataProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Enum DISPLAY_FIELD.
|
* The Enum DISPLAY_FIELD.
|
||||||
|
@ -82,18 +82,14 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
* @param displayProperties the display properties
|
* @param displayProperties the display properties
|
||||||
* @param showGcubeItemsInfo the show gcube items info
|
* @param showGcubeItemsInfo the show gcube items info
|
||||||
* @param startSortByColumn the start sort by column
|
* @param startSortByColumn the start sort by column
|
||||||
* @param asyncDataProvider the async data provider
|
|
||||||
*/
|
*/
|
||||||
public ItemsTable(HandlerManager eventBus, boolean showMoreInfo, DISPLAY_FIELD[] fields, List<String> displayProperties, boolean showGcubeItemsInfo, DISPLAY_FIELD startSortByColumn, AbstractDataProvider<T> dataProvider) {
|
public ItemsTable(HandlerManager eventBus, boolean showMoreInfo, DISPLAY_FIELD[] fields, List<String> displayProperties, boolean showGcubeItemsInfo, DISPLAY_FIELD startSortByColumn) {
|
||||||
this.dataProvider = dataProvider;
|
this.eventBus = eventBus;
|
||||||
initAbstractTable(eventBus, showMoreInfo, dataProvider, WorkspaceExplorerConstants.ITEMS_PER_PAGE);
|
|
||||||
this.dataProvider.addDataDisplay(sortedCellTable);
|
|
||||||
this.startSortByColumn = startSortByColumn;
|
|
||||||
setDisplayFields(fields);
|
setDisplayFields(fields);
|
||||||
setDisplayProperties(displayProperties);
|
setDisplayProperties(displayProperties);
|
||||||
setShowGcubeItemsInfo(showGcubeItemsInfo);
|
setShowGcubeItemsInfo(showGcubeItemsInfo);
|
||||||
this.isAsyncronusTable = dataProvider instanceof AbstractDataProvider?true:false;
|
this.startSortByColumn = startSortByColumn;
|
||||||
initTable(null, null);
|
//initTable(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +125,13 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
* @see org.gcube.portlets.admin.gcubereleases.client.view.AbstractPackageTable#initTable(com.google.gwt.user.cellview.client.AbstractCellTable, com.google.gwt.user.cellview.client.SimplePager, com.github.gwtbootstrap.client.ui.Pagination)
|
* @see org.gcube.portlets.admin.gcubereleases.client.view.AbstractPackageTable#initTable(com.google.gwt.user.cellview.client.AbstractCellTable, com.google.gwt.user.cellview.client.SimplePager, com.github.gwtbootstrap.client.ui.Pagination)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initTable(final SimplePager pager, final Pagination pagination) {
|
public void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider<T> dataProvider) {
|
||||||
|
this.dataProvider = dataProvider;
|
||||||
|
initAbstractTable(eventBus, showMoreInfo, dataProvider, WorkspaceExplorerConstants.ITEMS_PER_PAGE);
|
||||||
|
this.dataProvider.addDataDisplay(sortedCellTable);
|
||||||
|
|
||||||
|
this.isAsyncronusTable = dataProvider instanceof AbstractDataProvider?true:false;
|
||||||
|
|
||||||
sortedCellTable.setEmptyTableWidget(new Label("No data."));
|
sortedCellTable.setEmptyTableWidget(new Label("No data."));
|
||||||
|
|
||||||
if(this.displayFields.contains(DISPLAY_FIELD.ICON)){
|
if(this.displayFields.contains(DISPLAY_FIELD.ICON)){
|
||||||
|
@ -430,7 +432,7 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
|
||||||
for(int i=0;i<count;i++){
|
for(int i=0;i<count;i++){
|
||||||
sortedCellTable.removeColumn(0);
|
sortedCellTable.removeColumn(0);
|
||||||
}
|
}
|
||||||
initTable(null, null);
|
initTable(null, null, dataProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class Item implements IsSerializable, ItemInterface{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.isFolder = isFolder;
|
this.isFolder = isFolder;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.type = isFolder?ItemType.FOLDER:ItemType.UNKNOWN_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue