Added Delete inside Context Menu
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-open-widget@95300 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c5b7608268
commit
82817edc1c
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/tabular-data-open-widget-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/tabular-data-open-widget-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-open-widget-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/tabular-data-open-widget-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -33,5 +33,5 @@
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/tabular-data-open-widget-2.0.1-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/tabular-data-open-widget-2.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
||||||
d.addHideHandler(new HideHandler() {
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
public void onHide(HideEvent event) {
|
public void onHide(HideEvent event) {
|
||||||
removeTRWithLastTableNull();
|
deleteTRWithLastTableNull();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -109,14 +109,14 @@ public class TabResourcesSelectionCard extends WizardCard {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeTRWithLastTableNull() {
|
protected void deleteTRWithLastTableNull() {
|
||||||
final ConfirmMessageBox mb = new ConfirmMessageBox("Remove",
|
final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
|
||||||
"Would you like to remove this tabular resource without table?");
|
"Would you like to delete this tabular resource without table?");
|
||||||
mb.addHideHandler(new HideHandler() {
|
mb.addHideHandler(new HideHandler() {
|
||||||
public void onHide(HideEvent event) {
|
public void onHide(HideEvent event) {
|
||||||
if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
|
if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
|
||||||
.name())) {
|
.name())) {
|
||||||
callRemoveLastTable();
|
callDeleteLastTable();
|
||||||
} else if (mb.getHideButton() == mb
|
} else if (mb.getHideButton() == mb
|
||||||
.getButtonById(PredefinedButton.NO.name())) {
|
.getButtonById(PredefinedButton.NO.name())) {
|
||||||
// perform NO action
|
// perform NO action
|
||||||
|
@ -128,8 +128,8 @@ public class TabResourcesSelectionCard extends WizardCard {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void callRemoveLastTable(){
|
protected void callDeleteLastTable(){
|
||||||
Log.debug("Remove TR:" + tdOpenSession
|
Log.debug("Delete TR:" + tdOpenSession
|
||||||
.getSelectedTabResource().getTrId());
|
.getSelectedTabResource().getTrId());
|
||||||
TDGWTServiceAsync.INSTANCE.removeTabularResource(tdOpenSession
|
TDGWTServiceAsync.INSTANCE.removeTabularResource(tdOpenSession
|
||||||
.getSelectedTabResource().getTrId(),
|
.getSelectedTabResource().getTrId(),
|
||||||
|
@ -137,7 +137,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
AlertMessageBox d = new AlertMessageBox("Error",
|
AlertMessageBox d = new AlertMessageBox("Error",
|
||||||
"Error on remove TabResource: "
|
"Error on delete TabResource: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
d.addHideHandler(new HideHandler() {
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||||
|
import org.gcube.portlets.user.td.openwidget.client.resources.ResourceBundleTDOpen;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -18,6 +19,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
import com.google.gwt.event.dom.client.KeyUpEvent;
|
import com.google.gwt.event.dom.client.KeyUpEvent;
|
||||||
import com.google.gwt.event.dom.client.KeyUpHandler;
|
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||||
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
|
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
import com.google.gwt.event.shared.HandlerRegistration;
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -34,110 +36,131 @@ import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoader;
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||||
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
|
||||||
import com.sencha.gxt.widget.core.client.Resizable;
|
import com.sencha.gxt.widget.core.client.Resizable;
|
||||||
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
||||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||||
|
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
|
||||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
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.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
|
||||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||||
|
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.event.SelectEvent.SelectHandler;
|
||||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
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.CheckBoxSelectionModel;
|
||||||
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
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.ColumnModel;
|
||||||
import com.sencha.gxt.widget.core.client.grid.Grid;
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.Item;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.Menu;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
||||||
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
||||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TabResourcesSelectionPanel extends ContentPanel implements HasSelectionHandlers<TabResource> {
|
public class TabResourcesSelectionPanel extends ContentPanel implements
|
||||||
|
HasSelectionHandlers<TabResource> {
|
||||||
|
|
||||||
|
private static final TabResourcesProperties properties = GWT
|
||||||
|
.create(TabResourcesProperties.class);
|
||||||
|
|
||||||
|
protected static final ColumnConfig<TabResource, String> nameColumn = new ColumnConfig<TabResource, String>(
|
||||||
|
properties.name(), 90, "Name");
|
||||||
|
protected static final ColumnConfig<TabResource, String> typeColumn = new ColumnConfig<TabResource, String>(
|
||||||
|
properties.tabularResourceType(), 30, "Type");
|
||||||
|
protected static final ColumnConfig<TabResource, String> agencyColumn = new ColumnConfig<TabResource, String>(
|
||||||
|
properties.agency(), 60, "Agency");
|
||||||
|
protected static final ColumnConfig<TabResource, String> dateColumn = new ColumnConfig<TabResource, String>(
|
||||||
|
properties.date(), 40, "Date");
|
||||||
|
|
||||||
|
|
||||||
private static final TabResourcesProperties properties = GWT.create(TabResourcesProperties.class);
|
|
||||||
|
|
||||||
protected static final ColumnConfig<TabResource, String> nameColumn = new ColumnConfig<TabResource, String>(properties.name(), 90, "Name");
|
|
||||||
protected static final ColumnConfig<TabResource, String> typeColumn = new ColumnConfig<TabResource, String>(properties.tabularResourceType(), 30, "Type");
|
|
||||||
protected static final ColumnConfig<TabResource, String> agencyColumn = new ColumnConfig<TabResource, String>(properties.agency(), 60, "Agency");
|
|
||||||
protected static final ColumnConfig<TabResource, String> dateColumn = new ColumnConfig<TabResource, String>(properties.date(), 40, "Date");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected Grid<TabResource> grid;
|
protected Grid<TabResource> grid;
|
||||||
protected ResourceBundle res;
|
protected ResourceBundle res;
|
||||||
|
protected Menu contextMenu;
|
||||||
|
|
||||||
|
private TabResource removableTR;
|
||||||
public TabResourcesSelectionPanel(ResourceBundle res)
|
|
||||||
{
|
public TabResourcesSelectionPanel(ResourceBundle res) {
|
||||||
this.res=res;
|
this.res = res;
|
||||||
setHeaderVisible(false);
|
init();
|
||||||
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
createContextMenu();
|
||||||
buildPanel(properties.id(), Arrays.<ColumnConfig<TabResource, ?>>asList(nameColumn, typeColumn, agencyColumn, dateColumn), nameColumn);
|
buildPanel(properties.id(),
|
||||||
|
Arrays.<ColumnConfig<TabResource, ?>> asList(nameColumn,
|
||||||
|
typeColumn, agencyColumn, dateColumn), nameColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void init(){
|
||||||
protected void buildPanel(ModelKeyProvider<TabResource> keyProvider, List<ColumnConfig<TabResource, ?>> columns, ColumnConfig<TabResource, ?> autoexpandColumn)
|
setHeaderVisible(false);
|
||||||
{
|
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void buildPanel(ModelKeyProvider<TabResource> keyProvider,
|
||||||
|
List<ColumnConfig<TabResource, ?>> columns,
|
||||||
|
ColumnConfig<TabResource, ?> autoexpandColumn) {
|
||||||
|
|
||||||
ToolBar toolBar = new ToolBar();
|
ToolBar toolBar = new ToolBar();
|
||||||
toolBar.add(new LabelToolItem("Search: "));
|
toolBar.add(new LabelToolItem("Search: "));
|
||||||
final TextField searchField = new TextField();
|
final TextField searchField = new TextField();
|
||||||
toolBar.add(searchField);
|
toolBar.add(searchField);
|
||||||
|
|
||||||
TextButton btnReload = new TextButton();
|
TextButton btnReload = new TextButton();
|
||||||
//btnReload.setText("Reload");
|
// btnReload.setText("Reload");
|
||||||
btnReload.setIcon(res.refresh16());
|
btnReload.setIcon(res.refresh16());
|
||||||
btnReload.setToolTip("Reload");
|
btnReload.setToolTip("Reload");
|
||||||
toolBar.add(btnReload);
|
toolBar.add(btnReload);
|
||||||
|
|
||||||
|
|
||||||
IdentityValueProvider<TabResource> identity = new IdentityValueProvider<TabResource>();
|
IdentityValueProvider<TabResource> identity = new IdentityValueProvider<TabResource>();
|
||||||
final CheckBoxSelectionModel<TabResource> sm = new CheckBoxSelectionModel<TabResource>(identity);
|
final CheckBoxSelectionModel<TabResource> sm = new CheckBoxSelectionModel<TabResource>(
|
||||||
|
identity);
|
||||||
|
|
||||||
ColumnModel<TabResource> cm = new ColumnModel<TabResource>(columns);
|
ColumnModel<TabResource> cm = new ColumnModel<TabResource>(columns);
|
||||||
|
|
||||||
final ExtendedListStore<TabResource> store = new ExtendedListStore<TabResource>(keyProvider);
|
final ExtendedListStore<TabResource> store = new ExtendedListStore<TabResource>(
|
||||||
|
keyProvider);
|
||||||
|
|
||||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
public void onKeyUp(KeyUpEvent event) {
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
Log.trace("searchTerm: "+searchField.getCurrentValue());
|
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||||
store.applyFilters();
|
store.applyFilters();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.addFilter(new StoreFilter<TabResource>() {
|
store.addFilter(new StoreFilter<TabResource>() {
|
||||||
|
|
||||||
public boolean select(Store<TabResource> store, TabResource parent, TabResource item) {
|
public boolean select(Store<TabResource> store, TabResource parent,
|
||||||
|
TabResource item) {
|
||||||
String searchTerm = searchField.getCurrentValue();
|
String searchTerm = searchField.getCurrentValue();
|
||||||
if (searchTerm == null) return true;
|
if (searchTerm == null)
|
||||||
|
return true;
|
||||||
return TabResourcesSelectionPanel.this.select(item, searchTerm);
|
return TabResourcesSelectionPanel.this.select(item, searchTerm);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.setEnableFilters(true);
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
RpcProxy<ListLoadConfig, ListLoadResult<TabResource>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TabResource>>() {
|
RpcProxy<ListLoadConfig, ListLoadResult<TabResource>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TabResource>>() {
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig,
|
||||||
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<TabResource>> callback) {
|
final AsyncCallback<ListLoadResult<TabResource>> callback) {
|
||||||
loadData(loadConfig, callback);
|
loadData(loadConfig, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final ListLoader<ListLoadConfig, ListLoadResult<TabResource>> loader = new ListLoader<ListLoadConfig, ListLoadResult<TabResource>>(proxy);
|
final ListLoader<ListLoadConfig, ListLoadResult<TabResource>> loader = new ListLoader<ListLoadConfig, ListLoadResult<TabResource>>(
|
||||||
|
proxy);
|
||||||
|
|
||||||
loader.setRemoteSort(false);
|
loader.setRemoteSort(false);
|
||||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TabResource, ListLoadResult<TabResource>>(store));
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TabResource, ListLoadResult<TabResource>>(
|
||||||
|
store));
|
||||||
|
|
||||||
grid = new Grid<TabResource>(store, cm){
|
grid = new Grid<TabResource>(store, cm) {
|
||||||
@Override
|
@Override
|
||||||
protected void onAfterFirstAttach() {
|
protected void onAfterFirstAttach() {
|
||||||
super.onAfterFirstAttach();
|
super.onAfterFirstAttach();
|
||||||
|
@ -148,8 +171,8 @@ public class TabResourcesSelectionPanel extends ContentPanel implements HasSelec
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||||
grid.setLoader(loader);
|
grid.setLoader(loader);
|
||||||
grid.setSelectionModel(sm);
|
grid.setSelectionModel(sm);
|
||||||
grid.getView().setAutoExpandColumn(autoexpandColumn);
|
grid.getView().setAutoExpandColumn(autoexpandColumn);
|
||||||
|
@ -159,87 +182,170 @@ public class TabResourcesSelectionPanel extends ContentPanel implements HasSelec
|
||||||
grid.setBorders(false);
|
grid.setBorders(false);
|
||||||
grid.setLoadMask(true);
|
grid.setLoadMask(true);
|
||||||
grid.setColumnReordering(true);
|
grid.setColumnReordering(true);
|
||||||
|
|
||||||
|
|
||||||
SelectHandler sh = new SelectHandler() {
|
SelectHandler sh = new SelectHandler() {
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
loader.load();
|
loader.load();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
btnReload.addSelectHandler(sh);
|
btnReload.addSelectHandler(sh);
|
||||||
|
|
||||||
|
if (contextMenu != null) {
|
||||||
|
grid.setContextMenu(contextMenu);
|
||||||
|
} else
|
||||||
|
grid.setContextMenu(null);
|
||||||
|
|
||||||
|
|
||||||
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
con.add(toolBar, new VerticalLayoutData(1, -1));
|
con.add(toolBar, new VerticalLayoutData(1, -1));
|
||||||
con.add(grid, new VerticalLayoutData(1, 1));
|
con.add(grid, new VerticalLayoutData(1, 1));
|
||||||
setWidget(con);
|
setWidget(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void createContextMenu() {
|
||||||
|
MenuItem deleteTRItem = new MenuItem("Delete");
|
||||||
|
deleteTRItem.setId("DeleteTR");
|
||||||
|
deleteTRItem.setIcon(ResourceBundleTDOpen.INSTANCE.delete());
|
||||||
|
deleteTRItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
if (grid != null) {
|
||||||
|
TabResource tabResource= getSelectedItem();
|
||||||
|
deleteTR(tabResource);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contextMenu.add(deleteTRItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean select(TabResource item, String searchTerm) {
|
protected boolean select(TabResource item, String searchTerm) {
|
||||||
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
if (item.getName() != null
|
||||||
if (item.getTabularResourceType()!=null &&item.getTabularResourceType().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
&& item.getName().toLowerCase()
|
||||||
if (item.getAgency()!=null &&item.getAgency().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
.contains(searchTerm.toLowerCase()))
|
||||||
if (item.getDate()!=null && item.getDate().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
return true;
|
||||||
|
if (item.getTabularResourceType() != null
|
||||||
|
&& item.getTabularResourceType().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getAgency() != null
|
||||||
|
&& item.getAgency().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
|
if (item.getDate() != null
|
||||||
|
&& item.getDate().toLowerCase()
|
||||||
|
.contains(searchTerm.toLowerCase()))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
protected void loadData(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<TabResource>> callback) {
|
final AsyncCallback<ListLoadResult<TabResource>> callback) {
|
||||||
TDGWTServiceAsync.INSTANCE.getTabularResources(new AsyncCallback<ArrayList<TabResource>>() {
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getTabularResources(new AsyncCallback<ArrayList<TabResource>>() {
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Log.debug("Error retriving tabular resource: "+caught.getLocalizedMessage());
|
Log.debug("Error retrieving tabular resource: "
|
||||||
callback.onFailure(caught);
|
+ caught.getLocalizedMessage());
|
||||||
AlertMessageBox d = new AlertMessageBox("Error!",
|
callback.onFailure(caught);
|
||||||
"Error retrieving tabular resources on server!");
|
AlertMessageBox d = new AlertMessageBox("Error!",
|
||||||
d.addHideHandler(new HideHandler() {
|
"Error retrieving tabular resources on server!");
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
public void onHide(HideEvent event) {
|
public void onHide(HideEvent event) {
|
||||||
//
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<TabResource> result) {
|
||||||
|
Log.debug("loaded " + result.size()
|
||||||
|
+ " TabularResources");
|
||||||
|
/*
|
||||||
|
* for(TabResource tr:result){ Log.debug("TR:"+tr); }
|
||||||
|
*/
|
||||||
|
callback.onSuccess(new ListLoadResultBean<TabResource>(
|
||||||
|
result));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
d.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSuccess(ArrayList<TabResource> result) {
|
|
||||||
Log.debug("loaded "+result.size()+" TabularResources");
|
|
||||||
/*for(TabResource tr:result){
|
|
||||||
Log.debug("TR:"+tr);
|
|
||||||
}*/
|
|
||||||
callback.onSuccess(new ListLoadResultBean<TabResource>(result));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HandlerRegistration addSelectionHandler(
|
||||||
public HandlerRegistration addSelectionHandler(SelectionHandler<TabResource> handler) {
|
SelectionHandler<TabResource> handler) {
|
||||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabResource getSelectedItem() {
|
public TabResource getSelectedItem() {
|
||||||
return grid.getSelectionModel().getSelectedItem();
|
return grid.getSelectionModel().getSelectedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class ExtendedListStore<M> extends ListStore<M> {
|
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||||
|
|
||||||
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||||
super(keyProvider);
|
super(keyProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyFilters()
|
public void applyFilters() {
|
||||||
{
|
|
||||||
super.applyFilters();
|
super.applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gridReload(){
|
public void gridReload() {
|
||||||
grid.getLoader().load();
|
grid.getLoader().load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void deleteTR(TabResource tabResource) {
|
||||||
|
removableTR=tabResource;
|
||||||
|
final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
|
||||||
|
"Would you like to delete this tabular resource?");
|
||||||
|
mb.addHideHandler(new HideHandler() {
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
|
||||||
|
.name())) {
|
||||||
|
callDeleteTabularResource();
|
||||||
|
} else if (mb.getHideButton() == mb
|
||||||
|
.getButtonById(PredefinedButton.NO.name())) {
|
||||||
|
// perform NO action
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mb.setWidth(300);
|
||||||
|
mb.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void callDeleteTabularResource() {
|
||||||
|
Log.debug("Delete TR:" + removableTR);
|
||||||
|
TDGWTServiceAsync.INSTANCE.removeTabularResource(removableTR.getTrId(),
|
||||||
|
new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
AlertMessageBox d = new AlertMessageBox("Error",
|
||||||
|
"Error on delete TabResource: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
gridReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.gcube.portlets.user.td.openwidget.client.resources;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ResourceBundleTDOpen extends ClientBundle {
|
||||||
|
|
||||||
|
public static final ResourceBundleTDOpen INSTANCE=GWT.create(ResourceBundleTDOpen.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Source("delete.png")
|
||||||
|
ImageResource delete();
|
||||||
|
|
||||||
|
@Source("delete32.png")
|
||||||
|
ImageResource delete32();
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 614 B |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 614 B |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in New Issue