-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added preference option to use custom URL for DOI generation (#7480)
- Loading branch information
1 parent
f7de0a6
commit 2c7715c
Showing
14 changed files
with
199 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/org/jabref/gui/preferences/customization/CustomizationTab.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.CheckBox?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.layout.HBox?> | ||
<fx:root spacing="10.0" type="VBox" | ||
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" | ||
fx:controller="org.jabref.gui.preferences.customization.CustomizationTab"> | ||
<Label styleClass="titleHeader" text="%Customization"/> | ||
|
||
<Label styleClass="sectionHeader" text="%Custom DOI URI"/> | ||
<HBox alignment="CENTER_LEFT" spacing="10.0"> | ||
<CheckBox fx:id="useCustomDOI" text="%Use custom DOI base URI for article access"/> | ||
<TextField fx:id="useCustomDOIName" HBox.hgrow="ALWAYS"/> | ||
</HBox> | ||
</fx:root> |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/jabref/gui/preferences/customization/CustomizationTab.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jabref.gui.preferences.customization; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.CheckBox; | ||
import javafx.scene.control.TextField; | ||
|
||
import org.jabref.gui.preferences.AbstractPreferenceTabView; | ||
import org.jabref.gui.preferences.PreferencesTab; | ||
import org.jabref.logic.l10n.Localization; | ||
|
||
import com.airhacks.afterburner.views.ViewLoader; | ||
|
||
public class CustomizationTab extends AbstractPreferenceTabView<CustomizationTabViewModel> implements PreferencesTab { | ||
|
||
@FXML private CheckBox useCustomDOI; | ||
@FXML private TextField useCustomDOIName; | ||
|
||
public CustomizationTab() { | ||
ViewLoader.view(this) | ||
.root(this) | ||
.load(); | ||
} | ||
|
||
@Override | ||
public String getTabName() { | ||
return Localization.lang("Customization"); | ||
} | ||
|
||
public void initialize() { | ||
this.viewModel = new CustomizationTabViewModel(dialogService, preferencesService); | ||
|
||
useCustomDOI.selectedProperty().bindBidirectional(viewModel.useCustomDOIProperty()); | ||
useCustomDOIName.textProperty().bindBidirectional(viewModel.useCustomDOINameProperty()); | ||
useCustomDOIName.disableProperty().bind(useCustomDOI.selectedProperty().not()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/org/jabref/gui/preferences/customization/CustomizationTabViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.jabref.gui.preferences.customization; | ||
|
||
import javafx.beans.property.BooleanProperty; | ||
import javafx.beans.property.SimpleBooleanProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.beans.property.StringProperty; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.preferences.PreferenceTabViewModel; | ||
import org.jabref.logic.preferences.DOIPreferences; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
public class CustomizationTabViewModel implements PreferenceTabViewModel { | ||
|
||
private final BooleanProperty useCustomDOIProperty = new SimpleBooleanProperty(); | ||
private final StringProperty useCustomDOINameProperty = new SimpleStringProperty(""); | ||
|
||
private final DialogService dialogService; | ||
private final PreferencesService preferencesService; | ||
private final DOIPreferences initialDOIPreferences; | ||
|
||
public CustomizationTabViewModel(DialogService dialogService, PreferencesService preferencesService) { | ||
this.dialogService = dialogService; | ||
this.preferencesService = preferencesService; | ||
this.initialDOIPreferences = preferencesService.getDOIPreferences(); | ||
} | ||
|
||
@Override | ||
public void setValues() { | ||
useCustomDOIProperty.setValue(initialDOIPreferences.isUseCustom()); | ||
useCustomDOINameProperty.setValue(initialDOIPreferences.getDefaultBaseURI()); | ||
} | ||
|
||
@Override | ||
public void storeSettings() { | ||
preferencesService.storeDOIPreferences(new DOIPreferences( | ||
useCustomDOIProperty.getValue(), | ||
useCustomDOINameProperty.getValue().trim())); | ||
} | ||
|
||
public BooleanProperty useCustomDOIProperty() { | ||
return this.useCustomDOIProperty; | ||
} | ||
|
||
public StringProperty useCustomDOINameProperty() { | ||
return this.useCustomDOINameProperty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/org/jabref/logic/preferences/DOIPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jabref.logic.preferences; | ||
|
||
public class DOIPreferences { | ||
private final boolean useCustom; | ||
private final String defaultBaseURI; | ||
|
||
public DOIPreferences(boolean useCustom, String defaultBaseURI) { | ||
this.useCustom = useCustom; | ||
this.defaultBaseURI = defaultBaseURI; | ||
} | ||
|
||
public boolean isUseCustom() { | ||
return useCustom; | ||
} | ||
|
||
public String getDefaultBaseURI() { | ||
return defaultBaseURI; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters