Cleaned and restored the project
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@84562 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
75bee4cedf
commit
3478f85911
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||||
|
|
||||||
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
import com.sencha.gxt.data.shared.LabelProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface AgenciesProperties extends PropertyAccess<Agencies> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<Agencies> key();
|
||||||
|
|
||||||
|
LabelProvider<Agencies> nameLabel();
|
||||||
|
|
||||||
|
ValueProvider<Agencies, String> name();
|
||||||
|
ValueProvider<Agencies, String> description();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,228 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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.Agencies;
|
||||||
|
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;
|
||||||
|
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.event.logical.shared.HasSelectionHandlers;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||||
|
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||||
|
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;
|
||||||
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||||
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||||
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.Resizable;
|
||||||
|
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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> {
|
||||||
|
|
||||||
|
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 Grid<Agencies> grid;
|
||||||
|
protected ResourceBundle res;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public AgenciesSelectionPanel(ResourceBundle res)
|
||||||
|
{
|
||||||
|
this.res=res;
|
||||||
|
setHeaderVisible(false);
|
||||||
|
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||||
|
buildPanel(properties.key(), Arrays.<ColumnConfig<Agencies, ?>>asList(nameColumn, descriptionColumn), nameColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void buildPanel(ModelKeyProvider<Agencies> keyProvider, List<ColumnConfig<Agencies, ?>> columns, ColumnConfig<Agencies, ?> autoexpandColumn)
|
||||||
|
{
|
||||||
|
|
||||||
|
ToolBar toolBar = new ToolBar();
|
||||||
|
toolBar.add(new LabelToolItem("Search: "));
|
||||||
|
final TextField searchField = new TextField();
|
||||||
|
toolBar.add(searchField);
|
||||||
|
|
||||||
|
TextButton btnReload = new TextButton();
|
||||||
|
//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);
|
||||||
|
|
||||||
|
ColumnModel<Agencies> cm = new ColumnModel<Agencies>(columns);
|
||||||
|
|
||||||
|
final ExtendedListStore<Agencies> store = new ExtendedListStore<Agencies>(keyProvider);
|
||||||
|
|
||||||
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
Log.trace("searchTerm: "+searchField.getCurrentValue());
|
||||||
|
store.applyFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.addFilter(new StoreFilter<Agencies>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean select(Store<Agencies> store, Agencies parent, Agencies item) {
|
||||||
|
String searchTerm = searchField.getCurrentValue();
|
||||||
|
if (searchTerm == null) return true;
|
||||||
|
return AgenciesSelectionPanel.this.select(item, searchTerm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<Agencies>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Agencies>>() {
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Agencies, ListLoadResult<Agencies>>(store));
|
||||||
|
|
||||||
|
grid = new Grid<Agencies>(store, cm){
|
||||||
|
@Override
|
||||||
|
protected void onAfterFirstAttach() {
|
||||||
|
super.onAfterFirstAttach();
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
grid.setLoader(loader);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
|
grid.getView().setAutoExpandColumn(autoexpandColumn);
|
||||||
|
grid.getView().setStripeRows(true);
|
||||||
|
grid.getView().setColumnLines(true);
|
||||||
|
grid.getView().setAutoFill(true);
|
||||||
|
grid.setBorders(false);
|
||||||
|
grid.setLoadMask(true);
|
||||||
|
grid.setColumnReordering(true);
|
||||||
|
|
||||||
|
SelectHandler sh = new SelectHandler() {
|
||||||
|
@Override
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
btnReload.addSelectHandler(sh);
|
||||||
|
|
||||||
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
|
con.add(toolBar, new VerticalLayoutData(1, -1));
|
||||||
|
con.add(grid, new VerticalLayoutData(1, 1));
|
||||||
|
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;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void loadData(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Agencies>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE.getAgencies(new AsyncCallback<ArrayList<Agencies>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ArrayList<Agencies> result) {
|
||||||
|
Log.trace("loaded "+result.size()+" agencies");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<Agencies>(result));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerRegistration addSelectionHandler(SelectionHandler<Agencies> handler) {
|
||||||
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*public List<Agencies> getSelectedItems() {
|
||||||
|
return grid.getSelectionModel().getSelectedItems();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Agencies getSelectedItem() {
|
||||||
|
return grid.getSelectionModel().getSelectedItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||||
|
|
||||||
|
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||||
|
super(keyProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyFilters()
|
||||||
|
{
|
||||||
|
super.applyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Codelist;
|
||||||
|
|
||||||
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface CodelistProperties extends PropertyAccess<Codelist> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<Codelist> key();
|
||||||
|
|
||||||
|
ValueProvider<Codelist, String> name();
|
||||||
|
ValueProvider<Codelist, String> agencyId();
|
||||||
|
ValueProvider<Codelist, String> version();
|
||||||
|
ValueProvider<Codelist, String> description();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,232 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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.Codelist;
|
||||||
|
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;
|
||||||
|
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.event.logical.shared.HasSelectionHandlers;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||||
|
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||||
|
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;
|
||||||
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||||
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||||
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.Resizable;
|
||||||
|
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodelistSelectionPanel extends ContentPanel implements HasSelectionHandlers<Codelist> {
|
||||||
|
|
||||||
|
private static final CodelistProperties properties = GWT.create(CodelistProperties.class);
|
||||||
|
|
||||||
|
protected static final ColumnConfig<Codelist, String> nameColumn = new ColumnConfig<Codelist, String>(properties.name(), 50, "Name");
|
||||||
|
protected static final ColumnConfig<Codelist, String> agencyIdColumn = new ColumnConfig<Codelist, String>(properties.agencyId(), 50, "Agency Id");
|
||||||
|
protected static final ColumnConfig<Codelist, String> versionColumn = new ColumnConfig<Codelist, String>(properties.version(), 50, "Version");
|
||||||
|
protected static final ColumnConfig<Codelist, String> descriptionColumn = new ColumnConfig<Codelist, String>(properties.description(), 50, "Description");
|
||||||
|
|
||||||
|
protected Grid<Codelist> grid;
|
||||||
|
protected ResourceBundle res;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public CodelistSelectionPanel(ResourceBundle res)
|
||||||
|
{
|
||||||
|
this.res=res;
|
||||||
|
setHeaderVisible(false);
|
||||||
|
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||||
|
buildPanel(properties.key(), Arrays.<ColumnConfig<Codelist, ?>>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void buildPanel(ModelKeyProvider<Codelist> keyProvider, List<ColumnConfig<Codelist, ?>> columns, ColumnConfig<Codelist, ?> autoexpandColumn)
|
||||||
|
{
|
||||||
|
|
||||||
|
ToolBar toolBar = new ToolBar();
|
||||||
|
toolBar.add(new LabelToolItem("Search: "));
|
||||||
|
final TextField searchField = new TextField();
|
||||||
|
toolBar.add(searchField);
|
||||||
|
|
||||||
|
TextButton btnReload = new TextButton();
|
||||||
|
//btnReload.setText("Reload");
|
||||||
|
btnReload.setIcon(res.refresh16());
|
||||||
|
btnReload.setToolTip("Reload");
|
||||||
|
toolBar.add(btnReload);
|
||||||
|
|
||||||
|
|
||||||
|
IdentityValueProvider<Codelist> identity = new IdentityValueProvider<Codelist>();
|
||||||
|
final CheckBoxSelectionModel<Codelist> sm = new CheckBoxSelectionModel<Codelist>(identity);
|
||||||
|
|
||||||
|
ColumnModel<Codelist> cm = new ColumnModel<Codelist>(columns);
|
||||||
|
|
||||||
|
final ExtendedListStore<Codelist> store = new ExtendedListStore<Codelist>(keyProvider);
|
||||||
|
|
||||||
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
Log.trace("searchTerm: "+searchField.getCurrentValue());
|
||||||
|
store.applyFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.addFilter(new StoreFilter<Codelist>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean select(Store<Codelist> store, Codelist parent, Codelist item) {
|
||||||
|
String searchTerm = searchField.getCurrentValue();
|
||||||
|
if (searchTerm == null) return true;
|
||||||
|
return CodelistSelectionPanel.this.select(item, searchTerm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<Codelist>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Codelist>>() {
|
||||||
|
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Codelist>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final ListLoader<ListLoadConfig, ListLoadResult<Codelist>> loader = new ListLoader<ListLoadConfig, ListLoadResult<Codelist>>(proxy);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Codelist, ListLoadResult<Codelist>>(store));
|
||||||
|
|
||||||
|
grid = new Grid<Codelist>(store, cm){
|
||||||
|
@Override
|
||||||
|
protected void onAfterFirstAttach() {
|
||||||
|
super.onAfterFirstAttach();
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
grid.setLoader(loader);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
|
grid.getView().setAutoExpandColumn(autoexpandColumn);
|
||||||
|
grid.getView().setStripeRows(true);
|
||||||
|
grid.getView().setColumnLines(true);
|
||||||
|
grid.getView().setAutoFill(true);
|
||||||
|
grid.setBorders(false);
|
||||||
|
grid.setLoadMask(true);
|
||||||
|
grid.setColumnReordering(true);
|
||||||
|
|
||||||
|
SelectHandler sh = new SelectHandler() {
|
||||||
|
@Override
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
btnReload.addSelectHandler(sh);
|
||||||
|
|
||||||
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
|
con.add(toolBar, new VerticalLayoutData(1, -1));
|
||||||
|
con.add(grid, new VerticalLayoutData(1, 1));
|
||||||
|
setWidget(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean select(Codelist item, String searchTerm) {
|
||||||
|
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
||||||
|
if (item.getAgencyId()!=null &&item.getAgencyId().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
||||||
|
if (item.getVersion()!=null && item.getVersion().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<Codelist>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE.getCodelists(new AsyncCallback<ArrayList<Codelist>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ArrayList<Codelist> result) {
|
||||||
|
Log.trace("loaded "+result.size()+" codelists");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<Codelist>(result));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerRegistration addSelectionHandler(SelectionHandler<Codelist> handler) {
|
||||||
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*public List<Codelist> getSelectedItems() {
|
||||||
|
return grid.getSelectionModel().getSelectedItems();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Codelist getSelectedItem() {
|
||||||
|
return grid.getSelectionModel().getSelectedItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||||
|
|
||||||
|
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||||
|
super(keyProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyFilters()
|
||||||
|
{
|
||||||
|
super.applyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Dataset;
|
||||||
|
|
||||||
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface DatasetProperties extends PropertyAccess<Dataset> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<Dataset> key();
|
||||||
|
|
||||||
|
ValueProvider<Dataset, String> name();
|
||||||
|
ValueProvider<Dataset, String> agencyId();
|
||||||
|
ValueProvider<Dataset, String> version();
|
||||||
|
ValueProvider<Dataset, String> description();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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.Dataset;
|
||||||
|
|
||||||
|
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.event.logical.shared.HasSelectionHandlers;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||||
|
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;
|
||||||
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||||
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||||
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.Resizable;
|
||||||
|
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DatasetSelectionPanel extends ContentPanel implements HasSelectionHandlers<Dataset> {
|
||||||
|
|
||||||
|
private static final DatasetProperties properties = GWT.create(DatasetProperties.class);
|
||||||
|
|
||||||
|
protected static final ColumnConfig<Dataset, String> nameColumn = new ColumnConfig<Dataset, String>(properties.name(), 50, "Name");
|
||||||
|
protected static final ColumnConfig<Dataset, String> agencyIdColumn = new ColumnConfig<Dataset, String>(properties.agencyId(), 50, "Agency Id");
|
||||||
|
protected static final ColumnConfig<Dataset, String> versionColumn = new ColumnConfig<Dataset, String>(properties.version(), 50, "Version");
|
||||||
|
protected static final ColumnConfig<Dataset, String> descriptionColumn = new ColumnConfig<Dataset, String>(properties.description(), 50, "Description");
|
||||||
|
|
||||||
|
protected Grid<Dataset> grid;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public DatasetSelectionPanel()
|
||||||
|
{
|
||||||
|
setHeaderVisible(false);
|
||||||
|
new Resizable(this, Dir.E, Dir.SE, Dir.S);
|
||||||
|
buildPanel(properties.key(), Arrays.<ColumnConfig<Dataset, ?>>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void buildPanel(ModelKeyProvider<Dataset> keyProvider, List<ColumnConfig<Dataset, ?>> columns, ColumnConfig<Dataset, ?> autoexpandColumn)
|
||||||
|
{
|
||||||
|
|
||||||
|
ToolBar toolBar = new ToolBar();
|
||||||
|
toolBar.add(new LabelToolItem("Search: "));
|
||||||
|
final TextField searchField = new TextField();
|
||||||
|
toolBar.add(searchField);
|
||||||
|
|
||||||
|
IdentityValueProvider<Dataset> identity = new IdentityValueProvider<Dataset>();
|
||||||
|
final CheckBoxSelectionModel<Dataset> sm = new CheckBoxSelectionModel<Dataset>(identity);
|
||||||
|
|
||||||
|
ColumnModel<Dataset> cm = new ColumnModel<Dataset>(columns);
|
||||||
|
|
||||||
|
final ExtendedListStore<Dataset> store = new ExtendedListStore<Dataset>(keyProvider);
|
||||||
|
|
||||||
|
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onKeyUp(KeyUpEvent event) {
|
||||||
|
Log.trace("searchTerm: "+searchField.getCurrentValue());
|
||||||
|
store.applyFilters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.addFilter(new StoreFilter<Dataset>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean select(Store<Dataset> store, Dataset parent, Dataset item) {
|
||||||
|
String searchTerm = searchField.getCurrentValue();
|
||||||
|
if (searchTerm == null) return true;
|
||||||
|
return DatasetSelectionPanel.this.select(item, searchTerm);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store.setEnableFilters(true);
|
||||||
|
|
||||||
|
RpcProxy<ListLoadConfig, ListLoadResult<Dataset>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Dataset>>() {
|
||||||
|
|
||||||
|
|
||||||
|
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Dataset>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final ListLoader<ListLoadConfig, ListLoadResult<Dataset>> loader = new ListLoader<ListLoadConfig, ListLoadResult<Dataset>>(proxy);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Dataset, ListLoadResult<Dataset>>(store));
|
||||||
|
|
||||||
|
grid = new Grid<Dataset>(store, cm){
|
||||||
|
@Override
|
||||||
|
protected void onAfterFirstAttach() {
|
||||||
|
super.onAfterFirstAttach();
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
grid.setLoader(loader);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
|
grid.getView().setAutoExpandColumn(autoexpandColumn);
|
||||||
|
grid.getView().setStripeRows(true);
|
||||||
|
grid.getView().setColumnLines(true);
|
||||||
|
grid.getView().setAutoFill(true);
|
||||||
|
grid.setBorders(false);
|
||||||
|
grid.setLoadMask(true);
|
||||||
|
|
||||||
|
grid.setColumnReordering(true);
|
||||||
|
|
||||||
|
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||||
|
con.add(toolBar, new VerticalLayoutData(1, -1));
|
||||||
|
con.add(grid, new VerticalLayoutData(1, 1));
|
||||||
|
setWidget(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean select(Dataset item, String searchTerm) {
|
||||||
|
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
|
||||||
|
if (item.getAgencyId()!=null &&item.getAgencyId().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<Dataset>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE.getDatasets(new AsyncCallback<ArrayList<Dataset>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ArrayList<Dataset> result) {
|
||||||
|
Log.trace("loaded "+result.size()+" datasets");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<Dataset>(result));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerRegistration addSelectionHandler(SelectionHandler<Dataset> handler) {
|
||||||
|
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Dataset> getSelectedItems() {
|
||||||
|
return grid.getSelectionModel().getSelectedItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||||
|
|
||||||
|
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||||
|
super(keyProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyFilters()
|
||||||
|
{
|
||||||
|
super.applyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Agencies;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXAgenciesSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
protected SDMXAgenciesSelectionCard thisCard;
|
||||||
|
protected SDMXExportSession exportSession;
|
||||||
|
protected AgenciesSelectionPanel agenciesSelectionPanel;
|
||||||
|
protected Agencies selectedAgencies=null;
|
||||||
|
|
||||||
|
public SDMXAgenciesSelectionCard(final SDMXExportSession exportSession) {
|
||||||
|
super("SDMX Agencies selection", "");
|
||||||
|
|
||||||
|
this.exportSession = exportSession;
|
||||||
|
thisCard=this;
|
||||||
|
|
||||||
|
this.agenciesSelectionPanel=new AgenciesSelectionPanel(res);
|
||||||
|
|
||||||
|
agenciesSelectionPanel.addSelectionHandler(new SelectionHandler<Agencies>(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Agencies> event) {
|
||||||
|
exportSession.setAgency(agenciesSelectionPanel.getSelectedItem());
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
setContent(agenciesSelectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(){
|
||||||
|
/*Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
|
||||||
|
importSession);
|
||||||
|
getWizardWindow()
|
||||||
|
.addCard(sdmxTableDetailCard);
|
||||||
|
Log.info("NextCard SDMXTableDetailCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXCodelistSelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.Agencies;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.SDMXExportSession;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.user.client.ui.HasValue;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXAgencyTypeCard extends WizardCard {
|
||||||
|
|
||||||
|
protected final SDMXExportSession exportSession;
|
||||||
|
|
||||||
|
protected Agencies agency;
|
||||||
|
|
||||||
|
public SDMXAgencyTypeCard(final SDMXExportSession exportSession) {
|
||||||
|
super("SDMX agency type", "");
|
||||||
|
|
||||||
|
this.exportSession = exportSession;
|
||||||
|
|
||||||
|
agency = new Agencies();
|
||||||
|
//agency.setNewAgency(false);
|
||||||
|
exportSession.setAgency(agency);
|
||||||
|
|
||||||
|
VerticalPanel selectionPanel = new VerticalPanel();
|
||||||
|
selectionPanel.setStylePrimaryName(res.sdmxExportCss()
|
||||||
|
.getExportSelectionSources());
|
||||||
|
|
||||||
|
Radio radioSDMXAgencyPresent = new Radio();
|
||||||
|
|
||||||
|
radioSDMXAgencyPresent
|
||||||
|
.setBoxLabel("<p style='display:inline-table;'><b>Agencies Present</b><br>Select from the agencies already present in the registry</p>");
|
||||||
|
radioSDMXAgencyPresent.setValue(true);
|
||||||
|
radioSDMXAgencyPresent.setName("present");
|
||||||
|
radioSDMXAgencyPresent.setStylePrimaryName(res.sdmxExportCss()
|
||||||
|
.getExportSelectionSource());
|
||||||
|
|
||||||
|
Radio radioSDMXAgencyNew = new Radio();
|
||||||
|
radioSDMXAgencyNew
|
||||||
|
.setBoxLabel("<p style='display:inline-table;'><b>New Agencies</b><br>Creates a new agency in the registry</p>");
|
||||||
|
radioSDMXAgencyNew.setName("new");
|
||||||
|
radioSDMXAgencyNew.setStylePrimaryName(res.sdmxExportCss()
|
||||||
|
.getExportSelectionSource());
|
||||||
|
|
||||||
|
selectionPanel.add(radioSDMXAgencyPresent);
|
||||||
|
selectionPanel.add(radioSDMXAgencyNew);
|
||||||
|
|
||||||
|
// we can set name on radios or use toggle group
|
||||||
|
ToggleGroup toggle = new ToggleGroup();
|
||||||
|
toggle.add(radioSDMXAgencyPresent);
|
||||||
|
toggle.add(radioSDMXAgencyNew);
|
||||||
|
|
||||||
|
toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
|
||||||
|
try {
|
||||||
|
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||||
|
Radio radio = (Radio) group.getValue();
|
||||||
|
Log.info("Agency type: " + radio.getName());
|
||||||
|
if (radio.getName().compareTo("present") == 0) {
|
||||||
|
//exportSession.getAgency().setNewAgency(false);
|
||||||
|
} else {
|
||||||
|
if (radio.getName().compareTo("new") == 0) {
|
||||||
|
//exportSession.getAgency().setNewAgency(true);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("ToggleGroup: onValueChange "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setContent(selectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
/*Log.info("Agency New: "+exportSession.getAgency().isNewAgency());
|
||||||
|
if (exportSession.getAgency().isNewAgency()) {
|
||||||
|
} else {
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
SDMXAgenciesSelectionCard sdmxAgenciesSelectionCard = new SDMXAgenciesSelectionCard(
|
||||||
|
exportSession);
|
||||||
|
getWizardWindow().addCard(sdmxAgenciesSelectionCard);
|
||||||
|
Log.info("NextCard SDMXAgenciesSelectionCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.Codelist;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.SDMXExportSession;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXCodelistSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
protected SDMXCodelistSelectionCard thisCard;
|
||||||
|
protected SDMXExportSession importSession;
|
||||||
|
protected CodelistSelectionPanel codelistSelectionPanel;
|
||||||
|
protected Codelist selectedCodelist=null;
|
||||||
|
public SDMXCodelistSelectionCard(final SDMXExportSession importSession) {
|
||||||
|
super("SDMX Codelist selection", "");
|
||||||
|
|
||||||
|
this.importSession = importSession;
|
||||||
|
thisCard=this;
|
||||||
|
|
||||||
|
this.codelistSelectionPanel=new CodelistSelectionPanel(res);
|
||||||
|
|
||||||
|
codelistSelectionPanel.addSelectionHandler(new SelectionHandler<Codelist>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Codelist> event) {
|
||||||
|
importSession.setSelectedCodelist(codelistSelectionPanel.getSelectedItem());
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
setContent(codelistSelectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(){
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
|
||||||
|
importSession);
|
||||||
|
getWizardWindow()
|
||||||
|
.addCard(sdmxTableDetailCard);
|
||||||
|
Log.info("NextCard SDMXTableDetailCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXCodelistSelectionCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.SDMXExportSession;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXDatasetSelectionCard extends WizardCard {
|
||||||
|
|
||||||
|
protected SDMXDatasetSelectionCard thisCard;
|
||||||
|
protected SDMXExportSession importSession;
|
||||||
|
protected DatasetSelectionPanel datasetSelectionPanel;
|
||||||
|
|
||||||
|
public SDMXDatasetSelectionCard(final SDMXExportSession importSession) {
|
||||||
|
super("SDMX Dataset selection", "");
|
||||||
|
|
||||||
|
this.importSession = importSession;
|
||||||
|
|
||||||
|
thisCard=this;
|
||||||
|
|
||||||
|
this.datasetSelectionPanel=new DatasetSelectionPanel();
|
||||||
|
|
||||||
|
setContent(datasetSelectionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(){
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXDatasetSelectionCard");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.rpc.SDMXExportWizardServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.SDMXExportSession;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXExportWizardTD extends WizardWindow {
|
||||||
|
|
||||||
|
protected SDMXExportSession exportSession;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the {@link CSVTarget} to use.
|
||||||
|
* @param targetId
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
public SDMXExportWizardTD(String title) {
|
||||||
|
super(title);
|
||||||
|
setWidth(550);
|
||||||
|
setHeight(520);
|
||||||
|
|
||||||
|
exportSession= new SDMXExportSession();
|
||||||
|
|
||||||
|
SDMXExportWizardServiceAsync.INSTANCE.setSDMXSession(exportSession,new AsyncCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object result) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SDMXAgencyTypeCard sdmxAgencyType= new SDMXAgencyTypeCard(exportSession);
|
||||||
|
addCard(sdmxAgencyType);
|
||||||
|
|
||||||
|
SDMXAgenciesSelectionCard sdmxAgenciesSelection= new SDMXAgenciesSelectionCard(exportSession);
|
||||||
|
addCard(sdmxAgenciesSelection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXExportWizardTDEntry implements EntryPoint {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onModuleLoad() {
|
||||||
|
SDMXExportWizardTD exportWizard= new SDMXExportWizardTD("SDMXExport");
|
||||||
|
Log.info(exportWizard.getId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.ImportProgressBarUpdater;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.OperationProgressListener;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.progress.OperationProgressUpdater;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.rpc.SDMXExportWizardServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.SDMXExportSession;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
||||||
|
|
||||||
|
//import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
//import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXOperationInProgressCard extends WizardCard
|
||||||
|
implements OperationProgressListener {
|
||||||
|
|
||||||
|
public static final int STATUS_POLLING_DELAY = 1000;
|
||||||
|
protected SDMXOperationInProgressCard thisCard;
|
||||||
|
protected SDMXExportSession importSession;
|
||||||
|
protected OperationProgressUpdater progressUpdater;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SDMXOperationInProgressCard(final SDMXExportSession importSession) {
|
||||||
|
super("Operation In Progress", "");
|
||||||
|
|
||||||
|
this.importSession = importSession;
|
||||||
|
thisCard=this;
|
||||||
|
|
||||||
|
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
||||||
|
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
||||||
|
|
||||||
|
final FlexTable description = new FlexTable();
|
||||||
|
//FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||||
|
description.setCellSpacing(10);
|
||||||
|
description.setCellPadding(4);
|
||||||
|
description.setBorderWidth(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FramedPanel summary = new FramedPanel();
|
||||||
|
summary.setHeadingText("Import Summary");
|
||||||
|
summary.setWidth(400);
|
||||||
|
summary.add(description);
|
||||||
|
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,5,10,5)));
|
||||||
|
|
||||||
|
ProgressBar progressBar = new ProgressBar();
|
||||||
|
operationInProgressPanel.add(progressBar, new BoxLayoutData(new Margins(10,5,10,5)));
|
||||||
|
|
||||||
|
progressUpdater = new OperationProgressUpdater();
|
||||||
|
progressUpdater.addListener(new ImportProgressBarUpdater(progressBar));
|
||||||
|
|
||||||
|
progressUpdater.addListener(this);
|
||||||
|
|
||||||
|
setContent(operationInProgressPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void exportSDMX()
|
||||||
|
{
|
||||||
|
SDMXExportWizardServiceAsync.INSTANCE.exportSDMXClientLibraryRequest(importSession, new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
showErrorAndHide("Error in exportSDMX", "An error occured in exportSDMX", "", caught);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(){
|
||||||
|
getWizardWindow().setEnableBackButton(false);
|
||||||
|
setBackButtonVisible(false);
|
||||||
|
setNextButtonVisible(false);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
getWizardWindow().setNextButtonToFinish();
|
||||||
|
exportSDMX();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationInitializing() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(final TRId trId){
|
||||||
|
// final String tableId,final String tableResourceId) {
|
||||||
|
|
||||||
|
Command sayComplete = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().close(false);
|
||||||
|
Log.info("fire Complete: tabular resource "+trId.getId());
|
||||||
|
Log.info("fire Complete: tableId "+trId.getTableId());
|
||||||
|
|
||||||
|
getWizardWindow().fireCompleted(trId);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||||
|
|
||||||
|
setNextButtonVisible(true);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationFailed(Throwable caught, String reason,
|
||||||
|
String failureDetails) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,317 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.rpc.SDMXExportWizardServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.Agencies;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.SDMXExportSession;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.TableDetail;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.user.client.Command;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.HasValue;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||||
|
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||||
|
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||||
|
import com.sencha.gxt.data.shared.LabelProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ListStore;
|
||||||
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||||
|
import com.sencha.gxt.data.shared.loader.PagingLoadConfig;
|
||||||
|
import com.sencha.gxt.data.shared.loader.PagingLoadResult;
|
||||||
|
import com.sencha.gxt.data.shared.loader.PagingLoadResultBean;
|
||||||
|
import com.sencha.gxt.data.shared.loader.PagingLoader;
|
||||||
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
|
||||||
|
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.form.ComboBox;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
|
import com.sencha.gxt.widget.core.client.info.Info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SDMXTableDetailCard extends WizardCard {
|
||||||
|
|
||||||
|
protected SDMXExportSession importSession;
|
||||||
|
protected SDMXTableDetailCard thisCard;
|
||||||
|
|
||||||
|
protected static final AgenciesProperties agenciesProperties = GWT.create(AgenciesProperties.class);
|
||||||
|
protected VerticalLayoutContainer p = new VerticalLayoutContainer();
|
||||||
|
//private final ComboBox<String> combo2;
|
||||||
|
protected VerticalPanel tableDetailPanel;
|
||||||
|
|
||||||
|
//private static TextField agencyName=null;
|
||||||
|
|
||||||
|
protected TextField name;
|
||||||
|
protected TextArea description;
|
||||||
|
protected TextField right;
|
||||||
|
protected ComboBox<Agencies> combo=null;
|
||||||
|
|
||||||
|
TableDetail detail=new TableDetail();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SDMXTableDetailCard(final SDMXExportSession importSession) {
|
||||||
|
super("SDMX Table Detail", "");
|
||||||
|
|
||||||
|
this.importSession = importSession;
|
||||||
|
thisCard=this;
|
||||||
|
|
||||||
|
|
||||||
|
tableDetailPanel = new VerticalPanel();
|
||||||
|
|
||||||
|
tableDetailPanel.setSpacing(4);
|
||||||
|
tableDetailPanel.setWidth("100%");
|
||||||
|
tableDetailPanel.setHeight("100%");
|
||||||
|
|
||||||
|
|
||||||
|
FramedPanel form2 = new FramedPanel();
|
||||||
|
form2.setHeadingText("Details");
|
||||||
|
//form2.setWidth(350);
|
||||||
|
|
||||||
|
FieldSet fieldSet = new FieldSet();
|
||||||
|
fieldSet.setHeadingText("Information");
|
||||||
|
fieldSet.setCollapsible(true);
|
||||||
|
form2.add(fieldSet);
|
||||||
|
|
||||||
|
//VerticalLayoutContainer p = new VerticalLayoutContainer();
|
||||||
|
fieldSet.add(p);
|
||||||
|
|
||||||
|
name = new TextField();
|
||||||
|
name.setAllowBlank(false);
|
||||||
|
name.setEmptyText("Enter a name...");
|
||||||
|
name.setValue(importSession.getSelectedCodelist().getName());
|
||||||
|
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
|
||||||
|
description = new TextArea();
|
||||||
|
description.setAllowBlank(false);
|
||||||
|
description.setEmptyText("Enter a description...");
|
||||||
|
description.setValue(importSession.getSelectedCodelist().getDescription());
|
||||||
|
p.add(new FieldLabel(description, "Description"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
right = new TextField();
|
||||||
|
right.setEmptyText("Enter right...");
|
||||||
|
right.setAllowBlank(false);
|
||||||
|
p.add(new FieldLabel(right, "Right"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
|
||||||
|
ListStore<Agencies> agenciesStore = new ListStore<Agencies>(agenciesProperties.key());
|
||||||
|
|
||||||
|
RpcProxy<PagingLoadConfig, PagingLoadResult<Agencies>> proxy = new RpcProxy<PagingLoadConfig, PagingLoadResult<Agencies>>() {
|
||||||
|
|
||||||
|
|
||||||
|
public void load(PagingLoadConfig loadConfig, final AsyncCallback<PagingLoadResult<Agencies>> callback) {
|
||||||
|
loadData(loadConfig, callback);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
final PagingLoader<PagingLoadConfig, PagingLoadResult<Agencies>> loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<Agencies>>(proxy);
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<PagingLoadConfig, Agencies, PagingLoadResult<Agencies>>(agenciesStore));
|
||||||
|
|
||||||
|
//agenciesStore.addAll(TestData.getStates());
|
||||||
|
|
||||||
|
combo = new ComboBox<Agencies>(agenciesStore, agenciesProperties.nameLabel());
|
||||||
|
addHandlersForEventObservation(combo, agenciesProperties.nameLabel());
|
||||||
|
|
||||||
|
combo.setLoader(loader);
|
||||||
|
combo.setEmptyText("Enter Agency...");
|
||||||
|
combo.setTriggerAction(TriggerAction.ALL);
|
||||||
|
combo.setAllowBlank(false);
|
||||||
|
combo.setForceSelection(true);
|
||||||
|
combo.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//HorizontalLayoutContainer agenciesSelect= selectAgencies();
|
||||||
|
p.add(new FieldLabel(combo, "Agencies"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
/*FieldLabel comboLabel=new FieldLabel(combo, "");
|
||||||
|
comboLabel.setLabelSeparator("");
|
||||||
|
p.add(comboLabel, new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
|
||||||
|
agencyName = new TextField();
|
||||||
|
agencyName.setVisible(false);
|
||||||
|
agencyName.setEmptyText("Enter Agency...");
|
||||||
|
FieldLabel agencyNameLabel=new FieldLabel(agencyName, "");
|
||||||
|
agencyNameLabel.setLabelSeparator("");
|
||||||
|
p.add(agencyNameLabel, new VerticalLayoutData(1, -1));
|
||||||
|
*/
|
||||||
|
tableDetailPanel.add(form2);
|
||||||
|
|
||||||
|
setContent(tableDetailPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void loadData(PagingLoadConfig loadConfig, final AsyncCallback<PagingLoadResult<Agencies>> callback) {
|
||||||
|
SDMXExportWizardServiceAsync.INSTANCE.getAgencies(new AsyncCallback<List<Agencies>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<Agencies> result) {
|
||||||
|
Log.trace("loaded "+result.size()+" agencies");
|
||||||
|
for(int i=0; i<result.size(); i++){
|
||||||
|
Agencies ag=result.get(i);
|
||||||
|
//if(ag.getId().compareTo())
|
||||||
|
}
|
||||||
|
|
||||||
|
callback.onSuccess(new PagingLoadResultBean<Agencies>(result, result.size(), 0));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to add handlers to observe events that occur on each combobox
|
||||||
|
*/
|
||||||
|
private <T> void addHandlersForEventObservation(final ComboBox<T> combo, final LabelProvider<T> labelProvider) {
|
||||||
|
combo.addValueChangeHandler(new ValueChangeHandler<T>() {
|
||||||
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<T> event) {
|
||||||
|
|
||||||
|
Info.display("Value Changed", "New value: "
|
||||||
|
+ (event.getValue() == null ? combo.getValue() : labelProvider.getLabel(event.getValue()) + "!"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
combo.addSelectionHandler(new SelectionHandler<T>() {
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<T> event) {
|
||||||
|
Info.display("Agency Selected", "You selected "
|
||||||
|
+ (event.getSelectedItem() == null ? combo.getValue() : labelProvider.getLabel(event.getSelectedItem()) + "!"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup(){
|
||||||
|
Command sayNextCard = new Command() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
detail.setName(name.getCurrentValue());
|
||||||
|
detail.setAgency(combo.getSelectedText());
|
||||||
|
detail.setDescription(description.getCurrentValue());
|
||||||
|
detail.setRight(right.getCurrentValue());
|
||||||
|
|
||||||
|
importSession.setTableDetail(detail);
|
||||||
|
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
|
||||||
|
importSession);
|
||||||
|
getWizardWindow()
|
||||||
|
.addCard(sdmxOperationInProgressCard);
|
||||||
|
Log.info("NextCard SDMXOperationInProgressCard");
|
||||||
|
getWizardWindow().nextCard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||||
|
|
||||||
|
|
||||||
|
Command sayPreviousCard = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().previousCard();
|
||||||
|
getWizardWindow().removeCard(thisCard);
|
||||||
|
Log.info("Remove SDMXTableDetailCard");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
|
getWizardWindow().setEnableNextButton(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private HorizontalLayoutContainer selectAgencies(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HorizontalLayoutContainer documentSelectionPanel = new HorizontalLayoutContainer();
|
||||||
|
|
||||||
|
Radio radioAgenciesAlready = new Radio();
|
||||||
|
|
||||||
|
radioAgenciesAlready.setBoxLabel("Present");
|
||||||
|
radioAgenciesAlready.setValue(true);
|
||||||
|
radioAgenciesAlready.setName("Agencies");
|
||||||
|
|
||||||
|
Radio radioAgencyNew = new Radio();
|
||||||
|
radioAgencyNew.setBoxLabel("New");
|
||||||
|
radioAgencyNew.setName("AgencyNew");
|
||||||
|
|
||||||
|
|
||||||
|
documentSelectionPanel.add(radioAgenciesAlready);
|
||||||
|
documentSelectionPanel.add(radioAgencyNew);
|
||||||
|
|
||||||
|
|
||||||
|
// we can set name on radios or use toggle group
|
||||||
|
ToggleGroup toggle = new ToggleGroup();
|
||||||
|
toggle.add(radioAgenciesAlready);
|
||||||
|
toggle.add(radioAgencyNew);
|
||||||
|
|
||||||
|
toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
|
||||||
|
try {
|
||||||
|
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||||
|
Radio radio = (Radio) group.getValue();
|
||||||
|
Log.info("Document Selected:" + radio.getName());
|
||||||
|
if (radio.getName().compareTo("AgencyNew") == 0) {
|
||||||
|
/*agencyName.setVisible(true);
|
||||||
|
combo.setVisible(false);
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
if (radio.getName().compareTo("Agency") == 0) {
|
||||||
|
/*agencyName.setVisible(false);
|
||||||
|
combo.setVisible(true);
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.error("ToggleGroup: onValueChange " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return documentSelectionPanel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a {@link ProgressBar} progress and text based on {@link OperationProgressListener} events.
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ImportProgressBarUpdater implements OperationProgressListener {
|
||||||
|
|
||||||
|
protected ProgressBar progressBar;
|
||||||
|
//protected FramedPanel operationResult;
|
||||||
|
//protected WizardWindow wizardWindow;
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ProgressBar} updater.
|
||||||
|
* @param progressBar the {@link ProgressBar} to update.
|
||||||
|
*/
|
||||||
|
public ImportProgressBarUpdater(ProgressBar progressBar) {
|
||||||
|
this.progressBar = progressBar;
|
||||||
|
//this.wizardWindow = w;
|
||||||
|
//this.operationResult = operationResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void operationComplete(TRId trId) {// TODO Auto-generated method stub
|
||||||
|
Log.info("Import complete");
|
||||||
|
progressBar.updateProgress(1, "Import complete.");
|
||||||
|
/*final FlexTable descriptionResult = new FlexTable();
|
||||||
|
descriptionResult.setCellSpacing(10);
|
||||||
|
descriptionResult.setCellPadding(4);
|
||||||
|
descriptionResult.setBorderWidth(0);
|
||||||
|
descriptionResult.setText(0, 0, "Result: ");
|
||||||
|
descriptionResult.setText(0, 1, "Import complete");
|
||||||
|
|
||||||
|
operationResult.add(descriptionResult);
|
||||||
|
operationResult.setVisible(true);
|
||||||
|
*/
|
||||||
|
//wizardWindow.setEnableNextButton(true);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||||
|
Log.info("Import failed");
|
||||||
|
progressBar.updateText("Import failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationInitializing() {
|
||||||
|
Log.info("Inport inizializing");
|
||||||
|
progressBar.updateProgress(0, "initializing...");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
Log.info("Import elaborated: "+elaborated);
|
||||||
|
if (elaborated == 0) progressBar.updateProgress(0, "initializing...");
|
||||||
|
if (elaborated>0 && elaborated<1) {
|
||||||
|
Log.trace("progress "+elaborated);
|
||||||
|
int elab=new Float(elaborated*100).intValue();
|
||||||
|
progressBar.updateProgress(elaborated,elab+"% importing...");
|
||||||
|
}
|
||||||
|
if (elaborated == 1) progressBar.updateProgress(1, "completing...");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a listener for operation progress.
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface OperationProgressListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is starting.
|
||||||
|
*/
|
||||||
|
public void operationInitializing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is a progress for the operation.
|
||||||
|
* @param elaborated the elaborated part.
|
||||||
|
*/
|
||||||
|
public void operationUpdate(float elaborated);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is complete.
|
||||||
|
*/
|
||||||
|
public void operationComplete(TRId trId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the operation is failed.
|
||||||
|
* @param caught the failure exception.
|
||||||
|
* @param reason the failure reason.
|
||||||
|
*/
|
||||||
|
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.sdmxexportwidget.client.progress;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gxtservice.shared.TRId;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.client.rpc.SDMXExportWizardServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.sdmxexportwidget.shared.ExportMonitor;
|
||||||
|
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link Timer} retrieves {@link OperationProgress} from the specified {@link OperationProgressSource} with the scheduled interval.
|
||||||
|
* The retrieved information are spread to the subscribed {@link OperationProgressListener}.
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OperationProgressUpdater extends Timer {
|
||||||
|
|
||||||
|
protected ArrayList<OperationProgressListener> listeners = new ArrayList<OperationProgressListener>();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.debug("requesting operation progress");
|
||||||
|
SDMXExportWizardServiceAsync.INSTANCE.getExportMonitor(new AsyncCallback<ExportMonitor>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
cancel();
|
||||||
|
Log.error("Error retrieving the operation state", caught);
|
||||||
|
String message = getStack(caught);
|
||||||
|
fireOperationFailed(caught, "Failed getting operation updates", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ExportMonitor result) {
|
||||||
|
Log.info("retrieved ImportMonitor: "+result.getStatus());
|
||||||
|
switch (result.getStatus()) {
|
||||||
|
case WAITING:
|
||||||
|
break;
|
||||||
|
case INITIALIZING:
|
||||||
|
fireOperationInitializing();
|
||||||
|
break;
|
||||||
|
case IN_PROGRESS:
|
||||||
|
fireOperationUpdate(result.getProgress());
|
||||||
|
break;
|
||||||
|
case FAILED:
|
||||||
|
cancel();
|
||||||
|
fireOperationFailed(result.getError(),"Failed Client Library Import", result.getStatusDescription());
|
||||||
|
break;
|
||||||
|
case SUCCEDED:
|
||||||
|
cancel();
|
||||||
|
Log.info("Import fisnish TableId :"+result.getTrId());
|
||||||
|
fireOperationComplete(result.getTrId());
|
||||||
|
break;
|
||||||
|
case ABORTED:
|
||||||
|
cancel();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getStack(Throwable e)
|
||||||
|
{
|
||||||
|
String message = e.getLocalizedMessage()+" -> <br>";
|
||||||
|
Throwable c = e.getCause();
|
||||||
|
if (c!=null) message += getStack(c);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationInitializing()
|
||||||
|
{
|
||||||
|
for (OperationProgressListener listener:listeners) listener.operationInitializing();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationUpdate(float elaborated)
|
||||||
|
{
|
||||||
|
for (OperationProgressListener listener:listeners) listener.operationUpdate(elaborated);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationComplete(TRId trId)
|
||||||
|
{
|
||||||
|
for (OperationProgressListener listener:listeners) listener.operationComplete(trId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationFailed(Throwable caught, String failure, String failureDetails)
|
||||||
|
{
|
||||||
|
for (OperationProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new {@link OperationProgressListener} to this {@link OperationProgressUpdater}.
|
||||||
|
* @param listener the listener to add.
|
||||||
|
*/
|
||||||
|
public void addListener(OperationProgressListener listener)
|
||||||
|
{
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the specified {@link OperationProgressListener} from this {@link OperationProgressUpdater}.
|
||||||
|
* @param listener the listener to remove.
|
||||||
|
*/
|
||||||
|
public void removeListener(OperationProgressListener listener)
|
||||||
|
{
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue