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

New global search #8045

Merged
merged 51 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
91509f6
WIP Prepare for adding global search state
Siedlerchr Aug 30, 2021
754155c
Transform to BibEnty list
Siedlerchr Aug 30, 2021
0a6082c
use traditional approach
Siedlerchr Aug 31, 2021
3add3f6
remove observables
Siedlerchr Aug 31, 2021
774a3a5
Proof of concept for Global Search
Siedlerchr Aug 31, 2021
c64aeb4
Add library to sarch results
Siedlerchr Aug 31, 2021
ccdcb46
Add new custom dialog method without modality to enable floating window
Siedlerchr Aug 31, 2021
715d068
Merge remote-tracking branch 'upstream/main' into newGlobalSearch
Siedlerchr Aug 31, 2021
4be7161
update search results
Siedlerchr Aug 31, 2021
326d7ce
refactor
Siedlerchr Aug 31, 2021
0515e88
rename
Siedlerchr Aug 31, 2021
0d7ae9b
change to custom field
Siedlerchr Aug 31, 2021
2f202e4
remove special fields
Siedlerchr Sep 1, 2021
bff8b2b
move dialog to search bar
Siedlerchr Sep 1, 2021
11ad482
checkstyle
Siedlerchr Sep 1, 2021
128d8df
change column name
Siedlerchr Sep 1, 2021
5f38554
checkstyle
Siedlerchr Sep 1, 2021
8d37221
Change GlobalMode Button
Siedlerchr Sep 1, 2021
f2d76f0
Add Tooltip
Siedlerchr Sep 1, 2021
73b6103
fix checkstyle
Siedlerchr Sep 1, 2021
c844215
Update DialogService.java
calixtus Sep 1, 2021
a992002
refactor
Siedlerchr Sep 1, 2021
c362243
Merge branch 'newGlobalSearch' of github.com:JabRef/jabref into newGl…
Siedlerchr Sep 1, 2021
abf2bcf
remove empty line
Siedlerchr Sep 1, 2021
723acda
Add keep search string
Siedlerchr Sep 1, 2021
6231360
Fix css icon for button
Siedlerchr Sep 1, 2021
342f273
checkstyle
Siedlerchr Sep 1, 2021
8e9a5a0
checkstyle again argh
Siedlerchr Sep 1, 2021
44d6c31
fix some checkstle
Siedlerchr Sep 1, 2021
bb5988e
update search results
Siedlerchr Sep 1, 2021
ae228d4
Add Preview tab
Siedlerchr Sep 1, 2021
2068f11
fix accidentally deleted
Siedlerchr Sep 1, 2021
aceaed5
just install a new value table factory for the cell library
Siedlerchr Sep 1, 2021
0433973
WIP: prepare dialog
Siedlerchr Sep 1, 2021
4264a80
single selection
Siedlerchr Sep 1, 2021
c68ff82
remove groups matcher
Siedlerchr Sep 1, 2021
05ae012
inject
Siedlerchr Sep 1, 2021
35b53f7
Convert to GlobalSearchDialog to MVVM
calixtus Sep 1, 2021
1072743
Fixed conversion errors
calixtus Sep 1, 2021
df20354
always on top
Siedlerchr Sep 2, 2021
4a87e9c
Add checkbox for keeping dialog on top
Siedlerchr Sep 2, 2021
bdc5e95
Merge remote-tracking branch 'upstream/main' into newGlobalSearch
Siedlerchr Sep 2, 2021
2303465
check for global search active
Siedlerchr Sep 2, 2021
2fa9328
Remove explicit showNonModalCustomDialogAndWait
calixtus Sep 2, 2021
307cd72
Fixed keep always on top
calixtus Sep 2, 2021
a0bb0b6
Reduced scope of globalSearchActive property
calixtus Sep 2, 2021
d2a922a
Add CHANGELOG entry
koppor Sep 2, 2021
4572081
Add missing CHANGELOG entry
koppor Sep 2, 2021
e7f64fb
Fixed whitespaces
calixtus Sep 2, 2021
cb72abd
Merge remote-tracking branch 'upstream/newGlobalSearch' into newGloba…
calixtus Sep 2, 2021
0f70245
Remove empty line
koppor Sep 2, 2021
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 src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,13 @@ TextFlow > .tooltip-text-monospaced {
-fx-fill: -jr-search-text;
}


.mainToolbar .search-field .button .glyph-icon {
-fx-fill: -jr-search-text;
-fx-text-fill: -jr-search-text;
-fx-icon-color: -jr-search-text;
}

/* magnifier glass */
.mainToolbar .search-field .glyph-icon {
-fx-fill: -jr-search-text;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
-fx-background-color: -jr-background;
}

.mainToolbar .search-field .button .glyph-icon {
-fx-fill: derive(-fx-light-text-color, 80%);
-fx-text-fill: derive(-fx-light-text-color, 80%);
-fx-icon-color: derive(-fx-light-text-color, 80%);
}

.mainToolbar .search-field .toggle-button .glyph-icon {
-fx-fill: -jr-search-text;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/jabref/gui/DialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ boolean showConfirmationDialogWithOptOutAndWait(String title, String content,
*/
void showCustomDialog(BaseDialog<?> dialog);

/**
* This will create and display a new dialog showing a custom {@link DialogPane}
* and using custom {@link ButtonType}s.
*
*
*/
Optional<ButtonType> showNonModalCustomDialogAndWait(String title, DialogPane contentPane, ButtonType... buttonTypes);
koppor marked this conversation as resolved.
Show resolved Hide resolved

/**
* This will create and display a new dialog of the specified
* {@link Alert.AlertType} but with user defined buttons as optional
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
Expand Down Expand Up @@ -63,6 +64,7 @@
* advised to rather create a new sub class of {@link FXDialog}.
*/
public class JabRefDialogService implements DialogService {

// Snackbar dialog maximum size
public static final int DIALOG_SIZE_LIMIT = 300;

Expand Down Expand Up @@ -272,6 +274,20 @@ public Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane con
return alert.showAndWait();
}

@Override
public Optional<ButtonType> showNonModalCustomDialogAndWait(String title, DialogPane contentPane,
ButtonType... buttonTypes) {
FXDialog alert = new FXDialog(AlertType.NONE, title);
alert.initModality(Modality.NONE);
alert.setDialogPane(contentPane);
alert.getButtonTypes().setAll(buttonTypes);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.setResizable(true);
alert.initOwner(mainWindow);
preferences.getTheme().installCss(alert.getDialogPane().getScene());
return alert.showAndWait();
}

@Override
public <R> Optional<R> showCustomDialogAndWait(javafx.scene.control.Dialog<R> dialog) {
if (dialog.getOwner() == null) {
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public JabRefFrame(Stage mainStage) {
this.dialogService = new JabRefDialogService(mainStage, this, prefs);
this.stateManager = Globals.stateManager;
this.pushToApplicationsManager = new PushToApplicationsManager(dialogService, stateManager, prefs);
this.globalSearchBar = new GlobalSearchBar(this, stateManager, prefs);
this.undoManager = Globals.undoManager;
this.globalSearchBar = new GlobalSearchBar(this, stateManager, prefs, undoManager, dialogService);
this.fileHistory = new FileHistoryMenu(prefs, dialogService, getOpenDatabaseAction());
this.taskExecutor = Globals.TASK_EXECUTOR;
this.setOnKeyTyped(key -> {
Expand Down Expand Up @@ -593,10 +593,16 @@ public void init() {

// Subscribe to the search
EasyBind.subscribe(stateManager.activeSearchQueryProperty(),
query -> {
if (getCurrentLibraryTab() != null) {
getCurrentLibraryTab().setCurrentSearchQuery(query);
}
query -> {
if (prefs.getSearchPreferences().isKeepSearchStrng()) {
for (LibraryTab tab : getLibraryTabs()) {
tab.setCurrentSearchQuery(query);
}
} else {
if (getCurrentLibraryTab() != null) {
getCurrentLibraryTab().setCurrentSearchQuery(query);
}
}
});

// Wait for the scene to be created, otherwise focusOwnerProperty is not provided
Expand Down
17 changes: 4 additions & 13 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jabref.gui;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -109,7 +108,7 @@ public class LibraryTab extends Tab {
// initializing it so we prevent NullPointerException
private BackgroundTask<ParserResult> dataLoadingTask = BackgroundTask.wrap(() -> null);

private IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR);
private final IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR);

public LibraryTab(JabRefFrame frame,
PreferencesService preferencesService,
Expand Down Expand Up @@ -311,17 +310,9 @@ public void updateTabTitle(boolean isChanged) {
}

// Unique path fragment
List<String> uniquePathParts = FileUtil.uniquePathSubstrings(collectAllDatabasePaths());
Optional<String> uniquePathPart = uniquePathParts.stream()
.filter(part -> databasePath.toString().contains(part)
&& !part.equals(fileName) && part.contains(File.separator))
.findFirst();
if (uniquePathPart.isPresent()) {
String uniquePath = uniquePathPart.get();
// remove filename
uniquePath = uniquePath.substring(0, uniquePath.lastIndexOf(File.separator));
tabTitle.append(" \u2013 ").append(uniquePath);
}
Optional<String> uniquePathPart = FileUtil.getUniquePathFragment(collectAllDatabasePaths(), databasePath);
uniquePathPart.ifPresent(part -> tabTitle.append(" \u2013 ").append(part));

} else {
if (databaseLocation == DatabaseLocation.LOCAL) {
tabTitle.append(Localization.lang("untitled"));
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/jabref/gui/StateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ReadOnlyListProperty;
import javafx.beans.property.ReadOnlyListWrapper;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -52,10 +54,11 @@ public class StateManager {
private final OptionalObjectProperty<SearchQuery> activeSearchQuery = OptionalObjectProperty.empty();
private final ObservableMap<BibDatabaseContext, IntegerProperty> searchResultMap = FXCollections.observableHashMap();
private final OptionalObjectProperty<Node> focusOwner = OptionalObjectProperty.empty();
private final ObservableList<Task<?>> backgroundTasks = FXCollections.observableArrayList(task -> new Observable[]{task.progressProperty(), task.runningProperty()});
private final ObservableList<Task<?>> backgroundTasks = FXCollections.observableArrayList(task -> new Observable[] {task.progressProperty(), task.runningProperty()});
private final EasyBinding<Boolean> anyTaskRunning = EasyBind.reduce(backgroundTasks, tasks -> tasks.anyMatch(Task::isRunning));
private final EasyBinding<Double> tasksProgress = EasyBind.reduce(backgroundTasks, tasks -> tasks.filter(Task::isRunning).mapToDouble(Task::getProgress).average().orElse(1));
private final ObservableMap<String, DialogWindowState> dialogWindowStates = FXCollections.observableHashMap();
private final BooleanProperty globalSearch = new SimpleBooleanProperty();

public StateManager() {
activeGroups.bind(Bindings.valueAt(selectedGroups, activeDatabase.orElse(null)));
Expand Down Expand Up @@ -128,6 +131,18 @@ public void setSearchQuery(SearchQuery searchQuery) {
activeSearchQuery.setValue(Optional.of(searchQuery));
}

public void setGlobalSearchActive(boolean active) {
calixtus marked this conversation as resolved.
Show resolved Hide resolved
globalSearch.setValue(active);
}

public BooleanProperty globalSearchPropery() {
return globalSearch;
}

public boolean isGlobalSearchActive() {
return globalSearch.get();
}

public OptionalObjectProperty<Node> focusOwnerProperty() {
return focusOwner;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/icon/IconTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ public enum JabRefIcons implements JabRefIcon {
LINK(MaterialDesignL.LINK),
LINK_VARIANT(MaterialDesignL.LINK_VARIANT),
PROTECT_STRING(MaterialDesignC.CODE_BRACES),
SELECT_ICONS(MaterialDesignA.APPS);
SELECT_ICONS(MaterialDesignA.APPS),
KEEP_SEARCH_STRING(MaterialDesignE.EARTH),
OPEN_GLOBAL_SEARCH(MaterialDesignO.OPEN_IN_NEW);

private final JabRefIcon icon;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public MainTableDataModel(BibDatabaseContext context, PreferencesService prefere
IntegerProperty resultSize = new SimpleIntegerProperty();
resultSize.bind(Bindings.size(entriesFiltered));
stateManager.setActiveSearchResultSize(context, resultSize);
stateManager.setActiveSearchResultSize(context, resultSize);
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
// We need to wrap the list since otherwise sorting in the table does not work
entriesSorted = new SortedList<>(entriesFiltered);
groupViewMode = preferencesService.getGroupViewMode();

}

private boolean isMatched(ObservableList<GroupTreeNode> groups, Optional<SearchQuery> query, BibEntryTableViewModel entry) {
Expand Down
Loading