2521: Explore the possibility to port the StatMan interface onto Dataminer

https://support.d4science.org/issues/2521

Fixed Menu Event

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128371 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-04-27 16:41:39 +00:00
parent 0eedb36822
commit 8b73acb942
12 changed files with 586 additions and 326 deletions

View File

@ -1,7 +1,9 @@
package org.gcube.portlets.user.dataminermanager.client;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.computations.ComputationsPanel;
import org.gcube.portlets.user.dataminermanager.client.dataspace.DataSpacePanel;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.experiments.ExperimentPanel;
import org.gcube.portlets.user.dataminermanager.client.resources.Resources;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
@ -12,54 +14,39 @@ import com.google.gwt.core.client.EntryPoint;
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.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
//import com.google.gwt.event.logical.shared.ResizeEvent;
//import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer.HorizontalLayoutData;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
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.container.Viewport;
//import com.google.gwt.event.logical.shared.ResizeEvent;
//import com.google.gwt.event.logical.shared.ResizeHandler;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class DataMinerManager implements EntryPoint {
public static final Resources resources = GWT.create(Resources.class);
private static final String SM_DIV = "contentDiv";
@SuppressWarnings("unused")
private DataMinerManagerController dataMinerManagerController;
private Header header;
private HomePanel homeMenu;
private DataSpacePanel dataSpacePanel;
private ExperimentPanel experimentPanel;
private ComputationsPanel computationsPanel;
private SimpleContainer previousPanel;
private SimpleContainer homeMenu;
private SimpleContainer centerPanel;
public enum MenuItem {
DATA_SPACE, EXPERIMENT, COMPUTATIONS
};
private Header header;
// Main Panel
private static BorderLayoutContainer mainPanelLayout;
/**
* {@inheritDoc}
*/
@ -106,84 +93,64 @@ public class DataMinerManager implements EntryPoint {
}
private void loadMainPanel() {
// AccountingManagerResources.INSTANCE.accountingManagerCSS().ensureInjected();
// ScriptInjector.fromString(AccountingManagerResources.INSTANCE.jqueryJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
dataMinerManagerController = new DataMinerManagerController();
homeMenu = createMenuPanel();
homeMenu = new HomePanel();
dataSpacePanel = new DataSpacePanel();
experimentPanel = new ExperimentPanel();
computationsPanel = new ComputationsPanel();
bind();
// Layout
mainPanelLayout = new BorderLayoutContainer();
BorderLayoutContainer mainPanelLayout = new BorderLayoutContainer();
mainPanelLayout.setId("mainPanelLayout");
mainPanelLayout.setBorders(false);
mainPanelLayout.setResize(true);
mainPanelLayout.getElement().getStyle().setBackgroundColor("#FFFFFF");
// mainPanelLayout.getElement().getStyle().setBackgroundColor("rgb(3, 126, 207)");
// Center
centerPanel = new SimpleContainer();
MarginData mainData = new MarginData(new Margins(0));
mainPanelLayout.setCenterWidget(centerPanel, mainData);
// Menu
header = new Header() {
header = new Header();
@Override
public void select(MenuItem menuItem) {
if (menuItem == null)
switchTo(homeMenu);
else if (menuItem == MenuItem.EXPERIMENT)
switchTo(experimentPanel);
else if (menuItem == MenuItem.DATA_SPACE)
switchTo(dataSpacePanel);
else if (menuItem == MenuItem.COMPUTATIONS)
switchTo(computationsPanel);
/*
* else if (menuItem == MenuItem.COMPUTATIONS)
* switchTo(jobsPanel);
*/
}
};
BorderLayoutData menuData = new BorderLayoutData(58);
BorderLayoutData menuData = new BorderLayoutData(40);
menuData.setMargins(new Margins(5));
menuData.setCollapsible(false);
menuData.setSplit(false);
mainPanelLayout.setNorthWidget(header, menuData);
// Filters
/*
* FiltersPanel filtersPanel=new FiltersPanel(eventBus);
* BorderLayoutData westData = new BorderLayoutData(410);
* westData.setCollapsible(false); westData.setSplit(false);
* westData.setFloatable(false); westData.setCollapseMini(false);
* westData.setMargins(new Margins(2, 7, 2, 7));
* westData.setCollapseHidden(true); westData.setMaxSize(410);
* westData.setMinSize(410); mainPanelLayout.setWestWidget(filtersPanel,
* westData); filtersPanel.expand(); filtersPanel.enable();
*/
//
centerPanel.add(homeMenu);
previousPanel = homeMenu;
bind(mainPanelLayout);
bindWindow(mainPanelLayout);
mainPanelLayout.forceLayout();
bindEvents();
/*
* dataMinerManagerController.setMainPanelLayout(mainPanelLayout);
* dataMinerManagerController.restoreUISession();
*/
}
private void bind() {
EventBusProvider.INSTANCE.addHandler(MenuSwitchEvent.TYPE,
new MenuSwitchEvent.MenuSwitchEventHandler() {
@Override
public void onSelect(MenuSwitchEvent event) {
Log.debug("Catch MenuSwitchEvent");
menuSwitch(event);
}
});
}
private void bind(BorderLayoutContainer mainWidget) {
/**
*
* @param mainWidget
*/
private void bindWindow(BorderLayoutContainer mainWidget) {
try {
RootPanel root = RootPanel.get(SM_DIV);
Log.info("Root Panel: " + root);
@ -214,149 +181,50 @@ public class DataMinerManager implements EntryPoint {
}
}
/*
* private void updateSize() { RootPanel smDiv = RootPanel.get(SM_DIV);
*
* int topBorder = smDiv.getAbsoluteTop(); int leftBorder =
* smDiv.getAbsoluteLeft();
*
* int rootHeight = Window.getClientHeight() - topBorder - 4;// - ((footer
* // == // null)?0:(footer.getOffsetHeight()-15)); int rootWidth =
* Window.getClientWidth() - 2 * leftBorder - 5; // - // rightScrollBar;
*
* //
* System.out.println("New Data Miner Manager dimension Width: "+rootWidth
* +"; Height: "+rootHeight);
*
* if (previousPanel == menu) dataMinerManagerLayout.setSize(rootWidth,
* 700); else dataMinerManagerLayout.setSize(rootWidth, rootHeight); }
*/
/**
*
* @param event
*/
private void bindEvents() {
/*
* EventBusProvider.INSTANCE.addHandler(MaskEvent.getType(), new
* MaskEvent.MaskHandler() {
*
* @Override public void onMask(MaskEvent event) { if (mainPanelLayout
* == null) return;
*
* String message = event.getMessage(); if (message == null)
* mainPanelLayout.unmask(); else mainPanelLayout.mask(message);
*
* // Constants.maskLoadingStyle); } });
*/
/*
* EventBusProvider.getInstance().addHandler(
* SessionExpiredEvent.getType(), new
* SessionExpiredEvent.SessionExpiredHandler() {
*
* @Override public void onSessionExpired(SessionExpiredEvent event) {
* Window.alert("The session has expired. Please refresh the page."); }
* });
*/
private void menuSwitch(MenuSwitchEvent event){
if(event==null||event.getMenuType()==null){
return;
}
switch(event.getMenuType()){
case COMPUTATIONS:
switchPanel(computationsPanel);
break;
case DATA_SPACE:
switchPanel(dataSpacePanel);
break;
case EXPERIMENT:
switchPanel(experimentPanel);
break;
case HOME:
switchPanel(homeMenu);
break;
default:
break;
}
}
/**
* @return
*/
private SimpleContainer createMenuPanel() {
SimpleContainer topLc = new SimpleContainer();
topLc.setStylePrimaryName("smMenu");
topLc.addStyleName("smLayoutContainer");
VerticalLayoutContainer lc = new VerticalLayoutContainer();
VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1,
new Margins(20, 90, 10, 90));
VerticalLayoutData layoutNext = new VerticalLayoutData(-1, -1,
new Margins(10, 90, 10, 90));
SimpleContainer itemDataSpace = createMenuItem(
"Access to the Data Space",
"The data space contains the set of input and output data sets of the users. It is possible to upload and share tables. Data sources can be chosen from those hosted by the infrastructure. Outputs of the computations can be even saved in this space.",
resources.inputSpaceIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
switchTo(dataSpacePanel);
header.setMenuSelected(MenuItem.DATA_SPACE);
}
});
lc.add(itemDataSpace, layoutTop);
SimpleContainer itemExperiment = createMenuItem(
"Execute an Experiment",
"This section allows to execute or prepare a Niche Modeling experiment. The section is endowed with a list of algorithms for training and executing statistical models for biological applications. Evaluation of the performances is possible by means of several kinds of measurement systems and processes.",
resources.executionIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
switchTo(experimentPanel);
header.setMenuSelected(MenuItem.EXPERIMENT);
}
});
lc.add(itemExperiment, layoutNext);
SimpleContainer itemComputations = createMenuItem(
"Check the Computations",
"This section allows to check the status of the computation. A list of processes launched by the user is shown along with meta-information. By clicking on the completed jobs it is possible to visualize the data set contents.",
resources.computationsIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
switchTo(computationsPanel);
header.setMenuSelected(MenuItem.COMPUTATIONS);
}
});
lc.add(itemComputations, layoutNext);
topLc.add(lc);
return topLc;
}
/**
*
* @param panel
*/
private void switchTo(SimpleContainer lc) {
private void switchPanel(SimpleContainer panel) {
centerPanel.remove(previousPanel);
centerPanel.add(lc);
centerPanel.add(panel);
centerPanel.forceLayout();
previousPanel = lc;
previousPanel = panel;
}
private SimpleContainer createMenuItem(String title, String description,
ImageResource imgResource, MouseDownHandler handle) {
HorizontalLayoutContainer horiz = new HorizontalLayoutContainer();
Image img = new Image(imgResource);
HTML text = new HTML("<b>" + title + "</b><br>" + description);
text.addStyleName("smMenuItemText");
HorizontalLayoutData textLayoutData = new HorizontalLayoutData(400,
140, new Margins(10, 5, 10, 10));
HorizontalLayoutData imgLayoutData = new HorizontalLayoutData(140, 140,
new Margins(10, 10, 10, 5));
horiz.add(text, textLayoutData);
horiz.add(img, imgLayoutData);
SimpleContainer container = new SimpleContainer();
container.addDomHandler(handle, MouseDownEvent.getType());
container.setWidth(540);
container.setHeight(170);
container.addStyleName("smMenuItem");
container.addStyleOnOver(container.getElement(), "smMenuItem:HOVER");
container.add(horiz);
return container;
}

View File

@ -7,10 +7,12 @@ import org.gcube.portlets.user.dataminermanager.client.bean.OperatorsClassificat
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.CancelComputationExecutionRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DeleteItemRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationEvent;
import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent;
@ -19,6 +21,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.StartComputationEx
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaEventType;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
@ -41,6 +44,7 @@ public class DataMinerManagerController {
private UserInfo userInfo;
private DataMinerWorkArea dataMinerWorkArea;
private List<OperatorsClassification> operatorsClassifications;
private MenuType currentVisualization;
public DataMinerManagerController() {
init();
@ -124,6 +128,17 @@ public class DataMinerManagerController {
}
});
EventBusProvider.INSTANCE.addHandler(MenuEvent.TYPE,
new MenuEvent.MenuEventHandler() {
@Override
public void onSelect(MenuEvent event) {
Log.debug("Catch MenuEvent:");
manageMenuEvent(event);
}
});
EventBusProvider.INSTANCE
.addHandler(
StartComputationExecutionRequestEvent.TYPE,
@ -210,6 +225,22 @@ public class DataMinerManagerController {
}
private void manageMenuEvent(MenuEvent event) {
if (event == null
|| event.getMenuType() == null
|| (currentVisualization == null && event.getMenuType()
.compareTo(MenuType.HOME) == 0)
|| (currentVisualization != null && event.getMenuType()
.compareTo(currentVisualization) == 0)) {
return;
}
currentVisualization = event.getMenuType();
MenuSwitchEvent menuSwitchEvent = new MenuSwitchEvent(
event.getMenuType());
EventBusProvider.INSTANCE.fireEvent(menuSwitchEvent);
}
private void startComputationRequest(
final StartComputationExecutionRequestEvent event) {
@ -441,39 +472,40 @@ public class DataMinerManagerController {
}
private void deleteItemRequest(final DeleteItemRequestEvent event) {
DataMinerPortletServiceAsync.INSTANCE
.deleteItem(event.getItemDescription(), new AsyncCallback<Void>() {
DataMinerPortletServiceAsync.INSTANCE.deleteItem(
event.getItemDescription(), new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
} else {
UtilsGXT3.alert("Error",
"Error deleting item on workspace: "
+ caught.getLocalizedMessage());
}
}
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
} else {
UtilsGXT3.alert("Error",
"Error deleting item on workspace: "
+ caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(Void result) {
Log.debug("Deleted Item!");
fireRefreshDataMinerWorkAreaEvent(event.getDataMinerWorkAreaElementType());
@Override
public void onSuccess(Void result) {
Log.debug("Deleted Item!");
fireRefreshDataMinerWorkAreaEvent(event
.getDataMinerWorkAreaElementType());
}
}
});
});
}
private void fireRefreshDataMinerWorkAreaEvent(
DataMinerWorkAreaElementType dataMinerWorkAreaElementType) {
RefreshDataMinerWorkAreaEvent refreshEvent=new RefreshDataMinerWorkAreaEvent(dataMinerWorkAreaElementType);
RefreshDataMinerWorkAreaEvent refreshEvent = new RefreshDataMinerWorkAreaEvent(
dataMinerWorkAreaElementType);
EventBusProvider.INSTANCE.fireEvent(refreshEvent);
}
}

View File

@ -3,8 +3,12 @@
*/
package org.gcube.portlets.user.dataminermanager.client;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager.MenuItem;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HorizontalPanel;
@ -16,18 +20,31 @@ import com.google.gwt.user.client.ui.Image;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public abstract class Header extends HorizontalPanel {
public abstract void select(MenuItem menuItem);
public class Header extends HorizontalPanel {
private Image menuGoBack, menuExperiment, menuDataSpace, menuComputations;
private MenuItem currentSelection = null;
private Enum<MenuType> currentSelection;
/**
*
*/
public Header() {
super();
create();
bind();
}
private void bind() {
EventBusProvider.INSTANCE.addHandler(MenuSwitchEvent.TYPE,
new MenuSwitchEvent.MenuSwitchEventHandler() {
@Override
public void onSelect(MenuSwitchEvent event) {
Log.debug("Catch MenuSwitchEvent");
menuSwitch(event);
}
});
}
private void create() {
// this.setStyleAttribute("background-color", "#FFFFFF");
Image logo = new Image(DataMinerManager.resources.logoLittle());
logo.setAltText("Data Miner Manager");
@ -39,8 +56,9 @@ public abstract class Header extends HorizontalPanel {
menuGoBack.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (setMenuSelected(null))
select(null);
MenuEvent menuEvent = new MenuEvent(MenuType.HOME);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
@ -50,8 +68,8 @@ public abstract class Header extends HorizontalPanel {
menuDataSpace.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (setMenuSelected(MenuItem.DATA_SPACE))
select(MenuItem.DATA_SPACE);
MenuEvent menuEvent = new MenuEvent(MenuType.DATA_SPACE);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
@ -61,8 +79,8 @@ public abstract class Header extends HorizontalPanel {
menuExperiment.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (setMenuSelected(MenuItem.EXPERIMENT))
select(MenuItem.EXPERIMENT);
MenuEvent menuEvent = new MenuEvent(MenuType.EXPERIMENT);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
@ -73,8 +91,8 @@ public abstract class Header extends HorizontalPanel {
@Override
public void onClick(ClickEvent event) {
if (setMenuSelected(MenuItem.COMPUTATIONS))
select(MenuItem.COMPUTATIONS);
MenuEvent menuEvent = new MenuEvent(MenuType.COMPUTATIONS);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
@ -99,57 +117,53 @@ public abstract class Header extends HorizontalPanel {
/**
* @param inputSpace
*/
public boolean setMenuSelected(MenuItem menuItem) {
// return true if the menu was changed
private void menuSwitch(MenuSwitchEvent event) {
Log.debug("MenuSwitch: " + event);
if (menuItem == currentSelection)
return false; // nothing to change
if (menuItem == null) {
if (event.getMenuType().compareTo(MenuType.HOME) == 0) {
menuGoBack.setVisible(false);
menuDataSpace.setVisible(false);
menuExperiment.setVisible(false);
menuComputations.setVisible(false);
if (currentSelection == MenuItem.EXPERIMENT)
if (currentSelection != null
&& currentSelection.compareTo(MenuType.EXPERIMENT) == 0)
menuExperiment.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.DATA_SPACE)
else if (currentSelection != null
&& currentSelection.compareTo(MenuType.DATA_SPACE) == 0)
menuDataSpace.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.COMPUTATIONS)
else if (currentSelection != null
&& currentSelection.compareTo(MenuType.COMPUTATIONS) == 0)
menuComputations.removeStyleName("menuItemImage-selected");
} else {
if (currentSelection == null) {
if (currentSelection == null
|| (currentSelection != null && currentSelection
.compareTo(MenuType.HOME) == 0)) {
menuGoBack.setVisible(true);
menuDataSpace.setVisible(true);
menuExperiment.setVisible(true);
menuComputations.setVisible(true);
}
if (currentSelection == MenuItem.EXPERIMENT)
if (currentSelection != null
&& currentSelection.compareTo(MenuType.EXPERIMENT) == 0)
menuExperiment.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.DATA_SPACE)
else if (currentSelection != null
&& currentSelection.compareTo(MenuType.DATA_SPACE) == 0)
menuDataSpace.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.COMPUTATIONS)
else if (currentSelection != null
&& currentSelection.compareTo(MenuType.COMPUTATIONS) == 0)
menuComputations.removeStyleName("menuItemImage-selected");
/*
* Image imgNew=menuExperiment;
*/
/*
* Image imgNew = (menuItem == MenuItem.DATA_SPACE ? menuDataSpace :
* menuExperiment);
*/
Image imgNew = (menuItem == MenuItem.DATA_SPACE ? menuDataSpace
: (menuItem == MenuItem.EXPERIMENT ? menuExperiment
Image imgNew = (event.getMenuType().compareTo(MenuType.DATA_SPACE) == 0 ? menuDataSpace
: (event.getMenuType().compareTo(MenuType.EXPERIMENT) == 0 ? menuExperiment
: menuComputations));
imgNew.addStyleName("menuItemImage-selected");
}
currentSelection = menuItem;
return true;
currentSelection = event.getMenuType();
return;
}
}

View File

@ -0,0 +1,130 @@
package org.gcube.portlets.user.dataminermanager.client;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer.HorizontalLayoutData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class HomePanel extends SimpleContainer {
public HomePanel() {
super();
init();
create();
}
private void init() {
setStylePrimaryName("smMenu");
//setBodyStyle("backgroundColor:white;");
addStyleName("smLayoutContainer");
//setHeaderVisible(false);
setBorders(false);
//setBodyBorder(false);
}
private void create() {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1,
new Margins(20, 90, 10, 90));
VerticalLayoutData layoutNext = new VerticalLayoutData(-1, -1,
new Margins(10, 90, 10, 90));
SimpleContainer itemDataSpace = createMenuItem(
"Access to the Data Space",
"The data space contains the set of input and output data sets of the users. It is possible to upload and share tables. Data sources can be chosen from those hosted by the infrastructure. Outputs of the computations can be even saved in this space.",
DataMinerManager.resources.inputSpaceIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MenuEvent menuEvent=new MenuEvent(MenuType.DATA_SPACE);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
lc.add(itemDataSpace, layoutTop);
SimpleContainer itemExperiment = createMenuItem(
"Execute an Experiment",
"This section allows to execute or prepare a Niche Modeling experiment. The section is endowed with a list of algorithms for training and executing statistical models for biological applications. Evaluation of the performances is possible by means of several kinds of measurement systems and processes.",
DataMinerManager.resources.executionIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MenuEvent menuEvent=new MenuEvent(MenuType.EXPERIMENT);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
lc.add(itemExperiment, layoutNext);
SimpleContainer itemComputations = createMenuItem(
"Check the Computations",
"This section allows to check the status of the computation. A list of processes launched by the user is shown along with meta-information. By clicking on the completed jobs it is possible to visualize the data set contents.",
DataMinerManager.resources.computationsIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MenuEvent menuEvent=new MenuEvent(MenuType.COMPUTATIONS);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
lc.add(itemComputations, layoutNext);
add(lc);
}
private SimpleContainer createMenuItem(String title, String description,
ImageResource imgResource, MouseDownHandler handle) {
HorizontalLayoutContainer horiz = new HorizontalLayoutContainer();
Image img = new Image(imgResource);
HTML text = new HTML("<b>" + title + "</b><br>" + description);
text.addStyleName("smMenuItemText");
HorizontalLayoutData textLayoutData = new HorizontalLayoutData(400,
140, new Margins(10, 5, 10, 10));
HorizontalLayoutData imgLayoutData = new HorizontalLayoutData(140, 140,
new Margins(10, 10, 10, 5));
horiz.add(text, textLayoutData);
horiz.add(img, imgLayoutData);
SimpleContainer container = new SimpleContainer();
container.addDomHandler(handle, MouseDownEvent.getType());
container.setWidth(540);
container.setHeight(160);
container.addStyleName("smMenuItem");
container.addStyleOnOver(container.getElement(), "smMenuItem:HOVER");
container.add(horiz);
return container;
}
}

View File

@ -0,0 +1,67 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Menu Event
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class MenuEvent extends
GwtEvent<MenuEvent.MenuEventHandler> {
public static Type<MenuEventHandler> TYPE = new Type<MenuEventHandler>();
private MenuType menuType;
public interface MenuEventHandler extends EventHandler {
void onSelect(MenuEvent event);
}
public interface HasMenuEventHandler extends HasHandlers {
public HandlerRegistration addMenuEventHandler(
MenuEventHandler handler);
}
public MenuEvent(
MenuType menuType) {
this.menuType = menuType;
}
@Override
protected void dispatch(MenuEventHandler handler) {
handler.onSelect(this);
}
@Override
public Type<MenuEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<MenuEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, MenuEvent event) {
source.fireEvent(event);
}
public MenuType getMenuType() {
return menuType;
}
@Override
public String toString() {
return "MenuEvent []";
}
}

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Menu Event
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class MenuSwitchEvent extends
GwtEvent<MenuSwitchEvent.MenuSwitchEventHandler> {
public static Type<MenuSwitchEventHandler> TYPE = new Type<MenuSwitchEventHandler>();
private MenuType menuType;
public interface MenuSwitchEventHandler extends EventHandler {
void onSelect(MenuSwitchEvent event);
}
public interface HasMenuSwitchEventHandler extends HasHandlers {
public HandlerRegistration addMenuSwitchEventHandler(
MenuSwitchEventHandler handler);
}
public MenuSwitchEvent(MenuType menuType) {
this.menuType = menuType;
}
@Override
protected void dispatch(MenuSwitchEventHandler handler) {
handler.onSelect(this);
}
@Override
public Type<MenuSwitchEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<MenuSwitchEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, MenuSwitchEvent event) {
source.fireEvent(event);
}
public MenuType getMenuType() {
return menuType;
}
@Override
public String toString() {
return "MenuSwitchEvent [menuType=" + menuType + "]";
}
}

View File

@ -138,7 +138,7 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar =new ProgressBar(cell);
progressBar.updateProgress(1, "Computation Complete");
progressBar.addStyleName("progressBar-complete");
vert.insert(progressBar, index);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
showOutput();
} else if (computationStatus.isFailed()) {
@ -160,7 +160,7 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar.updateProgress(1, "Computation Fail");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
progressBar.addStyleName("progressBar-failed");
vert.insert(progressBar, index);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
}
}
@ -212,7 +212,7 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar.updateProgress(1, "Failed to get the status");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
progressBar.addStyleName("progressBar-failed");
vert.insert(progressBar, index);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
}

View File

@ -0,0 +1,11 @@
package org.gcube.portlets.user.dataminermanager.client.type;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public enum MenuType {
HOME, DATA_SPACE, EXPERIMENT, COMPUTATIONS;
}

View File

@ -5,6 +5,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -26,7 +27,6 @@ import net.opengis.wps.x100.SupportedComplexDataInputType;
import net.opengis.wps.x100.impl.ExecuteResponseDocumentImpl;
import org.apache.xmlbeans.XmlString;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationItem;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus.Status;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
@ -40,6 +40,7 @@ import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource;
import org.gcube.portlets.user.dataminermanager.client.bean.parameters.ObjectParameter;
import org.gcube.portlets.user.dataminermanager.client.bean.parameters.Parameter;
import org.gcube.portlets.user.dataminermanager.server.is.InformationSystemUtils;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.ProcessInformations;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.ResponseWPS;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.StatWPSClientSession;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.WPS2SM;
@ -65,7 +66,7 @@ import org.w3c.dom.NodeList;
public class SClient4WPS extends SClient {
private static Logger logger = LoggerFactory.getLogger(SClient4WPS.class);
//private static final int OPERATOR_BRIEF_DESCRIPTION_MAX_LENGHT = 170;
// private static final int OPERATOR_BRIEF_DESCRIPTION_MAX_LENGHT = 170;
private static final String OTHERS = "OTHERS";
private String wpsToken;
@ -75,16 +76,17 @@ public class SClient4WPS extends SClient {
private String wpsCancelComputationServlet;
private ProcessDescriptionType[] processesDescriptionType;
private ProcessBriefType[] processBriefs;
private ProcessBriefType[] processesBriefs;
private ProcessDescriptionType currentProcessDescription;
private InputDescriptionType[] currentInputs;
private OutputDescriptionType[] currentOutputs;
private HashMap<String, ProcessInformations> process;
private HashMap<ComputationId, ProcessInformations> runningProcess;
private StatWPSClientSession wpsClient;
public SClient4WPS(ServiceCredential serviceCredential) throws Exception {
super();
process = new HashMap<>();
runningProcess = new HashMap<>();
if (serviceCredential == null) {
logger.error("Error credetials are null!");
throw new Exception("Error credetials are null!");
@ -157,12 +159,12 @@ public class SClient4WPS extends SClient {
LinkedHashMap<String, String> operatorsToCategoriesMap = new LinkedHashMap<>();
LinkedHashMap<String, List<Operator>> categoriesToOperatorsMap = new LinkedHashMap<>();
connect();
if (processBriefs == null || processesDescriptionType == null) {
requestCapability();
if (processesBriefs == null || processesDescriptionType == null) {
throw new ServiceException("Algorithms WPS not available!");
}
for (ProcessBriefType processBrief : processBriefs) {
for (ProcessBriefType processBrief : processesBriefs) {
String categoryTitle = processBrief.getTitle().getStringValue();
String categoryName;
if (categoryTitle == null || categoryTitle.isEmpty()) {
@ -251,12 +253,17 @@ public class SClient4WPS extends SClient {
return operatorsClass;
}
private void describeProcess(String processID) throws Exception {
describeProcess(processID, null);
private ProcessInformations describeProcess(String processId)
throws Exception {
return describeProcess(processId, null);
}
private void describeProcess(String processID, URL processDescriptionURL)
throws Exception {
private ProcessInformations describeProcess(String processId,
URL processDescriptionURL) throws Exception {
if (process.containsKey(processId)) {
return process.get(processId);
}
StatWPSClientSession wpsClient = null;
try {
wpsClient = createWPSClientSession();
@ -266,7 +273,7 @@ public class SClient4WPS extends SClient {
for (int k = 0; k <= 3; k++) {
try {
processDescription = wpsClient.getProcessDescription(
wpsProcessingServlet, processID);
wpsProcessingServlet, processId);
} catch (Exception e) {
logger.debug("Retrying with WPS URL: "
+ wpsProcessingServlet);
@ -276,7 +283,9 @@ public class SClient4WPS extends SClient {
if (processDescription != null)
break;
}
this.currentProcessDescription = processDescription;
ProcessInformations processInformations = new ProcessInformations(
processDescription);
if (processDescriptionURL != null)
processDescription.set(XmlString.Factory
@ -298,9 +307,12 @@ public class SClient4WPS extends SClient {
logger.debug("WPSClient->Output: " + output);
}
currentInputs = inputList;
currentOutputs = outputList;
processInformations.setInputs(inputList);
processInformations.setOutputs(outputList);
process.put(processId, processInformations);
return processInformations;
} catch (Exception e) {
e.printStackTrace();
throw e;
@ -309,10 +321,10 @@ public class SClient4WPS extends SClient {
}
}
private void connect() throws ServiceException {
private void requestCapability() throws ServiceException {
StatWPSClientSession wpsClient = null;
processesDescriptionType = null;
processBriefs = null;
processesBriefs = null;
try {
wpsClient = createWPSClientSession();
@ -325,7 +337,7 @@ public class SClient4WPS extends SClient {
CapabilitiesDocument capabilitiesDocument = wpsClient
.getWPSCaps(wpsProcessingServlet);
processBriefs = capabilitiesDocument.getCapabilities()
processesBriefs = capabilitiesDocument.getCapabilities()
.getProcessOfferings().getProcessArray();
return;
@ -340,14 +352,7 @@ public class SClient4WPS extends SClient {
}
private ProcessDescriptionType getProcessDescription() {
return currentProcessDescription;
}
private void setProcessDescription(ProcessDescriptionType processDescription) {
this.currentProcessDescription = processDescription;
}
private String executeProcessAsync(ExecuteRequestBuilder executeBuilder,
ProcessDescriptionType processDescription) throws Exception {
try {
@ -629,9 +634,11 @@ public class SClient4WPS extends SClient {
throws Exception {
try {
logger.info("Parameters of algorithm " + operator.getId());
ProcessInformations processInformations;
try {
describeProcess(operator.getId());
processInformations = describeProcess(operator
.getId());
} catch (Throwable e) {
logger.error("GetParameters: " + e.getLocalizedMessage());
e.printStackTrace();
@ -641,7 +648,7 @@ public class SClient4WPS extends SClient {
List<Parameter> parameters = new ArrayList<>();
Parameter inputParameter;
for (InputDescriptionType inputDesc : currentInputs) {
for (InputDescriptionType inputDesc : processInformations.getInputs()) {
inputParameter = WPS2SM.convert2SMType(inputDesc);
logger.debug("InputParameter: " + inputParameter);
parameters.add(inputParameter);
@ -663,10 +670,10 @@ public class SClient4WPS extends SClient {
public ComputationId startComputation(Operator operator,
String computationTitle, String computationDescription)
throws Exception {
// TODO Auto-generated method stub
ProcessInformations processInformations;
try {
describeProcess(operator.getId());
processInformations = describeProcess(operator
.getId());
} catch (Throwable e) {
logger.error("GetParameters: " + e.getLocalizedMessage());
e.printStackTrace();
@ -676,7 +683,7 @@ public class SClient4WPS extends SClient {
LinkedHashMap<String, Parameter> inputParameters = new LinkedHashMap<>();
Parameter inputParameter;
for (InputDescriptionType inputDesc : currentInputs) {
for (InputDescriptionType inputDesc : processInformations.getInputs()) {
inputParameter = WPS2SM.convert2SMType(inputDesc);
logger.debug("InputParameter: " + inputParameter);
inputParameters.put(inputParameter.getName(), inputParameter);
@ -690,7 +697,7 @@ public class SClient4WPS extends SClient {
+ parm.getValue());
}
String processUrl = compute(userInputs, inputParameters,
String processUrl = compute(processInformations, userInputs, inputParameters,
computationTitle, computationDescription);
logger.debug("Stated Computation ProcessLocation:" + processUrl);
@ -704,19 +711,21 @@ public class SClient4WPS extends SClient {
}
ComputationId computationId = new ComputationId(id, processUrl);
logger.debug("ComputationId: " + computationId);
runningProcess.put(computationId, processInformations);
return computationId;
}
private String compute(Map<String, String> userInputs,
private String compute(ProcessInformations processInformations, Map<String, String> userInputs,
Map<String, Parameter> inputParameters, String computationTitle,
String computationDescription) throws Exception {
try {
// setup the inputs
org.n52.wps.client.ExecuteRequestBuilder executeBuilder = new org.n52.wps.client.ExecuteRequestBuilder(
currentProcessDescription);
processInformations.getProcessDescription());
// for each input
for (InputDescriptionType input : currentInputs) {
for (InputDescriptionType input : processInformations.getInputs()) {
// retrieve the input from the sm config
String value = userInputs.get(input.getIdentifier()
.getStringValue());
@ -764,7 +773,7 @@ public class SClient4WPS extends SClient {
// Submit the execution
String statusLocation = executeProcessAsync(executeBuilder,
currentProcessDescription);
processInformations.getProcessDescription());
logger.debug("Starting Process: " + statusLocation);
return statusLocation;
@ -913,27 +922,27 @@ public class SClient4WPS extends SClient {
@Override
public Resource getResourceByComputationId(ComputationId computationId)
throws Exception {
Map<String, Resource> resources = retrieveOutput(computationId
.getUrlId());
Map<String, Resource> resources = retrieveOutput(computationId);
MapResource mapResource = new MapResource("mapResource", "Resources",
"Resources", resources);
return mapResource;
}
private Map<String, Resource> retrieveOutput(String processLocation)
private Map<String, Resource> retrieveOutput(ComputationId computationId)
throws Exception {
Map<String, Resource> outputResource = new LinkedHashMap<>();
Map<String, Parameter> outputParameters = new LinkedHashMap<>();
ProcessInformations processInformations=runningProcess.get(computationId);
Parameter outputParameter;
for (OutputDescriptionType outputDesc : currentOutputs) {
for (OutputDescriptionType outputDesc : processInformations.getOutputs()) {
outputParameter = WPS2SM.convert2SMType(outputDesc);
logger.debug("OutputParameter: " + outputParameter);
outputParameters.put(outputParameter.getName(), outputParameter);
}
retrieveProcessOutput(processLocation, outputParameters, outputResource);
retrieveProcessOutput(computationId.getUrlId(), outputParameters, outputResource);
return outputResource;
@ -1121,7 +1130,7 @@ public class SClient4WPS extends SClient {
@Override
public ComputationId resubmitComputation(ComputationId computationId)
throws Exception {
//TODO
// TODO
return null;
}

View File

@ -0,0 +1,65 @@
package org.gcube.portlets.user.dataminermanager.server.smservice.wps;
import java.io.Serializable;
import java.util.Arrays;
import net.opengis.wps.x100.InputDescriptionType;
import net.opengis.wps.x100.OutputDescriptionType;
import net.opengis.wps.x100.ProcessDescriptionType;
public class ProcessInformations implements Serializable {
private static final long serialVersionUID = 4729933672312944832L;
private ProcessDescriptionType processDescription;
private InputDescriptionType[] inputs;
private OutputDescriptionType[] outputs;
public ProcessInformations(ProcessDescriptionType processDescription) {
super();
this.processDescription = processDescription;
this.inputs = new InputDescriptionType[0];
this.outputs = new OutputDescriptionType[0];
}
public ProcessInformations(ProcessDescriptionType processDescription,
InputDescriptionType[] inputs, OutputDescriptionType[] outputs) {
super();
this.processDescription = processDescription;
this.inputs = inputs;
this.outputs = outputs;
}
public ProcessDescriptionType getProcessDescription() {
return processDescription;
}
public void setProcessDescription(
ProcessDescriptionType processDescription) {
this.processDescription = processDescription;
}
public InputDescriptionType[] getInputs() {
return inputs;
}
public void setInputs(InputDescriptionType[] inputs) {
this.inputs = inputs;
}
public OutputDescriptionType[] getOutputs() {
return outputs;
}
public void setOutputs(OutputDescriptionType[] outputs) {
this.outputs = outputs;
}
@Override
public String toString() {
return "ProcessInformations [processDescription="
+ processDescription + ", inputs="
+ Arrays.toString(inputs) + ", outputs="
+ Arrays.toString(outputs) + "]";
}
}

View File

@ -48,7 +48,7 @@
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />

View File

@ -32,7 +32,7 @@
.smMenu {
width: 720px !important;
height: 600px !important;
height: 570px !important;
margin: auto;
margin-bottom: 20px;
}