added items number also for trash
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@95809 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
789fe40149
commit
ee8df8eef2
|
@ -52,7 +52,6 @@ import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter;
|
|||
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.user.workspace.client.view.panels;
|
|||
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.ConstantsPortlet;
|
||||
import org.gcube.portlets.user.workspace.client.event.SaveSmartFolderEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.ScopeChangeEvent;
|
||||
|
@ -11,7 +10,6 @@ import org.gcube.portlets.user.workspace.client.event.SearchTextEvent;
|
|||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
import org.gcube.portlets.user.workspace.client.view.GxtComboBox;
|
||||
import org.gcube.portlets.user.workspace.client.view.toolbars.GxtBreadcrumbPathPanel;
|
||||
import org.gcube.portlets.user.workspace.client.view.toolbars.GxtToolBarItemFunctionality;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
|
||||
|
|
|
@ -17,6 +17,7 @@ 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.Style.Scroll;
|
||||
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
|
@ -157,6 +158,7 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
cp.setBodyBorder(true);
|
||||
cp.setLayout(new FitLayout());
|
||||
cp.setButtonAlign(HorizontalAlignment.CENTER);
|
||||
cp.setScrollMode(Scroll.AUTOY);
|
||||
add(cp);
|
||||
}
|
||||
|
||||
|
@ -476,4 +478,12 @@ public class TrashInfoContainer extends LayoutContainer {
|
|||
return store.getCount();
|
||||
}
|
||||
|
||||
protected GroupingStore<FileTrashedModel> getStore() {
|
||||
return store;
|
||||
}
|
||||
|
||||
public ContentPanel getCp() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,11 +10,18 @@ import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
|||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.Style.Scroll;
|
||||
import com.extjs.gxt.ui.client.data.ModelData;
|
||||
import com.extjs.gxt.ui.client.event.Listener;
|
||||
import com.extjs.gxt.ui.client.store.Store;
|
||||
import com.extjs.gxt.ui.client.store.StoreEvent;
|
||||
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
||||
import com.extjs.gxt.ui.client.widget.Html;
|
||||
import com.extjs.gxt.ui.client.widget.Label;
|
||||
import com.extjs.gxt.ui.client.widget.Window;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -27,7 +34,9 @@ public class WindowTrash extends Window {
|
|||
|
||||
private List<FileTrashedModel> trashedFiles;
|
||||
private TrashInfoContainer trashContainers;
|
||||
private HorizontalPanel hpItemsNumber;
|
||||
private static WindowTrash INSTANCE = null;
|
||||
private Label labelItemsNumber = new Label();
|
||||
|
||||
|
||||
private WindowTrash() {
|
||||
|
@ -47,6 +56,9 @@ public class WindowTrash extends Window {
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called only once
|
||||
*/
|
||||
private void initAccounting() {
|
||||
setLayout(new FitLayout());
|
||||
setSize(770, 400);
|
||||
|
@ -54,6 +66,63 @@ public class WindowTrash extends Window {
|
|||
setMaximizable(true);
|
||||
this.trashContainers = new TrashInfoContainer();
|
||||
add(trashContainers);
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
hpItemsNumber = new HorizontalPanel();
|
||||
hpItemsNumber.setStyleAttribute("margin-left", "10px");
|
||||
hpItemsNumber.setHorizontalAlign(HorizontalAlignment.CENTER);
|
||||
hpItemsNumber.add(labelItemsNumber);
|
||||
toolBar.add(hpItemsNumber);
|
||||
|
||||
setBottomComponent(toolBar);
|
||||
|
||||
addStoreListeners();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void addStoreListeners() {
|
||||
|
||||
trashContainers.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>(){
|
||||
|
||||
@Override
|
||||
public void handleEvent(StoreEvent<ModelData> be) {
|
||||
updateItemsNumber(storeSize());
|
||||
}
|
||||
});
|
||||
|
||||
trashContainers.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>(){
|
||||
|
||||
@Override
|
||||
public void handleEvent(StoreEvent<ModelData> be) {
|
||||
updateItemsNumber(storeSize());
|
||||
}
|
||||
});
|
||||
|
||||
trashContainers.getStore().addListener(Store.Clear, new Listener<StoreEvent<ModelData>>(){
|
||||
|
||||
@Override
|
||||
public void handleEvent(StoreEvent<ModelData> be) {
|
||||
updateItemsNumber(storeSize());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size
|
||||
*/
|
||||
public void updateItemsNumber(int size) {
|
||||
if(size<=0)
|
||||
labelItemsNumber.setText("No Items");
|
||||
else if(size==1)
|
||||
labelItemsNumber.setText("1 Item");
|
||||
else if(size>1)
|
||||
labelItemsNumber.setText(size +" Items");
|
||||
|
||||
hpItemsNumber.layout();
|
||||
}
|
||||
|
||||
public void setWindowTitle(String title) {
|
||||
|
@ -61,6 +130,20 @@ public class WindowTrash extends Window {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return -1 if store is null. The size otherwise
|
||||
*/
|
||||
private int storeSize(){
|
||||
|
||||
if(trashContainers.getStore()!=null && trashContainers.getStore().getModels()!=null){
|
||||
return trashContainers.getStore().getModels().size();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue