Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixlookupfulltext
Browse files Browse the repository at this point in the history
* upstream/master: (27 commits)
  remove wrong dependencies
  add missing dependencies
  Fix exception when adding field formatter in 'Cleanup entries' dialog
  Disables the preview cycling
  Removed unused method (#5219)
  Switch from tika-parsers to tika-core (#5217)
  Fix for issue 4629 (#5150)
  fix l10n, again
  fix l10n
  Fix checkstyle
  Removed old entrypreview and corresponding actions
  Prototype
  Add minor improvements and remove unused code
  Update CHANGELOG.md
  Update to current entry types and reformat code
  Convert Integer type to primitive
  Fix localization keys
  fix checkstyle again
  fix checkstyle erros
  Bibtexextractor
  ...
  • Loading branch information
Siedlerchr committed Aug 25, 2019
2 parents d2c4724 + 06f1049 commit 1846b24
Show file tree
Hide file tree
Showing 32 changed files with 498 additions and 180 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,4 @@ Yang Zongze
Yara Grassi Gouffon
Yifan Peng
Zhang Liang
Nikita Borovikov
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345)
- We added an option on the Linked File Viewer to rename the attached file of an entry directly on the JabRef. [#4844](https://github.com/JabRef/jabref/issues/4844)
- We added an option in the preference dialog box that allows user to enable helpful tooltips.[#3599](https://github.com/JabRef/jabref/issues/3599)
- We added a tool for extracting BibTeX entries from plain text. [#5206](https://github.com/JabRef/jabref/pull/5206)
- We moved the dropdown menu for selecting the push-application from the toolbar into the external application preferences. [#674](https://github.com/JabRef/jabref/issues/674)
- We removed the alphabetical ordering of the custom tabs and updated the error message when trying to create a general field with a name containing an illegal character. [#5019](https://github.com/JabRef/jabref/issues/5019)
- We added a context menu to the bib(la)tex-source-editor to copy'n'paste. [#5007](https://github.com/JabRef/jabref/pull/5007)
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dependencies {
compile 'org.apache.pdfbox:fontbox:2.0.16'
compile 'org.apache.pdfbox:xmpbox:2.0.16'

compile group: 'org.apache.tika', name: 'tika-parsers', version: '1.22'
compile group: 'org.apache.tika', name: 'tika-core', version: '1.22'

// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
compile 'org.bouncycastle:bcprov-jdk15on:1.62'
Expand All @@ -121,6 +121,7 @@ dependencies {

compile 'com.google.guava:guava:28.0-jre'


// JavaFX stuff
compile 'de.jensd:fontawesomefx-commons:8.15'
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
Expand Down
44 changes: 44 additions & 0 deletions docs/adr/0005-fully-support-utf8-only-for-latex-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Fully Support UTF-8 Only For LaTeX Files

## Context and Problem Statement

The feature [search for citations](https://github.com/JabRef/help.jabref.org/issues/210) displays the content of LaTeX files.
The LaTeX files are text files and might be encoded arbitrarily.

## Considered Options

* Support UTF-8 encoding only
* Support ASCII encoding only
* Support (nearly) all encodings

## Decision Outcome

Chosen option: "Support UTF-8 encoding only", because comes out best (see below).

### Positive Consequences

* All content of LaTeX files are displayed in JabRef

### Negative Consequences

* When a LaTeX files is encoded in another encoding, the user might see strange characters in JabRef

## Pros and Cons of the Options

### Support UTF-8 encoding only

* Good, because covers most tex file encodings
* Good, because easy to implement
* Bad, because does not support encodings used before around 2010

### Support ASCII encoding only

* Good, because easy to implement
* Bad, because does not support any encoding at all

### Support (nearly) all encodings

* Good, because easy to implement
* Bad, because it relies on Apache Tika's `CharsetDetector`, which resides in `tika-parsers`.
This causes issues during compilation (see https://github.com/JabRef/jabref/pull/3421#issuecomment-524532832).
Example: `error: module java.xml.bind reads package javax.activation from both java.activation and jakarta.activation`.
1 change: 1 addition & 0 deletions docs/adr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This log lists the architectural decisions for JabRef.
- [ADR-0002](0002-use-slf4j-for-logging.md) - Use slf4j together with log4j2 for logging
- [ADR-0003](0003-use-gradle-as-build-tool.md) - Use Gradle as build tool
- [ADR-0004](0004-use-mariadb-connector.md) - Use MariaDB Connector
- [ADR-0005](0005-fully-support-utf8-only-for-latex-files.md) - Fully Support UTF-8 Only For LaTeX Files

<!-- adrlogstop -->

Expand Down
103 changes: 14 additions & 89 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.jabref.gui.mergeentries.MergeEntriesAction;
import org.jabref.gui.mergeentries.MergeWithFetchedEntryAction;
import org.jabref.gui.preview.CitationStyleToClipboardWorker;
import org.jabref.gui.preview.PreviewPanel;
import org.jabref.gui.specialfields.SpecialFieldDatabaseChangeListener;
import org.jabref.gui.specialfields.SpecialFieldValueViewModel;
import org.jabref.gui.specialfields.SpecialFieldViewModel;
Expand Down Expand Up @@ -122,7 +121,6 @@ public class BasePanel extends StackPane {
// Keeps track of the string dialog if it is open.
private final Map<Actions, BaseAction> actions = new HashMap<>();
private final SidePaneManager sidePaneManager;
private final PreviewPanel preview;
private final BasePanelPreferences preferences;
private final ExternalFileTypes externalFileTypes;

Expand Down Expand Up @@ -179,8 +177,6 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas
this.getDatabase().registerListener(new UpdateTimestampListener(Globals.prefs));

this.entryEditor = new EntryEditor(this, externalFileTypes);

this.preview = new PreviewPanel(getBibDatabaseContext(), this, dialogService, externalFileTypes, Globals.getKeyPrefs(), preferences.getPreviewPreferences());
}

@Subscribe
Expand Down Expand Up @@ -263,8 +259,6 @@ private void setupActions() {
// The action for copying selected entries.
actions.put(Actions.COPY, this::copy);

actions.put(Actions.PRINT_PREVIEW, new PrintPreviewAction());

actions.put(Actions.CUT, this::cut);

actions.put(Actions.DELETE, () -> delete(false));
Expand Down Expand Up @@ -358,19 +352,6 @@ private void setupActions() {
new SpecialFieldViewModel(SpecialField.READ_STATUS, undoManager).getSpecialFieldAction(status, this.frame));
}

actions.put(Actions.TOGGLE_PREVIEW, () -> {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences();
boolean enabled = !previewPreferences.isPreviewPanelEnabled();
PreviewPreferences newPreviewPreferences = previewPreferences.getBuilder()
.withPreviewPanelEnabled(enabled)
.build();
Globals.prefs.storePreviewPreferences(newPreviewPreferences);
setPreviewActive(enabled);
});

actions.put(Actions.NEXT_PREVIEW_STYLE, this::nextPreviewStyle);
actions.put(Actions.PREVIOUS_PREVIEW_STYLE, this::previousPreviewStyle);

actions.put(Actions.SEND_AS_EMAIL, new SendAsEMailAction(frame));

actions.put(Actions.WRITE_XMP, new WriteXMPAction(this)::execute);
Expand Down Expand Up @@ -679,7 +660,6 @@ private void createMainTable() {
.stream()
.findFirst()
.ifPresent(entry -> {
preview.setEntry(entry);
entryEditor.setEntry(entry);
}));

Expand Down Expand Up @@ -816,9 +796,7 @@ private void instantiateSearchAutoCompleter() {
}

private void adjustSplitter() {
if (mode == BasePanelMode.SHOWING_PREVIEW) {
splitPane.setDividerPositions(Globals.prefs.getPreviewPreferences().getPreviewPanelDividerPosition().doubleValue());
} else if (mode == BasePanelMode.SHOWING_EDITOR) {
if (mode == BasePanelMode.SHOWING_EDITOR) {
splitPane.setDividerPositions(preferences.getEntryEditorDividerPosition());
}
}
Expand All @@ -844,17 +822,11 @@ public void showAndEdit(BibEntry entry) {
}

private void showBottomPane(BasePanelMode newMode) {
Node pane;
switch (newMode) {
case SHOWING_PREVIEW:
pane = preview;
break;
case SHOWING_EDITOR:
pane = entryEditor;
break;
default:
throw new UnsupportedOperationException("new mode not recognized: " + newMode.name());
if (newMode != BasePanelMode.SHOWING_EDITOR) {
throw new UnsupportedOperationException("new mode not recognized: " + newMode.name());
}
Node pane = entryEditor;

if (splitPane.getItems().size() == 2) {
splitPane.getItems().set(1, pane);
} else {
Expand All @@ -870,23 +842,6 @@ private void showAndEdit() {
}
}

/**
* Sets the given preview panel as the bottom component in the split panel. Updates the mode to SHOWING_PREVIEW.
*
* @param entry The entry to show in the preview.
*/
private void showPreview(BibEntry entry) {
showBottomPane(BasePanelMode.SHOWING_PREVIEW);

preview.setEntry(entry);
}

private void showPreview() {
if (!mainTable.getSelectedEntries().isEmpty()) {
showPreview(mainTable.getSelectedEntries().get(0));
}
}

public void nextPreviewStyle() {
cyclePreview(Globals.prefs.getPreviewPreferences().getPreviewCyclePosition() + 1);
}
Expand All @@ -901,16 +856,15 @@ private void cyclePreview(int newPosition) {
.withPreviewCyclePosition(newPosition)
.build();
Globals.prefs.storePreviewPreferences(previewPreferences);

preview.updateLayout(previewPreferences);
entryEditor.updatePreviewInTabs(previewPreferences);
}

/**
* Removes the bottom component.
*/
public void closeBottomPane() {
mode = BasePanelMode.SHOWING_NOTHING;
splitPane.getItems().removeAll(entryEditor, preview);
splitPane.getItems().remove(entryEditor);
}

/**
Expand All @@ -932,23 +886,17 @@ public void selectNextEntry() {
/**
* This method is called from an EntryEditor when it should be closed. We relay to the selection listener, which
* takes care of the rest.
*
* @param editor The entry editor to close.
*/
public void entryEditorClosing(EntryEditor editor) {
if (Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled()) {
showPreview(editor.getEntry());
} else {
closeBottomPane();
}
public void entryEditorClosing() {
closeBottomPane();
mainTable.requestFocus();
}

/**
* Closes the entry editor or preview panel if it is showing the given entry.
* Closes the entry editor if it is showing the given entry.
*/
public void ensureNotShowingBottomPanel(BibEntry entry) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry)) || ((mode == BasePanelMode.SHOWING_PREVIEW))) {
private void ensureNotShowingBottomPanel(BibEntry entry) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry))) {
closeBottomPane();
}
}
Expand Down Expand Up @@ -996,7 +944,7 @@ public BibDatabase getDatabase() {
return bibDatabaseContext.getDatabase();
}

public boolean showDeleteConfirmationDialog(int numberOfEntries) {
private boolean showDeleteConfirmationDialog(int numberOfEntries) {
if (Globals.prefs.getBoolean(JabRefPreferences.CONFIRM_DELETE)) {
String title = Localization.lang("Delete entry");
String message = Localization.lang("Really delete the selected entry?");
Expand Down Expand Up @@ -1029,13 +977,7 @@ private void saveDividerLocation(Number position) {
return;
}

if (mode == BasePanelMode.SHOWING_PREVIEW) {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences()
.getBuilder()
.withPreviewPanelDividerPosition(position)
.build();
Globals.prefs.storePreviewPreferences(previewPreferences);
} else if (mode == BasePanelMode.SHOWING_EDITOR) {
if (mode == BasePanelMode.SHOWING_EDITOR) {
preferences.setEntryEditorDividerPosition(position.doubleValue());
}
}
Expand Down Expand Up @@ -1093,14 +1035,6 @@ public String formatOutputMessage(String start, int count) {
return String.format("%s %d %s.", start, count, (count > 1 ? Localization.lang("entries") : Localization.lang("entry")));
}

private void setPreviewActive(boolean enabled) {
if (enabled) {
showPreview();
} else {
preview.close();
}
}

public CountingUndoManager getUndoManager() {
return undoManager;
}
Expand Down Expand Up @@ -1353,13 +1287,4 @@ public void action() {
markChangedOrUnChanged();
}
}

private class PrintPreviewAction implements BaseAction {

@Override
public void action() {
showPreview();
preview.print();
}
}
}
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/BasePanelMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

public enum BasePanelMode {
SHOWING_NOTHING,
SHOWING_PREVIEW,
SHOWING_EDITOR,
WILL_SHOW_EDITOR
}
8 changes: 7 additions & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.auximport.NewSubLibraryAction;
import org.jabref.gui.bibtexextractor.ExtractBibtexAction;
import org.jabref.gui.bibtexkeypattern.BibtexKeyPatternAction;
import org.jabref.gui.contentselector.ManageContentSelectorAction;
import org.jabref.gui.copyfiles.CopyFilesAction;
Expand Down Expand Up @@ -772,6 +773,7 @@ private MenuBar createMenu() {
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(this, stateManager)),
factory.createMenuItem(StandardActions.WRITE_XMP, new OldDatabaseCommandWrapper(Actions.WRITE_XMP, this, stateManager)),
factory.createMenuItem(StandardActions.COPY_LINKED_FILES, new CopyFilesAction(stateManager, this.getDialogService())),
factory.createMenuItem(StandardActions.EXTRACT_BIBTEX, new ExtractBibtexAction(stateManager)),

new SeparatorMenuItem(),

Expand Down Expand Up @@ -806,7 +808,6 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createCheckMenuItem(StandardActions.TOGGLE_PREVIEW, new OldDatabaseCommandWrapper(Actions.TOGGLE_PREVIEW, this, stateManager), Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled()),
factory.createMenuItem(StandardActions.NEXT_PREVIEW_STYLE, new OldDatabaseCommandWrapper(Actions.NEXT_PREVIEW_STYLE, this, stateManager)),
factory.createMenuItem(StandardActions.PREVIOUS_PREVIEW_STYLE, new OldDatabaseCommandWrapper(Actions.PREVIOUS_PREVIEW_STYLE, this, stateManager)),

Expand Down Expand Up @@ -1225,6 +1226,11 @@ public EditAction(Actions command) {
this.command = command;
}

@Override
public String toString() {
return this.command.toString();
}

@Override
public void execute() {
Node focusOwner = mainStage.getScene().getFocusOwner();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/gui/actions/ActionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static Label getAssociatedNode(MenuItem menuItem) {
}

public MenuItem configureMenuItem(Action action, Command command, MenuItem menuItem) {
ActionUtils.configureMenuItem(new JabRefAction(action, command, keyBindingRepository), menuItem);
ActionUtils.configureMenuItem(new JabRefAction(action, command, keyBindingRepository, Sources.FromMenu), menuItem);
setGraphic(menuItem, action);

// Show tooltips
Expand Down Expand Up @@ -105,7 +105,7 @@ public MenuItem createMenuItem(Action action, Command command) {
}

public CheckMenuItem createCheckMenuItem(Action action, Command command, boolean selected) {
CheckMenuItem checkMenuItem = ActionUtils.createCheckMenuItem(new JabRefAction(action, command, keyBindingRepository));
CheckMenuItem checkMenuItem = ActionUtils.createCheckMenuItem(new JabRefAction(action, command, keyBindingRepository, Sources.FromMenu));
checkMenuItem.setSelected(selected);
setGraphic(checkMenuItem, action);

Expand All @@ -127,7 +127,7 @@ public Menu createSubMenu(Action action, MenuItem... children) {
}

public Button createIconButton(Action action, Command command) {
Button button = ActionUtils.createButton(new JabRefAction(action, command, keyBindingRepository), ActionUtils.ActionTextBehavior.HIDE);
Button button = ActionUtils.createButton(new JabRefAction(action, command, keyBindingRepository, Sources.FromButton), ActionUtils.ActionTextBehavior.HIDE);

button.getStyleClass().setAll("icon-button");

Expand All @@ -140,7 +140,7 @@ public Button createIconButton(Action action, Command command) {

public ButtonBase configureIconButton(Action action, Command command, ButtonBase button) {
ActionUtils.configureButton(
new JabRefAction(action, command, keyBindingRepository),
new JabRefAction(action, command, keyBindingRepository, Sources.FromButton),
button,
ActionUtils.ActionTextBehavior.HIDE);

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/actions/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public enum Actions {
SELECT_ALL,
SEND_AS_EMAIL,
TOGGLE_GROUPS,
TOGGLE_PREVIEW,
UNABBREVIATE,
UNDO,
WRITE_XMP,
Expand Down
Loading

0 comments on commit 1846b24

Please sign in to comment.