Removed behaviors not supported
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-import-widget@115563 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
298766a17e
commit
4c560d8e6b
|
@ -53,90 +53,100 @@ 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 CodelistSelectionPanel extends ContentPanel implements HasSelectionHandlers<Codelist> {
|
||||
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");
|
||||
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;
|
||||
|
||||
private WizardCard parent;
|
||||
|
||||
|
||||
public CodelistSelectionPanel(WizardCard parent,ResourceBundle res)
|
||||
{
|
||||
this.parent=parent;
|
||||
this.res=res;
|
||||
|
||||
public CodelistSelectionPanel(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<Codelist, ?>>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn);
|
||||
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)
|
||||
{
|
||||
|
||||
|
||||
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.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);
|
||||
|
||||
final CheckBoxSelectionModel<Codelist> sm = new CheckBoxSelectionModel<Codelist>(
|
||||
identity);
|
||||
|
||||
ColumnModel<Codelist> cm = new ColumnModel<Codelist>(columns);
|
||||
|
||||
final ExtendedListStore<Codelist> store = new ExtendedListStore<Codelist>(keyProvider);
|
||||
final ExtendedListStore<Codelist> store = new ExtendedListStore<Codelist>(
|
||||
keyProvider);
|
||||
|
||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||
|
||||
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
Log.trace("searchTerm: "+searchField.getCurrentValue());
|
||||
store.applyFilters();
|
||||
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||
store.applyFilters();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
store.addFilter(new StoreFilter<Codelist>() {
|
||||
|
||||
public boolean select(Store<Codelist> store, Codelist parent, Codelist item) {
|
||||
public boolean select(Store<Codelist> store, Codelist parent,
|
||||
Codelist item) {
|
||||
String searchTerm = searchField.getCurrentValue();
|
||||
if (searchTerm == null) return true;
|
||||
if (searchTerm == null)
|
||||
return true;
|
||||
return CodelistSelectionPanel.this.select(item, searchTerm);
|
||||
}
|
||||
});
|
||||
|
||||
store.setEnableFilters(true);
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<Codelist>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Codelist>>() {
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<Codelist>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Codelist>>() {
|
||||
|
||||
|
||||
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Codelist>> callback) {
|
||||
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);
|
||||
final ListLoader<ListLoadConfig, ListLoadResult<Codelist>> loader = new ListLoader<ListLoadConfig, ListLoadResult<Codelist>>(
|
||||
proxy);
|
||||
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Codelist, ListLoadResult<Codelist>>(store));
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Codelist, ListLoadResult<Codelist>>(
|
||||
store));
|
||||
|
||||
grid = new Grid<Codelist>(store, cm){
|
||||
grid = new Grid<Codelist>(store, cm) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
|
@ -147,8 +157,8 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.getView().setAutoExpandColumn(autoexpandColumn);
|
||||
|
@ -158,81 +168,90 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection
|
|||
grid.setBorders(false);
|
||||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(true);
|
||||
|
||||
|
||||
SelectHandler sh = new SelectHandler() {
|
||||
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;
|
||||
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>>() {
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<Codelist>> callback) {
|
||||
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);
|
||||
}
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
parent.getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("No codelists retrieved");
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<Codelist> result) {
|
||||
Log.trace("loaded "+result.size()+" codelists");
|
||||
callback.onSuccess(new ListLoadResultBean<Codelist>(result));
|
||||
}
|
||||
});
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<Codelist> result) {
|
||||
Log.trace("loaded " + result.size() + " codelists");
|
||||
callback.onSuccess(new ListLoadResultBean<Codelist>(
|
||||
result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public HandlerRegistration addSelectionHandler(SelectionHandler<Codelist> handler) {
|
||||
public HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<Codelist> handler) {
|
||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
public void applyFilters() {
|
||||
super.applyFilters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,59 +14,61 @@ import com.google.gwt.user.client.Command;
|
|||
|
||||
/**
|
||||
*
|
||||
* @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 SDMXCodelistSelectionCard extends WizardCard {
|
||||
|
||||
|
||||
protected SDMXCodelistSelectionCard thisCard;
|
||||
protected SDMXImportSession importSession;
|
||||
protected CodelistSelectionPanel codelistSelectionPanel;
|
||||
protected Codelist selectedCodelist=null;
|
||||
protected Codelist selectedCodelist = null;
|
||||
|
||||
public SDMXCodelistSelectionCard(final SDMXImportSession importSession) {
|
||||
super("SDMX Codelist selection", "");
|
||||
|
||||
this.importSession = importSession;
|
||||
thisCard=this;
|
||||
|
||||
this.codelistSelectionPanel=new CodelistSelectionPanel(thisCard,res);
|
||||
|
||||
codelistSelectionPanel.addSelectionHandler(new SelectionHandler<Codelist>() {
|
||||
|
||||
|
||||
public void onSelection(SelectionEvent<Codelist> event) {
|
||||
importSession.setSelectedCodelist(codelistSelectionPanel.getSelectedItem());
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
this.importSession = importSession;
|
||||
thisCard = this;
|
||||
|
||||
this.codelistSelectionPanel = new CodelistSelectionPanel(thisCard, res);
|
||||
|
||||
codelistSelectionPanel
|
||||
.addSelectionHandler(new SelectionHandler<Codelist>() {
|
||||
|
||||
public void onSelection(SelectionEvent<Codelist> event) {
|
||||
importSession
|
||||
.setSelectedCodelist(codelistSelectionPanel
|
||||
.getSelectedItem());
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
setContent(codelistSelectionPanel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
public void setup() {
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
|
||||
importSession);
|
||||
getWizardWindow()
|
||||
.addCard(sdmxTableDetailCard);
|
||||
Log.info("NextCard SDMXTableDetailCard");
|
||||
getWizardWindow().nextCard();
|
||||
|
||||
try {
|
||||
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
|
||||
importSession);
|
||||
getWizardWindow().addCard(sdmxTableDetailCard);
|
||||
Log.info("NextCard SDMXTableDetailCard");
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
|
@ -77,10 +79,13 @@ public class SDMXCodelistSelectionCard extends WizardCard {
|
|||
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
setBackButtonVisible(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,44 +1,53 @@
|
|||
package org.gcube.portlets.user.td.sdmximportwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.document.CodelistDocument;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
||||
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
*/
|
||||
public class SDMXImportWizardTD extends WizardWindow {
|
||||
public class SDMXImportWizardTD extends WizardWindow {
|
||||
|
||||
private SDMXImportSession importSession;
|
||||
|
||||
protected SDMXImportSession importSession;
|
||||
|
||||
|
||||
/**
|
||||
* The id of the {@link CSVTarget} to use.
|
||||
*
|
||||
* @param targetId
|
||||
*/
|
||||
|
||||
public SDMXImportWizardTD(String title,EventBus eventBus) {
|
||||
super(title,eventBus);
|
||||
|
||||
public SDMXImportWizardTD(String title, EventBus eventBus) {
|
||||
super(title, eventBus);
|
||||
setWidth(550);
|
||||
setHeight(520);
|
||||
|
||||
importSession = new SDMXImportSession();
|
||||
|
||||
// For multiple sources
|
||||
/*
|
||||
* SDMXDocumentSelectionCard sdmxdocumentSelection= new
|
||||
* SDMXDocumentSelectionCard(importSession);
|
||||
* addCard(sdmxdocumentSelection);
|
||||
*
|
||||
* SourceSelectionCard sourceSelection= new
|
||||
* SourceSelectionCard(importSession); addCard(sourceSelection);
|
||||
*/
|
||||
|
||||
final SDMXRegistrySource sdmxRegistrySource = SDMXRegistrySource.INSTANCE;
|
||||
importSession.setSource(sdmxRegistrySource);
|
||||
|
||||
final CodelistDocument codelist = CodelistDocument.INSTANCE;
|
||||
importSession.setSDMXDocument(codelist);
|
||||
|
||||
importSession= new SDMXImportSession();
|
||||
|
||||
|
||||
SDMXDocumentSelectionCard sdmxdocumentSelection= new SDMXDocumentSelectionCard(importSession);
|
||||
addCard(sdmxdocumentSelection);
|
||||
|
||||
SourceSelectionCard sourceSelection= new SourceSelectionCard(importSession);
|
||||
addCard(sourceSelection);
|
||||
|
||||
|
||||
SDMXCodelistSelectionCard sdmxCodelistSelectionCard = new SDMXCodelistSelectionCard(
|
||||
importSession);
|
||||
addCard(sdmxCodelistSelectionCard);
|
||||
sdmxCodelistSelectionCard.setup();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -256,7 +256,9 @@ public class SDMXTableDetailCard extends WizardCard {
|
|||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
setBackButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue