Skip to content

Commit

Permalink
Merge remote-tracking branch 'JabRef/master' into entryType
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jan 26, 2016
2 parents 796cea3 + f45747d commit 7bb2135
Show file tree
Hide file tree
Showing 43 changed files with 102 additions and 418 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
### Removed
- Fixed [#627](https://github.com/JabRef/jabref/issues/627): The pdf field is removed from the export formats, use the file field
- Removed configuration option to use database file directory as base directory for attached files and make it default instead.
- Removed save session functionality as it just saved the last opened tabs which is done by default
- Removed CLI option -l to load a session



Expand Down
15 changes: 15 additions & 0 deletions scripts/generate_toc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby

# Source: https://gist.github.com/albertodebortoli/9310424
# Via: http://stackoverflow.com/a/22131019/873282

File.open("Code-Howtos.md", 'r') do |f|
f.each_line do |line|
forbidden_words = ['Table of contents', 'define', 'pragma']
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ }

title = line.gsub("#", "").strip
href = title.gsub(" ", "-").gsub('"',"").downcase
puts " " * (line.count("#")-1) + "* [#{title}](\##{href})"
end
end
4 changes: 0 additions & 4 deletions src/main/java/net/sf/jabref/JabRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,6 @@ private void openWindow(Vector<ParserResult> loaded) {
first = false;
}

if (cli.isLoadSession()) {
JabRef.jrf.loadSessionAction.actionPerformed(new java.awt.event.ActionEvent(JabRef.jrf, 0, ""));
}

// Start auto save timer:
if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_SAVE)) {
Globals.startAutoSaveManager(JabRef.jrf);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/sf/jabref/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ private Options getOptions() {
options.addOption("v", "version", false, Localization.lang("Display version"));
options.addOption("n", "nogui", false, Localization.lang("No GUI. Only process command line options."));
options.addOption("h", "help", false, Localization.lang("Display help on command line options"));
options.addOption("l", "loads", false, Localization.lang("Load session"));
options.addOption("b", "blank", false, Localization.lang("Do not open any files at startup"));
options.addOption(null, "debug", false, Localization.lang("Show debug level messages"));

Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ public final class JabRefPreferences {
public static final String MARKED_ENTRY_BACKGROUND = "markedEntryBackground";
public static final String KEY_PATTERN_REGEX = "KeyPatternRegex";
public static final String KEY_PATTERN_REPLACEMENT = "KeyPatternReplacement";
public static final String SAVED_SESSION = "savedSession";

// Currently, it is not possible to specify defaults for specific entry types
// When this should be made possible, the code to inspect is net.sf.jabref.gui.preftabs.LabelPatternPrefTab.storeSettings() -> LabelPattern keypatterns = getLabelPattern(); etc
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/exporter/SaveSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@
* If committing fails, the temporary file will not be deleted.
*/
public class SaveSession {
private static final Log LOGGER = LogFactory.getLog(SaveSession.class);

public static final String LOCKFILE_SUFFIX = ".lock";

// The age in ms of a lockfile before JabRef will offer to "steal" the locked file:
public static final long LOCKFILE_CRITICAL_AGE = 60000;

private static final String TEMP_PREFIX = "jabref";
private static final String TEMP_SUFFIX = "save.bib";

private static final String TEMP_SUFFIX = "save.bib";
private final File file;
private final File tmp;
private final Charset encoding;
private boolean backup;
private final boolean useLockFile;
private final VerifyingWriter writer;

private static final Log LOGGER = LogFactory.getLog(SaveSession.class);
private final VerifyingWriter writer;


public SaveSession(File file, Charset encoding, boolean backup) throws IOException, UnsupportedCharsetException {
Expand Down
105 changes: 0 additions & 105 deletions src/main/java/net/sf/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ void addJToogleButton(JToggleButton button) {
IconTheme.JabRefIcon.PRINTED.getIcon());
private final AbstractAction manageSelectors = new GeneralAction(Actions.MANAGE_SELECTORS,
Localization.menuTitle("Manage content selectors"));
private final AbstractAction saveSessionAction = new SaveSessionAction();
public final AbstractAction loadSessionAction = new LoadSessionAction();
private final AbstractAction normalSearch = new GeneralAction(Actions.SEARCH, Localization.menuTitle("Search"),
Localization.lang("Search"), Globals.getKeyPrefs().getKey(KeyBinding.SEARCH), IconTheme.JabRefIcon.SEARCH.getIcon());

Expand Down Expand Up @@ -1133,7 +1131,6 @@ private void fillMenu() {
//mb.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
mb.setBorder(null);
JMenu file = JabRefFrame.subMenu(Localization.menuTitle("File"));
JMenu sessions = JabRefFrame.subMenu(Localization.menuTitle("Sessions"));
JMenu edit = JabRefFrame.subMenu(Localization.menuTitle("Edit"));
JMenu search = JabRefFrame.subMenu(Localization.menuTitle("Search"));
JMenu groups = JabRefFrame.subMenu(Localization.menuTitle("Groups"));
Expand Down Expand Up @@ -1166,9 +1163,6 @@ private void fillMenu() {
file.add(databaseProperties);
file.addSeparator();

sessions.add(loadSessionAction);
sessions.add(saveSessionAction);
file.add(sessions);
file.add(fileHistory);
file.addSeparator();
file.add(editModeAction);
Expand Down Expand Up @@ -1870,105 +1864,6 @@ public void run() {

}


class SaveSessionAction
extends MnemonicAwareAction {

public SaveSessionAction() {
super();
putValue(Action.NAME, Localization.menuTitle("Save session"));
putValue(Action.ACCELERATOR_KEY, Globals.getKeyPrefs().getKey(KeyBinding.SAVE_SESSION));
}

@Override
public void actionPerformed(ActionEvent e) {
// Here we store the names of all current files. If
// there is no current file, we remove any
// previously stored filename.
List<String> filenames = new ArrayList<>();
if (tabbedPane.getTabCount() > 0) {
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (tabbedPane.getTitleAt(i).equals(GUIGlobals.untitledTitle)) {
tabbedPane.setSelectedIndex(i);
int answer = JOptionPane.showConfirmDialog
(JabRefFrame.this, Localization.lang
("This untitled database must be saved first to be "
+ "included in the saved session. Save now?"),
Localization.lang("Save database"),
JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) {
// The user wants to save.
try {
getCurrentBasePanel().runCommand(Actions.SAVE);
} catch (Throwable ignored) {
// Ignored
}
}
}
if (getBasePanelAt(i).getDatabaseFile() != null) {
filenames.add(getBasePanelAt(i).getDatabaseFile().getPath());
}
}
}

if (filenames.isEmpty()) {
output(Localization.lang("Not saved (empty session)") + '.');
} else {
prefs.putStringList(JabRefPreferences.SAVED_SESSION, filenames);
output(Localization.lang("Saved session") + '.');
}

}
}

public class LoadSessionAction extends MnemonicAwareAction {

private volatile boolean running;

public LoadSessionAction() {
super();
putValue(Action.NAME, Localization.menuTitle("Load session"));
putValue(Action.ACCELERATOR_KEY, Globals.getKeyPrefs().getKey(KeyBinding.LOAD_SESSION));
}

@Override
public void actionPerformed(ActionEvent e) {
if (prefs.get(JabRefPreferences.SAVED_SESSION) == null) {
output(Localization.lang("No saved session found."));
return;
}
if (running) {
return;
} else {
running = true;
}

output(Localization.lang("Loading session..."));
JabRefExecutorService.INSTANCE.execute(new Runnable() {

@Override
public void run() {
HashSet<String> currentFiles = new HashSet<>();
if (tabbedPane.getTabCount() > 0) {
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (getBasePanelAt(i).getDatabaseFile() != null) {
currentFiles.add(getBasePanelAt(i).getDatabaseFile().getPath());
}
}
}
List<String> names = prefs.getStringList(JabRefPreferences.SAVED_SESSION);
ArrayList<File> filesToOpen = new ArrayList<>();
for (String name : names) {
filesToOpen.add(new File(name));
}
open.openFiles(filesToOpen, true);
running = false;
}
});

}
}

class ChangeTabAction extends MnemonicAwareAction {

private final boolean next;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public enum KeyBinding {
IMPORT_INTO_CURRENT_DATABASE("Import into current database", Localization.lang("Import into current database"), "ctrl I"),
IMPORT_INTO_NEW_DATABASE("Import into new database", Localization.lang("Import into new database"), "ctrl alt I"),
INCREASE_TABLE_FONT_SIZE("Increase table font size", Localization.lang("Increase table font size"), "ctrl PLUS"),
LOAD_SESSION("Load session", Localization.lang("Load session"), "F12"),
MARK_ENTRIES("Mark entries", Localization.lang("Mark entries"), "ctrl M"),
NEW_ARTICLE("New article", Localization.lang("New article"), "ctrl shift A"),
NEW_BOOK("New book", Localization.lang("New book"), "ctrl shift B"),
Expand Down Expand Up @@ -73,7 +72,6 @@ public enum KeyBinding {
SAVE_ALL("Save all", Localization.lang("Save all"), "ctrl alt S"),
SAVE_DATABASE("Save database", Localization.lang("Save database"), "ctrl S"),
SAVE_DATABASE_AS("Save database as ...", Localization.lang("Save database as ..."), "ctrl shift S"),
SAVE_SESSION("Save session", Localization.lang("Save session"), "F11"),
SEARCH("Search", Localization.lang("Search"), "ctrl F"),
SELECT_ALL("Select all", Localization.lang("Select all"), "ctrl A"),
STRING_DIALOG_ADD_STRING("String dialog, add string", Localization.lang("String dialog, add string"), "ctrl N"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static String getCanonicalRepresentation(BibEntry e) {
// generate field entries
StringJoiner sj = new StringJoiner(",\n", "", "\n");
for (String fieldName : sortedFields) {
String line = String.format(" %s = {%s}", fieldName, mapFieldToValue.get(fieldName));
String line = String.format(" %s = {%s}", fieldName, String.valueOf(mapFieldToValue.get(fieldName)).replaceAll("\\r\\n","\n"));
sj.add(line);
}
sb.append(sj);
Expand Down
6 changes: 0 additions & 6 deletions src/main/resources/help/de/CommandLine.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ <h2>Kein GUI-Modus: -n</h2>
der Kommandozeile oder mit Hilfe eines Scripts
durchzuf&uuml;hren.</p>

<h2>Sitzung laden: -l</h2>

<p>Diese Option veranlasst JabRef, eine
gespeicherte Sitzung zu laden, sofern eine vorhanden ist, bevor
sich das Hauptfenster &ouml;ffnet.</p>

<h2>Datei importieren: -i Dateiname[,Importformat]</h2>

<p>Bei dieser Option importiert oder l&auml;dt JabRef eine bestimmte
Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/help/en/CommandLine.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ <h2>No-GUI mode: -n</h2>
<p>This option is useful for performing file conversion
operations from the command line or a script.</p>

<h2>Load session: -l</h2>

<p>This option causes JabRef to load the
saved session, if any, before opening the main window.</p>

<h2>Import file: -i filename[,format]</h2>

<p>This option causes
Expand Down
6 changes: 0 additions & 6 deletions src/main/resources/help/fr/CommandLine.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ <h2>No-GUI mode&nbsp;: -n</h2>
op&eacute;rations de conversion &agrave; partir de la ligne de
commande ou dans un script.</p>

<h2>Chargement d'une session&nbsp;: -l</h2>

<p>Cette option demande
&agrave; JabRef de charger la session sauvegard&eacute;e, si
elle existe, avant d'ouvrir la fen&ecirc;tre principale.</p>

<h2>Importation de fichier&nbsp;: -i
nomdefichier[,format]</h2>

Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/help/ja/CommandLine.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ <h2>GUI無しモード: -n</h2>

<p>このオプションは、コマンドラインやスクリプトからファイル変換操作を行う際に便利です。</p>

<h2>セッションの読込: -l</h2>

<p>このオプションを与えると、JabRefは、保存されたセッションがある場合には其れを読み込み、それから基本ウィンドウを開きます。</p>

<h2>ファイルの読込: -i ファイル名[,形式]</h2>

<p>このオプションを与えると、JabRefは指定したファイルを読み込むか開くかします。ファイル名だけが指定された場合やファイル名の後にコンマか*文字を付けた場合には、JabRefはファイル形式の自動検出を試みます。これは、BibTeXファイルとJabRefがサポートしているすべての読込形式に対して機能します。ファイル名の後にコンマと読込形式名を続けると、その読込フィルタが使用されます。使用できる読込形式については、<code>-h</code>オプションを使うと一覧を得ることができます。</p>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2417,8 +2417,8 @@ Push_to_application=Push_to_application
Refresh_OO=Refresh_OO
Resolve_duplicate_BibTeX_keys=Resolve_duplicate_BibTeX_keys
Save_all=Save_all
Save_session=Save_session
String_dialog,_add_string=String_dialog,_add_string
Save_session=Save_session
String_dialog,_remove_string=String_dialog,_remove_string
Switch_preview_layout=Switch_preview_layout
Synchronize_files=Synchronize_files
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/l10n/Menu_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ Replace_string=&Replace_string
Save_database=&Save_database
Save_database_as_...=S&ave_database_as_...
Save_selected_as_...=Save_se&lected_as_...
Save_session=Save_session
# Tools
Search=&Search
Search_IEEEXplore=Search_IEEEXplore
Search_ACM_Portal=Search_ACM_Portal
Select_all=Select_&all
Set_up_general_fields=Set_up_&general_fields
Show_error_console=Show_error_console

Save_session=Save_session
Sort_tabs=&Sort_tabs
Switch_preview_layout=&Switch_preview_layout
# Export menu
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/net/sf/jabref/bibtex/BibtexEntryAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public static void assertEquals(List<BibEntry> shouldBeIs, List<BibEntry> actual
*/
private static void assertEquals(BibEntry shouldBeEntry, BibEntry entry) {
// use the canonical string representation to compare the entries
Assert.assertEquals(CanonicalBibtexEntry.getCanonicalRepresentation(shouldBeEntry),
CanonicalBibtexEntry.getCanonicalRepresentation(entry));
String shouldBeEntryRepresentation = CanonicalBibtexEntry.getCanonicalRepresentation(shouldBeEntry);
String entryRepresentation = CanonicalBibtexEntry.getCanonicalRepresentation(entry);
Assert.assertEquals(shouldBeEntryRepresentation, entryRepresentation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void emptyResult() throws Exception {

@Test
public void resultFor797485368() throws Exception {
doTest("gvk_result_for_797485368.xml", 1, Arrays.asList(new String[] {"gvk_result_for_797485368.bib"}));
doTest("gvk_result_for_797485368.xml", 1, Arrays.asList("gvk_result_for_797485368.bib"));
}

@Test
public void GMP() throws Exception {
doTest("gvk_gmp.xml", 2, Arrays.asList(new String[] {"gvk_gmp.1.bib", "gvk_gmp.2.bib"}));
doTest("gvk_gmp.xml", 2, Arrays.asList("gvk_gmp.1.bib", "gvk_gmp.2.bib"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,21 @@ public void parseIgnoresAndWarnsAboutEntryWithUnmatchedOpenBracketInQuotationMar
}

@Test
@Ignore
public void parseIgnoresAndWarnsAboutEntryWithUnmatchedClosingBracket() throws IOException {
public void parseIgnoresArbitraryContentAfterEntry() throws IOException {

ParserResult result = BibtexParser.parse(new StringReader("@article{test,author={author bracket } to much}}"));
ParserResult result = BibtexParser.parse(new StringReader("@article{test,author={author bracket }}}"));

Assert.assertTrue(result.hasWarnings());
Collection<BibEntry> c = result.getDatabase().getEntries();
Assert.assertEquals("Size should be one, but was " + c.size(), 1, c.size());
Assert.assertEquals("Epilog should be preserved","}",result.getDatabase().getEpilog());
}

@Test
public void parseWarnsAboutUnmatchedContentInEntry() throws IOException {

ParserResult result = BibtexParser.parse(new StringReader("@article{test,author={author bracket }, to much}"));

Assert.assertTrue("There should be warnings", result.hasWarnings());

Collection<BibEntry> c = result.getDatabase().getEntries();
Assert.assertEquals("Size should be zero, but was " + c.size(), 0, c.size());
Expand Down Expand Up @@ -720,10 +729,9 @@ public void parseIgnoresAndWarnsAboutCorruptedEntryButRecognizeOthers() throws I
* Test for SF Bug #1283
*/
@Test
@Ignore
public void parseRecognizesMonthFieldsWithFollowingComma() throws IOException {

ParserResult result = BibtexParser.parse(new StringReader("@article{test,author={Ed von Test}},month={8,},"));
ParserResult result = BibtexParser.parse(new StringReader("@article{test,author={Ed von Test},month={8,}},"));

Collection<BibEntry> c = result.getDatabase().getEntries();
Assert.assertEquals(1, c.size());
Expand Down
Loading

0 comments on commit 7bb2135

Please sign in to comment.