From: gregor herrmann
Date: Wed, 20 May 2015 15:32:45 +0000 (+0200)
Subject: Imported Upstream version 2.11~beta2+ds
X-Git-Tag: upstream/2.11_beta2+ds^0
X-Git-Url: https://git.toastfreeware.priv.at/debian/jabref.git/commitdiff_plain/286669bdf3065988249dd5cbad3e86153985b38b
Imported Upstream version 2.11~beta2+ds
---
diff --git a/CHANGELOG b/CHANGELOG
index ff0e8af..d863ed3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+2.11 beta 2
+ - Feature: Option to clean URLs generated by Google (patch #204)
+ - Fix for bug #1272: JabRef now launches on Mac OS X
+ - Updated DBLPfetcher to new DBLP functionality
+ - Feature: Ability to reorder the panels in the side pane
+ - Feature: Option to save selected entries as plain BibTex without JabRef metadata
2.11 beta
- Some UI updates (mainly removing unnecessary boundaries)
- Feature: Gridlines are now optional (and disabled by default)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8611a87..3a72c17 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,8 @@
## Understanding the basics
Not sure what a pull request is, or how to submit one? Take a look at GitHub's excellent [help documentation] first.
+We also have [guidelines for setting up a local workspace](https://github.com/JabRef/jabref/wiki/Guidelines-for-setting-up-a-local-workspace).
+
## Add your change to the CHANGELOG
You should edit the [CHANGELOG](CHANGELOG) located in the root directory of the JabRef source.
diff --git a/README.md b/README.md
index 7ba7b8f..99151db 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# JabRef version 2.11 beta
+# JabRef version 2.11 beta 2
This version is a beta version. Features may not work as expected.
@@ -105,7 +105,9 @@ and then generate the Eclipse `gradlew eclipse` or IntelliJ IDEA `gradlew idea`
## Release Process
-Requires [NSIS](http://nsis.sourceforge.net) with the [WinShell plug-in](http://nsis.sourceforge.net/WinShell_plug-in).
+Requires
+ * [launch4j](http://launch4j.sourceforge.net/)
+ * [NSIS](http://nsis.sourceforge.net) with the [WinShell plug-in](http://nsis.sourceforge.net/WinShell_plug-in).
Replace `ANY_ANT_TARGET` with the Ant Target of your choice, and the system will build your binaries.
To get a list of all targets, use `gradlew tasks`.
diff --git a/build.gradle b/build.gradle
index 21b658c..64e5d5b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,7 +28,7 @@ test {
}
}
-version = "2.11b"
+version = "2.11b2"
repositories {
mavenCentral()
diff --git a/build.xml b/build.xml
index a44f9f8..f014216 100644
--- a/build.xml
+++ b/build.xml
@@ -35,8 +35,8 @@
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
-
-
+
+
diff --git a/src/main/java/net/sf/jabref/BasePanel.java b/src/main/java/net/sf/jabref/BasePanel.java
index 5d5dc1c..900e7c8 100644
--- a/src/main/java/net/sf/jabref/BasePanel.java
+++ b/src/main/java/net/sf/jabref/BasePanel.java
@@ -70,6 +70,7 @@ import net.sf.jabref.export.FileActions;
import net.sf.jabref.export.SaveDatabaseAction;
import net.sf.jabref.export.SaveException;
import net.sf.jabref.export.SaveSession;
+import net.sf.jabref.export.FileActions.DatabaseSaveType;
import net.sf.jabref.export.layout.Layout;
import net.sf.jabref.export.layout.LayoutHelper;
import net.sf.jabref.external.AttachFileAction;
@@ -411,30 +412,10 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe
}
});
- actions.put("saveSelectedAs", new BaseAction () {
- public void action() throws Throwable {
-
- String chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get("workingDirectory")), ".bib",
- JFileChooser.SAVE_DIALOG, false);
- if (chosenFile != null) {
- File expFile = new File(chosenFile);
- if (!expFile.exists() ||
- (JOptionPane.showConfirmDialog
- (frame, "'"+expFile.getName()+"' "+
- Globals.lang("exists. Overwrite file?"),
- Globals.lang("Save database"), JOptionPane.OK_CANCEL_OPTION)
- == JOptionPane.OK_OPTION)) {
-
- saveDatabase(expFile, true, Globals.prefs.get("defaultEncoding"));
- //runCommand("save");
- frame.getFileHistory().newFile(expFile.getPath());
- frame.output(Globals.lang("Saved selected to")+" '"
- +expFile.getPath()+"'.");
- }
- }
- }
- });
-
+ actions.put("saveSelectedAs", new SaveSelectedAction(FileActions.DatabaseSaveType.DEFAULT));
+
+ actions.put("saveSelectedAsPlain", new SaveSelectedAction(FileActions.DatabaseSaveType.PLAIN_BIBTEX));
+
// The action for copying selected entries.
actions.put("copy", new BaseAction() {
public void action() {
@@ -1716,7 +1697,7 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe
//}).start();
}
- private boolean saveDatabase(File file, boolean selectedOnly, String encoding) throws SaveException {
+ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, FileActions.DatabaseSaveType saveType) throws SaveException {
SaveSession session;
frame.block();
try {
@@ -1725,7 +1706,7 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe
Globals.prefs, false, false, encoding, false);
else
session = FileActions.savePartOfDatabase(database, metaData, file,
- Globals.prefs, mainTable.getSelectedEntries(), encoding);
+ Globals.prefs, mainTable.getSelectedEntries(), encoding, saveType);
} catch (UnsupportedCharsetException ex2) {
JOptionPane.showMessageDialog(frame, Globals.lang("Could not save file. "
@@ -1775,7 +1756,7 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe
JOptionPane.QUESTION_MESSAGE, null, Globals.ENCODINGS, encoding);
if (choice != null) {
String newEncoding = (String)choice;
- return saveDatabase(file, selectedOnly, newEncoding);
+ return saveDatabase(file, selectedOnly, newEncoding, saveType);
} else
commit = false;
} else if (answer == JOptionPane.CANCEL_OPTION)
@@ -3096,5 +3077,34 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe
frame.forward.setEnabled(nextEntries.size() > 0);
}
-
+ private class SaveSelectedAction extends BaseAction {
+
+ private DatabaseSaveType saveType;
+
+ public SaveSelectedAction(DatabaseSaveType saveType) {
+ this.saveType = saveType;
+ }
+
+ public void action() throws Throwable {
+
+ String chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get("workingDirectory")), ".bib",
+ JFileChooser.SAVE_DIALOG, false);
+ if (chosenFile != null) {
+ File expFile = new File(chosenFile);
+ if (!expFile.exists() ||
+ (JOptionPane.showConfirmDialog
+ (frame, "'"+expFile.getName()+"' "+
+ Globals.lang("exists. Overwrite file?"),
+ Globals.lang("Save database"), JOptionPane.OK_CANCEL_OPTION)
+ == JOptionPane.OK_OPTION)) {
+
+ saveDatabase(expFile, true, Globals.prefs.get("defaultEncoding"), saveType);
+ //runCommand("save");
+ frame.getFileHistory().newFile(expFile.getPath());
+ frame.output(Globals.lang("Saved selected to")+" '"
+ +expFile.getPath()+"'.");
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/net/sf/jabref/FieldTextMenu.java b/src/main/java/net/sf/jabref/FieldTextMenu.java
index f500959..567f61e 100644
--- a/src/main/java/net/sf/jabref/FieldTextMenu.java
+++ b/src/main/java/net/sf/jabref/FieldTextMenu.java
@@ -48,6 +48,7 @@ import javax.swing.text.JTextComponent;
import net.sf.jabref.util.CaseChangeMenu;
import net.sf.jabref.util.NameListNormalizer;
+import net.sf.jabref.util.GoogleUrlCleaner;
public class FieldTextMenu implements MouseListener
{
@@ -65,6 +66,8 @@ public class FieldTextMenu implements MouseListener
inputMenu.add( copyAct ) ;
inputMenu.addSeparator();
inputMenu.add(new ReplaceAction());
+ inputMenu.add(new UrlAction());
+
if (myFieldName.getTextComponent() instanceof JTextComponent)
inputMenu.add(new CaseChangeMenu((JTextComponent) myFieldName.getTextComponent()));
}
@@ -219,5 +222,18 @@ public class FieldTextMenu implements MouseListener
}
}
+ class UrlAction extends BasicAction{
+ public UrlAction(){
+ super("Clean Google URL");
+ putValue(SHORT_DESCRIPTION, Globals.lang("If possible, clean URL that Google search returned"));
+ }
+ public void actionPerformed(ActionEvent evt){
+ if (myFieldName.getText().equals("")){
+ return;
+ }
+ String input = myFieldName.getText();
+ myFieldName.setText(GoogleUrlCleaner.cleanUrl(input));
+ }
+ }
}
diff --git a/src/main/java/net/sf/jabref/JabRef.java b/src/main/java/net/sf/jabref/JabRef.java
index 20b8f84..ed94c70 100644
--- a/src/main/java/net/sf/jabref/JabRef.java
+++ b/src/main/java/net/sf/jabref/JabRef.java
@@ -187,12 +187,13 @@ public class JabRef {
Globals.NEWLINE = Globals.prefs.get(JabRefPreferences.NEWLINE);
Globals.NEWLINE_LENGTH = Globals.NEWLINE.length();
-
- // Set application user model id so that pinning JabRef to the Win7/8 taskbar works
- // Based on http://stackoverflow.com/a/1928830
- setCurrentProcessExplicitAppUserModelID("JabRef."+Globals.VERSION);
- //System.out.println(getCurrentProcessExplicitAppUserModelID());
-
+ if (Globals.ON_WIN) {
+ // Set application user model id so that pinning JabRef to the Win7/8 taskbar works
+ // Based on http://stackoverflow.com/a/1928830
+ setCurrentProcessExplicitAppUserModelID("JabRef." + Globals.VERSION);
+ //System.out.println(getCurrentProcessExplicitAppUserModelID());
+ }
+
openWindow(processArguments(args, true));
}
@@ -223,7 +224,9 @@ public class JabRef {
static
{
- Native.register("shell32");
+ if (Globals.ON_WIN) {
+ Native.register("shell32");
+ }
}
diff --git a/src/main/java/net/sf/jabref/JabRefFrame.java b/src/main/java/net/sf/jabref/JabRefFrame.java
index 7b30bbc..e189c5e 100644
--- a/src/main/java/net/sf/jabref/JabRefFrame.java
+++ b/src/main/java/net/sf/jabref/JabRefFrame.java
@@ -186,6 +186,10 @@ public class JabRefFrame extends JFrame implements OutputPrinter {
"Save selected as ...",
Globals.lang("Save selected as ..."),
GUIGlobals.getIconUrl("saveAs")),
+ saveSelectedAsPlain = new GeneralAction("saveSelectedAsPlain",
+ "Save selected as plain BibTeX ...",
+ Globals.lang("Save selected as plain BibTeX ..."),
+ GUIGlobals.getIconUrl("saveAs")),
exportAll = ExportFormats.getExportAction(this, false),
exportSelected = ExportFormats.getExportAction(this, true),
importCurrent = ImportFormats.getImportAction(this, false),
@@ -1291,6 +1295,7 @@ public JabRefPreferences prefs() {
file.add(saveAs);
file.add(saveAll);
file.add(saveSelectedAs);
+ file.add(saveSelectedAsPlain);
file.addSeparator();
//file.add(importMenu);
//file.add(importNewMenu);
diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java
index 9fc09f4..ab89ba2 100644
--- a/src/main/java/net/sf/jabref/JabRefPreferences.java
+++ b/src/main/java/net/sf/jabref/JabRefPreferences.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2012 JabRef contributors.
+/* Copyright (C) 2003-2015 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -310,6 +310,9 @@ public class JabRefPreferences {
defaults.put(NEWLINE, System.getProperty("line.separator"));
+ defaults.put("sidePaneComponentNames", "");
+ defaults.put("sidePaneComponentPreferredPositions", "");
+
defaults.put("columnNames", "entrytype;author;title;year;journal;owner;timestamp;bibtexkey");
defaults.put("columnWidths", "75;280;400;60;100;100;100;100");
defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY,
diff --git a/src/main/java/net/sf/jabref/SidePaneComponent.java b/src/main/java/net/sf/jabref/SidePaneComponent.java
index 716f49b..165cdac 100644
--- a/src/main/java/net/sf/jabref/SidePaneComponent.java
+++ b/src/main/java/net/sf/jabref/SidePaneComponent.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2011 JabRef contributors.
+/* Copyright (C) 2003-2015 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -31,6 +31,8 @@ import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
public abstract class SidePaneComponent extends SimpleInternalFrame {
protected JButton close = new JButton(GUIGlobals.getImage("close"));
+ protected JButton up = new JButton(GUIGlobals.getImage("up"));
+ protected JButton down = new JButton(GUIGlobals.getImage("down"));
protected boolean visible = false;
@@ -46,7 +48,15 @@ public abstract class SidePaneComponent extends SimpleInternalFrame {
close.setMargin(new Insets(0, 0, 0, 0));
// tlb.setOpaque(false);
close.setBorder(null);
+ up.setMargin(new Insets(0, 0, 0, 0));
+ down.setMargin(new Insets(0, 0, 0, 0));
+ up.setBorder(null);
+ down.setBorder(null);
+ up.addActionListener(new UpButtonListener());
+ down.addActionListener(new DownButtonListener());
tlb.setFloatable(false);
+ tlb.add(up);
+ tlb.add(down);
tlb.add(close);
close.addActionListener(new CloseButtonListener());
setToolBar(tlb);
@@ -61,6 +71,14 @@ public abstract class SidePaneComponent extends SimpleInternalFrame {
public void hideAway() {
manager.hideComponent(this);
}
+
+ public void moveUp() {
+ manager.moveUp(this);
+ }
+
+ public void moveDown() {
+ manager.moveDown(this);
+ }
/**
* Used by SidePaneManager only, to keep track of visibility.
@@ -111,4 +129,16 @@ public abstract class SidePaneComponent extends SimpleInternalFrame {
hideAway();
}
}
+
+ class UpButtonListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ moveUp();
+ }
+ }
+
+ class DownButtonListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ moveDown();
+ }
+ }
}
diff --git a/src/main/java/net/sf/jabref/SidePaneManager.java b/src/main/java/net/sf/jabref/SidePaneManager.java
index 972a38e..13c0191 100644
--- a/src/main/java/net/sf/jabref/SidePaneManager.java
+++ b/src/main/java/net/sf/jabref/SidePaneManager.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2011 JabRef contributors.
+/* Copyright (C) 2003-2015 JabRef contributors.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -37,6 +37,7 @@ public class SidePaneManager {
SidePane sidep;
Map components = new LinkedHashMap();
+ Map componentNames = new HashMap();
List visible = new LinkedList();
@@ -104,6 +105,7 @@ public class SidePaneManager {
public synchronized void register(String name, SidePaneComponent comp) {
components.put(name, comp);
+ componentNames.put(comp, name);
}
public synchronized void registerAndShow(String name, SidePaneComponent comp) {
@@ -115,6 +117,10 @@ public class SidePaneManager {
if (!visible.contains(component)) {
// Put the new component at the top of the group
visible.add(0, component);
+
+ // Sort the visible components by their preferred position
+ Collections.sort(visible, new PreferredIndexSort());
+
updateView();
component.componentOpening();
}
@@ -123,6 +129,10 @@ public class SidePaneManager {
public SidePaneComponent getComponent(String name) {
return components.get(name);
}
+
+ public String getComponentName(SidePaneComponent comp) {
+ return componentNames.get(comp);
+ }
public synchronized void hideComponent(SidePaneComponent comp) {
if (visible.contains(comp)) {
@@ -143,7 +153,97 @@ public class SidePaneManager {
}
}
+ private Map getPreferredPositions() {
+ Map preferredPositions = new HashMap();
+
+ String[] componentNames = Globals.prefs.getStringArray("sidePaneComponentNames");
+ String[] componentPositions = Globals.prefs.getStringArray("sidePaneComponentPreferredPositions");
+
+ for (int i = 0; i < componentNames.length; ++i) {
+ try {
+ preferredPositions.put(componentNames[i], Integer.parseInt(componentPositions[i]));
+ }
+ catch (NumberFormatException e) {
+ // Invalid integer format, ignore
+ }
+ }
+
+ return preferredPositions;
+ }
+
+ private void updatePreferredPositions() {
+ Map preferredPositions = getPreferredPositions();
+
+ // Update the preferred positions of all visible components
+ int index = 0;
+ for (SidePaneComponent comp : visible) {
+ String componentName = getComponentName(comp);
+ preferredPositions.put(componentName, index++);
+ }
+
+ // Split the map into a pair of parallel String arrays suitable for storage
+ String[] componentNames = preferredPositions.keySet().toArray(new String[0]);
+ String[] componentPositions = new String[preferredPositions.size()];
+
+ for (int i = 0; i < componentNames.length; ++i) {
+ componentPositions[i] = preferredPositions.get(componentNames[i]).toString();
+ }
+
+ Globals.prefs.putStringArray("sidePaneComponentNames", componentNames);
+ Globals.prefs.putStringArray("sidePaneComponentPreferredPositions", componentPositions);
+ }
+
+ // Helper class for sorting visible componenys based on their preferred position
+ private class PreferredIndexSort implements Comparator {
+ private Map preferredPositions;
+
+ public PreferredIndexSort() {
+ preferredPositions = getPreferredPositions();
+ }
+
+ @Override
+ public int compare(SidePaneComponent comp1, SidePaneComponent comp2) {
+ String comp1Name = getComponentName(comp1);
+ String comp2Name = getComponentName(comp2);
+
+ // Manually provide default values, since getOrDefault() doesn't exist prior to Java 8
+ int pos1 = (preferredPositions.containsKey(comp1Name) ? preferredPositions.get(comp1Name) : 0);
+ int pos2 = (preferredPositions.containsKey(comp2Name) ? preferredPositions.get(comp2Name) : 0);
+
+ return Integer.compare(pos1, pos2);
+ }
+ }
+
+ public synchronized void moveUp(SidePaneComponent comp) {
+ if (visible.contains(comp)) {
+ int currIndex = visible.indexOf(comp);
+ if (currIndex > 0) {
+ int newIndex = currIndex - 1;
+ visible.remove(currIndex);
+ visible.add(newIndex, comp);
+
+ updatePreferredPositions();
+ updateView();
+ }
+ }
+ }
+
+ public synchronized void moveDown(SidePaneComponent comp) {
+ if (visible.contains(comp)) {
+ int currIndex = visible.indexOf(comp);
+ if (currIndex < (visible.size() - 1)) {
+ int newIndex = currIndex + 1;
+ visible.remove(currIndex);
+ visible.add(newIndex, comp);
+
+ updatePreferredPositions();
+ updateView();
+ }
+ }
+ }
+
public synchronized void unregisterComponent(String name) {
+ componentNames.remove(components.get(name));
components.remove(name);
}
diff --git a/src/main/java/net/sf/jabref/export/FileActions.java b/src/main/java/net/sf/jabref/export/FileActions.java
index fa00745..b8f8908 100644
--- a/src/main/java/net/sf/jabref/export/FileActions.java
+++ b/src/main/java/net/sf/jabref/export/FileActions.java
@@ -55,7 +55,11 @@ import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.SortedList;
public class FileActions {
-
+
+ public enum DatabaseSaveType {
+ DEFAULT, PLAIN_BIBTEX
+ }
+
private static Pattern refPat = Pattern.compile("(#[A-Za-z]+#)"); // Used to detect string references in strings
private static BibtexString.Type previousStringType;
@@ -357,7 +361,7 @@ public class FileActions {
* @return A List containing warnings, if any.
*/
public static SaveSession savePartOfDatabase(BibtexDatabase database, MetaData metaData,
- File file, JabRefPreferences prefs, BibtexEntry[] bes, String encoding) throws SaveException {
+ File file, JabRefPreferences prefs, BibtexEntry[] bes, String encoding, DatabaseSaveType saveType) throws SaveException {
TreeMap types = new TreeMap(); // Map
// to
@@ -382,9 +386,11 @@ public class FileActions {
// Define our data stream.
VerifyingWriter fw = session.getWriter();
- // Write signature.
- writeBibFileHeader(fw, encoding);
-
+ if (saveType != DatabaseSaveType.PLAIN_BIBTEX) {
+ // Write signature.
+ writeBibFileHeader(fw, encoding);
+ }
+
// Write preamble if there is one.
writePreamble(fw, database.getPreamble());
@@ -423,7 +429,7 @@ public class FileActions {
}
// Write meta data.
- if (metaData != null) {
+ if (saveType != DatabaseSaveType.PLAIN_BIBTEX && metaData != null) {
metaData.writeMetaData(fw);
}
diff --git a/src/main/java/net/sf/jabref/export/SaveDatabaseAction.java b/src/main/java/net/sf/jabref/export/SaveDatabaseAction.java
index bcc1f41..e1186d6 100644
--- a/src/main/java/net/sf/jabref/export/SaveDatabaseAction.java
+++ b/src/main/java/net/sf/jabref/export/SaveDatabaseAction.java
@@ -218,7 +218,7 @@ public class SaveDatabaseAction extends AbstractWorker {
Globals.prefs, false, false, encoding, false);
else
session = FileActions.savePartOfDatabase(panel.database(), panel.metaData(), file,
- Globals.prefs, panel.getSelectedEntries(), encoding);
+ Globals.prefs, panel.getSelectedEntries(), encoding, FileActions.DatabaseSaveType.DEFAULT);
} catch (UnsupportedCharsetException ex2) {
JOptionPane.showMessageDialog(frame, Globals.lang("Could not save file. "
diff --git a/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java b/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java
index da26695..da707ea 100644
--- a/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java
+++ b/src/main/java/net/sf/jabref/external/FileLinksUpgradeWarning.java
@@ -89,9 +89,11 @@ public class FileLinksUpgradeWarning implements PostOpenAction {
JPanel message = new JPanel();
DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("left:pref", ""), message);
- b.append(new JLabel("" + Globals.lang("This database was written using an older version of JabRef.") + "
" + Globals.lang("The current version features a new way of handling links to external files.
"
- + "To take advantage of this, your links must be changed into the new format, and
"
- + "JabRef must be configured to show the new links.") + "" + Globals.lang("Do you want JabRef to do the following operations?") + ""));
+ // Keep the formatting of these lines. Otherwise, strings have to be translated again.
+ // See updated JabRef_en.properties modifications by python syncLang.py -s -u
+ b.append(new JLabel("" + Globals.lang("This database was written using an older version of JabRef.") + "
"
+ + Globals.lang("The current version features a new way of handling links to external files.
To take advantage of this, your links must be changed into the new format, and
JabRef must be configured to show the new links.") + "
"
+ + Globals.lang("Do you want JabRef to do the following operations?") + ""));
b.nextLine();
if (offerChangeSettings) {
b.append(changeSettings);
diff --git a/src/main/java/net/sf/jabref/imports/DBLPFetcher.java b/src/main/java/net/sf/jabref/imports/DBLPFetcher.java
index c9254ef..ffae2ef 100644
--- a/src/main/java/net/sf/jabref/imports/DBLPFetcher.java
+++ b/src/main/java/net/sf/jabref/imports/DBLPFetcher.java
@@ -20,11 +20,14 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import javax.swing.JPanel;
import net.sf.jabref.BibtexEntry;
+import net.sf.jabref.DuplicateCheck;
import net.sf.jabref.GUIGlobals;
import net.sf.jabref.OutputPrinter;
@@ -49,6 +52,8 @@ public class DBLPFetcher implements EntryFetcher {
public boolean processQuery(String query, ImportInspector inspector,
OutputPrinter status) {
+ final HashMap bibentryKnown = new HashMap();
+
boolean res = false;
this.query = query;
@@ -64,7 +69,7 @@ public class DBLPFetcher implements EntryFetcher {
//System.out.println(page);
String[] lines = page.split("\n");
List bibtexUrlList = new ArrayList();
- for(String line : lines) {
+ for(final String line : lines) {
if( line.startsWith("\"url\"") ) {
String addr = line.replace("\"url\":\"", "");
addr = addr.substring(0, addr.length()-2);
@@ -74,6 +79,18 @@ public class DBLPFetcher implements EntryFetcher {
}
+ // we save the duplicate check threshold
+ // we need to overcome the "smart" approach of this heuristic
+ // and we will set it back afterwards, so maybe someone is happy again
+ double saveThreshold = DuplicateCheck.duplicateThreshold;
+ DuplicateCheck.duplicateThreshold = Double.MAX_VALUE;
+
+ // 2014-11-08
+ // DBLP now shows the BibTeX entry using ugly HTML entities
+ // but they also offer the download of a bib file
+ // we find this in the page which we get from "url"
+ // and this bib file is then in "biburl"
+
int count = 1;
for(String urlStr : bibtexUrlList) {
if( ! shouldContinue ) {
@@ -81,21 +98,46 @@ public class DBLPFetcher implements EntryFetcher {
}
final URL bibUrl = new URL(urlStr);
- String bibtexPage = readFromURL(bibUrl);
- //System.out.println(bibtexPage);
- List bibtexList = helper.getBibTexFromPage(bibtexPage);
+ final String bibtexHTMLPage = readFromURL(bibUrl);
+
+ final String[] htmlLines = bibtexHTMLPage.split("\n");
+
+
+ for(final String line : htmlLines) {
+ if( line.contains("biburl") ) {
+ int sidx = line.indexOf("{");
+ int eidx = line.indexOf("}");
+ // now we take everything within the curley braces
+ String bibtexUrl = line.substring(sidx+1, eidx);
+
+ // we do not access dblp.uni-trier.de as they will complain
+ bibtexUrl = bibtexUrl.replace("dblp.uni-trier.de", "www.dblp.org");
- for(BibtexEntry bibtexEntry : bibtexList ) {
- inspector.addEntry(bibtexEntry);
- if( ! shouldContinue ) {
- break;
+ final URL bibFileURL = new URL(bibtexUrl);
+ //System.out.println("URL:|"+bibtexUrl+"|");
+ final String bibtexPage = readFromURL(bibFileURL);
+
+ Collection bibtexEntries = BibtexParser.fromString(bibtexPage);
+
+ for(BibtexEntry be : bibtexEntries) {
+
+ if( ! bibentryKnown.containsKey( be.getCiteKey() ) ) {
+
+ inspector.addEntry(be);
+ bibentryKnown.put(be.getCiteKey(), true);
+ }
+
+ }
}
}
- inspector.setProgress(count, bibtexUrlList.size());
+
+ inspector.setProgress(count, bibtexUrlList.size());
count++;
}
+ DuplicateCheck.duplicateThreshold = saveThreshold;
+
// everything went smooth
res = true;
diff --git a/src/main/java/net/sf/jabref/imports/DBLPHelper.java b/src/main/java/net/sf/jabref/imports/DBLPHelper.java
index 1eef98e..063f896 100644
--- a/src/main/java/net/sf/jabref/imports/DBLPHelper.java
+++ b/src/main/java/net/sf/jabref/imports/DBLPHelper.java
@@ -78,7 +78,7 @@ public class DBLPHelper {
endIdx);
entry1 = cleanEntry(entry1);
bibtexList.add(BibtexParser.singleFromString(entry1));
- //System.out.println("'" + entry1 + "'");
+ // System.out.println("'" + entry1 + "'");
// let's see whether there is another entry (crossref)
tmpStr = tmpStr
@@ -96,8 +96,10 @@ public class DBLPHelper {
return bibtexList;
}
+
+
private String cleanEntry(final String bibEntry) {
- return bibEntry.replaceFirst("DBLP", "DBLP");
+ return bibEntry.replaceFirst("DBLP", "DBLP");
}
}
diff --git a/src/main/java/net/sf/jabref/util/GoogleUrlCleaner.java b/src/main/java/net/sf/jabref/util/GoogleUrlCleaner.java
new file mode 100644
index 0000000..d356348
--- /dev/null
+++ b/src/main/java/net/sf/jabref/util/GoogleUrlCleaner.java
@@ -0,0 +1,81 @@
+/* Copyright (C) 2003-2013 JabRef contributors.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+package net.sf.jabref.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
+
+/**
+ * Class containing method(s) for cleaning URL returned by Google search.
+ * E.g. If you search for the "The String-to-String Correction Problem", Google
+ * will return a list of web pages associated with that text. If you copy any
+ * link that search returned, you will have access to the link "enriched"
+ * with many meta data.
+ * E.g. instead link http://dl.acm.org/citation.cfm?id=321811
+ * in your clipboard you will have this link:
+ * https://www.google.hr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CC8QFjAA&url=http%3A%2F%2Fdl.acm.org%2Fcitation.cfm%3Fid%3D321811&ei=L2_RUcj6HsfEswa7joGwBw&usg=AFQjCNEBJPUimu-bAns6lSLe-kszz4AiGA&sig2=tj9c5x62ioFHkQTKfwkj0g&bvm=bv.48572450,d.Yms
+ *
+ * Using methods of this class, "dirty" link will be cleaned.
+ *
+ * Created by Krunoslav Zubrinic, July 2013.
+ */
+public class GoogleUrlCleaner {
+
+/*
+ public static void main(String[] args) {
+ System.out.println(cleanUrl("https://www.google.hr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CC0QFjAA&url=http%3A%2F%2Fdl.acm.org%2Fcitation.cfm%3Fid%3D321811&ei=gHDRUa-IKobotQbMy4GAAg&usg=AFQjCNEBJPUimu-bAns6lSLe-kszz4AiGA&sig2=DotF0pIZD8OhjDcSHPlBbQ"));
+ System.out.println(cleanUrl("http://dl.acm.org/citation.cfm?id=321811"));
+ System.out.println(cleanUrl("test text"));
+ System.out.println(cleanUrl(" "));
+ System.out.println(cleanUrl(""));
+ System.out.println(cleanUrl(null));
+ }
+*/
+
+ // clean Google URL
+ public static String cleanUrl(String dirty) {
+ if (dirty==null || dirty.length()==0)
+ return dirty;
+ try{
+ URL u = new URL(dirty);
+ // read URL parameters
+ String query = u.getQuery();
+ // if there is no parameters
+ if (query==null)
+ return dirty;
+ // split parameters
+ String[] pairs = query.split("&");
+ if (pairs==null)
+ return dirty;
+ for (String pair : pairs) {
+ int idx = pair.indexOf("=");
+ // "clean" url is decoded value of "url" parameter
+ if (pair.substring(0, idx).equals("url"))
+ return URLDecoder.decode(pair.substring(idx + 1), "UTF-8");
+ }
+ }
+ catch(MalformedURLException e){
+ return dirty;
+ }
+ catch(UnsupportedEncodingException e){
+ return dirty;
+ }
+ return dirty;
+ }
+
+}
diff --git a/src/main/resources/help/About.html b/src/main/resources/help/About.html
index 46c4e61..560a043 100644
--- a/src/main/resources/help/About.html
+++ b/src/main/resources/help/About.html
@@ -63,6 +63,7 @@
Nathan Dunn,
E. Hakan Duran,
Brian Van Essen,
+ Michael Falkenthal,
Alexis Gallagher,
David Gleich,
Eduardo Roberto Greco,
@@ -88,6 +89,7 @@
Ambrogio Oliva,
Brian Quistorff,
Stephan Rave,
+ Adam Rehn,
John Relph,
Hannes Restel,
Moritz Ringler,
@@ -106,7 +108,8 @@
Mattias Ulbrich,
David Weitzman,
Seb Wills,
- John Zedlewski
+ John Zedlewski,
+ Krunoslav Zubrinic
Thanks to:
diff --git a/src/main/resources/help/da/About.html b/src/main/resources/help/da/About.html
index b31fe62..11f54f7 100644
--- a/src/main/resources/help/da/About.html
+++ b/src/main/resources/help/da/About.html
@@ -54,6 +54,7 @@
Nathan Dunn,
E. Hakan Duran,
Brian Van Essen,
+ Michael Falkenthal,
Alexis Gallagher,
David Gleich,
Eduardo Roberto Greco,
@@ -79,6 +80,7 @@
Ambrogio Oliva,
Brian Quistorff,
Stephan Rave,
+ Adam Rehn,
John Relph,
Hannes Restel,
Moritz Ringler,
@@ -97,7 +99,8 @@
Mattias Ulbrich,
David Weitzman,
Seb Wills,
- John Zedlewski
+ John Zedlewski,
+ Krunoslav Zubrinic
Tak til:
diff --git a/src/main/resources/help/de/About.html b/src/main/resources/help/de/About.html
index 353c8bc..db03f8a 100644
--- a/src/main/resources/help/de/About.html
+++ b/src/main/resources/help/de/About.html
@@ -53,6 +53,7 @@
Nathan Dunn,
E. Hakan Duran,
Brian Van Essen,
+ Michael Falkenthal,
Alexis Gallagher,
David Gleich,
Eduardo Roberto Greco,
@@ -78,6 +79,7 @@
Ambrogio Oliva,
Brian Quistorff,
Stephan Rave,
+ Adam Rehn,
John Relph,
Hannes Restel,
Moritz Ringler,
@@ -96,7 +98,8 @@
Mattias Ulbrich,
David Weitzman,
Seb Wills,
- John Zedlewski
+ John Zedlewski,
+ Krunoslav Zubrinic
Dank an:
diff --git a/src/main/resources/help/fr/About.html b/src/main/resources/help/fr/About.html
index 8b274a2..f795b79 100644
--- a/src/main/resources/help/fr/About.html
+++ b/src/main/resources/help/fr/About.html
@@ -62,6 +62,7 @@
Nathan Dunn,
E. Hakan Duran,
Brian Van Essen,
+ Michael Falkenthal,
Alexis Gallagher,
David Gleich,
Eduardo Roberto Greco,
@@ -87,6 +88,7 @@
Ambrogio Oliva,
Brian Quistorff,
Stephan Rave,
+ Adam Rehn,
John Relph,
Hannes Restel,
Moritz Ringler,
@@ -105,7 +107,8 @@
Mattias Ulbrich,
David Weitzman,
Seb Wills,
- John Zedlewski
+ John Zedlewski,
+ Krunoslav Zubrinic
Remerciements à :
diff --git a/src/main/resources/help/in/About.html b/src/main/resources/help/in/About.html
index d84e34d..91b0316 100644
--- a/src/main/resources/help/in/About.html
+++ b/src/main/resources/help/in/About.html
@@ -54,6 +54,7 @@
Nathan Dunn,
E. Hakan Duran,
Brian Van Essen,
+ Michael Falkenthal,
Alexis Gallagher,
David Gleich,
Eduardo Roberto Greco,
@@ -79,6 +80,7 @@
Ambrogio Oliva,
Brian Quistorff,
Stephan Rave,
+ Adam Rehn,
John Relph,
Hannes Restel,
Moritz Ringler,
diff --git a/src/main/resources/help/ja/About.html b/src/main/resources/help/ja/About.html
index 54c197d..f0f8ed4 100644
--- a/src/main/resources/help/ja/About.html
+++ b/src/main/resources/help/ja/About.html
@@ -53,6 +53,7 @@
Nathan Dunn,
E. Hakan Duran,
Brian Van Essen,
+ Michael Falkenthal,
Alexis Gallagher,
David Gleich,
Eduardo Roberto Greco,
@@ -78,6 +79,7 @@
Ambrogio Oliva,
Brian Quistorff,
Stephan Rave,
+ Adam Rehn,
John Relph,
Hannes Restel,
Moritz Ringler,
@@ -96,7 +98,8 @@
Mattias Ulbrich,
David Weitzman,
Seb Wills,
- John Zedlewski
+ John Zedlewski,
+ Krunoslav Zubrinic
以ä¸ã®æ¹ã
ã«æè¬ãã¾ã:
diff --git a/src/main/resources/help/ja/BibtexHelp.html b/src/main/resources/help/ja/BibtexHelp.html
index d5af4b8..943fb31 100644
--- a/src/main/resources/help/ja/BibtexHelp.html
+++ b/src/main/resources/help/ja/BibtexHelp.html
@@ -156,7 +156,19 @@
- urldate
æå¾ã«ãã¼ã¸ã訪ããæ¥ä»ã
- *) ã¯ãJabRefã«ãã£ã¦ç´æ¥ãµãã¼ãããã¦ãã¾ããã
+ * ã®ã¤ãããã£ã¼ã«ãã¯ãJabRefã¯ç´æ¥ãµãã¼ããã¦ãã¾ããã
+
+ ãã£ã¼ã«ãã«é¢ãããã³ã
+
+ çµç¹åã¯ã{}
æ¬å¼§ã®ä¸ã«ç½®ãã¾ããçµç¹åã«çç¥è¡¨è¨ãããå ´åããã®çç¥è¡¨è¨ã{}
æ¬å¼§ã®ä¸ã«ç½®ãã¾ããä¾ï¼{The Attributed Graph Grammar System ({AGG})}
.
+
+ ããã«è©³ããæ
å ±
+
+