Skip to content

Commit

Permalink
Add button for a user to reset the cite command to the default value. (
Browse files Browse the repository at this point in the history
…JabRef#10580)

* Add button for a user to reset the cite command to the default value.

Add button in ExternalTab.fxml and link it to a method in ExternalTabViewModel.java that sets the citeCommandProperty to the specified default value
Update CHANGELOG.md

* Fix the requested changes.

Delete redundant comment.
Encapsulate getDefaultCiteCommand in ExternalApplicationsPreferences and update JabRefPreferences accordingly

---------

Co-authored-by: Jonathan Rech <joni.w.rech@gmail.com>
Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent 8804fac commit d6a0e59
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
### Added

- We added a dropdown menu to let users change the reference library during AUX file import. [#10472](https://github.com/JabRef/jabref/issues/10472)
- We added a button to let users reset the cite command to the default value. [#10569](https://github.com/JabRef/jabref/issues/10569)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="150.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="20.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
Expand All @@ -60,6 +60,15 @@
styleClass="icon-button,narrow"
prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="2"/>
<Button styleClass="icon-button,narrow" onAction="#resetCiteCommandToDefault"
prefHeight="20.0" prefWidth="20.0" GridPane.columnIndex="3" GridPane.rowIndex="2">
<graphic>
<JabRefIconView glyph="REFRESH"/>
</graphic>
<tooltip>
<Tooltip text="%Reset to default"/>
</tooltip>
</Button>
</GridPane>
</HBox>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,9 @@ void useTerminalCommandBrowse() {
void useFileBrowserSpecialCommandBrowse() {
viewModel.customFileBrowserBrowse();
}

@FXML
void resetCiteCommandToDefault() {
viewModel.resetCiteCommandToDefault();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,8 @@ public BooleanProperty useCustomFileBrowserProperty() {
public StringProperty customFileBrowserCommandProperty() {
return this.customFileBrowserCommandProperty;
}

public void resetCiteCommandToDefault() {
this.citeCommandProperty.setValue(preferences.getExternalApplicationsPreferences().getDefaultCiteCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class ExternalApplicationsPreferences {
private final BooleanProperty shouldAutoOpenEmailAttachmentsFolder;
private final StringProperty citeCommand;

private final StringProperty defaultCiteCommand;

private final BooleanProperty useCustomTerminal;
private final StringProperty customTerminalCommand;
private final BooleanProperty useCustomFileBrowser;
Expand All @@ -20,6 +22,7 @@ public class ExternalApplicationsPreferences {
public ExternalApplicationsPreferences(String eMailSubject,
boolean shouldAutoOpenEmailAttachmentsFolder,
String citeCommand,
String defaultCiteCommand,
boolean useCustomTerminal,
String customTerminalCommand,
boolean useCustomFileBrowser,
Expand All @@ -29,6 +32,7 @@ public ExternalApplicationsPreferences(String eMailSubject,
this.eMailSubject = new SimpleStringProperty(eMailSubject);
this.shouldAutoOpenEmailAttachmentsFolder = new SimpleBooleanProperty(shouldAutoOpenEmailAttachmentsFolder);
this.citeCommand = new SimpleStringProperty(citeCommand);
this.defaultCiteCommand = new SimpleStringProperty(defaultCiteCommand);
this.useCustomTerminal = new SimpleBooleanProperty(useCustomTerminal);
this.customTerminalCommand = new SimpleStringProperty(customTerminalCommand);
this.useCustomFileBrowser = new SimpleBooleanProperty(useCustomFileBrowser);
Expand Down Expand Up @@ -131,4 +135,8 @@ public StringProperty kindleEmailProperty() {
public void setKindleEmail(String kindleEmail) {
this.kindleEmail.set(kindleEmail);
}

public String getDefaultCiteCommand() {
return defaultCiteCommand.getValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ public ExternalApplicationsPreferences getExternalApplicationsPreferences() {
get(EMAIL_SUBJECT),
getBoolean(OPEN_FOLDERS_OF_ATTACHED_FILES),
get(CITE_COMMAND),
(String) defaults.get(CITE_COMMAND),
!getBoolean(USE_DEFAULT_CONSOLE_APPLICATION), // mind the !
get(CONSOLE_COMMAND),
!getBoolean(USE_DEFAULT_FILE_BROWSER_APPLICATION), // mind the !
Expand Down

0 comments on commit d6a0e59

Please sign in to comment.