mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 04:27:48 -05:00
#849 Resolves issue with frequency table column not updating after saving new channel configuration. (#850)
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -39,6 +39,7 @@ import io.github.dsheirer.source.SourceType;
|
|||||||
import io.github.dsheirer.source.config.SourceConfigFactory;
|
import io.github.dsheirer.source.config.SourceConfigFactory;
|
||||||
import io.github.dsheirer.source.config.SourceConfigRecording;
|
import io.github.dsheirer.source.config.SourceConfigRecording;
|
||||||
import io.github.dsheirer.source.config.SourceConfigTuner;
|
import io.github.dsheirer.source.config.SourceConfigTuner;
|
||||||
|
import io.github.dsheirer.source.config.SourceConfigTunerMultipleFrequency;
|
||||||
import io.github.dsheirer.source.config.SourceConfiguration;
|
import io.github.dsheirer.source.config.SourceConfiguration;
|
||||||
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||||
import javafx.beans.Observable;
|
import javafx.beans.Observable;
|
||||||
@@ -48,10 +49,13 @@ import javafx.beans.property.SimpleBooleanProperty;
|
|||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.beans.Transient;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@JacksonXmlRootElement(localName = "channel")
|
@JacksonXmlRootElement(localName = "channel")
|
||||||
@@ -78,6 +82,7 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
|||||||
private StringProperty mSystem = new SimpleStringProperty();
|
private StringProperty mSystem = new SimpleStringProperty();
|
||||||
private StringProperty mSite = new SimpleStringProperty();
|
private StringProperty mSite = new SimpleStringProperty();
|
||||||
private StringProperty mName = new SimpleStringProperty();
|
private StringProperty mName = new SimpleStringProperty();
|
||||||
|
private ObservableList<Long> mFrequencyList;
|
||||||
|
|
||||||
private BooleanProperty mProcessing = new SimpleBooleanProperty();
|
private BooleanProperty mProcessing = new SimpleBooleanProperty();
|
||||||
private BooleanProperty mAutoStart = new SimpleBooleanProperty();
|
private BooleanProperty mAutoStart = new SimpleBooleanProperty();
|
||||||
@@ -178,6 +183,23 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the frequencies property as the source configuration changes or is initialized.
|
||||||
|
*/
|
||||||
|
private void updateFrequencies()
|
||||||
|
{
|
||||||
|
getFrequencyList().clear();
|
||||||
|
|
||||||
|
if(mSourceConfiguration instanceof SourceConfigTuner)
|
||||||
|
{
|
||||||
|
getFrequencyList().add(((SourceConfigTuner)mSourceConfiguration).getFrequency());
|
||||||
|
}
|
||||||
|
else if(mSourceConfiguration instanceof SourceConfigTunerMultipleFrequency)
|
||||||
|
{
|
||||||
|
getFrequencyList().addAll(((SourceConfigTunerMultipleFrequency)mSourceConfiguration).getFrequencies());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias list name property
|
* Alias list name property
|
||||||
*/
|
*/
|
||||||
@@ -243,6 +265,23 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
|||||||
return mChannelID;
|
return mChannelID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of frequencies extracted from the source configuration. This method only exists to support JavaFX
|
||||||
|
* monitoring of frequency list changes. Use the source configuration to manage frequencies.
|
||||||
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
|
public ObservableList<Long> getFrequencyList()
|
||||||
|
{
|
||||||
|
if(mFrequencyList == null)
|
||||||
|
{
|
||||||
|
mFrequencyList = FXCollections.observableArrayList();
|
||||||
|
updateFrequencies();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mFrequencyList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if this channel has been selected for prioritized audio output
|
* Indicates if this channel has been selected for prioritized audio output
|
||||||
* and display of processing chain products
|
* and display of processing chain products
|
||||||
@@ -529,6 +568,8 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
|||||||
mSourceConfiguration = config;
|
mSourceConfiguration = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFrequencies();
|
||||||
|
|
||||||
//Clear the tune channel object so that it can be recreated if the
|
//Clear the tune channel object so that it can be recreated if the
|
||||||
//source configuration changes
|
//source configuration changes
|
||||||
mTunerChannel = null;
|
mTunerChannel = null;
|
||||||
@@ -676,6 +717,7 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
|||||||
public static Callback<Channel,Observable[]> extractor()
|
public static Callback<Channel,Observable[]> extractor()
|
||||||
{
|
{
|
||||||
return (Channel c) -> new Observable[] {c.processingProperty(), c.nameProperty(), c.aliasListNameProperty(),
|
return (Channel c) -> new Observable[] {c.processingProperty(), c.nameProperty(), c.aliasListNameProperty(),
|
||||||
c.autoStartOrderProperty(), c.autoStartProperty(), c.siteProperty(), c.systemProperty()};
|
c.autoStartOrderProperty(), c.autoStartProperty(), c.siteProperty(), c.systemProperty(),
|
||||||
|
c.getFrequencyList()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ import io.github.dsheirer.module.decode.DecoderFactory;
|
|||||||
import io.github.dsheirer.module.decode.DecoderType;
|
import io.github.dsheirer.module.decode.DecoderType;
|
||||||
import io.github.dsheirer.playlist.PlaylistManager;
|
import io.github.dsheirer.playlist.PlaylistManager;
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.config.SourceConfigTuner;
|
|
||||||
import io.github.dsheirer.source.config.SourceConfigTunerMultipleFrequency;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import javafx.collections.transformation.FilteredList;
|
import javafx.collections.transformation.FilteredList;
|
||||||
import javafx.collections.transformation.SortedList;
|
import javafx.collections.transformation.SortedList;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
@@ -642,6 +641,7 @@ public class ChannelEditor extends SplitPane
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel tuner channel source frequencies value factory
|
* Channel tuner channel source frequencies value factory
|
||||||
*/
|
*/
|
||||||
@@ -653,26 +653,17 @@ public class ChannelEditor extends SplitPane
|
|||||||
@Override
|
@Override
|
||||||
public ObservableValue<String> call(TableColumn.CellDataFeatures<Channel, String> param)
|
public ObservableValue<String> call(TableColumn.CellDataFeatures<Channel, String> param)
|
||||||
{
|
{
|
||||||
Channel channel = param.getValue();
|
ObservableList<Long> frequencies = param.getValue().getFrequencyList();
|
||||||
|
|
||||||
if(channel != null)
|
if(frequencies != null)
|
||||||
{
|
{
|
||||||
if(channel.getSourceConfiguration() instanceof SourceConfigTuner)
|
List<String> freqsMHz = new ArrayList<>();
|
||||||
|
for(Long frequency: frequencies)
|
||||||
{
|
{
|
||||||
long frequency = ((SourceConfigTuner)channel.getSourceConfiguration()).getFrequency();
|
freqsMHz.add(String.valueOf(frequency / 1E6));
|
||||||
mFrequency.set(String.valueOf(frequency / 1E6));
|
|
||||||
}
|
}
|
||||||
else if(channel.getSourceConfiguration() instanceof SourceConfigTunerMultipleFrequency)
|
|
||||||
{
|
|
||||||
List<Long> frequencies = ((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).getFrequencies();
|
|
||||||
|
|
||||||
List<String> formatted = new ArrayList<>();
|
mFrequency.set(Joiner.on(", ").join(freqsMHz));
|
||||||
for(Long frequency: frequencies)
|
|
||||||
{
|
|
||||||
formatted.add(String.valueOf(frequency / 1E6));
|
|
||||||
}
|
|
||||||
mFrequency.set(Joiner.on(",").join(formatted));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user