diff --git a/UnionWizardTD.launch b/UnionWizardTD.launch new file mode 100644 index 0000000..0aca07c --- /dev/null +++ b/UnionWizardTD.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0a1ff55 --- /dev/null +++ b/pom.xml @@ -0,0 +1,300 @@ + + + + + maven-parent + org.gcube.tools + 1.0.0 + + + + + 4.0.0 + org.gcube.portlets.user + tabular-data-unionwizard-widget + 1.0.0-SNAPSHOT + + tabular-data-unionwizard-widget + tabular-data-unionwizard-widget allows the union of tabular resources + + + https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-unionwizard-widget + + + + + Giancarlo Panichi + g.panichi@isti.cnr.it + CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" + + architect + developer + + + + + + ${project.basedir}/distro + ${project.build.directory}/${project.build.finalName} + 2014-07-04 + templates + distro + config + + + 2.5.1 + + ${env.KEYS} + + UTF-8 + UTF-8 + + + + + localRun + + + org.slf4j + slf4j-api + compile + + + ch.qos.logback + logback-classic + 1.0.1 + runtime + + + + + + + + + com.google.gwt + gwt-servlet + + + com.google.gwt + gwt-user + + + + junit + junit + 4.8.1 + test + + + javax.validation + validation-api + 1.0.0.GA + test + + + javax.validation + validation-api + 1.0.0.GA + sources + test + + + + com.sencha.gxt + gxt + 3.0.1 + + + + + + + org.gcube.portlets.user + tabular-data-gwt-service + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + + + org.gcube.portlets.user + tabular-data-widget-common-event + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + provided + + + + + + org.gcube.portlets.user + tabular-data-wizard-widget + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + provided + + + + + + com.allen-sauer.gwt.log + gwt-log + 3.2.1 + provided + + + + org.slf4j + slf4j-api + + + + + + + + + + ${webappDirectory}/WEB-INF/classes + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + true + + + + + org.apache.maven.surefire + surefire-junit47 + 2.16 + + + + + + + org.codehaus.mojo + gwt-maven-plugin + ${gwtVersion} + + + + resources + + + + + UnionWizardTD.html + ${webappDirectory} + org.gcube.portlets.user.td.unionwizardwidget.UnionWizardTD + + + + + + maven-resources-plugin + 2.6 + + + copy-profile + process-resources + + copy-resources + + + ${configDirectory} + + + ${templatesDirectory} + + profile.xml + + true + + + + + + copy-distro-resources + process-resources + + copy-resources + + + ${distroDirectory} + + + ${templatesDirectory} + + profile.xml + descriptor.xml + + true + + + + + + + + maven-clean-plugin + 2.5 + + + + ${distroDirectory} + + ** + + false + + + ${configDirectory} + + ** + + false + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${templatesDirectory}/descriptor.xml + + + + + servicearchive + package + + single + + + + + + + + + + + + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + + + + diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingCard.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingCard.java new file mode 100644 index 0000000..6881af3 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingCard.java @@ -0,0 +1,102 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession; +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; + +public class ColumnMappingCard extends WizardCard { + protected UnionSession unionSession; + protected ColumnMappingCard thisCard; + protected ColumnMappingPanel columnMappingPanel; + + public ColumnMappingCard(final UnionSession unionSession) { + super("Column Mapping", ""); + Log.debug("ColumnMappingCard"); + this.unionSession = unionSession; + thisCard = this; + + columnMappingPanel = new ColumnMappingPanel(thisCard,res); + + columnMappingPanel + .addSelectionHandler(new SelectionHandler() { + + public void onSelection(SelectionEvent event) { + /*codelistMappingSession.setConnectedTR(tabResourcesSelectionPanel + .getSelectedItem()); + getWizardWindow().setEnableNextButton(true);*/ + } + + }); + + setContent(columnMappingPanel); + + } + + @Override + public void setup() { + Log.debug("ColumnMappingCard Call Setup "); + Command sayNextCard = new Command() { + + public void execute() { + Log.debug("ColumnMappingCard Call sayNextCard"); + setMapping(); + + } + + }; + + getWizardWindow().setNextButtonCommand(sayNextCard); + + Command sayPreviousCard = new Command() { + public void execute() { + try { + getWizardWindow().previousCard(); + getWizardWindow().removeCard(thisCard); + Log.debug("Remove ColumnMappingCard"); + } catch (Exception e) { + Log.error("sayPreviousCard :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setPreviousButtonCommand(sayPreviousCard); + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(true); + + + + + + } + + protected void setMapping() { + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(false); + + + + } + + + + + + protected void goNext() { + try { + Log.info("NextCard ColumnSelectionCard"); + UnionOperationInProgressCard progressCard = new UnionOperationInProgressCard( + unionSession); + getWizardWindow().addCard( + progressCard); + getWizardWindow().nextCard(); + } catch (Throwable e) { + Log.error("goNext: " + e.getLocalizedMessage()); + } + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java new file mode 100644 index 0000000..540fdaf --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/ColumnMappingPanel.java @@ -0,0 +1,371 @@ +package org.gcube.portlets.user.td.unionwizardwidget.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.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; +import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; +import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +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.SelectionEvent; +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.Dialog.PredefinedButton; +import com.sencha.gxt.widget.core.client.Resizable.Dir; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox; +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.HideEvent; +import com.sencha.gxt.widget.core.client.event.SelectEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; +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.menu.Item; +import com.sencha.gxt.widget.core.client.menu.Menu; +import com.sencha.gxt.widget.core.client.menu.MenuItem; +import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; +import com.sencha.gxt.widget.core.client.toolbar.ToolBar; + +public class ColumnMappingPanel extends ContentPanel implements + HasSelectionHandlers { + + private static final TabResourcesProperties properties = GWT + .create(TabResourcesProperties.class); + + protected static final ColumnConfig nameColumn = new ColumnConfig( + properties.name(), 90, "Name"); + protected static final ColumnConfig typeColumn = new ColumnConfig( + properties.tabularResourceType(), 30, "Type"); + protected static final ColumnConfig agencyColumn = new ColumnConfig( + properties.agency(), 60, "Agency"); + protected static final ColumnConfig ownerColumn = new ColumnConfig( + properties.ownerLogin(), 70, "Owner"); + protected static final ColumnConfig dateColumn = new ColumnConfig( + properties.date(), 40, "Date"); + + protected Grid grid; + protected ResourceBundle res; + protected Menu contextMenu; + + private TabResource removableTR; + + private WizardCard parent; + + public ColumnMappingPanel(WizardCard parent, ResourceBundle res) { + this.res = res; + this.parent = parent; + Log.debug("TabResourcesSelectionPanel"); + init(); + try { + createContextMenu(); + } catch (Throwable e) { + Log.debug("Error In CreateContextMenu:" + e.getMessage()); + e.printStackTrace(); + } + try { + buildPanel(properties.id(), + Arrays.> asList(nameColumn, + typeColumn, ownerColumn, agencyColumn, dateColumn), + nameColumn); + + } catch (Throwable e) { + Log.debug("Error building panel:" + e.getMessage()); + e.printStackTrace(); + } + } + + protected void init() { + setHeaderVisible(false); + new Resizable(this, Dir.E, Dir.SE, Dir.S); + + } + + 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.setIcon(res.refresh16()); + btnReload.setToolTip("Reload"); + toolBar.add(btnReload); + + IdentityValueProvider identity = new IdentityValueProvider(); + final CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + identity); + + ColumnModel cm = new ColumnModel(columns); + + final ExtendedListStore store = new ExtendedListStore( + keyProvider); + + searchField.addKeyUpHandler(new KeyUpHandler() { + + public void onKeyUp(KeyUpEvent event) { + Log.trace("searchTerm: " + searchField.getCurrentValue()); + store.applyFilters(); + } + }); + + store.addFilter(new StoreFilter() { + + public boolean select(Store store, TabResource parent, + TabResource item) { + String searchTerm = searchField.getCurrentValue(); + if (searchTerm == null) + return true; + return ColumnMappingPanel.this.select(item, searchTerm); + } + }); + + store.setEnableFilters(true); + + RpcProxy> proxy = new RpcProxy>() { + + public void load(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + loadData(loadConfig, callback); + } + }; + final ListLoader> loader = new ListLoader>( + proxy); + + loader.setRemoteSort(false); + loader.addLoadHandler(new LoadResultListStoreBinding>( + store)); + + grid = new Grid(store, cm) { + @Override + protected void onAfterFirstAttach() { + super.onAfterFirstAttach(); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + 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() { + public void onSelect(SelectEvent event) { + loader.load(); + } + }; + + btnReload.addSelectHandler(sh); + + if (contextMenu != null) { + grid.setContextMenu(contextMenu); + } else + grid.setContextMenu(null); + + VerticalLayoutContainer con = new VerticalLayoutContainer(); + con.add(toolBar, new VerticalLayoutData(1, -1)); + con.add(grid, new VerticalLayoutData(1, 1)); + setWidget(con); + } + + protected void createContextMenu() { + contextMenu = new Menu(); + MenuItem deleteTRItem = new MenuItem("Delete"); + deleteTRItem.setId("DeleteTR"); + deleteTRItem.setIcon(org.gcube.portlets.user.td.unionwizardwidget.client.dataresource.ResourceBundle.INSTANCE.delete()); + deleteTRItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + if (grid != null) { + TabResource tabResource = getSelectedItem(); + deleteTR(tabResource); + } + + } + }); + contextMenu.add(deleteTRItem); + + } + + protected boolean select(TabResource item, String searchTerm) { + if (item.getName() != null + && item.getName().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getTabularResourceType() != null + && item.getTabularResourceType().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getAgency() != null + && item.getAgency().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getDate() != null + && item.getDate().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getOwnerLogin() != null + && item.getOwnerLogin().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + return false; + } + + protected void loadData(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + TDGWTServiceAsync.INSTANCE + .getTabularResources(new AsyncCallback>() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + parent.getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.debug("Error retrieving tabular resource: " + + caught.getLocalizedMessage()); + + AlertMessageBox d = new AlertMessageBox("Error!", + "Error retrieving tabular resources on server!"); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + // + } + + }); + d.show(); + } + callback.onFailure(caught); + } + + public void onSuccess(ArrayList result) { + Log.debug("loaded " + result.size() + + " TabularResources"); + callback.onSuccess(new ListLoadResultBean( + result)); + } + }); + } + + public HandlerRegistration addSelectionHandler( + SelectionHandler handler) { + return grid.getSelectionModel().addSelectionHandler(handler); + } + + public TabResource getSelectedItem() { + return grid.getSelectionModel().getSelectedItem(); + } + + protected class ExtendedListStore extends ListStore { + + public ExtendedListStore(ModelKeyProvider keyProvider) { + super(keyProvider); + } + + public void applyFilters() { + super.applyFilters(); + } + + } + + public void gridReload() { + grid.getLoader().load(); + } + + protected void deleteTR(TabResource tabResource) { + removableTR = tabResource; + final ConfirmMessageBox mb = new ConfirmMessageBox("Delete", + "Would you like to delete this tabular resource?"); + mb.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES + .name())) { + callDeleteTabularResource(); + } else if (mb.getHideButton() == mb + .getButtonById(PredefinedButton.NO.name())) { + // perform NO action + } + } + }); + mb.setWidth(300); + mb.show(); + + } + + protected void callDeleteTabularResource() { + Log.debug("Delete TR:" + removableTR); + TDGWTServiceAsync.INSTANCE.removeTabularResource(removableTR.getTrId(), + new AsyncCallback() { + + public void onFailure(Throwable caught) { + AlertMessageBox d = new AlertMessageBox("Error", + "Error on delete TabResource: " + + caught.getLocalizedMessage()); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + + + } + }); + d.show(); + + } + + public void onSuccess(Void result) { + gridReload(); + } + + }); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesProperties.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesProperties.java new file mode 100644 index 0000000..4d287f3 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesProperties.java @@ -0,0 +1,27 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; + +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" + * g.panichi@isti.cnr.it + * + */ +public interface TabResourcesProperties extends PropertyAccess { + + @Path("id") + ModelKeyProvider id(); + + ValueProvider name(); + ValueProvider agency(); + ValueProvider date(); + ValueProvider tabularResourceType(); + ValueProvider ownerLogin(); + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionCard.java new file mode 100644 index 0000000..7329ad3 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionCard.java @@ -0,0 +1,196 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession; +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; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox; +import com.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; + +public class TabResourcesSelectionCard extends WizardCard { + protected UnionSession unionSession; + protected TabResourcesSelectionCard thisCard; + protected TabResourcesSelectionPanel tabResourcesSelectionPanel; + protected TabResource selectedTabResource = null; + + public TabResourcesSelectionCard(final UnionSession unionSession) { + super("Select Tabular Resource for Union", ""); + Log.debug("TabResourcesSelectionCard"); + this.unionSession = unionSession; + thisCard = this; + + tabResourcesSelectionPanel = new TabResourcesSelectionPanel(thisCard,res); + + tabResourcesSelectionPanel + .addSelectionHandler(new SelectionHandler() { + + public void onSelection(SelectionEvent event) { + unionSession.setUnionTabularResource(tabResourcesSelectionPanel + .getSelectedItem()); + getWizardWindow().setEnableNextButton(true); + } + + }); + + setContent(tabResourcesSelectionPanel); + + } + + @Override + public void setup() { + Log.debug("TabResourcesSelectionCard Call Setup "); + Command sayNextCard = new Command() { + + public void execute() { + Log.debug("TabResourcesSelectionCard Call sayNextCard"); + retrieveLastTable(); + + } + + }; + + getWizardWindow().setNextButtonCommand(sayNextCard); + + Command sayPreviousCard = new Command() { + public void execute() { + try { + getWizardWindow().previousCard(); + getWizardWindow().removeCard(thisCard); + Log.debug("Remove TabResourcesSelectionCard"); + } catch (Exception e) { + Log.error("sayPreviousCard :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setPreviousButtonCommand(sayPreviousCard); + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(true); + + + + + + } + + protected void retrieveLastTable() { + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(false); + + TDGWTServiceAsync.INSTANCE.getLastTable(unionSession + .getUnionTabularResource().getTrId(), + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + Log.debug("Attention", + "This tabular resource does not have a valid table"); + AlertMessageBox d = new AlertMessageBox("Attention", + "This tabular resource does not have a valid table"); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + deleteTRWithLastTableNull(); + + } + }); + d.show(); + + } + + @Override + public void onSuccess(TableData result) { + Log.debug("Retrieve last table: " + result); + updateConnectedTRInfo(result); + } + + }); + + } + + protected void deleteTRWithLastTableNull() { + final ConfirmMessageBox mb = new ConfirmMessageBox("Delete", + "Would you like to delete this tabular resource without table?"); + mb.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES + .name())) { + callDeleteLastTable(); + + } else if (mb.getHideButton() == mb + .getButtonById(PredefinedButton.NO.name())) { + getWizardWindow().setEnableNextButton(true); + getWizardWindow().setEnableBackButton(true); + } + } + }); + mb.setWidth(300); + mb.show(); + + } + + protected void callDeleteLastTable(){ + Log.debug("Delete TR:" + unionSession.getUnionTabularResource() + .getTrId()); + TDGWTServiceAsync.INSTANCE.removeTabularResource(unionSession.getUnionTabularResource() + .getTrId(), + new AsyncCallback() { + + public void onFailure(Throwable caught) { + AlertMessageBox d = new AlertMessageBox("Error", + "Error on delete TabResource: " + + caught.getLocalizedMessage()); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + getWizardWindow().setEnableNextButton(true); + getWizardWindow().setEnableBackButton(true); + + } + }); + d.show(); + + } + + public void onSuccess(Void result) { + tabResourcesSelectionPanel.gridReload(); + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(true); + } + + }); + } + + + protected void updateConnectedTRInfo(TableData table) { + TabResource tabResource = unionSession.getUnionTabularResource(); + tabResource.setTrId(table.getTrId()); + unionSession.setUnionTabularResource(tabResource); + Log.debug("UnionSession: " + unionSession); + goNext(); + } + + protected void goNext() { + try { + Log.info("NextCard ColumnMappingCard"); + ColumnMappingCard columnSelectionCard = new ColumnMappingCard( + unionSession); + getWizardWindow().addCard( + columnSelectionCard); + getWizardWindow().nextCard(); + } catch (Throwable e) { + Log.error("goNext: " + e.getLocalizedMessage()); + } + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionPanel.java new file mode 100644 index 0000000..3217077 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/TabResourcesSelectionPanel.java @@ -0,0 +1,371 @@ +package org.gcube.portlets.user.td.unionwizardwidget.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.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; +import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; +import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +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.SelectionEvent; +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.Dialog.PredefinedButton; +import com.sencha.gxt.widget.core.client.Resizable.Dir; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox; +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.HideEvent; +import com.sencha.gxt.widget.core.client.event.SelectEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; +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.menu.Item; +import com.sencha.gxt.widget.core.client.menu.Menu; +import com.sencha.gxt.widget.core.client.menu.MenuItem; +import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; +import com.sencha.gxt.widget.core.client.toolbar.ToolBar; + +public class TabResourcesSelectionPanel extends ContentPanel implements + HasSelectionHandlers { + + private static final TabResourcesProperties properties = GWT + .create(TabResourcesProperties.class); + + protected static final ColumnConfig nameColumn = new ColumnConfig( + properties.name(), 90, "Name"); + protected static final ColumnConfig typeColumn = new ColumnConfig( + properties.tabularResourceType(), 30, "Type"); + protected static final ColumnConfig agencyColumn = new ColumnConfig( + properties.agency(), 60, "Agency"); + protected static final ColumnConfig ownerColumn = new ColumnConfig( + properties.ownerLogin(), 70, "Owner"); + protected static final ColumnConfig dateColumn = new ColumnConfig( + properties.date(), 40, "Date"); + + protected Grid grid; + protected ResourceBundle res; + protected Menu contextMenu; + + private TabResource removableTR; + + private WizardCard parent; + + public TabResourcesSelectionPanel(WizardCard parent, ResourceBundle res) { + this.res = res; + this.parent = parent; + Log.debug("TabResourcesSelectionPanel"); + init(); + try { + createContextMenu(); + } catch (Throwable e) { + Log.debug("Error In CreateContextMenu:" + e.getMessage()); + e.printStackTrace(); + } + try { + buildPanel(properties.id(), + Arrays.> asList(nameColumn, + typeColumn, ownerColumn, agencyColumn, dateColumn), + nameColumn); + + } catch (Throwable e) { + Log.debug("Error building panel:" + e.getMessage()); + e.printStackTrace(); + } + } + + protected void init() { + setHeaderVisible(false); + new Resizable(this, Dir.E, Dir.SE, Dir.S); + + } + + 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.setIcon(res.refresh16()); + btnReload.setToolTip("Reload"); + toolBar.add(btnReload); + + IdentityValueProvider identity = new IdentityValueProvider(); + final CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + identity); + + ColumnModel cm = new ColumnModel(columns); + + final ExtendedListStore store = new ExtendedListStore( + keyProvider); + + searchField.addKeyUpHandler(new KeyUpHandler() { + + public void onKeyUp(KeyUpEvent event) { + Log.trace("searchTerm: " + searchField.getCurrentValue()); + store.applyFilters(); + } + }); + + store.addFilter(new StoreFilter() { + + public boolean select(Store store, TabResource parent, + TabResource item) { + String searchTerm = searchField.getCurrentValue(); + if (searchTerm == null) + return true; + return TabResourcesSelectionPanel.this.select(item, searchTerm); + } + }); + + store.setEnableFilters(true); + + RpcProxy> proxy = new RpcProxy>() { + + public void load(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + loadData(loadConfig, callback); + } + }; + final ListLoader> loader = new ListLoader>( + proxy); + + loader.setRemoteSort(false); + loader.addLoadHandler(new LoadResultListStoreBinding>( + store)); + + grid = new Grid(store, cm) { + @Override + protected void onAfterFirstAttach() { + super.onAfterFirstAttach(); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + 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() { + public void onSelect(SelectEvent event) { + loader.load(); + } + }; + + btnReload.addSelectHandler(sh); + + if (contextMenu != null) { + grid.setContextMenu(contextMenu); + } else + grid.setContextMenu(null); + + VerticalLayoutContainer con = new VerticalLayoutContainer(); + con.add(toolBar, new VerticalLayoutData(1, -1)); + con.add(grid, new VerticalLayoutData(1, 1)); + setWidget(con); + } + + protected void createContextMenu() { + contextMenu = new Menu(); + MenuItem deleteTRItem = new MenuItem("Delete"); + deleteTRItem.setId("DeleteTR"); + deleteTRItem.setIcon(org.gcube.portlets.user.td.unionwizardwidget.client.dataresource.ResourceBundle.INSTANCE.delete()); + deleteTRItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + if (grid != null) { + TabResource tabResource = getSelectedItem(); + deleteTR(tabResource); + } + + } + }); + contextMenu.add(deleteTRItem); + + } + + protected boolean select(TabResource item, String searchTerm) { + if (item.getName() != null + && item.getName().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getTabularResourceType() != null + && item.getTabularResourceType().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getAgency() != null + && item.getAgency().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getDate() != null + && item.getDate().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + if (item.getOwnerLogin() != null + && item.getOwnerLogin().toLowerCase() + .contains(searchTerm.toLowerCase())) + return true; + return false; + } + + protected void loadData(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + TDGWTServiceAsync.INSTANCE + .getTabularResources(new AsyncCallback>() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + parent.getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.debug("Error retrieving tabular resource: " + + caught.getLocalizedMessage()); + + AlertMessageBox d = new AlertMessageBox("Error!", + "Error retrieving tabular resources on server!"); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + // + } + + }); + d.show(); + } + callback.onFailure(caught); + } + + public void onSuccess(ArrayList result) { + Log.debug("loaded " + result.size() + + " TabularResources"); + callback.onSuccess(new ListLoadResultBean( + result)); + } + }); + } + + public HandlerRegistration addSelectionHandler( + SelectionHandler handler) { + return grid.getSelectionModel().addSelectionHandler(handler); + } + + public TabResource getSelectedItem() { + return grid.getSelectionModel().getSelectedItem(); + } + + protected class ExtendedListStore extends ListStore { + + public ExtendedListStore(ModelKeyProvider keyProvider) { + super(keyProvider); + } + + public void applyFilters() { + super.applyFilters(); + } + + } + + public void gridReload() { + grid.getLoader().load(); + } + + protected void deleteTR(TabResource tabResource) { + removableTR = tabResource; + final ConfirmMessageBox mb = new ConfirmMessageBox("Delete", + "Would you like to delete this tabular resource?"); + mb.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES + .name())) { + callDeleteTabularResource(); + } else if (mb.getHideButton() == mb + .getButtonById(PredefinedButton.NO.name())) { + // perform NO action + } + } + }); + mb.setWidth(300); + mb.show(); + + } + + protected void callDeleteTabularResource() { + Log.debug("Delete TR:" + removableTR); + TDGWTServiceAsync.INSTANCE.removeTabularResource(removableTR.getTrId(), + new AsyncCallback() { + + public void onFailure(Throwable caught) { + AlertMessageBox d = new AlertMessageBox("Error", + "Error on delete TabResource: " + + caught.getLocalizedMessage()); + d.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + + + } + }); + d.show(); + + } + + public void onSuccess(Void result) { + gridReload(); + } + + }); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java new file mode 100644 index 0000000..167f4b4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionOperationInProgressCard.java @@ -0,0 +1,213 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession; +import org.gcube.portlets.user.td.unionwizardwidget.client.progress.UnionProgressBarUpdater; +import org.gcube.portlets.user.td.unionwizardwidget.client.progress.UnionProgressListener; +import org.gcube.portlets.user.td.unionwizardwidget.client.progress.UnionProgressUpdater; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.Command; +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.box.AlertMessageBox; +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.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; + + + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class UnionOperationInProgressCard extends WizardCard implements + UnionProgressListener { + + public static final int STATUS_POLLING_DELAY = 1000; + protected UnionOperationInProgressCard thisCard; + protected UnionSession unionSession; + protected UnionProgressUpdater progressUpdater; + + public UnionOperationInProgressCard(final UnionSession unionSession) { + super("Operation In Progress", ""); + + this.unionSession = unionSession; + thisCard = this; + + VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer(); + operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); + + final FlexTable description = new FlexTable(); + description.setCellSpacing(10); + description.setCellPadding(4); + description.setBorderWidth(0); + + description.setHTML(0, 0, + "Union with: "); + description.setText(0, 1, unionSession.getUnionTabularResource().getName()); + description.setHTML(1, 0, + "Type: "); + description.setText(1, 1, unionSession.getUnionTabularResource().getTabularResourceType()); + + description.setHTML(2, 0, + "Owner: "); + description.setText(2, 1, unionSession.getUnionTabularResource().getOwnerLogin()); + + FramedPanel summary = new FramedPanel(); + summary.setHeadingText("Union 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 UnionProgressUpdater(); + progressUpdater + .addListener(new UnionProgressBarUpdater(progressBar)); + + progressUpdater.addListener(this); + + setContent(operationInProgressPanel); + + } + + + public void importCodelistMapping() { + /*TDGWTServiceAsync.INSTANCE.startUnion(unionSession, + new AsyncCallback() { + + public void onSuccess(Void result) { + progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY); + } + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + showErrorAndHide( + "Error in import codelist mapping", + "An error occured in import codelist mapping: " + + caught.getLocalizedMessage(), + caught.getStackTrace().toString(), caught); + } + } + }); + */ + } + + @Override + public void setup() { + getWizardWindow().setEnableBackButton(false); + setBackButtonVisible(false); + setNextButtonVisible(false); + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setNextButtonToFinish(); + importCodelistMapping(); + } + + public void operationInitializing() { + + } + + public void operationUpdate(float elaborated) { + + } + + public void operationComplete(final TRId trId) { + + Command sayComplete = new Command() { + public void execute() { + try { + getWizardWindow().close(false); + Log.info("fire Complete: "+ trId); + + getWizardWindow().fireCompleted(trId); + + } catch (Exception e) { + Log.error("fire Complete :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setNextButtonCommand(sayComplete); + + setNextButtonVisible(true); + getWizardWindow().setEnableNextButton(true); + } + + public void operationFailed(Throwable caught, String reason, + String failureDetails) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + AlertMessageBox d = new AlertMessageBox("Error in Codelist Mapping Import", + reason); + d.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + } + }); + d.show(); + } + } + + @Override + public void operationStopped(final TRId trId, String reason, String details) { + + 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 operationGeneratingView() { + // TODO Auto-generated method stub + + } + + @Override + public void operationValidate(float elaborated) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionWizardTD.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionWizardTD.java new file mode 100644 index 0000000..42b21b4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionWizardTD.java @@ -0,0 +1,44 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.web.bindery.event.shared.EventBus; + +/** + * + * @author "Giancarlo Panichi" + * + */ +public class UnionWizardTD extends WizardWindow { + protected static final int WITHWIZARD=720; + protected static final int HEIGHTWIZARD=520; + + protected UnionSession unionSession; + + /** + * The id of the {@link CSVTarget} to use. + * @param targetId + */ + + public UnionWizardTD(TRId trId, String title, EventBus eventBus) { + super(title,eventBus); + Log.debug("UnionWizardTD: "+trId); + setWidth(WITHWIZARD); + setHeight(HEIGHTWIZARD); + + unionSession= new UnionSession(); + unionSession.setTrId(trId); + + TabResourcesSelectionCard tabResourcesSelection= new TabResourcesSelectionCard(unionSession); + addCard(tabResourcesSelection); + tabResourcesSelection.setup(); + + } + + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionWizardTDEntry.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionWizardTDEntry.java new file mode 100644 index 0000000..c0cb6dc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/UnionWizardTDEntry.java @@ -0,0 +1,23 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.EntryPoint; +import com.google.web.bindery.event.shared.SimpleEventBus; + +/** + * + * @author "Giancarlo Panichi" + * email: g.panichi@isti.cnr.it + * + */ +public class UnionWizardTDEntry implements EntryPoint { + + public void onModuleLoad() { + TRId trId=new TRId(); + SimpleEventBus eventBus=new SimpleEventBus(); + UnionWizardTD unionWizard= new UnionWizardTD(trId, "Union",eventBus); + Log.info(unionWizard.getId()); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/ResourceBundle.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/ResourceBundle.java new file mode 100644 index 0000000..42d07cc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/ResourceBundle.java @@ -0,0 +1,44 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client.dataresource; + + + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; + + +public interface ResourceBundle extends ClientBundle { + + public static final ResourceBundle INSTANCE=GWT.create(ResourceBundle.class); + + @Source("resources/UnionWizardTD.css") + UnionCSS unionCss(); + + @Source("resources/arrow-refresh.png") + ImageResource refresh(); + + @Source("resources/arrow-refresh_16.png") + ImageResource refresh_16(); + + @Source("resources/arrow-refresh_32.png") + ImageResource refresh32(); + + @Source("resources/accept.png") + ImageResource csvCheckSuccess(); + + @Source("resources/error.png") + ImageResource csvCheckFailure(); + + @Source("resources/loading.gif") + ImageResource loading(); + + @Source("resources/information.png") + ImageResource information(); + + @Source("resources/delete.png") + ImageResource delete(); + + @Source("resources/delete_32.png") + ImageResource delete32(); +} + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/UnionCSS.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/UnionCSS.java new file mode 100644 index 0000000..a1b2d68 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/UnionCSS.java @@ -0,0 +1,41 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.dataresource; + +import com.google.gwt.resources.client.CssResource; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface UnionCSS extends CssResource { + + @ClassName("wizard-title") + public String getWizardTitle(); + + @ClassName("wizard-footer") + public String getWizardFooter(); + + @ClassName("source-selection-hover") + public String getSourceSelectionHover(); + + @ClassName("column-excluded") + public String getColumnExcluded(); + + @ClassName("importSelection-sources") + public String getImportSelectionSources(); + + @ClassName("importSelection-source") + public String getImportSelectionSource(); + + @ClassName("sdmxRegistryUrlStyle") + public String getSDMXRegistryUrlStyle(); + + @ClassName("sdmxRegistryUrlInputStyle") + public String getSDMXRegistryUrlInputStyle(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/grid/ColumnDataGridPanel.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/grid/ColumnDataGridPanel.java new file mode 100644 index 0000000..40e4244 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/grid/ColumnDataGridPanel.java @@ -0,0 +1,156 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client.grid; + +import java.util.ArrayList; +import java.util.List; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +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.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.core.client.dom.ScrollSupport.ScrollMode; +import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.data.client.loader.RpcProxy; +import com.sencha.gxt.data.shared.ListStore; +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.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +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; + +public class ColumnDataGridPanel extends ContentPanel implements + HasSelectionHandlers { + protected static final int GRIDHEIGHT = 360; + + protected static final ColumnDataProperties props = GWT + .create(ColumnDataProperties.class); + + protected final CheckBoxSelectionModel sm; + + protected final Grid grid; + protected TRId trId; + + public ColumnDataGridPanel(TRId trId) { + Log.debug("ColumnDataGridPanel"); + if(trId==null){ + Log.error("ColumnDataGridPanel: TRId is null"); + } + Log.debug("ColumnDataGridPanel: "+trId.toString()); + this.trId=trId; + setHeaderVisible(false); + //setHeadingText("Columns"); + + ColumnConfig labelCol = new ColumnConfig( + props.label(), 120,"Column"); + + IdentityValueProvider identity = new IdentityValueProvider(); + + sm = new CheckBoxSelectionModel(identity); + + List> l = new ArrayList>(); + + l.add(labelCol); + ColumnModel cm = new ColumnModel(l); + + ListStore store = new ListStore(props.id()); + + RpcProxy> proxy = new RpcProxy>() { + + public void load(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + loadData(loadConfig, callback); + } + }; + final ListLoader> loader = new ListLoader>( + proxy); + + loader.setRemoteSort(false); + loader.addLoadHandler(new LoadResultListStoreBinding>( + store) { + }); + + grid = new Grid(store, cm) { + @Override + protected void onAfterFirstAttach() { + super.onAfterFirstAttach(); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + public void execute() { + loader.load(); + } + }); + } + }; + + sm.setSelectionMode(SelectionMode.SINGLE); + grid.setLoader(loader); + grid.setSelectionModel(sm); + grid.setHeight(GRIDHEIGHT); + 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.setScrollMode(ScrollMode.AUTO); + con.add(grid, new VerticalLayoutData(-1, -1, new Margins(0))); + setWidget(con); + + } + + public Grid getGrid() { + return grid; + } + + protected void loadData(ListLoadConfig loadConfig, + final AsyncCallback> callback) { + TDGWTServiceAsync.INSTANCE + .getColumns(trId, new AsyncCallback>() { + + public void onFailure(Throwable caught) { + Log.error("No load columns: " + + caught.getLocalizedMessage()); + callback.onFailure(caught); + } + + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " columns"); + callback.onSuccess(new ListLoadResultBean( + result)); + sm.selectAll(); + forceLayout(); + } + }); + } + + + + public ColumnData getSelectedItem() { + return grid.getSelectionModel().getSelectedItem(); + + } + + public HandlerRegistration addSelectionHandler( + SelectionHandler handler) { + return grid.getSelectionModel().addSelectionHandler(handler); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/grid/ColumnDataProperties.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/grid/ColumnDataProperties.java new file mode 100644 index 0000000..2c86c30 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/grid/ColumnDataProperties.java @@ -0,0 +1,21 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client.grid; + +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; + +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; + +public interface ColumnDataProperties extends PropertyAccess { + + @Path("id") + ModelKeyProvider id(); + + ValueProvider label(); + + // ValueProvider typeName(); + + // ValueProvider typeCode(); + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressBarUpdater.java new file mode 100644 index 0000000..95fbde8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressBarUpdater.java @@ -0,0 +1,99 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.progress; + + + + +import org.gcube.portlets.user.td.widgetcommonevent.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 UnionProgressListener} events. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class UnionProgressBarUpdater implements UnionProgressListener { + + protected ProgressBar progressBar; + + /** + * Creates a new {@link ProgressBar} updater. + * @param progressBar the {@link ProgressBar} to update. + */ + public UnionProgressBarUpdater(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + + /** + * {@inheritDoc} + */ + @Override + public void operationComplete(TRId trId) { + Log.info("Import completed"); + progressBar.updateProgress(1, "Import completed."); + + } + + /** + * {@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("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..."); + + } + + @Override + public void operationValidate(float elaborated) { + Log.info("Validation Elaborated: "+elaborated); + if (elaborated == 0) progressBar.updateProgress(0, "Start Validation..."); + if (elaborated>0 && elaborated<1) { + Log.trace("Validation progress "+elaborated); + int elab=new Float(elaborated*100).intValue(); + progressBar.updateProgress(elaborated,elab+"% Validation Progress..."); + } + if (elaborated == 1) progressBar.updateProgress(1, "Validation..."); + } + + @Override + public void operationStopped(TRId trId,String reason, String details) { + Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]"); + progressBar.updateText("Validations failed"); + + } + + + @Override + public void operationGeneratingView() { + Log.info("Generating View..."); + progressBar.updateText("Generating View..."); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressListener.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressListener.java new file mode 100644 index 0000000..8aee58d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressListener.java @@ -0,0 +1,63 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.progress; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + + + +/** + * Defines a listener for operation progress. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface UnionProgressListener { + + /** + * 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 there is a validate for the operation. + * @param elaborated the elaborated part. + */ + public void operationValidate(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); + + /** + * Called when the operation is stopped + * + * @param trId + * @param reason + * @param details + */ + public void operationStopped(TRId trId, String reason, String details); + + /** + * Called when the operation is generating the view + */ + public void operationGeneratingView(); + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressUpdater.java new file mode 100644 index 0000000..8238343 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/progress/UnionProgressUpdater.java @@ -0,0 +1,193 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.progress; + +import java.util.ArrayList; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingMonitor; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +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 UnionProgressListener}. + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class UnionProgressUpdater extends Timer { + + protected ArrayList listeners = new ArrayList(); + + /** + * {@inheritDoc} + */ + @Override + public void run() { + Log.debug("requesting operation progress"); + TDGWTServiceAsync.INSTANCE + .getCodelistMappingMonitor(new AsyncCallback() { + + + 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); + } + + public void onSuccess(CodelistMappingMonitor result) { + Log.info("retrieved CSVImportMonitor: " + + result.getStatus()); + switch (result.getStatus()) { + case INITIALIZING: + Log.info("CSV Import Initializing..."); + fireOperationInitializing(); + break; + case ABORTED: + cancel(); + Log.info("CSV Import Operation Aborted"); + break; + case IN_PROGRESS: + fireOperationUpdate(result.getProgress()); + break; + case VALIDATING_RULES: + fireOperationValidate(result.getProgress()); + break; + case GENERATING_VIEW: + Log.info("Generating View..."); + fireOperationGeneratingView(); + break; + case STOPPED: + cancel(); + stopMessage(result); + break; + case FAILED: + cancel(); + errorMessage(result); + break; + case SUCCEDED: + cancel(); + Log.info("Import fisnish:" + + result.getTrId()); + fireOperationComplete(result.getTrId()); + break; + default: + Log.info("Unknow State"); + break; + } + + } + + }); + + } + + protected void errorMessage(CodelistMappingMonitor result) { + Log.info("Codelist Mapping Import Failed"); + Throwable th = null; + String failure = null; + String details = null; + if (result.getError() != null) { + th = result.getError(); + failure = "Failed Client Library Codelist Mapping Import"; + details = result.getError().getLocalizedMessage(); + } else { + th = new Throwable("Failed"); + failure = "Failed Client Library Codelist Mapping Import"; + details = "Error in codelist mapping import"; + } + fireOperationFailed(th, failure, details); + + } + + protected void stopMessage(CodelistMappingMonitor result) { + Log.info("Codelist Mapping Import Stopped"); + String failure = null; + String details = null; + if (result.getError() != null) { + failure = "Stopped"; + details = result.getError().getLocalizedMessage(); + } else { + failure = "Stopped"; + details = "Stopped codelist mapping import"; + } + + fireOperationStopped(result.getTrId(),failure, details); + } + + protected String getStack(Throwable e) { + String message = e.getLocalizedMessage() + " ->
"; + Throwable c = e.getCause(); + if (c != null) + message += getStack(c); + return message; + } + + protected void fireOperationInitializing() { + for (UnionProgressListener listener : listeners) + listener.operationInitializing(); + } + + protected void fireOperationGeneratingView() { + for (UnionProgressListener listener : listeners) + listener.operationGeneratingView(); + } + + protected void fireOperationUpdate(float elaborated) { + for (UnionProgressListener listener : listeners) + listener.operationUpdate(elaborated); + } + + protected void fireOperationValidate(float elaborated) { + for (UnionProgressListener listener : listeners) + listener.operationValidate(elaborated); + } + + protected void fireOperationComplete(TRId trId) { + for (UnionProgressListener listener : listeners) + listener.operationComplete(trId); + } + + protected void fireOperationFailed(Throwable caught, String failure, + String failureDetails) { + for (UnionProgressListener listener : listeners) + listener.operationFailed(caught, failure, failureDetails); + } + + protected void fireOperationStopped(TRId trId, String reason, String details) { + for (UnionProgressListener listener : listeners) + listener.operationStopped(trId,reason, details); + } + + /** + * Add a new {@link UnionProgressListener} to this + * {@link UnionProgressUpdater}. + * + * @param listener + * the listener to add. + */ + public void addListener(UnionProgressListener listener) { + listeners.add(listener); + } + + /** + * Removes the specified {@link UnionProgressListener} from this + * {@link UnionProgressUpdater}. + * + * @param listener + * the listener to remove. + */ + public void removeListener(UnionProgressListener listener) { + listeners.remove(listener); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/ErrorMessageBox.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/ErrorMessageBox.java new file mode 100644 index 0000000..b0c4b92 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/ErrorMessageBox.java @@ -0,0 +1,67 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.util; + +import com.google.gwt.core.client.Callback; +import com.google.gwt.user.client.ui.Label; +import com.sencha.gxt.widget.core.client.Dialog; +import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton; +import com.sencha.gxt.widget.core.client.box.MessageBox; +import com.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class ErrorMessageBox { + + + private static final String DETAILS = "Details"; + + + public static void showError(String title, String failureReason, final String failureDetails) + { + showError(title, failureReason, failureDetails, new NOPCallBack()); + } + + public static void showError(String title, String failureReason, final String failureDetails, final Callback callback) + { + final MessageBox box = new MessageBox(title); + box.setMessage(failureReason); + box.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + Dialog dialog = (Dialog) event.getSource(); + + if (dialog.getHideButton().getText().equals(DETAILS)){ + //box.close(); + showErrorDetails("Error details", failureDetails); + } else callback.onSuccess(dialog); + } + }); + + box.show(); + } + + public static void showErrorDetails(String title, String failureDetails) + { + final Dialog simple = new Dialog(); + simple.setHeadingText(title); + simple.setPredefinedButtons(PredefinedButton.OK); + simple.setBodyStyleName("pad-text"); + + + simple.add(new Label("
"+failureDetails+"
")); + + + simple.setHideOnButtonClick(true); + simple.setWidth(400); + simple.setHeight(400); + simple.show(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/Format.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/Format.java new file mode 100644 index 0000000..92a626f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/Format.java @@ -0,0 +1,37 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.util; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class Format { + + /** + * Converts a file size into a {@link String} representation adding the misure unit. + * @param size the file size. + * @return the textual representation. + */ + public static String fileSize(long size) { + StringBuilder text = new StringBuilder(); + if (size < 1024) { + text.append(size); + text.append(" bytes"); + } else if (size < 1048576) { + text.append(Math.round(((size * 10) / 1024)) / 10); + text.append(" KB"); + } else if (size < 1073741824) { + text.append(Math.round(((size * 10) / 1048576)) / 10); + text.append(" MB"); + } else { + text.append(Math.round(((size * 10) / 1073741824)) / 10); + text.append(" GB"); + } + return text.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/NOPCallBack.java b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/NOPCallBack.java new file mode 100644 index 0000000..2333168 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/unionwizardwidget/client/util/NOPCallBack.java @@ -0,0 +1,22 @@ +/** + * + */ +package org.gcube.portlets.user.td.unionwizardwidget.client.util; + +import com.google.gwt.core.client.Callback; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + * @param + * @param + */ +public class NOPCallBack implements Callback { + + public void onFailure(F reason) {} + + public void onSuccess(T result) {} + +} diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml new file mode 100644 index 0000000..1fc13c1 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTD.gwt.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/Messages.properties b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/Messages.properties new file mode 100644 index 0000000..c222555 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/Messages.properties @@ -0,0 +1,2 @@ +sendButton = Send +nameField = Enter your name \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/Messages_fr.properties new file mode 100644 index 0000000..b4a7627 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/Messages_fr.properties @@ -0,0 +1,2 @@ +sendButton = Envoyer +nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/CodelistMappingImportWizardTD.css b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/CodelistMappingImportWizardTD.css new file mode 100644 index 0000000..553fd48 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/CodelistMappingImportWizardTD.css @@ -0,0 +1,54 @@ +@CHARSET "UTF-8"; + + +.wizard-title { + padding: 5px; + font-weight: bold; + font-size: small; + background-color: #C3D9FF; +} + +.wizard-footer { + padding: 5px; + font-weight: bold; + font-size: small; + text-align: right; + background-color: #CDEB8B +} + +.source-selection-hover:hover { + cursor: pointer; +} + + + +.column-excluded { + background-color: #e6e0da !important; + color: #bfa698; +} + +.importSelection-sources { + padding: 30px; + display: block; + margin-top: 20px; + +} + +.importSelection-source { + padding-bottom: 20px; +} + + + +.sdmxRegistryUrlStyle { + padding-top:5px; +} + +.sdmxRegistryUrlInputStyle { + width:300px!important; +} + + +input#sdmxRegistryUrlInputFieldId-input { + width:300px!important; +} diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/accept.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/accept.png new file mode 100644 index 0000000..89c8129 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/accept.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh.png new file mode 100644 index 0000000..764f995 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh_16.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh_16.png new file mode 100644 index 0000000..72edf8a Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh_16.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh_32.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh_32.png new file mode 100644 index 0000000..f3521ea Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/arrow-refresh_32.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/codelistmapping.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/codelistmapping.png new file mode 100644 index 0000000..0485079 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/codelistmapping.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/codelistmapping_32.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/codelistmapping_32.png new file mode 100644 index 0000000..b5624ab Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/codelistmapping_32.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/delete.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/delete.png new file mode 100644 index 0000000..b639afd Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/delete.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/delete_32.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/delete_32.png new file mode 100644 index 0000000..020b555 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/delete_32.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/error.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/error.png new file mode 100644 index 0000000..c37bd06 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/error.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/information.png b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/information.png new file mode 100644 index 0000000..12cd1ae Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/information.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/loading.gif b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/loading.gif new file mode 100644 index 0000000..e846e1d Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/unionwizardwidget/client/dataresource/resources/loading.gif differ diff --git a/src/main/webapp/UnionWizardTD.css b/src/main/webapp/UnionWizardTD.css new file mode 100644 index 0000000..7aca7ac --- /dev/null +++ b/src/main/webapp/UnionWizardTD.css @@ -0,0 +1,34 @@ +/** Add css rules here for your application. */ + + +/** Example rules used by the template application (remove for your app) */ +h1 { + font-size: 2em; + font-weight: bold; + color: #777777; + margin: 40px 0px 70px; + text-align: center; +} + +.sendButton { + display: block; + font-size: 16pt; +} + +/** Most GWT widgets already have a style name defined */ +.gwt-DialogBox { + width: 400px; +} + +.dialogVPanel { + margin: 5px; +} + +.serverResponseLabelError { + color: red; +} + +/** Set ids using widget.getElement().setId("idOfElement") */ +#closeButton { + margin: 15px 6px 6px; +} diff --git a/src/main/webapp/UnionWizardTD.html b/src/main/webapp/UnionWizardTD.html new file mode 100644 index 0000000..5f67805 --- /dev/null +++ b/src/main/webapp/UnionWizardTD.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + +

Web Application Starter Project

+ + + + + + + + + + + + +
Please enter your name:
+ + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..eb27dcd --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,40 @@ + + + + + + + + TDGWTService + org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl + + + + jUnitHostImpl + com.google.gwt.junit.server.JUnitHostImpl + + + + + + + + TDGWTService + tdgwtservice/TDGWTService + + + jUnitHostImpl + UnionWizardWidgets/junithost/* + + + + + + + + UnionWizardTD.html + + + diff --git a/src/test/java/org/gcube/portlets/user/td/unionwizardwidget/client/GwtTestUnionWizardTD.java b/src/test/java/org/gcube/portlets/user/td/unionwizardwidget/client/GwtTestUnionWizardTD.java new file mode 100644 index 0000000..fa0a84e --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/td/unionwizardwidget/client/GwtTestUnionWizardTD.java @@ -0,0 +1,82 @@ +package org.gcube.portlets.user.td.unionwizardwidget.client; + +import java.util.ArrayList; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.junit.client.GWTTestCase; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; + +/** + * GWT JUnit integration tests must extend GWTTestCase. + * Using "GwtTest*" naming pattern exclude them from running with + * surefire during the test phase. + * + * If you run the tests using the Maven command line, you will have to + * navigate with your browser to a specific url given by Maven. + * See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html + * for details. + */ +public class GwtTestUnionWizardTD extends GWTTestCase { + + /** + * Must refer to a valid module that sources this class. + */ + public String getModuleName() { + return "org.gcube.portlets.user.unionwizardwidget.UnionWizardTDJUnit"; + } + + /** + * This test will send a request to the server + */ + public void testResource() { + // Create the service that we will test. + TDGWTServiceAsync tdGWTService = GWT.create(TDGWTService.class); + ServiceDefTarget target = (ServiceDefTarget) tdGWTService; + System.out.println(GWT.getModuleBaseURL() + "TDGWTService"); + target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGWTService"); + + // Since RPC calls are asynchronous, we will need to wait for a response + // after this test method returns. This line tells the test runner to wait + // up to 7 seconds before timing out. + delayTestFinish(7000); + + // Send a request to the server. + tdGWTService.getTabularResources(new AsyncCallback>() { + + + public void onFailure(Throwable caught) { + // The request resulted in an unexpected error. + fail("Request failure: " + caught.getMessage()); + + } + + public void onSuccess(ArrayList result) { + // Shows the first three resources. + int i=0; + for(TabResource tr:result){ + i++; + System.out.println(tr.toString()); + if(i>3){ + break; + } + } + + assertTrue(result.size()>0); + + // Now that we have received a response, we need to tell the test runner + // that the test is complete. You must call finishTest() after an + // asynchronous test finishes successfully, or the test will time out. + finishTest(); + + } + }); + + } + + +} diff --git a/src/test/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTDJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTDJUnit.gwt.xml new file mode 100644 index 0000000..bd02383 --- /dev/null +++ b/src/test/resources/org/gcube/portlets/user/td/unionwizardwidget/UnionWizardTDJUnit.gwt.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/templates/INSTALL b/templates/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/templates/LICENSE b/templates/LICENSE new file mode 100644 index 0000000..cc51139 --- /dev/null +++ b/templates/LICENSE @@ -0,0 +1,6 @@ +gCube System - License +------------------------------------------------------------ + +The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl). +The software and documentation is provided by its authors/distributors "as is" and no expressed or +implied warranty is given for its use, quality or fitness for a particular case. \ No newline at end of file diff --git a/templates/MAINTAINERS b/templates/MAINTAINERS new file mode 100644 index 0000000..0bc9be3 --- /dev/null +++ b/templates/MAINTAINERS @@ -0,0 +1 @@ +Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" diff --git a/templates/README b/templates/README new file mode 100644 index 0000000..e81341a --- /dev/null +++ b/templates/README @@ -0,0 +1,40 @@ +The gCube System - ${name} +------------------------------------------------------------ + +This work has been supported by the following European projects: iMarine (FP7-INFRASTRUCTURES-2011-2) + +Authors +------- + +Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, +Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" + + +Version and Release Date +------------------------ + +v. ${version} (${release.date}) + +Description +----------- + +${project.description} + +Download information +-------------------- +Source code URL: ${scm.url} + + +Documentation +------------- + +${project.description} + + +Licensing +--------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. + + + diff --git a/templates/changelog.xml b/templates/changelog.xml new file mode 100644 index 0000000..f9f8997 --- /dev/null +++ b/templates/changelog.xml @@ -0,0 +1,6 @@ + + + First Release + + \ No newline at end of file diff --git a/templates/descriptor.xml b/templates/descriptor.xml new file mode 100644 index 0000000..b978636 --- /dev/null +++ b/templates/descriptor.xml @@ -0,0 +1,39 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + INSTALL + MAINTAINERS + changelog.xml + + 755 + + + + + ${distroDirectory}/svnpath.txt + /${artifactId} + + + ${configDirectory}/profile.xml + / + + + target/${build.finalName}.${packaging} + /${artifactId} + + + \ No newline at end of file diff --git a/templates/profile.xml b/templates/profile.xml new file mode 100644 index 0000000..ffa3274 --- /dev/null +++ b/templates/profile.xml @@ -0,0 +1,29 @@ + + + + Service + + ${project.description} + PortletsUser + ${project.name} + 1.0.0 + + + ${project.description} + ${project.name} + ${version} + + ${project.groupId} + ${project.artifactId} + ${project.version} + + library + + ${project.build.finalName}.${project.packaging} + + + + + + + diff --git a/templates/svnpath.txt b/templates/svnpath.txt new file mode 100644 index 0000000..dcd0d22 --- /dev/null +++ b/templates/svnpath.txt @@ -0,0 +1 @@ +${scm.url} \ No newline at end of file