mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Updates pull request from Roman Tsypuk to convert the build system from
ant to gradle. Removes linux and windows application launch scripts and produces an executable jar with all resources included.
This commit is contained in:
116
src/main/java/io/github/dsheirer/controller/ControllerPanel.java
Normal file
116
src/main/java/io/github/dsheirer/controller/ControllerPanel.java
Normal file
@@ -0,0 +1,116 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 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.controller;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
import io.github.dsheirer.audio.AudioManager;
|
||||
import io.github.dsheirer.audio.AudioPanel;
|
||||
import io.github.dsheirer.audio.broadcast.BroadcastModel;
|
||||
import io.github.dsheirer.audio.broadcast.BroadcastPanel;
|
||||
import io.github.dsheirer.channel.metadata.ChannelMetadataViewer;
|
||||
import io.github.dsheirer.controller.channel.ChannelController;
|
||||
import io.github.dsheirer.controller.channel.ChannelModel;
|
||||
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.map.MapPanel;
|
||||
import io.github.dsheirer.map.MapService;
|
||||
import io.github.dsheirer.settings.SettingsManager;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
import io.github.dsheirer.source.tuner.TunerModel;
|
||||
import io.github.dsheirer.source.tuner.TunerViewPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import io.github.dsheirer.alias.AliasController;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class ControllerPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private AliasController mAliasController;
|
||||
private AudioPanel mAudioPanel;
|
||||
private BroadcastPanel mBroadcastPanel;
|
||||
private ChannelController mChannelController;
|
||||
private ChannelMetadataViewer mChannelMetadataViewer;
|
||||
private ChannelModel mChannelModel;
|
||||
private MapPanel mMapPanel;
|
||||
private TunerViewPanel mTunerManagerPanel;
|
||||
private BroadcastModel mBroadcastModel;
|
||||
|
||||
private JideTabbedPane mTabbedPane;
|
||||
protected JTable mChannelActivityTable = new JTable();
|
||||
|
||||
public ControllerPanel(AudioManager audioManager,
|
||||
AliasModel aliasModel,
|
||||
BroadcastModel broadcastModel,
|
||||
ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
IconManager iconManager,
|
||||
MapService mapService,
|
||||
SettingsManager settingsManager,
|
||||
SourceManager sourceManager,
|
||||
TunerModel tunerModel)
|
||||
{
|
||||
mBroadcastModel = broadcastModel;
|
||||
mChannelModel = channelModel;
|
||||
|
||||
mAudioPanel = new AudioPanel(iconManager, settingsManager, sourceManager, audioManager);
|
||||
|
||||
mChannelMetadataViewer = new ChannelMetadataViewer(channelProcessingManager, iconManager, settingsManager);
|
||||
|
||||
mMapPanel = new MapPanel(mapService, iconManager, settingsManager);
|
||||
|
||||
mBroadcastPanel = new BroadcastPanel(broadcastModel, aliasModel, iconManager);
|
||||
|
||||
mChannelController = new ChannelController(channelModel, channelMapModel, sourceManager, aliasModel);
|
||||
|
||||
mAliasController = new AliasController(aliasModel, broadcastModel, iconManager);
|
||||
|
||||
mTunerManagerPanel = new TunerViewPanel(tunerModel);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[]0[grow,fill]0[]"));
|
||||
|
||||
add(mAudioPanel, "wrap");
|
||||
|
||||
//Tabbed View - configuration, calls, messages, map
|
||||
mTabbedPane = new JideTabbedPane();
|
||||
mTabbedPane.setFont(this.getFont());
|
||||
mTabbedPane.setForeground(Color.BLACK);
|
||||
mTabbedPane.addTab("Now Playing", mChannelMetadataViewer);
|
||||
mTabbedPane.addTab("Aliases", mAliasController);
|
||||
mTabbedPane.addTab("Channels", mChannelController);
|
||||
mTabbedPane.addTab("Map", mMapPanel);
|
||||
mTabbedPane.addTab("Streaming", mBroadcastPanel);
|
||||
mTabbedPane.addTab("Tuners", mTunerManagerPanel);
|
||||
|
||||
//Set preferred size to influence the split between these panels
|
||||
mTabbedPane.setPreferredSize(new Dimension(880, 500));
|
||||
|
||||
add(mTabbedPane,"wrap");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package io.github.dsheirer.controller;
|
||||
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Thread factory that applies custom names to threads
|
||||
*/
|
||||
public class NamingThreadFactory implements ThreadFactory
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ThreadPool.class);
|
||||
|
||||
private static final AtomicInteger mPoolNumber = new AtomicInteger(1);
|
||||
|
||||
private final ThreadGroup mThreadGroup;
|
||||
|
||||
private final AtomicInteger mThreadNumber = new AtomicInteger(1);
|
||||
|
||||
private final String mNamePrefix;
|
||||
|
||||
public NamingThreadFactory( String prefix )
|
||||
{
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
|
||||
mThreadGroup = (s != null)? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||
|
||||
mNamePrefix = prefix + " pool-" + mPoolNumber.getAndIncrement() + "-thread-";
|
||||
}
|
||||
|
||||
public Thread newThread( Runnable runnable )
|
||||
{
|
||||
Thread thread = new Thread(mThreadGroup, runnable,
|
||||
mNamePrefix + mThreadNumber.getAndIncrement(), 0 );
|
||||
|
||||
if( thread.isDaemon() )
|
||||
{
|
||||
thread.setDaemon( false );
|
||||
}
|
||||
|
||||
if( thread.getPriority() != Thread.NORM_PRIORITY )
|
||||
{
|
||||
thread.setPriority( Thread.NORM_PRIORITY );
|
||||
}
|
||||
|
||||
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e)
|
||||
{
|
||||
mLog.error("Error while executing runnable in scheduled thread pool [" + t.getName() + "]", e);
|
||||
}
|
||||
});
|
||||
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
480
src/main/java/io/github/dsheirer/controller/channel/Channel.java
Normal file
480
src/main/java/io/github/dsheirer/controller/channel/Channel.java
Normal file
@@ -0,0 +1,480 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 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.controller.channel;
|
||||
|
||||
import io.github.dsheirer.controller.config.Configuration;
|
||||
import io.github.dsheirer.module.decode.DecoderFactory;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.config.AuxDecodeConfiguration;
|
||||
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
|
||||
import io.github.dsheirer.module.log.EventLogType;
|
||||
import io.github.dsheirer.module.log.config.EventLogConfiguration;
|
||||
import io.github.dsheirer.record.RecorderType;
|
||||
import io.github.dsheirer.record.config.RecordConfiguration;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.SourceType;
|
||||
import io.github.dsheirer.source.config.SourceConfigFactory;
|
||||
import io.github.dsheirer.source.config.SourceConfigRecording;
|
||||
import io.github.dsheirer.source.config.SourceConfigTuner;
|
||||
import io.github.dsheirer.source.config.SourceConfiguration;
|
||||
import io.github.dsheirer.source.tuner.TunerChannel;
|
||||
import io.github.dsheirer.source.tuner.TunerChannel.Type;
|
||||
import io.github.dsheirer.source.tuner.frequency.FrequencyChangeEvent;
|
||||
import io.github.dsheirer.source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@XmlSeeAlso({Configuration.class})
|
||||
@XmlRootElement(name = "channel")
|
||||
public class Channel extends Configuration implements Listener<FrequencyChangeEvent>
|
||||
{
|
||||
// Standard channels are persisted and traffic channels are temporary
|
||||
public enum ChannelType
|
||||
{
|
||||
STANDARD, TRAFFIC
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
|
||||
// Static unique channel identifier tracking
|
||||
private static int UNIQUE_ID = 0;
|
||||
|
||||
private DecodeConfiguration mDecodeConfiguration = DecoderFactory.getDefaultDecodeConfiguration();
|
||||
private AuxDecodeConfiguration mAuxDecodeConfiguration =
|
||||
new AuxDecodeConfiguration();
|
||||
private SourceConfiguration mSourceConfiguration =
|
||||
SourceConfigFactory.getDefaultSourceConfiguration();
|
||||
private EventLogConfiguration mEventLogConfiguration =
|
||||
new EventLogConfiguration();
|
||||
private RecordConfiguration mRecordConfiguration = new RecordConfiguration();
|
||||
|
||||
private String mAliasListName;
|
||||
private String mSystem = "System";
|
||||
private String mSite = "Site";
|
||||
private String mName = "Channel";
|
||||
|
||||
private boolean mEnabled;
|
||||
private boolean mSelected;
|
||||
private TunerChannel mTunerChannel = null;
|
||||
|
||||
private ChannelType mChannelType = ChannelType.STANDARD;
|
||||
|
||||
private int mChannelID;
|
||||
private int mChannelFrequencyCorrection = 0;
|
||||
|
||||
/**
|
||||
* Channel represents a complete set of configurations needed to setup and
|
||||
* manage a processing chain and/or manage as a set of business objects that
|
||||
* can be displayed in graphical components.
|
||||
*
|
||||
* @param channelName
|
||||
* @param channelType
|
||||
*/
|
||||
public Channel(String channelName, ChannelType channelType)
|
||||
{
|
||||
this(channelName);
|
||||
mChannelType = channelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new standard channel with the specified channel name
|
||||
*/
|
||||
public Channel(String channelName)
|
||||
{
|
||||
this();
|
||||
mName = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new standard channel with a default name of "Channel"
|
||||
*/
|
||||
public Channel()
|
||||
{
|
||||
mChannelID = UNIQUE_ID++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a (new) deep copy of this channel
|
||||
*/
|
||||
public Channel copyOf()
|
||||
{
|
||||
Channel channel = new Channel(mName);
|
||||
channel.setSystem(mSystem);
|
||||
channel.setSite(mSite);
|
||||
channel.setAliasListName(mAliasListName);
|
||||
|
||||
AuxDecodeConfiguration aux = new AuxDecodeConfiguration();
|
||||
|
||||
for(DecoderType auxType : aux.getAuxDecoders())
|
||||
{
|
||||
aux.addAuxDecoder(auxType);
|
||||
}
|
||||
|
||||
channel.setAuxDecodeConfiguration(aux);
|
||||
|
||||
channel.setDecodeConfiguration(DecoderFactory.copy(mDecodeConfiguration));
|
||||
|
||||
EventLogConfiguration log = new EventLogConfiguration();
|
||||
|
||||
for(EventLogType logType : mEventLogConfiguration.getLoggers())
|
||||
{
|
||||
log.addLogger(logType);
|
||||
}
|
||||
|
||||
channel.setEventLogConfiguration(log);
|
||||
|
||||
RecordConfiguration record = new RecordConfiguration();
|
||||
|
||||
for(RecorderType recordType : mRecordConfiguration.getRecorders())
|
||||
{
|
||||
record.addRecorder(recordType);
|
||||
}
|
||||
|
||||
channel.setRecordConfiguration(record);
|
||||
|
||||
channel.setSourceConfiguration(SourceConfigFactory.copy(mSourceConfiguration));
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier for this channel. Value is transient (not persisted).
|
||||
*/
|
||||
@XmlTransient
|
||||
public int getChannelID()
|
||||
{
|
||||
return mChannelID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this channel has been selected for prioritized audio output
|
||||
* and display of processing chain products
|
||||
*/
|
||||
@XmlTransient
|
||||
public boolean isSelected()
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets selection status of the channel.
|
||||
*
|
||||
* NOTE: this method is package private so that only the ChannelSelectionManager
|
||||
* can toggle the selection state. Use the channel model to broadcast a
|
||||
* request select/deselect channel event.
|
||||
*
|
||||
* @param selected
|
||||
*/
|
||||
void setSelected(boolean selected)
|
||||
{
|
||||
mSelected = selected;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public ChannelType getChannelType()
|
||||
{
|
||||
return mChannelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owning system for this channel.
|
||||
*/
|
||||
@XmlAttribute(name = "system")
|
||||
public String getSystem()
|
||||
{
|
||||
return mSystem;
|
||||
}
|
||||
|
||||
public void setSystem(String system)
|
||||
{
|
||||
mSystem = system;
|
||||
}
|
||||
|
||||
public boolean hasSystem()
|
||||
{
|
||||
return mSystem != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owning site for this channel.
|
||||
*/
|
||||
@XmlAttribute(name = "site")
|
||||
public String getSite()
|
||||
{
|
||||
return mSite;
|
||||
}
|
||||
|
||||
public void setSite(String site)
|
||||
{
|
||||
mSite = site;
|
||||
}
|
||||
|
||||
public boolean hasSite()
|
||||
{
|
||||
return mSite != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this channel.
|
||||
*/
|
||||
@XmlAttribute(name = "name")
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this channel.
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default display string for this channel: SYSTEM_SITE_NAME
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(hasSystem() ? getSystem() : "SYSTEM");
|
||||
sb.append("_");
|
||||
sb.append(hasSite() ? getSite() : "SITE");
|
||||
sb.append("_");
|
||||
sb.append(getName());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this channel is enabled for processing.
|
||||
*/
|
||||
@XmlAttribute(name = "enabled")
|
||||
public boolean getEnabled()
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this channel will automatically start processing on
|
||||
* application startup or if this channel is currently processing after
|
||||
* application startup.
|
||||
*
|
||||
* Note: this method is package private and is intended to be managed
|
||||
* by a co-package central processing manager
|
||||
*
|
||||
* @see ChannelProcessingManager
|
||||
*/
|
||||
void setEnabled(boolean enabled)
|
||||
{
|
||||
mEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alias list that is used by this channel for looking up alias
|
||||
* values for the various identifiers produced by the decoder(s).
|
||||
*/
|
||||
@XmlElement(name = "alias_list_name")
|
||||
public String getAliasListName()
|
||||
{
|
||||
return mAliasListName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alias list to be used for looking up the alias values for the
|
||||
* various identifiers produced by the decoder
|
||||
*/
|
||||
public void setAliasListName(String name)
|
||||
{
|
||||
mAliasListName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the primary decoder configuration used by this channel
|
||||
*/
|
||||
@XmlElement(name = "decode_configuration")
|
||||
public DecodeConfiguration getDecodeConfiguration()
|
||||
{
|
||||
return mDecodeConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the primary decoder configuration used by this channel
|
||||
*/
|
||||
public void setDecodeConfiguration(DecodeConfiguration config)
|
||||
{
|
||||
mDecodeConfiguration = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the aux decoder configuration used by this channel. Aux decoders
|
||||
* operate on demodulated audio
|
||||
*/
|
||||
@XmlElement(name = "aux_decode_configuration")
|
||||
public AuxDecodeConfiguration getAuxDecodeConfiguration()
|
||||
{
|
||||
return mAuxDecodeConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the decoder configuration used by this channel
|
||||
*/
|
||||
public void setAuxDecodeConfiguration(AuxDecodeConfiguration config)
|
||||
{
|
||||
mAuxDecodeConfiguration = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source configuration for this channel. A channel source
|
||||
* identifies where the processing chain will get source sample data from.
|
||||
*/
|
||||
@XmlElement(name = "source_configuration")
|
||||
public SourceConfiguration getSourceConfiguration()
|
||||
{
|
||||
return mSourceConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source configuration for this channel.
|
||||
*/
|
||||
public void setSourceConfiguration(SourceConfiguration config)
|
||||
{
|
||||
mSourceConfiguration = config;
|
||||
|
||||
//Clear the tune channel object so that it can be recreated if the
|
||||
//source configuration changes
|
||||
mTunerChannel = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event logger configuration for this channel.
|
||||
*/
|
||||
@XmlElement(name = "event_log_configuration")
|
||||
public EventLogConfiguration getEventLogConfiguration()
|
||||
{
|
||||
return mEventLogConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the event logger configuration for this channel.
|
||||
*/
|
||||
public void setEventLogConfiguration(EventLogConfiguration config)
|
||||
{
|
||||
mEventLogConfiguration = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the recorder configuration for this channel.
|
||||
*/
|
||||
@XmlElement(name = "record_configuration")
|
||||
public RecordConfiguration getRecordConfiguration()
|
||||
{
|
||||
return mRecordConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the recorder configuration for this channel.
|
||||
*/
|
||||
public void setRecordConfiguration(RecordConfiguration config)
|
||||
{
|
||||
mRecordConfiguration = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to construct a tuner channel object representing a
|
||||
* tuner or recording source frequency and bandwidth that can be used by
|
||||
* application components for graphically representing this channel.
|
||||
*
|
||||
* If the source configuration is not a tuner or recording, this method
|
||||
* returns null.
|
||||
*/
|
||||
@XmlTransient
|
||||
public TunerChannel getTunerChannel()
|
||||
{
|
||||
if(mTunerChannel == null)
|
||||
{
|
||||
if(mSourceConfiguration.getSourceType() == SourceType.TUNER)
|
||||
{
|
||||
SourceConfigTuner config = (SourceConfigTuner)mSourceConfiguration;
|
||||
|
||||
mTunerChannel = new TunerChannel(Type.LOCKED, config.getFrequency(),
|
||||
mDecodeConfiguration.getDecoderType().getChannelBandwidth());
|
||||
}
|
||||
else if(mSourceConfiguration.getSourceType() == SourceType.RECORDING)
|
||||
{
|
||||
SourceConfigRecording config =
|
||||
(SourceConfigRecording)mSourceConfiguration;
|
||||
|
||||
mTunerChannel = new TunerChannel(Type.LOCKED, config.getFrequency(),
|
||||
mDecodeConfiguration.getDecoderType().getChannelBandwidth());
|
||||
}
|
||||
}
|
||||
|
||||
return mTunerChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to indicate if any part of this channel is contained
|
||||
* within the minimum and maximum frequency values.
|
||||
*/
|
||||
public boolean isWithin(long minimum, long maximum)
|
||||
{
|
||||
TunerChannel tunerChannel = getTunerChannel();
|
||||
|
||||
return tunerChannel != null && tunerChannel.overlaps(minimum, maximum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to make the current channel frequency correction value
|
||||
* available for use outside of a constructed processing chain while maintaining
|
||||
* linkage to the source channel. This hack allows the correction value to
|
||||
* be used to visually show in the spectral display.
|
||||
*/
|
||||
@Override
|
||||
public void receive(FrequencyChangeEvent event)
|
||||
{
|
||||
if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE)
|
||||
{
|
||||
mChannelFrequencyCorrection = event.getValue().intValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Current channel frequency correction value (when this channel is processing)
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public int getChannelFrequencyCorrection()
|
||||
{
|
||||
return mChannelFrequencyCorrection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets frequency correction value to 0
|
||||
*/
|
||||
public void resetFrequencyCorrection()
|
||||
{
|
||||
mChannelFrequencyCorrection = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
import net.coderazzi.filters.gui.AutoChoices;
|
||||
import net.coderazzi.filters.gui.TableFilterHeader;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelController extends JPanel
|
||||
implements ActionListener, ListSelectionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private JTable mChannelTable;
|
||||
private TableFilterHeader mTableFilterHeader;
|
||||
private ChannelEditor mEditor;
|
||||
|
||||
private static final String NEW_CHANNEL = "New";
|
||||
private static final String COPY_CHANNEL = "Copy";
|
||||
private static final String DELETE_CHANNEL = "Delete";
|
||||
|
||||
private JButton mNewChannelButton = new JButton( NEW_CHANNEL );
|
||||
private JButton mCopyChannelButton = new JButton( COPY_CHANNEL );
|
||||
private JButton mDeleteChannelButton = new JButton( DELETE_CHANNEL );
|
||||
|
||||
public ChannelController( ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
SourceManager sourceManager,
|
||||
AliasModel aliasModel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
|
||||
mEditor = new ChannelEditor( channelModel, channelMapModel, sourceManager, aliasModel );
|
||||
mChannelModel.addListener( mEditor );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]") );
|
||||
|
||||
//System Configuration View and Editor
|
||||
mChannelTable = new JTable( mChannelModel );
|
||||
mChannelTable.setDefaultRenderer( String.class, new ChannelTableCellRenderer() );
|
||||
mChannelTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
mChannelTable.getSelectionModel().addListSelectionListener( this );
|
||||
mChannelTable.setAutoCreateRowSorter( true );
|
||||
|
||||
mTableFilterHeader = new TableFilterHeader( mChannelTable, AutoChoices.ENABLED );
|
||||
mTableFilterHeader.setFilterOnUpdates( true );
|
||||
|
||||
JScrollPane channelScroller = new JScrollPane( mChannelTable );
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
|
||||
buttonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]") );
|
||||
|
||||
mNewChannelButton.addActionListener( this );
|
||||
mNewChannelButton.setToolTipText( "Create a new channel configuration" );
|
||||
buttonsPanel.add( mNewChannelButton );
|
||||
|
||||
mCopyChannelButton.addActionListener( this );
|
||||
mCopyChannelButton.setEnabled( false );
|
||||
mCopyChannelButton.setToolTipText( "Create a copy of the currently selected channel configuration" );
|
||||
buttonsPanel.add( mCopyChannelButton );
|
||||
|
||||
mDeleteChannelButton.addActionListener( this );
|
||||
mDeleteChannelButton.setEnabled( false );
|
||||
mDeleteChannelButton.setToolTipText( "Delete the currently selected channel configuration" );
|
||||
buttonsPanel.add( mDeleteChannelButton );
|
||||
|
||||
JPanel listAndButtonsPanel = new JPanel();
|
||||
|
||||
listAndButtonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill][]") );
|
||||
|
||||
listAndButtonsPanel.add( channelScroller, "wrap" );
|
||||
listAndButtonsPanel.add( buttonsPanel );
|
||||
|
||||
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.VERTICAL_SPLIT );
|
||||
splitPane.setDividerSize( 5 );
|
||||
splitPane.setShowGripper( true );
|
||||
|
||||
//Shrink this guy so that he'll eventually be expanded to the scroller preferred size
|
||||
listAndButtonsPanel.setPreferredSize( new Dimension( 10, 10 ) );
|
||||
|
||||
//Attempt to get a 60:40 vertical sizing preference
|
||||
JScrollPane listScroller = new JScrollPane( listAndButtonsPanel );
|
||||
listScroller.setPreferredSize( new Dimension( 800, 58 ) );
|
||||
|
||||
JScrollPane editorScroller = new JScrollPane( mEditor );
|
||||
editorScroller.setPreferredSize( new Dimension( 800, 42 ) );
|
||||
|
||||
splitPane.add( listScroller );
|
||||
splitPane.add( editorScroller );
|
||||
|
||||
add( splitPane );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
//This limits event firing to only when selection is complete
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int selectedRow = mChannelTable.getSelectedRow();
|
||||
|
||||
if( selectedRow != -1 )
|
||||
{
|
||||
int index = mChannelTable.convertRowIndexToModel( mChannelTable.getSelectedRow() );
|
||||
|
||||
Channel channel = mChannelModel.getChannelAtIndex( index );
|
||||
|
||||
if( channel != null )
|
||||
{
|
||||
mEditor.setItem( channel );
|
||||
mCopyChannelButton.setEnabled( true );
|
||||
mDeleteChannelButton.setEnabled( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mEditor.setItem( null );
|
||||
mCopyChannelButton.setEnabled( false );
|
||||
mDeleteChannelButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the channel to the channel model/table and scrolls to view it
|
||||
*/
|
||||
private void addChannel( Channel channel )
|
||||
{
|
||||
//HACK: when inserting a row to the model, the JTable gets
|
||||
//notified and attempts to tell the coderazzi table filter
|
||||
//adaptive choices filter to refresh before the table filter is
|
||||
//notified of the row additions, causing an index out of bounds
|
||||
//exception. We turn off adaptive choices temporarily, add the
|
||||
//channel, and turn on adaptive choices again.
|
||||
mTableFilterHeader.setAdaptiveChoices( false );
|
||||
|
||||
int index = mChannelModel.addChannel( channel );
|
||||
|
||||
mTableFilterHeader.setAdaptiveChoices( true );
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
int translatedIndex = mChannelTable.convertRowIndexToView( index );
|
||||
mChannelTable.setRowSelectionInterval( translatedIndex, translatedIndex );
|
||||
mChannelTable.scrollRectToVisible(
|
||||
new Rectangle( mChannelTable.getCellRect( translatedIndex, 0, true ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
private Channel getSelectedChannel()
|
||||
{
|
||||
int index = mChannelTable.getSelectedRow();
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
return mChannelModel.getChannelAtIndex(
|
||||
mChannelTable.convertRowIndexToModel( index ) );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to New, Copy and Delete Channel button invocations
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent event )
|
||||
{
|
||||
switch( event.getActionCommand() )
|
||||
{
|
||||
case NEW_CHANNEL:
|
||||
addChannel( new Channel( "New Channel" ) );
|
||||
break;
|
||||
case COPY_CHANNEL:
|
||||
Channel selected = getSelectedChannel();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
addChannel( selected.copyOf() );
|
||||
}
|
||||
break;
|
||||
case DELETE_CHANNEL:
|
||||
Channel toDelete = getSelectedChannel();
|
||||
|
||||
if( toDelete != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( ChannelController.this,
|
||||
"Do you want to delete this channel?", "Delete Channel?",
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mChannelModel.removeChannel( toDelete );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public class ChannelTableCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column )
|
||||
{
|
||||
Component component = super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column );
|
||||
|
||||
ChannelModel model = (ChannelModel)table.getModel();
|
||||
|
||||
int index = table.convertRowIndexToModel( row );
|
||||
|
||||
Channel channel = model.getChannelAtIndex( index );
|
||||
|
||||
boolean enabled = channel.getEnabled();
|
||||
|
||||
if( isSelected )
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
component.setBackground( Color.YELLOW );
|
||||
}
|
||||
else
|
||||
{
|
||||
component.setBackground( table.getSelectionBackground() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
component.setBackground( Color.GREEN );
|
||||
}
|
||||
else
|
||||
{
|
||||
component.setBackground( table.getBackground() );
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.gui.editor.Editor;
|
||||
import io.github.dsheirer.gui.editor.EditorValidationException;
|
||||
import io.github.dsheirer.record.RecordConfigurationEditor;
|
||||
import io.github.dsheirer.source.SourceConfigurationEditor;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.module.decode.AuxDecodeConfigurationEditor;
|
||||
import io.github.dsheirer.module.decode.DecodeConfigurationEditor;
|
||||
import io.github.dsheirer.module.log.EventLogConfigurationEditor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelEditor extends Editor<Channel> implements ActionListener, ChannelEventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private NameConfigurationEditor mNameConfigurationEditor;
|
||||
private SourceConfigurationEditor mSourceConfigurationEditor;
|
||||
private DecodeConfigurationEditor mDecodeConfigurationEditor;
|
||||
private AuxDecodeConfigurationEditor mAuxDecodeConfigurationEditor;
|
||||
private EventLogConfigurationEditor mEventLogConfigurationEditor;
|
||||
private RecordConfigurationEditor mRecordConfigurationEditor;
|
||||
|
||||
private JButton mEnableButton = new JButton( "Enable" );
|
||||
private JLabel mChannelName = new JLabel( "Channel:" );
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelMapModel mChannelMapModel;
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
private boolean mChannelEnableRequested = false;
|
||||
|
||||
public ChannelEditor( ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
SourceManager sourceManager,
|
||||
AliasModel aliasModel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelMapModel = channelMapModel;
|
||||
mSourceManager = sourceManager;
|
||||
mNameConfigurationEditor = new NameConfigurationEditor( aliasModel, mChannelModel );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 3", "[grow,fill][grow,fill][grow,fill]", "[grow,fill][]" ) );
|
||||
|
||||
JideTabbedPane tabs = new JideTabbedPane();
|
||||
tabs.setFont( this.getFont() );
|
||||
tabs.setForeground( Color.BLACK );
|
||||
|
||||
tabs.setTabTrailingComponent( mChannelName );
|
||||
|
||||
mNameConfigurationEditor.setSaveRequestListener( this );
|
||||
tabs.addTab( "Name/Alias", mNameConfigurationEditor );
|
||||
|
||||
mSourceConfigurationEditor = new SourceConfigurationEditor( mSourceManager );
|
||||
mSourceConfigurationEditor.setSaveRequestListener( this );
|
||||
tabs.addTab( "Source", mSourceConfigurationEditor );
|
||||
|
||||
mDecodeConfigurationEditor = new DecodeConfigurationEditor( mChannelMapModel );
|
||||
mDecodeConfigurationEditor.setSaveRequestListener( this );
|
||||
tabs.addTab( "Decoder", mDecodeConfigurationEditor );
|
||||
|
||||
mAuxDecodeConfigurationEditor = new AuxDecodeConfigurationEditor();
|
||||
mAuxDecodeConfigurationEditor.setSaveRequestListener( this );
|
||||
tabs.addTab( "Aux Decoders", mAuxDecodeConfigurationEditor );
|
||||
|
||||
mEventLogConfigurationEditor = new EventLogConfigurationEditor();
|
||||
mEventLogConfigurationEditor.setSaveRequestListener( this );
|
||||
tabs.addTab( "Logging", mEventLogConfigurationEditor );
|
||||
|
||||
mRecordConfigurationEditor = new RecordConfigurationEditor();
|
||||
mRecordConfigurationEditor.setSaveRequestListener( this );
|
||||
tabs.addTab( "Recording", mRecordConfigurationEditor );
|
||||
|
||||
add( tabs, "span" );
|
||||
|
||||
mEnableButton.addActionListener( this );
|
||||
mEnableButton.setEnabled( false );
|
||||
mEnableButton.setToolTipText( "Start the currently selected channel running/decoding" );
|
||||
add( mEnableButton );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.setToolTipText( "Save changes to the currently selected channel" );
|
||||
btnSave.addActionListener( ChannelEditor.this );
|
||||
add( btnSave );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.setToolTipText( "Reload the currently selected channel" );
|
||||
btnReset.addActionListener( ChannelEditor.this );
|
||||
add( btnReset );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged( ChannelEvent event )
|
||||
{
|
||||
if( hasItem() && getItem() == event.getChannel() )
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case NOTIFICATION_CONFIGURATION_CHANGE:
|
||||
case NOTIFICATION_PROCESSING_START:
|
||||
case NOTIFICATION_PROCESSING_STOP:
|
||||
setItem( getItem() );
|
||||
mChannelEnableRequested = false;
|
||||
break;
|
||||
case NOTIFICATION_DELETE:
|
||||
setItem( null );
|
||||
break;
|
||||
case NOTIFICATION_ENABLE_REJECTED:
|
||||
if( mChannelEnableRequested )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ChannelEditor.this, "Channel could not be "
|
||||
+ "enabled. This is likely because there are no tuner channels "
|
||||
+ "available", "Couldn't enable channel", JOptionPane.INFORMATION_MESSAGE );
|
||||
|
||||
mChannelEnableRequested = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Enable" ) )
|
||||
{
|
||||
if( hasItem() )
|
||||
{
|
||||
save();
|
||||
|
||||
mChannelEnableRequested = true;
|
||||
mChannelModel.broadcast( new ChannelEvent( getItem(), ChannelEvent.Event.REQUEST_ENABLE ) );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Disable" ) )
|
||||
{
|
||||
if( hasItem() )
|
||||
{
|
||||
mChannelModel.broadcast( new ChannelEvent( getItem(), ChannelEvent.Event.REQUEST_DISABLE ) );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Save" ) )
|
||||
{
|
||||
save();
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
{
|
||||
setItem( getItem() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel configuration in each of the channel editor components
|
||||
* Note: this method must be invoked on the swing event dispatch thread
|
||||
*/
|
||||
public void setItem( final Channel channel )
|
||||
{
|
||||
super.setItem( channel );
|
||||
|
||||
mNameConfigurationEditor.setItem( channel );
|
||||
mSourceConfigurationEditor.setItem( channel );
|
||||
mDecodeConfigurationEditor.setItem( channel );
|
||||
mAuxDecodeConfigurationEditor.setItem( channel );
|
||||
mEventLogConfigurationEditor.setItem( channel );
|
||||
mRecordConfigurationEditor.setItem( channel );
|
||||
|
||||
if( channel != null )
|
||||
{
|
||||
mChannelName.setText( "Channel: " + channel.getName() );
|
||||
mEnableButton.setText( channel.getEnabled() ? "Disable" : "Enable" );
|
||||
mEnableButton.setEnabled( true );
|
||||
mEnableButton.setBackground( channel.getEnabled() ? Color.GREEN : getBackground() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mChannelName.setText( "Channel: " );
|
||||
mEnableButton.setText( "Enable" );
|
||||
mEnableButton.setEnabled( false );
|
||||
mEnableButton.setBackground( getBackground() );
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() )
|
||||
{
|
||||
mNameConfigurationEditor.save();
|
||||
mSourceConfigurationEditor.save();
|
||||
mDecodeConfigurationEditor.save();
|
||||
mAuxDecodeConfigurationEditor.save();
|
||||
mEventLogConfigurationEditor.save();
|
||||
mRecordConfigurationEditor.save();
|
||||
|
||||
try
|
||||
{
|
||||
mDecodeConfigurationEditor.validate( mSourceConfigurationEditor );
|
||||
mDecodeConfigurationEditor.validate( mAuxDecodeConfigurationEditor );
|
||||
}
|
||||
catch( EditorValidationException e )
|
||||
{
|
||||
e.getEditor().requestFocus();
|
||||
|
||||
JOptionPane.showMessageDialog( e.getEditor(), e.getReason(),
|
||||
"Configuration Error", JOptionPane.ERROR_MESSAGE );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mChannelModel.broadcast( new ChannelEvent( getItem(),
|
||||
ChannelEvent.Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel;
|
||||
|
||||
public class ChannelEvent
|
||||
{
|
||||
private Channel mChannel;
|
||||
private Event mEvent;
|
||||
|
||||
/**
|
||||
* ChannelEvent - event describing any changes to channels
|
||||
* @param channel - channel that changed
|
||||
* @param event - change event
|
||||
*/
|
||||
public ChannelEvent( Channel channel, Event event )
|
||||
{
|
||||
mChannel = channel;
|
||||
mEvent = event;
|
||||
}
|
||||
|
||||
public Channel getChannel()
|
||||
{
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
public Event getEvent()
|
||||
{
|
||||
return mEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel events to describe the specific event
|
||||
*/
|
||||
public enum Event
|
||||
{
|
||||
//Channel is added
|
||||
NOTIFICATION_ADD,
|
||||
//Channel configuration has changed
|
||||
NOTIFICATION_CONFIGURATION_CHANGE,
|
||||
//Channel is deleted/removed
|
||||
NOTIFICATION_DELETE,
|
||||
//Channel enable request was rejected
|
||||
NOTIFICATION_ENABLE_REJECTED,
|
||||
//Channel has started processing/decoding
|
||||
NOTIFICATION_PROCESSING_START,
|
||||
//Channel has stopped processing/decoding
|
||||
NOTIFICATION_PROCESSING_STOP,
|
||||
//Channel's selection state has changed
|
||||
NOTIFICATION_SELECTION_CHANGE,
|
||||
//Channel's channel-state has been reset
|
||||
NOTIFICATION_STATE_RESET,
|
||||
//Request to delete the channel
|
||||
REQUEST_DELETE,
|
||||
//Request to deselect the channel
|
||||
REQUEST_DESELECT,
|
||||
//Request to disable a channel - response will be a PROCESSING_STOP_NOTIFICATION
|
||||
REQUEST_DISABLE,
|
||||
//Request to enable a channel - response will be a PROCESSING_START_NOTIFICATION
|
||||
REQUEST_ENABLE,
|
||||
//Request to select the channel
|
||||
REQUEST_SELECT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel;
|
||||
|
||||
/**
|
||||
* Interface for receiving channel events. Each listener will receive
|
||||
* notification of all channel events.
|
||||
*/
|
||||
public interface ChannelEventListener
|
||||
{
|
||||
/**
|
||||
* Notifies the listener that a channel event has occurred
|
||||
*/
|
||||
public void channelChanged( ChannelEvent event );
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 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.controller.channel;
|
||||
|
||||
import io.github.dsheirer.controller.channel.Channel.ChannelType;
|
||||
import io.github.dsheirer.controller.channel.ChannelEvent.Event;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* Channel Model
|
||||
*/
|
||||
public class ChannelModel extends AbstractTableModel implements IChannelEventBroadcaster
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int COLUMN_ENABLED = 0;
|
||||
public static final int COLUMN_SYSTEM = 1;
|
||||
public static final int COLUMN_SITE = 2;
|
||||
public static final int COLUMN_NAME = 3;
|
||||
public static final int COLUMN_ALIAS_LIST = 4;
|
||||
public static final int COLUMN_SOURCE = 5;
|
||||
public static final int COLUMN_DECODER = 6;
|
||||
|
||||
private static final String[] COLUMN_NAMES = new String[] {"Enabled", "System", "Site", "Name", "Alias List",
|
||||
"Source", "Decoder"};
|
||||
|
||||
private List<Channel> mChannels = new CopyOnWriteArrayList<>();
|
||||
private List<Channel> mTrafficChannels = new CopyOnWriteArrayList<>();
|
||||
private List<ChannelEventListener> mListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
public ChannelModel()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmodifiable list of non-traffic channels currently in the model
|
||||
*/
|
||||
public List<Channel> getChannels()
|
||||
{
|
||||
return Collections.unmodifiableList(mChannels);
|
||||
}
|
||||
|
||||
public Channel getChannelAtIndex(int row)
|
||||
{
|
||||
if(row < mChannels.size())
|
||||
{
|
||||
return mChannels.get(row);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the channel identified by the id argument
|
||||
*/
|
||||
public Channel getChannelFromChannelID(Integer id)
|
||||
{
|
||||
if(id != null)
|
||||
{
|
||||
for(Channel channel: mChannels)
|
||||
{
|
||||
if(channel.getChannelID() == id)
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of unique system values from across the channel set
|
||||
*/
|
||||
public List<String> getSystems()
|
||||
{
|
||||
List<String> systems = new ArrayList<>();
|
||||
|
||||
for(Channel channel : mChannels)
|
||||
{
|
||||
if(channel.hasSystem() && !systems.contains(channel.getSystem()))
|
||||
{
|
||||
systems.add(channel.getSystem());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(systems);
|
||||
|
||||
return systems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of unique site values for all channels that have a matching
|
||||
* system value
|
||||
*/
|
||||
public List<String> getSites(String system)
|
||||
{
|
||||
List<String> sites = new ArrayList<>();
|
||||
|
||||
if(system != null)
|
||||
{
|
||||
for(Channel channel : mChannels)
|
||||
{
|
||||
if(channel.hasSystem() &&
|
||||
system.equals(channel.getSystem()) &&
|
||||
channel.hasSite() &&
|
||||
!sites.contains(channel.getSite()))
|
||||
{
|
||||
sites.add(channel.getSite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(sites);
|
||||
|
||||
return sites;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts the channel event to all registered listeners
|
||||
*/
|
||||
@Override
|
||||
public void broadcast(ChannelEvent event)
|
||||
{
|
||||
for(ChannelEventListener listener : mListeners)
|
||||
{
|
||||
listener.channelChanged(event);
|
||||
}
|
||||
|
||||
if(event.getChannel().getChannelType() == ChannelType.STANDARD)
|
||||
{
|
||||
switch(event.getEvent())
|
||||
{
|
||||
case NOTIFICATION_CONFIGURATION_CHANGE:
|
||||
case NOTIFICATION_PROCESSING_START:
|
||||
case NOTIFICATION_PROCESSING_STOP:
|
||||
case NOTIFICATION_SELECTION_CHANGE:
|
||||
int index = mChannels.indexOf(event.getChannel());
|
||||
fireTableRowsUpdated(index, index);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(event.getEvent() == Event.REQUEST_DELETE)
|
||||
{
|
||||
removeChannel(event.getChannel());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk loading of channel list. Each channel is added and a channel add
|
||||
* event is broadcast.
|
||||
*/
|
||||
public void addChannels(List<Channel> channels)
|
||||
{
|
||||
for(Channel channel : channels)
|
||||
{
|
||||
addChannel(channel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the channel to the model and broadcasts a channel add event
|
||||
*/
|
||||
public int addChannel(Channel channel)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
switch(channel.getChannelType())
|
||||
{
|
||||
case STANDARD:
|
||||
mChannels.add(channel);
|
||||
|
||||
index = mChannels.size() - 1;
|
||||
|
||||
fireTableRowsInserted(index, index);
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mTrafficChannels.add(channel);
|
||||
index = mChannels.size() - 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
broadcast(new ChannelEvent(channel, Event.NOTIFICATION_ADD));
|
||||
|
||||
if(channel.getEnabled())
|
||||
{
|
||||
broadcast(new ChannelEvent(channel, Event.REQUEST_ENABLE));
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the channel from the model and broadcasts a channel remove event
|
||||
*/
|
||||
public void removeChannel(Channel channel)
|
||||
{
|
||||
if(channel != null)
|
||||
{
|
||||
switch(channel.getChannelType())
|
||||
{
|
||||
case STANDARD:
|
||||
int index = mChannels.indexOf(channel);
|
||||
|
||||
mChannels.remove(channel);
|
||||
|
||||
if(index >= 0)
|
||||
{
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mTrafficChannels.remove(channel);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
broadcast(new ChannelEvent(channel, Event.NOTIFICATION_DELETE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of channels that fall within the frequency range
|
||||
*
|
||||
* @param start frequency of the range
|
||||
* @param stop frequency of the range
|
||||
* @return list of channels or an empty list if none fall within the range
|
||||
*/
|
||||
public List<Channel> getChannelsInFrequencyRange(long start, long stop)
|
||||
{
|
||||
List<Channel> channels = new ArrayList<>();
|
||||
|
||||
for(Channel channel : mChannels)
|
||||
{
|
||||
if(channel.isWithin(start, stop))
|
||||
{
|
||||
channels.add(channel);
|
||||
}
|
||||
}
|
||||
|
||||
for(Channel channel : mTrafficChannels)
|
||||
{
|
||||
if(channel.isWithin(start, stop))
|
||||
{
|
||||
channels.add(channel);
|
||||
}
|
||||
}
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
public void addListener(ChannelEventListener listener)
|
||||
{
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(ChannelEventListener listener)
|
||||
{
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
//Table Model Interface Methods - standard channels only
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mChannels.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return COLUMN_NAMES.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex)
|
||||
{
|
||||
if(columnIndex < COLUMN_NAMES.length)
|
||||
{
|
||||
return COLUMN_NAMES[columnIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex)
|
||||
{
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
Channel channel = mChannels.get(rowIndex);
|
||||
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_ENABLED:
|
||||
return channel.getEnabled() ? "Enabled" : null;
|
||||
case COLUMN_SYSTEM:
|
||||
return channel.getSystem();
|
||||
case COLUMN_SITE:
|
||||
return channel.getSite();
|
||||
case COLUMN_NAME:
|
||||
return channel.getName();
|
||||
case COLUMN_ALIAS_LIST:
|
||||
return channel.getAliasListName();
|
||||
case COLUMN_SOURCE:
|
||||
return channel.getSourceConfiguration().getDescription();
|
||||
case COLUMN_DECODER:
|
||||
return channel.getDecodeConfiguration().getDecoderType().getShortDisplayString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
|
||||
{
|
||||
throw new IllegalArgumentException("Not yet implemented");
|
||||
}
|
||||
|
||||
public void createChannel(DecoderType decoderType, long frequency)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 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.controller.channel;
|
||||
|
||||
import io.github.dsheirer.audio.AudioPacket;
|
||||
import io.github.dsheirer.channel.metadata.Attribute;
|
||||
import io.github.dsheirer.channel.metadata.AttributeChangeRequest;
|
||||
import io.github.dsheirer.channel.metadata.ChannelMetadataModel;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
|
||||
import io.github.dsheirer.filter.FilterSet;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.record.RecorderManager;
|
||||
import io.github.dsheirer.record.RecorderType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.Source;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
import io.github.dsheirer.source.SourceType;
|
||||
import io.github.dsheirer.source.config.SourceConfigTuner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.DecoderFactory;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.event.MessageActivityModel;
|
||||
import io.github.dsheirer.module.log.EventLogManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ChannelProcessingManager implements ChannelEventListener
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelProcessingManager.class);
|
||||
|
||||
private Map<Integer,ProcessingChain> mProcessingChains = new HashMap<>();
|
||||
|
||||
private List<Listener<AudioPacket>> mAudioPacketListeners = new CopyOnWriteArrayList<>();
|
||||
private List<Listener<Message>> mMessageListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelMapModel mChannelMapModel;
|
||||
private ChannelMetadataModel mChannelMetadataModel = new ChannelMetadataModel();
|
||||
private AliasModel mAliasModel;
|
||||
private EventLogManager mEventLogManager;
|
||||
private RecorderManager mRecorderManager;
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
public ChannelProcessingManager(ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
AliasModel aliasModel,
|
||||
EventLogManager eventLogManager,
|
||||
RecorderManager recorderManager,
|
||||
SourceManager sourceManager)
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelMapModel = channelMapModel;
|
||||
mAliasModel = aliasModel;
|
||||
mEventLogManager = eventLogManager;
|
||||
mRecorderManager = recorderManager;
|
||||
mSourceManager = sourceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel metadata model containing metadata for each channel or channel time-slice that is currently processing.
|
||||
*/
|
||||
public ChannelMetadataModel getChannelMetadataModel()
|
||||
{
|
||||
return mChannelMetadataModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel model
|
||||
*/
|
||||
public ChannelModel getChannelModel()
|
||||
{
|
||||
return mChannelModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if a processing chain is constructed for the channel and that
|
||||
* the processing chain is currently processing.
|
||||
*/
|
||||
private boolean isProcessing(Channel channel)
|
||||
{
|
||||
return mProcessingChains.containsKey(channel.getChannelID()) &&
|
||||
mProcessingChains.get(channel.getChannelID()).isProcessing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current processing chain associated with the channel, or
|
||||
* null if a processing chain is not currently setup for the channel
|
||||
*/
|
||||
public ProcessingChain getProcessingChain(Channel channel)
|
||||
{
|
||||
return mProcessingChains.get(channel.getChannelID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the channel associated with the processing chain
|
||||
* @param processingChain
|
||||
* @return channel associated with the processing chain or null
|
||||
*/
|
||||
public Channel getChannel(ProcessingChain processingChain)
|
||||
{
|
||||
return mChannelModel.getChannelFromChannelID(getChannelID(processingChain));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the channel ID associated with the processing chain
|
||||
*/
|
||||
private Integer getChannelID(ProcessingChain processingChain)
|
||||
{
|
||||
if(processingChain != null)
|
||||
{
|
||||
for(Map.Entry<Integer,ProcessingChain> entry: mProcessingChains.entrySet())
|
||||
{
|
||||
if(entry.getValue() == processingChain)
|
||||
{
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void channelChanged(ChannelEvent event)
|
||||
{
|
||||
Channel channel = event.getChannel();
|
||||
|
||||
switch(event.getEvent())
|
||||
{
|
||||
case REQUEST_ENABLE:
|
||||
if(!mProcessingChains.containsKey(channel.getChannelID()) ||
|
||||
!mProcessingChains.get(channel.getChannelID()).isProcessing())
|
||||
{
|
||||
startProcessing(event);
|
||||
}
|
||||
break;
|
||||
case REQUEST_DISABLE:
|
||||
if(channel.getEnabled())
|
||||
{
|
||||
switch(channel.getChannelType())
|
||||
{
|
||||
case STANDARD:
|
||||
stopProcessing(channel, true);
|
||||
break;
|
||||
case TRAFFIC:
|
||||
//Don't remove traffic channel processing chains
|
||||
//until explicitly deleted, so that we can reuse them
|
||||
stopProcessing(channel, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case NOTIFICATION_DELETE:
|
||||
if(channel.getEnabled())
|
||||
{
|
||||
stopProcessing(channel, true);
|
||||
}
|
||||
break;
|
||||
case NOTIFICATION_CONFIGURATION_CHANGE:
|
||||
if(isProcessing(channel))
|
||||
{
|
||||
stopProcessing(channel, true);
|
||||
startProcessing(event);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void startProcessing(ChannelEvent event)
|
||||
{
|
||||
Channel channel = event.getChannel();
|
||||
|
||||
ProcessingChain processingChain = mProcessingChains.get(channel.getChannelID());
|
||||
|
||||
//If we're already processing, ignore the request
|
||||
if(processingChain != null && processingChain.isProcessing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Ensure that we can get a source before we construct a new processing chain
|
||||
Source source = null;
|
||||
|
||||
try
|
||||
{
|
||||
source = mSourceManager.getSource(channel.getSourceConfiguration(),
|
||||
channel.getDecodeConfiguration().getDecoderType().getChannelBandwidth());
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mLog.debug("Error obtaining source for channel [" + channel.getName() + "]", se);
|
||||
}
|
||||
|
||||
if(source == null)
|
||||
{
|
||||
channel.setEnabled(false);
|
||||
|
||||
mChannelModel.broadcast(new ChannelEvent(channel, ChannelEvent.Event.NOTIFICATION_ENABLE_REJECTED));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(processingChain == null)
|
||||
{
|
||||
processingChain = new ProcessingChain(channel.getChannelType());
|
||||
|
||||
/* Register global listeners */
|
||||
for(Listener<AudioPacket> listener : mAudioPacketListeners)
|
||||
{
|
||||
processingChain.addAudioPacketListener(listener);
|
||||
}
|
||||
|
||||
for(Listener<Message> listener : mMessageListeners)
|
||||
{
|
||||
processingChain.addMessageListener(listener);
|
||||
}
|
||||
|
||||
//Register channel to receive frequency correction events to show in the spectral display (hack!)
|
||||
processingChain.addFrequencyChangeListener(channel);
|
||||
|
||||
/* Processing Modules */
|
||||
List<Module> modules = DecoderFactory.getModules(mChannelModel, mChannelMapModel, this,
|
||||
mAliasModel, channel, processingChain.getChannelState().getMutableMetadata());
|
||||
processingChain.addModules(modules);
|
||||
|
||||
/* Setup message activity model with filtering */
|
||||
FilterSet<Message> messageFilter = DecoderFactory.getMessageFilters(modules);
|
||||
MessageActivityModel messageModel = new MessageActivityModel(messageFilter);
|
||||
processingChain.setMessageActivityModel(messageModel);
|
||||
|
||||
}
|
||||
|
||||
//Set the recordable flag to true if the user has requested recording. The metadata class can still
|
||||
//override recordability if any of the aliased values has 'Do Not Record' alias identifier.
|
||||
boolean recordable = channel.getRecordConfiguration() != null &&
|
||||
channel.getRecordConfiguration().getRecorders().contains(RecorderType.AUDIO);
|
||||
|
||||
processingChain.getChannelState().getMutableMetadata().setRecordable(recordable);
|
||||
|
||||
//Inject channel metadata that will be inserted into audio packets for recorder manager and streaming
|
||||
processingChain.getChannelState().getMutableMetadata().receive(
|
||||
new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_SYSTEM, channel.getSystem()));
|
||||
processingChain.getChannelState().getMutableMetadata().receive(
|
||||
new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_SITE, channel.getSite()));
|
||||
processingChain.getChannelState().getMutableMetadata().receive(
|
||||
new AttributeChangeRequest<String>(Attribute.CHANNEL_CONFIGURATION_NAME, channel.getName()));
|
||||
|
||||
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
|
||||
{
|
||||
long frequency = ((SourceConfigTuner)channel.getSourceConfiguration()).getFrequency();
|
||||
|
||||
processingChain.getChannelState().getMutableMetadata().receive(
|
||||
new AttributeChangeRequest<Long>(Attribute.CHANNEL_FREQUENCY, frequency));
|
||||
}
|
||||
|
||||
processingChain.getChannelState().getMutableMetadata().receive(
|
||||
new AttributeChangeRequest<DecoderType>(Attribute.PRIMARY_DECODER_TYPE,
|
||||
channel.getDecodeConfiguration().getDecoderType()));
|
||||
|
||||
/* Setup event logging */
|
||||
List<Module> loggers = mEventLogManager.getLoggers(channel.getEventLogConfiguration(), channel.getName());
|
||||
|
||||
if(!loggers.isEmpty())
|
||||
{
|
||||
processingChain.addModules(loggers);
|
||||
}
|
||||
|
||||
/* Setup recorders */
|
||||
List<RecorderType> recorders = channel.getRecordConfiguration().getRecorders();
|
||||
|
||||
if(!recorders.isEmpty())
|
||||
{
|
||||
/* Add baseband recorder */
|
||||
if((recorders.contains(RecorderType.BASEBAND) && channel.getChannelType() == Channel.ChannelType.STANDARD))
|
||||
{
|
||||
processingChain.addModule(mRecorderManager.getBasebandRecorder(channel.toString()));
|
||||
}
|
||||
|
||||
/* Add traffic channel baseband recorder */
|
||||
if(recorders.contains(RecorderType.TRAFFIC_BASEBAND) && channel.getChannelType() == Channel.ChannelType.TRAFFIC)
|
||||
{
|
||||
processingChain.addModule(mRecorderManager.getBasebandRecorder(channel.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
processingChain.setSource(source);
|
||||
|
||||
if(event instanceof TrafficChannelEvent)
|
||||
{
|
||||
TrafficChannelEvent trafficChannelEvent = (TrafficChannelEvent) event;
|
||||
|
||||
processingChain.getChannelState().configureAsTrafficChannel(
|
||||
trafficChannelEvent.getTrafficChannelManager(),
|
||||
trafficChannelEvent.getCallEvent());
|
||||
}
|
||||
|
||||
processingChain.start();
|
||||
|
||||
getChannelMetadataModel().add(processingChain.getChannelState().getMutableMetadata(), channel);
|
||||
|
||||
channel.setEnabled(true);
|
||||
|
||||
mProcessingChains.put(channel.getChannelID(), processingChain);
|
||||
|
||||
mChannelModel.broadcast(new ChannelEvent(channel, ChannelEvent.Event.NOTIFICATION_PROCESSING_START));
|
||||
}
|
||||
|
||||
private void stopProcessing(Channel channel, boolean remove)
|
||||
{
|
||||
channel.setEnabled(false);
|
||||
|
||||
if(mProcessingChains.containsKey(channel.getChannelID()))
|
||||
{
|
||||
ProcessingChain processingChain = mProcessingChains.get(channel.getChannelID());
|
||||
|
||||
getChannelMetadataModel().remove(processingChain.getChannelState().getMutableMetadata());
|
||||
|
||||
processingChain.stop();
|
||||
|
||||
processingChain.removeEventLoggingModules();
|
||||
|
||||
processingChain.removeRecordingModules();
|
||||
|
||||
//Deregister channel from receive frequency correction events to show in the spectral display (hack!)
|
||||
processingChain.removeFrequencyChangeListener(channel);
|
||||
channel.resetFrequencyCorrection();
|
||||
|
||||
mChannelModel.broadcast(new ChannelEvent(channel, ChannelEvent.Event.NOTIFICATION_PROCESSING_STOP));
|
||||
|
||||
if(remove)
|
||||
{
|
||||
mProcessingChains.remove(channel.getChannelID());
|
||||
|
||||
processingChain.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message listener that will be added to all channels to receive
|
||||
* any messages.
|
||||
*/
|
||||
public void addAudioPacketListener(Listener<AudioPacket> listener)
|
||||
{
|
||||
mAudioPacketListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a message listener.
|
||||
*/
|
||||
public void removeAudioPacketListener(Listener<AudioPacket> listener)
|
||||
{
|
||||
mAudioPacketListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message listener that will be added to all channels to receive
|
||||
* any messages.
|
||||
*/
|
||||
public void addMessageListener(Listener<Message> listener)
|
||||
{
|
||||
mMessageListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a message listener.
|
||||
*/
|
||||
public void removeMessageListener(Listener<Message> listener)
|
||||
{
|
||||
mMessageListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2015 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.controller.channel;
|
||||
|
||||
public class ChannelSelectionManager implements ChannelEventListener
|
||||
{
|
||||
private IChannelEventBroadcaster mChannelEventBroadcaster;
|
||||
private Channel mSelectedChannel = null;
|
||||
|
||||
/**
|
||||
* Manages channel selection state to ensure that only one channel is ever
|
||||
* in a selected state.
|
||||
*/
|
||||
public ChannelSelectionManager( IChannelEventBroadcaster broadcaster )
|
||||
{
|
||||
mChannelEventBroadcaster = broadcaster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged( ChannelEvent event )
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case REQUEST_SELECT:
|
||||
if( mSelectedChannel != null )
|
||||
{
|
||||
mSelectedChannel.setSelected( false );
|
||||
mChannelEventBroadcaster.broadcast( new ChannelEvent( mSelectedChannel,
|
||||
ChannelEvent.Event.NOTIFICATION_SELECTION_CHANGE ) );
|
||||
mSelectedChannel = null;
|
||||
}
|
||||
|
||||
mSelectedChannel = event.getChannel();
|
||||
mSelectedChannel.setSelected( true );
|
||||
mChannelEventBroadcaster.broadcast( new ChannelEvent( event.getChannel(),
|
||||
ChannelEvent.Event.NOTIFICATION_SELECTION_CHANGE ) );
|
||||
break;
|
||||
case NOTIFICATION_PROCESSING_STOP:
|
||||
case REQUEST_DESELECT:
|
||||
if( mSelectedChannel != null &&
|
||||
mSelectedChannel == event.getChannel() )
|
||||
{
|
||||
mSelectedChannel.setSelected( false );
|
||||
mSelectedChannel = null;
|
||||
mChannelEventBroadcaster.broadcast( new ChannelEvent( event.getChannel(),
|
||||
ChannelEvent.Event.NOTIFICATION_SELECTION_CHANGE ) );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.channel.state.DecoderState;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.event.ActivitySummaryFrame;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelUtils
|
||||
{
|
||||
/**
|
||||
* Creates a context menu for the channel argument
|
||||
*/
|
||||
public static JMenu getContextMenu( final ChannelModel channelModel,
|
||||
final ChannelProcessingManager channelProcessingManager,
|
||||
final Channel channel,
|
||||
final Component anchor )
|
||||
{
|
||||
if( channel != null )
|
||||
{
|
||||
JMenu menu = new JMenu( "Channel: " + channel.getName() );
|
||||
|
||||
if( channel.getEnabled() )
|
||||
{
|
||||
JMenuItem disable = new JMenuItem( "Disable" );
|
||||
disable.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
channelModel.broadcast(
|
||||
new ChannelEvent( channel, ChannelEvent.Event.REQUEST_DISABLE ) );
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( disable );
|
||||
|
||||
menu.add( new JSeparator() );
|
||||
|
||||
JMenuItem actySummaryItem =
|
||||
new JMenuItem( "Activity Summary" );
|
||||
|
||||
actySummaryItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
ProcessingChain chain = channelProcessingManager.getProcessingChain( channel );
|
||||
|
||||
if( chain != null )
|
||||
{
|
||||
for( DecoderState decoderState: chain.getDecoderStates() )
|
||||
{
|
||||
sb.append( decoderState.getActivitySummary() );
|
||||
}
|
||||
}
|
||||
|
||||
new ActivitySummaryFrame( sb.toString(), anchor );
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( actySummaryItem );
|
||||
}
|
||||
else
|
||||
{
|
||||
JMenuItem enable = new JMenuItem( "Enable" );
|
||||
enable.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
channelModel.broadcast(
|
||||
new ChannelEvent( channel, ChannelEvent.Event.REQUEST_ENABLE ) );
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( enable );
|
||||
}
|
||||
|
||||
menu.add( new JSeparator() );
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int response = JOptionPane.showConfirmDialog( anchor,
|
||||
"Do you want to delete channel " + channel.getName() + "?",
|
||||
"Are you sure?", JOptionPane.YES_NO_CANCEL_OPTION );
|
||||
|
||||
if( response == JOptionPane.YES_OPTION )
|
||||
{
|
||||
channelModel.broadcast(
|
||||
new ChannelEvent( channel, ChannelEvent.Event.REQUEST_DELETE ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( deleteItem );
|
||||
|
||||
return menu;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ConfigurationValidationException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Component mComponent;
|
||||
|
||||
public ConfigurationValidationException( Component component,
|
||||
String validationMessage )
|
||||
{
|
||||
super( validationMessage );
|
||||
|
||||
mComponent = component;
|
||||
}
|
||||
|
||||
public Component getComponent()
|
||||
{
|
||||
return mComponent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2016 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.controller.channel;
|
||||
|
||||
/**
|
||||
* Provides channel event broadcasting capability.
|
||||
*/
|
||||
public interface IChannelEventBroadcaster
|
||||
{
|
||||
/**
|
||||
* Broadcasts the channel event
|
||||
*/
|
||||
public void broadcast( ChannelEvent event );
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
public interface IChannelEventListener
|
||||
{
|
||||
public Listener<ChannelEvent> getChannelEventListener();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
public interface IChannelEventProvider
|
||||
{
|
||||
public void setChannelEventListener( Listener<ChannelEvent> listener );
|
||||
public void removeChannelEventListener();
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel;
|
||||
|
||||
import io.github.dsheirer.gui.editor.Editor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NameConfigurationEditor extends Editor<Channel> implements DocumentListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger(NameConfigurationEditor.class);
|
||||
|
||||
private static ComboBoxModel<String> EMPTY_SYSTEM_MODEL = new DefaultComboBoxModel<>();
|
||||
private static ComboBoxModel<String> EMPTY_SITE_MODEL = new DefaultComboBoxModel<>();
|
||||
private static ComboBoxModel<String> EMPTY_ALIAS_LIST_MODEL = new DefaultComboBoxModel<>();
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private ChannelModel mChannelModel;
|
||||
|
||||
private JTextField mChannelName;
|
||||
private JComboBox<String> mSystemNameCombo;
|
||||
private JComboBox<String> mSiteNameCombo;
|
||||
private JComboBox<String> mAliasListCombo;
|
||||
|
||||
public NameConfigurationEditor(AliasModel aliasModel, ChannelModel model)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mChannelModel = model;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("fill,wrap 4", "[right][grow,fill][right][grow,fill]", "[][][grow]"));
|
||||
|
||||
mChannelName = new JTextField("");
|
||||
mChannelName.getDocument().addDocumentListener(this);
|
||||
mChannelName.setEnabled(false);
|
||||
|
||||
add(new JLabel("Name:"));
|
||||
add(mChannelName);
|
||||
|
||||
mSystemNameCombo = new JComboBox<>(EMPTY_SYSTEM_MODEL);
|
||||
mSystemNameCombo.setEnabled(false);
|
||||
mSystemNameCombo.setEditable(true);
|
||||
mSystemNameCombo.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Object selected = mSystemNameCombo.getSelectedItem();
|
||||
|
||||
if(selected != null)
|
||||
{
|
||||
String system = (String)selected;
|
||||
|
||||
List<String> sites = mChannelModel.getSites(system);
|
||||
|
||||
if(!sites.contains(getItem().getSite()))
|
||||
{
|
||||
sites.add(getItem().getSite());
|
||||
}
|
||||
|
||||
if(sites.isEmpty())
|
||||
{
|
||||
mSiteNameCombo.setModel(EMPTY_SITE_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSiteNameCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
sites.toArray(new String[sites.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
mSiteNameCombo.setSelectedItem(getItem().getSite());
|
||||
}
|
||||
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
add(new JLabel("System:"));
|
||||
add(mSystemNameCombo);
|
||||
|
||||
mAliasListCombo = new JComboBox<String>(EMPTY_ALIAS_LIST_MODEL);
|
||||
mAliasListCombo.setEnabled(false);
|
||||
mAliasListCombo.setEditable(true);
|
||||
mAliasListCombo.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
add(new JLabel("Alias List:"));
|
||||
add(mAliasListCombo);
|
||||
|
||||
mSiteNameCombo = new JComboBox<>(EMPTY_SITE_MODEL);
|
||||
mSiteNameCombo.setEnabled(false);
|
||||
mSiteNameCombo.setEditable(true);
|
||||
mSiteNameCombo.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
add(new JLabel("Site:"));
|
||||
add(mSiteNameCombo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if(hasItem() && isModified())
|
||||
{
|
||||
getItem().setName(mChannelName.getText());
|
||||
|
||||
Object system = mSystemNameCombo.getSelectedItem();
|
||||
getItem().setSystem((system == null ? null : (String)system));
|
||||
|
||||
Object site = mSiteNameCombo.getSelectedItem();
|
||||
getItem().setSite((site == null ? null : (String)site));
|
||||
|
||||
Object aliasList = mAliasListCombo.getSelectedItem();
|
||||
getItem().setAliasListName(aliasList == null ? null : (String)aliasList);
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
private void setControlsEnabled(boolean enabled)
|
||||
{
|
||||
if(mChannelName.isEnabled() != enabled)
|
||||
{
|
||||
mChannelName.setEnabled(enabled);
|
||||
}
|
||||
|
||||
if(mAliasListCombo.isEnabled() != enabled)
|
||||
{
|
||||
mAliasListCombo.setEnabled(enabled);
|
||||
}
|
||||
|
||||
if(mSystemNameCombo.isEnabled() != enabled)
|
||||
{
|
||||
mSystemNameCombo.setEnabled(enabled);
|
||||
}
|
||||
|
||||
if(mSiteNameCombo.isEnabled() != enabled)
|
||||
{
|
||||
mSiteNameCombo.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(Channel channel)
|
||||
{
|
||||
super.setItem(channel);
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
setControlsEnabled(true);
|
||||
|
||||
mChannelName.setText(channel.getName());
|
||||
|
||||
List<String> systems = mChannelModel.getSystems();
|
||||
|
||||
if(systems.isEmpty())
|
||||
{
|
||||
mSystemNameCombo.setModel(EMPTY_SYSTEM_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSystemNameCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
systems.toArray(new String[systems.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
mSystemNameCombo.setSelectedItem(channel.getSystem());
|
||||
|
||||
List<String> sites = mChannelModel.getSites(channel.getSystem());
|
||||
|
||||
if(sites.isEmpty())
|
||||
{
|
||||
mSiteNameCombo.setModel(EMPTY_SITE_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSiteNameCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
sites.toArray(new String[sites.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
if(channel.getSite() != null)
|
||||
{
|
||||
mSiteNameCombo.setSelectedItem(channel.getSite());
|
||||
}
|
||||
|
||||
List<String> lists = mAliasModel.getListNames();
|
||||
Collections.sort(lists);
|
||||
mAliasListCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
lists.toArray(new String[lists.size()])));
|
||||
|
||||
if(channel.getAliasListName() != null)
|
||||
{
|
||||
mAliasListCombo.setSelectedItem(channel.getAliasListName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setControlsEnabled(false);
|
||||
mChannelName.setText(null);
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.channel.traffic.TrafficChannelManager;
|
||||
import io.github.dsheirer.module.decode.event.CallEvent;
|
||||
|
||||
public class TrafficChannelEvent extends ChannelEvent
|
||||
{
|
||||
private TrafficChannelManager mTrafficChannelManager;
|
||||
private CallEvent mCallEvent;
|
||||
|
||||
/**
|
||||
* Call event with traffic channel manager for call back, and original creation event.
|
||||
*/
|
||||
public TrafficChannelEvent( TrafficChannelManager trafficChannelManager,
|
||||
Channel channel,
|
||||
Event event,
|
||||
CallEvent callEvent )
|
||||
{
|
||||
super( channel, event );
|
||||
|
||||
mTrafficChannelManager = trafficChannelManager;
|
||||
mCallEvent = callEvent;
|
||||
}
|
||||
|
||||
public TrafficChannelManager getTrafficChannelManager()
|
||||
{
|
||||
return mTrafficChannelManager;
|
||||
}
|
||||
|
||||
public CallEvent getCallEvent()
|
||||
{
|
||||
return mCallEvent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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.controller.channel.map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlSeeAlso( { ChannelRange.class } )
|
||||
public class ChannelMap
|
||||
{
|
||||
private String mName;
|
||||
private boolean mInvalid = false;
|
||||
|
||||
private List<ChannelRange> mRanges = new ArrayList<ChannelRange>();
|
||||
|
||||
public ChannelMap()
|
||||
{
|
||||
this( "New Channel Map" );
|
||||
}
|
||||
|
||||
public ChannelMap( String name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public ChannelMap copyOf()
|
||||
{
|
||||
ChannelMap map = new ChannelMap( new String( mName ) );
|
||||
|
||||
for( ChannelRange range: mRanges )
|
||||
{
|
||||
map.addRange( range.copyOf() );
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public boolean isInvalid()
|
||||
{
|
||||
return mInvalid;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mName + ( mInvalid ? " - Error" : "" );
|
||||
}
|
||||
|
||||
@XmlElement( name = "range" )
|
||||
public List<ChannelRange> getRanges()
|
||||
{
|
||||
return mRanges;
|
||||
}
|
||||
|
||||
public void setRanges( List<ChannelRange> ranges )
|
||||
{
|
||||
mRanges = ranges;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public long getFrequency( int channelNumber )
|
||||
{
|
||||
for( ChannelRange range: mRanges )
|
||||
{
|
||||
if( range.hasChannel( channelNumber ) )
|
||||
{
|
||||
return range.getFrequency( channelNumber );
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates each of the channel ranges for overlap
|
||||
*/
|
||||
private void validate()
|
||||
{
|
||||
mInvalid = false;
|
||||
|
||||
for( int x = 0; x < mRanges.size(); x++ )
|
||||
{
|
||||
if( !mRanges.get( x ).isValid() )
|
||||
{
|
||||
mInvalid = true;
|
||||
}
|
||||
|
||||
for( int y = x + 1; y < mRanges.size(); y++ )
|
||||
{
|
||||
if( mRanges.get( x ).overlaps( mRanges.get( y ) ) )
|
||||
{
|
||||
mInvalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addRange( ChannelRange range )
|
||||
{
|
||||
mRanges.add( range );
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
public void removeRange( ChannelRange range )
|
||||
{
|
||||
mRanges.remove( range );
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel.map;
|
||||
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapEvent.Event;
|
||||
import io.github.dsheirer.controller.channel.map.ChannelRangeModel.ChannelRangeEventListener;
|
||||
import io.github.dsheirer.gui.editor.DocumentListenerEditor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.text.InternationalFormatter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelMapEditor extends DocumentListenerEditor<ChannelMap>
|
||||
implements ListSelectionListener, ChannelRangeEventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mNameLabel;
|
||||
private JTextField mNameText;
|
||||
private ChannelRangeModel mRangeModel;
|
||||
private JTable mRangeTable;
|
||||
private JButton mNewButton;
|
||||
private JButton mDeleteButton;
|
||||
private JButton mSaveButton;
|
||||
private JLabel mRangeDescription;
|
||||
private ChannelMapModel mChannelMapModel;
|
||||
|
||||
public ChannelMapEditor( ChannelMapModel channelMapModel )
|
||||
{
|
||||
mChannelMapModel = channelMapModel;
|
||||
init();
|
||||
}
|
||||
|
||||
public ChannelMap getChannelMap()
|
||||
{
|
||||
if( hasItem() )
|
||||
{
|
||||
return (ChannelMap)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( ChannelMap item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
ChannelMap map = getChannelMap();
|
||||
|
||||
mNameText.setText( map.getName() );
|
||||
|
||||
mRangeModel.clear();
|
||||
mRangeModel.addRanges( map.getRanges() );
|
||||
|
||||
mNewButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mNameText.setText( "" );
|
||||
|
||||
mRangeModel.clear();
|
||||
|
||||
mNewButton.setEnabled( false );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModified( boolean modified )
|
||||
{
|
||||
super.setModified( modified );
|
||||
|
||||
mSaveButton.setEnabled( modified );
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 3",
|
||||
"[grow,fill][grow,fill][grow,fill]", "[][grow][][]" ) );
|
||||
|
||||
mNameLabel = new JLabel( "Channel Map:" );
|
||||
add( mNameLabel );
|
||||
|
||||
mNameText = new JTextField();
|
||||
mNameText.getDocument().addDocumentListener( this );
|
||||
add( mNameText, "span" );
|
||||
|
||||
mRangeModel = new ChannelRangeModel();
|
||||
mRangeModel.setListener( this );
|
||||
|
||||
mRangeTable = new JTable( mRangeModel );
|
||||
mRangeTable.setPreferredScrollableViewportSize( new Dimension( 300, 150 ) );
|
||||
mRangeTable.setFillsViewportHeight( true );
|
||||
mRangeTable.setAutoCreateRowSorter( true );
|
||||
for( int x = 0; x < mRangeTable.getColumnCount(); x++ )
|
||||
{
|
||||
mRangeTable.getColumnModel().getColumn( x )
|
||||
.setCellEditor( new RangeTableEditor() );
|
||||
}
|
||||
|
||||
mRangeTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int index = event.getFirstIndex();
|
||||
|
||||
mDeleteButton.setEnabled( index >= 0 );
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
int modelIndex = mRangeTable.convertRowIndexToModel( index );
|
||||
|
||||
if( modelIndex >= 0 )
|
||||
{
|
||||
ChannelRange selected = mRangeModel.getChannelRange( modelIndex );
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
mRangeDescription.setText( selected.getDescription() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mRangeDescription.setText( "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane( mRangeTable );
|
||||
add( scrollPane, "span,grow,push");
|
||||
|
||||
mRangeDescription = new JLabel( " " );
|
||||
add( mRangeDescription, "span" );
|
||||
|
||||
mSaveButton = new JButton( "Save" );
|
||||
mSaveButton.setEnabled( false );
|
||||
mSaveButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
save();
|
||||
}
|
||||
} );
|
||||
add( mSaveButton );
|
||||
|
||||
mNewButton = new JButton( "New Range" );
|
||||
mNewButton.setEnabled( false );
|
||||
mNewButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
mRangeModel.addRange( new ChannelRange() );
|
||||
}
|
||||
} );
|
||||
add( mNewButton );
|
||||
|
||||
mDeleteButton = new JButton( "DeleteRange" );
|
||||
mDeleteButton.setEnabled( false );
|
||||
mDeleteButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int selectedRow = mRangeTable.getSelectedRow();
|
||||
|
||||
if( selectedRow >= 0 )
|
||||
{
|
||||
int modelRow = mRangeTable.convertRowIndexToModel( selectedRow );
|
||||
|
||||
ChannelRange selectedRange = mRangeModel.getChannelRange( modelRow );
|
||||
|
||||
if( selectedRange != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( mRangeTable,
|
||||
"Do you want to delete this channel range?",
|
||||
"Delete Channel Range?", JOptionPane.YES_NO_OPTION );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mRangeModel.removeRange( selectedRange );
|
||||
mDeleteButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mDeleteButton, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( isModified() && hasItem() )
|
||||
{
|
||||
ChannelMap channelMap = getChannelMap();
|
||||
|
||||
channelMap.setName( mNameText.getText() );
|
||||
channelMap.setRanges( mRangeModel.getChannelRanges() );
|
||||
|
||||
mChannelMapModel.broadcast( new ChannelMapEvent( getChannelMap(), Event.CHANGE ) );
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent e )
|
||||
{
|
||||
if( !e.getValueIsAdjusting() )
|
||||
{
|
||||
if( e.getSource() instanceof JList )
|
||||
{
|
||||
JList<?> list = (JList<?>)e.getSource();
|
||||
|
||||
if( list.getSelectedValue() instanceof ChannelMap )
|
||||
{
|
||||
setItem( (ChannelMap)list.getSelectedValue() );
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRangesChanged()
|
||||
{
|
||||
setModified( true );
|
||||
|
||||
//Update description
|
||||
int index = mRangeTable.getSelectedRow();
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
ChannelRange selected = mRangeModel.getChannelRange(
|
||||
mRangeTable.convertRowIndexToModel( index ) );
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
mRangeDescription.setText( selected.getDescription() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mRangeDescription.setText( "" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RangeTableEditor extends AbstractCellEditor
|
||||
implements TableCellEditor, ActionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
JFormattedTextField mEditor;
|
||||
|
||||
public RangeTableEditor()
|
||||
{
|
||||
InternationalFormatter nf = new InternationalFormatter();
|
||||
nf.setMinimum( 1 );
|
||||
nf.setAllowsInvalid( true );
|
||||
|
||||
mEditor = new JFormattedTextField( nf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue()
|
||||
{
|
||||
return mEditor.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent( JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
int row,
|
||||
int column )
|
||||
{
|
||||
mEditor.setValue( value );
|
||||
|
||||
return mEditor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel.map;
|
||||
|
||||
public class ChannelMapEvent
|
||||
{
|
||||
private ChannelMap mChannelMap;
|
||||
private Event mEvent;
|
||||
private String mPreviousChannelMapName;
|
||||
|
||||
/**
|
||||
* ChannelMapEvent - event describing any changes to a channel map
|
||||
*
|
||||
* @param channelMap that changed
|
||||
* @param event describing the change
|
||||
*/
|
||||
public ChannelMapEvent( ChannelMap channelMap, Event event )
|
||||
{
|
||||
mChannelMap = channelMap;
|
||||
mEvent = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMapEvent - channel map renaming event.
|
||||
*
|
||||
* @param channelMap that changed
|
||||
* @param previousName of the channel map
|
||||
*/
|
||||
public ChannelMapEvent( ChannelMap channelMap, String previousName )
|
||||
{
|
||||
this( channelMap, Event.RENAME );
|
||||
|
||||
mPreviousChannelMapName = previousName;
|
||||
}
|
||||
|
||||
public ChannelMap getChannelMap()
|
||||
{
|
||||
return mChannelMap;
|
||||
}
|
||||
|
||||
public String getPreviousChannelMapName()
|
||||
{
|
||||
return mPreviousChannelMapName;
|
||||
}
|
||||
|
||||
public Event getEvent()
|
||||
{
|
||||
return mEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Events
|
||||
*/
|
||||
public enum Event
|
||||
{
|
||||
ADD,
|
||||
CHANGE,
|
||||
RENAME,
|
||||
DELETE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package io.github.dsheirer.controller.channel.map;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelMapManager extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChannelMapModel mChannelMapModel;
|
||||
private JList<ChannelMap> mChannelMapList;
|
||||
private ChannelMapEditor mChannelMapEditor;
|
||||
private JButton mDeleteMapButton;
|
||||
private JButton mCloneMapButton;
|
||||
|
||||
public ChannelMapManager( ChannelMapModel channelMapModel )
|
||||
{
|
||||
mChannelMapModel = channelMapModel;
|
||||
mChannelMapList = new JList<>( mChannelMapModel );
|
||||
mChannelMapEditor = new ChannelMapEditor( mChannelMapModel );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 1 1 1 1", "[fill,grow]", "[fill,grow]" ) );
|
||||
|
||||
JPanel listPanel = new JPanel();
|
||||
listPanel.setLayout( new MigLayout( "",
|
||||
"[fill,grow][fill,grow][fill,grow]", "[fill,grow][]" ) );
|
||||
|
||||
mChannelMapList.addListSelectionListener( mChannelMapEditor );
|
||||
mChannelMapList.addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent e )
|
||||
{
|
||||
if( mChannelMapList.getSelectedValue() != null )
|
||||
{
|
||||
mCloneMapButton.setEnabled( true );
|
||||
mDeleteMapButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCloneMapButton.setEnabled( false );
|
||||
mDeleteMapButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
} );
|
||||
mChannelMapList.setLayoutOrientation( JList.VERTICAL );
|
||||
mChannelMapList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
|
||||
JScrollPane listScroller = new JScrollPane( mChannelMapList );
|
||||
|
||||
listPanel.add( listScroller, "span" );
|
||||
|
||||
JButton newMapButton = new JButton( "New" );
|
||||
newMapButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ChannelMap channelMap = new ChannelMap( "New Channel Map" );
|
||||
mChannelMapModel.addChannelMap( channelMap );
|
||||
mChannelMapList.setSelectedValue( channelMap, true );
|
||||
}
|
||||
} );
|
||||
|
||||
listPanel.add( newMapButton );
|
||||
|
||||
mCloneMapButton = new JButton( "Clone" );
|
||||
mCloneMapButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ChannelMap selected = mChannelMapList.getSelectedValue();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
ChannelMap copy = selected.copyOf();
|
||||
mChannelMapModel.addChannelMap( copy );
|
||||
mChannelMapList.setSelectedValue( copy, true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
listPanel.add( mCloneMapButton );
|
||||
|
||||
mDeleteMapButton = new JButton( "Delete" );
|
||||
mDeleteMapButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ChannelMap channelMap = mChannelMapList.getSelectedValue();
|
||||
|
||||
if( channelMap != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( mChannelMapList,
|
||||
"Do you want to delete this channel map?",
|
||||
"Delete Channel Map?", JOptionPane.YES_NO_OPTION );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mChannelMapModel.removeChannelMap( channelMap );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
listPanel.add( mDeleteMapButton );
|
||||
|
||||
JScrollPane editorScroller = new JScrollPane( mChannelMapEditor );
|
||||
|
||||
JideSplitPane splitPane = new JideSplitPane();
|
||||
splitPane.setOrientation( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
splitPane.add( listPanel );
|
||||
splitPane.add( editorScroller );
|
||||
|
||||
add( splitPane );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel.map;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class ChannelMapManagerFrame extends JFrame
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ChannelMapManagerFrame( ChannelMapModel channelMapModel )
|
||||
{
|
||||
init( new ChannelMapManager( channelMapModel ) );
|
||||
}
|
||||
|
||||
private void init( ChannelMapManager channelMapManager )
|
||||
{
|
||||
setTitle( "Channel Map Manager" );
|
||||
setSize( 800, 400 );
|
||||
setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
|
||||
add( channelMapManager );
|
||||
setLocationRelativeTo( null );
|
||||
}
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
ChannelMapModel channelMapModel = new ChannelMapModel();
|
||||
|
||||
final ChannelMapManagerFrame frame =
|
||||
new ChannelMapManagerFrame( channelMapModel );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
frame.setVisible( true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package io.github.dsheirer.controller.channel.map;
|
||||
|
||||
import io.github.dsheirer.controller.channel.map.ChannelMapEvent.Event;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ChannelMapModel extends AbstractListModel<ChannelMap>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelMapModel.class);
|
||||
|
||||
private List<ChannelMap> mChannelMaps = new ArrayList<>();
|
||||
private Broadcaster<ChannelMapEvent> mEventBroadcaster = new Broadcaster<>();
|
||||
|
||||
public ChannelMapModel()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable list of channel maps currently in the model
|
||||
*/
|
||||
public List<ChannelMap> getChannelMaps()
|
||||
{
|
||||
return Collections.unmodifiableList(mChannelMaps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the channel map with a matching name or null
|
||||
*/
|
||||
public ChannelMap getChannelMap(String name)
|
||||
{
|
||||
for(ChannelMap channelMap : mChannelMaps)
|
||||
{
|
||||
if(channelMap.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return channelMap;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener to receive notifications when channel map updates occur
|
||||
*/
|
||||
public void addListener(Listener<ChannelMapEvent> listener)
|
||||
{
|
||||
mEventBroadcaster.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the channel map update notification listener
|
||||
*/
|
||||
public void removeListener(Listener<ChannelMapEvent> listener)
|
||||
{
|
||||
mEventBroadcaster.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a channel map change.
|
||||
*
|
||||
* Note: use the add/remove methods to add or remove channel maps from this
|
||||
* model. When using those methods, an add or delete event will automatically
|
||||
* be generated.
|
||||
*/
|
||||
public void broadcast(ChannelMapEvent event)
|
||||
{
|
||||
if(event.getEvent() == ChannelMapEvent.Event.CHANGE ||
|
||||
event.getEvent() == ChannelMapEvent.Event.RENAME)
|
||||
{
|
||||
int index = mChannelMaps.indexOf(event.getChannelMap());
|
||||
|
||||
if(index >= 0)
|
||||
{
|
||||
fireContentsChanged(this, index, index);
|
||||
}
|
||||
}
|
||||
|
||||
mEventBroadcaster.broadcast(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a list of channel maps to this model
|
||||
*/
|
||||
public void addChannelMaps(List<ChannelMap> channelMaps)
|
||||
{
|
||||
for(ChannelMap channelMap : channelMaps)
|
||||
{
|
||||
addChannelMap(channelMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the channel map to this model
|
||||
*/
|
||||
public void addChannelMap(ChannelMap channelMap)
|
||||
{
|
||||
if(!mChannelMaps.contains(channelMap))
|
||||
{
|
||||
mChannelMaps.add(channelMap);
|
||||
|
||||
int index = mChannelMaps.indexOf(channelMap);
|
||||
|
||||
fireIntervalAdded(this, index, index);
|
||||
|
||||
broadcast(new ChannelMapEvent(channelMap, Event.ADD));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the channel map from this model
|
||||
*/
|
||||
public void removeChannelMap(ChannelMap channelMap)
|
||||
{
|
||||
if(mChannelMaps.contains(channelMap))
|
||||
{
|
||||
int index = mChannelMaps.indexOf(channelMap);
|
||||
|
||||
mChannelMaps.remove(channelMap);
|
||||
|
||||
fireIntervalRemoved(this, index, index);
|
||||
|
||||
broadcast(new ChannelMapEvent(channelMap, Event.DELETE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Size/Number of channel maps in this model
|
||||
*/
|
||||
@Override
|
||||
public int getSize()
|
||||
{
|
||||
return mChannelMaps.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the channel map at the specified index
|
||||
*/
|
||||
@Override
|
||||
public ChannelMap getElementAt(int index)
|
||||
{
|
||||
if(index <= mChannelMaps.size())
|
||||
{
|
||||
return mChannelMaps.get(index);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel.map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@XmlRootElement
|
||||
@XmlType( name = "range" )
|
||||
public class ChannelRange
|
||||
{
|
||||
private static final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" );
|
||||
|
||||
private int mFirst = 1;
|
||||
private int mLast = 1023;
|
||||
private int mBase = 450000000;
|
||||
private int mSize = 12500;
|
||||
|
||||
private boolean mOverlapping = false;
|
||||
|
||||
public ChannelRange()
|
||||
{
|
||||
}
|
||||
|
||||
public ChannelRange( int first, int last, int base, int size )
|
||||
{
|
||||
mFirst = first;
|
||||
mLast = last;
|
||||
mBase = base;
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public ChannelRange copyOf()
|
||||
{
|
||||
return new ChannelRange( mFirst, mLast, mBase, mSize );
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if( isValid() )
|
||||
{
|
||||
sb.append( "First: " );
|
||||
sb.append( mFirst + "=" );
|
||||
|
||||
long frequency = getFrequency( mFirst );
|
||||
|
||||
sb.append( FREQUENCY_FORMATTER.format( (double)frequency / 1E6D ) );
|
||||
sb.append( " Last: " );
|
||||
sb.append( mLast + "=" );
|
||||
|
||||
frequency = getFrequency( mLast );
|
||||
sb.append( FREQUENCY_FORMATTER.format( (double)frequency / 1E6D ) );
|
||||
sb.append( " MHz" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "First channel must be smaller than last channel" );
|
||||
}
|
||||
|
||||
if( isOverlapping() )
|
||||
{
|
||||
if( sb.length() > 0 )
|
||||
{
|
||||
sb.append( ", " );
|
||||
}
|
||||
|
||||
sb.append( "Overlap!" );
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return mFirst < mLast;
|
||||
}
|
||||
|
||||
public boolean overlaps( ChannelRange other )
|
||||
{
|
||||
return ( mFirst <= other.mFirst && other.mFirst <= mLast ) ||
|
||||
( mFirst <= other.mLast && other.mLast <= mLast ) ||
|
||||
( mFirst <= other.mFirst && other.mLast <= mLast ) ||
|
||||
( other.mFirst <= mFirst && mLast <= other.mLast );
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public boolean isOverlapping()
|
||||
{
|
||||
return mOverlapping;
|
||||
}
|
||||
|
||||
public void setOverlapping( boolean overlapping )
|
||||
{
|
||||
mOverlapping = overlapping;
|
||||
}
|
||||
|
||||
public boolean hasChannel( int channel )
|
||||
{
|
||||
return mFirst <= channel && channel <= mLast;
|
||||
}
|
||||
|
||||
public long getFrequency( int channel )
|
||||
{
|
||||
if( hasChannel( channel ) )
|
||||
{
|
||||
return mBase + ( ( channel - mFirst ) * mSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "first" )
|
||||
public int getFirstChannelNumber()
|
||||
{
|
||||
return mFirst;
|
||||
}
|
||||
|
||||
public void setFirstChannelNumber( int first )
|
||||
{
|
||||
mFirst = first;
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "last" )
|
||||
public void setLastChannelNumber( int last )
|
||||
{
|
||||
mLast = last;
|
||||
}
|
||||
|
||||
public int getLastChannelNumber()
|
||||
{
|
||||
return mLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base frequency
|
||||
* @param base frequency in hertz
|
||||
*/
|
||||
@XmlAttribute( name = "base" )
|
||||
public void setBase( int base )
|
||||
{
|
||||
mBase = base;
|
||||
}
|
||||
|
||||
public int getBase()
|
||||
{
|
||||
return mBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel size
|
||||
* @param size in hertz
|
||||
*/
|
||||
@XmlAttribute( name = "size" )
|
||||
public void setSize( int size )
|
||||
{
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.controller.channel.map;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ChannelRangeModel extends AbstractTableModel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final int START = 0;
|
||||
private static final int STOP = 1;
|
||||
private static final int BASE = 2;
|
||||
private static final int SIZE = 3;
|
||||
private static final int ERROR = 4;
|
||||
|
||||
protected int[] mColumnWidths = { 110, 110, 110, -1, 80 };
|
||||
|
||||
protected String[] mHeaders = new String[] { "Begin",
|
||||
"End",
|
||||
"Base",
|
||||
"Size",
|
||||
"Error" };
|
||||
|
||||
private List<ChannelRange> mRanges = new CopyOnWriteArrayList<>();
|
||||
private ChannelRangeEventListener mListener;
|
||||
|
||||
public ChannelRangeModel()
|
||||
{
|
||||
}
|
||||
|
||||
public void setListener( ChannelRangeEventListener listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
private void broadcastChange()
|
||||
{
|
||||
if( mListener != null )
|
||||
{
|
||||
mListener.channelRangesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for( ChannelRange range: mRanges )
|
||||
{
|
||||
removeRange( range );
|
||||
}
|
||||
|
||||
broadcastChange();
|
||||
}
|
||||
|
||||
public List<ChannelRange> getChannelRanges()
|
||||
{
|
||||
return mRanges;
|
||||
}
|
||||
|
||||
public void addRanges( List<ChannelRange> ranges )
|
||||
{
|
||||
for( ChannelRange range: ranges )
|
||||
{
|
||||
addRange( range );
|
||||
}
|
||||
|
||||
broadcastChange();
|
||||
}
|
||||
|
||||
public void addRange( ChannelRange range )
|
||||
{
|
||||
if( range != null && !mRanges.contains( range ) )
|
||||
{
|
||||
mRanges.add( range );
|
||||
|
||||
int index = mRanges.indexOf( range );
|
||||
|
||||
fireTableRowsInserted( index, index );
|
||||
}
|
||||
|
||||
validate();
|
||||
|
||||
broadcastChange();
|
||||
}
|
||||
|
||||
public void removeRange( ChannelRange range )
|
||||
{
|
||||
if( range != null && mRanges.contains( range ) )
|
||||
{
|
||||
int index = mRanges.indexOf( range );
|
||||
|
||||
mRanges.remove( range );
|
||||
|
||||
fireTableRowsDeleted( index, index );
|
||||
}
|
||||
|
||||
validate();
|
||||
|
||||
broadcastChange();
|
||||
}
|
||||
|
||||
public int[] getColumnWidths()
|
||||
{
|
||||
return mColumnWidths;
|
||||
}
|
||||
|
||||
public void setColumnWidths( int[] widths )
|
||||
{
|
||||
if( widths.length != mHeaders.length )
|
||||
{
|
||||
throw new IllegalArgumentException( "ChannelMapRangeModel - "
|
||||
+ "column widths array should have " +
|
||||
mHeaders.length + " elements" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mColumnWidths = widths;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mRanges.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return mHeaders.length;
|
||||
}
|
||||
|
||||
public String getColumnName( int column )
|
||||
{
|
||||
return mHeaders[ column ];
|
||||
}
|
||||
|
||||
public ChannelRange getChannelRange( int index )
|
||||
{
|
||||
if( index < mRanges.size() )
|
||||
{
|
||||
return mRanges.get( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt( int rowIndex, int columnIndex )
|
||||
{
|
||||
ChannelRange range = getChannelRange( rowIndex );
|
||||
|
||||
if( range != null )
|
||||
{
|
||||
switch( columnIndex )
|
||||
{
|
||||
case START:
|
||||
return range.getFirstChannelNumber();
|
||||
case STOP:
|
||||
return range.getLastChannelNumber();
|
||||
case BASE:
|
||||
return range.getBase();
|
||||
case SIZE:
|
||||
return range.getSize();
|
||||
case ERROR:
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if( !range.isValid() )
|
||||
{
|
||||
sb.append( "Sequence" );
|
||||
}
|
||||
|
||||
if( range.isOverlapping() )
|
||||
{
|
||||
if( sb.length() > 0 )
|
||||
{
|
||||
sb.append( "," );
|
||||
}
|
||||
|
||||
sb.append( "Overlap" );
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates each of the channel ranges for overlap
|
||||
*/
|
||||
private void validate()
|
||||
{
|
||||
for( int x = 0; x < mRanges.size(); x++ )
|
||||
{
|
||||
mRanges.get( x ).setOverlapping( false );
|
||||
fireTableCellUpdated( x, ERROR );
|
||||
}
|
||||
|
||||
for( int x = 0; x < mRanges.size(); x++ )
|
||||
{
|
||||
for( int y = x + 1; y < mRanges.size(); y++ )
|
||||
{
|
||||
if( mRanges.get( x ).overlaps( mRanges.get( y ) ) )
|
||||
{
|
||||
mRanges.get( x ).setOverlapping( true );
|
||||
fireTableCellUpdated( x, ERROR );
|
||||
|
||||
mRanges.get( y ).setOverlapping( true );
|
||||
fireTableCellUpdated( y, ERROR );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCellEditable( int row, int column )
|
||||
{
|
||||
return row < mRanges.size() && column != ERROR;
|
||||
}
|
||||
|
||||
public void setValueAt( Object value, int row, int column )
|
||||
{
|
||||
int parsedValue = -1;
|
||||
|
||||
try
|
||||
{
|
||||
parsedValue = Integer.parseInt( (String)value );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing ... we'll use 0
|
||||
}
|
||||
|
||||
if( parsedValue >= 0 )
|
||||
{
|
||||
ChannelRange range = getChannelRange( row );
|
||||
|
||||
if( range != null )
|
||||
{
|
||||
switch( column )
|
||||
{
|
||||
case START:
|
||||
range.setFirstChannelNumber( parsedValue );
|
||||
break;
|
||||
case STOP:
|
||||
range.setLastChannelNumber( parsedValue );
|
||||
break;
|
||||
case BASE:
|
||||
range.setBase( parsedValue );
|
||||
break;
|
||||
case SIZE:
|
||||
range.setSize( parsedValue );
|
||||
break;
|
||||
}
|
||||
|
||||
validate();
|
||||
|
||||
broadcastChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException( "Invalid channel range row index" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ChannelRangeEventListener
|
||||
{
|
||||
public void channelRangesChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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.controller.config;
|
||||
|
||||
import io.github.dsheirer.record.config.RecordConfiguration;
|
||||
import io.github.dsheirer.source.config.SourceConfiguration;
|
||||
import io.github.dsheirer.module.decode.config.AuxDecodeConfiguration;
|
||||
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
|
||||
import io.github.dsheirer.module.log.config.EventLogConfiguration;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
@XmlSeeAlso( { AuxDecodeConfiguration.class,
|
||||
DecodeConfiguration.class,
|
||||
EventLogConfiguration.class,
|
||||
RecordConfiguration.class,
|
||||
SourceConfiguration.class } )
|
||||
@XmlRootElement( name = "configuration" )
|
||||
public abstract class Configuration
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user