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:
  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)
  select whole word when selecting search bar (#2149)
  • Loading branch information
Siedlerchr committed Oct 11, 2016
2 parents fc956bb + 3459ec3 commit dd32a00
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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
13 changes: 2 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 @@ -277,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
1 change: 1 addition & 0 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public void listChanged(ListEvent<BibEntry> e) {
}

final BibEntry newSelected = selected.get(0);
if ((panel.getMode() == BasePanelMode.SHOWING_EDITOR || panel.getMode() == BasePanelMode.WILL_SHOW_EDITOR)
&& newSelected == panel.getCurrentEditor().getEntry()) {
// entry already selected and currently editing it, do not steal the focus from the selected textfield
return;
}

if (newSelected != null) {
final BasePanelMode mode = panel.getMode(); // What is the panel already showing?
if ((mode == BasePanelMode.WILL_SHOW_EDITOR) || (mode == BasePanelMode.SHOWING_EDITOR)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public AppearancePrefsTab(JabRefPreferences prefs) {
overrideFonts.addActionListener(e -> fontSize.setEnabled(overrideFonts.isSelected()));

fontButton.addActionListener(
e -> new FontSelectorDialog(null, GUIGlobals.currentFont).getSelectedFont().ifPresent(x -> usedFont = x));
e -> new FontSelectorDialog(null, usedFont).getSelectedFont().ifPresent(x -> usedFont = x));

JPanel pan = builder.getPanel();
pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
Expand Down
85 changes: 50 additions & 35 deletions src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
* Preferences dialog. Contains a TabbedPane, and tabs will be defined in
* separate classes. Tabs MUST implement the PrefsTab interface, since this
Expand Down Expand Up @@ -153,21 +154,7 @@ public PreferencesDialog(JabRefFrame parent) {

// Import and export actions:
exportPreferences.setToolTipText(Localization.lang("Export preferences to file"));
exportPreferences.addActionListener(e -> {
FileDialog dialog = new FileDialog(frame).withExtension(FileExtensions.XML);
dialog.setDefaultExtension(FileExtensions.XML);
Optional<Path> path = dialog.saveNewFile();

path.ifPresent(exportFile -> {
try {
prefs.exportPreferences(exportFile.toString());
} catch (JabRefException ex) {
LOGGER.warn(ex.getMessage(), ex);
JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
Localization.lang("Export preferences"), JOptionPane.ERROR_MESSAGE);
}
});
});
exportPreferences.addActionListener(new ExportAction());

importPreferences.setToolTipText(Localization.lang("Import preferences from file"));
importPreferences.addActionListener(e -> {
Expand All @@ -182,6 +169,7 @@ public PreferencesDialog(JabRefFrame parent) {
JOptionPane.showMessageDialog(PreferencesDialog.this,
Localization.lang("You must restart JabRef for this to come into effect."),
Localization.lang("Import preferences"), JOptionPane.WARNING_MESSAGE);
this.dispose();
} catch (JabRefException ex) {
LOGGER.warn(ex.getMessage(), ex);
JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
Expand All @@ -191,7 +179,7 @@ public PreferencesDialog(JabRefFrame parent) {
});

showPreferences.addActionListener(
e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame).setVisible(true));
e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(prefs), frame).setVisible(true));
resetPreferences.addActionListener(e -> {
if (JOptionPane.showConfirmDialog(PreferencesDialog.this,
Localization.lang("Are you sure you want to reset all settings to default values?"),
Expand Down Expand Up @@ -229,6 +217,28 @@ private void updateAfterPreferenceChanges() {
Globals.prefs.updateEntryEditorTabList();
}

private void storeAllSettings(){
// First check that all tabs are ready to close:
Component[] preferenceTabs = main.getComponents();
for (Component tab: preferenceTabs) {
if (!((PrefsTab) tab).validateSettings()) {
return; // If not, break off.
}
}
// Then store settings and close:
for (Component tab: preferenceTabs) {
((PrefsTab) tab).storeSettings();
}
Globals.prefs.flush();

setVisible(false);
MainTable.updateRenderers();
GUIGlobals.updateEntryEditorColors();
frame.setupAllTables();
frame.getGroupSelector().revalidateGroups(); // icons may have changed
frame.output(Localization.lang("Preferences recorded."));
}


class OkAction extends AbstractAction {

Expand All @@ -238,27 +248,32 @@ public OkAction() {

@Override
public void actionPerformed(ActionEvent e) {
storeAllSettings();
}
}

// First check that all tabs are ready to close:
int count = main.getComponentCount();
Component[] comps = main.getComponents();
for (int i = 0; i < count; i++) {
if (!((PrefsTab) comps[i]).validateSettings()) {
return; // If not, break off.
}
}
// Then store settings and close:
for (int i = 0; i < count; i++) {
((PrefsTab) comps[i]).storeSettings();
}
Globals.prefs.flush();
class ExportAction extends AbstractAction {

setVisible(false);
MainTable.updateRenderers();
GUIGlobals.updateEntryEditorColors();
frame.setupAllTables();
frame.getGroupSelector().revalidateGroups(); // icons may have changed
frame.output(Localization.lang("Preferences recorded."));
public ExportAction() {
super("Export");
}

@Override
public void actionPerformed(ActionEvent e) {
FileDialog dialog = new FileDialog(frame).withExtension(FileExtensions.XML);
dialog.setDefaultExtension(FileExtensions.XML);
Optional<Path> path = dialog.saveNewFile();

path.ifPresent(exportFile -> {
try {
storeAllSettings();
Globals.prefs.exportPreferences(exportFile.toString());
} catch (JabRefException ex) {
LOGGER.warn(ex.getMessage(), ex);
JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
Localization.lang("Export preferences"), JOptionPane.WARNING_MESSAGE);
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ private void endSearch() {
public void focus() {
if (!searchField.hasFocus()) {
searchField.requestFocus();
searchField.selectAll();
}
}

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/net/sf/jabref/gui/search/SearchWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import net.sf.jabref.JabRefGUI;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.BasePanelMode;
import net.sf.jabref.gui.maintable.MainTableDataModel;
import net.sf.jabref.logic.search.SearchQuery;
import net.sf.jabref.model.database.BibDatabase;
Expand Down Expand Up @@ -92,14 +93,17 @@ private void updateUIWithSearchResult(List<BibEntry> matchedEntries) {
}

// only selects the first match if the selected entries are no hits or no entry is selected
List<BibEntry> selectedEntries = basePanel.getSelectedEntries();
boolean isHitSelected = selectedEntries.stream().anyMatch(BibEntry::isSearchHit);
if (!isHitSelected && !matchedEntries.isEmpty()) {
for (int i = 0; i < basePanel.getMainTable().getRowCount(); i++) {
BibEntry entry = basePanel.getMainTable().getEntryAt(i);
if (entry.isSearchHit()) {
basePanel.getMainTable().setSelected(i);
break;
// and no editor is open (to avoid jumping around when editing an entry)
if (basePanel.getMode() != BasePanelMode.SHOWING_EDITOR && basePanel.getMode() != BasePanelMode.WILL_SHOW_EDITOR) {
List<BibEntry> selectedEntries = basePanel.getSelectedEntries();
boolean isHitSelected = selectedEntries.stream().anyMatch(BibEntry::isSearchHit);
if (!isHitSelected && !matchedEntries.isEmpty()) {
for (int i = 0; i < basePanel.getMainTable().getRowCount(); i++) {
BibEntry entry = basePanel.getMainTable().getEntryAt(i);
if (entry.isSearchHit()) {
basePanel.getMainTable().setSelected(i);
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.database.BibDatabaseContext;
import net.sf.jabref.model.database.DatabaseLocation;
import net.sf.jabref.shared.DBMSConnection;
import net.sf.jabref.shared.DBMSConnectionProperties;
import net.sf.jabref.shared.DBMSType;
Expand Down Expand Up @@ -382,13 +384,11 @@ private void setLoadingConnectButtonText(boolean isLoading) {
*/
private boolean isSharedDatabaseAlreadyPresent() {
List<BasePanel> panels = JabRefGUI.getMainFrame().getBasePanelList();
for (BasePanel panel : panels) {
DBMSConnectionProperties dbmsConnectionProperties = panel.getBibDatabaseContext().getDBMSSynchronizer()
.getDBProcessor().getDBMSConnectionProperties();
if (this.connectionProperties.equals(dbmsConnectionProperties)) {
return true;
}
}
return false;
return panels.parallelStream().anyMatch(panel -> {
BibDatabaseContext context = panel.getBibDatabaseContext();
return ((context.getLocation() == DatabaseLocation.SHARED) &&
this.connectionProperties.equals(context.getDBMSSynchronizer()
.getDBProcessor().getDBMSConnectionProperties()));
});
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/sf/jabref/logic/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
public class Version {

public static final String JABREF_DOWNLOAD_URL = "http://www.fosshub.com/JabRef.html";
public static final String JABREF_DOWNLOAD_URL = "https://downloads.jabref.org";
private static final Log LOGGER = LogFactory.getLog(Version.class);
private static final String JABREF_GITHUB_URL = "https://api.github.com/repos/JabRef/jabref/releases/latest";

Expand Down

0 comments on commit dd32a00

Please sign in to comment.