diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c9dba27c0..cb0162801be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed +- We integrated the external file types dialog directly inside the preferences. [#8341](https://github.com/JabRef/jabref/pull/8341) + ### Fixed ### Removed diff --git a/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesDialog.fxml b/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesDialog.fxml deleted file mode 100644 index 6489e52a788..00000000000 --- a/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesDialog.fxml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesDialog.java b/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTab.java similarity index 81% rename from src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesDialog.java rename to src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTab.java index ad80133a034..41998975660 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesDialog.java +++ b/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTab.java @@ -1,13 +1,15 @@ -package org.jabref.gui.externalfiletype; +package org.jabref.gui.preferences.externalfiletypes; import javafx.fxml.FXML; -import javafx.scene.control.ButtonType; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; +import org.jabref.gui.externalfiletype.ExternalFileType; +import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.icon.JabRefIcon; -import org.jabref.gui.util.BaseDialog; +import org.jabref.gui.preferences.AbstractPreferenceTabView; +import org.jabref.gui.preferences.PreferencesTab; import org.jabref.gui.util.BindingsHelper; import org.jabref.gui.util.ValueTableCellFactory; import org.jabref.logic.l10n.Localization; @@ -17,7 +19,7 @@ /** * Editor for external file types. */ -public class CustomizeExternalFileTypesDialog extends BaseDialog { +public class ExternalFileTypesTab extends AbstractPreferenceTabView implements PreferencesTab { @FXML private TableColumn fileTypesTableIconColumn; @FXML private TableColumn fileTypesTableNameColumn; @@ -28,26 +30,20 @@ public class CustomizeExternalFileTypesDialog extends BaseDialog { @FXML private TableColumn fileTypesTableDeleteColumn; @FXML private TableView fileTypesTable; - private CustomizeExternalFileTypesViewModel viewModel; - - public CustomizeExternalFileTypesDialog() { - this.setTitle(Localization.lang("Manage external file types")); - + public ExternalFileTypesTab() { ViewLoader.view(this) - .load() - .setAsDialogPane(this); + .root(this) + .load(); + } - this.setResultConverter(button -> { - if (button == ButtonType.OK) { - viewModel.storeSettings(); - } - return null; - }); + @Override + public String getTabName() { + return Localization.lang("External file types"); } @FXML public void initialize() { - viewModel = new CustomizeExternalFileTypesViewModel(); + viewModel = new ExternalFileTypesTabViewModel(ExternalFileTypes.getInstance()); fileTypesTable.setItems(viewModel.getFileTypes()); diff --git a/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesViewModel.java b/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTabViewModel.java similarity index 67% rename from src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesViewModel.java rename to src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTabViewModel.java index c147c839fc8..ee669177d6d 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/CustomizeExternalFileTypesViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTabViewModel.java @@ -1,33 +1,39 @@ -package org.jabref.gui.externalfiletype; +package org.jabref.gui.preferences.externalfiletypes; import java.util.Comparator; import java.util.List; -import java.util.Set; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import org.jabref.gui.DialogService; +import org.jabref.gui.externalfiletype.CustomExternalFileType; +import org.jabref.gui.externalfiletype.EditExternalFileTypeEntryDialog; +import org.jabref.gui.externalfiletype.ExternalFileType; +import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.preferences.PreferenceTabViewModel; import org.jabref.logic.l10n.Localization; import com.airhacks.afterburner.injection.Injector; -public class CustomizeExternalFileTypesViewModel { +public class ExternalFileTypesTabViewModel implements PreferenceTabViewModel { - private final ObservableList fileTypes; + private final ExternalFileTypes externalFileTypes; + private final ObservableList fileTypes = FXCollections.observableArrayList(); - public CustomizeExternalFileTypesViewModel() { - Set types = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); - fileTypes = FXCollections.observableArrayList(types); + public ExternalFileTypesTabViewModel(ExternalFileTypes externalFileTypes) { + this.externalFileTypes = externalFileTypes; + } + + @Override + public void setValues() { + fileTypes.setAll(externalFileTypes.getExternalFileTypeSelection()); fileTypes.sort(Comparator.comparing(ExternalFileType::getName)); } - /** - * Stores the list of external entry types in the preferences. - */ public void storeSettings() { - ExternalFileTypes.getInstance().setExternalFileTypes(fileTypes); + externalFileTypes.setExternalFileTypes(fileTypes); } public void resetToDefaults() { diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 1bd26af7d11..20d378ac7fe 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -509,7 +509,7 @@ Main\ file\ directory=Main file directory Manage\ custom\ exports=Manage custom exports Manage\ custom\ imports=Manage custom imports -Manage\ external\ file\ types=Manage external file types +External\ file\ types=External file types Mark\ new\ entries\ with\ owner\ name=Mark new entries with owner name