Added SessionExpiredShow
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@95788 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e56d041841
commit
5e3fa60764
|
@ -8,7 +8,11 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -51,32 +55,38 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AgenciesSelectionPanel extends ContentPanel implements HasSelectionHandlers<Agencies> {
|
||||
public class AgenciesSelectionPanel extends ContentPanel implements
|
||||
HasSelectionHandlers<Agencies> {
|
||||
|
||||
private static final AgenciesProperties properties = GWT.create(AgenciesProperties.class);
|
||||
private static final AgenciesProperties properties = GWT
|
||||
.create(AgenciesProperties.class);
|
||||
|
||||
protected static final ColumnConfig<Agencies, String> nameColumn = new ColumnConfig<Agencies, String>(properties.name(), 50, "Name");
|
||||
protected static final ColumnConfig<Agencies, String> descriptionColumn = new ColumnConfig<Agencies, String>(properties.description(), 50, "Description");
|
||||
protected static final ColumnConfig<Agencies, String> nameColumn = new ColumnConfig<Agencies, String>(
|
||||
properties.name(), 50, "Name");
|
||||
protected static final ColumnConfig<Agencies, String> descriptionColumn = new ColumnConfig<Agencies, String>(
|
||||
properties.description(), 50, "Description");
|
||||
|
||||
protected Grid<Agencies> grid;
|
||||
protected ResourceBundle res;
|
||||
|
||||
private WizardCard parent;
|
||||
|
||||
public AgenciesSelectionPanel(ResourceBundle res)
|
||||
{
|
||||
this.res=res;
|
||||
public AgenciesSelectionPanel(WizardCard parent, ResourceBundle res) {
|
||||
this.parent = parent;
|
||||
this.res = res;
|
||||
setHeaderVisible(false);
|
||||
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||
buildPanel(properties.key(), Arrays.<ColumnConfig<Agencies, ?>>asList(nameColumn, descriptionColumn), nameColumn);
|
||||
buildPanel(properties.key(), Arrays.<ColumnConfig<Agencies, ?>> asList(
|
||||
nameColumn, descriptionColumn), nameColumn);
|
||||
}
|
||||
|
||||
|
||||
protected void buildPanel(ModelKeyProvider<Agencies> keyProvider, List<ColumnConfig<Agencies, ?>> columns, ColumnConfig<Agencies, ?> autoexpandColumn)
|
||||
{
|
||||
protected void buildPanel(ModelKeyProvider<Agencies> keyProvider,
|
||||
List<ColumnConfig<Agencies, ?>> columns,
|
||||
ColumnConfig<Agencies, ?> autoexpandColumn) {
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(new LabelToolItem("Search: "));
|
||||
|
@ -84,52 +94,56 @@ public class AgenciesSelectionPanel extends ContentPanel implements HasSelection
|
|||
toolBar.add(searchField);
|
||||
|
||||
TextButton btnReload = new TextButton();
|
||||
//btnReload.setText("Reload");
|
||||
// btnReload.setText("Reload");
|
||||
btnReload.setIcon(res.refresh16());
|
||||
btnReload.setToolTip("Reload");
|
||||
toolBar.add(btnReload);
|
||||
|
||||
|
||||
IdentityValueProvider<Agencies> identity = new IdentityValueProvider<Agencies>();
|
||||
final CheckBoxSelectionModel<Agencies> sm = new CheckBoxSelectionModel<Agencies>(identity);
|
||||
final CheckBoxSelectionModel<Agencies> sm = new CheckBoxSelectionModel<Agencies>(
|
||||
identity);
|
||||
|
||||
ColumnModel<Agencies> cm = new ColumnModel<Agencies>(columns);
|
||||
|
||||
final ExtendedListStore<Agencies> store = new ExtendedListStore<Agencies>(keyProvider);
|
||||
final ExtendedListStore<Agencies> store = new ExtendedListStore<Agencies>(
|
||||
keyProvider);
|
||||
|
||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||
|
||||
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
Log.trace("searchTerm: "+searchField.getCurrentValue());
|
||||
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||
store.applyFilters();
|
||||
}
|
||||
});
|
||||
|
||||
store.addFilter(new StoreFilter<Agencies>() {
|
||||
|
||||
public boolean select(Store<Agencies> store, Agencies parent, Agencies item) {
|
||||
public boolean select(Store<Agencies> store, Agencies parent,
|
||||
Agencies item) {
|
||||
String searchTerm = searchField.getCurrentValue();
|
||||
if (searchTerm == null) return true;
|
||||
if (searchTerm == null)
|
||||
return true;
|
||||
return AgenciesSelectionPanel.this.select(item, searchTerm);
|
||||
}
|
||||
});
|
||||
|
||||
store.setEnableFilters(true);
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<Agencies>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Agencies>>() {
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<Agencies>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Agencies>>() {
|
||||
|
||||
|
||||
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||
public void load(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
final ListLoader<ListLoadConfig, ListLoadResult<Agencies>> loader = new ListLoader<ListLoadConfig, ListLoadResult<Agencies>>(proxy);
|
||||
final ListLoader<ListLoadConfig, ListLoadResult<Agencies>> loader = new ListLoader<ListLoadConfig, ListLoadResult<Agencies>>(
|
||||
proxy);
|
||||
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Agencies, ListLoadResult<Agencies>>(store));
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Agencies, ListLoadResult<Agencies>>(
|
||||
store));
|
||||
|
||||
grid = new Grid<Agencies>(store, cm){
|
||||
grid = new Grid<Agencies>(store, cm) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
|
@ -166,40 +180,56 @@ public class AgenciesSelectionPanel extends ContentPanel implements HasSelection
|
|||
setWidget(con);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected boolean select(Agencies item, String searchTerm) {
|
||||
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
||||
if (item.getDescription()!=null && item.getDescription().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
||||
if (item.getId()!=null &&item.getId().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
||||
if (item.getName() != null
|
||||
&& item.getName().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
if (item.getDescription() != null
|
||||
&& item.getDescription().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
if (item.getId() != null
|
||||
&& item.getId().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getAgencies(new AsyncCallback<ArrayList<Agencies>>() {
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE.getAgencies(new AsyncCallback<ArrayList<Agencies>>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
parent.getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("No agencies retrieved");
|
||||
}
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<Agencies> result) {
|
||||
Log.trace("loaded "+result.size()+" agencies");
|
||||
callback.onSuccess(new ListLoadResultBean<Agencies>(result));
|
||||
}
|
||||
});
|
||||
public void onSuccess(ArrayList<Agencies> result) {
|
||||
Log.trace("loaded " + result.size() + " agencies");
|
||||
callback.onSuccess(new ListLoadResultBean<Agencies>(
|
||||
result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public HandlerRegistration addSelectionHandler(SelectionHandler<Agencies> handler) {
|
||||
public HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<Agencies> handler) {
|
||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||
}
|
||||
|
||||
|
||||
/*public List<Agencies> getSelectedItems() {
|
||||
return grid.getSelectionModel().getSelectedItems();
|
||||
}*/
|
||||
/*
|
||||
* public List<Agencies> getSelectedItems() { return
|
||||
* grid.getSelectionModel().getSelectedItems(); }
|
||||
*/
|
||||
|
||||
public Agencies getSelectedItem() {
|
||||
return grid.getSelectionModel().getSelectedItem();
|
||||
|
@ -211,12 +241,10 @@ public class AgenciesSelectionPanel extends ContentPanel implements HasSelection
|
|||
super(keyProvider);
|
||||
}
|
||||
|
||||
public void applyFilters()
|
||||
{
|
||||
public void applyFilters() {
|
||||
super.applyFilters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,11 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -67,9 +71,12 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection
|
|||
protected Grid<Codelist> grid;
|
||||
protected ResourceBundle res;
|
||||
|
||||
private WizardCard parent;
|
||||
|
||||
public CodelistSelectionPanel(ResourceBundle res)
|
||||
|
||||
public CodelistSelectionPanel(WizardCard parent,ResourceBundle res)
|
||||
{
|
||||
this.parent=parent;
|
||||
this.res=res;
|
||||
setHeaderVisible(false);
|
||||
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||
|
@ -183,6 +190,14 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection
|
|||
TDGWTServiceAsync.INSTANCE.getCodelists(new AsyncCallback<ArrayList<Codelist>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
parent.getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("No codelists retrieved");
|
||||
}
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
|
@ -199,10 +214,6 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection
|
|||
}
|
||||
|
||||
|
||||
/*public List<Codelist> getSelectedItems() {
|
||||
return grid.getSelectionModel().getSelectedItems();
|
||||
}*/
|
||||
|
||||
public Codelist getSelectedItem() {
|
||||
return grid.getSelectionModel().getSelectedItem();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,12 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -61,8 +66,14 @@ public class DatasetSelectionPanel extends ContentPanel implements HasSelectionH
|
|||
|
||||
protected Grid<Dataset> grid;
|
||||
|
||||
public DatasetSelectionPanel()
|
||||
protected ResourceBundle res;
|
||||
|
||||
private WizardCard parent;
|
||||
|
||||
public DatasetSelectionPanel(WizardCard parent, ResourceBundle res)
|
||||
{
|
||||
this.parent=parent;
|
||||
this.res=res;
|
||||
setHeaderVisible(false);
|
||||
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||
buildPanel(properties.key(), Arrays.<ColumnConfig<Dataset, ?>>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn);
|
||||
|
@ -159,6 +170,15 @@ public class DatasetSelectionPanel extends ContentPanel implements HasSelectionH
|
|||
TDGWTServiceAsync.INSTANCE.getDatasets(new AsyncCallback<ArrayList<Dataset>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
parent.getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("No datasets retrieved");
|
||||
}
|
||||
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SDMXAgenciesSelectionCard extends WizardCard {
|
|||
this.exportSession = exportSession;
|
||||
thisCard=this;
|
||||
|
||||
this.agenciesSelectionPanel=new AgenciesSelectionPanel(res);
|
||||
this.agenciesSelectionPanel=new AgenciesSelectionPanel(thisCard,res);
|
||||
|
||||
agenciesSelectionPanel.addSelectionHandler(new SelectionHandler<Agencies>(){
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SDMXCodelistSelectionCard extends WizardCard {
|
|||
this.exportSession = exportSession;
|
||||
thisCard=this;
|
||||
|
||||
this.codelistSelectionPanel=new CodelistSelectionPanel(res);
|
||||
this.codelistSelectionPanel=new CodelistSelectionPanel(thisCard,res);
|
||||
|
||||
codelistSelectionPanel.addSelectionHandler(new SelectionHandler<Codelist>() {
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SDMXDatasetSelectionCard extends WizardCard {
|
|||
|
||||
thisCard=this;
|
||||
|
||||
this.datasetSelectionPanel=new DatasetSelectionPanel();
|
||||
this.datasetSelectionPanel=new DatasetSelectionPanel(thisCard,res);
|
||||
|
||||
setContent(datasetSelectionPanel);
|
||||
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressBarUpdater;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressListener;
|
||||
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.SDMXExportProgressUpdater;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
|
@ -114,11 +117,19 @@ public class SDMXOperationInProgressCard extends WizardCard implements
|
|||
}
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
showErrorAndHide(
|
||||
"Error in exportSDMX",
|
||||
"An error occured in exportSDMX: "
|
||||
+ caught.getLocalizedMessage(), caught
|
||||
.getStackTrace().toString(), caught);
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
||||
showErrorAndHide(
|
||||
"Error in exportSDMX",
|
||||
"An error occured in exportSDMX: "
|
||||
+ caught.getLocalizedMessage(),
|
||||
caught.getStackTrace().toString(), caught);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -167,13 +178,21 @@ public class SDMXOperationInProgressCard extends WizardCard implements
|
|||
|
||||
public void operationFailed(Throwable caught, String reason,
|
||||
String failureDetails) {
|
||||
AlertMessageBox d = new AlertMessageBox("Error in SDMX Export", reason);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
public void onHide(HideEvent event) {
|
||||
}
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
AlertMessageBox d = new AlertMessageBox("Error in SDMX Export",
|
||||
reason);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
public void onHide(HideEvent event) {
|
||||
}
|
||||
|
||||
});
|
||||
d.show();
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -147,8 +150,15 @@ public class SDMXRegistrySelectionCard extends WizardCard {
|
|||
((SDMXRegistrySource)exportSession.getSource()), new AsyncCallback<Void>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("SDMXRegistrySource do not stored "
|
||||
+ caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(Void result) {
|
||||
|
|
Loading…
Reference in New Issue