diff --git a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyEditor.java b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyEditor.java index 7cba16abd..ee86b2139 100644 --- a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyEditor.java +++ b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyEditor.java @@ -23,6 +23,7 @@ import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.rrapi.type.Agency; import io.github.dsheirer.rrapi.type.AgencyInfo; +import io.github.dsheirer.rrapi.type.CountyInfo; import io.github.dsheirer.service.radioreference.RadioReference; import io.github.dsheirer.util.ThreadPool; import javafx.application.Platform; @@ -158,8 +159,13 @@ private void setAgency(Agency agency) ThreadPool.CACHED.submit(() -> { try { - final AgencyInfo agencyInfo = mRadioReference.getService().getAgencyInfo(agency); - Platform.runLater(() -> getAgencyFrequencyEditor().setCategories(agencyInfo.getCategories())); + if (mLevel == Level.COUNTY && agency instanceof CountyAgency) { + final CountyInfo countyInfo = mRadioReference.getService().getCountyInfo(-agency.getAgencyId()); + Platform.runLater(() -> getAgencyFrequencyEditor().setCategories(countyInfo.getCategories())); + } else { + final AgencyInfo agencyInfo = mRadioReference.getService().getAgencyInfo(agency); + Platform.runLater(() -> getAgencyFrequencyEditor().setCategories(agencyInfo.getCategories())); + } } catch(Throwable t) { @@ -196,11 +202,11 @@ public int compare(Agency o1, Agency o2) { return 0; } - else if(o1.getName() == null) + else if(o1.getName() == null || o2 instanceof CountyAgency) { return 1; } - else if(o2.getName() == null) + else if(o2.getName() == null || o1 instanceof CountyAgency) { return -1; } diff --git a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyFrequencyEditor.java b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyFrequencyEditor.java index db5f42e30..03d47ea3f 100644 --- a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyFrequencyEditor.java +++ b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/AgencyFrequencyEditor.java @@ -158,9 +158,12 @@ public void setCategories(List categories) if(categories != null && !categories.isEmpty()) { - getCategoryComboBox().getItems().add(ALL_CATEGORIES); + // Only allow the combined list of all categories if there aren't that many + if (categories.size() < 10) { + categories.add(0, ALL_CATEGORIES); + } getCategoryComboBox().getItems().addAll(categories); - getCategoryComboBox().getSelectionModel().select(ALL_CATEGORIES); + getCategoryComboBox().getSelectionModel().select(categories.get(0)); } else { diff --git a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/CountyAgency.java b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/CountyAgency.java new file mode 100644 index 000000000..36c8e8397 --- /dev/null +++ b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/CountyAgency.java @@ -0,0 +1,33 @@ +/* + * ***************************************************************************** + * Copyright (C) 2014-2022 Dennis Sheirer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + * **************************************************************************** + */ + +package io.github.dsheirer.gui.playlist.radioreference; + +import io.github.dsheirer.rrapi.type.Agency; +import io.github.dsheirer.rrapi.type.CountyInfo; + +public class CountyAgency extends Agency +{ + public CountyAgency(CountyInfo countyInfo) + { + this.setAgencyId(-countyInfo.getCountyId()); + this.setName(countyInfo.getName() + " County (All)"); + this.setType(-1); + } +} diff --git a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/RadioReferenceEditor.java b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/RadioReferenceEditor.java index 9530a1301..9a8fdd9a7 100644 --- a/src/main/java/io/github/dsheirer/gui/playlist/radioreference/RadioReferenceEditor.java +++ b/src/main/java/io/github/dsheirer/gui/playlist/radioreference/RadioReferenceEditor.java @@ -22,6 +22,7 @@ import io.github.dsheirer.playlist.PlaylistManager; import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.rrapi.RadioReferenceException; +import io.github.dsheirer.rrapi.type.Agency; import io.github.dsheirer.rrapi.type.AuthorizationInformation; import io.github.dsheirer.rrapi.type.Country; import io.github.dsheirer.rrapi.type.CountryInfo; @@ -55,6 +56,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -689,7 +691,12 @@ private void setCounty(County county) Platform.runLater(() -> { getCountySystemEditor().setSystems(countyInfo.getSystems()); - getCountyAgencyEditor().setAgencies(countyInfo.getAgencies()); + + // Make a new list so we don't add our CountyAgency to the original list of agencies + List countyAgencies = new ArrayList(); + countyAgencies.add(new CountyAgency(countyInfo)); + countyAgencies.addAll(countyInfo.getAgencies()); + getCountyAgencyEditor().setAgencies(countyAgencies); }); } catch(RadioReferenceException rre)