Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
LoayGhreeb committed Aug 5, 2024
1 parent aa81985 commit f8f2399
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 52 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We reintroduced the floating search in the main table. [#11326](https://github.com/JabRef/jabref/pull/11326)
- We made new groups automatically to focus upon creation. [#11449](https://github.com/JabRef/jabref/issues/11449)
- We added support for selecting and using CSL Styles in JabRef's OpenOffice/LibreOffice integration for inserting bibliographic and in-text citations into a document. [#2146](https://github.com/JabRef/jabref/issues/2146), [#8893](https://github.com/JabRef/jabref/issues/8893)
- We added Tools > New library based on references in PDF file... to create a new library based on the references section in a PDF file. [#11522](https://github.com/JabRef/jabref/pull/11522)
- When converting the references section of a paper (PDF file), more than the last page is treated. [#11522](https://github.com/JabRef/jabref/pull/11522)
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private LibraryTab(BibDatabaseContext bibDatabaseContext,
}

this.selectedGroupsProperty = new SimpleListProperty<>(stateManager.getSelectedGroups(bibDatabaseContext));
this.tableModel = new MainTableDataModel(getBibDatabaseContext(), preferencesService, taskExecutor, selectedGroupsProperty(), searchQueryProperty(), resultSizeProperty());
this.tableModel = new MainTableDataModel(getBibDatabaseContext(), preferencesService, taskExecutor, getLuceneManager(), selectedGroupsProperty(), searchQueryProperty(), resultSizeProperty());

citationStyleCache = new CitationStyleCache(bibDatabaseContext);
annotationCache = new FileAnnotationCache(bibDatabaseContext, preferencesService.getFilePreferences());
Expand Down Expand Up @@ -333,7 +333,7 @@ private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
setLuceneManager();
this.tableModel.unbind();
this.selectedGroupsProperty = new SimpleListProperty<>(stateManager.getSelectedGroups(bibDatabaseContext));
this.tableModel = new MainTableDataModel(getBibDatabaseContext(), preferencesService, taskExecutor, selectedGroupsProperty(), searchQueryProperty(), resultSizeProperty());
this.tableModel = new MainTableDataModel(getBibDatabaseContext(), preferencesService, taskExecutor, getLuceneManager(), selectedGroupsProperty(), searchQueryProperty(), resultSizeProperty());

citationStyleCache = new CitationStyleCache(bibDatabaseContext);
annotationCache = new FileAnnotationCache(bibDatabaseContext, preferencesService.getFilePreferences());
Expand Down Expand Up @@ -571,6 +571,7 @@ private void createMainTable() {
preferencesService,
dialogService,
stateManager,
preferencesService.getKeyBindingRepository(),
clipBoardManager,
entryTypesManager,
taskExecutor,
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import javafx.beans.binding.Binding;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
Expand Down Expand Up @@ -48,6 +50,8 @@ public class BibEntryTableViewModel {
private final EasyBinding<Map<Field, String>> linkedIdentifiers;
private final Binding<List<AbstractGroup>> matchedGroups;
private final BibDatabaseContext bibDatabaseContext;
private final FloatProperty searchScore = new SimpleFloatProperty(0);
private final BooleanProperty hasFullTextResults = new SimpleBooleanProperty(false);
private final BooleanProperty isMatchedBySearch = new SimpleBooleanProperty(true);
private final BooleanProperty isVisibleBySearch = new SimpleBooleanProperty(true);
private final BooleanProperty isMatchedByGroup = new SimpleBooleanProperty(true);
Expand Down Expand Up @@ -159,6 +163,14 @@ public BibDatabaseContext getBibDatabaseContext() {
return bibDatabaseContext;
}

public FloatProperty searchScoreProperty() {
return searchScore;
}

public BooleanProperty hasFullTextResultsProperty() {
return hasFullTextResults;
}

public BooleanProperty isMatchedBySearch() {
return isMatchedBySearch;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,11 @@ private void handleOnDragDropped(TableRow<BibEntryTableViewModel> row, BibEntryT
}
case MOVE -> {
LOGGER.debug("Mode MOVE"); // alt on win
importHandler.getLinker().moveFilesToFileDirRenameAndAddToEntry(entry, files, libraryTab.getIndexingTaskManager());
importHandler.getLinker().moveFilesToFileDirRenameAndAddToEntry(entry, files, libraryTab.getLuceneManager());
}
case COPY -> {
LOGGER.debug("Mode Copy"); // ctrl on win
importHandler.getLinker().copyFilesToFileDirAndAddToEntry(entry, files, libraryTab.getIndexingTaskManager());
importHandler.getLinker().copyFilesToFileDirAndAddToEntry(entry, files, libraryTab.getLuceneManager());
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/jabref/gui/maintable/MainTableDataModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import org.jabref.gui.util.FilteredListProxy;
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.search.SearchQuery;
import org.jabref.logic.search.LuceneManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.groups.GroupTreeNode;
import org.jabref.model.search.SearchQuery;
import org.jabref.model.search.matchers.MatcherSet;
import org.jabref.model.search.matchers.MatcherSets;
import org.jabref.preferences.PreferencesService;
Expand All @@ -43,6 +44,7 @@ public class MainTableDataModel {
private final SearchPreferences searchPreferences;
private final NameDisplayPreferences nameDisplayPreferences;
private final BibDatabaseContext bibDatabaseContext;
private final LuceneManager luceneManager;
private final TaskExecutor taskExecutor;
private final Subscription searchQuerySubscription;
private final Subscription searchDisplayModeSubscription;
Expand All @@ -53,13 +55,15 @@ public class MainTableDataModel {
public MainTableDataModel(BibDatabaseContext context,
PreferencesService preferencesService,
TaskExecutor taskExecutor,
LuceneManager luceneManager,
ListProperty<GroupTreeNode> selectedGroupsProperty,
OptionalObjectProperty<SearchQuery> searchQueryProperty,
IntegerProperty resultSizeProperty) {
this.groupsPreferences = preferencesService.getGroupsPreferences();
this.searchPreferences = preferencesService.getSearchPreferences();
this.nameDisplayPreferences = preferencesService.getNameDisplayPreferences();
this.taskExecutor = taskExecutor;
this.luceneManager = luceneManager;
this.bibDatabaseContext = context;
this.groupsMatcher = createGroupMatcher(selectedGroupsProperty.get(), groupsPreferences);

Expand Down Expand Up @@ -100,10 +104,10 @@ private void updateSearchMatches(Optional<SearchQuery> query) {
}

private static void updateEntrySearchMatch(Optional<SearchQuery> query, BibEntryTableViewModel entry, boolean isFloatingMode) {
boolean isMatched = query.map(matcher -> matcher.isMatch(entry.getEntry())).orElse(true);
entry.isMatchedBySearch().set(isMatched);
// boolean isMatched = query.map(matcher -> matcher.isMatch(entry.getEntry())).orElse(true);
entry.isMatchedBySearch().set(/* isMatched */ true);
entry.updateMatchCategory();
setEntrySearchVisibility(entry, isMatched, isFloatingMode);
setEntrySearchVisibility(entry, /* isMatched */ true, isFloatingMode);
}

private static void setEntrySearchVisibility(BibEntryTableViewModel entry, boolean isMatched, boolean isFloatingMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ private void constructItems() {
continue;
}
// Append only if the column has not already been added (a common column)
if (((MainTableColumn<?>) column).getModel().getType().equals(MainTableColumnModel.Type.SEARCH_RANK)) {
continue;
}
RightClickMenuItem itemToAdd = createMenuItem(column, true);
this.getItems().add(itemToAdd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public void setValues() {

availableColumnsProperty.clear();
availableColumnsProperty.addAll(
new MainTableColumnModel(MainTableColumnModel.Type.SCORE),
new MainTableColumnModel(MainTableColumnModel.Type.INDEX),
new MainTableColumnModel(MainTableColumnModel.Type.LINKED_IDENTIFIER),
new MainTableColumnModel(MainTableColumnModel.Type.GROUPS),
Expand Down Expand Up @@ -206,15 +205,13 @@ public void insertColumnInList() {
}

public void removeColumn(MainTableColumnModel column) {
if (column.getType() != MainTableColumnModel.Type.SEARCH_RANK) {
columnsListProperty.remove(column);
}
columnsListProperty.remove(column);
}

public void moveColumnUp() {
MainTableColumnModel selectedColumn = selectedColumnModelProperty.getValue().getSelectedItem();
int row = columnsListProperty.getValue().indexOf(selectedColumn);
if ((selectedColumn == null) || (row < 1) || selectedColumn.getType() == MainTableColumnModel.Type.SEARCH_RANK) {
if ((selectedColumn == null) || (row < 1)) {
return;
}

Expand All @@ -226,7 +223,7 @@ public void moveColumnUp() {
public void moveColumnDown() {
MainTableColumnModel selectedColumn = selectedColumnModelProperty.getValue().getSelectedItem();
int row = columnsListProperty.getValue().indexOf(selectedColumn);
if ((selectedColumn == null) || (row > (columnsListProperty.getValue().size() - 2)) || selectedColumn.getType() == MainTableColumnModel.Type.SEARCH_RANK) {
if ((selectedColumn == null) || (row > (columnsListProperty.getValue().size() - 2))) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.ListChangeListener;
import javafx.collections.MapChangeListener;
import javafx.collections.SetChangeListener;
import javafx.css.PseudoClass;
import javafx.event.Event;
Expand Down Expand Up @@ -62,7 +61,6 @@
import org.jabref.model.entry.Author;
import org.jabref.model.search.SearchFlags;
import org.jabref.model.search.SearchQuery;
import org.jabref.model.search.SearchResults;
import org.jabref.preferences.PreferencesService;
import org.jabref.preferences.SearchPreferences;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.FilteredListProxy;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.search.SearchQuery;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.search.SearchQuery;
import org.jabref.preferences.PreferencesService;

import com.tobiasdiez.easybind.EasyBind;
Expand Down Expand Up @@ -67,7 +67,8 @@ private void updateSearchMatches(Optional<SearchQuery> query) {
}

private boolean isMatchedBySearch(Optional<SearchQuery> query, BibEntryTableViewModel entry) {
return query.map(matcher -> matcher.isMatch(entry.getEntry())).orElse(true);
/* query.map(matcher -> matcher.isMatch(entry.getEntry())).orElse(true);*/
return true;
}

public SortedList<BibEntryTableViewModel> getEntriesFilteredAndSorted() {
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/org/jabref/migrations/PreferencesMigrations.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public static void runMigrations(JabRefPreferences preferences, BibEntryTypesMan
// variable names. However, the variables from 5.0 need to be copied to the new variable name too.
changeColumnVariableNamesFor51(preferences);
upgradeColumnPreferences(preferences);
addSearchRankColumn(preferences);
restoreVariablesForBackwardCompatibility(preferences);
upgradeCleanups(preferences);
moveApiKeysToKeyring(preferences);
Expand Down Expand Up @@ -408,25 +407,6 @@ static void upgradeColumnPreferences(JabRefPreferences preferences) {
}
}

static void addSearchRankColumn(JabRefPreferences preferences) {
List<String> columnNames = new ArrayList<>(preferences.getStringList(JabRefPreferences.COLUMN_NAMES));
if (!columnNames.getFirst().equals(MainTableColumnModel.Type.SEARCH_RANK.getName())) {
List<String> columnWidths = new ArrayList<>(preferences.getStringList(JabRefPreferences.COLUMN_WIDTHS));
List<String> columnSortTypes = new ArrayList<>(preferences.getStringList(JabRefPreferences.COLUMN_SORT_TYPES));
List<String> sortOrder = new ArrayList<>(preferences.getStringList(JabRefPreferences.COLUMN_SORT_ORDER));

columnNames.addFirst(MainTableColumnModel.Type.SEARCH_RANK.getName());
columnWidths.addFirst(String.valueOf(ColumnPreferences.DEFAULT_COLUMN_WIDTH));
columnSortTypes.addFirst(TableColumn.SortType.ASCENDING.toString());
sortOrder.addFirst(MainTableColumnModel.Type.SEARCH_RANK.getName());

preferences.putStringList(JabRefPreferences.COLUMN_NAMES, columnNames);
preferences.putStringList(JabRefPreferences.COLUMN_WIDTHS, columnWidths);
preferences.putStringList(JabRefPreferences.COLUMN_SORT_TYPES, columnSortTypes);
preferences.putStringList(JabRefPreferences.COLUMN_SORT_ORDER, sortOrder);
}
}

static void changeColumnVariableNamesFor51(JabRefPreferences preferences) {
// The variable names have to be hardcoded, because they have changed between 5.0 and 5.1
final String V5_0_COLUMN_NAMES = "columnNames";
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/org/jabref/preferences/SearchPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import javafx.collections.ObservableSet;

import org.jabref.gui.search.SearchDisplayMode;
import org.jabref.model.search.rules.SearchRules.SearchFlags;
import org.jabref.model.search.SearchFlags;

import com.google.common.annotations.VisibleForTesting;

Expand All @@ -26,12 +26,9 @@ public class SearchPreferences {
private final BooleanProperty keepSearchSting;
private final ObjectProperty<SearchDisplayMode> searchDisplayMode;

public SearchPreferences(SearchDisplayMode searchDisplayMode, boolean isCaseSensitive, boolean isRegularExpression, boolean isFulltext, boolean keepSearchString, boolean keepWindowOnTop, double searchWindowHeight, double searchWindowWidth, double searchWindowDividerPosition) {
public SearchPreferences(SearchDisplayMode searchDisplayMode, boolean isRegularExpression, boolean isFulltext, boolean keepSearchString, boolean keepWindowOnTop, double searchWindowHeight, double searchWindowWidth, double searchWindowDividerPosition) {
this(searchDisplayMode, EnumSet.noneOf(SearchFlags.class), keepSearchString, keepWindowOnTop, searchWindowHeight, searchWindowWidth, searchWindowDividerPosition);

if (isCaseSensitive) {
searchFlags.add(SearchFlags.CASE_SENSITIVE);
}
if (isRegularExpression) {
searchFlags.add(SearchFlags.REGULAR_EXPRESSION);
}
Expand Down Expand Up @@ -64,10 +61,6 @@ public ObservableSet<SearchFlags> getObservableSearchFlags() {
return searchFlags;
}

public boolean isCaseSensitive() {
return searchFlags.contains(SearchFlags.CASE_SENSITIVE);
}

public void setSearchFlag(SearchFlags flag, boolean value) {
if (searchFlags.contains(flag) && !value) {
searchFlags.remove(flag);
Expand Down

0 comments on commit f8f2399

Please sign in to comment.