#1635 Add a special county agency to show all county freqs without an agency (#1724)

#1635 Playlist Editor Add a special county agency to show all county freqs without an agency.
Merge pull request #1724
This commit is contained in:
Eric Tendian
2023-11-11 03:39:17 -06:00
committed by GitHub
parent 16aed8741d
commit ae31c41643
4 changed files with 56 additions and 7 deletions

View File

@@ -23,6 +23,7 @@ import io.github.dsheirer.playlist.PlaylistManager;
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 @@ public class AgencyEditor extends VBox
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 class AgencyEditor extends VBox
{
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;
}

View File

@@ -158,9 +158,12 @@ public class AgencyFrequencyEditor extends GridPane
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
{

View File

@@ -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 <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
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);
}
}

View File

@@ -22,6 +22,7 @@ package io.github.dsheirer.gui.playlist.radioreference;
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 jiconfont.javafx.IconNode;
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 @@ public class RadioReferenceEditor extends BorderPane implements Consumer<Authori
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<Agency> countyAgencies = new ArrayList<Agency>();
countyAgencies.add(new CountyAgency(countyInfo));
countyAgencies.addAll(countyInfo.getAgencies());
getCountyAgencyEditor().setAgencies(countyAgencies);
});
}
catch(RadioReferenceException rre)