Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into groupSorting
Browse files Browse the repository at this point in the history
* upstream/master:
  Implement #1359: collect telemetry (#2283)
  Write groups under tag `group` instead of `groupstree` to enhance compatibility with previous versions (#2704)
  Avoid conversion of single underscores (#2711)
  Fix #628: implement hierarchical keywords (#2703)
  • Loading branch information
Siedlerchr committed Apr 6, 2017
2 parents 2e86aa0 + 36b5381 commit ce38b4c
Show file tree
Hide file tree
Showing 92 changed files with 947 additions and 288 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We added a few properties to a group:
- Icon (with customizable color) that is shown in the groups panel (implements a [feature request in the forum](http://discourse.jabref.org/t/assign-colors-to-groups/321)).
- Description text that is shown on mouse hover (implements old feature requests [489](https://sourceforge.net/p/jabref/feature-requests/489/) and [818](https://sourceforge.net/p/jabref/feature-requests/818/)
- We introduced "automatic groups" that automatically create subgroups based on a certain criteria (e.g. a subgroup for every author or keyword). Implements [91](https://sourceforge.net/p/jabref/feature-requests/91/), [398](https://sourceforge.net/p/jabref/feature-requests/398/) and [#1173](https://github.com/JabRef/jabref/issues/1173).
- We introduced "automatic groups" that automatically create subgroups based on a certain criteria (e.g. a subgroup for every author or keyword) and supports hierarchies. Implements [91](https://sourceforge.net/p/jabref/feature-requests/91/), [398](https://sourceforge.net/p/jabref/feature-requests/398/) and [#1173](https://github.com/JabRef/jabref/issues/1173) and [#628](https://github.com/JabRef/jabref/issues/628).
- Expansion status of groups are saved across sessions. [#1428](https://github.com/JabRef/jabref/issues/1428)
- We removed the ordinals-to-superscript formatter from the recommendations for biblatex save actions [#2596](https://github.com/JabRef/jabref/issues/2596)
- The `Move linked files to default file directory`-Cleanup operation respects the `File directory pattern` setting
Expand All @@ -64,6 +64,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Entries with a single corporate author are now correclty exported to the corresponding `corporate` author field in MS-Office XML. [#1497](https://github.com/JabRef/jabref/issues/1497)
- Improved author handling in MS-Office Import/Export
- The `day` part of the biblatex `date` field is now exported to the corresponding `day` field in MS-Office XML. [#2691](https://github.com/JabRef/jabref/issues/2691)
- Single underscores are not converted during the LaTeX to unicode conversion, which does not follow the rules of LaTeX, but is what users require. [#2664](https://github.com/JabRef/jabref/issues/2664)

### Fixed
- We fixed an issue of duplicate keys after using a fetcher, e.g., DOI or ISBN [#2867](https://github.com/JabRef/jabref/issues/2687)
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ dependencies {

compile 'com.github.tomtung:latex2unicode_2.12:0.2'

compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '1.0.+'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '1.0.+'

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.7.21'
testCompile 'com.github.tomakehurst:wiremock:2.5.1'
Expand All @@ -163,7 +166,8 @@ processResources {
expand(version: project.version,
"year": String.valueOf(Calendar.getInstance().get(Calendar.YEAR)),
"authors": new File('AUTHORS').readLines().findAll { !it.startsWith("#") }.join(", "),
"developers": new File('DEVELOPERS').readLines().findAll { !it.startsWith("#") }.join(", "))
"developers": new File('DEVELOPERS').readLines().findAll { !it.startsWith("#") }.join(", "),
"azureInstrumentationKey": System.getenv('AzureInstrumentationKey'))
filteringCharset = 'UTF-8'
}
filteringCharset = 'UTF-8'
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.jabref;

import java.awt.Toolkit;
import java.util.UUID;

import org.jabref.collab.FileUpdateMonitor;
import org.jabref.gui.GlobalFocusListener;
import org.jabref.gui.StateManager;
Expand All @@ -13,6 +16,11 @@
import org.jabref.logic.util.BuildInfo;
import org.jabref.preferences.JabRefPreferences;

import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.TelemetryConfiguration;
import com.microsoft.applicationinsights.telemetry.SessionState;
import org.apache.commons.lang3.SystemUtils;

public class Globals {

// JabRef version info
Expand Down Expand Up @@ -44,6 +52,7 @@ public class Globals {
// Background tasks
private static GlobalFocusListener focusListener;
private static FileUpdateMonitor fileUpdateMonitor;
private static TelemetryClient telemetryClient;

private Globals() {
}
Expand All @@ -63,6 +72,30 @@ public static void startBackgroundTasks() {

Globals.fileUpdateMonitor = new FileUpdateMonitor();
JabRefExecutorService.INSTANCE.executeInterruptableTask(Globals.fileUpdateMonitor, "FileUpdateMonitor");

startTelemetryClient();
}

private static void stopTelemetryClient() {
telemetryClient.trackSessionState(SessionState.End);
telemetryClient.flush();
}

private static void startTelemetryClient() {
TelemetryConfiguration telemetryConfiguration = TelemetryConfiguration.getActive();
telemetryConfiguration.setInstrumentationKey(Globals.BUILD_INFO.getAzureInstrumentationKey());
telemetryConfiguration.setTrackingIsDisabled(!Globals.prefs.shouldCollectTelemetry());
telemetryClient = new TelemetryClient(telemetryConfiguration);
telemetryClient.getContext().getProperties().put("JabRef version", Globals.BUILD_INFO.getVersion().toString());
telemetryClient.getContext().getProperties().put("Java version", SystemUtils.JAVA_RUNTIME_VERSION);
telemetryClient.getContext().getUser().setId(Globals.prefs.getOrCreateUserId());
telemetryClient.getContext().getSession().setId(UUID.randomUUID().toString());
telemetryClient.getContext().getDevice().setOperatingSystem(SystemUtils.OS_NAME);
telemetryClient.getContext().getDevice().setOperatingSystemVersion(SystemUtils.OS_VERSION);
telemetryClient.getContext().getDevice().setScreenResolution(
Toolkit.getDefaultToolkit().getScreenSize().toString());

telemetryClient.trackSessionState(SessionState.Start);
}

public static GlobalFocusListener getFocusListener() {
Expand All @@ -77,4 +110,12 @@ public static void shutdownThreadPools() {
taskExecutor.shutdown();
JabRefExecutorService.INSTANCE.shutdownEverything();
}

public static void stopBackgroundTasks() {
stopTelemetryClient();
}

public static TelemetryClient getTelemetryClient() {
return telemetryClient;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ private static void start(String[] args) {
Authenticator.setDefault(new ProxyAuthenticator());
}

Globals.startBackgroundTasks();
Globals.prefs = preferences;
Globals.startBackgroundTasks();
Localization.setLanguage(preferences.get(JabRefPreferences.LANGUAGE));
Globals.prefs.setLanguageDependentDefaultValues();

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/collab/ChangeDisplayDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand All @@ -21,11 +20,12 @@
import javax.swing.tree.DefaultMutableTreeNode;

import org.jabref.gui.BasePanel;
import org.jabref.gui.JabRefDialog;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabase;

class ChangeDisplayDialog extends JDialog implements TreeSelectionListener {
class ChangeDisplayDialog extends JabRefDialog implements TreeSelectionListener {

private final JTree tree;
private final JPanel infoPanel = new JPanel();
Expand All @@ -38,7 +38,7 @@ class ChangeDisplayDialog extends JDialog implements TreeSelectionListener {

public ChangeDisplayDialog(JFrame owner, final BasePanel panel,
BibDatabase secondary, final DefaultMutableTreeNode root) {
super(owner, Localization.lang("External changes"), true);
super(owner, Localization.lang("External changes"), true, ChangeDisplayDialog.class);
BibDatabase localSecondary;

// Just to be sure, put in an empty secondary base if none is given:
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/jabref/gui/DialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ default void showErrorDialogAndWait(Exception exception) {
/**
* This will create and display a new confirmation dialog.
* It will include a blue question icon on the left and
* a OK and Cancel Button. To create a confirmation dialog with custom
* a OK and Cancel button. To create a confirmation dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*
* @return true if the use clicked "OK" otherwise false
Expand All @@ -74,13 +74,23 @@ default void showErrorDialogAndWait(Exception exception) {
/**
* Create and display a new confirmation dialog.
* It will include a blue question icon on the left and
* a OK (with given label) and Cancel Button. To create a confirmation dialog with custom
* a OK (with given label) and Cancel button. To create a confirmation dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*
* @return true if the use clicked "OK" otherwise false
*/
boolean showConfirmationDialogAndWait(String title, String content, String okButtonLabel);

/**
* Create and display a new confirmation dialog.
* It will include a blue question icon on the left and
* a OK (with given label) and Cancel (also with given label) button. To create a confirmation dialog with custom
* buttons see also {@link #showCustomButtonDialogAndWait(Alert.AlertType, String, String, ButtonType...)}
*
* @return true if the use clicked "OK" otherwise false
*/
boolean showConfirmationDialogAndWait(String title, String content, String okButtonLabel, String cancelButtonLabel);

/**
* This will create and display a new dialog of the specified
* {@link Alert.AlertType} but with user defined buttons as optional
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/gui/DuplicateResolverDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

import org.jabref.gui.help.HelpAction;
Expand All @@ -18,7 +17,7 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.JabRefPreferences;

public class DuplicateResolverDialog extends JDialog {
public class DuplicateResolverDialog extends JabRefDialog {

public enum DuplicateResolverType {
DUPLICATE_SEARCH,
Expand Down Expand Up @@ -46,14 +45,14 @@ public enum DuplicateResolverResult {
private MergeEntries me;

public DuplicateResolverDialog(JabRefFrame frame, BibEntry one, BibEntry two, DuplicateResolverType type) {
super(frame, Localization.lang("Possible duplicate entries"), true);
super(frame, Localization.lang("Possible duplicate entries"), true, DuplicateResolverDialog.class);
this.frame = frame;
init(one, two, type);
}

public DuplicateResolverDialog(ImportInspectionDialog dialog, BibEntry one, BibEntry two,
DuplicateResolverType type) {
super(dialog, Localization.lang("Possible duplicate entries"), true);
super(dialog, Localization.lang("Possible duplicate entries"), true, DuplicateResolverDialog.class);
this.frame = dialog.getFrame();
init(one, two, type);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/gui/EntryTypeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand Down Expand Up @@ -51,7 +50,7 @@
* Dialog that prompts the user to choose a type for an entry.
* Returns null if canceled.
*/
public class EntryTypeDialog extends JDialog implements ActionListener {
public class EntryTypeDialog extends JabRefDialog implements ActionListener {

private static final Log LOGGER = LogFactory.getLog(EntryTypeDialog.class);
private static final int COLUMN = 3;
Expand All @@ -65,7 +64,7 @@ public class EntryTypeDialog extends JDialog implements ActionListener {

public EntryTypeDialog(JabRefFrame frame) {
// modal dialog
super(frame, true);
super(frame, true, EntryTypeDialog.class);

this.frame = frame;

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/jabref/gui/FXDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public boolean showConfirmationDialogAndWait(String title, String content, Strin
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
}

@Override
public boolean showConfirmationDialogAndWait(String title, String content, String okButtonLabel, String cancelButtonLabel) {
FXDialog alert = createDialog(AlertType.CONFIRMATION, title, content);
ButtonType okButtonType = new ButtonType(okButtonLabel, ButtonBar.ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType(cancelButtonLabel, ButtonBar.ButtonData.NO);
alert.getButtonTypes().setAll(okButtonType, cancelButtonType);
return alert.showAndWait().filter(buttonType -> buttonType == okButtonType).isPresent();
}

@Override
public Optional<ButtonType> showCustomButtonDialogAndWait(AlertType type, String title, String content,
ButtonType... buttonTypes) {
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
Expand Down Expand Up @@ -88,7 +87,7 @@
/**
* GUI Dialog for the feature "Find unlinked files".
*/
public class FindUnlinkedFilesDialog extends JDialog {
public class FindUnlinkedFilesDialog extends JabRefDialog {
private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class);

/**
Expand Down Expand Up @@ -159,18 +158,8 @@ public class FindUnlinkedFilesDialog extends JDialog {

private boolean checkBoxWhyIsThereNoGetSelectedStupidSwing;

/**
* For Unit-testing only. <i>Don't remove!</i> <br>
* Used via reflection in {@link org.jabref.logic.importer.DatabaseFileLookupTest} to construct this
* class.
*/
@SuppressWarnings("unused")
private FindUnlinkedFilesDialog() {
//intended
}

public FindUnlinkedFilesDialog(Frame owner, JabRefFrame frame, BasePanel panel) {
super(owner, Localization.lang("Find unlinked files"), true);
super(owner, Localization.lang("Find unlinked files"), true, FindUnlinkedFilesDialog.class);
this.frame = frame;

restoreSizeOfDialog();
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/jabref/gui/GenFieldsCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
Expand All @@ -33,7 +32,7 @@
import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.layout.Sizes;

public class GenFieldsCustomizer extends JDialog {
public class GenFieldsCustomizer extends JabRefDialog {

private final JPanel buttons = new JPanel();
private final JButton ok = new JButton();
Expand All @@ -50,7 +49,7 @@ public class GenFieldsCustomizer extends JDialog {
private final JButton revert = new JButton();

public GenFieldsCustomizer(JabRefFrame frame) {
super(frame, Localization.lang("Set general fields"), false);
super(frame, Localization.lang("Set general fields"), false, GenFieldsCustomizer.class);
helpBut = new HelpAction(HelpFile.GENERAL_FIELDS).getHelpButton();
jbInit();
setSize(new Dimension(650, 300));
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/org/jabref/gui/JabRefDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.jabref.gui;

import java.awt.Frame;
import java.awt.Window;

import javax.swing.JDialog;

import org.jabref.Globals;

public class JabRefDialog extends JDialog {

public <T extends JabRefDialog> JabRefDialog(Frame owner, boolean modal, Class<T> clazz) {
super(owner, modal);

trackDialogOpening(clazz);
}

public <T extends JabRefDialog> JabRefDialog(Class<T> clazz) {
super();

trackDialogOpening(clazz);
}

public <T extends JabRefDialog> JabRefDialog(Frame owner, Class<T> clazz) {
super(owner);

trackDialogOpening(clazz);
}

public <T extends JabRefDialog> JabRefDialog(Window owner, String title, Class<T> clazz) {
super(owner, title);

trackDialogOpening(clazz);
}

private <T extends JabRefDialog> void trackDialogOpening(Class<T> clazz) {
Globals.getTelemetryClient().trackPageView(clazz.getName());
}

public <T extends JabRefDialog> JabRefDialog(Frame owner, String title, Class<T> clazz) {
this(owner, title, true, clazz);
}

public <T extends JabRefDialog> JabRefDialog(Frame owner, String title, boolean modal, Class<T> clazz) {
super(owner, title, modal);

trackDialogOpening(clazz);
}

public <T extends JabRefDialog> JabRefDialog(java.awt.Dialog owner, String title, Class<T> clazz) {
this(owner, title, true, clazz);
}

public <T extends JabRefDialog> JabRefDialog(java.awt.Dialog owner, String title, boolean modal, Class<T> clazz) {
super(owner, title, modal);

trackDialogOpening(clazz);
}
}
Loading

0 comments on commit ce38b4c

Please sign in to comment.