Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fileDirPattern
Browse files Browse the repository at this point in the history
* upstream/master: (24 commits)
  hotfix NPE in the main table (#2158)
  Enhance side pane toggle (#1605)
  Added gray background text to authors field to assist newcomers (#2147)
  Rewrite google scholar fetcher to new infrastructure (#2101)
  Found entries will be shown when dropping a pdf with xmp meta data (#2150)
  Japanese translation (#2155)
  Add shortcuts to context menu (#2131)
  [WIP] Doi resolution ignore (#2154)
  Fix DuplicationChecker and key generator (#2151)
  just close popup on first ESC
  keep entry in sight
  Fix isSharedDatabaseAlreadyPresent check.
  don't change entry after search if editing an entry (#2129)
  Change download URL to downloads.jabref.org (#2145)
  fix switching edited textfield in the entry editor with TAB (#2138)
  Update me.champeau.gradle.jmh' version from 0.3.0 to 0.3.1
  Update install4j plugin from 6.1.2 to 6.1.3
  Remove gradle plugin com.github.youribonnaffe.gradle.format as it is deprecated and the config uses a non-existing file
  Update gradle from 3.0 to 3.1
  Fix changing the font size not working when importing preferences (#2069)
  ...

# Conflicts:
#	src/main/java/net/sf/jabref/gui/externalfiles/DroppedFileHandler.java
#	src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java
  • Loading branch information
Siedlerchr committed Oct 13, 2016
2 parents 6472b4e + 57027c0 commit d4c9b88
Show file tree
Hide file tree
Showing 73 changed files with 1,250 additions and 1,070 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#

### Changed
- Source tab in the entry editor displays "BibLaTeX Source" when using biblatex mode
- [koppor#171](https://github.com/koppor/jabref/issues/171): Add Shortcuts to context menu
- Add session restoring functionality for shared database. Related to [#1703](https://github.com/JabRef/jabref/issues/1703)
- Implementation of LiveUpdate for PostgreSQL & Oracle systems. Related to [#970](https://github.com/JabRef/jabref/issues/970).
- [koppor#31](https://github.com/koppor/jabref/issues/31): Number column in the main table is always Left aligned
Expand Down Expand Up @@ -59,8 +60,11 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Improve language quality of the German translation of shared database
- Change "Recent files" to "Recent databases" to keep the file menu consistent
- Customized importer files need to be slightly changed since the class `ImportFormat` was renamed to `Importer`
- [koppor#5](https://github.com/koppor/jabref/issues/5) When entries are found while dropping a pdf with xmp meta data the found entries will be displayed in the import dialog
- [koppor#61](https://github.com/koppor/jabref/issues/61) Display gray background text in "Author" and "Editor" field to assist newcomers

### Fixed
- Fixed [#2089](https://github.com/JabRef/jabref/issues/2089): Fixed faulty cite key generation
- Fixed [#2092](https://github.com/JabRef/jabref/issues/2092): "None"-button in date picker clears the date field
- Fixed [#1993](https://github.com/JabRef/jabref/issues/1993): Various optimizations regarding search performance
- Fixed [koppor#160](https://github.com/koppor/jabref/issues/160): Tooltips now working in the main table
Expand Down Expand Up @@ -88,6 +92,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed InvalidBackgroundColor flickering with Ctrl-s and File > Save database
- Fixed loop when pulling changes (shared database) when current selected field has changed
- Fixed [#1958](https://github.com/JabRef/jabref/issues/1958): Verbatim fields are no longer checked for HTML encoded characters by integrity checks
- Fixed [#1808](https://github.com/JabRef/jabref/issues/1808): Font preference dialog now keeps changes
- Fixed [#1937](https://github.com/JabRef/jabref/issues/1937): If no help page for the current chosen language exists, the english help page will be shown
- Fixed [#2060](https://github.com/JabRef/jabref/issues/2060): Medline fetcher now imports data in UTF-8 encoding
- Fixed file menu displays wrong hotkey in the German translation
Expand Down
18 changes: 7 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ buildscript {
}

plugins {
id "com.install4j.gradle" version "6.1.2"
id "com.install4j.gradle" version "6.1.3"
id 'com.github.johnrengelman.shadow' version '1.2.3'
// TODO replaced by spotless plugin, needs to be updated
id "com.github.youribonnaffe.gradle.format" version "1.5"
// If this is updated to 0.0.9, check configurations.errorprone
id "net.ltgt.errorprone" version "0.0.8"
id 'me.champeau.gradle.jmh' version '0.3.0'
id 'me.champeau.gradle.jmh' version '0.3.1'
}

apply plugin: "java"
Expand Down Expand Up @@ -247,6 +245,11 @@ test {
}
}

task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources

task databaseTest(type: Test) {
testClassesDir = sourceSets.databaseTest.output.classesDir
Expand All @@ -272,13 +275,6 @@ jacocoTestReport {
}
}

// enables `gradlew format`. Currently `LabelPatternUtil.java` is destroyed. Use with care!
format {
configurationFile = file('ide-settings/formatter_settings.xml')
// default: reformat main and test
//files = sourceSets.main.java
}

shadowJar {
classifier 'fat'

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 06 12:44:33 CEST 2016
#Tue Oct 11 00:24:20 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
5 changes: 5 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,9 @@ function splitJvmOpts() {
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
6 changes: 0 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ goto fail
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/net/sf/jabref/collab/FileUpdatePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import net.sf.jabref.gui.SidePaneManager;
import net.sf.jabref.logic.l10n.Localization;

public class FileUpdatePanel extends SidePaneComponent implements ActionListener,
ChangeScanner.DisplayResultCallback {

public static final String NAME = "fileUpdate";
public class FileUpdatePanel extends SidePaneComponent implements ActionListener, ChangeScanner.DisplayResultCallback {

private final SidePaneManager manager;

Expand Down Expand Up @@ -65,14 +62,19 @@ public BasePanel getPanel() {
*/
@Override
public void componentClosing() {
manager.unregisterComponent(FileUpdatePanel.NAME);
manager.unregisterComponent(FileUpdatePanel.class);
}

@Override
public int getRescalingWeight() {
return 0;
}

@Override
public ToggleAction getToggleAction() {
throw new UnsupportedOperationException();
}

/**
* actionPerformed
*
Expand Down
144 changes: 72 additions & 72 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -70,6 +69,7 @@
import net.sf.jabref.gui.importer.actions.AppendDatabaseAction;
import net.sf.jabref.gui.journals.AbbreviateAction;
import net.sf.jabref.gui.journals.UnabbreviateAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.maintable.MainTable;
import net.sf.jabref.gui.maintable.MainTableDataModel;
import net.sf.jabref.gui.maintable.MainTableFormat;
Expand Down Expand Up @@ -112,6 +112,7 @@
import net.sf.jabref.logic.util.io.FileUtil;
import net.sf.jabref.logic.util.io.RegExpFileSearch;
import net.sf.jabref.model.FieldChange;
import net.sf.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.database.BibDatabaseContext;
import net.sf.jabref.model.database.DatabaseLocation;
Expand Down Expand Up @@ -395,12 +396,6 @@ private void setupActions() {

});

// The action for toggling the groups interface
actions.put(Actions.TOGGLE_GROUPS, (BaseAction) () -> {
sidePaneManager.toggle("groups");
frame.groupToggle.setSelected(sidePaneManager.isComponentVisible("groups"));
});

actions.put(FindUnlinkedFilesDialog.ACTION_COMMAND, (BaseAction) () -> {
final FindUnlinkedFilesDialog dialog = new FindUnlinkedFilesDialog(frame, frame, BasePanel.this);
dialog.setLocationRelativeTo(frame);
Expand Down Expand Up @@ -434,65 +429,47 @@ public void init() {
// Run second, on a different thread:
@Override
public void run() {
BibEntry bes;

// First check if any entries have keys set already. If so, possibly remove
// them from consideration, or warn about overwriting keys.
// This is a partial clone of net.sf.jabref.gui.entryeditor.EntryEditor.GenerateKeyAction.actionPerformed(ActionEvent)
for (final Iterator<BibEntry> i = entries.iterator(); i.hasNext();) {
bes = i.next();
if (bes.hasCiteKey()) {
if (Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) {
// Remove the entry, because its key is already set:
i.remove();
} else if (Globals.prefs.getBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY)) {
// Ask if the user wants to cancel the operation:
CheckBoxMessage cbm = new CheckBoxMessage(
Localization.lang("One or more keys will be overwritten. Continue?"),
Localization.lang("Disable this confirmation dialog"), false);
final int answer = JOptionPane.showConfirmDialog(frame, cbm,
Localization.lang("Overwrite keys"), JOptionPane.YES_NO_OPTION);
if (cbm.isSelected()) {
Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, false);
}
if (answer == JOptionPane.NO_OPTION) {
// Ok, break off the operation.
canceled = true;
return;
}
// No need to check more entries, because the user has already confirmed
// that it's ok to overwrite keys:
break;
// We don't want to generate keys for entries which already have one thus remove the entries
if (Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) {
entries.removeIf(BibEntry::hasCiteKey);

// if we're going to override some cite keys warn the user about it
} else if (Globals.prefs.getBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY)) {
if (entries.parallelStream().anyMatch(BibEntry::hasCiteKey)) {
CheckBoxMessage cbm = new CheckBoxMessage(
Localization.lang("One or more keys will be overwritten. Continue?"),
Localization.lang("Disable this confirmation dialog"), false);
final int answer = JOptionPane.showConfirmDialog(frame, cbm,
Localization.lang("Overwrite keys"), JOptionPane.YES_NO_OPTION);
Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, !cbm.isSelected());

// The user doesn't want to overide cite keys
if (answer == JOptionPane.NO_OPTION) {
canceled = true;
return;
}
}
}

Map<BibEntry, String> oldvals = new HashMap<>();
// Iterate again, removing already set keys. This is skipped if overwriting
// is disabled, since all entries with keys set will have been removed.
if (!Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) {
for (BibEntry entry : entries) {
bes = entry;
// Store the old value:
oldvals.put(bes, bes.getCiteKeyOptional().orElse(null));
bes.clearCiteKey();
}
}

// generate the new cite keys for each entry
final NamedCompound ce = new NamedCompound(Localization.lang("Autogenerate BibTeX keys"));

// Finally, set the new keys:
AbstractBibtexKeyPattern citeKeyPattern = bibDatabaseContext.getMetaData()
.getCiteKeyPattern(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern());
for (BibEntry entry : entries) {
bes = entry;
BibtexKeyPatternUtil.makeLabel(bibDatabaseContext.getMetaData()
.getCiteKeyPattern(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern()),
bibDatabaseContext.getDatabase(),
bes, Globals.prefs.getBibtexKeyPatternPreferences());
ce.addEdit(new UndoableKeyChange(bibDatabaseContext.getDatabase(), bes, oldvals.get(bes),
bes.getCiteKeyOptional().orElse(null)));
String oldCiteKey = entry.getCiteKeyOptional().orElse("");
BibtexKeyPatternUtil.makeLabel(citeKeyPattern, bibDatabaseContext.getDatabase(),
entry, Globals.prefs.getBibtexKeyPatternPreferences());
String newCiteKey = entry.getCiteKeyOptional().orElse("");
if (!oldCiteKey.equals(newCiteKey)) {
ce.addEdit(new UndoableKeyChange(entry, oldCiteKey, newCiteKey));
}
}
ce.end();
getUndoManager().addEdit(ce);

// register the undo event only if new cite keys were generated
if (ce.hasEdits()) {
getUndoManager().addEdit(ce);
}
}

// Run third, on EDT:
Expand Down Expand Up @@ -1217,7 +1194,7 @@ public void listen(EntryAddedEvent addedEntryEvent) {
}

// Automatically add new entry to the selected group (or set of groups)
if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP) && frame.groupToggle.isSelected()) {
if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP) && frame.getGroupSelector().getToggleAction().isSelected()) {
final List<BibEntry> entries = Collections.singletonList(addedEntryEvent.getBibEntry());
final TreePath[] selection = frame.getGroupSelector().getGroupsTree().getSelectionPaths();
if (selection != null) {
Expand Down Expand Up @@ -1301,6 +1278,7 @@ public void listen(EntryChangedEvent entryChangedEvent) {

@Subscribe
public void listen(EntryRemovedEvent removedEntryEvent) {
// IMO only used to update the status (found X entries)
frame.getGlobalSearchBar().performSearch();
}
}
Expand Down Expand Up @@ -1381,6 +1359,30 @@ private void createMainTable() {
};
mainTable.addSelectionListener(groupsHighlightListener);

String clearSearch = "clearSearch";
mainTable.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.CLEAR_SEARCH), clearSearch);
mainTable.getActionMap().put(clearSearch, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
// need to close these here, b/c this action overshadows the responsible actions when the main table is selected
switch (mode) {
case SHOWING_NOTHING:
frame.getGlobalSearchBar().endSearch();
break;
case SHOWING_PREVIEW:
getPreviewPanel().close();
break;
case SHOWING_EDITOR:
case WILL_SHOW_EDITOR:
getCurrentEditor().close();
break;
default:
LOGGER.warn("unknown BasePanelMode: '" + mode + "', doing nothing");
break;
}
}
});

mainTable.getActionMap().put(Actions.CUT, new AbstractAction() {

@Override
Expand Down Expand Up @@ -1903,7 +1905,6 @@ public boolean showDeleteConfirmationDialog(int numberOfEntries) {
public void autoGenerateKeysBeforeSaving() {
if (Globals.prefs.getBoolean(JabRefPreferences.GENERATE_KEYS_BEFORE_SAVING)) {
NamedCompound ce = new NamedCompound(Localization.lang("Autogenerate BibTeX keys"));
boolean any = false;

for (BibEntry bes : bibDatabaseContext.getDatabase().getEntries()) {
Optional<String> oldKey = bes.getCiteKeyOptional();
Expand All @@ -1912,13 +1913,12 @@ public void autoGenerateKeysBeforeSaving() {
.getCiteKeyPattern(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern()),
bibDatabaseContext.getDatabase(),
bes, Globals.prefs.getBibtexKeyPatternPreferences());
ce.addEdit(new UndoableKeyChange(bibDatabaseContext.getDatabase(), bes, null,
bes.getCiteKeyOptional().get())); // Cite key is set here
any = true;
ce.addEdit(new UndoableKeyChange(bes, oldKey.orElse(""), bes.getCiteKeyOptional().get()));
}
}

// Store undo information, if any:
if (any) {
if (ce.hasEdits()) {
ce.end();
getUndoManager().addEdit(ce);
}
Expand Down Expand Up @@ -2117,15 +2117,15 @@ public void fileUpdated() {

// Check if there is already a notification about external
// changes:
boolean hasAlready = sidePaneManager.hasComponent(FileUpdatePanel.NAME);
boolean hasAlready = sidePaneManager.hasComponent(FileUpdatePanel.class);
if (hasAlready) {
sidePaneManager.hideComponent(FileUpdatePanel.NAME);
sidePaneManager.unregisterComponent(FileUpdatePanel.NAME);
sidePaneManager.hideComponent(FileUpdatePanel.class);
sidePaneManager.unregisterComponent(FileUpdatePanel.class);
}
FileUpdatePanel pan = new FileUpdatePanel(BasePanel.this, sidePaneManager,
getBibDatabaseContext().getDatabaseFile().orElse(null), scanner);
sidePaneManager.register(FileUpdatePanel.NAME, pan);
sidePaneManager.show(FileUpdatePanel.NAME);
sidePaneManager.register(pan);
sidePaneManager.show(FileUpdatePanel.class);
};

if (scanner.changesFound()) {
Expand All @@ -2149,10 +2149,10 @@ public void cleanUp() {
}
// Check if there is a FileUpdatePanel for this BasePanel being shown. If so,
// remove it:
if (sidePaneManager.hasComponent("fileUpdate")) {
FileUpdatePanel fup = (FileUpdatePanel) sidePaneManager.getComponent("fileUpdate");
if (sidePaneManager.hasComponent(FileUpdatePanel.class)) {
FileUpdatePanel fup = (FileUpdatePanel) sidePaneManager.getComponent(FileUpdatePanel.class);
if (fup.getPanel() == this) {
sidePaneManager.hideComponent("fileUpdate");
sidePaneManager.hideComponent(FileUpdatePanel.class);
}
}
}
Expand Down
Loading

0 comments on commit d4c9b88

Please sign in to comment.