added feature to customize the message in case of empty list

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@174471 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-11-29 14:33:30 +00:00
parent a3398cbd9a
commit dfb325deec
3 changed files with 45 additions and 30 deletions

View File

@ -143,9 +143,9 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
} }
loadExplorer(captionTxt, null, null); loadExplorer(captionTxt, null, null);
customizeEmptyMessage(showOnlyFolders);
} }
/** /**
* Instantiates a new workspace explorer select dialog. * Instantiates a new workspace explorer select dialog.
* *
@ -181,6 +181,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
} }
loadExplorer(captionTxt, baseFolderId, baseFolderName); loadExplorer(captionTxt, baseFolderId, baseFolderName);
customizeEmptyMessage(showOnlyFolders);
} }
@ -207,6 +208,7 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
} }
loadExplorer(captionTxt, baseFolderId, baseFolderName); loadExplorer(captionTxt, baseFolderId, baseFolderName);
customizeEmptyMessage(showOnlyFolders);
} }
/** /**
@ -235,35 +237,15 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
loadExplorer(captionTxt, null, null); loadExplorer(captionTxt, null, null);
} }
// /**
// * Load explorer.
// * If folder id is null or empty the explorer loads the root element
// * Otherwise, it loads the folder id
// *
// * @param captionTxt the caption txt
// * @param folderId the folder id
// */
// private void loadExplorer(String captionTxt, String folderId){
//
// if(folderId==null || folderId.isEmpty())
// controller.getEventBus().fireEvent(new LoadRootEvent());
// else{
// Item item = new Item(folderId, "", true);
// controller.getEventBus().fireEvent(new LoadFolderEvent<Item>(item));
// }
// initDialog(captionTxt);
// }
/** /**
* Load explorer. * Load explorer.
* If folder id is null or empty the explorer loads the root element * If folder id is null or empty the explorer loads the root element
* Otherwise, it loads the folder id * Otherwise, it loads the folder id
* *
* @param captionTxt the caption txt * @param captionTxt the caption txt
* @param folderId the folder id * @param folderId the folder id
* @param baseFolderName the base folder name * @param baseFolderName the base folder name
*/ */
private void loadExplorer(String captionTxt, String folderId, String baseFolderName){ private void loadExplorer(String captionTxt, String folderId, String baseFolderName){
if(folderId==null || folderId.isEmpty()) if(folderId==null || folderId.isEmpty())
@ -275,6 +257,17 @@ public class WorkspaceExplorerSelectDialog extends Modal implements HasWorskpace
initDialog(captionTxt); initDialog(captionTxt);
} }
/**
* Customize empty message.
*
* @param showOnlyFolders the show only folders
*/
private void customizeEmptyMessage(boolean showOnlyFolders){
//AFTER THE INIT I'M CHANGING THE MESSAGE IN CASE OF ONLY FOLDER ARE SHWOWN
if(showOnlyFolders)
controller.getWsExplorer().getItTables().setEmptyTableMessage("No folder selectable here");
}
/** /**
* Inits the dialog. * Inits the dialog.
* *

View File

@ -139,6 +139,7 @@ public class WorkspaceExplorerSelectPanel extends ScrollPanel implements HasWors
setShowableTypes(itemsType); setShowableTypes(itemsType);
} }
loadExplorer(captionTxt, null); loadExplorer(captionTxt, null);
customizeEmptyMessage(showOnlyFolders);
} }
/** /**
@ -160,7 +161,15 @@ public class WorkspaceExplorerSelectPanel extends ScrollPanel implements HasWors
setSelectableTypes(itemsType); setSelectableTypes(itemsType);
setShowableTypes(itemsType); setShowableTypes(itemsType);
} }
loadExplorer(captionTxt, baseFolderId); loadExplorer(captionTxt, baseFolderId);
customizeEmptyMessage(showOnlyFolders);
}
private void customizeEmptyMessage(boolean showOnlyFolders){
//AFTER THE INIT I'M CHANGING THE MESSAGE IN CASE OF ONLY FOLDER ARE SHWOWN
if(showOnlyFolders)
controller.getWsExplorer().getItTables().setEmptyTableMessage("No folder selectable here");
} }
/** /**

View File

@ -134,7 +134,8 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
//this.isAsyncronusTable = dataProvider instanceof AbstractDataProvider?true:false; //this.isAsyncronusTable = dataProvider instanceof AbstractDataProvider?true:false;
this.isAsyncronusTable = dataProvider instanceof ListDataProvider?false:true; this.isAsyncronusTable = dataProvider instanceof ListDataProvider?false:true;
sortedCellTable.setEmptyTableWidget(new Label(WorkspaceExplorerConstants.WORKSPACE_FOLDER_EMPTY_MESSAGE)); //sortedCellTable.setEmptyTableWidget(new Label(WorkspaceExplorerConstants.WORKSPACE_FOLDER_EMPTY_MESSAGE));
setEmptyTableMessage(WorkspaceExplorerConstants.WORKSPACE_FOLDER_EMPTY_MESSAGE);
if(this.displayFields.contains(DISPLAY_FIELD.ICON)){ if(this.displayFields.contains(DISPLAY_FIELD.ICON)){
//ICONS //ICONS
@ -481,4 +482,16 @@ public class ItemsTable<T extends Item> extends AbstractItemsCellTable<T> implem
public T getSelectedItem() { public T getSelectedItem() {
return ssm.getSelectedObject(); return ssm.getSelectedObject();
} }
/**
* Sets the empty table message.
*
* @param msg the new empty table message
*/
public void setEmptyTableMessage(String msg){
msg = msg!=null&&!msg.isEmpty()?msg:WorkspaceExplorerConstants.WORKSPACE_FOLDER_EMPTY_MESSAGE;
if(sortedCellTable!=null)
sortedCellTable.setEmptyTableWidget(new Label(msg));
}
} }