Skip to content

Commit

Permalink
Merge branch 'master' into fast-search
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Apr 5, 2016
2 parents 480dae7 + 49454a4 commit 8aabec3
Show file tree
Hide file tree
Showing 42 changed files with 316 additions and 481 deletions.
29 changes: 14 additions & 15 deletions src/main/java/net/sf/jabref/JabRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@
*/
package net.sf.jabref;

import java.awt.Font;
import java.io.File;
import java.io.IOException;
import java.net.Authenticator;
import java.nio.charset.Charset;
import java.util.*;
import java.util.prefs.BackingStoreException;
import javax.swing.*;
import javax.swing.plaf.FontUIResource;

import com.jgoodies.looks.plastic.Plastic3DLookAndFeel;
import com.jgoodies.looks.plastic.theme.SkyBluer;
import net.sf.jabref.bibtex.InternalBibtexFields;
import net.sf.jabref.cli.AuxCommandLine;
import net.sf.jabref.exporter.*;
import net.sf.jabref.gui.*;
import net.sf.jabref.gui.remote.JabRefMessageHandler;
Expand Down Expand Up @@ -45,22 +57,9 @@
import net.sf.jabref.model.database.BibDatabaseMode;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.util.Util;
import net.sf.jabref.bibtex.InternalBibtexFields;
import net.sf.jabref.cli.AuxCommandLine;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.Authenticator;
import java.nio.charset.Charset;
import java.util.*;
import java.util.List;
import java.util.prefs.BackingStoreException;

/**
* JabRef Main Class - The application gets started here.
*/
Expand Down Expand Up @@ -250,7 +249,7 @@ public Optional<Vector<ParserResult>> processArguments(String[] args, boolean in
BibDatabase newBase = new DatabaseSearcher(query, dataBase).getDatabaseFromMatches(); //newBase contains only match entries

//export database
if ((newBase != null) && (!newBase.hasNoEntries())) {
if ((newBase != null) && newBase.hasEntries()) {
String formatName;

//read in the export format, take default format if no format entered
Expand Down Expand Up @@ -397,7 +396,7 @@ public Optional<Vector<ParserResult>> processArguments(String[] args, boolean in
boolean notSavedMsg = false;

// write an output, if something could be resolved
if ((newBase != null) && !newBase.hasNoEntries()) {
if ((newBase != null) && newBase.hasEntries()) {
String subName = StringUtil.getCorrectFileName(data[1], "bib");

try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/collab/ChangeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ChangeScanner implements Runnable {
public ChangeScanner(JabRefFrame frame, BasePanel bp, File file) {
this.panel = bp;
this.frame = frame;
this.inMem = bp.database();
this.inMem = bp.getDatabase();
this.mdInMem = bp.getBibDatabaseContext().getMetaData();
this.f = file;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/collab/EntryAddChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package net.sf.jabref.collab;

import javax.swing.*;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.MetaData;
Expand All @@ -27,8 +29,6 @@
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.IdGenerator;

import javax.swing.*;

class EntryAddChange extends Change {

private final BibEntry diskEntry;
Expand All @@ -47,9 +47,9 @@ public EntryAddChange(BibEntry diskEntry) {
@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
diskEntry.setId(IdGenerator.next());
panel.database().insertEntry(diskEntry);
panel.getDatabase().insertEntry(diskEntry);
secondary.insertEntry(diskEntry);
undoEdit.addEdit(new UndoableInsertEntry(panel.database(), diskEntry, panel));
undoEdit.addEdit(new UndoableInsertEntry(panel.getDatabase(), diskEntry, panel));
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/collab/EntryDeleteChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package net.sf.jabref.collab;

import javax.swing.*;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.MetaData;
Expand All @@ -29,8 +31,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.swing.*;

class EntryDeleteChange extends Change {

private final BibEntry memEntry;
Expand Down Expand Up @@ -61,8 +61,8 @@ public EntryDeleteChange(BibEntry memEntry, BibEntry tmpEntry) {

@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
panel.database().removeEntry(memEntry);
undoEdit.addEdit(new UndoableRemoveEntry(panel.database(), memEntry, panel));
panel.getDatabase().removeEntry(memEntry);
undoEdit.addEdit(new UndoableRemoveEntry(panel.getDatabase(), memEntry, panel));
secondary.removeEntry(tmpEntry);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/collab/GroupChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound
// the group tree is now appled to a different BibDatabase than it was created
// for, which affects groups such as ExplicitGroup (which links to BibEntry objects).
// We must traverse the tree and refresh all groups:
root.refreshGroupsForNewDatabase(panel.database());
root.refreshGroupsForNewDatabase(panel.getDatabase());
}

if (panel.getGroupSelector().getGroupTreeRoot() == root) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/collab/PreambleChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public PreambleChange(String mem, String disk) {

@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
panel.database().setPreamble(disk);
undoEdit.addEdit(new UndoablePreambleChange(panel.database(), panel, mem, disk));
panel.getDatabase().setPreamble(disk);
undoEdit.addEdit(new UndoablePreambleChange(panel.getDatabase(), panel, mem, disk));
secondary.setPreamble(disk);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/collab/StringAddChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public StringAddChange(BibtexString string) {
@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {

if (panel.database().hasStringLabel(string.getName())) {
if (panel.getDatabase().hasStringLabel(string.getName())) {
// The name to change to is already in the database, so we can't comply.
LOGGER.info("Cannot add string '" + string.getName() + "' because the name "
+ "is already in use.");
}

try {
panel.database().addString(string);
undoEdit.addEdit(new UndoableInsertString(panel, panel.database(), string));
panel.getDatabase().addString(string);
undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), string));
} catch (KeyCollisionException ex) {
LOGGER.info("Error: could not add string '" + string.getName() + "': " + ex.getMessage(), ex);
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/net/sf/jabref/collab/StringChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound
String newId = IdGenerator.next();
BibtexString bs = new BibtexString(newId, label, disk);
try {
panel.database().addString(bs);
undoEdit.addEdit(new UndoableInsertString(panel, panel.database(), bs));
panel.getDatabase().addString(bs);
undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), bs));
} catch (KeyCollisionException ex) {
LOGGER.info("Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex);
}
} else {
string.setContent(disk);
undoEdit.addEdit(new UndoableStringChange(panel, string, false, mem, disk));
// Update tmp databse:

}

// Update tmp database:
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/sf/jabref/collab/StringNameChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public StringNameChange(BibtexString string, BibtexString tmpString,
@Override
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {

if (panel.database().hasStringLabel(disk)) {
if (panel.getDatabase().hasStringLabel(disk)) {
// The name to change to is already in the database, so we can't comply.
LOGGER.info("Cannot rename string '" + mem + "' to '" + disk + "' because the name "
+ "is already in use.");
Expand All @@ -67,8 +67,8 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound
String newId = IdGenerator.next();
BibtexString bs = new BibtexString(newId, disk, content);
try {
panel.database().addString(bs);
undoEdit.addEdit(new UndoableInsertString(panel, panel.database(), bs));
panel.getDatabase().addString(bs);
undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), bs));
} catch (KeyCollisionException ex) {
LOGGER.info("Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/collab/StringRemoveChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public StringRemoveChange(BibtexString string, BibtexString tmpString, BibtexStr
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {

try {
panel.database().removeString(inMem.getId());
undoEdit.addEdit(new UndoableRemoveString(panel, panel.database(), string));
panel.getDatabase().removeString(inMem.getId());
undoEdit.addEdit(new UndoableRemoveString(panel, panel.getDatabase(), string));
} catch (Exception ex) {
LOGGER.info("Error: could not add string '" + string.getName() + "': " + ex.getMessage(), ex);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/exporter/ExportFormats.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void actionPerformed(ActionEvent e) {
@Override
public void run() {
try {
format.performExport(frame.getCurrentBasePanel().database(),
format.performExport(frame.getCurrentBasePanel().getDatabase(),
frame.getCurrentBasePanel().getBibDatabaseContext().getMetaData(),
finFile.getPath(), frame
.getCurrentBasePanel().getEncoding(), finEntries);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/jabref/external/DroppedFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void handleDroppedfile(String fileName, ExternalFileType fileType, BibEnt
}

// Show dialog
if (!showLinkMoveCopyRenameDialog(fileName, fileType, entry, panel.database())) {
if (!showLinkMoveCopyRenameDialog(fileName, fileType, entry, panel.getDatabase())) {
return;
}

Expand Down Expand Up @@ -186,7 +186,7 @@ public void linkPdfToEntry(String fileName, BibEntry entry) {

ExternalFileType fileType = optFileType.get();
// Show dialog
if (!showLinkMoveCopyRenameDialog(fileName, fileType, entry, panel.database())) {
if (!showLinkMoveCopyRenameDialog(fileName, fileType, entry, panel.getDatabase())) {
return;
}

Expand Down
21 changes: 11 additions & 10 deletions src/main/java/net/sf/jabref/external/SynchronizeFileField.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@
*/
package net.sf.jabref.external;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.*;
import javax.swing.*;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
import net.sf.jabref.*;
import net.sf.jabref.Globals;
import net.sf.jabref.JabRefExecutorService;
import net.sf.jabref.MetaData;
import net.sf.jabref.gui.*;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.undo.NamedCompound;
import net.sf.jabref.gui.undo.UndoableFieldChange;
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.logic.util.io.FileUtil;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.util.Util;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.*;
import java.util.List;

/**
* This action goes through all selected entries in the BasePanel, and attempts to autoset the
* given external file (pdf, ps, ...) based on the same algorithm used for the "Auto" button in
Expand Down Expand Up @@ -68,7 +69,7 @@ public SynchronizeFileField(BasePanel panel) {

@Override
public void init() {
Collection<BibEntry> col = panel.database().getEntries();
Collection<BibEntry> col = panel.getDatabase().getEntries();
goOn = true;
sel = new ArrayList<>(col);

Expand Down
23 changes: 11 additions & 12 deletions src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
*/
package net.sf.jabref.external;

import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.xml.transform.TransformerException;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.*;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.gui.entryeditor.EntryEditor;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.logic.util.io.FileUtil;
import net.sf.jabref.logic.xmp.XMPUtil;

import javax.swing.*;
import javax.xml.transform.TransformerException;

import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import net.sf.jabref.model.entry.BibEntry;

/**
* Write XMP action for EntryEditor toolbar.
Expand Down Expand Up @@ -123,7 +122,7 @@ public void run() {

} else {
try {
XMPUtil.writeXMP(file, entry, panel.database());
XMPUtil.writeXMP(file, entry, panel.getDatabase());
if (files.size() == 1) {
message = Localization.lang("Wrote XMP-metadata");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void actionPerformed(ActionEvent e) {
@Override
public void run() {
// Do the operation:
operation.pushEntries(panel.database(), entries, getKeyString(entries), panel.getBibDatabaseContext().getMetaData());
operation.pushEntries(panel.getDatabase(), entries, getKeyString(entries), panel.getBibDatabaseContext().getMetaData());

// Call the operationCompleted() method on the event dispatch thread:
SwingUtilities.invokeLater(new Runnable() {
Expand Down
Loading

0 comments on commit 8aabec3

Please sign in to comment.