ref 13226:StorageHub - Update workspace-sharing-widget to SH

https://support.d4science.org/issues/13226

Updated to StorageHub

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@177245 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-02-22 14:18:35 +00:00
parent 5d06d96a4f
commit 3b414664ca
4 changed files with 189 additions and 181 deletions

View File

@ -1,11 +1,15 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets-user.workspace-portlet.6-22-0"
date="2019-02-22">
<Change>Updated to StorageHub [ticket: #13226]</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.workspace-portlet.6-21-0" <Changeset component="org.gcube.portlets-user.workspace-portlet.6-21-0"
date="${buildDate}"> date="2018-11-01">
<Change>Task #13106: Provide public links for versioned files <Change>Task #13106: Provide public links for versioned files
</Change> </Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets-user.workspace-portlet.6-20-0" <Changeset component="org.gcube.portlets-user.workspace-portlet.6-20-0"
date="${buildDate}"> date="2018-09-01">
<Change>Task #12604: Migrate Move operation to StorageHub <Change>Task #12604: Migrate Move operation to StorageHub
</Change> </Change>
<Change>Incident #12922: Bug fix</Change> <Change>Incident #12922: Bug fix</Change>

View File

@ -40,21 +40,9 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
*/ */
public class GxtBottomToolBarItem extends ToolBar { public class GxtBottomToolBarItem extends ToolBar {
/**
*
*/
private static final String VERSIONS = "Versions"; private static final String VERSIONS = "Versions";
/**
*
*/
protected static final String INFO = "Info"; protected static final String INFO = "Info";
/**
*
*/
protected static final String READ = "Read"; protected static final String READ = "Read";
/**
*
*/
protected static final String HISTORY = "History"; protected static final String HISTORY = "History";
private static final String EDIT_ADMINISTRATOR = "Edit Administrator/s"; private static final String EDIT_ADMINISTRATOR = "Edit Administrator/s";
@ -81,7 +69,9 @@ public class GxtBottomToolBarItem extends ToolBar{
initToolbar(); initToolbar();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see com.extjs.gxt.ui.client.widget.Component#onLoad() * @see com.extjs.gxt.ui.client.widget.Component#onLoad()
*/ */
@Override @Override
@ -151,7 +141,8 @@ public class GxtBottomToolBarItem extends ToolBar{
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
AppController.getEventBus().fireEvent(new FileVersioningEvent(WorkspaceVersioningOperation.SHOW, null, null, null, null)); AppController.getEventBus()
.fireEvent(new FileVersioningEvent(WorkspaceVersioningOperation.SHOW, null, null, null, null));
} }
}); });
@ -195,13 +186,13 @@ public class GxtBottomToolBarItem extends ToolBar{
/** /**
* Sets the visible add administrators. * Sets the visible add administrators.
* *
* @param bool the new visible add administrators * @param bool
* the new visible add administrators
*/ */
private void setVisibleAddAdministrators(boolean bool) { private void setVisibleAddAdministrators(boolean bool) {
btnAddAdmin.setVisible(bool); btnAddAdmin.setVisible(bool);
} }
/** /**
* Reset details. * Reset details.
*/ */
@ -213,12 +204,13 @@ public class GxtBottomToolBarItem extends ToolBar{
this.txtOwner.setText(""); this.txtOwner.setText("");
} }
/** /**
* Enable info history buttons. * Enable info history buttons.
* *
* @param selectedFile the selected file * @param target
* @param enable the enable * target
* @param enable
* the enable
*/ */
public void enableInfoHistoryButtons(FileModel target, boolean enable) { public void enableInfoHistoryButtons(FileModel target, boolean enable) {
bHistory.setEnabled(enable); bHistory.setEnabled(enable);
@ -228,7 +220,9 @@ public class GxtBottomToolBarItem extends ToolBar{
btnVersioning.setEnabled(false); btnVersioning.setEnabled(false);
if (target != null) { if (target != null) {
GXTFolderItemTypeEnum category = target.getGXTFolderItemType(); GXTFolderItemTypeEnum category = target.getGXTFolderItemType();
if(category!=null && (category.equals(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE) || category.equals(GXTFolderItemTypeEnum.EXTERNAL_FILE) || category.equals(GXTFolderItemTypeEnum.EXTERNAL_IMAGE))) if (category != null && (category.equals(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE)
|| category.equals(GXTFolderItemTypeEnum.EXTERNAL_FILE)
|| category.equals(GXTFolderItemTypeEnum.EXTERNAL_IMAGE)))
btnVersioning.setEnabled(enable); btnVersioning.setEnabled(enable);
} }
} }
@ -236,11 +230,16 @@ public class GxtBottomToolBarItem extends ToolBar{
/** /**
* Sets the details. * Sets the details.
* *
* @param itemName the item name * @param itemName
* @param description the description * the item name
* @param dimension the dimension * @param description
* @param creationTime the creation time * the description
* @param owner the owner * @param dimension
* the dimension
* @param creationTime
* the creation time
* @param owner
* the owner
*/ */
public void setDetails(String itemName, String description, String dimension, String creationTime, String owner) { public void setDetails(String itemName, String description, String dimension, String creationTime, String owner) {
@ -256,7 +255,8 @@ public class GxtBottomToolBarItem extends ToolBar{
/** /**
* Update acl info. * Update acl info.
* *
* @param acl the acl * @param acl
* the acl
*/ */
public void updateACLInfo(WorkspaceACL acl) { public void updateACLInfo(WorkspaceACL acl) {
setVisibleAddAdministrators(false); setVisibleAddAdministrators(false);
@ -271,12 +271,13 @@ public class GxtBottomToolBarItem extends ToolBar{
this.layout(); this.layout();
} }
/** /**
* Update add administator info. * Update add administator info.
* *
* @param loginUserLogger the login user logger * @param loginUserLogger
* @param acl the acl * the login user logger
* @param acl
* the acl
*/ */
public void updateAddAdministatorInfo(String loginUserLogger, ExtendedWorkspaceACL acl) { public void updateAddAdministatorInfo(String loginUserLogger, ExtendedWorkspaceACL acl) {
setVisibleAddAdministrators(false); setVisibleAddAdministrators(false);
@ -284,7 +285,8 @@ public class GxtBottomToolBarItem extends ToolBar{
if (loginUserLogger == null || loginUserLogger.isEmpty()) if (loginUserLogger == null || loginUserLogger.isEmpty())
MessageBox.alert("Error", "I could not get you username yet.. please try again", null); MessageBox.alert("Error", "I could not get you username yet.. please try again", null);
ConstantsExplorer.log("acl isBaseSharedFolder: "+acl.isBaseSharedFolder() +", user type: "+acl.getUserType() + ", owner: "+acl.getLoginOwner() + ", acl item id: "+acl.getWorkspaceItemId()); ConstantsExplorer.log("acl isBaseSharedFolder: " + acl.isBaseSharedFolder() + ", user type: "
+ acl.getUserType() + ", owner: " + acl.getLoginOwner() + ", acl item id: " + acl.getWorkspaceItemId());
if (acl.isBaseSharedFolder()) { if (acl.isBaseSharedFolder()) {
if (acl.getUserType().equals(USER_TYPE.ADMINISTRATOR)) { if (acl.getUserType().equals(USER_TYPE.ADMINISTRATOR)) {
@ -297,7 +299,8 @@ public class GxtBottomToolBarItem extends ToolBar{
/** /**
* Update trash icon. * Update trash icon.
* *
* @param trashIsFull the trash is full * @param trashIsFull
* the trash is full
*/ */
public void updateTrashIcon(boolean trashIsFull) { public void updateTrashIcon(boolean trashIsFull) {
@ -310,7 +313,8 @@ public class GxtBottomToolBarItem extends ToolBar{
/** /**
* Update items number. * Update items number.
* *
* @param size the size * @param size
* the size
*/ */
public void updateItemsNumber(int size) { public void updateItemsNumber(int size) {
if (size <= 0) if (size <= 0)

View File

@ -74,8 +74,12 @@ public class TrashInfoContainer extends LayoutContainer {
this.gridDropTarget = new GridDropTarget(grid) { this.gridDropTarget = new GridDropTarget(grid) {
/* (non-Javadoc) /*
* @see com.extjs.gxt.ui.client.dnd.GridDropTarget#onDragDrop(com.extjs.gxt.ui.client.event.DNDEvent) * (non-Javadoc)
*
* @see
* com.extjs.gxt.ui.client.dnd.GridDropTarget#onDragDrop(com.extjs.
* gxt.ui.client.event.DNDEvent)
*/ */
@Override @Override
@ -95,7 +99,6 @@ public class TrashInfoContainer extends LayoutContainer {
super.onDragDrop(e); super.onDragDrop(e);
} }
private List<FileModel> getDragSource(DNDEvent event) { private List<FileModel> getDragSource(DNDEvent event) {
@ -112,31 +115,47 @@ public class TrashInfoContainer extends LayoutContainer {
for (int i = 0; i < listItemsSource.size(); i++) { for (int i = 0; i < listItemsSource.size(); i++) {
if(listItemsSource.get(i) instanceof TreeStoreModel){ //DRAG FROM TREE if (listItemsSource.get(i) instanceof TreeStoreModel) { // DRAG
// FROM
// TREE
// System.out.println("qui 1"); // System.out.println("qui 1");
// //
// TreeStoreModel itemSource = (TreeStoreModel) listItemsSource.get(i); // TreeStoreModel itemSource = (TreeStoreModel)
// listItemsSource.get(i);
// //
// listDraggedFile.add((FileModel) itemSource.getModel()); // listDraggedFile.add((FileModel)
// itemSource.getModel());
// sourceFileModel = (FileModel) itemSource.getModel(); // sourceFileModel = (FileModel)
// itemSource.getModel();
// //
// if(sourceFileModel.getParentFileModel()!=null) // if(sourceFileModel.getParentFileModel()!=null)
// //
// System.out.println("Trash Source Name " + sourceFileModel.getName() + " id " + sourceFileModel.getIdentifier() + " end drag " + " Parent Name: " + sourceFileModel.getParentFileModel().getName() + "id " + sourceFileModel.getParentFileModel().getIdentifier()); // System.out.println("Trash Source Name " +
// sourceFileModel.getName() + " id " +
// sourceFileModel.getIdentifier() + " end drag " +
// " Parent Name: " +
// sourceFileModel.getParentFileModel().getName() +
// "id " +
// sourceFileModel.getParentFileModel().getIdentifier());
// else // else
// System.out.println("Trash Source Name " + sourceFileModel.getName() + " id " + sourceFileModel.getIdentifier() + " end drag "); // System.out.println("Trash Source Name " +
// sourceFileModel.getName() + " id " +
// sourceFileModel.getIdentifier() + " end drag ");
} else if (listItemsSource.get(i) instanceof FileGridModel) { // DRAG
}else if(listItemsSource.get(i) instanceof FileGridModel){ //DRAG FROM GRID // FROM
// GRID
listDraggedFile.add((FileModel) listItemsSource.get(i)); listDraggedFile.add((FileModel) listItemsSource.get(i));
// FileGridModel fileGrid = listItemsSource.get(i); // FileGridModel fileGrid = listItemsSource.get(i);
// System.out.println("qui 2"); // System.out.println("qui 2");
// System.out.println("class "+listItemsSource.get(i).getClass()); // System.out.println("class
// "+listItemsSource.get(i).getClass());
} }
// System.out.println("Trash Child count: " + itemSource.getChildCount()); // System.out.println("Trash Child count: " +
// itemSource.getChildCount());
} }
} }
@ -183,13 +202,13 @@ public class TrashInfoContainer extends LayoutContainer {
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
if (checkSelection()) if (checkSelection())
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.RESTORE, grid.getSelectionModel().getSelectedItems())); AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.RESTORE,
grid.getSelectionModel().getSelectedItems()));
} }
}); });
bar.add(buttonRestore); bar.add(buttonRestore);
buttonDelete = new Button(WorkspaceTrashOperation.DELETE_PERMANENTLY.getLabel(), Resources.getIconDeleteItem()); buttonDelete = new Button(WorkspaceTrashOperation.DELETE_PERMANENTLY.getLabel(), Resources.getIconDeleteItem());
buttonDelete.setToolTip(WorkspaceTrashOperation.DELETE_PERMANENTLY.getOperationDescription()); buttonDelete.setToolTip(WorkspaceTrashOperation.DELETE_PERMANENTLY.getOperationDescription());
buttonDelete.setScale(ButtonScale.SMALL); buttonDelete.setScale(ButtonScale.SMALL);
@ -200,13 +219,13 @@ public class TrashInfoContainer extends LayoutContainer {
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
if (checkSelection()) if (checkSelection())
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.DELETE_PERMANENTLY, grid.getSelectionModel().getSelectedItems())); AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.DELETE_PERMANENTLY,
grid.getSelectionModel().getSelectedItems()));
} }
}); });
bar.add(buttonDelete); bar.add(buttonDelete);
bar.add(new SeparatorMenuItem()); bar.add(new SeparatorMenuItem());
buttonRestoreAll = new Button(WorkspaceTrashOperation.RESTORE_ALL.getLabel(), Resources.getIconRecycle()); buttonRestoreAll = new Button(WorkspaceTrashOperation.RESTORE_ALL.getLabel(), Resources.getIconRecycle());
@ -239,7 +258,6 @@ public class TrashInfoContainer extends LayoutContainer {
bar.add(buttonEmptyTrash); bar.add(buttonEmptyTrash);
bar.add(new FillToolItem()); bar.add(new FillToolItem());
Button buttonRefresh = new Button(WorkspaceTrashOperation.REFRESH.getLabel(), Resources.getIconRefresh()); Button buttonRefresh = new Button(WorkspaceTrashOperation.REFRESH.getLabel(), Resources.getIconRefresh());
@ -264,10 +282,13 @@ public class TrashInfoContainer extends LayoutContainer {
ColumnConfig icon = new ColumnConfig(FileGridModel.ICON, "", 40); ColumnConfig icon = new ColumnConfig(FileGridModel.ICON, "", 40);
ColumnConfig name = createSortableColumnConfig(FileGridModel.NAME, FileGridModel.NAME, 190); ColumnConfig name = createSortableColumnConfig(FileGridModel.NAME, FileGridModel.NAME, 190);
ColumnConfig type = createSortableColumnConfig(FileGridModel.TYPE, FileGridModel.TYPE, 80); ColumnConfig type = createSortableColumnConfig(FileGridModel.TYPE, FileGridModel.TYPE, 80);
ColumnConfig originalPath = createSortableColumnConfig(FileTrashedModel.STOREINFO.ORIGINALPATH.toString(), "Original Path", 190); ColumnConfig originalPath = createSortableColumnConfig(FileTrashedModel.STOREINFO.ORIGINALPATH.toString(),
ColumnConfig deleteDate = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEDATE.toString(), "Deleted Date", 90); "Original Path", 190);
ColumnConfig deleteDate = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEDATE.toString(),
"Deleted Date", 90);
deleteDate.setDateTimeFormat(DateTimeFormat.getFormat("dd MMM hh:mm aaa yyyy")); deleteDate.setDateTimeFormat(DateTimeFormat.getFormat("dd MMM hh:mm aaa yyyy"));
ColumnConfig deleteUser = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEUSER.toString(), "Deleted By", 150); ColumnConfig deleteUser = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEUSER.toString(),
"Deleted By", 150);
ColumnModel cm = new ColumnModel(Arrays.asList(icon, name, type, originalPath, deleteDate, deleteUser)); ColumnModel cm = new ColumnModel(Arrays.asList(icon, name, type, originalPath, deleteDate, deleteUser));
@ -281,20 +302,22 @@ public class TrashInfoContainer extends LayoutContainer {
this.grid.setView(view); this.grid.setView(view);
this.grid.setContextMenu(null); this.grid.setContextMenu(null);
GridCellRenderer<FileModel> folderRender = new GridCellRenderer<FileModel>() { GridCellRenderer<FileModel> folderRender = new GridCellRenderer<FileModel>() {
@Override @Override
public String render(FileModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<FileModel> store, Grid<FileModel> grid) { public String render(FileModel model, String property, ColumnData config, int rowIndex, int colIndex,
ListStore<FileModel> store, Grid<FileModel> grid) {
String val = model.get(property); String val = model.get(property);
String color = "black"; String color = "black";
if (val != null && val.equals(GXTFolderItemTypeEnum.FOLDER.toString())) { if (val != null && val.equals(GXTFolderItemTypeEnum.FOLDER.toString())) {
// color = "#EEC900"; // color = "#EEC900";
return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val + "' style='font-weight: bold;color:" + color + "'>" + val + "</span>"; return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val
+ "' style='font-weight: bold;color:" + color + "'>" + val + "</span>";
} else { } else {
if (val == null) if (val == null)
val = ""; val = "";
return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val + "' style='color:" + color + "'>" + val + "</span>"; return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val
+ "' style='color:" + color + "'>" + val + "</span>";
} }
} }
}; };
@ -304,7 +327,6 @@ public class TrashInfoContainer extends LayoutContainer {
GridFilters filters = new GridFilters(); GridFilters filters = new GridFilters();
filters.setLocal(true); filters.setLocal(true);
StringFilter nameFilter = new StringFilter(FileGridModel.NAME); StringFilter nameFilter = new StringFilter(FileGridModel.NAME);
StringFilter typeFilter = new StringFilter(FileGridModel.TYPE); StringFilter typeFilter = new StringFilter(FileGridModel.TYPE);
DateFilter dateFilter = new DateFilter(FileTrashedModel.STOREINFO.DELETEDATE.toString()); DateFilter dateFilter = new DateFilter(FileTrashedModel.STOREINFO.DELETEDATE.toString());
@ -334,11 +356,8 @@ public class TrashInfoContainer extends LayoutContainer {
grid.setStyleAttribute("borderTop", "none"); grid.setStyleAttribute("borderTop", "none");
cp.add(grid); cp.add(grid);
} }
public void setPanelSize(int width, int height) { public void setPanelSize(int width, int height) {
if (width > 0 && height > 0 && grid != null) { if (width > 0 && height > 0 && grid != null) {
@ -371,21 +390,17 @@ public class TrashInfoContainer extends LayoutContainer {
activeButtonsOnNotEmtpy(store.getModels().size() > 0); activeButtonsOnNotEmtpy(store.getModels().size() > 0);
} }
/**
* @param b
*/
private void activeButtonsOnNotEmtpy(boolean isNotEmpty) { private void activeButtonsOnNotEmtpy(boolean isNotEmpty) {
buttonRestoreAll.setEnabled(isNotEmpty); buttonRestoreAll.setEnabled(isNotEmpty);
buttonEmptyTrash.setEnabled(isNotEmpty); buttonEmptyTrash.setEnabled(isNotEmpty);
} }
/**
* @param multi
*/
protected void activeButtonOnSelection(boolean bool) { protected void activeButtonOnSelection(boolean bool) {
buttonDelete.setEnabled(bool); buttonDelete.setEnabled(bool);
buttonRestore.setEnabled(bool); buttonRestore.setEnabled(bool);
} }
private void updateStore(ListStore<FileTrashedModel> store) { private void updateStore(ListStore<FileTrashedModel> store) {
resetStore(); resetStore();
@ -396,8 +411,7 @@ public class TrashInfoContainer extends LayoutContainer {
this.grid.getStore().removeAll(); this.grid.getStore().removeAll();
} }
public ColumnConfig createSortableColumnConfig(String id, String name, public ColumnConfig createSortableColumnConfig(String id, String name, int width) {
int width) {
ColumnConfig columnConfig = new ColumnConfig(id, name, width); ColumnConfig columnConfig = new ColumnConfig(id, name, width);
columnConfig.setSortable(true); columnConfig.setSortable(true);
@ -409,11 +423,6 @@ public class TrashInfoContainer extends LayoutContainer {
// cp.layout(); // cp.layout();
} }
/**
*
* @param identifier
* @return
*/
public FileTrashedModel getFileModelByIdentifier(String identifier) { public FileTrashedModel getFileModelByIdentifier(String identifier) {
return store.findModel(FileGridModel.IDENTIFIER, identifier); return store.findModel(FileGridModel.IDENTIFIER, identifier);
@ -422,18 +431,17 @@ public class TrashInfoContainer extends LayoutContainer {
/** /**
* *
* @param identifier (MANDATORY) * @param identifier
* @return * mandatory
* @return operation result
*/ */
public boolean deleteItem(String identifier) { public boolean deleteItem(String identifier) {
FileTrashedModel fileTarget = getFileModelByIdentifier(identifier); FileTrashedModel fileTarget = getFileModelByIdentifier(identifier);
if (fileTarget != null) { if (fileTarget != null) {
return deleteItem(fileTarget); return deleteItem(fileTarget);
} } else
else
System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store"); System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store");
return false; return false;
@ -441,8 +449,9 @@ public class TrashInfoContainer extends LayoutContainer {
/** /**
* *
* @param fileTarget (MANDATORY) * @param fileTarget
* @return * (MANDATORY)
* @return operation result
*/ */
private boolean deleteItem(FileTrashedModel fileTarget) { private boolean deleteItem(FileTrashedModel fileTarget) {
@ -455,9 +464,8 @@ public class TrashInfoContainer extends LayoutContainer {
return true; return true;
} else } else
System.out.println("Record Error: file target with " System.out.println(
+ fileTarget.getIdentifier() "Record Error: file target with " + fileTarget.getIdentifier() + " identifier not exist in store");
+ " identifier not exist in store");
activeButtonsOnNotEmtpy(store.getModels().size() > 0); activeButtonsOnNotEmtpy(store.getModels().size() > 0);

View File

@ -47,10 +47,7 @@ public class WindowTrash extends Window {
setHeading("Trash"); setHeading("Trash");
} }
/**
*
* @return
*/
public static synchronized WindowTrash getInstance(){ public static synchronized WindowTrash getInstance(){
if(INSTANCE==null) if(INSTANCE==null)
INSTANCE = new WindowTrash(); INSTANCE = new WindowTrash();
@ -150,11 +147,6 @@ public class WindowTrash extends Window {
} }
/**
*
* @param fileModelId
* @return
*/
public boolean deleteFileFromTrash(String fileModelId){ public boolean deleteFileFromTrash(String fileModelId){
boolean deleted = this.trashContainers.deleteItem(fileModelId); boolean deleted = this.trashContainers.deleteItem(fileModelId);