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

Integrated CustomizeExternalFileTypesDialog into Preferences #8341

Merged
merged 4 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the union/intersection view button in the group sidepane to the left of the other controls. [#8202](https://github.com/JabRef/jabref/pull/8202)
- We improved the Drag and Drop behavior in the "Customize Entry Types" Dialog [#6338](https://github.com/JabRef/jabref/issues/6338)
- When determining the URL of an ArXiV eprint, the URL now points to the version [#8149](https://github.com/JabRef/jabref/pull/8149)
- We integrated the external file types dialog directly inside the preferences. [#8341](https://github.com/JabRef/jabref/pull/8341)
- We Included all standard fields with citation key when exporting to Old OpenOffice/LibreOffice Calc Format [#8176](https://github.com/JabRef/jabref/pull/8176)
- In case the database is encoded with `UTF8`, the `% Encoding` marker is not written anymore
- The written `.bib` file has the same line endings [#390](https://github.com/koppor/jabref/issues/390)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="4.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="16.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="%Application to push entries to"/>
<ComboBox fx:id="pushToApplicationCombo"
Expand All @@ -54,9 +52,6 @@
<Label text="%Cite command" GridPane.rowIndex="2"/>
<TextField fx:id="citeCommand"
prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="2"/>

<Button onAction="#manageExternalFileTypes" text="%Manage external file types"
prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
</GridPane>
</HBox>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ void pushToApplicationSettings() {
viewModel.pushToApplicationSettings();
}

@FXML
void manageExternalFileTypes() {
viewModel.manageExternalFileTypes();
}

@FXML
void useTerminalCommandBrowse() {
viewModel.customTerminalBrowse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.icon.JabRefIconView?>
<fx:root spacing="10.0" type="VBox"
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="org.jabref.gui.preferences.externalfiletypes.ExternalFileTypesTab">
<Label styleClass="titleHeader" text="%External file types"/>
<TableView fx:id="fileTypesTable" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="fileTypesTableIconColumn" minWidth="40.0" maxWidth="40.0"/>
<TableColumn fx:id="fileTypesTableNameColumn" text="%Name"/>
<TableColumn fx:id="fileTypesTableExtensionColumn" text="%Extension" prefWidth="120"/>
<TableColumn fx:id="fileTypesTableTypeColumn" text="%MIME type" prefWidth="150"/>
<TableColumn fx:id="fileTypesTableApplicationColumn" text="%Application" prefWidth="100"/>
<TableColumn fx:id="fileTypesTableEditColumn" minWidth="40.0" maxWidth="40.0"/>
<TableColumn fx:id="fileTypesTableDeleteColumn" minWidth="40.0" maxWidth="40.0"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
<HBox alignment="BASELINE_RIGHT" spacing="10.0">
<Button text="%Add new file type" onAction="#addNewType">
<graphic>
<JabRefIconView glyph="ADD_NOBOX"/>
</graphic>
</Button>
<Button text="%Reset to default" onAction="#resetToDefault">
<graphic>
<JabRefIconView glyph="REFRESH"/>
</graphic>
</Button>
</HBox>
</fx:root>
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,7 +19,7 @@
/**
* Editor for external file types.
*/
public class CustomizeExternalFileTypesDialog extends BaseDialog<Void> {
public class ExternalFileTypesTab extends AbstractPreferenceTabView<ExternalFileTypesTabViewModel> implements PreferencesTab {

@FXML private TableColumn<ExternalFileType, JabRefIcon> fileTypesTableIconColumn;
@FXML private TableColumn<ExternalFileType, String> fileTypesTableNameColumn;
Expand All @@ -28,26 +30,20 @@ public class CustomizeExternalFileTypesDialog extends BaseDialog<Void> {
@FXML private TableColumn<ExternalFileType, Boolean> fileTypesTableDeleteColumn;
@FXML private TableView<ExternalFileType> 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());

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ExternalFileType> fileTypes;
private final ExternalFileTypes externalFileTypes;
private final ObservableList<ExternalFileType> fileTypes = FXCollections.observableArrayList();

public CustomizeExternalFileTypesViewModel() {
Set<ExternalFileType> 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() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down