enhancements on trash

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@95654 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-05-13 16:43:35 +00:00
parent 0851b6a2ac
commit 69d798737f
3 changed files with 42 additions and 94 deletions

View File

@ -6,8 +6,6 @@ import java.util.List;
import org.gcube.portlets.user.workspace.client.AppController; import org.gcube.portlets.user.workspace.client.AppController;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.GridElementSelectedEvent;
import org.gcube.portlets.user.workspace.client.event.GridElementUnSelectedEvent;
import org.gcube.portlets.user.workspace.client.event.TrashEvent; import org.gcube.portlets.user.workspace.client.event.TrashEvent;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; 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.FileGridModel;
@ -20,7 +18,6 @@ import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment; import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.IconAlign; import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.dnd.GridDropTarget; import com.extjs.gxt.ui.client.dnd.GridDropTarget;
import com.extjs.gxt.ui.client.event.ButtonEvent; import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.DNDEvent; import com.extjs.gxt.ui.client.event.DNDEvent;
@ -41,6 +38,7 @@ 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.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; 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.GroupingView;
import com.extjs.gxt.ui.client.widget.grid.filters.DateFilter;
import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters; 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.grid.filters.StringFilter;
import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.layout.FitLayout;
@ -50,19 +48,15 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
public class TrashInfoContainer extends LayoutContainer { public class TrashInfoContainer extends LayoutContainer {
/**
*
*/
private Grid<FileTrashedModel> grid; private Grid<FileTrashedModel> grid;
private ContentPanel cp; private ContentPanel cp;
private GroupingStore<FileTrashedModel> store = new GroupingStore<FileTrashedModel>(); private GroupingStore<FileTrashedModel> store = new GroupingStore<FileTrashedModel>();
private boolean groupingEnabled;
private ListStore<FileTrashedModel> typeStoreOperation = new ListStore<FileTrashedModel>(); private ListStore<FileTrashedModel> typeStoreOperation = new ListStore<FileTrashedModel>();
private GridDropTarget gridDropTarget; private GridDropTarget gridDropTarget;
private Button buttonDelete; private Button buttonDelete;
private Button buttonRestore; private Button buttonRestore;
private Button buttonRestoreAll;
private Button buttonEmptyTrash;
public TrashInfoContainer() { public TrashInfoContainer() {
initContentPanel(); initContentPanel();
@ -73,8 +67,6 @@ public class TrashInfoContainer extends LayoutContainer {
activeButtonOnSelection(false); activeButtonOnSelection(false);
} }
/** /**
* *
*/ */
@ -176,6 +168,7 @@ public class TrashInfoContainer extends LayoutContainer {
return true; return true;
} }
private void createToolBar() { private void createToolBar() {
ToolBar bar = new ToolBar(); ToolBar bar = new ToolBar();
@ -217,7 +210,7 @@ public class TrashInfoContainer extends LayoutContainer {
bar.add(new SeparatorMenuItem()); bar.add(new SeparatorMenuItem());
Button buttonRestoreAll = new Button(WorkspaceTrashOperation.RESTORE_ALL.getLabel(),Resources.getIconRecycle()); buttonRestoreAll = new Button(WorkspaceTrashOperation.RESTORE_ALL.getLabel(),Resources.getIconRecycle());
buttonRestoreAll.setToolTip(WorkspaceTrashOperation.RESTORE_ALL.getOperationDescription()); buttonRestoreAll.setToolTip(WorkspaceTrashOperation.RESTORE_ALL.getOperationDescription());
buttonRestoreAll.setScale(ButtonScale.SMALL); buttonRestoreAll.setScale(ButtonScale.SMALL);
buttonRestoreAll.setIconAlign(IconAlign.TOP); buttonRestoreAll.setIconAlign(IconAlign.TOP);
@ -233,7 +226,7 @@ public class TrashInfoContainer extends LayoutContainer {
bar.add(buttonRestoreAll); bar.add(buttonRestoreAll);
Button buttonEmptyTrash = new Button(WorkspaceTrashOperation.EMPTY_TRASH.getLabel(),Resources.getTrashEmpty()); buttonEmptyTrash = new Button(WorkspaceTrashOperation.EMPTY_TRASH.getLabel(),Resources.getTrashEmpty());
buttonEmptyTrash.setToolTip(WorkspaceTrashOperation.EMPTY_TRASH.getOperationDescription()); buttonEmptyTrash.setToolTip(WorkspaceTrashOperation.EMPTY_TRASH.getOperationDescription());
buttonEmptyTrash.setScale(ButtonScale.SMALL); buttonEmptyTrash.setScale(ButtonScale.SMALL);
buttonEmptyTrash.setIconAlign(IconAlign.TOP); buttonEmptyTrash.setIconAlign(IconAlign.TOP);
@ -275,9 +268,9 @@ public class TrashInfoContainer extends LayoutContainer {
ColumnConfig icon = new ColumnConfig(ConstantsExplorer.ICON, "", 25); ColumnConfig icon = new ColumnConfig(ConstantsExplorer.ICON, "", 25);
ColumnConfig name = createSortableColumnConfig(ConstantsExplorer.NAME, ConstantsExplorer.NAME, 200); ColumnConfig name = createSortableColumnConfig(ConstantsExplorer.NAME, ConstantsExplorer.NAME, 200);
ColumnConfig type = createSortableColumnConfig(ConstantsExplorer.TYPE, ConstantsExplorer.TYPE, 50); ColumnConfig type = createSortableColumnConfig(ConstantsExplorer.TYPE, ConstantsExplorer.TYPE, 80);
ColumnConfig originalPath = createSortableColumnConfig(FileTrashedModel.STOREINFO.ORIGINALPATH.toString(), "Original Path", 200); ColumnConfig originalPath = createSortableColumnConfig(FileTrashedModel.STOREINFO.ORIGINALPATH.toString(), "Original Path", 200);
ColumnConfig deleteDate = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEDATE.toString(), "Deleted Date", 50); ColumnConfig deleteDate = createSortableColumnConfig(FileTrashedModel.STOREINFO.DELETEDATE.toString(), "Deleted Date", 80);
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));
@ -287,7 +280,8 @@ public class TrashInfoContainer extends LayoutContainer {
grid = new Grid<FileTrashedModel>(this.store, cm); grid = new Grid<FileTrashedModel>(this.store, cm);
GroupingView view = new GroupingView(); GroupingView view = new GroupingView();
view.setShowGroupedColumn(true); view.setShowGroupedColumn(false);
this.grid.setView(view); this.grid.setView(view);
// view.setGroupRenderer(new GridGroupRenderer() { // view.setGroupRenderer(new GridGroupRenderer() {
@ -324,33 +318,29 @@ public class TrashInfoContainer extends LayoutContainer {
StringFilter nameFilter = new StringFilter(ConstantsExplorer.NAME); StringFilter nameFilter = new StringFilter(ConstantsExplorer.NAME);
StringFilter authorFilter = new StringFilter(ConstantsExplorer.TYPE); StringFilter typeFilter = new StringFilter(ConstantsExplorer.TYPE);
DateFilter dateFilter = new DateFilter(FileTrashedModel.STOREINFO.DELETEDATE.toString());
filters.addFilter(nameFilter); filters.addFilter(nameFilter);
filters.addFilter(authorFilter); filters.addFilter(typeFilter);
filters.addFilter(dateFilter);
grid.addPlugin(filters); grid.addPlugin(filters);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<FileTrashedModel>() { grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<FileTrashedModel>() {
@Override @Override
public void selectionChanged(SelectionChangedEvent<FileTrashedModel> se) { public void selectionChanged(SelectionChangedEvent<FileTrashedModel> se) {
boolean selection = grid.getSelectionModel().getSelectedItems().size()>0; boolean selection = grid.getSelectionModel().getSelectedItems().size()>0;
if(selection){
activeButtonOnSelection(selection); activeButtonOnSelection(selection);
} }
}
}); });
grid.getView().setAutoFill(true);
grid.setBorders(true); grid.setBorders(true);
grid.setStripeRows(true); grid.setStripeRows(true);
grid.getView().setAutoFill(true); grid.getView().setShowDirtyCells(false);
grid.setColumnLines(true); grid.setColumnLines(true);
grid.setColumnReordering(true); grid.setColumnReordering(true);
grid.setStyleAttribute("borderTop", "none"); grid.setStyleAttribute("borderTop", "none");
@ -359,13 +349,7 @@ public class TrashInfoContainer extends LayoutContainer {
} }
/**
* @param multi
*/
protected void activeButtonOnSelection(boolean bool) {
buttonDelete.setEnabled(bool);
buttonRestore.setEnabled(bool);
}
public void setPanelSize(int width, int height) { public void setPanelSize(int width, int height) {
@ -382,28 +366,6 @@ public class TrashInfoContainer extends LayoutContainer {
updateTrash(trashFiles); updateTrash(trashFiles);
} }
public void disableGrouping() {
GroupingStore<FileTrashedModel> groupingStore = null;
if (store instanceof GroupingStore) {
groupingStore = (GroupingStore<FileTrashedModel>) store;
if (groupingStore != null) {
groupingStore.clearGrouping();
}
this.groupingEnabled = false;
}
}
public void enableGrouping() {
GroupingStore<FileTrashedModel> groupingStore = null;
if (store instanceof GroupingStore) {
groupingStore = (GroupingStore<FileTrashedModel>) store;
if (groupingStore != null) {
groupingStore.groupBy(ConstantsExplorer.SHORTCUTCATEGORY);
}
this.groupingEnabled = true;
}
}
public void updateTrash(List<FileTrashedModel> trashFiles) { public void updateTrash(List<FileTrashedModel> trashFiles) {
store.removeAll(); store.removeAll();
@ -414,8 +376,25 @@ public class TrashInfoContainer extends LayoutContainer {
} }
store.add(trashFiles); store.add(trashFiles);
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<FileTrashedModel> store) { private void updateStore(ListStore<FileTrashedModel> store) {
resetStore(); resetStore();
@ -439,15 +418,6 @@ public class TrashInfoContainer extends LayoutContainer {
// cp.layout(); // cp.layout();
} }
private boolean isGroupingEnabled() {
return groupingEnabled;
}
private void setGroupingEnabled(boolean groupingEnabled) {
this.groupingEnabled = groupingEnabled;
}
/** /**
* *
* @param identifier * @param identifier
@ -498,6 +468,8 @@ public class TrashInfoContainer extends LayoutContainer {
+ fileTarget.getIdentifier() + fileTarget.getIdentifier()
+ " identifier not exist in store"); + " identifier not exist in store");
activeButtonsOnNotEmtpy(store.getModels().size()>0);
return false; return false;
} }

View File

@ -28,7 +28,6 @@ public class WindowTrash extends Window {
initAccounting(); initAccounting();
setIcon(Resources.getTrashFull()); //TODO setIcon(Resources.getTrashFull()); //TODO
setHeading("Trash"); setHeading("Trash");
// addResizeListner();
} }
/** /**
@ -42,34 +41,11 @@ public class WindowTrash extends Window {
return INSTANCE; return INSTANCE;
} }
// public void addResizeListner(){
//
// this.addListener(Events.Resize, new Listener<WindowEvent>() {
//
// @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<FileModel> trashFiles) {
// updateTrashContainer(trashFiles);
// }
private void initAccounting() { private void initAccounting() {
// setModal(true);
setLayout(new FitLayout()); setLayout(new FitLayout());
setSize(700, 350); setSize(750, 400);
setResizable(true); setResizable(true);
setMaximizable(true); setMaximizable(true);
// setCollapsible(true);
this.trashContainers = new TrashInfoContainer(); this.trashContainers = new TrashInfoContainer();
add(trashContainers); add(trashContainers);
} }