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/EditExternalFileTypesAction.java b/src/main/java/org/jabref/gui/externalfiletype/EditExternalFileTypesAction.java
deleted file mode 100644
index f2e25f72040..00000000000
--- a/src/main/java/org/jabref/gui/externalfiletype/EditExternalFileTypesAction.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.jabref.gui.externalfiletype;
-
-import org.jabref.gui.DialogService;
-import org.jabref.gui.actions.SimpleCommand;
-
-import com.airhacks.afterburner.injection.Injector;
-
-public class EditExternalFileTypesAction extends SimpleCommand {
-
- @Override
- public void execute() {
- DialogService dialogService = Injector.instantiateModelOrService(DialogService.class);
- dialogService.showCustomDialogAndWait(new CustomizeExternalFileTypesDialog());
- }
-}
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
index 9a50eae8e22..fb1c888f01f 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
@@ -19,6 +19,7 @@
import org.jabref.gui.preferences.entryeditor.EntryEditorTab;
import org.jabref.gui.preferences.entryeditortabs.CustomEditorFieldsTab;
import org.jabref.gui.preferences.external.ExternalTab;
+import org.jabref.gui.preferences.externalfiletypes.ExternalFileTypesTab;
import org.jabref.gui.preferences.file.FileTab;
import org.jabref.gui.preferences.general.GeneralTab;
import org.jabref.gui.preferences.groups.GroupsTab;
@@ -72,6 +73,7 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
new PreviewTab(),
new ProtectedTermsTab(),
new ExternalTab(frame.getPushToApplicationsManager()),
+ new ExternalFileTypesTab(),
new JournalAbbreviationsTab(),
new GroupsTab(),
new EntryEditorTab(),
diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml
index 33769554505..e4cd9d468b0 100644
--- a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.fxml
@@ -35,8 +35,6 @@
-
-
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
index 0abb78aa862..0af4ca04d86 100644
--- a/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
+++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTab.java
@@ -85,11 +85,6 @@ void pushToApplicationSettings() {
viewModel.pushToApplicationSettings();
}
- @FXML
- void manageExternalFileTypes() {
- viewModel.manageExternalFileTypes();
- }
-
@FXML
void useTerminalCommandBrowse() {
viewModel.customTerminalBrowse();
diff --git a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java
index 896fa4e7412..f6f8e88ed0a 100644
--- a/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java
@@ -13,7 +13,6 @@
import javafx.scene.control.DialogPane;
import org.jabref.gui.DialogService;
-import org.jabref.gui.externalfiletype.EditExternalFileTypesAction;
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.gui.push.PushToApplication;
import org.jabref.gui.push.PushToApplicationSettings;
@@ -160,10 +159,6 @@ public void pushToApplicationSettings() {
);
}
- public void manageExternalFileTypes() {
- new EditExternalFileTypesAction().execute();
- }
-
public void customTerminalBrowse() {
dialogService.showFileOpenDialog(fileDialogConfiguration)
.ifPresent(file -> customTerminalCommandProperty.setValue(file.toAbsolutePath().toString()));
diff --git a/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTab.fxml b/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTab.fxml
new file mode 100644
index 00000000000..5d8b4556c70
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/externalfiletypes/ExternalFileTypesTab.fxml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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