diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/DataMinerManager.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/DataMinerManager.java index 8772be3..7dce311 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/client/DataMinerManager.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/client/DataMinerManager.java @@ -11,37 +11,32 @@ import org.gcube.portlets.user.dataminermanager.client.experimentArea.Experiment import org.gcube.portlets.user.dataminermanager.client.resources.Resources; import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletService; import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync; +import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; import org.gcube.portlets.user.dataminermanager.shared.Constants; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import com.allen_sauer.gwt.log.client.Log; 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.dom.client.Style.Cursor; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseDownHandler; -import com.google.gwt.event.dom.client.MouseOverEvent; -import com.google.gwt.event.dom.client.MouseOverHandler; //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.core.client.util.Padding; -import com.sencha.gxt.widget.core.client.ContentPanel; 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.BoxLayoutContainer.BoxLayoutData; -import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; 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.VBoxLayoutContainer; -import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign; 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; @@ -100,13 +95,34 @@ public class DataMinerManager implements EntryPoint { // onModuleLoad2 Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { - loadMainPanel(); + loadScope(); } }); } - protected void loadMainPanel() { + private void loadScope() { + ClientScopeHelper.getService().setScope(Location.getHref(), + new AsyncCallback() { + @Override + public void onSuccess(Boolean result) { + if(result){ + loadMainPanel(); + } else { + UtilsGXT3.info("Attention", "ClientScopeHelper has returned a false value!"); + } + } + + @Override + public void onFailure(Throwable caught) { + UtilsGXT3.alert("Error", "Error setting scope: "+caught.getLocalizedMessage()); + caught.printStackTrace(); + } + }); + + } + + private void loadMainPanel() { // AccountingManagerResources.INSTANCE.accountingManagerCSS().ensureInjected(); // ScriptInjector.fromString(AccountingManagerResources.INSTANCE.jqueryJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); @@ -180,7 +196,7 @@ public class DataMinerManager implements EntryPoint { } - protected void bind(BorderLayoutContainer mainWidget) { + private void bind(BorderLayoutContainer mainWidget) { try { RootPanel root = RootPanel.get(SM_DIV); Log.info("Root Panel: " + root); @@ -280,11 +296,11 @@ public class DataMinerManager implements EntryPoint { topLc.setStylePrimaryName("smMenu"); topLc.addStyleName("smLayoutContainer"); VerticalLayoutContainer lc = new VerticalLayoutContainer(); - VerticalLayoutData layoutTop=new VerticalLayoutData(-1, -1, + VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1, new Margins(20, 90, 10, 90)); - VerticalLayoutData layoutNext=new VerticalLayoutData(-1, -1, + 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.", diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationOutputPanel.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationOutputPanel.java new file mode 100644 index 0000000..ea68cb6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationOutputPanel.java @@ -0,0 +1,302 @@ +/** + * + */ +package org.gcube.portlets.user.dataminermanager.client.experimentArea; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.gcube.portlets.user.dataminermanager.client.DataMinerManager; +import org.gcube.portlets.user.dataminermanager.client.bean.output.FileResource; +import org.gcube.portlets.user.dataminermanager.client.bean.output.ImagesResource; +import org.gcube.portlets.user.dataminermanager.client.bean.output.MapResource; +import org.gcube.portlets.user.dataminermanager.client.bean.output.ObjectResource; +import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource; +import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource.ResourceType; +import org.gcube.portlets.user.dataminermanager.client.bean.output.TableResource; +import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; +import org.gcube.portlets.user.dataminermanager.client.widgets.ImagesViewer; +import org.gcube.portlets.user.dataminermanager.client.widgets.ResourceViewer; +import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.sencha.gxt.core.client.XTemplates; +import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.widget.core.client.button.TextButton; +import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer; +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.event.SelectEvent; + +/** + * + * @author Giancarlo Panichi email: g.panichi@isti.cnr.it + * + */ +public class ComputationOutputPanel extends SimpleContainer { + + private ComputationId computationId; + private VerticalLayoutContainer v; + + public ComputationOutputPanel(ComputationId computationId) { + super(); + this.computationId = computationId; + Log.debug("ComputationOutputPanel"); + init(); + } + + private void init() { + v = new VerticalLayoutContainer(); + add(v); + + // request for a jobItem linked with the computationId (or jobId) + DataMinerManager.getService().getResourceByComputationId(computationId, + new AsyncCallback() { + @Override + public void onSuccess(Resource result) { + // unmask(); + showOutputInfo(result); + } + + @Override + public void onFailure(Throwable caught) { + Log.error("Error in getResourceByComputationId: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert( + "Error", + "Impossible to retrieve output info. " + + caught.getLocalizedMessage()); + + } + }); + + // this.mask("Loading Result Info..."); + } + + /** + * @param jobOutput + */ + private void showOutputInfo(Resource resource) { + try { + Log.info("Show Output Info on: " + resource); + if (resource == null) + return; + + ResourceType resourceType = resource.getResourceType(); + + switch (resourceType) { + + case FILE: + FileResource fileResource = (FileResource) resource; + v.add(getHtmlTitle("The algorithm produced a", "File"), new VerticalLayoutData(1, -1, + new Margins(0))); + v.add(getFileResourceOutput(fileResource), new VerticalLayoutData(1, -1, + new Margins(0))); + break; + + case TABULAR: + TableResource tabResource = (TableResource) resource; + v.add(getHtmlTitle("The algorithm produced a", "Table"), new VerticalLayoutData(1, -1, + new Margins(0))); + // v.add(getTabResourceOutput(tabResource)); + break; + + case IMAGES: + v.add(getHtmlTitle("The algorithm produced an", "Set of Images"), new VerticalLayoutData(1, -1, + new Margins(0))); + final ImagesResource imagesResource = (ImagesResource) resource; + v.add(getImagesResourceOutput(imagesResource), new VerticalLayoutData(1, -1, + new Margins(0))); + break; + + case MAP: + v.add(getHtmlTitle("The algorithm produced ", + "Multiple Results"), new VerticalLayoutData(1, -1, + new Margins(0))); + + final MapResource mapResource = (MapResource) resource; + + v.add(getMultipleOutput(mapResource), new VerticalLayoutData(1, + -1, new Margins(0))); + break; + case ERROR: + break; + case OBJECT: + break; + default: + break; + + } + + forceLayout(); + } catch (Throwable e) { + Log.error("Error in show output info: " + e.getLocalizedMessage()); + e.printStackTrace(); + } + } + + public interface TitleTemplate extends XTemplates { + @XTemplate("

{intro} {produced}.

") + SafeHtml getTemplate(String intro, String produced); + } + + /** + * @param string + * @return + */ + private HtmlLayoutContainer getHtmlTitle(String intro, String produced) { + TitleTemplate templates = GWT.create(TitleTemplate.class); + HtmlLayoutContainer c = new HtmlLayoutContainer(templates.getTemplate( + intro, produced)); + + return c; + } + + /** + * @param imagesResource + * @return + */ + private SimpleContainer getImagesResourceOutput( + ImagesResource imagesResource) { + SimpleContainer container = new SimpleContainer(); + container.add(new ImagesViewer(computationId, imagesResource)); + return container; + } + + /** + * + * @param fileResource + * @return + */ + private SimpleContainer getFileResourceOutput(FileResource fileResource) { + VerticalLayoutContainer lc = new VerticalLayoutContainer(); + SimpleContainer container = new SimpleContainer(); + final String fileName = fileResource.getName(); + final String fileUrl = fileResource.getUrl(); + HtmlLayoutContainer fileNameHtml = new HtmlLayoutContainer( + "

" + + new SafeHtmlBuilder().appendEscaped(fileName) + .toSafeHtml().asString() + "

"); + lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0))); + TextButton downloadBtn = new TextButton("Download File"); + downloadBtn.setIcon(DataMinerManager.resources.fileDownload()); + downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() { + @Override + public void onSelect(SelectEvent event) { + com.google.gwt.user.client.Window.open(fileUrl, fileName, ""); + + } + }); + + lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0))); + container.add(lc); + return container; + } + + /** + * @param map + * @return + */ + private SimpleContainer getMultipleOutput(MapResource mapResource) { + Map map = mapResource.getMap(); + VerticalLayoutContainer vp = new VerticalLayoutContainer(); + SimpleContainer container = new SimpleContainer(); + + Map mapValues = new LinkedHashMap<>(); + Map mapFiles = new LinkedHashMap<>(); + Map mapTabs = new LinkedHashMap<>(); + Map mapImages = new LinkedHashMap<>(); + + for (String key : map.keySet()) { + Resource resource = map.get(key); + ResourceType resourceType = resource.getResourceType(); + + switch (resourceType) { + case OBJECT: + mapValues.put(key, (ObjectResource) resource); + break; + case FILE: + mapFiles.put(key, (FileResource) resource); + break; + case TABULAR: + mapTabs.put(key, (TableResource) resource); + break; + case IMAGES: + mapImages.put(key, (ImagesResource) resource); + break; + case MAP: + break; + case ERROR: + break; + default: + break; + } + } + + if (mapValues.size() > 0) { + HtmlLayoutContainer html = new HtmlLayoutContainer("Output Values"); + html.setStyleName("computation-output-groupTitle"); + vp.add(html, new VerticalLayoutData(-1, -1, new Margins(0))); + + vp.add((new ResourceViewer(mapValues)).getHtml(), + new VerticalLayoutData(-1, -1, new Margins(0))); + + html = new HtmlLayoutContainer( + "
"); + vp.add(html); + } + + if (mapFiles.size() > 0) { + HtmlLayoutContainer html = new HtmlLayoutContainer("Files"); + html.setStyleName("computation-output-groupTitle"); + vp.add(html, new VerticalLayoutData(-1, -1, new Margins(0))); + + for (String fileKey : mapFiles.keySet()) { + // vp.add(new Html(""+fileKey+"")); + vp.add(getFileResourceOutput(mapFiles.get(fileKey)), + new VerticalLayoutData(-1, -1, new Margins(0))); + } + + html = new HtmlLayoutContainer( + "
"); + vp.add(html, new VerticalLayoutData(-1, -1, new Margins(0))); + } + + if (mapTabs.size() > 0) { + HtmlLayoutContainer html = new HtmlLayoutContainer("Tables"); + html.setStyleName("computation-output-groupTitle"); + vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0))); + + for (String tabKey : mapTabs.keySet()) { + // vp.add(new Html(""+tabKey+"")); + // vp.add(getTabResourceOutput(mapTabs.get(tabKey))); + } + + html = new HtmlLayoutContainer("
"); + vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0))); + } + + if (mapImages.size() > 0) { + HtmlLayoutContainer html = new HtmlLayoutContainer("Images"); + html.setStyleName("computation-output-groupTitle"); + vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0))); + + for (String imagesKey : mapImages.keySet()) { + // vp.add(new Html(""+imagesKey+"")); + vp.add(getImagesResourceOutput(mapImages.get(imagesKey))); + } + + html = new HtmlLayoutContainer("
"); + vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0))); + } + + container.add(vp); + return container; + } +} diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationStatusPanel.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationStatusPanel.java index d50bfd6..5ad6686 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationStatusPanel.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/client/experimentArea/ComputationStatusPanel.java @@ -12,32 +12,16 @@ import org.gcube.portlets.user.dataminermanager.client.bean.Operator; import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider; import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent; import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; -import org.gcube.portlets.user.dataminermanager.client.widgets.ComputationOutputPanel; import org.gcube.portlets.user.dataminermanager.shared.Constants; import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId; import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException; import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.i18n.client.NumberFormat; -import com.google.gwt.resources.client.ClientBundle; -import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.resources.client.ClientBundle.Source; -import com.google.gwt.resources.client.ImageResource.ImageOptions; -import com.google.gwt.resources.client.ImageResource.RepeatStyle; -import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.HTML; -import com.sencha.gxt.cell.core.client.ProgressBarCell; -import com.sencha.gxt.cell.core.client.ProgressBarCell.ProgressBarAppearanceOptions; import com.sencha.gxt.core.client.util.Margins; -import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance; -import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance.ProgressBarResources; -import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance.ProgressBarStyle; -import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance.ProgressBarTemplate; -import com.sencha.gxt.theme.blue.client.progress.BlueProgressBarAppearance.BlueProgressBarResources; import com.sencha.gxt.widget.core.client.ProgressBar; import com.sencha.gxt.widget.core.client.button.TextButton; import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer; @@ -56,19 +40,6 @@ import com.sencha.gxt.widget.core.client.info.Info; */ public class ComputationStatusPanel extends SimpleContainer { - /* - private class ProgressBarColoredAppearance extends ProgressBarDefaultAppearance { - - public ProgressBarColoredAppearance(ProgressBarResources resources, - ProgressBarTemplate template) { - super(resources, template); - // TODO Auto-generated constructor stub - } - - }*/ - - - private ProgressBar progressBar; private ComputationId computationId; private Operator operator; @@ -141,7 +112,6 @@ public class ComputationStatusPanel extends SimpleContainer { public void computationStarted(ComputationId computationId) { this.computationId = computationId; vert.add(new HtmlLayoutContainer("

Created, the id is "+computationId.getId()+" [link]

")); - //progressBar.getElement().getStyle().setMargin(20, Unit.PX); progressBar = new ProgressBar(); progressBar.updateProgress(0, "Starting..."); vert.add(progressBar,new VerticalLayoutData(1, -1, new Margins(20))); @@ -212,9 +182,6 @@ public class ComputationStatusPanel extends SimpleContainer { } else if (computationStatus.isFailed()) { Log.debug("Computation is Failed"); -// Info.display("Failed", "The computation of "+operator.getName()+" has failed."); -// MessageBox.alert("Failed", "The computation "+computationId+" of "+operator.getName()+" has failed.
" -// +"Message: "+computationStatus.getMessage(), null); String errorMessage; if(computationStatus.getErrResource()==null||computationStatus.getErrResource().getDescription()==null ){ errorMessage=new String("Computation Failed!"); @@ -223,11 +190,11 @@ public class ComputationStatusPanel extends SimpleContainer { } UtilsGXT3.alert("Failed", "The computation "+computationId.getId()+" of "+operator.getName()+" has failed.
" - +"Message: "+errorMessage, null); + +"Message: "+errorMessage); progressBar.updateProgress(1, "Computation Fail"); progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX); progressBar.addStyleName("progressBar-failed"); -// + } } @@ -239,11 +206,11 @@ public class ComputationStatusPanel extends SimpleContainer { * */ private void showOutput() { - HtmlLayoutContainer computationEndMessage=new HtmlLayoutContainer("

The computation "+operator.getName()+" finished.

"); + HtmlLayoutContainer computationEndMessage=new HtmlLayoutContainer("

The computation "+operator.getName()+" finished.

"); vert.add(computationEndMessage, new VerticalLayoutData(-1, -1, new Margins(0))); ComputationOutputPanel computationOutputPanel = new ComputationOutputPanel(computationId); computationOutputPanel.getElement().getStyle().setMarginBottom(36, Unit.PX); - vert.add(computationOutputPanel, new VerticalLayoutData(-1, -1, new Margins(0))); + vert.add(computationOutputPanel, new VerticalLayoutData(1, -1, new Margins(0))); } @@ -264,13 +231,9 @@ public class ComputationStatusPanel extends SimpleContainer { private class ComputationTimer extends Timer { - /* (non-Javadoc) - * @see com.google.gwt.user.client.Timer#run() - */ @Override public void run() { Log.debug("Timer run ....."); -// final ComputationStatusPanel cp = ComputationStatusPanel.this; DataMinerManager.getService().getComputationStatus(computationId, new AsyncCallback() { @Override @@ -278,9 +241,6 @@ public class ComputationStatusPanel extends SimpleContainer { progressBar.updateProgress(1, "Failed to get the status"); progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX); progressBar.addStyleName("progressBar-failed"); -// MessageBox.alert("Error", ""+caught.getLocalizedMessage()+"\nCause: "+caught.getCause()+"\nStackTrace: "+caught.getStackTrace().toString(), null); -// computationTerminated(computationId, operator, TerminationMode.FAILED2); -// ComputationTimer.this.cancel(); } @Override diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ComputationOutputPanel.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ComputationOutputPanel.java deleted file mode 100644 index 7a281a6..0000000 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ComputationOutputPanel.java +++ /dev/null @@ -1,283 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.dataminermanager.client.widgets; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.gcube.portlets.user.dataminermanager.client.DataMinerManager; -import org.gcube.portlets.user.dataminermanager.client.bean.output.FileResource; -import org.gcube.portlets.user.dataminermanager.client.bean.output.ImagesResource; -import org.gcube.portlets.user.dataminermanager.client.bean.output.MapResource; -import org.gcube.portlets.user.dataminermanager.client.bean.output.ObjectResource; -import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource; -import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource.ResourceType; -import org.gcube.portlets.user.dataminermanager.client.bean.output.TableResource; -import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync; -import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; -import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.HTML; -import com.sencha.gxt.widget.core.client.button.TextButton; -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.event.SelectEvent; - -/** - * @author ceras - * - */ -public class ComputationOutputPanel extends SimpleContainer { - - private ComputationId computationId; - private final DataMinerPortletServiceAsync service = DataMinerManager.getService(); - private VerticalLayoutContainer v; - - public ComputationOutputPanel(ComputationId computationId) { - super(); - this.computationId = computationId; - init(); - } - - private void init() { - v = new VerticalLayoutContainer(); - add(v); - - // request for a jobItem linked with the computationId (or jobId) - service.getResourceByComputationId(computationId, - new AsyncCallback() { - @Override - public void onSuccess(Resource result) { - unmask(); - showOutputInfo(result); - } - - @Override - public void onFailure(Throwable caught) { - unmask(); - UtilsGXT3.alert("Error", - "Impossible to retrieve output info.", null); - } - }); - - this.mask("Loading Result Info..."); - } - - /** - * @param jobOutput - */ - protected void showOutputInfo(Resource resource) { - if (resource == null) - return; - - ResourceType resourceType = resource.getResourceType(); - - switch (resourceType) { - - case FILE: - FileResource fileResource = (FileResource) resource; - v.add(getHtmlTitle("The algorithm produced a File.")); - v.add(getFileResourceOutput(fileResource)); - break; - - case TABULAR: - TableResource tabResource = (TableResource) resource; - v.add(getHtmlTitle("The algorithm produced a Table.")); - // v.add(getTabResourceOutput(tabResource)); - break; - - case IMAGES: - v.add(getHtmlTitle("The algorithm produced an Set of Images.")); - final ImagesResource imagesResource = (ImagesResource) resource; - v.add(getImagesResourceOutput(imagesResource)); - break; - - case MAP: - v.add(getHtmlTitle("The algorithm produced Multiple Results.")); - - final MapResource mapResource = (MapResource) resource; - - v.add(getMultipleOutput(mapResource)); - break; - case ERROR: - break; - case OBJECT: - break; - default: - break; - - } - - this.add(new HTML("
")); - forceLayout(); - } - - /** - * @param string - * @return - */ - private HTML getHtmlTitle(String title) { - HTML html = new HTML(title); - html.setStyleName("jobViewer-output-outputType"); - return html; - } - - /** - * @param imagesResource - * @return - */ - private SimpleContainer getImagesResourceOutput( - ImagesResource imagesResource) { - SimpleContainer container = new SimpleContainer(); - container.add(new ImagesViewer(computationId, imagesResource)); - return container; - } - - /** - * @param tabResource - * - * private LayoutContainer getTabResourceOutput(TableResource - * tabResource) { final String tableName = tabResource.getName(); - * final String tableId = tabResource.getResourceId(); - * LayoutContainer lc = new LayoutContainer(); lc.add(new - * Html("Data Set Created: " + tableName + "
- *
- * ")); - * - * lc.add(new Button("Show Data Set", Images.table(), new - * SelectionListener() { - * @Override public void componentSelected(ButtonEvent ce) { final - * TabularData tabularData = DataMinerManager .getTabularData(); - * TabularDataGridPanel grid = tabularData.getGridPanel(); - * grid.setHeaderVisible(false); Window window = new Window(); - * window.setMaximizable(true); window.setHeadingText("Data Set " - * + tableName); window.setModal(true); window.add(grid); - * window.setWidth(900); window.setHeight(500); - * tabularData.openTable(tableId); window.show(); } })); return - * lc; } - */ - - /** - * @param fileResource - * @return - */ - private SimpleContainer getFileResourceOutput(FileResource fileResource) { - VerticalLayoutContainer lc = new VerticalLayoutContainer(); - SimpleContainer container = new SimpleContainer(); - final String fileName = fileResource.getName(); - final String fileUrl = fileResource.getUrl(); - lc.add(new HTML(fileName)); - TextButton downloadBtn = new TextButton("Download File"); - downloadBtn.setIcon(DataMinerManager.resources.fileDownload()); - downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() { - @Override - public void onSelect(SelectEvent event) { - com.google.gwt.user.client.Window.open(fileUrl, fileName, ""); - - } - }); - - lc.add(downloadBtn); - container.add(lc); - return container; - } - - /** - * @param map - * @return - */ - private SimpleContainer getMultipleOutput(MapResource mapResource) { - Map map = mapResource.getMap(); - VerticalLayoutContainer vp = new VerticalLayoutContainer(); - SimpleContainer container = new SimpleContainer(); - - Map mapValues = new LinkedHashMap<>(); - Map mapFiles = new LinkedHashMap<>(); - Map mapTabs = new LinkedHashMap<>(); - Map mapImages = new LinkedHashMap<>(); - - for (String key : map.keySet()) { - Resource resource = map.get(key); - ResourceType resourceType = resource.getResourceType(); - - switch (resourceType) { - case OBJECT: - mapValues.put(key, (ObjectResource) resource); - break; - case FILE: - mapFiles.put(key, (FileResource) resource); - break; - case TABULAR: - mapTabs.put(key, (TableResource) resource); - break; - case IMAGES: - mapImages.put(key, (ImagesResource) resource); - break; - case MAP: - break; - case ERROR: - break; - default: - break; - } - } - - if (mapValues.size() > 0) { - HTML html = new HTML("Output Values"); - html.setStyleName("jobViewer-output-groupTitle"); - vp.add(html); - - vp.add((new ResourceViewer(mapValues)).getHtml()); - - html = new HTML("
"); - vp.add(html); - } - - if (mapFiles.size() > 0) { - HTML html = new HTML("Files"); - html.setStyleName("jobViewer-output-groupTitle"); - vp.add(html); - - for (String fileKey : mapFiles.keySet()) { - // vp.add(new Html(""+fileKey+"")); - vp.add(getFileResourceOutput(mapFiles.get(fileKey))); - } - - html = new HTML("
"); - vp.add(html); - } - - if (mapTabs.size() > 0) { - HTML html = new HTML("Tables"); - html.setStyleName("jobViewer-output-groupTitle"); - vp.add(html); - - for (String tabKey : mapTabs.keySet()) { - // vp.add(new Html(""+tabKey+"")); - // vp.add(getTabResourceOutput(mapTabs.get(tabKey))); - } - - html = new HTML("
"); - vp.add(html); - } - - if (mapImages.size() > 0) { - HTML html = new HTML("Images"); - html.setStyleName("jobViewer-output-groupTitle"); - vp.add(html); - - for (String imagesKey : mapImages.keySet()) { - // vp.add(new Html(""+imagesKey+"")); - vp.add(getImagesResourceOutput(mapImages.get(imagesKey))); - } - - html = new HTML("
"); - vp.add(html); - } - - container.add(vp); - return container; - } -} diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ImagesViewer.java b/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ImagesViewer.java index fb864de..7719f60 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ImagesViewer.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/client/widgets/ImagesViewer.java @@ -8,11 +8,13 @@ import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId; 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.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.widget.core.client.button.TextButton; +import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer; 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.event.SelectEvent; /** @@ -47,9 +49,10 @@ public class ImagesViewer extends SimpleContainer { add(v); if (imagesResource == null || imagesResource.getLink() == null || imagesResource.getLink().isEmpty()) - v.add(new HTML("No image found.")); + v.add(new HtmlLayoutContainer("No image found."), new VerticalLayoutData(-1, -1, + new Margins(0))); else { - v.add(new HTML(imagesResource.getName())); + v.add(new HtmlLayoutContainer(imagesResource.getName()),new VerticalLayoutData(-1, -1, new Margins(0))); TextButton saveImageBtn = new TextButton( "Save image on the Workspace"); saveImageBtn.setIcon(DataMinerManager.resources.save()); @@ -62,9 +65,9 @@ public class ImagesViewer extends SimpleContainer { } }); - v.add(saveImageBtn); + v.add(saveImageBtn,new VerticalLayoutData(-1, -1, new Margins(0))); final Image img = new Image(imagesResource.getLink()); - v.add(img); + v.add(img,new VerticalLayoutData(-1, -1, new Margins(0))); } forceLayout(); diff --git a/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java b/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java index 76f3219..eedd076 100644 --- a/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/dataminermanager/server/DataMinerManagerServiceImpl.java @@ -44,6 +44,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.user.server.rpc.RemoteServiceServlet; /** @@ -236,41 +237,19 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements @Override public Resource getResourceByComputationId(ComputationId computationId) { try { + Log.debug("getResourceByComputationId: "+computationId); HttpSession session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getASLSession(session); SClient smClient = SessionUtil.getSClient(session, aslSession); - return smClient.getResourceByComputationId(computationId); - - // SMComputation computation = factory.getComputation(jobId); - // JobItem jobItem = convertSMComputationToJobItem(computation, - // true); - // - // // try to add map data (if resource is an object) - // - // Resource res = jobItem.getResource(); - // if (res.isMap()) { - // MapResource mapResource = (MapResource) res; - // Map map = getMapFromMapResource(mapResource); - // mapResource.setMap(map); - // // jobItem.setMapData(map); - // logger.info("getResourceByJobId: " + mapResource); - // - // } else if (res.isImages()) { - // ImagesResource imgsRes = (ImagesResource) res; - // Map map = - // getImagesInfoFromImagesResource(imgsRes); - // imgsRes.setMapImages(map); - // logger.info("getResourceByJobId: " + imgsRes); - // } else { - // logger.info("getResourceByJobId: " + res); - // } - // return res; - + Resource resource= smClient.getResourceByComputationId(computationId); + Log.debug("Resoure: "+resource); + return resource; + } catch (Exception e) { logger.error("Error in getResourceByComputationId: " - + e.getLocalizedMessage());// in this case the resource - // doesn't exist, nothing to do + + e.getLocalizedMessage()); + e.printStackTrace(); return null; } diff --git a/src/main/webapp/DataMinerManager.css b/src/main/webapp/DataMinerManager.css index 092dbb9..c1a0341 100644 --- a/src/main/webapp/DataMinerManager.css +++ b/src/main/webapp/DataMinerManager.css @@ -1,4 +1,4 @@ -.smLayoutContainer { +.smLayoutContainer { /* Blue box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.11), 0 0 0 rgba(255, 255, 255, 1), 0 0 5px rgba(0, 28, 121, 1), 0px 0 40px @@ -12,8 +12,6 @@ -o-box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.11), 0 0 0 rgba(255, 255, 255, 1), 0 0 5px rgba(0, 28, 121, 1), 71px 0 27px rgba(0, 28, 121, 0.15);*/ - - box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.11), 0 0 0 rgba(255, 255, 255, 1), 0 0 5px rgba(196, 196, 196, 1), 0px 0 27px rgba(0, 0, 0, 0.15); @@ -238,9 +236,6 @@ margin-right: 5px;*/ } - - - .workflow-icon { border: 1px solid black; float: left; @@ -256,13 +251,11 @@ color: #000077; } - .workflow-description { font-size: 13px; color: #505050; } - .workflow-fieldDescription { font-size: 12px; color: #505050; @@ -280,8 +273,6 @@ margin-top: 4px; } - - .workflow-parameters-tableDescription { font-size: 12px; /* border: 1px solid gray;*/ @@ -332,7 +323,6 @@ vertical-align: middle; } - .menuImgLogo:HOVER { /* cursor: pointer;*/ @@ -355,17 +345,15 @@ cursor: auto; } - /* * Computation Execution */ .computationExcecutionPanel { - font-size: 13px; + font-size: 12px; color: black; - } -.computationStatusPanel{ +.computationStatusPanel { border: 1px solid black; padding: 10px; } @@ -378,12 +366,9 @@ } - /** * ProgressBar */ - - .progressBar-pending { border: 1px solid #AAAAAA; } @@ -402,26 +387,25 @@ background-image: url("images/progress-red.gif"); } - .progressBar-complete .progressWrap { - border-color:#00AA00; + border-color: #00AA00; } .progressBar-complete .progressInner { - background-color:#bdefbd; - background-image: url("images/bg-progress.gif"); - height: auto; + background-color: #bdefbd; + background-image: url("images/bg-progress.gif"); + height: auto; } .progressBar-complete .progressBar { - background-color:#4ec14e; - background-image: url("images/green-progress.gif"); - background-repeat: repeat-x; - background-position: left center; - height: 18px; - border-top-color:#d1fdda; - border-bottom-color:#7fe48a; - border-right-color:#7fe48a; + background-color: #4ec14e; + background-image: url("images/green-progress.gif"); + background-repeat: repeat-x; + background-position: left center; + height: 18px; + border-top-color: #d1fdda; + border-bottom-color: #7fe48a; + border-right-color: #7fe48a; } /* @@ -435,7 +419,39 @@ * background-image: url("images/progress-green.gif"); *} */ +/** +* Computation Output +*/ +.computation-output-outputType { + background-color: #EEEEEE; + border: 1px solid #BDBDBD; + /*font-weight: bold;*/ + padding: 5px; + text-align: center; + margin-top: 20px; + margin-bottom: 10px; +} + +.computation-output-groupTitle { + font-style: italic; + font-weight: bold; + margin-top: 5px; + margin-bottom: 5px; +} + +.computation-output-separator { + border-top: 2px solid #AAAAAA; + margin-top: 8px; + margin-bootm: 8px; + + /* height: 30px; + margin: 8px auto auto; + width: 400px; + */ +} - - +.computation-output-fileName{ + margin-top:2px; + margin-bottom:2px; +} \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 504060d..49e75f6 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -27,7 +27,7 @@ DownloadService /dataminermanager/DownloadService - + workspaceExplorer @@ -68,6 +68,17 @@ + + scopeService + org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl + + + + scopeService + /dataminermanager/scopeService + + + DataMinerManager.html