diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java index d86dbdc..589c76e 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java @@ -53,90 +53,100 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ -public class CodelistSelectionPanel extends ContentPanel implements HasSelectionHandlers { +public class CodelistSelectionPanel extends ContentPanel implements + HasSelectionHandlers { - private static final CodelistProperties properties = GWT.create(CodelistProperties.class); - - protected static final ColumnConfig nameColumn = new ColumnConfig(properties.name(), 50, "Name"); - protected static final ColumnConfig agencyIdColumn = new ColumnConfig(properties.agencyId(), 50, "Agency Id"); - protected static final ColumnConfig versionColumn = new ColumnConfig(properties.version(), 50, "Version"); - protected static final ColumnConfig descriptionColumn = new ColumnConfig(properties.description(), 50, "Description"); + private static final CodelistProperties properties = GWT + .create(CodelistProperties.class); + + protected static final ColumnConfig nameColumn = new ColumnConfig( + properties.name(), 50, "Name"); + protected static final ColumnConfig agencyIdColumn = new ColumnConfig( + properties.agencyId(), 50, "Agency Id"); + protected static final ColumnConfig versionColumn = new ColumnConfig( + properties.version(), 50, "Version"); + protected static final ColumnConfig descriptionColumn = new ColumnConfig( + properties.description(), 50, "Description"); protected Grid 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.>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn); + buildPanel(properties.key(), Arrays.> asList( + nameColumn, agencyIdColumn, versionColumn, descriptionColumn), + nameColumn); } - - - protected void buildPanel(ModelKeyProvider keyProvider, List> columns, ColumnConfig autoexpandColumn) - { + + + protected void buildPanel(ModelKeyProvider keyProvider, + List> columns, + ColumnConfig 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 identity = new IdentityValueProvider(); - final CheckBoxSelectionModel sm = new CheckBoxSelectionModel(identity); - + final CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + identity); + ColumnModel cm = new ColumnModel(columns); - final ExtendedListStore store = new ExtendedListStore(keyProvider); + final ExtendedListStore store = new ExtendedListStore( + 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() { - public boolean select(Store store, Codelist parent, Codelist item) { + public boolean select(Store 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> proxy = new RpcProxy>() { + RpcProxy> proxy = new RpcProxy>() { - - public void load(ListLoadConfig loadConfig, final AsyncCallback> callback) { + public void load(ListLoadConfig loadConfig, + final AsyncCallback> callback) { loadData(loadConfig, callback); - } + } }; - final ListLoader> loader = new ListLoader>(proxy); + final ListLoader> loader = new ListLoader>( + proxy); loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>(store)); + loader.addLoadHandler(new LoadResultListStoreBinding>( + store)); - grid = new Grid(store, cm){ + grid = new Grid(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> callback) { - TDGWTServiceAsync.INSTANCE.getCodelists(new AsyncCallback>() { + protected void loadData(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + TDGWTServiceAsync.INSTANCE + .getCodelists(new AsyncCallback>() { - 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 result) { - Log.trace("loaded "+result.size()+" codelists"); - callback.onSuccess(new ListLoadResultBean(result)); - } - }); + callback.onFailure(caught); + } + + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " codelists"); + callback.onSuccess(new ListLoadResultBean( + result)); + } + }); } - - public HandlerRegistration addSelectionHandler(SelectionHandler handler) { + public HandlerRegistration addSelectionHandler( + SelectionHandler handler) { return grid.getSelectionModel().addSelectionHandler(handler); } - - - public Codelist getSelectedItem() { return grid.getSelectionModel().getSelectedItem(); } - + protected class ExtendedListStore extends ListStore { public ExtendedListStore(ModelKeyProvider keyProvider) { super(keyProvider); } - public void applyFilters() - { + public void applyFilters() { super.applyFilters(); } } - } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java index 8415cc9..b338708 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java @@ -14,59 +14,61 @@ import com.google.gwt.user.client.Command; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ 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() { - - public void onSelection(SelectionEvent event) { - importSession.setSelectedCodelist(codelistSelectionPanel.getSelectedItem()); - getWizardWindow().setEnableNextButton(true); - } - - - }); - + this.importSession = importSession; + thisCard = this; + + this.codelistSelectionPanel = new CodelistSelectionPanel(thisCard, res); + + codelistSelectionPanel + .addSelectionHandler(new SelectionHandler() { + + public void onSelection(SelectionEvent 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); + } } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java index 259f678..6b1c41b 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java @@ -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 onModuleLoad(). */ -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(); } - - + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXTableDetailCard.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXTableDetailCard.java index fc7bde9..2282c7b 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXTableDetailCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXTableDetailCard.java @@ -256,7 +256,9 @@ public class SDMXTableDetailCard extends WizardCard { }; getWizardWindow().setPreviousButtonCommand(sayPreviousCard); + setBackButtonVisible(true); getWizardWindow().setEnableNextButton(true); + getWizardWindow().setEnableBackButton(true); }