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

Rework search bar #6682

Merged
merged 9 commits into from
Jul 17, 2020
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We merged the main table tabs in the preferences dialog. [#6518](https://github.com/JabRef/jabref/pull/6518)
- We changed the command line option 'generateBibtexKeys' to the more generic term 'generateCitationKeys' while the short option remains 'g'.[#6545](https://github.com/JabRef/jabref/pull/6545)
- We improved the "Possible duplicate entries" window to remember its size and position throughout a session. [#6582](https://github.com/JabRef/jabref/issues/6582)
- We divided the toolbar into small parts, so if the application window is to small, only a part of the toolbar is moved into the chevron popup. [#6682](https://github.com/JabRef/jabref/pull/6682)

### Fixed

Expand Down Expand Up @@ -95,6 +96,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue with the creation of a group of cited entries which incorrectly showed the message that the library had been modified externally whenever saving the library. [#6420](https://github.com/JabRef/jabref/issues/6420)
- We fixed an issue with the creation of a group of cited entries. Now the file path to an aux file gets validated. [#6585](https://github.com/JabRef/jabref/issues/6585)
- We fixed an issue on Linux systems where the application would crash upon inotify failure. Now, the user is prompted with a warning, and given the choice to continue the session. [#6073](https://github.com/JabRef/jabref/issues/6073)
- We moved the search modifier buttons into the search bar, as they were not accessible, if autocompletion was disabled. [#6625](https://github.com/JabRef/jabref/issues/6625)

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private boolean exportMatches(List<ParserResult> loaded) {
BibDatabaseContext databaseContext = pr.getDatabaseContext();
BibDatabase dataBase = pr.getDatabase();

SearchPreferences searchPreferences = new SearchPreferences(Globals.prefs);
SearchPreferences searchPreferences = Globals.prefs.getSearchPreferences();
SearchQuery query = new SearchQuery(searchTerm, searchPreferences.isCaseSensitive(),
searchPreferences.isRegularExpression());
List<BibEntry> matches = new DatabaseSearcher(query, dataBase).getMatches();
Expand Down
37 changes: 31 additions & 6 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@
-fx-padding: 0.5em;
}

.toggle-button:hover,
.toggle-button:selected:hover,
.icon-buttonNoSpaceBottom:hover,
.icon-buttonNoSpaceTop:hover,
.icon-button:hover {
Expand All @@ -374,8 +376,9 @@
-fx-fill: white;
}

.toggle-button:selected.icon-button:selected {
-fx-background-color: transparent;
.toggle-button:selected {
-fx-background-color: -jr-icon-background-active;
-fx-text-fill: -jr-selected;
-fx-fill: -jr-selected;
}

Expand Down Expand Up @@ -909,11 +912,33 @@
-fx-fill: -jr-search-text;
}

/* magnifier glass */
.mainToolbar .search-field .glyph-icon {
-fx-fill: -jr-search-text;
-fx-text-fill: -jr-search-text;
}

/* search modifier buttons */
.mainToolbar .search-field .toggle-button:selected {
-fx-background-color: transparent;
}

.mainToolbar .search-field .toggle-button:hover,
.mainToolbar .search-field .toggle-button:selected:hover {
-fx-background-color: -jr-icon-background-active;
}

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

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

/* search text */
.mainToolbar .search-field .label {
-fx-padding: 0em 1.8em 0em 0em;
}
Expand Down Expand Up @@ -966,7 +991,8 @@ We want to have a look that matches our icons in the tool-bar */
-fx-fill: -jr-head-fg;
}

.table-cell, .table-cell .glyph-icon {
.table-cell,
.table-cell .glyph-icon {
-fx-padding: 0.5em 1em 0.5em 1em;
-fx-cell-size: 4.0em;
-fx-text-fill: -fx-text-background-color;
Expand All @@ -979,12 +1005,11 @@ We want to have a look that matches our icons in the tool-bar */
}

.mainToolbar .context-menu .glyph-icon:hover {
-fx-fill: -jr-theme-active;
-fx-text-fill: -jr-theme-active;
-fx-fill: -jr-menu-forground-active;
-fx-text-fill: -jr-menu-forground-active;
-fx-background-color: -jr-icon-background-active; /* TODO: This has no effect */
}


/* This is awful, but I don't know a better way*/
.mainToolbar .context-menu * {
-fx-background-color: -fx-control-inner-background;
Expand Down
62 changes: 0 additions & 62 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,68 +294,6 @@ private void createMainTable() {
.stream()
.findFirst()
.ifPresent(entryEditor::setEntry));

// TODO: Register these actions globally
/*
String clearSearch = "clearSearch";
mainTable.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.CLEAR_SEARCH), clearSearch);
mainTable.getActionMap().put(clearSearch, new AbstractAction() {

@Override
public void actionPerformed(ActionEvent e) {
// need to close these here, b/c this action overshadows the responsible actions when the main table is selected
switch (mode) {
case SHOWING_NOTHING:
frame.getGlobalSearchBar().endSearch();
break;
case SHOWING_PREVIEW:
getPreviewPanel().close();
break;
case SHOWING_EDITOR:
case WILL_SHOW_EDITOR:
entryEditorClosing(getEntryEditor());
break;
default:
LOGGER.warn("unknown BasePanelMode: '" + mode + "', doing nothing");
break;
}
}
});

mainTable.getActionMap().put(Actions.CUT, new AbstractAction() {

@Override
public void actionPerformed(ActionEvent e) {
try {
runCommand(Actions.CUT);
} catch (Throwable ex) {
LOGGER.warn("Could not cut", ex);
}
}
});
mainTable.getActionMap().put(Actions.COPY, new AbstractAction() {

@Override
public void actionPerformed(ActionEvent e) {
try {
runCommand(Actions.COPY);
} catch (Throwable ex) {
LOGGER.warn("Could not copy", ex);
}
}
});
mainTable.getActionMap().put(Actions.PASTE, new AbstractAction() {

@Override
public void actionPerformed(ActionEvent e) {
try {
runCommand(Actions.PASTE);
} catch (Throwable ex) {
LOGGER.warn("Could not paste", ex);
}
}
});
*/
}

public void setupMainPanel() {
Expand Down
98 changes: 57 additions & 41 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
Expand Down Expand Up @@ -163,7 +163,7 @@ public class JabRefFrame extends BorderPane {
private final SplitPane splitPane = new SplitPane();
private final JabRefPreferences prefs = Globals.prefs;
private final ThemeLoader themeLoader = Globals.getThemeLoader();
private final GlobalSearchBar globalSearchBar = new GlobalSearchBar(this, Globals.stateManager);
private final GlobalSearchBar globalSearchBar = new GlobalSearchBar(this, Globals.stateManager, prefs);

private final FileHistoryMenu fileHistory;

Expand Down Expand Up @@ -502,64 +502,80 @@ private void setDividerPosition() {
}

private Node createToolbar() {
Pane leftSpacer = new Pane();
leftSpacer.setMinWidth(50);
HBox.setHgrow(leftSpacer, Priority.SOMETIMES);
Pane rightSpacer = new Pane();
HBox.setHgrow(rightSpacer, Priority.SOMETIMES);
final ActionFactory factory = new ActionFactory(Globals.getKeyPrefs());

ActionFactory factory = new ActionFactory(Globals.getKeyPrefs());
final Region leftSpacer = new Region();
final Region rightSpacer = new Region();

Button newLibrary;
if (Globals.prefs.getBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE)) {
final Button newLibrary;
if (Globals.prefs.getDefaultBibDatabaseMode() == BibDatabaseMode.BIBLATEX) {
newLibrary = factory.createIconButton(StandardActions.NEW_LIBRARY_BIBLATEX, new NewDatabaseAction(this, BibDatabaseMode.BIBLATEX));
} else {
newLibrary = factory.createIconButton(StandardActions.NEW_LIBRARY_BIBTEX, new NewDatabaseAction(this, BibDatabaseMode.BIBTEX));
}

HBox leftSide = new HBox(
newLibrary,
factory.createIconButton(StandardActions.OPEN_LIBRARY, new OpenDatabaseAction(this)),
factory.createIconButton(StandardActions.SAVE_LIBRARY, new SaveAction(SaveAction.SaveMethod.SAVE, this, stateManager)),
leftSpacer
);

final PushToApplicationAction pushToApplicationAction = getPushToApplicationsManager().getPushToApplicationAction();
final Button pushToApplicationButton = factory.createIconButton(pushToApplicationAction.getActionInformation(), pushToApplicationAction);
pushToApplicationsManager.registerReconfigurable(pushToApplicationButton);

HBox rightSide = new HBox(
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, StandardEntryType.Article, dialogService, Globals.prefs, stateManager)),
factory.createIconButton(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, Globals.prefs, stateManager)),
factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new ExtractBibtexAction(stateManager)),
factory.createIconButton(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, this, stateManager)),
ToolBar toolBar = new ToolBar(

new HBox(newLibrary,
factory.createIconButton(StandardActions.OPEN_LIBRARY, new OpenDatabaseAction(this)),
factory.createIconButton(StandardActions.SAVE_LIBRARY, new SaveAction(SaveAction.SaveMethod.SAVE, this, stateManager))),

leftSpacer,

globalSearchBar,

rightSpacer,

new HBox(
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, StandardEntryType.Article, dialogService, Globals.prefs, stateManager)),
factory.createIconButton(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, Globals.prefs, stateManager)),
factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new ExtractBibtexAction(stateManager)),
factory.createIconButton(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, this, stateManager))
),

new Separator(Orientation.VERTICAL),
factory.createIconButton(StandardActions.UNDO, new UndoRedoAction(StandardActions.UNDO, this, dialogService, stateManager)),
factory.createIconButton(StandardActions.REDO, new UndoRedoAction(StandardActions.REDO, this, dialogService, stateManager)),
factory.createIconButton(StandardActions.CUT, new EditAction(StandardActions.CUT, this, stateManager)),
factory.createIconButton(StandardActions.COPY, new EditAction(StandardActions.COPY, this, stateManager)),
factory.createIconButton(StandardActions.PASTE, new EditAction(StandardActions.PASTE, this, stateManager)),

new HBox(
factory.createIconButton(StandardActions.UNDO, new UndoRedoAction(StandardActions.UNDO, this, dialogService, stateManager)),
factory.createIconButton(StandardActions.REDO, new UndoRedoAction(StandardActions.REDO, this, dialogService, stateManager)),
factory.createIconButton(StandardActions.CUT, new EditAction(StandardActions.CUT, this, stateManager)),
factory.createIconButton(StandardActions.COPY, new EditAction(StandardActions.COPY, this, stateManager)),
factory.createIconButton(StandardActions.PASTE, new EditAction(StandardActions.PASTE, this, stateManager))
),

new Separator(Orientation.VERTICAL),
pushToApplicationButton,
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(this, dialogService, stateManager)),
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new CleanupAction(this, prefs, dialogService, stateManager)),

new HBox(
pushToApplicationButton,
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(this, dialogService, stateManager)),
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new CleanupAction(this, prefs, dialogService, stateManager))
),

new Separator(Orientation.VERTICAL),
factory.createIconButton(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref")),
factory.createIconButton(StandardActions.OPEN_FACEBOOK, new OpenBrowserAction("https://www.facebook.com/JabRef/")),
factory.createIconButton(StandardActions.OPEN_TWITTER, new OpenBrowserAction("https://twitter.com/jabref_org")),

new HBox(
factory.createIconButton(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref")),
factory.createIconButton(StandardActions.OPEN_FACEBOOK, new OpenBrowserAction("https://www.facebook.com/JabRef/")),
factory.createIconButton(StandardActions.OPEN_TWITTER, new OpenBrowserAction("https://twitter.com/jabref_org"))
),

new Separator(Orientation.VERTICAL),
createTaskIndicator()

new HBox(
createTaskIndicator()
)
);

leftSpacer.setPrefWidth(50);
leftSpacer.setMinWidth(Region.USE_PREF_SIZE);
leftSpacer.setMaxWidth(Region.USE_PREF_SIZE);
HBox.setHgrow(globalSearchBar, Priority.ALWAYS);
HBox.setHgrow(rightSpacer, Priority.SOMETIMES);

ToolBar toolBar = new ToolBar(
leftSide,

globalSearchBar,

rightSpacer,
rightSide);
toolBar.getStyleClass().add("mainToolbar");

return toolBar;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/importer/ImportEntriesDialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
-fx-font-size: 2em;
}

.addEntryButton:selected {
-fx-background-color: transparent;
-fx-fill: -jr-selected;
}

.entry-container {
/*-fx-padding: 0.5em 0em 0.5em 0em;*/
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void setValues() {
allowIntegerEditionProperty.setValue(initialGeneralPreferences.isAllowIntegerEditionBibtex());
memoryStickModeProperty.setValue(initialGeneralPreferences.isMemoryStickMode());
collectTelemetryProperty.setValue(preferencesService.shouldCollectTelemetry());
showAdvancedHintsProperty.setValue(initialGeneralPreferences.isShowAdvancedHints());
showAdvancedHintsProperty.setValue(initialGeneralPreferences.shouldShowAdvancedHints());

markOwnerProperty.setValue(initialOwnerPreferences.isUseOwner());
markOwnerNameProperty.setValue(initialOwnerPreferences.getDefaultOwner());
Expand Down
Loading