From 32fd21051c825e1f8aeabf9f042e1347e9496ed5 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 7 Mar 2019 17:29:16 +0000 Subject: [PATCH] updating GUI git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/performfish-analytics-portlet@178511 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../PerformFishAnalyticsController.java | 77 ++++++++++++++++++- .../PerformFishAnalyticsViewController.java | 70 +++++++++++++++-- .../client/event/LoadBatchesEvent.java | 36 +++++++++ .../client/event/LoadBatchesEventHandler.java | 18 +++++ .../client/view/totest/CellTreeExample.java | 1 - .../viewbinder/BatchIDAndListKPIView.java | 58 +++++++++++++- .../viewbinder/BatchIDAndListKPIView.ui.xml | 11 ++- .../PerformFishAnalitycsFormView.java | 21 ++--- .../GenericPersistenceDaoBuilder.java | 6 +- 9 files changed, 269 insertions(+), 29 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEventHandler.java diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java index 9ffe928..1d5a487 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsController.java @@ -16,6 +16,8 @@ import org.gcube.portlets.user.performfishanalytics.client.event.AddedBatchIdEve import org.gcube.portlets.user.performfishanalytics.client.event.AddedBatchIdEventHandler; import org.gcube.portlets.user.performfishanalytics.client.event.CallAlgorithmEvent; import org.gcube.portlets.user.performfishanalytics.client.event.CallAlgorithmEventHandler; +import org.gcube.portlets.user.performfishanalytics.client.event.LoadBatchesEvent; +import org.gcube.portlets.user.performfishanalytics.client.event.LoadBatchesEventHandler; import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEvent; import org.gcube.portlets.user.performfishanalytics.client.event.LoadPopulationTypeEventHandler; import org.gcube.portlets.user.performfishanalytics.client.event.PerformFishFieldFormChangedEvent; @@ -43,6 +45,7 @@ import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.Tab; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.shared.GWT; @@ -166,6 +169,64 @@ public class PerformFishAnalyticsController { viewController.manageAlgorithmsSubmit(selectedKPIsSize); } }); + + eventBus.addHandler(LoadBatchesEvent.TYPE, new LoadBatchesEventHandler() { + + @Override + public void onLoadBatches(LoadBatchesEvent loadBatchesEvent) { + + + viewController.hideErrors(); + + final Map> mapParameters = new HashMap>(); + + String farmId = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.FARMID_PARAM); + String batchType = viewController.getForm().getBatchType(); + String species = viewController.getForm().getSpecies(); + List listArea = viewController.getForm().getArea(); + List listPeriod = viewController.getForm().getPeriod(); + List listQuarter = viewController.getForm().getQuarter(); + + mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_FARMID_PARAM, Arrays.asList(farmId)); + mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_BATCH_TYPE_PARAM, Arrays.asList(batchType)); + mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_SPECIES_ID_PARAM, Arrays.asList(species)); + + if(!listArea.isEmpty()){ + mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM, listArea); + } + if(!listPeriod.isEmpty()){ + mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_PERIOD_PARAM, listPeriod); + } + if(!listQuarter.isEmpty()){ + mapParameters.put(PerformFishAnalyticsConstant.PERFORM_FISH_QUARTER_PARAM, listQuarter); + } + + final Modal modal = new Modal(true); + modal.setCloseVisible(false); + modal.hide(false); + final VerticalPanel vp = new VerticalPanel(); + LoaderIcon loader = new LoaderIcon("Loading Batches from service, please wait..."); + vp.add(loader); + loader.show(true); + modal.add(vp); + PerformFishAnalyticsServiceAsync.Util.getInstance().submitRequestToPerformFishService(mapParameters, new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + modal.hide(); + Window.alert(caught.getMessage()); + } + + @Override + public void onSuccess(PerformFishResponse performFishResponse) { + modal.hide(); + viewController.managePerformFishServiceResponse(performFishResponse, mapParameters, POPULATION_LEVEL.BATCH); + } + }); + modal.show(); + + } + }); eventBus.addHandler(PerformFishFieldFormChangedEvent.TYPE, new PerformFishFieldFormChangedEventHandler() { @@ -176,8 +237,20 @@ public class PerformFishAnalyticsController { viewController.setReloadPerformFishServiceData(true); boolean isValidForm = viewController.validatePerformFishInputFields(); + + if(isValidForm) { + viewController.resetBatchIdStatus(); + viewController.setBatchIdStatus(ControlGroupType.INFO); + viewController.enableLoadBatches(true); + viewController.enableAllAlgorithmsForSubmit(false); + + }else { + viewController.enableLoadBatches(false); + viewController.enableAllAlgorithmsForSubmit(false); + } + - if(isValidForm){ + /*if(isValidForm){ viewController.hideErrors(); @@ -241,7 +314,7 @@ public class PerformFishAnalyticsController { }else{ //IF IT IS NOT A VALID FORM WE NEED TO DISABLE DATAMINER REQUESTS viewController.enableAllAlgorithmsSubmits(false); - } + }*/ } }); diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsViewController.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsViewController.java index 9bd1f6c..0c774f7 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsViewController.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/controllers/PerformFishAnalyticsViewController.java @@ -40,6 +40,7 @@ import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; +// TODO: Auto-generated Javadoc /** * The Class PerformFishAnalyticsViewController. * @@ -48,24 +49,49 @@ import com.google.gwt.user.client.ui.Widget; */ public class PerformFishAnalyticsViewController { - /** - * - */ + /** The Constant PERFORM_FISH_ANALYTICS_DIV. */ public static final String PERFORM_FISH_ANALYTICS_DIV = "perform-fish-analytics"; + + /** The base dock layout panel. */ private BaseDockLayoutPanel baseDockLayoutPanel; + + /** The header page. */ private HeaderPanel headerPage; + + /** The body page. */ private BodyPanel bodyPage; + + /** The batch ID and list KPI. */ private BatchIDAndListKPIView batchIDAndListKPI; + + /** The form. */ private PerformFishAnalitycsFormView form; + + /** The selected population. */ private Population selectedPopulation; + + /** The custom tree model. */ private CustomTreeModel customTreeModel; + + /** The tree. */ private CellTree tree; + + /** The west panel. */ private VerticalPanel westPanel; + + /** The est panel. */ private VerticalPanel estPanel; + + /** The recap page. */ private RecapSubmitPage recapPage; + + /** The tab panel. */ private TabPanelView tabPanel; + + /** The root panel. */ private VerticalPanel rootPanel; + /** The reload perform fish service data. */ private boolean reloadPerformFishServiceData = true; /** @@ -275,12 +301,13 @@ public class PerformFishAnalyticsViewController { } } + /** - * Enable all algorithms submits. + * Enable all algorithms for submit. * * @param bool the bool */ - public void enableAllAlgorithmsSubmits(boolean bool){ + public void enableAllAlgorithmsForSubmit(boolean bool){ recapPage.activeAllAlgorithms(bool); } @@ -347,7 +374,26 @@ public class PerformFishAnalyticsViewController { return true; } + + + /** + * Reset batch id status. + */ + public void resetBatchIdStatus() { + batchIDAndListKPI.resetBatchIdStatus(); + } + + /** + * Sets the batch id status. + * + * @param status the new batch id status + */ + public void setBatchIdStatus(ControlGroupType status) { + ControlGroup cg_batch_id = batchIDAndListKPI.getControlGroupBatchID(); + cg_batch_id.setType(status); + } + /** * Validate batch id selection. * @@ -380,8 +426,9 @@ public class PerformFishAnalyticsViewController { return false;*/ String msgError = "Could not find valid data. Please change the selection (Areas, Periods and so on) parameters"; - cg_batch_id.setType(ControlGroupType.ERROR); + cg_batch_id.setType(ControlGroupType.INFO); batchIDAndListKPI.showError(msgError, true); + batchIDAndListKPI.enableButtonLoadBatches(false); return false; } @@ -400,6 +447,17 @@ public class PerformFishAnalyticsViewController { return form.validateForm(); } + + + /** + * Enable load batches. + * + * @param enable the enable + * @return true, if successful + */ + public void enableLoadBatches(boolean enable) { + batchIDAndListKPI.enableButtonLoadBatches(enable); + } /** * Resync selected kp is. diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEvent.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEvent.java new file mode 100644 index 0000000..a8563d8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEvent.java @@ -0,0 +1,36 @@ +package org.gcube.portlets.user.performfishanalytics.client.event; + +import com.google.gwt.event.shared.GwtEvent; + + +/** + * The Class LoadPopulationTypeEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * Jan 22, 2019 + */ +public class LoadBatchesEvent extends GwtEvent { + public static Type TYPE = new Type(); + /** + * Instantiates a new load batches event. + */ + public LoadBatchesEvent() { + } + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(LoadBatchesEventHandler handler) { + handler.onLoadBatches(this); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEventHandler.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEventHandler.java new file mode 100644 index 0000000..c28c934 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/event/LoadBatchesEventHandler.java @@ -0,0 +1,18 @@ +package org.gcube.portlets.user.performfishanalytics.client.event; + +import com.google.gwt.event.shared.EventHandler; + +// TODO: Auto-generated Javadoc +/** + * The Interface LoadBatchesEventHandler. + */ +public interface LoadBatchesEventHandler extends EventHandler { + + + /** + * On load batches. + * + * @param loadBatchesEvent the load batches event + */ + void onLoadBatches(LoadBatchesEvent loadBatchesEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/view/totest/CellTreeExample.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/view/totest/CellTreeExample.java index e9376c6..d9680c2 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/view/totest/CellTreeExample.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/view/totest/CellTreeExample.java @@ -9,7 +9,6 @@ import com.google.gwt.user.cellview.client.CellTree; import com.google.gwt.user.client.ui.RootLayoutPanel; import com.google.gwt.view.client.ListDataProvider; import com.google.gwt.view.client.TreeViewModel; -import com.google.gwt.view.client.TreeViewModel.DefaultNodeInfo; /** diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.java index cd2d4e0..41b90e0 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.java @@ -12,17 +12,21 @@ import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsC import org.gcube.portlets.user.performfishanalytics.client.PerformFishAnalyticsServiceAsync; import org.gcube.portlets.user.performfishanalytics.client.controllers.PerformFishAnalyticsController; import org.gcube.portlets.user.performfishanalytics.client.event.AddedBatchIdEvent; +import org.gcube.portlets.user.performfishanalytics.client.event.LoadBatchesEvent; import org.gcube.portlets.user.performfishanalytics.client.view.LoaderIcon; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVFile; import org.gcube.portlets.user.performfishanalytics.shared.csv.CSVRow; import org.gcube.portlets.user.performfishanalytics.shared.performfishservice.PerformFishResponse; import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; @@ -34,6 +38,7 @@ import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; +// TODO: Auto-generated Javadoc /** * The Class BatchIDAndListKPIView. * @@ -42,6 +47,7 @@ import com.google.gwt.user.client.ui.Widget; */ public class BatchIDAndListKPIView extends Composite { + /** The ui binder. */ private static BatchIDAndListKPIViewUiBinder uiBinder = GWT.create(BatchIDAndListKPIViewUiBinder.class); @@ -56,23 +62,34 @@ public class BatchIDAndListKPIView extends Composite { extends UiBinder { } + /** The the panel container. */ @UiField VerticalPanel the_panel_container; + /** The uib list batch id. */ @UiField ListBox uib_list_batch_id; + /** The the panel error. */ @UiField HorizontalPanel the_panel_error; + /** The cg batch id. */ @UiField ControlGroup cg_batch_id; + + /** The uib button load batches. */ + @UiField + Button uib_button_load_batches; + /** The perform fish response. */ private PerformFishResponse performFishResponse; + /** The map parameters. */ private Map> mapParameters; + /** The list batches ID. */ private List listBatchesID = new ArrayList(); @@ -83,6 +100,15 @@ public class BatchIDAndListKPIView extends Composite { initWidget(uiBinder.createAndBindUi(this)); uib_list_batch_id.setEnabled(false); + + + uib_button_load_batches.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + PerformFishAnalyticsController.eventBus.fireEvent(new LoadBatchesEvent()); + } + }); } @@ -96,6 +122,11 @@ public class BatchIDAndListKPIView extends Composite { } + /** + * Gets the all batches ID. + * + * @return the all batches ID + */ public List getAllBatchesID(){ return listBatchesID; } @@ -151,9 +182,7 @@ public class BatchIDAndListKPIView extends Composite { GWT.log("BatchesTable_internal is: "+fileURL); //Resetting batch ID and panel error after calling Perform Fish Service - uib_list_batch_id.clear(); - the_panel_error.clear(); - listBatchesID.clear(); + resetBatchIdStatus(); //Managing the Perform Fish Service Response if(fileURL==null){ @@ -182,6 +211,7 @@ public class BatchIDAndListKPIView extends Composite { if(result==null){ showAlert("No value found for "+PerformFishAnalyticsConstant.BATCHES_TABLE_INTERNAL, AlertType.ERROR, false, the_panel_error); + enableButtonLoadBatches(false); return; } @@ -216,6 +246,13 @@ public class BatchIDAndListKPIView extends Composite { }); } } + + public void resetBatchIdStatus() { + //Resetting batch ID and panel error after calling Perform Fish Service + uib_list_batch_id.clear(); + the_panel_error.clear(); + listBatchesID.clear(); + } /** * Show alert. @@ -280,6 +317,8 @@ public class BatchIDAndListKPIView extends Composite { /** + * Gets the perform fish response. + * * @return the performFishResponse */ public PerformFishResponse getPerformFishResponse() { @@ -289,12 +328,25 @@ public class BatchIDAndListKPIView extends Composite { /** + * Gets the map parameters. + * * @return the mapParameters */ public Map> getMapParameters() { return mapParameters; } + + /** + * Enable button load batches. + * + * @param enable the enable + */ + public void enableButtonLoadBatches(boolean enable) { + uib_button_load_batches.setEnabled(enable); + if(enable) + uib_list_batch_id.setTitle("Press on Load Batches"); + } } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.ui.xml b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.ui.xml index f250ef4..40b1eb0 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/BatchIDAndListKPIView.ui.xml @@ -1,6 +1,7 @@ + xmlns:g="urn:import:com.google.gwt.user.client.ui" + xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> @@ -10,12 +11,14 @@ BATCH ID - + + diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/PerformFishAnalitycsFormView.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/PerformFishAnalitycsFormView.java index f4e7d38..67a7fb2 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/PerformFishAnalitycsFormView.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/client/viewbinder/PerformFishAnalitycsFormView.java @@ -366,36 +366,37 @@ public class PerformFishAnalitycsFormView extends Composite { errorPanel.setVisible(false); // cg_remote_path.setType(ControlGroupType.NONE); if (field_select_quarter.getItemCount()>0 && field_select_quarter.getSelectedIndex() == -1) { - cg_select_quarter.setType(ControlGroupType.ERROR); - showError("You must select a Quarter"); + cg_select_quarter.setType(ControlGroupType.INFO); + showAlert("Please select a Quarter", AlertType.INFO); return false; } if (field_select_area.getItemCount()>0 && field_select_area.getSelectedIndex() == -1) { - cg_select_area.setType(ControlGroupType.ERROR); - showError("You must select an Area"); + cg_select_area.setType(ControlGroupType.INFO); + showAlert("Please select an Area", AlertType.INFO); return false; } if (field_select_period.getItemCount()>0 && field_select_period.getSelectedIndex() == -1) { - cg_select_period.setType(ControlGroupType.ERROR); - showError("You must select a Period"); + cg_select_period.setType(ControlGroupType.INFO); + showAlert("Please select a Period", AlertType.INFO); return false; } return true; } - + /** - * Show error. + * Show alert. * * @param txt the txt + * @param type the type */ - public void showError(String txt) { + public void showAlert(String txt, AlertType type) { errorPanel.clear(); errorPanel.setVisible(true); Alert msg = new Alert(txt); msg.setAnimation(true); msg.setClose(false); - msg.setType(AlertType.ERROR); + msg.setType(type); errorPanel.add(msg); } diff --git a/src/main/java/org/gcube/portlets/user/performfishanalytics/server/persistence/GenericPersistenceDaoBuilder.java b/src/main/java/org/gcube/portlets/user/performfishanalytics/server/persistence/GenericPersistenceDaoBuilder.java index 46ac708..fc57f78 100644 --- a/src/main/java/org/gcube/portlets/user/performfishanalytics/server/persistence/GenericPersistenceDaoBuilder.java +++ b/src/main/java/org/gcube/portlets/user/performfishanalytics/server/persistence/GenericPersistenceDaoBuilder.java @@ -2,13 +2,13 @@ package org.gcube.portlets.user.performfishanalytics.server.persistence; import javax.persistence.EntityManagerFactory; -import lombok.Getter; -import lombok.ToString; - import org.gcube.portlets.user.performfishanalytics.shared.GenericDao; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import lombok.Getter; +import lombok.ToString; + /** * Gets the persistence entity.