Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Sharelatex Integration #2866

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1b545e4
Sharelatex Integration
Siedlerchr Aug 12, 2017
db29578
For debug purposes, add system out println
Siedlerchr Aug 25, 2017
446d914
Merge branch 'master' into sharelatex
koppor Oct 19, 2017
867679d
Merge remote-tracking branch 'origin/master' into sharelatex
koppor Oct 20, 2017
418aaad
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Oct 22, 2017
74ce5b9
Added classes for prefs
Siedlerchr Oct 22, 2017
0222168
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Oct 24, 2017
6e64369
set buttn txt to logging in
Siedlerchr Oct 24, 2017
0af05f0
Improve setting of enabled/diabled actions
Siedlerchr Oct 24, 2017
67f08a9
Fix checkstyle
Siedlerchr Oct 24, 2017
48dc385
Merge remote-tracking branch 'origin/master' into sharelatex
koppor Oct 26, 2017
c360278
Improve preferences handling
Siedlerchr Oct 27, 2017
e45e206
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Oct 27, 2017
a9d1632
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Nov 3, 2017
fac2c3d
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Nov 10, 2017
74151de
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Dec 13, 2017
c91fe49
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Dec 28, 2017
06685dd
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Feb 6, 2018
23bf919
fix build
Siedlerchr Feb 6, 2018
dfe262d
commit
Siedlerchr Feb 6, 2018
ada867a
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Feb 7, 2018
a8855fa
Add method for getting entry from position
lenhard Feb 7, 2018
093140a
Merge branch 'sharelatex' of github.com:JabRef/jabref into sharelatex
Siedlerchr Feb 7, 2018
855cd54
get position from json update message
Siedlerchr Feb 7, 2018
49b2c41
only parse if > 0
Siedlerchr Feb 7, 2018
65f7bb2
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Feb 7, 2018
b6d2984
Refactor ShareLatexPreferences
lenhard Feb 7, 2018
4920b9f
Merge branch 'sharelatex' of github.com:JabRef/jabref into sharelatex
lenhard Feb 7, 2018
10f1bad
improve parsing
Siedlerchr Feb 7, 2018
3eadbfb
Merge branch 'sharelatex' of github.com:JabRef/jabref into sharelatex
Siedlerchr Feb 7, 2018
0ae5f11
unncessary import
Siedlerchr Feb 7, 2018
172a03e
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Feb 24, 2018
61177b2
Implement first version of entries merging
Siedlerchr Feb 24, 2018
99aaa1f
fix checkstyle
Siedlerchr Feb 24, 2018
954f3ab
Merge remote-tracking branch 'origin/master' into sharelatex
koppor Aug 25, 2019
4223da5
add missing dependencies
Siedlerchr Aug 25, 2019
61a97a0
Merge remote-tracking branch 'upstream/master' into sharelatex
Siedlerchr Aug 25, 2019
23a49da
add missing diff match patch
Siedlerchr Aug 25, 2019
d473102
remove controller
Siedlerchr Aug 25, 2019
961a97d
fix action
Siedlerchr Aug 25, 2019
9e5e176
fix some more stuff
Siedlerchr Aug 25, 2019
cd82f04
fix compile errors
Siedlerchr Aug 25, 2019
8f214f1
Merge remote-tracking branch 'origin/master' into sharelatex
koppor Aug 25, 2019
017f40e
Merge remote-tracking branch 'origin/master' into sharelatex
koppor Aug 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ dependencies {
compile 'commons-logging:commons-logging:1.2'

compile 'org.jsoup:jsoup:1.10.3'

compile 'com.mashape.unirest:unirest-java:1.4.9'
compile 'info.debatty:java-string-similarity:0.24'

Expand All @@ -130,6 +131,12 @@ dependencies {
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '1.0.+'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '1.0.+'

compile "org.glassfish.tyrus.bundles:tyrus-standalone-client:1.13.1"
compile "org.glassfish.tyrus.ext:tyrus-extension-deflate:1.13.1"

compile "com.google.code.gson:gson:2.8.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have another JSON library in JabRef? Maybe via unirest-java?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have Guava. And gson is a much better json library than the default implementation

compile "org.bitbucket.cowwoc:diff-match-patch:1.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need another diff library? Can't we use the diff library already used in the merge entries dialog? It is OK, if we do. Then, please explain it somehow. Preferrably using MADR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is diff library is the same which is used on the server side of sharelatex


testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.8.47'
testCompile 'com.github.tomakehurst:wiremock:2.7.1'
Expand Down
10 changes: 10 additions & 0 deletions external-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ Project: Flowless
URL: https://github.com/TomasMikula/Flowless
License: BSD-2-Clause

Id: org.glassfish.tyrus.bundles:tyrus-standalone-client
Projekt: Tyrus
URL: https://tyrus.java.net/
Licence: CDDL 1.1 and GPL 2 with CPE

Id: com.google.code.gson:gson
Project: google-gson
URL: https://github.com/google/gson
License: Apache-2.0

Id: org.fxmisc.richtext:richtextfx
Project: RichTextFX
URL: https://github.com/TomasMikula/RichTextFX
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.remote.server.RemoteListenerServerLifecycle;
import org.jabref.logic.sharelatex.ShareLatexManager;
import org.jabref.logic.util.BuildInfo;
import org.jabref.preferences.JabRefPreferences;

Expand Down Expand Up @@ -48,6 +49,8 @@ public class Globals {
* Manager for the state of the GUI.
*/
public static StateManager stateManager = new StateManager();

public static ShareLatexManager shareLatexManager = new ShareLatexManager();
// Key binding preferences
private static KeyBindingRepository keyBindingRepository;
// Background tasks
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/DefaultInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.sharelatex.ShareLatexManager;
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.injection.Injector;
Expand Down Expand Up @@ -35,6 +36,8 @@ private static Object createDependency(Class<?> clazz) {
return Globals.journalAbbreviationLoader;
} else if (clazz == StateManager.class) {
return Globals.stateManager;
} else if (clazz == ShareLatexManager.class) {
return Globals.shareLatexManager;
} else {
try {
return clazz.newInstance();
Expand Down
35 changes: 23 additions & 12 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.jabref.gui.actions.Actions;
import org.jabref.gui.actions.AutoLinkFilesAction;
import org.jabref.gui.actions.ConnectToSharedDatabaseAction;
import org.jabref.gui.actions.DisconnectFromSharelatexAction;
import org.jabref.gui.actions.ErrorConsoleAction;
import org.jabref.gui.actions.IntegrityCheckAction;
import org.jabref.gui.actions.LookupIdentifierAction;
Expand All @@ -78,7 +79,9 @@
import org.jabref.gui.actions.NewSubDatabaseAction;
import org.jabref.gui.actions.OpenBrowserAction;
import org.jabref.gui.actions.SearchForUpdateAction;
import org.jabref.gui.actions.SendChangesToShareLatexAction;
import org.jabref.gui.actions.SortTabsAction;
import org.jabref.gui.actions.SynchronizeWithShareLatexAction;
import org.jabref.gui.autosaveandbackup.AutosaveUIManager;
import org.jabref.gui.bibtexkeypattern.BibtexKeyPatternDialog;
import org.jabref.gui.customentrytypes.EntryCustomizationDialog;
Expand Down Expand Up @@ -153,6 +156,7 @@
* The main window of the application.
*/
public class JabRefFrame extends JFrame implements OutputPrinter {

private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class);

// Frame titles.
Expand All @@ -170,13 +174,13 @@ public class JabRefFrame extends JFrame implements OutputPrinter {
private final JLabel statusLine = new JLabel("", SwingConstants.LEFT);
private final JLabel statusLabel = new JLabel(
Localization.lang("Status")
+ ':', SwingConstants.LEFT);
+ ':',
SwingConstants.LEFT);
private final JProgressBar progressBar = new JProgressBar();
private final FileHistoryMenu fileHistory = new FileHistoryMenu(prefs, this);
private final OpenDatabaseAction open = new OpenDatabaseAction(this, true);
private final EditModeAction editModeAction = new EditModeAction();


// Here we instantiate menu/toolbar actions. Actions regarding
// the currently open database are defined as a GeneralAction
// with a unique command string. This causes the appropriate
Expand Down Expand Up @@ -391,6 +395,10 @@ public void actionPerformed(ActionEvent e) {
Localization.lang("Unabbreviate journal names of the selected entries"),
Globals.getKeyPrefs().getKey(KeyBinding.UNABBREVIATE));
private final AbstractAction manageJournals = new ManageJournalsAction();
private final AbstractAction synchronizeWithSharelatex = new SynchronizeWithShareLatexAction();
private final AbstractAction sendChangesToShareLatex = new SendChangesToShareLatexAction();
private final AbstractAction disconnectFromSharelatex = new DisconnectFromSharelatexAction();

private final AbstractAction databaseProperties = new DatabasePropertiesAction();
private final AbstractAction bibtexKeyPattern = new BibtexKeyPatternAction();
private final AbstractAction errorConsole = new ErrorConsoleAction();
Expand Down Expand Up @@ -421,8 +429,7 @@ public void actionPerformed(ActionEvent e) {
private final GeneralAction findUnlinkedFiles = new GeneralAction(
FindUnlinkedFilesDialog.ACTION_COMMAND,
FindUnlinkedFilesDialog.ACTION_MENU_TITLE, FindUnlinkedFilesDialog.ACTION_SHORT_DESCRIPTION,
Globals.getKeyPrefs().getKey(KeyBinding.FIND_UNLINKED_FILES)
);
Globals.getKeyPrefs().getKey(KeyBinding.FIND_UNLINKED_FILES));
private final AutoLinkFilesAction autoLinkFile = new AutoLinkFilesAction();
// The action for adding a new entry of unspecified type.
private final NewEntryAction newEntryAction = new NewEntryAction(this, Globals.getKeyPrefs().getKey(KeyBinding.NEW_ENTRY));
Expand Down Expand Up @@ -613,9 +620,7 @@ public void windowClosing(WindowEvent e) {

// Poor-mans binding to global state
// We need to invoke this in the JavaFX thread as all the listeners sit there
Platform.runLater(() ->
Globals.stateManager.activeDatabaseProperty().setValue(Optional.of(currentBasePanel.getBibDatabaseContext()))
);
Platform.runLater(() -> Globals.stateManager.activeDatabaseProperty().setValue(Optional.of(currentBasePanel.getBibDatabaseContext())));
if (new SearchPreferences(Globals.prefs).isGlobalSearch()) {
globalSearchBar.performSearch();
} else {
Expand Down Expand Up @@ -707,7 +712,7 @@ public void setWindowTitle() {
String changeFlag = panel.isModified() && !isAutosaveEnabled ? "*" : "";
String databaseFile = panel.getBibDatabaseContext().getDatabaseFile().map(File::getPath)
.orElse(GUIGlobals.UNTITLED_TITLE);
setTitle(FRAME_TITLE + " - " + databaseFile + changeFlag + modeInfo);
setTitle(FRAME_TITLE + " - " + databaseFile + changeFlag + modeInfo);
} else if (panel.getBibDatabaseContext().getLocation() == DatabaseLocation.SHARED) {
setTitle(FRAME_TITLE + " - " + panel.getBibDatabaseContext().getDBMSSynchronizer().getDBName() + " ["
+ Localization.lang("shared") + "]" + modeInfo);
Expand Down Expand Up @@ -1056,6 +1061,10 @@ private void fillMenu() {
file.addSeparator();
file.add(connectToSharedDatabaseAction);
file.add(pullChangesFromSharedDatabase);
file.addSeparator();
file.add(synchronizeWithSharelatex);
file.add(sendChangesToShareLatex);
file.add(disconnectFromSharelatex);

file.addSeparator();
file.add(databaseProperties);
Expand Down Expand Up @@ -1332,6 +1341,7 @@ private void createToolBar() {
tlb.addAction(cleanupEntries);
tlb.addAction(mergeEntries);
tlb.addAction(pullChangesFromSharedDatabase);
tlb.addAction(synchronizeWithSharelatex);
tlb.addAction(openConsole);

tlb.addSeparator();
Expand Down Expand Up @@ -1582,7 +1592,7 @@ private void trackOpenNewDatabase(BasePanel basePanel) {

Map<String, String> properties = new HashMap<>();
Map<String, Double> measurements = new HashMap<>();
measurements.put("NumberOfEntries", (double)basePanel.getDatabaseContext().getDatabase().getEntryCount());
measurements.put("NumberOfEntries", (double) basePanel.getDatabaseContext().getDatabase().getEntryCount());

Globals.getTelemetryClient().ifPresent(client -> client.trackEvent("OpenNewDatabase", properties, measurements));
}
Expand Down Expand Up @@ -1927,6 +1937,7 @@ public GlobalSearchBar getGlobalSearchBar() {
}

private static class MyGlassPane extends JPanel {

public MyGlassPane() {
addKeyListener(new KeyAdapter() {
// Nothing
Expand Down Expand Up @@ -2087,8 +2098,7 @@ private class ChangeTabAction extends MnemonicAwareAction {
private final boolean next;

public ChangeTabAction(boolean next) {
putValue(Action.NAME, next ? Localization.menuTitle("Next tab") :
Localization.menuTitle("Previous tab"));
putValue(Action.NAME, next ? Localization.menuTitle("Next tab") : Localization.menuTitle("Previous tab"));
this.next = next;
putValue(Action.ACCELERATOR_KEY,
next ? Globals.getKeyPrefs().getKey(KeyBinding.NEXT_TAB) : Globals.getKeyPrefs().getKey(KeyBinding.PREVIOUS_TAB));
Expand Down Expand Up @@ -2125,7 +2135,8 @@ public EditAction(String command, String menuTitle, String description, KeyStrok
putValue(Action.SHORT_DESCRIPTION, description);
}

@Override public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {

LOGGER.debug(Globals.getFocusListener().getFocused().toString());
JComponent source = Globals.getFocusListener().getFocused();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jabref.gui.actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import org.jabref.Globals;

public class DisconnectFromSharelatexAction extends AbstractAction {

public DisconnectFromSharelatexAction() {
super();
putValue(Action.NAME, "Disconnect from ShareLaTeX");

}

@Override
public void actionPerformed(ActionEvent e) {
Globals.shareLatexManager.disconnectAndCloseConnection();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.jabref.gui.actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import org.jabref.Globals;
import org.jabref.gui.StateManager;
import org.jabref.logic.sharelatex.ShareLatexManager;

public class SendChangesToShareLatexAction extends AbstractAction {

public SendChangesToShareLatexAction() {
super();
putValue(Action.NAME, "Send changes to ShareLaTeX Server");

}

@Override
public void actionPerformed(ActionEvent e) {

ShareLatexManager manager = Globals.shareLatexManager;
StateManager stateManager = Globals.stateManager;
manager.sendNewDatabaseContent(stateManager.getActiveDatabase().get());
System.out.println("Send changes");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.jabref.gui.actions;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import javafx.application.Platform;

import org.jabref.gui.IconTheme;
import org.jabref.gui.sharelatex.ShareLatexLoginDialogView;

public class SynchronizeWithShareLatexAction extends AbstractAction {

public SynchronizeWithShareLatexAction() {
super();
putValue(Action.NAME, "Synchronize with ShareLaTeX");
putValue(Action.SMALL_ICON, IconTheme.getImage("sharelatex"));
putValue(Action.SHORT_DESCRIPTION, "Synchronize with ShareLaTeX");

}

@Override
public void actionPerformed(ActionEvent e) {
Platform.runLater(() -> new ShareLatexLoginDialogView().show());

}
}
4 changes: 1 addition & 3 deletions src/main/java/org/jabref/gui/entryeditor/SourceTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private Node createSourceEditor(BibEntry entry, BibDatabaseMode mode) {
codeArea.setEditable(false);
LOGGER.debug("Incorrect entry", ex);
}

return new VirtualizedScrollPane<>(codeArea);
}

Expand Down Expand Up @@ -206,8 +205,7 @@ private void storeSource() {
Localization.lang("Problem with parsing entry"),
Localization.lang("Error") + ": " + ex.getMessage(),
Localization.lang("Edit"),
Localization.lang("Revert to original source")
);
Localization.lang("Revert to original source"));

if (!keepEditing) {
// Revert
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.jabref.gui.sharelatex;

import javax.inject.Inject;

import javafx.fxml.FXML;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;

import org.jabref.gui.AbstractController;
import org.jabref.gui.DialogService;
import org.jabref.gui.FXDialog;
import org.jabref.gui.FXDialogService;
import org.jabref.logic.sharelatex.ShareLatexManager;

public class ShareLatexLoginDialogController extends AbstractController<ShareLatexLoginDialogViewModel> {

@FXML private TextField tbAddress;
@FXML private TextField tbUsername;
@FXML private PasswordField pfPassword;
@Inject private ShareLatexManager manager;

@FXML
private void initialize() {
viewModel = new ShareLatexLoginDialogViewModel();
}

@FXML
private void closeDialog() {
getStage().close();
}

@FXML
private void signIn() {

try {
String result = manager.login(tbAddress.getText(), tbUsername.getText(), pfPassword.getText());
if (result.contains("incorrect")) {
FXDialog dlg = new FXDialog(AlertType.ERROR);
dlg.setContentText("Your email or password is incorrect. Please try again");
dlg.showAndWait();
} else {
ShareLatexProjectDialogView dlgprojects = new ShareLatexProjectDialogView();
dlgprojects.show();
closeDialog();
}
} catch (Exception e) {
DialogService dlg = new FXDialogService();
dlg.showErrorDialogAndWait(e);

}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.jabref.gui.sharelatex;

import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.DialogPane;

import org.jabref.gui.AbstractDialogView;
import org.jabref.gui.FXDialog;

public class ShareLatexLoginDialogView extends AbstractDialogView {

@Override
public void show() {
FXDialog sharelatexProjectDialog = new FXDialog(AlertType.INFORMATION, "Sharelatex Project Dialog");
sharelatexProjectDialog.setDialogPane((DialogPane) this.getView());
sharelatexProjectDialog.setResizable(true);
sharelatexProjectDialog.show();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jabref.gui.sharelatex;

import org.jabref.gui.AbstractViewModel;

public class ShareLatexLoginDialogViewModel extends AbstractViewModel {
//default construtor used
}
Loading