Skip to content

Commit

Permalink
Merge identical group color indicators (#6768)
Browse files Browse the repository at this point in the history
Co-authored-by: WangAooa <[email protected]>
  • Loading branch information
calixtus and WangAooa authored Aug 19, 2020
1 parent c09fa91 commit bd03fd0
Show file tree
Hide file tree
Showing 10 changed files with 490 additions and 283 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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. 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)
- We fixed an issue about duplicated group color indicators [#6175](https://github.com/JabRef/jabref/issues/6175)
- We fixed an issue where entries with the entry type Misc from an imported aux file would not be saved correctly to the bib file on disk [#6405](https://github.com/JabRef/jabref/issues/6405)
- We fixed an issue where percent sign ('%') was not formatted properly by the HTML formatter [#6753](https://github.com/JabRef/jabref/issues/6753)

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,14 @@ public void editEntryAndFocusField(BibEntry entry, Field field) {
private void createMainTable() {
bibDatabaseContext.getDatabase().registerListener(SpecialFieldDatabaseChangeListener.INSTANCE);

mainTable = new MainTable(tableModel, frame, this, bibDatabaseContext, preferences.getTablePreferences(), externalFileTypes, preferences.getKeyBindings());
mainTable = new MainTable(tableModel,
this,
bibDatabaseContext,
Globals.prefs,
dialogService,
Globals.stateManager,
externalFileTypes,
preferences.getKeyBindings());

// Add the listener that binds selection to state manager (TODO: should be replaced by proper JavaFX binding as soon as table is implemented in JavaFX)
mainTable.addSelectionListener(listEvent -> Globals.stateManager.setSelectedEntries(mainTable.getSelectedEntries()));
Expand Down
71 changes: 43 additions & 28 deletions src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@

import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.DragAndDropDataFormats;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.externalfiles.ImportHandler;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.maintable.columns.MainTableColumn;
import org.jabref.gui.util.ControlHelper;
import org.jabref.gui.util.CustomLocalDragboard;
import org.jabref.gui.util.DefaultTaskExecutor;
Expand All @@ -41,6 +43,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.event.EntriesAddedEvent;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;

import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
Expand All @@ -51,51 +54,56 @@ public class MainTable extends TableView<BibEntryTableViewModel> {
private static final Logger LOGGER = LoggerFactory.getLogger(MainTable.class);

private final BasePanel panel;

private final BibDatabaseContext database;
private final UndoManager undoManager;

private final MainTableDataModel model;

private final ImportHandler importHandler;
private final CustomLocalDragboard localDragboard;

private long lastKeyPressTime;
private String columnSearchTerm;

public MainTable(MainTableDataModel model, JabRefFrame frame,
BasePanel panel, BibDatabaseContext database,
MainTablePreferences preferences, ExternalFileTypes externalFileTypes, KeyBindingRepository keyBindingRepository) {
public MainTable(MainTableDataModel model,
BasePanel panel,
BibDatabaseContext database,
PreferencesService preferencesService,
DialogService dialogService,
StateManager stateManager,
ExternalFileTypes externalFileTypes,
KeyBindingRepository keyBindingRepository) {
super();

this.setOnKeyTyped(key -> {
if (this.getSortOrder().isEmpty()) {
return;
}
this.jumpToSearchKey(getSortOrder().get(0), key);
});

this.model = model;
this.panel = panel;
this.database = Objects.requireNonNull(database);

this.undoManager = panel.getUndoManager();
this.model = model;
UndoManager undoManager = panel.getUndoManager();
MainTablePreferences mainTablePreferences = preferencesService.getMainTablePreferences();

importHandler = new ImportHandler(
frame.getDialogService(), database, externalFileTypes,
Globals.prefs,
dialogService, database, externalFileTypes,
preferencesService,
Globals.getFileUpdateMonitor(),
undoManager,
Globals.stateManager);
localDragboard = Globals.stateManager.getLocalDragboard();
stateManager);

localDragboard = stateManager.getLocalDragboard();

this.getColumns().addAll(new MainTableColumnFactory(database, preferences.getColumnPreferences(), externalFileTypes, panel.getUndoManager(), frame.getDialogService()).createColumns());
this.getColumns().addAll(
new MainTableColumnFactory(database, preferencesService, externalFileTypes, panel.getUndoManager(), dialogService)
.createColumns());

new ViewModelTableRowFactory<BibEntryTableViewModel>()
.withOnMouseClickedEvent((entry, event) -> {
if (event.getClickCount() == 2) {
panel.showAndEdit(entry.getEntry());
}
})
.withContextMenu(entry -> RightClickMenu.create(entry, keyBindingRepository, panel, frame.getDialogService(), Globals.stateManager, Globals.prefs))
.withContextMenu(entry -> RightClickMenu.create(entry,
keyBindingRepository,
panel,
dialogService,
stateManager,
preferencesService))
.setOnDragDetected(this::handleOnDragDetected)
.setOnDragDropped(this::handleOnDragDropped)
.setOnDragOver(this::handleOnDragOver)
Expand All @@ -104,34 +112,41 @@ public MainTable(MainTableDataModel model, JabRefFrame frame,
.install(this);

this.getSortOrder().clear();
preferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->
mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->
this.getColumns().stream()
.map(column -> (MainTableColumn<?>) column)
.filter(column -> column.getModel().equals(columnModel))
.findFirst()
.ifPresent(column -> this.getSortOrder().add(column)));

if (preferences.getResizeColumnsToFit()) {
if (mainTablePreferences.getResizeColumnsToFit()) {
this.setColumnResizePolicy(new SmartConstrainedResizePolicy());
}

this.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

this.setItems(model.getEntriesFilteredAndSorted());

// Enable sorting
model.getEntriesFilteredAndSorted().comparatorProperty().bind(this.comparatorProperty());

this.panel = panel;

this.getStylesheets().add(MainTable.class.getResource("MainTable.css").toExternalForm());

// Store visual state
new PersistenceVisualStateTable(this, Globals.prefs);
new PersistenceVisualStateTable(this, preferencesService);

// TODO: Float marked entries
// model.updateMarkingState(Globals.prefs.getBoolean(JabRefPreferences.FLOAT_MARKED_ENTRIES));

setupKeyBindings(keyBindingRepository);

this.setOnKeyTyped(key -> {
if (this.getSortOrder().isEmpty()) {
return;
}
this.jumpToSearchKey(getSortOrder().get(0), key);
});

database.getDatabase().registerListener(this);
}

Expand Down
Loading

0 comments on commit bd03fd0

Please sign in to comment.