You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/06/20 06:45:36 UTC

[isis] branch master updated: ISIS-2376: properly disables actions, that are not applicable for the current mode selected (2)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new b1d5984  ISIS-2376: properly disables actions, that are not applicable for the current mode selected (2)
b1d5984 is described below

commit b1d59847bf746fce6c7ae3793f900d10d07eef3f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Jun 20 08:45:19 2020 +0200

    ISIS-2376: properly disables actions, that are not applicable for the
    current mode selected (2)
---
 .../core/runtimeservices/i18n/po/TranslationServicePo.java   | 12 ++++++++----
 .../runtimeservices/i18n/po/TranslationServicePoMenu.java    | 12 +++++++++---
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java
index 193dcbc..8ac2942 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.isis.core.runtimeservices.i18n.po;
 
+import java.util.Optional;
+
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
@@ -38,6 +40,8 @@ import org.apache.isis.core.commons.internal.base._Lazy;
 import org.apache.isis.core.commons.internal.environment.IsisSystemEnvironment;
 import org.apache.isis.core.config.IsisConfiguration;
 
+import lombok.val;
+
 @Service
 @Named("isisRuntimeServices.TranslationServicePo")
 @Order(OrderPrecedence.MIDPOINT)
@@ -116,13 +120,13 @@ public class TranslationServicePo implements TranslationService {
     /**
      * Not API
      */
-    public String toPot() {
+    public Optional<String> toPot() {
         if (!getMode().isWrite()) {
-            return null;
+            return Optional.empty();
         }
-        StringBuilder buf = new StringBuilder();
+        val buf = new StringBuilder();
         ((PoWriter)po).toPot(buf);
-        return buf.toString();
+        return Optional.of(buf.toString());
     }
 
 
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java
index 3d4dc9f..73660c1 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/i18n/po/TranslationServicePoMenu.java
@@ -60,13 +60,19 @@ public class TranslationServicePoMenu {
     public Clob downloadTranslations(
             @ParameterLayout(named = ".pot file name")
             final String potFileName) {
-        final String chars = translationService.toPot();
-        return new Clob(Util.withSuffix(potFileName, "pot"), "text/plain", chars);
+        
+        return translationService.toPot()
+                .map(chars->new Clob(Util.withSuffix(potFileName, "pot"), "text/plain", chars))
+                .orElse(null);
     }
-
     public String default0DownloadTranslations() {
         return "translations.pot";
     }
+    public String disableDownloadTranslations() {
+        return !translationService.getMode().isWrite()
+                ? notAvailableForCurrentMode()
+                : null;
+    }
 
     // //////////////////////////////////////