New patch 08_doubleextensions.patch, kindly backported and provided by
authorgregor herrmann <gregoa@debian.org>
Sun, 22 May 2011 15:57:06 +0000 (15:57 -0000)
committergregor herrmann <gregoa@debian.org>
Sun, 22 May 2011 15:57:06 +0000 (15:57 -0000)
upstream: improve handling of linked files with double extensions: file
types with a double extension are new recognized automatically when a new
link is added manually, or when a link is added automatically and
clicked-upon once, after defining the file type in the options
(closes: #626582).

debian/changelog
debian/patches/08_doubleextensions.patch [new file with mode: 0644]
debian/patches/series

index 0af748e..297aa87 100644 (file)
@@ -1,3 +1,14 @@
+jabref (2.7~beta1+ds-5) UNRELEASED; urgency=low
+
+  * New patch 08_doubleextensions.patch, kindly backported and provided by
+    upstream: improve handling of linked files with double extensions: file
+    types with a double extension are new recognized automatically when a new
+    link is added manually, or when a link is added automatically and
+    clicked-upon once, after defining the file type in the options
+    (closes: #626582).
+
+ -- gregor herrmann <gregoa@debian.org>  Sun, 22 May 2011 17:30:48 +0200
+
 jabref (2.7~beta1+ds-4) unstable; urgency=low
 
   [ tony mancill ]
diff --git a/debian/patches/08_doubleextensions.patch b/debian/patches/08_doubleextensions.patch
new file mode 100644 (file)
index 0000000..2f17bbb
--- /dev/null
@@ -0,0 +1,59 @@
+Description: handle double extensions better
+Origin: upstream
+Bug-Debian: http://bugs.debian.org/626582
+Forwarded: not needed, it's from them :)
+Author: Morten Omholt Alver <mortenalver@gmail.com>
+Reviewed-by: gregor herrmann <gregoa@debian.org>
+Last-Update: 2011-05-22
+Applied-Upstream: yes
+
+--- a/src/java/net/sf/jabref/gui/FileListEntryEditor.java
++++ b/src/java/net/sf/jabref/gui/FileListEntryEditor.java
+@@ -198,14 +198,9 @@
+             // Try to guess the file type:
+             String theLink = link.getText().trim();
+-            int index = theLink.lastIndexOf('.');
+-            if ((index >= 0) && (index < theLink.length()-1)) {
+-
+-                ExternalFileType type = Globals.prefs.getExternalFileTypeByExt
+-                        (theLink.substring(index+1));
+-                if (type != null)
+-                    types.setSelectedItem(type);
+-            }
++            ExternalFileType type = Globals.prefs.getExternalFileTypeForName(theLink);
++            if (type != null)
++                types.setSelectedItem(type);
+         }
+     }
+--- a/src/java/net/sf/jabref/JabRefPreferences.java
++++ b/src/java/net/sf/jabref/JabRefPreferences.java
+@@ -1065,6 +1065,27 @@
+     }
+     /**
++     * Look up the external file type registered for this filename, if any.
++     * @param filename The name of the file whose type to look up.
++     * @return The ExternalFileType registered, or null if none.
++     */
++    public ExternalFileType getExternalFileTypeForName(String filename) {
++        int longestFound = -1;
++        ExternalFileType foundType = null;
++        for (Iterator<ExternalFileType> iterator = externalFileTypes.iterator(); iterator.hasNext();) {
++            ExternalFileType type = iterator.next();
++            if ((type.getExtension() != null) && filename.toLowerCase().
++                    endsWith(type.getExtension().toLowerCase())) {
++                if (type.getExtension().length() > longestFound) {
++                    longestFound = type.getExtension().length();
++                    foundType = type;
++                }
++            }
++        }
++        return foundType;
++    }
++
++    /**
+      * Look up the external file type registered for this MIME type, if any.
+      * @param mimeType The MIME type.
+      * @return The ExternalFileType registered, or null if none. For the mime type "text/html",
index e74eb21..7da9af0 100644 (file)
@@ -3,3 +3,4 @@
 05_antlr32.patch
 06_BibtexEntry.patch
 07_pdfbox1.5.patch
+08_doubleextensions.patch