Added Filters on TemplateApplyPanel and TemplateDeletePanel

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@94531 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-08 10:56:27 +00:00 committed by Giancarlo Panichi
parent 2499bce31e
commit cee8e67eb8
7 changed files with 155 additions and 10 deletions

View File

@ -33,4 +33,11 @@ public interface ResourceBundle extends ClientBundle {
@Source("close-red_32.png")
ImageResource close32();
@Source("arrow-refresh.png")
ImageResource refresh();
@Source("arrow-refresh_32.png")
ImageResource refresh32();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -14,6 +14,8 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
@ -23,6 +25,9 @@ import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.Store;
import com.sencha.gxt.data.shared.Store.StoreFilter;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
@ -38,10 +43,12 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
public class TemplateApplyPanel extends FramedPanel {
@ -57,7 +64,7 @@ public class TemplateApplyPanel extends FramedPanel {
protected ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
protected Grid<TemplateData> grid;
protected ListStore<TemplateData> store;
protected ExtendedListStore<TemplateData> store;
public TemplateApplyPanel(TemplateApplyDialog parent, TRId trId,
EventBus eventBus) {
@ -75,7 +82,18 @@ public class TemplateApplyPanel extends FramedPanel {
}
protected void create() {
ToolBar toolBarHead = new ToolBar();
toolBarHead.add(new LabelToolItem("Search: "));
final TextField searchField = new TextField();
toolBarHead.add(searchField);
TextButton btnReload = new TextButton();
//btnReload.setText("Reload");
btnReload.setIcon(ResourceBundle.INSTANCE.refresh());
btnReload.setToolTip("Reload");
toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
identity);
@ -101,7 +119,29 @@ public class TemplateApplyPanel extends FramedPanel {
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
store = new ListStore<TemplateData>(props.id());
store = new ExtendedListStore<TemplateData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
Log.trace("searchTerm: "+searchField.getCurrentValue());
store.applyFilters();
}
});
store.addFilter(new StoreFilter<TemplateData>() {
@Override
public boolean select(Store<TemplateData> store,
TemplateData parent, TemplateData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null) return true;
return TemplateApplyPanel.this.select(item, searchTerm);
}
});
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
@ -134,7 +174,7 @@ public class TemplateApplyPanel extends FramedPanel {
sm.setSelectionMode(SelectionMode.SINGLE);
grid.setLoader(loader);
grid.setSelectionModel(sm);
grid.setHeight("418px");
grid.setHeight("384px");
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
@ -214,7 +254,9 @@ public class TemplateApplyPanel extends FramedPanel {
});
}
/*
* protected void setMenu() { Menu contextMenu = new Menu();
*
@ -252,5 +294,30 @@ public class TemplateApplyPanel extends FramedPanel {
protected void close() {
parent.close();
}
protected class ExtendedListStore<M> extends ListStore<M> {
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
super(keyProvider);
}
public void applyFilters()
{
super.applyFilters();
}
}
public void gridReload(){
grid.getLoader().load();
}
protected boolean select(TemplateData item, String searchTerm) {
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
if (item.getCategory()!=null &&item.getCategory().toLowerCase().contains(searchTerm.toLowerCase())) return true;
if (item.getAgency()!=null &&item.getAgency().toLowerCase().contains(searchTerm.toLowerCase())) return true;
if (item.getDescription()!=null && item.getDescription().toLowerCase().contains(searchTerm.toLowerCase())) return true;
return false;
}
}

View File

@ -13,6 +13,8 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
@ -22,6 +24,9 @@ import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.Store;
import com.sencha.gxt.data.shared.Store.StoreFilter;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
@ -37,10 +42,12 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
public class TemplateDeletePanel extends FramedPanel {
@ -55,8 +62,8 @@ public class TemplateDeletePanel extends FramedPanel {
protected ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
protected Grid<TemplateData> grid;
protected ListStore<TemplateData> store;
protected ExtendedListStore<TemplateData> store;
public TemplateDeletePanel(TemplateDeleteDialog parent,
EventBus eventBus) {
this.parent = parent;
@ -72,7 +79,19 @@ public class TemplateDeletePanel extends FramedPanel {
}
protected void create() {
ToolBar toolBarHead = new ToolBar();
toolBarHead.add(new LabelToolItem("Search: "));
final TextField searchField = new TextField();
toolBarHead.add(searchField);
TextButton btnReload = new TextButton();
//btnReload.setText("Reload");
btnReload.setIcon(ResourceBundle.INSTANCE.refresh());
btnReload.setToolTip("Reload");
toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
identity);
@ -98,8 +117,30 @@ public class TemplateDeletePanel extends FramedPanel {
l.add(descriptionCol);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
store = new ExtendedListStore<TemplateData>(props.id());
store = new ListStore<TemplateData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
Log.trace("searchTerm: "+searchField.getCurrentValue());
store.applyFilters();
}
});
store.addFilter(new StoreFilter<TemplateData>() {
@Override
public boolean select(Store<TemplateData> store,
TemplateData parent, TemplateData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null) return true;
return TemplateDeletePanel.this.select(item, searchTerm);
}
});
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
@ -132,7 +173,7 @@ public class TemplateDeletePanel extends FramedPanel {
sm.setSelectionMode(SelectionMode.MULTI);
grid.setLoader(loader);
grid.setSelectionModel(sm);
grid.setHeight("418px");
grid.setHeight("384px");
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
@ -180,6 +221,7 @@ public class TemplateDeletePanel extends FramedPanel {
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0)));
v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0)));
v.add(flowButton, new VerticalLayoutData(-1, 36,
@ -213,6 +255,10 @@ public class TemplateDeletePanel extends FramedPanel {
}
/*protected void setMenu() {
Menu contextMenu = new Menu();
@ -258,5 +304,30 @@ public class TemplateDeletePanel extends FramedPanel {
protected void close() {
parent.close();
}
protected class ExtendedListStore<M> extends ListStore<M> {
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
super(keyProvider);
}
public void applyFilters()
{
super.applyFilters();
}
}
public void gridReload(){
grid.getLoader().load();
}
protected boolean select(TemplateData item, String searchTerm) {
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
if (item.getCategory()!=null &&item.getCategory().toLowerCase().contains(searchTerm.toLowerCase())) return true;
if (item.getAgency()!=null &&item.getAgency().toLowerCase().contains(searchTerm.toLowerCase())) return true;
if (item.getDescription()!=null && item.getDescription().toLowerCase().contains(searchTerm.toLowerCase())) return true;
return false;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB