mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 10:37:26 -05:00
Compare commits
2 Commits
315-now-pl
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dd06288ac | ||
|
|
5fd469c402 |
@@ -40,6 +40,7 @@ import io.github.dsheirer.preference.UserPreferences;
|
|||||||
import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference;
|
import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference;
|
||||||
import io.github.dsheirer.sample.Broadcaster;
|
import io.github.dsheirer.sample.Broadcaster;
|
||||||
import io.github.dsheirer.sample.Listener;
|
import io.github.dsheirer.sample.Listener;
|
||||||
|
import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -356,6 +357,21 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li
|
|||||||
frequency.setCellFactory(NowPlayingCells.formatted(value -> frequencyFormat.format(value / 1e6d)));
|
frequency.setCellFactory(NowPlayingCells.formatted(value -> frequencyFormat.format(value / 1e6d)));
|
||||||
columns.add(frequency);
|
columns.add(frequency);
|
||||||
|
|
||||||
|
//Tuner that sources the channel
|
||||||
|
columns.add(NowPlayingCells.column("tuner", "Tuner", null, Pos.CENTER,
|
||||||
|
row -> getTunerName(row.getChannelMetadata()), Row::revisionProperty));
|
||||||
|
|
||||||
|
//System and site labels from the channel configuration, hidden by default
|
||||||
|
TableColumn<Row,String> system = NowPlayingCells.column("system", "System", null, Pos.CENTER,
|
||||||
|
row -> toText(row.getChannelMetadata().getSystemConfigurationIdentifier()), Row::revisionProperty);
|
||||||
|
system.setVisible(false);
|
||||||
|
columns.add(system);
|
||||||
|
|
||||||
|
TableColumn<Row,String> site = NowPlayingCells.column("site", "Site", null, Pos.CENTER,
|
||||||
|
row -> toText(row.getChannelMetadata().getSiteConfigurationIdentifier()), Row::revisionProperty);
|
||||||
|
site.setVisible(false);
|
||||||
|
columns.add(site);
|
||||||
|
|
||||||
columns.add(NowPlayingCells.column("channel.name", "Channel Name", null, Pos.CENTER,
|
columns.add(NowPlayingCells.column("channel.name", "Channel Name", null, Pos.CENTER,
|
||||||
row -> toText(row.getChannelMetadata().getChannelNameConfigurationIdentifier()), Row::revisionProperty));
|
row -> toText(row.getChannelMetadata().getChannelNameConfigurationIdentifier()), Row::revisionProperty));
|
||||||
|
|
||||||
@@ -365,7 +381,8 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li
|
|||||||
column.setSortable(false);
|
column.setSortable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Column numbers in the Swing version of the table, for its stored column widths. Talker is a new column.
|
//Column numbers in the Swing version of the table, for its stored column widths. Talker, Tuner, System and Site are new
|
||||||
|
//columns.
|
||||||
String[] swingColumns = {"status", "decoder", "from", "from.alias", "to", "to.alias", "channel", "frequency",
|
String[] swingColumns = {"status", "decoder", "from", "from.alias", "to", "to.alias", "channel", "frequency",
|
||||||
"channel.name"};
|
"channel.name"};
|
||||||
|
|
||||||
@@ -382,6 +399,22 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li
|
|||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the tuner that sources the channel, or null if the channel isn't sourced by a tuner.
|
||||||
|
*/
|
||||||
|
private String getTunerName(ChannelMetadata channelMetadata)
|
||||||
|
{
|
||||||
|
Channel channel = mChannelMetadataModel.getChannelFromMetadata(channelMetadata);
|
||||||
|
ProcessingChain processingChain = channel != null ? mChannelProcessingManager.getProcessingChain(channel) : null;
|
||||||
|
|
||||||
|
if(processingChain != null && processingChain.getSource() instanceof TunerChannelSource tunerChannelSource)
|
||||||
|
{
|
||||||
|
return tunerChannelSource.getTunerName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decoder logical channel name with the timeslot, if any
|
* Decoder logical channel name with the timeslot, if any
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class TableColumnMonitor<S>
|
|||||||
public static final String LEGACY_INDEX = "column.legacy.index";
|
public static final String LEGACY_INDEX = "column.legacy.index";
|
||||||
private static final String ORDER = ".column.order";
|
private static final String ORDER = ".column.order";
|
||||||
private static final String HIDDEN = ".column.hidden";
|
private static final String HIDDEN = ".column.hidden";
|
||||||
|
private static final String KNOWN = ".column.known";
|
||||||
private static final String WIDTH = ".column.width.";
|
private static final String WIDTH = ".column.width.";
|
||||||
private static final String SEPARATOR = ",";
|
private static final String SEPARATOR = ",";
|
||||||
|
|
||||||
@@ -230,6 +231,7 @@ public class TableColumnMonitor<S>
|
|||||||
|
|
||||||
mPreferences.remove(mKey + ORDER);
|
mPreferences.remove(mKey + ORDER);
|
||||||
mPreferences.remove(mKey + HIDDEN);
|
mPreferences.remove(mKey + HIDDEN);
|
||||||
|
mPreferences.remove(mKey + KNOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -328,10 +330,13 @@ public class TableColumnMonitor<S>
|
|||||||
if(hidden != null)
|
if(hidden != null)
|
||||||
{
|
{
|
||||||
Set<String> hiddenIds = Set.of(hidden.isEmpty() ? new String[0] : hidden.split(SEPARATOR));
|
Set<String> hiddenIds = Set.of(hidden.isEmpty() ? new String[0] : hidden.split(SEPARATOR));
|
||||||
|
Set<String> knownIds = getKnownIds();
|
||||||
|
|
||||||
for(TableColumn<S,?> column: mDefaultOrder)
|
for(TableColumn<S,?> column: mDefaultOrder)
|
||||||
{
|
{
|
||||||
column.setVisible(!hiddenIds.contains(column.getId()));
|
//Columns that weren't in the table when the visibility was stored are new, so use the default
|
||||||
|
column.setVisible(knownIds.contains(column.getId()) ? !hiddenIds.contains(column.getId()) :
|
||||||
|
mDefaultVisibility.get(column));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getVisibleColumnCount() == 0)
|
if(getVisibleColumnCount() == 0)
|
||||||
@@ -375,6 +380,32 @@ public class TableColumnMonitor<S>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IDs of the columns that were in the table when the visibility was stored. Settings stored before the known
|
||||||
|
* columns were stored only had columns that are shown by default.
|
||||||
|
*/
|
||||||
|
private Set<String> getKnownIds()
|
||||||
|
{
|
||||||
|
String known = mPreferences.get(mKey + KNOWN, null);
|
||||||
|
|
||||||
|
if(known != null)
|
||||||
|
{
|
||||||
|
return Set.of(known.isEmpty() ? new String[0] : known.split(SEPARATOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> ids = new HashSet<>();
|
||||||
|
|
||||||
|
for(TableColumn<S,?> column: mDefaultOrder)
|
||||||
|
{
|
||||||
|
if(mDefaultVisibility.get(column))
|
||||||
|
{
|
||||||
|
ids.add(column.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
private int getVisibleColumnCount()
|
private int getVisibleColumnCount()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -405,9 +436,12 @@ public class TableColumnMonitor<S>
|
|||||||
private void storeVisibility()
|
private void storeVisibility()
|
||||||
{
|
{
|
||||||
List<String> ids = new ArrayList<>();
|
List<String> ids = new ArrayList<>();
|
||||||
|
List<String> known = new ArrayList<>();
|
||||||
|
|
||||||
for(TableColumn<S,?> column: mDefaultOrder)
|
for(TableColumn<S,?> column: mDefaultOrder)
|
||||||
{
|
{
|
||||||
|
known.add(column.getId());
|
||||||
|
|
||||||
if(!column.isVisible())
|
if(!column.isVisible())
|
||||||
{
|
{
|
||||||
ids.add(column.getId());
|
ids.add(column.getId());
|
||||||
@@ -415,6 +449,7 @@ public class TableColumnMonitor<S>
|
|||||||
}
|
}
|
||||||
|
|
||||||
mPreferences.put(mKey + HIDDEN, String.join(SEPARATOR, ids));
|
mPreferences.put(mKey + HIDDEN, String.join(SEPARATOR, ids));
|
||||||
|
mPreferences.put(mKey + KNOWN, String.join(SEPARATOR, known));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getWidthKey(TableColumn<S,?> column)
|
private String getWidthKey(TableColumn<S,?> column)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class MultiFrequencyTunerChannelSource extends TunerChannelSource
|
|||||||
private final static Logger mLog = LoggerFactory.getLogger(MultiFrequencyTunerChannelSource.class);
|
private final static Logger mLog = LoggerFactory.getLogger(MultiFrequencyTunerChannelSource.class);
|
||||||
|
|
||||||
private TunerManager mTunerManager;
|
private TunerManager mTunerManager;
|
||||||
private TunerChannelSource mTunerChannelSource;
|
private volatile TunerChannelSource mTunerChannelSource;
|
||||||
private List<Long> mFrequencies;
|
private List<Long> mFrequencies;
|
||||||
private List<Long> mLockedFrequencies = new ArrayList<>();
|
private List<Long> mLockedFrequencies = new ArrayList<>();
|
||||||
private int mFrequencyListPointer = 0;
|
private int mFrequencyListPointer = 0;
|
||||||
@@ -73,6 +73,17 @@ public class MultiFrequencyTunerChannelSource extends TunerChannelSource
|
|||||||
mPreferredTuner = preferredTuner;
|
mPreferredTuner = preferredTuner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the tuner that provides the current frequency's tuner channel source, which can change as the
|
||||||
|
* frequencies rotate.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTunerName()
|
||||||
|
{
|
||||||
|
TunerChannelSource source = mTunerChannelSource;
|
||||||
|
return source != null ? source.getTunerName() : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the channel decoder requested frequency correction.
|
* Applies the channel decoder requested frequency correction.
|
||||||
* @param correction requested by the downstream processors.
|
* @param correction requested by the downstream processors.
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public abstract class TunerChannelSource extends ComplexSource implements ISourc
|
|||||||
protected String mThreadName;
|
protected String mThreadName;
|
||||||
private final ChannelFrequencyErrorManager mChannelFrequencyErrorManager;
|
private final ChannelFrequencyErrorManager mChannelFrequencyErrorManager;
|
||||||
private volatile long mStartTimestamp;
|
private volatile long mStartTimestamp;
|
||||||
|
private volatile String mTunerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tuner Channel Source is a Digital Drop Channel (DDC) abstract class that defines the minimum functionality
|
* Tuner Channel Source is a Digital Drop Channel (DDC) abstract class that defines the minimum functionality
|
||||||
@@ -112,6 +113,24 @@ public abstract class TunerChannelSource extends ComplexSource implements ISourc
|
|||||||
return mTunerChannel;
|
return mTunerChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the tuner that provides this channel source.
|
||||||
|
* @return preferred name of the tuner or null if not set
|
||||||
|
*/
|
||||||
|
public String getTunerName()
|
||||||
|
{
|
||||||
|
return mTunerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the tuner that provides this channel source.
|
||||||
|
* @param tunerName preferred name of the tuner
|
||||||
|
*/
|
||||||
|
public void setTunerName(String tunerName)
|
||||||
|
{
|
||||||
|
mTunerName = tunerName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the timestamp for the oldest samples to provide to this channel when it starts. This only applies to
|
* Sets the timestamp for the oldest samples to provide to this channel when it starts. This only applies to
|
||||||
* sources where the producer incorporates a sample delay buffer.
|
* sources where the producer incorporates a sample delay buffer.
|
||||||
|
|||||||
@@ -655,6 +655,7 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
|||||||
|
|
||||||
if(source != null)
|
if(source != null)
|
||||||
{
|
{
|
||||||
|
source.setTunerName(discoveredTuner.getTuner().getPreferredName());
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -680,6 +681,11 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
|||||||
{
|
{
|
||||||
source = discoveredTuner.getTuner().getChannelSourceManager().getSource(tunerChannel,
|
source = discoveredTuner.getTuner().getChannelSourceManager().getSource(tunerChannel,
|
||||||
channelSpecification, threadName);
|
channelSpecification, threadName);
|
||||||
|
|
||||||
|
if(source != null)
|
||||||
|
{
|
||||||
|
source.setTunerName(discoveredTuner.getTuner().getPreferredName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -212,6 +212,27 @@ public class TableColumnMonitorTest
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void newHiddenByDefaultColumnStaysHidden() throws Exception
|
||||||
|
{
|
||||||
|
onFx(() -> {
|
||||||
|
//Stored by a version without the hidden by default 'site' column and without the known columns
|
||||||
|
mPreferences.put(KEY + ".column.hidden", "a");
|
||||||
|
TableView<String> table = createTable("a", "b", "site");
|
||||||
|
table.getColumns().get(2).setVisible(false);
|
||||||
|
monitor(table);
|
||||||
|
assertEquals(List.of("b"), visibleIds(table));
|
||||||
|
|
||||||
|
//The user shows the column, which is kept in the next session
|
||||||
|
table.getColumns().get(2).setVisible(true);
|
||||||
|
TableView<String> restored = createTable("a", "b", "site", "system");
|
||||||
|
restored.getColumns().get(2).setVisible(false);
|
||||||
|
restored.getColumns().get(3).setVisible(false);
|
||||||
|
monitor(restored);
|
||||||
|
assertEquals(List.of("b", "site"), visibleIds(restored));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lastVisibleColumnCantBeHidden() throws Exception
|
public void lastVisibleColumnCantBeHidden() throws Exception
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user