From 01acfe16d498181b0b6d9b55b7851885b691080f Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 20 Jan 2016 08:51:24 +0000 Subject: [PATCH] 1452: Implement a GUI for StatMan Algorithms Importer Task-Url: https://support.d4science.org/issues/1452 Added Wiki Link git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122332 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/StatAlgoImporterController.java | 72 +++++++++++++------ .../resource/StatAlgoImporterResources.java | 5 ++ .../client/resource/WikiLink.txt | 1 + .../client/resource/WikiLink.txt | 1 + 4 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt create mode 100644 src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java index b4c8a54..1bd6a15 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java @@ -11,6 +11,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.Sessio import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.project.ProjectManager; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.SessionExpiredType; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.StatAlgoImporterRibbonType; @@ -26,8 +27,12 @@ import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.i18n.client.LocaleInfo; +import com.google.gwt.resources.client.ResourceCallback; +import com.google.gwt.resources.client.ResourceException; +import com.google.gwt.resources.client.TextResource; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer; @@ -135,7 +140,8 @@ public class StatAlgoImporterController { String currentLocaleCookie = Cookies.getCookie(LocaleInfo .getLocaleCookieName()); - Log.debug(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE + ":" + currentLocaleCookie); + Log.debug(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE + ":" + + currentLocaleCookie); LocaleInfo currentLocaleInfo = LocaleInfo.getCurrentLocale(); Log.debug("Current Locale:" + currentLocaleInfo.getLocaleName()); @@ -147,11 +153,13 @@ public class StatAlgoImporterController { long nowLong = now.getTime(); nowLong = nowLong + (1000 * 60 * 60 * 24 * 21); now.setTime(nowLong); - String cookieLang = Cookies.getCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE); + String cookieLang = Cookies + .getCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE); if (cookieLang != null) { Cookies.removeCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE); } - Cookies.setCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE, localeName, now); + Cookies.setCookie(Constants.STATISTICAL_ALGORITHMS_IMPORTER_COOKIE, + localeName, now); com.google.gwt.user.client.Window.Location.reload(); } @@ -161,9 +169,9 @@ public class StatAlgoImporterController { String value = com.google.gwt.user.client.Window.Location .getParameter(Constants.STATISTICAL_ALGORITHMS_IMPORTER_ID); - + pm.startProjectManager(value); - + } // Bind Controller to events on bus @@ -224,18 +232,17 @@ public class StatAlgoImporterController { } }); - + eventBus.addHandler(NewMainCodeEvent.TYPE, new NewMainCodeEvent.NewMainCodeEventHandler() { - + @Override public void onSet(NewMainCodeEvent event) { Log.debug("Catch SaveNewMainCodeEvent"); doSetNewMainCodeEvent(event); - + } - }); pm.startProjectManager(); @@ -269,6 +276,7 @@ public class StatAlgoImporterController { softwarePublish(); break; case HELP: + showHelp(); break; default: break; @@ -276,7 +284,32 @@ public class StatAlgoImporterController { } } - + private void showHelp() { + + try { + StatAlgoImporterResources.INSTANCE.wikiLink().getText( + new ResourceCallback() { + public void onError(ResourceException e) { + Log.error("Error retrieving wiki link!: " + + e.getLocalizedMessage()); + UtilsGXT3.alert("Error", + "Error retrieving wiki link!"); + } + + public void onSuccess(TextResource r) { + String s = r.getText(); + Window.open(s, + "Statistical Algorithms Importer Wiki", ""); + } + }); + } catch (ResourceException e) { + Log.error("Error retrieving wiki link!: " + e.getLocalizedMessage()); + UtilsGXT3.alert("Error", "Error retrieving wiki link!"); + e.printStackTrace(); + + } + + } private void doInputReadyCommand(InputReadyEvent event) { switch (inputRequestType) { @@ -308,15 +341,12 @@ public class StatAlgoImporterController { eventBus.fireEvent(inputRequestEvent); Log.debug("SoftwareCreateRequest: " + inputRequestEvent); } - - + private void softwarePublish() { pm.softwarePublish(); - + } - - - + private void showCreateProjectDialog() { pm.createProject(); @@ -338,14 +368,12 @@ public class StatAlgoImporterController { } } - - private void doSetNewMainCodeEvent( - NewMainCodeEvent event) { + + private void doSetNewMainCodeEvent(NewMainCodeEvent event) { monitor = new StatAlgoImporterMonitor(); - pm.setNewMainCode(event,monitor); - + pm.setNewMainCode(event, monitor); + } - private void doDeleteItemCommand(DeleteItemEvent event) { ItemDescription itemDescription = event.getItemDescription(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java index 865f287..c7cf4e9 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java @@ -5,6 +5,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource; import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ExternalTextResource; import com.google.gwt.resources.client.ImageResource; /** @@ -21,6 +22,10 @@ public interface StatAlgoImporterResources extends ClientBundle { @Source("StatAlgoImporter.css") StatAlgoImporterCSS srCSS(); + @Source("WikiLink.txt") + ExternalTextResource wikiLink(); + + @Source("help_32.png") ImageResource help32(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt new file mode 100644 index 0000000..91ee0ce --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt @@ -0,0 +1 @@ +http://wiki.gcube-system.org/gcube/Statistical_Algorithms_Importer \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt b/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt new file mode 100644 index 0000000..91ee0ce --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/WikiLink.txt @@ -0,0 +1 @@ +http://wiki.gcube-system.org/gcube/Statistical_Algorithms_Importer \ No newline at end of file