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

Change optional fields tabs #8856

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where an exxception for DOI search occured when the DOI contained urlencoded characters. [#8787](https://github.com/JabRef/jabref/issues/8787)
- We fixed an issue which allow us to select and open identifiers from a popup list in the maintable [#8758](https://github.com/JabRef/jabref/issues/8758), [8802](https://github.com/JabRef/jabref/issues/8802)
- We fixed an issue where the escape button had no functionality within the "Filter groups" textfield. [koppor#562](https://github.com/koppor/jabref/issues/562)
- We fixed an issue where right clicking a group and choose "remove selected entries from this group" leads to error when Bibtex source tab is selected. [#8012](https://github.com/JabRef/jabref/issues/8012)
- We fixed an issue where right clicking a group and choose "remove selected entries from this group" leads to error when Bibtex source tab is selected. [#8012](https://github.com/JabRef/jabref/issues/8012)
- We fixed an issue of 4688 which was about merging the optionals,optional2 and otherFields.[#4688](https://github.com/JabRef/jabref/issues/4688)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ToggleGroup?>
<DialogPane prefHeight="596.0" prefWidth="680"
xmlns="http://javafx.com/javafx/8.0.171"
xmlns:fx="http://javafx.com/fxml/1"
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,8 @@ private List<EntryEditorTab> createTabs() {

// Optional fields
entryEditorTabs.add(new OptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, ExternalFileTypes.getInstance(), taskExecutor, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new OptionalFields2Tab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, ExternalFileTypes.getInstance(), taskExecutor, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, ExternalFileTypes.getInstance(), taskExecutor, Globals.journalAbbreviationRepository));

// Other fields
entryEditorTabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, ExternalFileTypes.getInstance(), taskExecutor, Globals.journalAbbreviationRepository));

// General fields from preferences
for (Map.Entry<String, Set<Field>> tab : entryEditorPreferences.getEntryEditorTabList().entrySet()) {
entryEditorTabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, themeManager, libraryTab.getIndexingTaskManager(), bibEntryTypesManager, ExternalFileTypes.getInstance(), taskExecutor, Globals.journalAbbreviationRepository));
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,12 @@ private void setupPanel(BibEntry entry, boolean compressed) {

ColumnConstraints columnDoNotContract = new ColumnConstraints();
columnDoNotContract.setMinWidth(Region.USE_PREF_SIZE);
int rows;
if (compressed) {
rows = (int) Math.ceil((double) fields.size() / 2);

addColumn(gridPane, 0, labels.subList(0, rows));
addColumn(gridPane, 3, labels.subList(rows, labels.size()));
addColumn(gridPane, 1, editors.values().stream().map(FieldEditorFX::getNode).limit(rows));
addColumn(gridPane, 4, editors.values().stream().map(FieldEditorFX::getNode).skip(rows));

columnExpand.setPercentWidth(40);
gridPane.getColumnConstraints().addAll(columnDoNotContract, columnExpand, new ColumnConstraints(10),
columnDoNotContract, columnExpand);

setCompressedRowLayout(gridPane, rows);
} else {
addColumn(gridPane, 0, labels);
addColumn(gridPane, 1, editors.values().stream().map(FieldEditorFX::getNode));

gridPane.getColumnConstraints().addAll(columnDoNotContract, columnExpand);

setRegularRowLayout(gridPane);
}
}

private void setRegularRowLayout(GridPane gridPane) {
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/org/jabref/gui/entryeditor/OptionalFields2Tab.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.jabref.gui.entryeditor;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import javax.swing.undo.UndoManager;

Expand All @@ -28,6 +31,7 @@
public class OptionalFieldsTabBase extends FieldsEditorTab {
private final BibEntryTypesManager entryTypesManager;
private final boolean isPrimaryOptionalFields;
private final List<Field> customTabFieldNames;

public OptionalFieldsTabBase(String title,
boolean isPrimaryOptionalFields,
Expand Down Expand Up @@ -57,6 +61,7 @@ public OptionalFieldsTabBase(String title,
indexingTaskManager);
this.entryTypesManager = entryTypesManager;
this.isPrimaryOptionalFields = isPrimaryOptionalFields;
this.customTabFieldNames = preferences.getAllDefaultTabFieldNames();
setText(title);
setTooltip(new Tooltip(Localization.lang("Show optional fields")));
setGraphic(IconTheme.JabRefIcons.OPTIONAL.getGraphicNode());
Expand All @@ -66,11 +71,10 @@ public OptionalFieldsTabBase(String title,
protected Set<Field> determineFieldsToShow(BibEntry entry) {
Optional<BibEntryType> entryType = entryTypesManager.enrich(entry.getType(), databaseContext.getMode());
if (entryType.isPresent()) {
if (isPrimaryOptionalFields) {
return entryType.get().getPrimaryOptionalFields();
} else {
return entryType.get().getSecondaryOptionalNotDeprecatedFields();
}
Set<Field> allKnownFields = entryType.get().getAllFields();
Set<Field> otherFields = entry.getFields().stream().filter(field -> !allKnownFields.contains(field)).collect(Collectors.toCollection(LinkedHashSet::new));
otherFields.removeAll(entryType.get().getDeprecatedFields());
return otherFields;
} else {
// Entry type unknown -> treat all fields as required
return Collections.emptySet();
Expand Down
88 changes: 0 additions & 88 deletions src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java

This file was deleted.