Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into leakedthread
Browse files Browse the repository at this point in the history
* upstream/master:
  Extract v4.x changelog (#4125)
  Saves and reloads window state on close and on open (#4124)
  Fix convert to bibtex moves contents of the file field (#4123)
  Opens the directory of the currently edited file when opening a new file (#4106)
  Show Citation style also in entry preview in preferences (#4121)
  Mac graphics (#4074)
  The textarea in the PersonsEditor is focused when the field is focused (#4112)
  • Loading branch information
Siedlerchr committed Jun 13, 2018
2 parents defb6b2 + 4e50f63 commit 3880225
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 371 deletions.
382 changes: 25 additions & 357 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jabref.install4j
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</customScript>
<infoPlist mode="3" file="">
<content>&lt;key&gt;NSSupportsAutomaticGraphicsSwitching&lt;/key&gt;
&lt;string&gt;YES&lt;/string&gt;</content>
&lt;true/&gt;</content>
</infoPlist>
<iconImageFiles />
</launcher>
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class JabRefGUI {

private static final String NIMBUS_LOOK_AND_FEEL = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
private static final String WINDOWS_LOOK_AND_FEEL = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
private static final String OSX_AQUA_LOOk_AND_FEEL = "apple.laf.AquaLookAndFeel";
private static final String OSX_AQUA_LOOK_AND_FEEL = "apple.laf.AquaLookAndFeel";

private static final Logger LOGGER = LoggerFactory.getLogger(JabRefGUI.class);

Expand Down Expand Up @@ -155,6 +155,11 @@ private void openWindow(Stage mainStage) {
// do it here:
if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) {
mainStage.setMaximized(true);
} else {
mainStage.setX(Globals.prefs.getDouble(JabRefPreferences.POS_X));
mainStage.setY(Globals.prefs.getDouble(JabRefPreferences.POS_Y));
mainStage.setWidth(Globals.prefs.getDouble(JabRefPreferences.SIZE_X));
mainStage.setHeight(Globals.prefs.getDouble(JabRefPreferences.SIZE_Y));
}

Scene scene = new Scene(JabRefGUI.mainFrame, 800, 800);
Expand All @@ -165,6 +170,7 @@ private void openWindow(Stage mainStage) {
mainStage.show();

mainStage.setOnCloseRequest(event -> {
saveWindowState(mainStage);
boolean reallyQuit = mainFrame.quit();
if (!reallyQuit) {
event.consume();
Expand Down Expand Up @@ -203,6 +209,14 @@ private void openWindow(Stage mainStage) {
LOGGER.debug("Finished adding panels");
}

private void saveWindowState(Stage mainStage) {
Globals.prefs.putBoolean(JabRefPreferences.WINDOW_MAXIMISED, mainStage.isMaximized());
Globals.prefs.putDouble(JabRefPreferences.POS_X, mainStage.getX());
Globals.prefs.putDouble(JabRefPreferences.POS_Y, mainStage.getY());
Globals.prefs.putDouble(JabRefPreferences.SIZE_X, mainStage.getWidth());
Globals.prefs.putDouble(JabRefPreferences.SIZE_Y, mainStage.getHeight());
}

private void openLastEditedDatabases() {
if (Globals.prefs.get(JabRefPreferences.LAST_EDITED) == null) {
return;
Expand Down Expand Up @@ -248,7 +262,7 @@ private void setLookAndFeel() {
UIManager.setLookAndFeel(WINDOWS_LOOK_AND_FEEL);
}
if (OS.OS_X) {
UIManager.setLookAndFeel(OSX_AQUA_LOOk_AND_FEEL);
UIManager.setLookAndFeel(OSX_AQUA_LOOK_AND_FEEL);
} else {
UIManager.setLookAndFeel(NIMBUS_LOOK_AND_FEEL);
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private Region setupPanel(BibEntry entry, boolean compressed, SuggestionProvider
fields = determineFieldsToShow(entry, entryType);

List<Label> labels = new ArrayList<>();
boolean isFirstField = true;
for (String fieldName : fields) {
FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.TASK_EXECUTOR, dialogService,
Globals.journalAbbreviationLoader, Globals.prefs.getJournalAbbreviationPreferences(), Globals.prefs,
Expand All @@ -88,12 +89,10 @@ private Region setupPanel(BibEntry entry, boolean compressed, SuggestionProvider
fieldEditor.bindToEntry(entry);

editors.put(fieldName, fieldEditor);
/*
// TODO: Reenable this
if (i == 0) {
if (isFirstField) {
activeField = fieldEditor;
isFirstField = false;
}
*/

labels.add(new FieldNameLabel(fieldName));
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ public class PersonsEditor extends HBox implements FieldEditorFX {

@FXML private final PersonsEditorViewModel viewModel;

private EditorTextArea textArea;

public PersonsEditor(String fieldName, AutoCompleteSuggestionProvider<?> suggestionProvider, JabRefPreferences preferences, FieldCheckers fieldCheckers) {
this.viewModel = new PersonsEditorViewModel(fieldName, suggestionProvider, preferences.getAutoCompletePreferences(), fieldCheckers);

EditorTextArea textArea = new EditorTextArea();
textArea = new EditorTextArea();
HBox.setHgrow(textArea, Priority.ALWAYS);
textArea.textProperty().bindBidirectional(viewModel.textProperty());
textArea.addToContextMenu(EditorMenus.getNameMenu(textArea));
Expand All @@ -39,4 +41,10 @@ public void bindToEntry(BibEntry entry) {
public Parent getNode() {
return this;
}

@Override
public void requestFocus() {
textArea.requestFocus();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void execute() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(StandardFileType.BIBTEX_DB)
.withDefaultExtension(StandardFileType.BIBTEX_DB)
.withInitialDirectory(Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)))
.withInitialDirectory(getInitialDirectory())
.build();

List<Path> chosenFiles = ds.showFileOpenDialogAndGetMultipleFiles(fileDialogConfiguration);
Expand All @@ -101,6 +101,23 @@ public void execute() {
openFiles(filesToOpen, true);
}

/**
*
* @return Path of current panel database directory or the working directory
*/
private Path getInitialDirectory() {
if (frame.getBasePanelCount() == 0) {
return getWorkingDirectoryPath();
} else {
Optional<Path> databasePath = frame.getCurrentBasePanel().getBibDatabaseContext().getDatabasePath();
return databasePath.map(p -> p.getParent()).orElse(getWorkingDirectoryPath());
}
}

private Path getWorkingDirectoryPath() {
return Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY));
}

/**
* Opens the given file. If null or 404, nothing happens
*
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jabref.logic.citationstyle.CitationStyle;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.TestEntry;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.preferences.PreviewPreferences;

import com.google.common.primitives.Ints;
Expand Down Expand Up @@ -84,13 +85,15 @@ private void setupLogic() {
availableModel.removeElement(object);
chosenModel.addElement(object);
}
storeSettings();
});

btnLeft.addActionListener(event -> {
for (Object object : chosen.getSelectedValuesList()) {
availableModel.addElement(object);
chosenModel.removeElement(object);
}
storeSettings();
});

btnUp.addActionListener(event -> {
Expand All @@ -102,6 +105,7 @@ private void setupLogic() {
newSelectedIndices.add(newIndex);
}
chosen.setSelectedIndices(Ints.toArray(newSelectedIndices));
storeSettings();
});

btnDown.addActionListener(event -> {
Expand All @@ -115,6 +119,7 @@ private void setupLogic() {
newSelectedIndices.add(newIndex);
}
chosen.setSelectedIndices(Ints.toArray(newSelectedIndices));
storeSettings();
});

btnDefault.addActionListener(event -> layout.setText(Globals.prefs.getPreviewPreferences()
Expand All @@ -126,8 +131,19 @@ private void setupLogic() {
DefaultTaskExecutor.runInJavaFXThread(() -> {

PreviewPanel testPane = new PreviewPanel(null, null, Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), dialogService);
testPane.setFixedLayout(layout.getText());
testPane.setEntry(TestEntry.getTestEntry());
if (chosen.isSelectionEmpty()) {
testPane.setFixedLayout(layout.getText());
testPane.setEntry(TestEntry.getTestEntry());
}
else {
int indexStyle = chosen.getSelectedIndex();
PreviewPreferences preferences = Globals.prefs.getPreviewPreferences();
preferences = new PreviewPreferences(preferences.getPreviewCycle(),indexStyle,preferences.getPreviewPanelDividerPosition(),preferences.isPreviewPanelEnabled(), preferences.getPreviewStyle(),preferences.getPreviewStyleDefault());

testPane = new PreviewPanel(JabRefGUI.getMainFrame().getCurrentBasePanel(), new BibDatabaseContext(), Globals.getKeyPrefs(), preferences, dialogService);
testPane.setEntry(TestEntry.getTestEntry());
testPane.updateLayout(preferences);
}

DialogPane pane = new DialogPane();
pane.setContent(testPane);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/model/entry/EntryConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class EntryConverter {
EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("archiveprefix", FieldName.EPRINTTYPE);
EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put(FieldName.JOURNAL, FieldName.JOURNALTITLE);
EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put(FieldName.KEY, "sortkey");
EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put(FieldName.PDF, FieldName.FILE);
EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put("primaryclass", FieldName.EPRINTCLASS);
EntryConverter.FIELD_ALIASES_TEX_TO_LTX.put(FieldName.SCHOOL, FieldName.INSTITUTION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ private JabRefPreferences() {
defaults.put(POS_Y, 0);
defaults.put(SIZE_X, 1024);
defaults.put(SIZE_Y, 768);
defaults.put(WINDOW_MAXIMISED, Boolean.FALSE);
defaults.put(WINDOW_MAXIMISED, Boolean.TRUE);
defaults.put(AUTO_RESIZE_MODE, Boolean.TRUE);
defaults.put(ENTRY_EDITOR_HEIGHT, 0.65);
defaults.put(NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class PreviewPreferences {

private final List<String> previewCycle;
private final int previewCyclePosition;
private int previewCyclePosition;
private final Number previewPanelDividerPosition;
private final boolean previewPanelEnabled;
private final String previewStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public void cleanupMovesJournaltitleToJournal() {
assertEquals(Optional.empty(), entry.getField(FieldName.JOURNALTITLE));
assertEquals(Optional.of("Best of JabRef"), entry.getField(FieldName.JOURNAL));
}

@Test
public void cleanUpDoesntMoveFileField() {
String fileField = ":Ambriola2006 - On the Systematic Analysis of Natural Language Requirements with CIRCE.pdf:PDF";
BibEntry entry = new BibEntry().withField(FieldName.FILE, fileField);

worker.cleanup(entry);

assertEquals(Optional.of(fileField), entry.getField(FieldName.FILE));
}
}

0 comments on commit 3880225

Please sign in to comment.