changeset 1515:0bec8e87f180

Desktop sortcuts name is now based on title. And only if missing, then on file * netx/net/sourceforge/jnlp/JNLPFile.java: new method of createNameForDesktopFile, which returns title if it is present, jnlp file name otherwise. * netx/net/sourceforge/jnlp/util/XDesktopEntry.java: getGeneratedJnlpFileName and getDesktopIconName now uses * NEWS: mentioned
author Jiri Vanek <jvanek@redhat.com>
date Mon, 25 Feb 2019 13:55:44 +0100
parents 9abf341f758f
children a43eeeeafe53
files ChangeLog NEWS netx/net/sourceforge/jnlp/JNLPFile.java netx/net/sourceforge/jnlp/util/XDesktopEntry.java
diffstat 4 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Feb 25 13:54:27 2019 +0100
+++ b/ChangeLog	Mon Feb 25 13:55:44 2019 +0100
@@ -1,3 +1,11 @@
+2019-02-07  Jiri Vanek <jvanek@redhat.com>
+
+	Desktop sortcuts name is now based on title. And only if missing, then on file
+	* netx/net/sourceforge/jnlp/JNLPFile.java: new method of createNameForDesktopFile, which
+	returns title if it is present, jnlp file name otherwise.
+	* netx/net/sourceforge/jnlp/util/XDesktopEntry.java: getGeneratedJnlpFileName and getDesktopIconName now uses 
+	* NEWS: mentioned
+
 2019-02-06  Jiri Vanek <jvanek@redhat.com>
 
 	Delete-by app dialogue split keys to two groups instead of mixing them
--- a/NEWS	Mon Feb 25 13:54:27 2019 +0100
+++ b/NEWS	Mon Feb 25 13:55:44 2019 +0100
@@ -16,6 +16,7 @@
 * deployment.config now support generic url instead just file
 * Added support for windows desktop shortcuts via https://github.com/DmitriiShamrikov/mslinks
 * cache can now be operated by groups, list by -Xcacheids (details via -verbose, can filter by regex), Xclearcache now can clear only selected id. There is also gui to operate cache via id in itweb-settings now.
+* desktop shortcut name get shortened to title or file if title is missing.
 
 New in release 1.7.1 (2017-12-15):
 * better work with authors file
--- a/netx/net/sourceforge/jnlp/JNLPFile.java	Mon Feb 25 13:54:27 2019 +0100
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java	Mon Feb 25 13:55:44 2019 +0100
@@ -1190,7 +1190,7 @@
         return "Generated from applet from " + createJnlpVendorValue();
     }
 
-    public String createJnlpTitleValue() {
+    private String createJnlpTitleValue() {
         final String location;
         if (getSourceLocation() != null) {
             location = new File(getSourceLocation().getFile()).getName();
@@ -1215,6 +1215,15 @@
         return getTitle() + " from " + createJnlpTitleValue();
     }
     
+    public String createNameForDesktopFile() {
+        String basicTitle = getTitle();
+        if (basicTitle == null || basicTitle.trim().isEmpty()) {
+            return createJnlpTitleValue().replaceAll(".jnlp$","");
+        } else {
+            return basicTitle;            
+        }
+    }
+    
     //not private for testing purposes
     static String[] splitEntryPoints(String entryPointString) {
         if (entryPointString == null || entryPointString.trim().isEmpty()) {
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java	Mon Feb 25 13:54:27 2019 +0100
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java	Mon Feb 25 13:55:44 2019 +0100
@@ -414,7 +414,7 @@
 
     @Override
     public File getGeneratedJnlpFileName() {
-        String name = FileUtils.sanitizeFileName(file.createJnlpTitle());
+        String name = FileUtils.sanitizeFileName(file.createNameForDesktopFile());
         while (name.endsWith(".jnlp")) {
             name = name.substring(0, name.length() - 5);
         }
@@ -558,9 +558,10 @@
     }
     
     static String getDesktopIconName(JNLPFile file) {
-        return sanitize(file.createJnlpTitle());
+        return sanitize(file.createNameForDesktopFile());
     }
 
+    @Override
     public File getDesktopIconFile() {
             return new File(getDesktop(), getDesktopIconFileName());
     }