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:
Giancarlo Panichi 2015-06-25 16:31:43 +00:00 committed by Giancarlo Panichi
parent 298766a17e
commit 4c560d8e6b
4 changed files with 182 additions and 147 deletions

View File

@ -53,90 +53,100 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class CodelistSelectionPanel extends ContentPanel implements HasSelectionHandlers<Codelist> { public class CodelistSelectionPanel extends ContentPanel implements
HasSelectionHandlers<Codelist> {
private static final CodelistProperties properties = GWT.create(CodelistProperties.class); 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> nameColumn = new ColumnConfig<Codelist, String>(
protected static final ColumnConfig<Codelist, String> versionColumn = new ColumnConfig<Codelist, String>(properties.version(), 50, "Version"); properties.name(), 50, "Name");
protected static final ColumnConfig<Codelist, String> descriptionColumn = new ColumnConfig<Codelist, String>(properties.description(), 50, "Description"); 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 Grid<Codelist> grid;
protected ResourceBundle res; protected ResourceBundle res;
private WizardCard parent; private WizardCard parent;
public CodelistSelectionPanel(WizardCard parent, ResourceBundle res) {
public CodelistSelectionPanel(WizardCard parent,ResourceBundle res) this.parent = parent;
{ this.res = res;
this.parent=parent;
this.res=res;
setHeaderVisible(false); setHeaderVisible(false);
//new Resizable(this, Dir.E, Dir.SE, Dir.S); buildPanel(properties.key(), Arrays.<ColumnConfig<Codelist, ?>> asList(
buildPanel(properties.key(), Arrays.<ColumnConfig<Codelist, ?>>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn); 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 toolBar = new ToolBar();
toolBar.add(new LabelToolItem("Search: ")); toolBar.add(new LabelToolItem("Search: "));
final TextField searchField = new TextField(); final TextField searchField = new TextField();
toolBar.add(searchField); toolBar.add(searchField);
TextButton btnReload = new TextButton(); TextButton btnReload = new TextButton();
//btnReload.setText("Reload"); // btnReload.setText("Reload");
btnReload.setIcon(res.refresh16()); btnReload.setIcon(res.refresh16());
btnReload.setToolTip("Reload"); btnReload.setToolTip("Reload");
toolBar.add(btnReload); toolBar.add(btnReload);
IdentityValueProvider<Codelist> identity = new IdentityValueProvider<Codelist>(); 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); 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() { searchField.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) { public void onKeyUp(KeyUpEvent event) {
Log.trace("searchTerm: "+searchField.getCurrentValue()); Log.trace("searchTerm: " + searchField.getCurrentValue());
store.applyFilters(); store.applyFilters();
} }
}); });
store.addFilter(new StoreFilter<Codelist>() { 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(); String searchTerm = searchField.getCurrentValue();
if (searchTerm == null) return true; if (searchTerm == null)
return true;
return CodelistSelectionPanel.this.select(item, searchTerm); return CodelistSelectionPanel.this.select(item, searchTerm);
} }
}); });
store.setEnableFilters(true); 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,
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Codelist>> callback) { final AsyncCallback<ListLoadResult<Codelist>> callback) {
loadData(loadConfig, 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.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 @Override
protected void onAfterFirstAttach() { protected void onAfterFirstAttach() {
super.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.setLoader(loader);
grid.setSelectionModel(sm); grid.setSelectionModel(sm);
grid.getView().setAutoExpandColumn(autoexpandColumn); grid.getView().setAutoExpandColumn(autoexpandColumn);
@ -158,81 +168,90 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection
grid.setBorders(false); grid.setBorders(false);
grid.setLoadMask(true); grid.setLoadMask(true);
grid.setColumnReordering(true); grid.setColumnReordering(true);
SelectHandler sh = new SelectHandler() { SelectHandler sh = new SelectHandler() {
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
loader.load(); loader.load();
} }
}; };
btnReload.addSelectHandler(sh); btnReload.addSelectHandler(sh);
VerticalLayoutContainer con = new VerticalLayoutContainer(); VerticalLayoutContainer con = new VerticalLayoutContainer();
con.add(toolBar, new VerticalLayoutData(1, -1)); con.add(toolBar, new VerticalLayoutData(1, -1));
con.add(grid, new VerticalLayoutData(1, 1)); con.add(grid, new VerticalLayoutData(1, 1));
setWidget(con); setWidget(con);
} }
protected boolean select(Codelist item, String searchTerm) { protected boolean select(Codelist item, String searchTerm) {
if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true; if (item.getName() != null
if (item.getAgencyId()!=null &&item.getAgencyId().toLowerCase().contains(searchTerm.toLowerCase())) return true; && item.getName().toLowerCase()
if (item.getVersion()!=null && item.getVersion().toLowerCase().contains(searchTerm.toLowerCase())) return true; .contains(searchTerm.toLowerCase()))
if (item.getDescription()!=null && item.getDescription().toLowerCase().contains(searchTerm.toLowerCase())) return true; return true;
if (item.getId()!=null &&item.getId().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; return false;
} }
protected void loadData(ListLoadConfig loadConfig,
protected void loadData(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<Codelist>> callback) { final AsyncCallback<ListLoadResult<Codelist>> callback) {
TDGWTServiceAsync.INSTANCE.getCodelists(new AsyncCallback<ArrayList<Codelist>>() { TDGWTServiceAsync.INSTANCE
.getCodelists(new AsyncCallback<ArrayList<Codelist>>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) { if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus() parent.getEventBus()
.fireEvent( .fireEvent(
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("No codelists retrieved"); Log.error("No codelists retrieved");
} }
callback.onFailure(caught);
}
public void onSuccess(ArrayList<Codelist> result) { callback.onFailure(caught);
Log.trace("loaded "+result.size()+" codelists"); }
callback.onSuccess(new ListLoadResultBean<Codelist>(result));
} public void onSuccess(ArrayList<Codelist> result) {
}); Log.trace("loaded " + result.size() + " codelists");
callback.onSuccess(new ListLoadResultBean<Codelist>(
result));
}
});
} }
public HandlerRegistration addSelectionHandler(
public HandlerRegistration addSelectionHandler(SelectionHandler<Codelist> handler) { SelectionHandler<Codelist> handler) {
return grid.getSelectionModel().addSelectionHandler(handler); return grid.getSelectionModel().addSelectionHandler(handler);
} }
public Codelist getSelectedItem() { public Codelist getSelectedItem() {
return grid.getSelectionModel().getSelectedItem(); return grid.getSelectionModel().getSelectedItem();
} }
protected class ExtendedListStore<M> extends ListStore<M> { protected class ExtendedListStore<M> extends ListStore<M> {
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) { public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
super(keyProvider); super(keyProvider);
} }
public void applyFilters() public void applyFilters() {
{
super.applyFilters(); super.applyFilters();
} }
} }
} }

View File

@ -14,59 +14,61 @@ import com.google.gwt.user.client.Command;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class SDMXCodelistSelectionCard extends WizardCard { public class SDMXCodelistSelectionCard extends WizardCard {
protected SDMXCodelistSelectionCard thisCard; protected SDMXCodelistSelectionCard thisCard;
protected SDMXImportSession importSession; protected SDMXImportSession importSession;
protected CodelistSelectionPanel codelistSelectionPanel; protected CodelistSelectionPanel codelistSelectionPanel;
protected Codelist selectedCodelist=null; protected Codelist selectedCodelist = null;
public SDMXCodelistSelectionCard(final SDMXImportSession importSession) { public SDMXCodelistSelectionCard(final SDMXImportSession importSession) {
super("SDMX Codelist selection", ""); super("SDMX Codelist selection", "");
this.importSession = importSession;
thisCard=this;
this.codelistSelectionPanel=new CodelistSelectionPanel(thisCard,res);
codelistSelectionPanel.addSelectionHandler(new SelectionHandler<Codelist>() {
this.importSession = importSession;
public void onSelection(SelectionEvent<Codelist> event) { thisCard = this;
importSession.setSelectedCodelist(codelistSelectionPanel.getSelectedItem());
getWizardWindow().setEnableNextButton(true); 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); setContent(codelistSelectionPanel);
} }
@Override @Override
public void setup(){ public void setup() {
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard( try {
importSession); SDMXTableDetailCard sdmxTableDetailCard = new SDMXTableDetailCard(
getWizardWindow() importSession);
.addCard(sdmxTableDetailCard); getWizardWindow().addCard(sdmxTableDetailCard);
Log.info("NextCard SDMXTableDetailCard"); Log.info("NextCard SDMXTableDetailCard");
getWizardWindow().nextCard(); getWizardWindow().nextCard();
} catch (Throwable e) {
e.printStackTrace();
}
} }
}; };
getWizardWindow().setNextButtonCommand(sayNextCard); getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() { Command sayPreviousCard = new Command() {
public void execute() { public void execute() {
try { try {
@ -77,10 +79,13 @@ public class SDMXCodelistSelectionCard extends WizardCard {
Log.error("sayPreviousCard :" + e.getLocalizedMessage()); Log.error("sayPreviousCard :" + e.getLocalizedMessage());
} }
} }
}; };
getWizardWindow().setPreviousButtonCommand(sayPreviousCard); getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
setBackButtonVisible(false);
} }
} }

View File

@ -1,44 +1,53 @@
package org.gcube.portlets.user.td.sdmximportwidget.client; 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.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * 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. * The id of the {@link CSVTarget} to use.
*
* @param targetId * @param targetId
*/ */
public SDMXImportWizardTD(String title,EventBus eventBus) { public SDMXImportWizardTD(String title, EventBus eventBus) {
super(title,eventBus); super(title, eventBus);
setWidth(550); setWidth(550);
setHeight(520); 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(); SDMXCodelistSelectionCard sdmxCodelistSelectionCard = new SDMXCodelistSelectionCard(
importSession);
addCard(sdmxCodelistSelectionCard);
SDMXDocumentSelectionCard sdmxdocumentSelection= new SDMXDocumentSelectionCard(importSession); sdmxCodelistSelectionCard.setup();
addCard(sdmxdocumentSelection);
SourceSelectionCard sourceSelection= new SourceSelectionCard(importSession);
addCard(sourceSelection);
} }
} }

View File

@ -256,7 +256,9 @@ public class SDMXTableDetailCard extends WizardCard {
}; };
getWizardWindow().setPreviousButtonCommand(sayPreviousCard); getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setBackButtonVisible(true);
getWizardWindow().setEnableNextButton(true); getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(true);
} }