enhancements on trash
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@95645 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0b53c23b4a
commit
0851b6a2ac
|
@ -1692,7 +1692,7 @@ public class AppController implements SubscriberInterface {
|
|||
return;
|
||||
|
||||
|
||||
WindowTrash.getInstance().mask("Updating Trash");
|
||||
WindowTrash.getInstance().maskContainer("Updating Trash");
|
||||
List<String> trashIds = new ArrayList<String>(trashItemIds.size());
|
||||
for (FileModel fileModel : trashItemIds) {
|
||||
trashIds.add(fileModel.getIdentifier());
|
||||
|
@ -1702,34 +1702,41 @@ public class AppController implements SubscriberInterface {
|
|||
|
||||
@Override
|
||||
public void onFailure(Throwable arg0) {
|
||||
WindowTrash.getInstance().unmask();
|
||||
WindowTrash.getInstance().unmaskContainer();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TrashOperationContent operationResult) {
|
||||
WindowTrash.getInstance().unmask();
|
||||
WindowTrash.getInstance().unmaskContainer();
|
||||
|
||||
WindowTrash.getInstance().executeOperationOnTrashContainer(operationResult.getListTrashIds(), operationResult.getOperation());
|
||||
|
||||
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemDetails().updateTrashIcon(WindowTrash.getInstance().getTrashedFiles().size()>0);
|
||||
|
||||
//TODO POPUP ERROR
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
default:{
|
||||
|
||||
WindowTrash.getInstance().mask("Updating Trash");
|
||||
WindowTrash.getInstance().maskContainer("Updating Trash");
|
||||
AppControllerExplorer.rpcWorkspaceService.updateTrashContent(operation, new AsyncCallback<TrashContent>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable arg0) {
|
||||
WindowTrash.getInstance().unmask();
|
||||
WindowTrash.getInstance().unmaskContainer();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TrashContent operationResult) {
|
||||
WindowTrash.getInstance().unmask();
|
||||
WindowTrash.getInstance().unmaskContainer();
|
||||
WindowTrash.getInstance().updateTrashContainer(operationResult.getTrashContent());
|
||||
|
||||
wsPortlet.getGxtCardLayoutResultPanel().getToolBarItemDetails().updateTrashIcon(operationResult.getTrashContent().size()>0);
|
||||
//TODO POPUP ERROR
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ public class WorskpacePortlet {
|
|||
return basicTabContainer;
|
||||
}
|
||||
|
||||
public GxtBottomToolBarItem getDetailsContainer() {
|
||||
return toolBarItemDetails;
|
||||
}
|
||||
// public GxtBottomToolBarItem getDetailsContainer() {
|
||||
// return toolBarItemDetails;
|
||||
// }
|
||||
|
||||
|
||||
public GxtSeachAndFilterPanel getSearchAndFilterContainer() {
|
||||
|
|
|
@ -109,7 +109,7 @@ public class GxtBottomToolBarItem extends ToolBar{
|
|||
add(aclDivInfo);
|
||||
|
||||
btnGetTrash = new Button("Trash");
|
||||
btnGetTrash.setIcon(Resources.getTrash());
|
||||
btnGetTrash.setIcon(Resources.getTrashEmpty());
|
||||
btnGetTrash.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -176,4 +176,12 @@ public class GxtBottomToolBarItem extends ToolBar{
|
|||
aclDivInfo.updateInfo(acl.getLabel(), img);
|
||||
this.layout();
|
||||
}
|
||||
|
||||
public void updateTrashIcon(boolean trashIsFull){
|
||||
|
||||
if(trashIsFull)
|
||||
btnGetTrash.setIcon(Resources.getTrashFull());
|
||||
else
|
||||
btnGetTrash.setIcon(Resources.getTrashEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,19 +4,28 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.AppController;
|
||||
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.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 org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.IconAlign;
|
||||
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.event.ButtonEvent;
|
||||
import com.extjs.gxt.ui.client.event.DNDEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.store.GroupingStore;
|
||||
import com.extjs.gxt.ui.client.store.ListStore;
|
||||
|
@ -24,7 +33,8 @@ 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.MessageBox;
|
||||
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||
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;
|
||||
|
@ -34,6 +44,8 @@ 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.menu.SeparatorMenuItem;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||
|
||||
public class TrashInfoContainer extends LayoutContainer {
|
||||
|
@ -49,13 +61,19 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
private boolean groupingEnabled;
|
||||
private ListStore<FileTrashedModel> typeStoreOperation = new ListStore<FileTrashedModel>();
|
||||
private GridDropTarget gridDropTarget;
|
||||
private Button buttonDelete;
|
||||
private Button buttonRestore;
|
||||
|
||||
public TrashInfoContainer() {
|
||||
initContentPanel();
|
||||
initGrid();
|
||||
createToolBar();
|
||||
initDropTarget();
|
||||
|
||||
activeButtonOnSelection(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -149,27 +167,106 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
add(cp);
|
||||
}
|
||||
|
||||
private boolean checkSelection(){
|
||||
|
||||
if(grid.getSelectionModel().getSelectedItems().size()==0){
|
||||
MessageBox.info("Attention", "You must pick at least one item", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private void createToolBar() {
|
||||
|
||||
ToolBar bar = new ToolBar();
|
||||
final ToggleButton buttonGrouping = new ToggleButton("",Resources.getIconGridView());
|
||||
buttonGrouping.setToolTip("Grouping by Type");
|
||||
buttonGrouping.setScale(ButtonScale.SMALL);
|
||||
buttonGrouping.toggle(true);
|
||||
|
||||
buttonGrouping.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
buttonRestore = new Button(WorkspaceTrashOperation.RESTORE.getLabel(),Resources.getIconUndo());
|
||||
buttonRestore.setToolTip(WorkspaceTrashOperation.RESTORE.getOperationDescription());
|
||||
buttonRestore.setScale(ButtonScale.SMALL);
|
||||
buttonRestore.setIconAlign(IconAlign.TOP);
|
||||
|
||||
buttonRestore.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
if (buttonGrouping.isPressed())
|
||||
enableGrouping();
|
||||
else
|
||||
disableGrouping();
|
||||
if(checkSelection())
|
||||
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.RESTORE, grid.getSelectionModel().getSelectedItems()));
|
||||
}
|
||||
});
|
||||
|
||||
bar.add(buttonRestore);
|
||||
|
||||
|
||||
buttonDelete = new Button(WorkspaceTrashOperation.DELETE_PERMANENTLY.getLabel(),Resources.getIconDeleteItem());
|
||||
buttonDelete.setToolTip(WorkspaceTrashOperation.DELETE_PERMANENTLY.getOperationDescription());
|
||||
buttonDelete.setScale(ButtonScale.SMALL);
|
||||
buttonDelete.setIconAlign(IconAlign.TOP);
|
||||
buttonDelete.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
if(checkSelection())
|
||||
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.DELETE_PERMANENTLY, grid.getSelectionModel().getSelectedItems()));
|
||||
}
|
||||
});
|
||||
|
||||
// bar.add(buttonGrouping);
|
||||
bar.add(buttonDelete);
|
||||
|
||||
|
||||
bar.add(new SeparatorMenuItem());
|
||||
|
||||
Button buttonRestoreAll = new Button(WorkspaceTrashOperation.RESTORE_ALL.getLabel(),Resources.getIconRecycle());
|
||||
buttonRestoreAll.setToolTip(WorkspaceTrashOperation.RESTORE_ALL.getOperationDescription());
|
||||
buttonRestoreAll.setScale(ButtonScale.SMALL);
|
||||
buttonRestoreAll.setIconAlign(IconAlign.TOP);
|
||||
buttonRestoreAll.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.RESTORE_ALL, null));
|
||||
}
|
||||
});
|
||||
|
||||
bar.add(buttonRestoreAll);
|
||||
|
||||
|
||||
Button buttonEmptyTrash = new Button(WorkspaceTrashOperation.EMPTY_TRASH.getLabel(),Resources.getTrashEmpty());
|
||||
buttonEmptyTrash.setToolTip(WorkspaceTrashOperation.EMPTY_TRASH.getOperationDescription());
|
||||
buttonEmptyTrash.setScale(ButtonScale.SMALL);
|
||||
buttonEmptyTrash.setIconAlign(IconAlign.TOP);
|
||||
buttonEmptyTrash.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.EMPTY_TRASH, null));
|
||||
}
|
||||
});
|
||||
|
||||
bar.add(buttonEmptyTrash);
|
||||
|
||||
|
||||
bar.add(new FillToolItem());
|
||||
|
||||
Button buttonRefresh = new Button(WorkspaceTrashOperation.REFRESH.getLabel(),Resources.getIconRefresh());
|
||||
buttonRefresh.setToolTip(WorkspaceTrashOperation.REFRESH.getOperationDescription());
|
||||
buttonRefresh.setScale(ButtonScale.SMALL);
|
||||
buttonRefresh.setIconAlign(IconAlign.TOP);
|
||||
buttonRefresh.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
AppController.getEventBus().fireEvent(new TrashEvent(WorkspaceTrashOperation.REFRESH, null));
|
||||
}
|
||||
});
|
||||
|
||||
bar.add(buttonRefresh);
|
||||
|
||||
|
||||
cp.setTopComponent(bar);
|
||||
|
||||
}
|
||||
|
@ -233,7 +330,24 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
filters.addFilter(authorFilter);
|
||||
|
||||
grid.addPlugin(filters);
|
||||
|
||||
|
||||
|
||||
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<FileTrashedModel>() {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent<FileTrashedModel> se) {
|
||||
|
||||
boolean selection = grid.getSelectionModel().getSelectedItems().size()>0;
|
||||
|
||||
if(selection){
|
||||
activeButtonOnSelection(selection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
grid.setBorders(true);
|
||||
grid.setStripeRows(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
|
@ -245,6 +359,14 @@ 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) {
|
||||
|
||||
if (width > 0 && height > 0 && grid != null) {
|
||||
|
@ -317,11 +439,11 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
// cp.layout();
|
||||
}
|
||||
|
||||
public boolean isGroupingEnabled() {
|
||||
private boolean isGroupingEnabled() {
|
||||
return groupingEnabled;
|
||||
}
|
||||
|
||||
public void setGroupingEnabled(boolean groupingEnabled) {
|
||||
private void setGroupingEnabled(boolean groupingEnabled) {
|
||||
this.groupingEnabled = groupingEnabled;
|
||||
}
|
||||
|
||||
|
@ -379,5 +501,13 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the number of items contained into trash
|
||||
*/
|
||||
public int trashSize(){
|
||||
return store.getCount();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ public class WindowTrash extends Window {
|
|||
|
||||
private WindowTrash() {
|
||||
initAccounting();
|
||||
setIcon(Resources.getTrash()); //TODO
|
||||
setIcon(Resources.getTrashFull()); //TODO
|
||||
setHeading("Trash");
|
||||
// addResizeListner();
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class WindowTrash extends Window {
|
|||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
// public void addResizeListner(){
|
||||
//
|
||||
// this.addListener(Events.Resize, new Listener<WindowEvent>() {
|
||||
|
@ -86,7 +86,11 @@ public class WindowTrash extends Window {
|
|||
* @return
|
||||
*/
|
||||
public boolean deleteFileFromTrash(String fileModelId){
|
||||
return this.trashContainers.deleteItem(fileModelId);
|
||||
boolean deleted = this.trashContainers.deleteItem(fileModelId);
|
||||
|
||||
updateTrashIcon(this.trashContainers.trashSize()>0);
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,6 +99,8 @@ public class WindowTrash extends Window {
|
|||
this.trashContainers.resetStore();
|
||||
this.trashedFiles = trashFiles;
|
||||
this.trashContainers.updateTrash(trashFiles);
|
||||
|
||||
updateTrashIcon(this.trashContainers.trashSize()>0);
|
||||
}
|
||||
|
||||
public void executeOperationOnTrashContainer(List<String> trashIds, WorkspaceTrashOperation operation) {
|
||||
|
@ -105,6 +111,8 @@ public class WindowTrash extends Window {
|
|||
}else if(operation.equals(WorkspaceTrashOperation.RESTORE)){
|
||||
deleteListItems(trashIds);
|
||||
}
|
||||
|
||||
updateTrashIcon(this.trashContainers.trashSize()>0);
|
||||
}
|
||||
|
||||
public List<FileTrashedModel> getTrashedFiles() {
|
||||
|
@ -118,20 +126,20 @@ public class WindowTrash extends Window {
|
|||
}
|
||||
}
|
||||
|
||||
public void maskAccountingInfo(boolean bool){
|
||||
public void maskContainer(String title){
|
||||
this.trashContainers.mask(title, ConstantsExplorer.LOADINGSTYLE);
|
||||
}
|
||||
|
||||
public void unmaskContainer(){
|
||||
this.trashContainers.unmask();
|
||||
}
|
||||
|
||||
public void updateTrashIcon(boolean trashIsFull){
|
||||
|
||||
// if(accountingsContainers!=null){
|
||||
//
|
||||
// if(bool)
|
||||
// accountingsContainers.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
|
||||
// else
|
||||
// accountingsContainers.unmask();
|
||||
// }
|
||||
|
||||
if(bool)
|
||||
this.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE);
|
||||
if(trashIsFull)
|
||||
setIcon(Resources.getTrashFull());
|
||||
else
|
||||
this.unmask();
|
||||
setIcon(Resources.getTrashEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue