From 9b868e3fc6be5c3f55b4e5b6c2e6df868dc58508 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Mon, 27 May 2013 10:21:16 +0000 Subject: [PATCH] GUI for accountings was implemented git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@76290 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/AppControllerExplorer.java | 6 +- .../workspace/client/ConstantsExplorer.java | 8 +++ .../client/constant/WorkspaceOperation.java | 4 +- .../client/view/tree/ContextMenuTree.java | 60 +++++++++++++++++-- .../view/windows/AccoutingInfoContainer.java | 6 +- .../workspace/server/GWTWorkspaceBuilder.java | 8 +-- .../accounting/GxtAccountingEntryType.java | 6 +- 7 files changed, 81 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 51df90b..d00b9e1 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -138,6 +138,8 @@ import com.google.gwt.user.client.ui.HasWidgets; * */ public class AppControllerExplorer implements EventHandler, TreeAppControllerInterface{ + + public static final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) GWT.create(GWTWorkspaceService.class); private ExplorerPanel explorerPanel; private final static HandlerManager eventBus = new HandlerManager(null); @@ -659,7 +661,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt if(fileItem!=null){ - String title = "Accounting history of: "+fileItem.getName(); + String title = ConstantsExplorer.ACCOUNTING_HISTORY_OF+fileItem.getName(); final WindowAccountingInfo winInfo = new WindowAccountingInfo(fileItem,title); winInfo.show(); @@ -697,7 +699,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt if(fileItem!=null){ - String title = "Accounting readers of: "+fileItem.getName(); + String title = ConstantsExplorer.ACCOUNTING_READERS_OF+fileItem.getName(); final WindowAccountingInfo winInfo = new WindowAccountingInfo(fileItem,title); winInfo.show(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java index aa60386..703669b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java @@ -51,6 +51,8 @@ public class ConstantsExplorer { public static final String MESSAGE_SENT_IN_DATE = "Sent in date"; public static final String MESSAGE_ADD_CONTACT = "Add Contact"; public static final String MESSAGE_ADD_SUBJECT = "Add Subject"; + public static final String HISTORY = "History"; + public static final String ACCREAD = "Read"; public static final String MESSAGE_ERROR_OCCURED = "Sorry an error has occurred while processing your request"; public static final String INFO = "Info"; public static final String MESSAGE_SEND_TO_OK = "Your message has been successfully delivered"; @@ -175,10 +177,16 @@ public class ConstantsExplorer { public static final Object NONE = "None"; + //USED IN ACCOUNTINGS + public static final String ACCOUNTING_HISTORY_OF = "Accounting history of: "; + public static final String ACCOUNTING_READERS_OF = "Accounting readers of: "; + public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)"); + + public enum ViewSwitchType {Tree, SmartFolder, Messages}; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/constant/WorkspaceOperation.java b/src/main/java/org/gcube/portlets/user/workspace/client/constant/WorkspaceOperation.java index f3ed9f9..a4c0f07 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/constant/WorkspaceOperation.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/constant/WorkspaceOperation.java @@ -29,7 +29,9 @@ public enum WorkspaceOperation { PASTE("PSI", "PSI"), // paste REFRESH_FOLDER("RFH", "RFH"), // Refresh WEBDAV_URL("WDV", "WDV"), // WebDav - GET_INFO("GTI", "GTI");// GET INFO + GET_INFO("GTI", "GTI"), // GET INFO + HISTORY("HST", "HST"), //HISTORY + ACCREAD("ACR", "ACR"); //ACCOUNTING READ // //ID CONTEXT MENU diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java index e27196b..f2aed9e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/ContextMenuTree.java @@ -6,6 +6,8 @@ import java.util.List; import org.gcube.portlets.user.workspace.client.AppControllerExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation; +import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent; +import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent; import org.gcube.portlets.user.workspace.client.event.AddFolderEvent; import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent; import org.gcube.portlets.user.workspace.client.event.CreateUrlEvent; @@ -42,6 +44,8 @@ public class ContextMenuTree { private Menu contextMenu = new Menu(); private HandlerManager eventBus = AppControllerExplorer.getEventBus(); private List listSelectedItems = null; + + private MenuItem mnRead = new MenuItem(); private boolean hideSharing = false; @@ -162,6 +166,50 @@ public class ContextMenuTree { contextMenu.add(mnGetInfo); + contextMenu.add(new SeparatorMenuItem()); + + MenuItem mnHistory = new MenuItem(); + mnHistory.setIcon(Resources.getIconHistory()); + mnHistory.setId(WorkspaceOperation.HISTORY.getId()); + mnHistory.setText(ConstantsExplorer.HISTORY); + + mnHistory.addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(MenuEvent ce) { + + final FileModel sourceFileModel = listSelectedItems.get(0); + + if (sourceFileModel != null) { + + eventBus.fireEvent(new AccountingHistoryEvent(sourceFileModel)); + } + } + }); + contextMenu.add(mnHistory); + + //ACCOUNTING READ + mnRead = new MenuItem(); + mnRead.setIcon(Resources.getIconRead()); + mnRead.setId(WorkspaceOperation.ACCREAD.getId()); + mnRead.setText(ConstantsExplorer.ACCREAD); + + mnRead.addSelectionListener(new SelectionListener() { + + @Override + public void componentSelected(MenuEvent ce) { + + final FileModel sourceFileModel = listSelectedItems.get(0); + + if (sourceFileModel != null) { + + eventBus.fireEvent(new AccountingReadersEvent(sourceFileModel)); + } + } + }); + + contextMenu.add(mnRead); + contextMenu.add(new SeparatorMenuItem()); MenuItem insertFolder = new MenuItem(); @@ -169,7 +217,6 @@ public class ContextMenuTree { insertFolder.setText(ConstantsExplorer.MESSAGE_ADD_FOLDER); insertFolder.setIcon(Resources.getIconAddFolder()); - insertFolder.addSelectionListener(new SelectionListener() { public void componentSelected(MenuEvent ce) { @@ -308,9 +355,6 @@ public class ContextMenuTree { contextMenu.add(unShare); - - - MenuItem rename = new MenuItem(); rename.setId(WorkspaceOperation.RENAME.getId()); rename.setText("Rename Item"); @@ -557,6 +601,9 @@ public class ContextMenuTree { contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //set invisible refresh // contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //set invisible share // contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //set invisible unshare + + + contextMenu.showAt(posX, posY); } @@ -589,6 +636,11 @@ public class ContextMenuTree { contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE + //ACCOUNTINGS + if(selectedItem.isMarkAsRead()) + mnRead.setIcon(Resources.getIconRead()); + else + mnRead.setIcon(Resources.getIconNotRead()); if(selectedItem.isDirectory()){ contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java index 72dd8fc..3902a56 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/AccoutingInfoContainer.java @@ -108,10 +108,10 @@ public class AccoutingInfoContainer extends LayoutContainer { else if(model.get(OPERATION).equals(GxtAccountingEntryType.CUT)) return Resources.getIconCut().createImage(); else if(model.get(OPERATION).equals(GxtAccountingEntryType.PASTE)) - return Resources.getIconCopy().createImage(); - else if(model.get(OPERATION).equals(GxtAccountingEntryType.REMOVED)) + return Resources.getIconPaste().createImage(); + else if(model.get(OPERATION).equals(GxtAccountingEntryType.REMOVE)) return Resources.getIconCancel().createImage(); - else if(model.get(OPERATION).equals(GxtAccountingEntryType.RENAMED)) + else if(model.get(OPERATION).equals(GxtAccountingEntryType.RENAME)) return Resources.getIconRenameItem().createImage(); return null; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index 9d6b676..393e3fb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -1693,9 +1693,9 @@ public class GWTWorkspaceBuilder { case REMOVAL: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVED)){ + if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)){ - af.setOperation(GxtAccountingEntryType.REMOVED); + af.setOperation(GxtAccountingEntryType.REMOVE); AccountingEntryRemoval rem = (AccountingEntryRemoval) accountingEntry; @@ -1705,9 +1705,9 @@ public class GWTWorkspaceBuilder { case RENAMING: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAMED)){ + if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAME)){ - af.setOperation(GxtAccountingEntryType.RENAMED); + af.setOperation(GxtAccountingEntryType.RENAME); AccountingEntryRenaming ren = (AccountingEntryRenaming) accountingEntry; diff --git a/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java b/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java index 281ef5f..59506ae 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java +++ b/src/main/java/org/gcube/portlets/user/workspace/shared/accounting/GxtAccountingEntryType.java @@ -10,11 +10,11 @@ package org.gcube.portlets.user.workspace.shared.accounting; */ public enum GxtAccountingEntryType { - REMOVED("removed", "removed"), + REMOVE("removed", "removed"), - RENAMED("renamed", "renamed"), + RENAME("renamed", "renamed"), - CREATED("created", "created"), + CREATE("created", "created"), PASTE("pasted", "pasted"),