Skip to content

Commit

Permalink
#1635 Add a special county agency to show all county freqs without an…
Browse files Browse the repository at this point in the history
… agency (#1724)

#1635 Playlist Editor Add a special county agency to show all county freqs without an agency.
Merge pull request #1724
  • Loading branch information
EricTendian authored Nov 11, 2023
1 parent 16aed87 commit ae31c41
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ public void setCategories(List<Category> 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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<Agency> countyAgencies = new ArrayList<Agency>();
countyAgencies.add(new CountyAgency(countyInfo));
countyAgencies.addAll(countyInfo.getAgencies());
getCountyAgencyEditor().setAgencies(countyAgencies);
});
}
catch(RadioReferenceException rre)
Expand Down

0 comments on commit ae31c41

Please sign in to comment.