Skip to content

Commit

Permalink
Merge pull request #3591 from JabRef/javafxTable
Browse files Browse the repository at this point in the history
Maintable leaves the Swing year and comes back in a new JavaFX dress
  • Loading branch information
tobiasdiez committed Jan 29, 2018
2 parents 3524c5d + 3a2ee4e commit e5bf83c
Show file tree
Hide file tree
Showing 155 changed files with 3,511 additions and 3,138 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We added [oaDOI](https://oadoi.org/) as a fulltext provider, so that JabRef is now able to provide fulltexts for more than 90 million open-access articles.
- We completely reworked and redesigned the main table.
- We changed one default of [Cleanup entries dialog](http://help.jabref.org/en/CleanupEntries): Per default, the PDF are not moved to the default file directory anymore. [#3619](https://github.com/JabRef/jabref/issues/3619)
- We completely reworked and redesigned the main table.
- We added the export of the the `translator` field to the according MS-Office XML field. [#1750, comment](https://github.com/JabRef/jabref/issues/1750#issuecomment-357350986)
- We changed the import of the MS-Office XML fields `bookauthor` and `translator`. Both are now imported to their corresponding bibtex/biblatex fields.
- We improved the export of the `address` and `location` field to the MS-Office XML fields. If the address field does not contain a comma, it is treated as single value and exported to the field `city`. [#1750, comment](https://github.com/JabRef/jabref/issues/1750#issuecomment-357539167)
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ dependencies {
compile 'de.codecentric.centerdevice:javafxsvg:1.2.1'
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
compile 'de.saxsys:mvvmfx-validation:1.7.0'
compile 'de.saxsys:mvvmfx:1.7.0'
compile 'org.fxmisc.easybind:easybind:1.0.3'
compile 'org.fxmisc.flowless:flowless:0.6'
compile 'org.fxmisc.richtext:richtextfx:0.8.1'
Expand Down Expand Up @@ -169,7 +170,7 @@ dependencies {
testCompile 'com.tngtech.archunit:archunit-junit:0.5.0'
testCompile 'org.slf4j:slf4j-jcl:1.7.25' // required by ArchUnit to enable logging over jcl
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit:4.0.+"
testCompile "org.testfx:testfx-junit5:4.0.+"

checkstyle 'com.puppycrawl.tools:checkstyle:8.7'
}
Expand Down
447 changes: 202 additions & 245 deletions src/main/java/org/jabref/gui/BasePanel.java

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions src/main/java/org/jabref/gui/BasePanelPreferences.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.jabref.gui;

import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;

import org.jabref.Globals;
import org.jabref.gui.autocompleter.AutoCompletePreferences;
import org.jabref.gui.entryeditor.EntryEditorPreferences;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.maintable.MainTablePreferences;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreviewPreferences;

import org.fxmisc.easybind.EasyBind;

public class BasePanelPreferences {
private MainTablePreferences tablePreferences;
private AutoCompletePreferences autoCompletePreferences;
private EntryEditorPreferences entryEditorPreferences;
private KeyBindingRepository keyBindings;
private PreviewPreferences previewPreferences;
private DoubleProperty entryEditorDividerPosition = new SimpleDoubleProperty();

public BasePanelPreferences(MainTablePreferences tablePreferences, AutoCompletePreferences autoCompletePreferences, EntryEditorPreferences entryEditorPreferences, KeyBindingRepository keyBindings, PreviewPreferences previewPreferences, Double entryEditorDividerPosition) {
this.tablePreferences = tablePreferences;
this.autoCompletePreferences = autoCompletePreferences;
this.entryEditorPreferences = entryEditorPreferences;
this.keyBindings = keyBindings;
this.previewPreferences = previewPreferences;
this.entryEditorDividerPosition.setValue(entryEditorDividerPosition);
}

public static BasePanelPreferences from(JabRefPreferences preferences) {
BasePanelPreferences basePanelPreferences = new BasePanelPreferences(
MainTablePreferences.from(preferences),
preferences.getAutoCompletePreferences(),
EntryEditorPreferences.from(preferences),
Globals.getKeyPrefs(),
preferences.getPreviewPreferences(),
preferences.getDouble(JabRefPreferences.ENTRY_EDITOR_HEIGHT));
EasyBind.subscribe(basePanelPreferences.entryEditorDividerPosition, value -> preferences.putDouble(JabRefPreferences.ENTRY_EDITOR_HEIGHT, value.doubleValue()));
return basePanelPreferences;
}

public double getEntryEditorDividerPosition() {
return entryEditorDividerPosition.get();
}

public void setEntryEditorDividerPosition(double entryEditorDividerPosition) {
this.entryEditorDividerPosition.set(entryEditorDividerPosition);
}

public DoubleProperty entryEditorDividerPositionProperty() {
return entryEditorDividerPosition;
}

public MainTablePreferences getTablePreferences() {
return tablePreferences;
}

public AutoCompletePreferences getAutoCompletePreferences() {
return autoCompletePreferences;
}

public void setAutoCompletePreferences(AutoCompletePreferences autoCompletePreferences) {
this.autoCompletePreferences = autoCompletePreferences;
}

public EntryEditorPreferences getEntryEditorPreferences() {
return entryEditorPreferences;
}

public KeyBindingRepository getKeyBindings() {
return keyBindings;
}

public PreviewPreferences getPreviewPreferences() {
return previewPreferences;
}
}
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/DragDropPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ public void mouseReleased(MouseEvent e) {
static class MarkerPane extends JPanel {

private Point locationP;
private final IconTheme.JabRefIcon moveTabArrow;
private final JabRefIcon moveTabArrow;


public MarkerPane() {
setOpaque(false);

// Sets the marker fontIcon
moveTabArrow = IconTheme.JabRefIcon.MOVE_TAB_ARROW;
moveTabArrow = IconTheme.JabRefIcons.MOVE_TAB_ARROW;
}

@Override
Expand All @@ -141,7 +141,7 @@ public void paintComponent(Graphics g) {
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.9f)); // Set transparency
g.setFont(IconTheme.FONT.deriveFont(Font.BOLD, 24f));
g.drawString(moveTabArrow.getCode(), locationP.x - (moveTabArrow.getIcon().getIconWidth() / 2),
moveTabArrow.getSmallIcon().paintIcon(this, g, locationP.x - (moveTabArrow.getIcon().getIconWidth() / 2),
locationP.y + (moveTabArrow.getIcon().getIconHeight() / 2));

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/EntryTypeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ protected void done() {
final BibEntry bibEntry = result.get();
if ((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) {
//If there are duplicates starts ImportInspectionDialog
final BasePanel panel = (BasePanel) frame.getTabbedPane().getSelectedComponent();
final BasePanel panel = frame.getCurrentBasePanel();

ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false);
diag.addEntry(bibEntry);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public class FindUnlinkedFilesDialog extends JabRefDialog {
/**
* Keys to be used for referencing this Action.
*/
public static final String ACTION_COMMAND = "findUnlinkedFiles";
public static final String ACTION_MENU_TITLE = Localization.menuTitle("Find unlinked files...");

public static final String ACTION_SHORT_DESCRIPTION = Localization
Expand Down Expand Up @@ -987,7 +986,7 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
if (value instanceof EntryFromFileCreator) {
EntryFromFileCreator creator = (EntryFromFileCreator) value;
if (creator.getExternalFileType() != null) {
label.setIcon(creator.getExternalFileType().getIcon());
label.setIcon(creator.getExternalFileType().getIcon().getSmallIcon());
}
}
return label;
Expand Down
95 changes: 0 additions & 95 deletions src/main/java/org/jabref/gui/GUIGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
import java.awt.Color;
import java.awt.Font;
import java.awt.Toolkit;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JLabel;

import org.jabref.Globals;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.keyboard.EmacsKeyBindings;
import org.jabref.gui.specialfields.SpecialFieldViewModel;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.specialfields.SpecialField;
import org.jabref.preferences.JabRefPreferences;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -44,24 +35,11 @@ public class GUIGlobals {
// Colors.
public static final Color ENTRY_EDITOR_LABEL_COLOR = new Color(100, 100, 150); // Empty field, blue.

static final Color INACTIVE_TABBED_COLOR = Color.black; // inactive Database
private static final Log LOGGER = LogFactory.getLog(GUIGlobals.class);
private static final Map<String, JLabel> TABLE_ICONS = new HashMap<>(); // Contains table icon mappings. Set up
static final Color ACTIVE_TABBED_COLOR = ENTRY_EDITOR_LABEL_COLOR.darker(); // active Database (JTabbedPane)

private GUIGlobals() {
}

public static JLabel getTableIcon(String fieldType) {
JLabel label = GUIGlobals.TABLE_ICONS.get(fieldType);
if (label == null) {
LOGGER.info("Error: no table icon defined for type '" + fieldType + "'.");
return null;
} else {
return label;
}
}

public static void updateEntryEditorColors() {
GUIGlobals.activeBackgroundColor = JabRefPreferences.getInstance().getColor(JabRefPreferences.ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR);
GUIGlobals.validFieldBackgroundColor = JabRefPreferences.getInstance().getColor(JabRefPreferences.VALID_FIELD_BACKGROUND_COLOR);
Expand All @@ -75,79 +53,6 @@ public static void updateEntryEditorColors() {
* on Un*x is unavailable.
*/
public static void init() {
JLabel label;
label = new JLabel(IconTheme.JabRefIcon.PDF_FILE.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " PDF");
GUIGlobals.TABLE_ICONS.put(FieldName.PDF, label);

label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " URL");
GUIGlobals.TABLE_ICONS.put(FieldName.URL, label);

label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " CiteSeer URL");
GUIGlobals.TABLE_ICONS.put("citeseerurl", label);

label = new JLabel(IconTheme.JabRefIcon.WWW.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " ArXiv URL");
GUIGlobals.TABLE_ICONS.put(FieldName.EPRINT, label);

label = new JLabel(IconTheme.JabRefIcon.DOI.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " DOI " + Localization.lang("web link"));
GUIGlobals.TABLE_ICONS.put(FieldName.DOI, label);

label = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon());
label.setToolTipText(Localization.lang("Open") + " PS");
GUIGlobals.TABLE_ICONS.put(FieldName.PS, label);

label = new JLabel(IconTheme.JabRefIcon.FOLDER.getSmallIcon());
label.setToolTipText(Localization.lang("Open folder"));
GUIGlobals.TABLE_ICONS.put(FieldName.FOLDER, label);

label = new JLabel(IconTheme.JabRefIcon.FILE.getSmallIcon());
label.setToolTipText(Localization.lang("Open file"));
GUIGlobals.TABLE_ICONS.put(FieldName.FILE, label);

for (ExternalFileType fileType : ExternalFileTypes.getInstance().getExternalFileTypeSelection()) {
label = new JLabel(fileType.getIcon());
label.setToolTipText(Localization.lang("Open %0 file", fileType.getName()));
GUIGlobals.TABLE_ICONS.put(fileType.getName(), label);
}

SpecialFieldViewModel relevanceViewModel = new SpecialFieldViewModel(SpecialField.RELEVANCE);
label = new JLabel(relevanceViewModel.getRepresentingIcon());
label.setToolTipText(relevanceViewModel.getLocalization());
GUIGlobals.TABLE_ICONS.put(SpecialField.RELEVANCE.getFieldName(), label);

SpecialFieldViewModel qualityViewModel = new SpecialFieldViewModel(SpecialField.QUALITY);
label = new JLabel(qualityViewModel.getRepresentingIcon());
label.setToolTipText(qualityViewModel.getLocalization());
GUIGlobals.TABLE_ICONS.put(SpecialField.QUALITY.getFieldName(), label);

// Ranking item in the menu uses one star
SpecialFieldViewModel rankViewModel = new SpecialFieldViewModel(SpecialField.RANKING);
label = new JLabel(rankViewModel.getRepresentingIcon());
label.setToolTipText(rankViewModel.getLocalization());
GUIGlobals.TABLE_ICONS.put(SpecialField.RANKING.getFieldName(), label);

// Priority icon used for the menu
SpecialFieldViewModel priorityViewModel = new SpecialFieldViewModel(SpecialField.PRIORITY);
label = new JLabel(priorityViewModel.getRepresentingIcon());
label.setToolTipText(priorityViewModel.getLocalization());
GUIGlobals.TABLE_ICONS.put(SpecialField.PRIORITY.getFieldName(), label);

// Read icon used for menu
SpecialFieldViewModel readViewModel = new SpecialFieldViewModel(SpecialField.READ_STATUS);
label = new JLabel(readViewModel.getRepresentingIcon());
label.setToolTipText(readViewModel.getLocalization());
GUIGlobals.TABLE_ICONS.put(SpecialField.READ_STATUS.getFieldName(), label);

// Print icon used for menu
SpecialFieldViewModel printedViewModel = new SpecialFieldViewModel(SpecialField.PRINTED);
label = new JLabel(printedViewModel.getRepresentingIcon());
label.setToolTipText(printedViewModel.getLocalization());
GUIGlobals.TABLE_ICONS.put(SpecialField.PRINTED.getFieldName(), label);

if (Globals.prefs.getBoolean(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS)) {
EmacsKeyBindings.load();
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jabref/gui/GenFieldsCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import javax.swing.AbstractAction;
import javax.swing.ActionMap;
Expand All @@ -21,7 +23,6 @@
import javax.swing.JTextArea;

import org.jabref.Globals;
import org.jabref.gui.entryeditor.EntryEditorTabList;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.logic.bibtexkeypattern.BibtexKeyGenerator;
Expand Down Expand Up @@ -143,11 +144,10 @@ private void okActionPerformed() {
private void setFieldsText() {
StringBuilder sb = new StringBuilder();

EntryEditorTabList tabList = Globals.prefs.getEntryEditorTabList();
for (int i = 0; i < tabList.getTabCount(); i++) {
sb.append(tabList.getTabName(i));
for (Map.Entry<String, List<String>> tab : Globals.prefs.getEntryEditorTabList().entrySet()) {
sb.append(tab.getKey());
sb.append(':');
sb.append(String.join(";", tabList.getTabFields(i)));
sb.append(String.join(";", tab.getValue()));
sb.append('\n');
}

Expand Down
Loading

0 comments on commit e5bf83c

Please sign in to comment.