~ubuntu-branches/ubuntu/trusty/jabref/trusty

« back to all changes in this revision

Viewing changes to src/java/net/sf/jabref/gui/FileListEntryEditor.java

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann
  • Date: 2009-12-01 18:52:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20091201185251-08e2unpn1jl8ijq8
Tags: 2.6~beta2-1
* Remove alternative dependency on sun-java5-jre which was removed from the
  archive. Also adjust README.Debian and /usr/bin/jabref.
* New upstream beta release:
  - fixes "allow to disable (re)storing of current tab for entries"
    (closes: #447767)
  - thanks again to Philip Rinn for his help with the upgrade
* debian/copyright: add new developer.
* Refresh patches 01_free_javac.patch and 06_BibtexEntry.patch.
* Adjust debian/jabref.links and debian/jabref.install to new jar file.
* Simplify debian/jabref.dirs.
* Add a presubj fragment for reportbug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import java.io.File;
6
6
import java.io.IOException;
7
7
import java.util.ArrayList;
 
8
import java.util.regex.Pattern;
8
9
 
9
10
import javax.swing.*;
10
11
import javax.swing.event.DocumentEvent;
53
54
    private boolean okPressed = false, okDisabledExternally = false,
54
55
            openBrowseWhenShown = false, dontOpenBrowseUntilDisposed = false;
55
56
 
 
57
    public static Pattern remoteLinkPattern = Pattern.compile("[a-z]+://.*");
 
58
 
56
59
    public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar,
57
60
                               boolean showOpenButton, MetaData metaData) {
58
61
        this.entry = entry;
183
186
    private void checkExtension() {
184
187
        if ((types.getSelectedIndex() == -1) &&
185
188
                (link.getText().trim().length() > 0)) {
 
189
 
 
190
            // Check if this looks like a remote link:
 
191
            if (remoteLinkPattern.matcher(link.getText()).matches()) {
 
192
                ExternalFileType type = Globals.prefs.getExternalFileTypeByExt("html");
 
193
                if (type != null) {
 
194
                    types.setSelectedItem(type);
 
195
                    return;
 
196
                }
 
197
            }
 
198
 
186
199
            // Try to guess the file type:
187
200
            String theLink = link.getText().trim();
188
201
            int index = theLink.lastIndexOf('.');
266
279
        } else {
267
280
            String canPath = (new File(fileDir)).getCanonicalPath();
268
281
            File fl = new File(link.getText().trim());
269
 
            String flPath = fl.getCanonicalPath();
270
 
            if ((flPath.length() > canPath.length()) && (flPath.startsWith(canPath))) {
271
 
                String relFileName = fl.getCanonicalPath().substring(canPath.length()+1);
272
 
                entry.setLink(relFileName);
273
 
            } else
274
 
                entry.setLink(link.getText().trim());
 
282
            if (fl.isAbsolute()) {
 
283
                String flPath = fl.getCanonicalPath();
 
284
                if ((flPath.length() > canPath.length()) && (flPath.startsWith(canPath))) {
 
285
                    String relFileName = fl.getCanonicalPath().substring(canPath.length()+1);
 
286
                    entry.setLink(relFileName);
 
287
                } else
 
288
                    entry.setLink(link.getText().trim());
 
289
            }
 
290
            else entry.setLink(link.getText().trim());
275
291
        }
276
292
    } catch (java.io.IOException ex)
277
293
        {