Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Browse files Browse the repository at this point in the history
…tofx

* upstream/master:
  Convert Strings Dialog to javafx (#3735)
  • Loading branch information
Siedlerchr committed Feb 18, 2019
2 parents b54535f + e5ede3a commit e9db4bf
Show file tree
Hide file tree
Showing 24 changed files with 537 additions and 603 deletions.
18 changes: 18 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -975,3 +975,21 @@ We want to have a look that matches our icons in the tool-bar */
.color-palette-region .button {
-fx-border-width: 0px;
}


.warning-icon {
-fx-fill: -jr-warn;
}

.error-icon {
-fx-text-fill: -jr-error;
-fx-fill: -jr-error;
}

.tooltip-warning {
-fx-background-color: -jr-warn;
}

.tooltip-error {
-fx-background-color: -jr-error;
}
107 changes: 39 additions & 68 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public class BasePanel extends StackPane {
// Used to track whether the base has changed since last save.
private BibEntry showing;

private StringDialog stringDialog;
private SuggestionProviders suggestionProviders;

@SuppressWarnings({"FieldCanBeLocal", "unused"}) private Subscription dividerPositionSubscription;
Expand Down Expand Up @@ -308,17 +307,6 @@ private void setupActions() {

actions.put(Actions.SELECT_ALL, mainTable.getSelectionModel()::selectAll);

// The action for opening the string editor
actions.put(Actions.EDIT_STRINGS, () -> {
if (stringDialog == null) {
StringDialog form = new StringDialog(frame, BasePanel.this, bibDatabaseContext.getDatabase());
form.setVisible(true);
stringDialog = form;
} else {
stringDialog.setVisible(true);
}
});

// The action for auto-generating keys.
actions.put(Actions.MAKE_KEY, new GenerateBibtexKeyAction(this, frame.getDialogService()));

Expand Down Expand Up @@ -374,36 +362,36 @@ private void setupActions() {

actions.put(Actions.MERGE_WITH_FETCHED_ENTRY, new MergeWithFetchedEntryAction(this, frame.getDialogService()));

actions.put(Actions.REPLACE_ALL, ()-> (new ReplaceStringAction(this)).execute());
actions.put(Actions.REPLACE_ALL, () -> (new ReplaceStringAction(this)).execute());

actions.put(new SpecialFieldValueViewModel(SpecialField.RELEVANCE.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));

actions.put(new SpecialFieldValueViewModel(SpecialField.QUALITY.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.QUALITY, undoManager).getSpecialFieldAction(SpecialField.QUALITY.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.QUALITY, undoManager).getSpecialFieldAction(SpecialField.QUALITY.getValues().get(0), frame));

actions.put(new SpecialFieldValueViewModel(SpecialField.PRINTED.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.PRINTED, undoManager).getSpecialFieldAction(SpecialField.PRINTED.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.PRINTED, undoManager).getSpecialFieldAction(SpecialField.PRINTED.getValues().get(0), frame));

for (SpecialFieldValue prio : SpecialField.PRIORITY.getValues()) {
actions.put(new SpecialFieldValueViewModel(prio).getCommand(),
new SpecialFieldViewModel(SpecialField.PRIORITY, undoManager).getSpecialFieldAction(prio, this.frame));
new SpecialFieldViewModel(SpecialField.PRIORITY, undoManager).getSpecialFieldAction(prio, this.frame));
}
for (SpecialFieldValue rank : SpecialField.RANKING.getValues()) {
actions.put(new SpecialFieldValueViewModel(rank).getCommand(),
new SpecialFieldViewModel(SpecialField.RANKING, undoManager).getSpecialFieldAction(rank, this.frame));
new SpecialFieldViewModel(SpecialField.RANKING, undoManager).getSpecialFieldAction(rank, this.frame));
}
for (SpecialFieldValue status : SpecialField.READ_STATUS.getValues()) {
actions.put(new SpecialFieldValueViewModel(status).getCommand(),
new SpecialFieldViewModel(SpecialField.READ_STATUS, undoManager).getSpecialFieldAction(status, this.frame));
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();
.withPreviewPanelEnabled(enabled)
.build();
Globals.prefs.storePreviewPreferences(newPreviewPreferences);
DefaultTaskExecutor.runInJavaFXThread(() -> setPreviewActiveBasePanels(enabled));
});
Expand Down Expand Up @@ -496,9 +484,9 @@ private void copyTitle() {
if (!selectedBibEntries.isEmpty()) {
// Collect all non-null titles.
List<String> titles = selectedBibEntries.stream()
.filter(bibEntry -> bibEntry.getTitle().isPresent())
.map(bibEntry -> bibEntry.getTitle().get())
.collect(Collectors.toList());
.filter(bibEntry -> bibEntry.getTitle().isPresent())
.map(bibEntry -> bibEntry.getTitle().get())
.collect(Collectors.toList());

if (titles.isEmpty()) {
output(Localization.lang("None of the selected entries have titles."));
Expand Down Expand Up @@ -530,8 +518,8 @@ private void copyCiteKey() {

String sb = String.join(",", keys);
String citeCommand = Optional.ofNullable(Globals.prefs.get(JabRefPreferences.CITE_COMMAND))
.filter(cite -> cite.contains("\\")) // must contain \
.orElse("\\cite");
.filter(cite -> cite.contains("\\")) // must contain \
.orElse("\\cite");
Globals.clipboardManager.setContent(citeCommand + "{" + sb + '}');

if (keys.size() == bes.size()) {
Expand Down Expand Up @@ -575,7 +563,7 @@ private void copyKeyAndTitle() {
Layout layout;
try {
layout = new LayoutHelper(sr, Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader))
.getLayoutFromText();
.getLayoutFromText();
} catch (IOException e) {
LOGGER.info("Could not get layout", e);
return;
Expand Down Expand Up @@ -719,12 +707,12 @@ private void createMainTable() {

// Update entry editor and preview according to selected entries
mainTable.addSelectionListener(event -> mainTable.getSelectedEntries()
.stream()
.findFirst()
.ifPresent(entry -> {
preview.setEntry(entry);
entryEditor.setEntry(entry);
}));
.stream()
.findFirst()
.ifPresent(entry -> {
preview.setEntry(entry);
entryEditor.setEntry(entry);
}));

// TODO: Register these actions globally
/*
Expand Down Expand Up @@ -814,8 +802,8 @@ public void setupMainPanel() {
// Saves the divider position as soon as it changes
// We need to keep a reference to the subscription, otherwise the binding gets garbage collected
dividerPositionSubscription = EasyBind.monadic(Bindings.valueAt(splitPane.getDividers(), 0))
.flatMap(SplitPane.Divider::positionProperty)
.subscribe((observable, oldValue, newValue) -> saveDividerLocation(newValue));
.flatMap(SplitPane.Divider::positionProperty)
.subscribe((observable, oldValue, newValue) -> saveDividerLocation(newValue));
}

/**
Expand Down Expand Up @@ -846,18 +834,6 @@ private void instantiateSearchAutoCompleter() {
}
}

public void assureStringDialogNotEditing() {
if (stringDialog != null) {
stringDialog.assureNotEditing();
}
}

public void updateStringDialog() {
if (stringDialog != null) {
stringDialog.refreshTable();
}
}

private void adjustSplitter() {
if (mode == BasePanelMode.SHOWING_PREVIEW) {
splitPane.setDividerPositions(Globals.prefs.getPreviewPreferences().getPreviewPanelDividerPosition().doubleValue());
Expand Down Expand Up @@ -945,9 +921,9 @@ public void previousPreviewStyle() {

private void cyclePreview(int newPosition) {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences()
.getBuilder()
.withPreviewCyclePosition(newPosition)
.build();
.getBuilder()
.withPreviewCyclePosition(newPosition)
.build();
Globals.prefs.storePreviewPreferences(previewPreferences);

preview.updateLayout(previewPreferences);
Expand Down Expand Up @@ -997,7 +973,7 @@ public void entryEditorClosing(EntryEditor editor) {
*/
public void ensureNotShowingBottomPanel(BibEntry entry) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry))
|| ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) {
|| ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) {
closeBottomPane();
}
}
Expand Down Expand Up @@ -1054,10 +1030,6 @@ public BibDatabase getDatabase() {
return bibDatabaseContext.getDatabase();
}

public void stringsClosing() {
stringDialog = null;
}

public void changeTypeOfSelectedEntries(String newType) {
List<BibEntry> bes = mainTable.getSelectedEntries();
changeType(bes, newType);
Expand Down Expand Up @@ -1105,11 +1077,11 @@ public boolean showDeleteConfirmationDialog(int numberOfEntries) {
}

return dialogService.showConfirmationDialogWithOptOutAndWait(title,
message,
okButton,
cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
message,
okButton,
cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
} else {
return true;
}
Expand All @@ -1125,16 +1097,15 @@ private void saveDividerLocation(Number position) {

if (mode == BasePanelMode.SHOWING_PREVIEW) {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences()
.getBuilder()
.withPreviewPanelDividerPosition(position)
.build();
.getBuilder()
.withPreviewPanelDividerPosition(position)
.build();
Globals.prefs.storePreviewPreferences(previewPreferences);
} else if (mode == BasePanelMode.SHOWING_EDITOR) {
preferences.setEntryEditorDividerPosition(position.doubleValue());
}
}


/**
* Perform necessary cleanup when this BasePanel is closed.
*/
Expand Down Expand Up @@ -1432,17 +1403,17 @@ public void action() {

Optional<LinkedFile> linkedFile = files.stream()
.filter(file -> (FieldName.URL.equalsIgnoreCase(file.getFileType())
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
.findFirst();

if (linkedFile.isPresent()) {

try {

JabRefDesktop.openExternalFileAnyFormat(bibDatabaseContext,
linkedFile.get().getLink(),
ExternalFileTypes.getInstance().fromLinkedFile(linkedFile.get(), true));
linkedFile.get().getLink(),
ExternalFileTypes.getInstance().fromLinkedFile(linkedFile.get(), true));

output(Localization.lang("External viewer called") + '.');
} catch (IOException e) {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.menus.FileHistoryMenu;
import org.jabref.gui.mergeentries.MergeEntriesAction;
import org.jabref.gui.metadata.BibtexStringEditorAction;
import org.jabref.gui.metadata.PreambleEditor;
import org.jabref.gui.push.PushToApplicationButton;
import org.jabref.gui.push.PushToApplications;
import org.jabref.gui.search.GlobalSearchBar;
Expand Down Expand Up @@ -848,7 +850,8 @@ private MenuBar createMenu() {

factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, dialogService)),
factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(this)),
factory.createMenuItem(StandardActions.EDIT_STRINGS, new OldDatabaseCommandWrapper(Actions.EDIT_STRINGS, this, Globals.stateManager))
factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(this))

);

Menu lookupIdentifiers = factory.createSubMenu(StandardActions.LOOKUP_DOC_IDENTIFIER);
Expand All @@ -857,6 +860,7 @@ private MenuBar createMenu() {
lookupIdentifiers.getItems().add(factory.createMenuItem(identifierAction.getAction(), identifierAction));
}

//@formatter:off
quality.getItems().addAll(
factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService)),
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(this)),
Expand Down Expand Up @@ -971,7 +975,7 @@ private MenuBar createMenu() {
),
factory.createMenuItem(StandardActions.ABOUT, new AboutAction())
);

//@formatter:on
MenuBar menu = new MenuBar();
menu.getStyleClass().add("mainMenu");
menu.getMenus().addAll(
Expand Down
Loading

0 comments on commit e9db4bf

Please sign in to comment.