From 3b414664cadcff3441e66f11f621170552287e6a Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 22 Feb 2019 14:18:35 +0000 Subject: [PATCH] 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 --- distro/changelog.xml | 8 +- .../view/toolbars/GxtBottomToolBarItem.java | 132 +++++----- .../client/view/trash/TrashInfoContainer.java | 232 +++++++++--------- .../client/view/trash/WindowTrash.java | 10 +- 4 files changed, 195 insertions(+), 187 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index cc0f229..5b89973 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,11 +1,15 @@ + + Updated to StorageHub [ticket: #13226] + + date="2018-11-01"> Task #13106: Provide public links for versioned files + date="2018-09-01"> Task #12604: Migrate Move operation to StorageHub Incident #12922: Bug fix diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBottomToolBarItem.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBottomToolBarItem.java index 57cd0ac..6e5143b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBottomToolBarItem.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBottomToolBarItem.java @@ -38,23 +38,11 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype; * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it */ -public class GxtBottomToolBarItem extends ToolBar{ +public class GxtBottomToolBarItem extends ToolBar { - /** - * - */ private static final String VERSIONS = "Versions"; - /** - * - */ protected static final String INFO = "Info"; - /** - * - */ protected static final String READ = "Read"; - /** - * - */ protected static final String HISTORY = "History"; private static final String EDIT_ADMINISTRATOR = "Edit Administrator/s"; @@ -76,12 +64,14 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * Instantiates a new gxt bottom tool bar item. */ - public GxtBottomToolBarItem(){ + public GxtBottomToolBarItem() { super(); initToolbar(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see com.extjs.gxt.ui.client.widget.Component#onLoad() */ @Override @@ -93,7 +83,7 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * Inits the toolbar. */ - private void initToolbar(){ + private void initToolbar() { btnGetTrash = new Button("Trash"); btnGetTrash.setIcon(Resources.getTrashEmpty()); @@ -151,14 +141,15 @@ public class GxtBottomToolBarItem extends ToolBar{ @Override 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)); } }); btnAddAdmin = new Button(EDIT_ADMINISTRATOR); - //TODO CHANGE ICON + // TODO CHANGE ICON btnAddAdmin.setIcon(Resources.getIconManageAdministrator()); -// btnAddAdmin.setIcon(Resources.getIconAddAdministrator()); + // btnAddAdmin.setIcon(Resources.getIconAddAdministrator()); btnAddAdmin.setScale(ButtonScale.MEDIUM); btnAddAdmin.addSelectionListener(new SelectionListener() { @@ -195,17 +186,17 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * 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); } - /** * Reset details. */ - public void resetDetails(){ + public void resetDetails() { this.txtDimension.setText(""); this.txtCreationTime.setText(""); @@ -213,22 +204,25 @@ public class GxtBottomToolBarItem extends ToolBar{ this.txtOwner.setText(""); } - /** * Enable info history buttons. * - * @param selectedFile the selected file - * @param enable the enable + * @param target + * target + * @param enable + * the enable */ - public void enableInfoHistoryButtons(FileModel target, boolean enable){ + public void enableInfoHistoryButtons(FileModel target, boolean enable) { bHistory.setEnabled(enable); bRead.setEnabled(enable); btnGetInfo.setEnabled(enable); btnVersioning.setEnabled(false); - if(target!=null){ + if (target != null) { 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); } } @@ -236,13 +230,18 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * Sets the details. * - * @param itemName the item name - * @param description the description - * @param dimension the dimension - * @param creationTime the creation time - * @param owner the owner + * @param itemName + * the item name + * @param description + * the description + * @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) { this.resetDetails(); @@ -256,12 +255,13 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * Update acl info. * - * @param acl the acl + * @param acl + * the acl */ - public void updateACLInfo(WorkspaceACL acl){ + public void updateACLInfo(WorkspaceACL acl) { setVisibleAddAdministrators(false); - if(acl==null){ + if (acl == null) { aclDivInfo.updateInfo(null, null); return; } @@ -271,23 +271,25 @@ public class GxtBottomToolBarItem extends ToolBar{ this.layout(); } - /** * Update add administator info. * - * @param loginUserLogger the login user logger - * @param acl the acl + * @param loginUserLogger + * the login user logger + * @param acl + * the acl */ - public void updateAddAdministatorInfo(String loginUserLogger, ExtendedWorkspaceACL acl){ + public void updateAddAdministatorInfo(String loginUserLogger, ExtendedWorkspaceACL acl) { setVisibleAddAdministrators(false); - if(loginUserLogger==null || loginUserLogger.isEmpty()) + if (loginUserLogger == null || loginUserLogger.isEmpty()) 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.getUserType().equals(USER_TYPE.ADMINISTRATOR)){ + if (acl.isBaseSharedFolder()) { + if (acl.getUserType().equals(USER_TYPE.ADMINISTRATOR)) { setVisibleAddAdministrators(true); } } @@ -297,11 +299,12 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * 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) { - if(trashIsFull) + if (trashIsFull) btnGetTrash.setIcon(Resources.getTrashFull()); else btnGetTrash.setIcon(Resources.getTrashEmpty()); @@ -310,15 +313,16 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * Update items number. * - * @param size the size + * @param size + * the size */ public void updateItemsNumber(int size) { - if(size<=0) + if (size <= 0) labelItemsNumber.setText("No Items"); - else if(size==1) + else if (size == 1) labelItemsNumber.setText("1 Item"); - else if(size>1) - labelItemsNumber.setText(size +" Items"); + else if (size > 1) + labelItemsNumber.setText(size + " Items"); hpItemsNumber.layout(); } @@ -326,21 +330,21 @@ public class GxtBottomToolBarItem extends ToolBar{ /** * Sets the items number to center. */ - public void setItemsNumberToCenter(){ + public void setItemsNumberToCenter() { - if(this.isRendered()){ + if (this.isRendered()) { String width = this.getElement().getStyle().getWidth(); width = width.replace("px", ""); - try{ + try { long intWidth = Long.parseLong(width); - intWidth = intWidth/2-30; //calculate the center - intWidth = intWidth-60*3; //previous buttons - GWT.log("refreshSize width is "+width); -// hpItemsNumber.setWidth(intWidth+"px"); - hpItemsNumber.setStyleAttribute("margin-left", intWidth+"px"); + intWidth = intWidth / 2 - 30; // calculate the center + intWidth = intWidth - 60 * 3; // previous buttons + GWT.log("refreshSize width is " + width); + // hpItemsNumber.setWidth(intWidth+"px"); + hpItemsNumber.setStyleAttribute("margin-left", intWidth + "px"); hpItemsNumber.layout(); - }catch (Exception e) { - GWT.log("width is not a long "+e); + } catch (Exception e) { + GWT.log("width is not a long " + e); } } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java index 4a9af5c..24b2dd7 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java @@ -53,7 +53,7 @@ public class TrashInfoContainer extends LayoutContainer { private ContentPanel cp; private GroupingStore store = new GroupingStore(); private ListStore typeStoreOperation = new ListStore(); - private GridDropTarget gridDropTarget; + private GridDropTarget gridDropTarget; private Button buttonDelete; private Button buttonRestore; private Button buttonRestoreAll; @@ -63,7 +63,7 @@ public class TrashInfoContainer extends LayoutContainer { initContentPanel(); initGrid(); createToolBar(); -// initDropTarget(); + // initDropTarget(); activeButtonOnSelection(false); } @@ -72,19 +72,23 @@ public class TrashInfoContainer extends LayoutContainer { */ private void initDropTarget() { - 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 protected void onDragDrop(DNDEvent e) { // TODO Auto-generated method stub - List listFileModel = getDragSource(e); + List listFileModel = getDragSource(e); - List ids = new ArrayList(); + List ids = new ArrayList(); for (FileModel fileModel : listFileModel) { fileModel.setIcon(); @@ -95,55 +99,70 @@ public class TrashInfoContainer extends LayoutContainer { super.onDragDrop(e); - } - private List getDragSource(DNDEvent event){ + private List getDragSource(DNDEvent event) { - List listDraggedFile = new ArrayList(); + List listDraggedFile = new ArrayList(); - if(event.getData() != null){ + if (event.getData() != null) { - List listItemsSource = event.getData(); + List listItemsSource = event.getData(); System.out.println("Trash - Number of move " + listItemsSource.size()); -// FileModel sourceFileModel = null; //for print - - for(int i=0; i folderRender = new GridCellRenderer() { @Override - public String render(FileModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) { - String val = model.get(property); - String color = "black"; - - if(val != null && val.equals(GXTFolderItemTypeEnum.FOLDER.toString())){ -// color = "#EEC900"; - return "" + val + ""; - }else{ - if(val==null) - val = ""; - return "" + val + ""; - } + public String render(FileModel model, String property, ColumnData config, int rowIndex, int colIndex, + ListStore store, Grid grid) { + String val = model.get(property); + String color = "black"; + + if (val != null && val.equals(GXTFolderItemTypeEnum.FOLDER.toString())) { + // color = "#EEC900"; + return "" + val + ""; + } else { + if (val == null) + val = ""; + return "" + val + ""; + } } - }; + }; - type.setRenderer(folderRender); + type.setRenderer(folderRender); GridFilters filters = new GridFilters(); filters.setLocal(true); - StringFilter nameFilter = new StringFilter(FileGridModel.NAME); StringFilter typeFilter = new StringFilter(FileGridModel.TYPE); DateFilter dateFilter = new DateFilter(FileTrashedModel.STOREINFO.DELETEDATE.toString()); @@ -320,7 +342,7 @@ public class TrashInfoContainer extends LayoutContainer { @Override public void selectionChanged(SelectionChangedEvent se) { - boolean selection = grid.getSelectionModel().getSelectedItems().size()>0; + boolean selection = grid.getSelectionModel().getSelectedItems().size() > 0; activeButtonOnSelection(selection); } }); @@ -334,11 +356,8 @@ public class TrashInfoContainer extends LayoutContainer { grid.setStyleAttribute("borderTop", "none"); cp.add(grid); - } - - public void setPanelSize(int width, int height) { if (width > 0 && height > 0 && grid != null) { @@ -361,31 +380,27 @@ public class TrashInfoContainer extends LayoutContainer { for (FileTrashedModel fileTrashedModel : trashFiles) { fileTrashedModel.setIcon(); -// GWT.log("TrashFile: "+fileTrashedModel); -// //Workaround remove this -// if(fileTrashedModel.isDirectory()) -// fileTrashedModel.setFolderItemType(GXTFolderItemTypeEnum.FOLDER); + // GWT.log("TrashFile: "+fileTrashedModel); + // //Workaround remove this + // if(fileTrashedModel.isDirectory()) + // fileTrashedModel.setFolderItemType(GXTFolderItemTypeEnum.FOLDER); } store.add(trashFiles); - activeButtonsOnNotEmtpy(store.getModels().size()>0); + activeButtonsOnNotEmtpy(store.getModels().size() > 0); } - /** - * @param b - */ + private void activeButtonsOnNotEmtpy(boolean isNotEmpty) { buttonRestoreAll.setEnabled(isNotEmpty); buttonEmptyTrash.setEnabled(isNotEmpty); } - /** - * @param multi - */ protected void activeButtonOnSelection(boolean bool) { buttonDelete.setEnabled(bool); buttonRestore.setEnabled(bool); } + private void updateStore(ListStore store) { resetStore(); @@ -396,8 +411,7 @@ public class TrashInfoContainer extends LayoutContainer { this.grid.getStore().removeAll(); } - public ColumnConfig createSortableColumnConfig(String id, String name, - int width) { + public ColumnConfig createSortableColumnConfig(String id, String name, int width) { ColumnConfig columnConfig = new ColumnConfig(id, name, width); columnConfig.setSortable(true); @@ -409,40 +423,35 @@ public class TrashInfoContainer extends LayoutContainer { // cp.layout(); } - /** - * - * @param identifier - * @return - */ - public FileTrashedModel getFileModelByIdentifier(String identifier){ + public FileTrashedModel getFileModelByIdentifier(String identifier) { return store.findModel(FileGridModel.IDENTIFIER, identifier); } /** - * - * @param identifier (MANDATORY) - * @return + * + * @param identifier + * mandatory + * @return operation result */ public boolean deleteItem(String identifier) { FileTrashedModel fileTarget = getFileModelByIdentifier(identifier); - - if(fileTarget!=null){ + if (fileTarget != null) { return deleteItem(fileTarget); - } - else - System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" ); + } else + System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store"); return false; } /** * - * @param fileTarget (MANDATORY) - * @return + * @param fileTarget + * (MANDATORY) + * @return operation result */ private boolean deleteItem(FileTrashedModel fileTarget) { @@ -455,11 +464,10 @@ public class TrashInfoContainer extends LayoutContainer { return true; } else - System.out.println("Record Error: file target with " - + fileTarget.getIdentifier() - + " identifier not exist in store"); + System.out.println( + "Record Error: file target with " + fileTarget.getIdentifier() + " identifier not exist in store"); - activeButtonsOnNotEmtpy(store.getModels().size()>0); + activeButtonsOnNotEmtpy(store.getModels().size() > 0); return false; @@ -469,7 +477,7 @@ public class TrashInfoContainer extends LayoutContainer { * * @return the number of items contained into trash */ - public int trashSize(){ + public int trashSize() { return store.getCount(); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java index d5bb70b..a25dedb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java @@ -47,10 +47,7 @@ public class WindowTrash extends Window { setHeading("Trash"); } - /** - * - * @return - */ + public static synchronized WindowTrash getInstance(){ if(INSTANCE==null) INSTANCE = new WindowTrash(); @@ -150,11 +147,6 @@ public class WindowTrash extends Window { } - /** - * - * @param fileModelId - * @return - */ public boolean deleteFileFromTrash(String fileModelId){ boolean deleted = this.trashContainers.deleteItem(fileModelId);