enhancement on GUI

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/performfish-analytics-portlet@178516 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2019-03-08 14:18:38 +00:00
parent ac9e209484
commit daecdba666
4 changed files with 107 additions and 73 deletions

View File

@ -40,18 +40,14 @@ import org.gcube.portlets.user.performfishanalytics.shared.performfishservice.Pe
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.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;
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.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -62,6 +58,7 @@ import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;
// TODO: Auto-generated Javadoc
/**
* The Class PerformFishAnalyticsController.
*
@ -70,13 +67,14 @@ import com.google.gwt.user.client.ui.VerticalPanel;
*/
public class PerformFishAnalyticsController {
/**
*
*/
/** The Constant eventBus. */
public final static HandlerManager eventBus = new HandlerManager(null);
/** The view controller. */
private PerformFishAnalyticsViewController viewController;
/** The decrypt parameters. */
private PerformFishInitParameter decryptParameters;
/**
@ -166,8 +164,11 @@ public class PerformFishAnalyticsController {
viewController.manageKPI(selectedKPI.getKpi(), selectedKPI.isChecked(), selectedKPI.getSelectedPopulationType());
int selectedKPIsSize = viewController.getSelectedKPIs().size();
boolean isValidForm = viewController.validatePerformFishInputFields();
if(isValidForm) {
viewController.manageAlgorithmsSubmit(selectedKPIsSize);
}
}
});
eventBus.addHandler(LoadBatchesEvent.TYPE, new LoadBatchesEventHandler() {
@ -175,11 +176,9 @@ public class PerformFishAnalyticsController {
@Override
public void onLoadBatches(LoadBatchesEvent loadBatchesEvent) {
viewController.hideErrors();
final Map<String, List<String>> mapParameters = new HashMap<String, List<String>>();
String farmId = decryptParameters.getParameters().get(PerformFishAnalyticsConstant.FARMID_PARAM);
String batchType = viewController.getForm().getBatchType();
String species = viewController.getForm().getSpecies();
@ -360,12 +359,7 @@ public class PerformFishAnalyticsController {
mapParameters.put(PerformFishAnalyticsConstant.DATA_INPUTS, Arrays.asList(dataInParameters));
// final Modal modal = new Modal(true);
// modal.setCloseVisible(false);
// modal.hide(false);
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("");
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
submitRequestPanel.showLoader(true, "Submitting "+DataMinerAlgorithms.CORRELATION.getName()+" request to DM Service...");
String tabTitle = DataMinerAlgorithms.CORRELATION.getName().substring(0,1).toUpperCase()+DataMinerAlgorithms.CORRELATION.getName().toLowerCase().substring(1, DataMinerAlgorithms.CORRELATION.getName().length()); //CAMEL CASE
final Tab tab = viewController.createTab(submitRequestPanel, tabTitle+" #"+(viewController.currentNumberOfTab()+1));
@ -375,7 +369,7 @@ public class PerformFishAnalyticsController {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
submitRequestPanel.showLoader(false, null);
viewController.noSpinner(tab);
checkTabSpinner(submitRequestPanel, tab);
AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult();
analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
analyticsPanelResult.addSelectedKPIs(viewController.getSelectedKPIs());
@ -391,7 +385,7 @@ public class PerformFishAnalyticsController {
public void onFailure(Throwable caught) {
GWT.log(caught.toString());
submitRequestPanel.showLoader(false, null);
viewController.noSpinner(tab);
checkTabSpinner(submitRequestPanel, tab);
try {
AnalyticsPanelResult analyticsPanelResult = new AnalyticsPanelResult();
analyticsPanelResult.addSelectedAreas(performFishRequestParameters.get(PerformFishAnalyticsConstant.PERFORM_FISH_AREA_PARAM));
@ -427,7 +421,7 @@ public class PerformFishAnalyticsController {
if(listBatchID==null || listBatchID.size()==0)
Window.alert("Something seems wrong, no selected BatchID, try again");
SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("");
SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
//submitRequestPanel.getElement().addClassName("ext-horizontal-panel");
String tabTitle = algorithm.getName().substring(0,1).toUpperCase()+algorithm.getName().toLowerCase().substring(1, algorithm.getName().length()); //CAMEL CASE
Tab tab = viewController.createTab(submitRequestPanel, tabTitle+" #"+(viewController.currentNumberOfTab()+1));
@ -436,7 +430,7 @@ public class PerformFishAnalyticsController {
case BOXPLOT:
case SPEEDOMETER:
//submitRequestPanel.setTheTitle(title);
submitRequestPanel.setTotalRequests(inputKPI.size());
for (KPI kpi : inputKPI) {
String title = "KPI: "+kpi.getName();
HTML toBigTitle = new HTML(title);
@ -444,7 +438,7 @@ public class PerformFishAnalyticsController {
submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel();
hp.getElement().addClassName("ext-horizontal-panel");
callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, Arrays.asList(kpi), Arrays.asList(kpi), algorithm, focusID, hp, tab);
callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, Arrays.asList(kpi), Arrays.asList(kpi), algorithm, focusID, submitRequestPanel, hp, tab);
//resultPanel.add(hp);
submitRequestPanel.addWidget(hp);
}
@ -461,7 +455,7 @@ public class PerformFishAnalyticsController {
submitRequestPanel.setTheTitle(titleScatter);
default:
callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, submitRequestPanel.getContainerPanel(), tab);
callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, inputKPI, outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab);
}
}
@ -475,10 +469,11 @@ public class PerformFishAnalyticsController {
* @param outputKPI the output kpi
* @param chartType the chart type
* @param focusID the focus id
* @param requestPanel the request panel
* @param panelContainer the panel
* @param tab
* @param tab the tab
*/
private void callDataMinerServiceForChart(PerformFishResponse performFishResponse, POPULATION_LEVEL scalePValue, final List<KPI> inputKPI, final List<KPI> outputKPI, final DataMinerAlgorithms chartType, final String focusID, final ComplexPanel panelContainer, final Tab tab) {
private void callDataMinerServiceForChart(PerformFishResponse performFishResponse, POPULATION_LEVEL scalePValue, final List<KPI> inputKPI, final List<KPI> outputKPI, final DataMinerAlgorithms chartType, final String focusID, final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab) {
GWT.log("Read perform fish response: "+performFishResponse);
@ -546,8 +541,8 @@ public class PerformFishAnalyticsController {
@Override
public void onSuccess(DataMinerResponse dmResponse) {
viewController.noSpinner(tab);
loaderIcon.setVisible(false);
checkTabSpinner(requestPanel, tab);
//field_unary_algorithm.setVisible(true);
GWT.log("I'm displaying: "+dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, chartType, inputKPI, outputKPI, focusID, panelContainer, false);
@ -555,14 +550,29 @@ public class PerformFishAnalyticsController {
@Override
public void onFailure(Throwable caught) {
viewController.noSpinner(tab);
loaderIcon.setVisible(false);
checkTabSpinner(requestPanel, tab);
displayOutputFilesAsStaticEntities(null, chartType, inputKPI, outputKPI, focusID, panelContainer, true);
}
});
}
/**
* Remove the spinner if all DM responses are returned
*
* @param requestPanel the request panel
* @param tab the tab
*/
private void checkTabSpinner(SubmitRequestPanel requestPanel, Tab tab){
requestPanel.incrementCompletedRequests();
int completed = requestPanel.getCompletedRequests();
int total = requestPanel.getTotalRequests();
if(completed>=total) {
viewController.noSpinner(tab);
}
}
/**
* Display output files as static entities.
@ -578,25 +588,6 @@ public class PerformFishAnalyticsController {
private void displayOutputFilesAsStaticEntities(DataMinerResponse dmResponse, final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final Panel container, boolean displayError){
String title = displayError?"No results ":"";
/*title+=chartType;
title+=inputKPIs.size()>1?" [Input KPIs: ":" [Input KPI: ";
for (KPI kpi : inputKPIs) {
title+=" "+kpi.getName()+",";
}
title = title.substring(0,title.length()-1)+"]";
if(outputKPIs!=null && outputKPIs.size()>0){
title+=inputKPIs.size()>1?" [Output KPIs: ":" [Output KPI: ";
for (KPI kpi : outputKPIs) {
title+=" "+kpi.getName()+",";
}
title = title.substring(0,title.length()-1)+"]";
}*/
//title+= " Focus "+focusID;
if(displayError){
Alert alert = new Alert(title);
@ -625,17 +616,6 @@ public class PerformFishAnalyticsController {
@Override
public void onSuccess(String base64Content) {
//String title = toTitle;
// switch (chartType) {
// case BOXPLOT:
// break;
// case SPEEDOMETER:
// title+= " BATCH ID: "+focusID;
// break;
// default:
// break;
// }
String title = toTitle;
switch (chartType) {
case BOXPLOT:
@ -677,18 +657,6 @@ public class PerformFishAnalyticsController {
public void onSuccess(CSVFile result) {
GWT.log("Displaying: "+result);
// String title = toTitle;
// switch (chartType) {
// case BOXPLOT:
// title+= " Statistics on all data";
// break;
// case SPEEDOMETER:
// title+= " BATCH ID: "+focusID;
// break;
// default:
// break;
// }
String title = toTitle;
switch (chartType) {
case BOXPLOT:

View File

@ -254,9 +254,11 @@ public class PerformFishAnalyticsViewController {
TreeNode rootNode = tree.getRootTreeNode();
customTreeModel.setNewBatchType(result);
// Open the first playlist by default.
TreeNode firstPlaylist = rootNode.setChildOpen(0, true);
//firstPlaylist.setChildOpen(0, true);
expandAllTreeNode(rootNode);
//IT SHOULD BE AN EVENT
recapPage.removeAllSelected();
@ -265,6 +267,18 @@ public class PerformFishAnalyticsViewController {
}
private void expandAllTreeNode(TreeNode rootNode) {
if(rootNode==null || rootNode.getChildCount()==0)
return;
for (int i=0; i<rootNode.getChildCount(); i++) {
TreeNode childNode = rootNode.setChildOpen(i, true);
expandAllTreeNode(childNode);
//GWT.log("Opened child: "+childNode);
}
}
/**
* Manage kpi.
@ -361,7 +375,8 @@ public class PerformFishAnalyticsViewController {
bodyPage.hideError();
List<KPI> selectedKPIs = recapPage.getSelectedKPIs();
if(selectedKPIs.size()<1){
bodyPage.showAlert("Please select at least 1 KPI. Expand the KPI's tree and than select at least 1 KPI by checkbox", AlertType.ERROR);
//bodyPage.showAlert("Please select at least 1 KPI.", AlertType.ERROR);
bodyPage.showAlert("Please select at least 1 KPI. Expand the KPI's levels and than select at least 1 KPI by checkbox", AlertType.ERROR);
//recapPage.setError("You must select a KPI");
return false;
}

View File

@ -282,6 +282,7 @@ public class PerformFishAnalitycsFormView extends Composite {
}
else {
field_select_area.setEnabled(false);
uib_check_all_area.setEnabled(false);
}
}
@ -302,6 +303,7 @@ public class PerformFishAnalitycsFormView extends Composite {
}
else {
field_select_period.setEnabled(false);
uib_check_all_period.setEnabled(false);
}
}
@ -322,6 +324,7 @@ public class PerformFishAnalitycsFormView extends Composite {
}
else {
field_select_quarter.setEnabled(false);
uib_check_all_quarter.setEnabled(false);
}
}

View File

@ -15,6 +15,7 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
// TODO: Auto-generated Javadoc
/**
* The Class SubmitRequestPanel.
*
@ -23,6 +24,7 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class SubmitRequestPanel extends Composite {
/** The ui binder. */
private static SubmitRequestPanelPanelUiBinder uiBinder =
GWT.create(SubmitRequestPanelPanelUiBinder.class);
@ -36,14 +38,23 @@ public class SubmitRequestPanel extends Composite {
extends UiBinder<Widget, SubmitRequestPanel> {
}
/** The title. */
@UiField
HTML theTitle;
/** The container panel. */
@UiField
HTMLPanel containerPanel;
/** The loader. */
LoaderIcon loader;
/** The completed requests. */
private int completedRequests = 0;
/** The total requests. */
private int totalRequests = 1;
/**
* Because this class has a default constructor, it can
* be used as a binder template. In other words, it can be used in other
@ -56,13 +67,15 @@ public class SubmitRequestPanel extends Composite {
* implement HasHTML instead of HasText.
*
* @param title the title
* @param totalRequests the total requests
*/
public SubmitRequestPanel(String title) {
public SubmitRequestPanel(String title, int totalRequests) {
initWidget(uiBinder.createAndBindUi(this));
theTitle.getElement().addClassName("to-big-title");
theTitle.getElement().getStyle().setTextAlign(TextAlign.CENTER);
setTheTitle(title);
this.totalRequests = totalRequests;
}
@ -108,6 +121,41 @@ public class SubmitRequestPanel extends Composite {
}
}
/**
* Increment completed requests.
*/
public synchronized void incrementCompletedRequests() {
completedRequests++;
}
/**
* Gets the completed requests.
*
* @return the completed requests
*/
public synchronized int getCompletedRequests() {
return completedRequests;
}
/**
* Gets the total requests.
*
* @return the total requests
*/
public int getTotalRequests() {
return totalRequests;
}
/**
* Sets the total requests.
*
* @param totalRequests the new total requests
*/
public void setTotalRequests(int totalRequests) {
this.totalRequests = totalRequests;
}
/**
* Adds the widget.
*