mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
328 Channel Auto-Start capability. Adds auto-start and auto-start
ordering to each channel configuration to provide the user with greater control over initial application startup configuration. Adds new dialog window that displays on startup that allows the user to invoke/cancel auto-start, or simply allow the timer to expire whereby the channels will be auto-started. Updates channel table model to include an auto-start column and relabels the 'Enabled' column to read 'Playing'. Updates channel editor to change the 'Enable/Disable' button to read 'Start/Stop'. Changes the 'enabled' property of the channel configuration to indicate the current 'processing' status - isProcessing(). Channel's XML configuration re-purposes the 'enabled' property to indicate auto-start and adds a new (optional) auto-start 'order' attribute.
This commit is contained in:
@@ -25,6 +25,7 @@ import io.github.dsheirer.module.decode.DecoderType;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@@ -42,9 +43,11 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
||||
public static final int COLUMN_ALIAS_LIST = 4;
|
||||
public static final int COLUMN_SOURCE = 5;
|
||||
public static final int COLUMN_DECODER = 6;
|
||||
public static final int COLUMN_AUTO_START = 7;
|
||||
|
||||
private static final String[] COLUMN_NAMES = new String[] {"Enabled", "System", "Site", "Name", "Alias List",
|
||||
"Source", "Decoder"};
|
||||
private static final String[] COLUMN_NAMES = new String[] {"Playing", "System", "Site", "Name", "Alias List",
|
||||
"Source", "Decoder", "Auto-Start"};
|
||||
private static final String VALUE_YES = "Yes";
|
||||
|
||||
private List<Channel> mChannels = new CopyOnWriteArrayList<>();
|
||||
private List<Channel> mTrafficChannels = new CopyOnWriteArrayList<>();
|
||||
@@ -209,11 +212,6 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
||||
|
||||
broadcast(new ChannelEvent(channel, Event.NOTIFICATION_ADD));
|
||||
|
||||
if(channel.getEnabled())
|
||||
{
|
||||
broadcast(new ChannelEvent(channel, Event.REQUEST_ENABLE));
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -247,6 +245,48 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List of channels that have the auto-start flag set.
|
||||
*
|
||||
* @return auto-start channels sorted by the channel order value.
|
||||
*/
|
||||
public List<Channel> getAutoStartChannels()
|
||||
{
|
||||
List<Channel> autoStartChannels = new ArrayList<>();
|
||||
|
||||
for(Channel channel: getChannels())
|
||||
{
|
||||
if(channel.isAutoStart())
|
||||
{
|
||||
autoStartChannels.add(channel);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(autoStartChannels, new Comparator<Channel>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Channel channel1, Channel channel2)
|
||||
{
|
||||
if(channel1.hasAutoStartOrder() && channel2.hasAutoStartOrder())
|
||||
{
|
||||
return Integer.compare(channel1.getAutoStartOrder(), channel2.getAutoStartOrder());
|
||||
}
|
||||
else if(channel1.hasAutoStartOrder())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if(channel2.hasAutoStartOrder())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
return autoStartChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of channels that fall within the frequency range
|
||||
*
|
||||
@@ -331,7 +371,7 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_ENABLED:
|
||||
return channel.getEnabled() ? "Enabled" : null;
|
||||
return channel.isProcessing() ? VALUE_YES : null;
|
||||
case COLUMN_SYSTEM:
|
||||
return channel.getSystem();
|
||||
case COLUMN_SITE:
|
||||
@@ -344,6 +384,19 @@ public class ChannelModel extends AbstractTableModel implements IChannelEventBro
|
||||
return channel.getSourceConfiguration().getDescription();
|
||||
case COLUMN_DECODER:
|
||||
return channel.getDecodeConfiguration().getDecoderType().getShortDisplayString();
|
||||
case COLUMN_AUTO_START:
|
||||
if(channel.isAutoStart())
|
||||
{
|
||||
if(channel.hasAutoStartOrder())
|
||||
{
|
||||
return channel.getAutoStartOrder();
|
||||
}
|
||||
else
|
||||
{
|
||||
return VALUE_YES;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user