>() {
@Override
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/ACLDivInfo.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/ACLDivInfo.java
new file mode 100644
index 0000000..7890fc2
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/ACLDivInfo.java
@@ -0,0 +1,59 @@
+package org.gcube.portlets.user.workspace.client.view.toolbars;
+
+import com.extjs.gxt.ui.client.widget.HorizontalPanel;
+import com.extjs.gxt.ui.client.widget.LayoutContainer;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.HTML;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @Feb 17, 2014
+ *
+ */
+public class ACLDivInfo extends LayoutContainer {
+
+ private HorizontalPanel hpPanel = new HorizontalPanel();
+
+ private HTML text = new HTML();
+
+ public ACLDivInfo(String caption, AbstractImagePrototype img) {
+ super();
+ super.setWidth(80);
+ text.setPixelSize(50, 30);
+ hpPanel.setWidth("100%");
+
+ updateInfo(caption,img);
+ }
+
+ public void updateInfo(String caption, AbstractImagePrototype img){
+
+ String html = "";
+
+ if(img!=null)
+ html+=addImage(img);
+
+ if(caption!=null)
+ html+=addCaption(caption);
+
+
+ html+="
";
+
+ text.setHTML(html);
+
+ hpPanel.layout();
+ }
+
+ private String addImage(AbstractImagePrototype img){
+
+ return "" + img.getHTML() + "";
+
+ }
+
+ private String addCaption(String caption){
+
+ return ""+ caption+"";
+
+ }
+}
+
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 fa02a04..eb13fec 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
@@ -5,16 +5,21 @@ 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.GetInfoEvent;
import org.gcube.portlets.user.workspace.client.event.TrashEvent;
-import org.gcube.portlets.user.workspace.client.event.TrashEvent.TRASHOPERATION;
import org.gcube.portlets.user.workspace.client.resources.Resources;
+import org.gcube.portlets.user.workspace.client.util.GetPermissionIconByACL;
+import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
+import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@@ -43,6 +48,7 @@ public class GxtBottomToolBarItem extends ToolBar{
private Button bHistory;
private Button bRead;
private Button btnGetTrash;
+ private ACLDivInfo aclDivInfo;
public GxtBottomToolBarItem(){
super();
@@ -98,6 +104,11 @@ public class GxtBottomToolBarItem extends ToolBar{
// add(bRead);
+
+ add(new FillToolItem());
+ aclDivInfo = new ACLDivInfo("", null);
+ add(aclDivInfo);
+
btnGetTrash = new Button("Trash");
btnGetTrash.setIcon(Resources.getTrash());
btnGetTrash.addSelectionListener(new SelectionListener() {
@@ -105,17 +116,19 @@ public class GxtBottomToolBarItem extends ToolBar{
@Override
public void componentSelected(ButtonEvent ce) {
- AppController.getEventBus().fireEvent(new TrashEvent(TRASHOPERATION.SHOW, null));
+ AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.SHOW, null));
}
});
// add(new FillToolItem());
// add(btnGetTrash);
+
+
+
enableButtons(false);
-
-
+
}
public void resetDetails(){
@@ -154,4 +167,11 @@ public class GxtBottomToolBarItem extends ToolBar{
bRead.setEnabled(markAsRead);
}
+
+
+ public void updateACLInfo(WorkspaceACL acl){
+
+ AbstractImagePrototype img = GetPermissionIconByACL.getImage(acl);
+ aclDivInfo.updateInfo(acl.getLabel(), img);
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtPathPanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java
similarity index 98%
rename from src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtPathPanel.java
rename to src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java
index 508ff51..258cf69 100644
--- a/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtPathPanel.java
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/toolbars/GxtBreadcrumbPathPanel.java
@@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.Image;
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
-public class GxtPathPanel {
+public class GxtBreadcrumbPathPanel {
private static final String ROOT_NAME = "Workspace";
@@ -34,7 +34,7 @@ public class GxtPathPanel {
private FileModel lastParent;
- public GxtPathPanel() {
+ public GxtBreadcrumbPathPanel() {
toolBar = new HorizontalPanel();
toolBar.setHeight("25px");
initToolbar();
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
new file mode 100644
index 0000000..f37e966
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java
@@ -0,0 +1,386 @@
+package org.gcube.portlets.user.workspace.client.view.trash;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
+import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
+import org.gcube.portlets.user.workspace.client.model.FileGridModel;
+import org.gcube.portlets.user.workspace.client.model.FileModel;
+import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
+import org.gcube.portlets.user.workspace.client.resources.Resources;
+
+import com.extjs.gxt.ui.client.Style.ButtonScale;
+import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
+import com.extjs.gxt.ui.client.data.BaseModelData;
+import com.extjs.gxt.ui.client.dnd.GridDropTarget;
+import com.extjs.gxt.ui.client.event.ButtonEvent;
+import com.extjs.gxt.ui.client.event.DNDEvent;
+import com.extjs.gxt.ui.client.event.SelectionListener;
+import com.extjs.gxt.ui.client.store.GroupingStore;
+import com.extjs.gxt.ui.client.store.ListStore;
+import com.extjs.gxt.ui.client.store.Record;
+import com.extjs.gxt.ui.client.store.TreeStoreModel;
+import com.extjs.gxt.ui.client.widget.ContentPanel;
+import com.extjs.gxt.ui.client.widget.LayoutContainer;
+import com.extjs.gxt.ui.client.widget.button.ToggleButton;
+import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
+import com.extjs.gxt.ui.client.widget.grid.ColumnData;
+import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
+import com.extjs.gxt.ui.client.widget.grid.Grid;
+import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
+import com.extjs.gxt.ui.client.widget.grid.GroupingView;
+import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters;
+import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
+import com.google.gwt.i18n.client.NumberFormat;
+
+public class TrashInfoContainer extends LayoutContainer {
+
+ /**
+ *
+ */
+
+
+ private Grid grid;
+ private ContentPanel cp;
+ private GroupingStore store = new GroupingStore();
+ private boolean groupingEnabled;
+ private ListStore typeStoreOperation = new ListStore();
+ private NumberFormat number = ConstantsExplorer.numberFormatterKB;
+ private GridDropTarget gridDropTarget;
+
+ public TrashInfoContainer() {
+ initContentPanel();
+ initGrid();
+ createToolBar();
+ initDropTarget();
+ }
+
+ /**
+ *
+ */
+ private void initDropTarget() {
+
+ this.gridDropTarget = new GridDropTarget(grid){
+
+ /* (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 ids = new ArrayList();
+
+ for (FileModel fileModel : listFileModel) {
+ fileModel.setIcon();
+ ids.add(fileModel.getIdentifier());
+ }
+
+ System.out.println("** Trash Event move handleInsertDrop is completed");
+
+ super.onDragDrop(e);
+
+
+ }
+
+ private List getDragSource(DNDEvent event){
+
+ List listDraggedFile = new ArrayList();
+
+ if(event.getData() != null){
+
+ List listItemsSource = event.getData();
+
+ System.out.println("Trash - Number of move " + listItemsSource.size());
+
+// FileModel sourceFileModel = null; //for print
+
+ for(int i=0; i() {
+
+ @Override
+ public void componentSelected(ButtonEvent ce) {
+
+ if (buttonGrouping.isPressed())
+ enableGrouping();
+ else
+ disableGrouping();
+ }
+ });
+
+// bar.add(buttonGrouping);
+ cp.setTopComponent(bar);
+
+ }
+
+ public void initGrid() {
+
+// store.groupBy(ConstantsExplorer.SHORTCUTCATEGORY);
+// groupingEnabled = true;
+
+ ColumnConfig icon = new ColumnConfig(ConstantsExplorer.ICON, "", 25);
+ ColumnConfig name = createSortableColumnConfig(ConstantsExplorer.NAME, ConstantsExplorer.NAME, 200);
+ ColumnConfig type = createSortableColumnConfig(ConstantsExplorer.TYPE, ConstantsExplorer.TYPE, 50);
+ ColumnConfig originalPath = createSortableColumnConfig(FileTrashedModel.STOREINFO.ORIGINALPATH.toString(), "Original Path", 200);
+ ColumnConfig deleteDate = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEDATE.toString(), "Delete Date", 50);
+ ColumnConfig deleteUser = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEUSER.toString(), "Delete User", 150);
+// ColumnConfig category = createSortableColumnConfig(ConstantsExplorer.SHORTCUTCATEGORY, ConstantsExplorer.SHORTCUTCATEGORY, 100);
+// ColumnConfig ownerFullName = createSortableColumnConfig(ConstantsExplorer.OWNERFULLNAME, ConstantsExplorer.OWNER, 100);
+// ColumnConfig ownerFullName = createSortableColumnConfig(ConstantsExplorer.OWNERFULLNAME, ConstantsExplorer.OWNER, 100);
+
+ ColumnModel cm = new ColumnModel(Arrays.asList(icon, name, type, originalPath, deleteDate, deleteUser));
+
+ final ColumnModel columnModel = cm;
+
+ grid = new Grid(this.store, cm);
+
+ GroupingView view = new GroupingView();
+ view.setShowGroupedColumn(true);
+ this.grid.setView(view);
+
+// view.setGroupRenderer(new GridGroupRenderer() {
+// public String render(GroupColumnData data) {
+// String f = columnModel.getColumnById(data.field).getHeader();
+// String l = data.models.size() == 1 ? "Item" : "Items";
+// return f + ": " + data.group + " (" + data.models.size() + " "
+// + l + ")";
+// }
+// });
+
+
+ GridCellRenderer 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 + "";
+ }
+ }
+ };
+
+ type.setRenderer(folderRender);
+
+ GridFilters filters = new GridFilters();
+ filters.setLocal(true);
+
+
+ StringFilter nameFilter = new StringFilter(ConstantsExplorer.NAME);
+ StringFilter authorFilter = new StringFilter(ConstantsExplorer.TYPE);
+
+ filters.addFilter(nameFilter);
+ filters.addFilter(authorFilter);
+
+ grid.addPlugin(filters);
+
+ grid.setBorders(true);
+ grid.setStripeRows(true);
+ grid.getView().setAutoFill(true);
+ grid.setColumnLines(true);
+ grid.setColumnReordering(true);
+ grid.setStyleAttribute("borderTop", "none");
+ cp.add(grid);
+
+
+ }
+
+ public void setPanelSize(int width, int height) {
+
+ if (width > 0 && height > 0 && grid != null) {
+ cp.setSize(width, height);
+ // grid.setSize(width, height);
+ }
+ }
+
+ public TrashInfoContainer(List trashFiles) {
+
+ initContentPanel();
+ initGrid();
+ updateTrash(trashFiles);
+ }
+
+ public void disableGrouping() {
+ GroupingStore groupingStore = null;
+ if (store instanceof GroupingStore) {
+ groupingStore = (GroupingStore) store;
+ if (groupingStore != null) {
+ groupingStore.clearGrouping();
+ }
+ this.groupingEnabled = false;
+ }
+ }
+
+ public void enableGrouping() {
+ GroupingStore groupingStore = null;
+ if (store instanceof GroupingStore) {
+ groupingStore = (GroupingStore) store;
+ if (groupingStore != null) {
+ groupingStore.groupBy(ConstantsExplorer.SHORTCUTCATEGORY);
+ }
+ this.groupingEnabled = true;
+ }
+ }
+
+ public void updateTrash(List trashFiles) {
+
+ store.removeAll();
+ typeStoreOperation.removeAll();
+ store.add(trashFiles);
+ }
+
+ private void updateStore(ListStore store) {
+
+ resetStore();
+ this.grid.getStore().add(store.getModels());
+ }
+
+ public void resetStore() {
+ this.grid.getStore().removeAll();
+ }
+
+ public ColumnConfig createSortableColumnConfig(String id, String name,
+ int width) {
+ ColumnConfig columnConfig = new ColumnConfig(id, name, width);
+ columnConfig.setSortable(true);
+
+ return columnConfig;
+ }
+
+ public void setHeaderTitle(String title) {
+ cp.setHeading(title);
+ // cp.layout();
+ }
+
+ public boolean isGroupingEnabled() {
+ return groupingEnabled;
+ }
+
+ public void setGroupingEnabled(boolean groupingEnabled) {
+ this.groupingEnabled = groupingEnabled;
+ }
+
+
+ /**
+ *
+ * @param identifier
+ * @return
+ */
+ public FileTrashedModel getFileModelByIdentifier(String identifier){
+
+ return store.findModel(ConstantsExplorer.IDENTIFIER, identifier);
+
+ }
+
+ /**
+ *
+ * @param identifier (MANDATORY)
+ * @return
+ */
+ public boolean deleteItem(String identifier) {
+
+ FileTrashedModel fileTarget = getFileModelByIdentifier(identifier);
+
+
+ if(fileTarget!=null){
+ return deleteItem(fileTarget);
+ }
+ else
+ System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" );
+
+ return false;
+ }
+
+ /**
+ *
+ * @param fileTarget (MANDATORY)
+ * @return
+ */
+ private boolean deleteItem(FileTrashedModel fileTarget) {
+
+ Record record = store.getRecord(fileTarget);
+
+ if (record != null) {
+
+ FileTrashedModel item = (FileTrashedModel) record.getModel();
+ store.remove(item);
+
+ return true;
+ } else
+ System.out.println("Record Error: file target with "
+ + fileTarget.getIdentifier()
+ + " identifier not exist in store");
+
+ return false;
+
+ }
+
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..ceaa3c3
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java
@@ -0,0 +1,119 @@
+package org.gcube.portlets.user.workspace.client.view.trash;
+
+import java.util.List;
+
+import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
+import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
+import org.gcube.portlets.user.workspace.client.resources.Resources;
+
+import com.extjs.gxt.ui.client.widget.Window;
+import com.extjs.gxt.ui.client.widget.layout.FitLayout;
+
+/**
+ *
+ * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
+ * @May 23, 2013
+ *
+ * Singleton
+ */
+public class WindowTrash extends Window {
+
+ private List trashedFiles;
+ private TrashInfoContainer trashContainers;
+ private static WindowTrash INSTANCE = null;
+
+
+ private WindowTrash() {
+ initAccounting();
+ setIcon(Resources.getTrash()); //TODO
+ setHeading("Trash");
+// addResizeListner();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static synchronized WindowTrash getInstance(){
+ if(INSTANCE==null)
+ INSTANCE = new WindowTrash();
+
+ return INSTANCE;
+ }
+
+// public void addResizeListner(){
+//
+// this.addListener(Events.Resize, new Listener() {
+//
+// @Override
+// public void handleEvent(WindowEvent we )
+// {
+//
+// if(trashContainers!=null){
+//// System.out.println("Size in event: " + we.getWidth() + "x" + we.getHeight() );
+//// accountingsContainers.setPanelSize(we.getWidth()-14, we.getHeight()-30);
+// }
+// }
+//
+// });
+// }
+
+// public WindowTrash(List trashFiles) {
+// updateTrashContainer(trashFiles);
+// }
+
+ private void initAccounting() {
+// setModal(true);
+ setLayout(new FitLayout());
+ setSize(700, 350);
+ setResizable(true);
+ setMaximizable(true);
+// setCollapsible(true);
+ this.trashContainers = new TrashInfoContainer();
+ add(trashContainers);
+ }
+
+ public void setWindowTitle(String title) {
+ this.setHeading(title);
+
+ }
+
+
+ /**
+ *
+ * @param fileModelId
+ * @return
+ */
+ public boolean deleteFileFromTrash(String fileModelId){
+ return this.trashContainers.deleteItem(fileModelId);
+ }
+
+
+ public void updateTrashContainer(List trashFiles) {
+
+ this.trashContainers.resetStore();
+ this.trashedFiles = trashFiles;
+ this.trashContainers.updateTrash(trashFiles);
+ }
+
+ public List getTrashedFiles() {
+ return trashedFiles;
+ }
+
+ public void maskAccountingInfo(boolean bool){
+
+// if(accountingsContainers!=null){
+//
+// if(bool)
+// accountingsContainers.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
+// else
+// accountingsContainers.unmask();
+// }
+
+ if(bool)
+ this.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
+ else
+ this.unmask();
+ }
+
+}