Skip to content

Commit

Permalink
Got the Popularity button to enable/disable based on preferences. (Ja…
Browse files Browse the repository at this point in the history
  • Loading branch information
ExrosZ-Alt committed Oct 17, 2024
1 parent 587d542 commit 5367b87
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/groups/GroupDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ public void initialize() {
searchRadioButton.selectedProperty().bindBidirectional(viewModel.typeSearchProperty());
autoRadioButton.selectedProperty().bindBidirectional(viewModel.typeAutoProperty());
texRadioButton.selectedProperty().bindBidirectional(viewModel.typeTexProperty());
popularityButton.selectedProperty().bindBidirectional(viewModel.typePopularityProperty());
popularityButton.disableProperty().bind(viewModel.trackViewsEnabledProperty().not());

timePeriodCombo.setItems(FXCollections.observableArrayList("Last week", "Last month", "Last year", "All time"));
maxEntriesCombo.setItems(FXCollections.observableArrayList(10, 20, 50, 100, 999));

timePeriodCombo.visibleProperty().bind(popularityButton.selectedProperty());
maxEntriesCombo.visibleProperty().bind(popularityButton.selectedProperty());

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.importer.actions.SearchGroupsMigrationAction;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.preferences.entry.EntryTabViewModel;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.auxparser.DefaultAuxParser;
import org.jabref.logic.groups.DefaultGroupsFactory;
Expand Down Expand Up @@ -582,10 +583,6 @@ public BooleanProperty typeTexProperty() {
return typeTexProperty;
}

public BooleanProperty typePopularityProperty(){
return typePopularityProperty;
}

public StringProperty keywordGroupSearchTermProperty() {
return keywordGroupSearchTermProperty;
}
Expand Down Expand Up @@ -649,4 +646,8 @@ private boolean groupOrSubgroupIsSearchGroup(GroupTreeNode groupTreeNode) {
}
return false;
}

public BooleanProperty trackViewsEnabledProperty() {
return EntryTabViewModel.trackViewsProperty();
}
}
11 changes: 10 additions & 1 deletion src/main/java/org/jabref/gui/preferences/entry/EntryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class EntryTab extends AbstractPreferenceTabView<EntryTabViewModel> implements PreferencesTab {


@FXML public CheckBox trackViews;

@FXML private TextField keywordSeparator;

Expand Down Expand Up @@ -70,6 +70,11 @@ public void initialize() {

addCreationDate.selectedProperty().bindBidirectional(viewModel.addCreationDateProperty());
addModificationDate.selectedProperty().bindBidirectional(viewModel.addModificationDateProperty());
trackViews.selectedProperty().bindBidirectional(viewModel.trackViewsProperty());

trackViews.selectedProperty().addListener((observable, oldValue, newValue) -> {
viewModel.setTrackViewsEnabled(newValue);
});

ActionFactory actionFactory = new ActionFactory();
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.OWNER, dialogService, preferences.getExternalApplicationsPreferences()), markOwnerHelp);
Expand All @@ -79,4 +84,8 @@ public void initialize() {
public String getTabName() {
return Localization.lang("Entry");
}

public CheckBox getTrackViews() {
return trackViews;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class EntryTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty markOwnerOverwriteProperty = new SimpleBooleanProperty();
private final BooleanProperty addCreationDateProperty = new SimpleBooleanProperty();
private final BooleanProperty addModificationDateProperty = new SimpleBooleanProperty();
private static final BooleanProperty trackViewsProperty = new SimpleBooleanProperty();

private final FieldPreferences fieldPreferences;
private final BibEntryPreferences bibEntryPreferences;
Expand Down Expand Up @@ -110,4 +111,16 @@ public BooleanProperty addCreationDateProperty() {
public BooleanProperty addModificationDateProperty() {
return addModificationDateProperty;
}

public static BooleanProperty trackViewsProperty() {
return trackViewsProperty;
}

public boolean isTrackViewsEnabled() {
return trackViewsProperty.get();
}

public void setTrackViewsEnabled(boolean enabled) {
trackViewsProperty.set(enabled);
}
}

0 comments on commit 5367b87

Please sign in to comment.