mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
wip #34 - reformatting the channel configuration editors.
This commit is contained in:
@@ -23,9 +23,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
|
import module.decode.DecoderFactory;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
import module.decode.config.AuxDecodeConfiguration;
|
import module.decode.config.AuxDecodeConfiguration;
|
||||||
import module.decode.config.DecodeConfigFactory;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
import module.decode.config.DecodeConfiguration;
|
||||||
import module.log.EventLogType;
|
import module.log.EventLogType;
|
||||||
import module.log.config.EventLogConfiguration;
|
import module.log.config.EventLogConfiguration;
|
||||||
@@ -42,7 +42,6 @@ import source.config.SourceConfigTuner;
|
|||||||
import source.config.SourceConfiguration;
|
import source.config.SourceConfiguration;
|
||||||
import source.tuner.TunerChannel;
|
import source.tuner.TunerChannel;
|
||||||
import source.tuner.TunerChannel.Type;
|
import source.tuner.TunerChannel.Type;
|
||||||
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||||
@@ -61,8 +60,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
|||||||
// Static unique channel identifier tracking
|
// Static unique channel identifier tracking
|
||||||
private static int UNIQUE_ID = 0;
|
private static int UNIQUE_ID = 0;
|
||||||
|
|
||||||
private DecodeConfiguration mDecodeConfiguration =
|
private DecodeConfiguration mDecodeConfiguration = DecoderFactory.getDefaultDecodeConfiguration();
|
||||||
DecodeConfigFactory.getDefaultDecodeConfiguration();
|
|
||||||
private AuxDecodeConfiguration mAuxDecodeConfiguration =
|
private AuxDecodeConfiguration mAuxDecodeConfiguration =
|
||||||
new AuxDecodeConfiguration();
|
new AuxDecodeConfiguration();
|
||||||
private SourceConfiguration mSourceConfiguration =
|
private SourceConfiguration mSourceConfiguration =
|
||||||
@@ -135,7 +133,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
|||||||
|
|
||||||
channel.setAuxDecodeConfiguration( aux );
|
channel.setAuxDecodeConfiguration( aux );
|
||||||
|
|
||||||
channel.setDecodeConfiguration( DecodeConfigFactory.copy( mDecodeConfiguration ) );
|
channel.setDecodeConfiguration( DecoderFactory.copy( mDecodeConfiguration ) );
|
||||||
|
|
||||||
EventLogConfiguration log = new EventLogConfiguration();
|
EventLogConfiguration log = new EventLogConfiguration();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package controller.channel;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -23,7 +24,6 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
|
||||||
import source.SourceManager;
|
import source.SourceManager;
|
||||||
import alias.AliasModel;
|
import alias.AliasModel;
|
||||||
|
|
||||||
@@ -57,8 +57,7 @@ public class ChannelController extends JPanel
|
|||||||
{
|
{
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
|
|
||||||
mEditor = new ChannelEditor( channelModel, channelMapModel,
|
mEditor = new ChannelEditor( channelModel, channelMapModel, sourceManager, aliasModel );
|
||||||
sourceManager, aliasModel );
|
|
||||||
mChannelModel.addListener( mEditor );
|
mChannelModel.addListener( mEditor );
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -66,9 +65,7 @@ public class ChannelController extends JPanel
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "insets 0 0 0 0",
|
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]") );
|
||||||
"[grow,fill]",
|
|
||||||
"[grow,fill]") );
|
|
||||||
|
|
||||||
//System Configuration View and Editor
|
//System Configuration View and Editor
|
||||||
mChannelTable = new JTable( mChannelModel );
|
mChannelTable = new JTable( mChannelModel );
|
||||||
@@ -109,11 +106,22 @@ public class ChannelController extends JPanel
|
|||||||
listAndButtonsPanel.add( channelScroller, "wrap" );
|
listAndButtonsPanel.add( channelScroller, "wrap" );
|
||||||
listAndButtonsPanel.add( buttonsPanel );
|
listAndButtonsPanel.add( buttonsPanel );
|
||||||
|
|
||||||
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
|
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.VERTICAL_SPLIT );
|
||||||
splitPane.setDividerSize( 5 );
|
splitPane.setDividerSize( 5 );
|
||||||
splitPane.setShowGripper( true );
|
splitPane.setShowGripper( true );
|
||||||
splitPane.add( listAndButtonsPanel );
|
|
||||||
splitPane.add( mEditor );
|
//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, 60 ) );
|
||||||
|
|
||||||
|
JScrollPane editorScroller = new JScrollPane( mEditor );
|
||||||
|
editorScroller.setPreferredSize( new Dimension( 800, 40 ) );
|
||||||
|
|
||||||
|
splitPane.add( listScroller );
|
||||||
|
splitPane.add( editorScroller );
|
||||||
|
|
||||||
add( splitPane );
|
add( splitPane );
|
||||||
}
|
}
|
||||||
@@ -134,14 +142,14 @@ public class ChannelController extends JPanel
|
|||||||
|
|
||||||
if( channel != null )
|
if( channel != null )
|
||||||
{
|
{
|
||||||
mEditor.setChannel( channel );
|
mEditor.setItem( channel );
|
||||||
mCopyChannelButton.setEnabled( true );
|
mCopyChannelButton.setEnabled( true );
|
||||||
mDeleteChannelButton.setEnabled( true );
|
mDeleteChannelButton.setEnabled( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mEditor.setChannel( null );
|
mEditor.setItem( null );
|
||||||
mCopyChannelButton.setEnabled( false );
|
mCopyChannelButton.setEnabled( false );
|
||||||
mDeleteChannelButton.setEnabled( false );
|
mDeleteChannelButton.setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,28 +17,26 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
import module.decode.AuxDecodeComponentEditor;
|
import module.decode.AuxDecodeConfigurationEditor;
|
||||||
import module.decode.DecodeComponentEditor;
|
import module.decode.DecodeConfigurationEditor;
|
||||||
import module.log.EventLogComponentEditor;
|
import module.log.EventLogConfigurationEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
import record.RecordConfigurationEditor;
|
||||||
import record.RecordComponentEditor;
|
import source.SourceConfigurationEditor;
|
||||||
import source.SourceComponentEditor;
|
|
||||||
import source.SourceManager;
|
import source.SourceManager;
|
||||||
import alias.AliasModel;
|
import alias.AliasModel;
|
||||||
|
|
||||||
@@ -47,22 +45,19 @@ import com.jidesoft.swing.JideTabbedPane;
|
|||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
import controller.channel.map.ChannelMapModel;
|
import controller.channel.map.ChannelMapModel;
|
||||||
|
|
||||||
public class ChannelEditor extends JPanel
|
public class ChannelEditor extends Editor<Channel> implements ActionListener, ChannelEventListener
|
||||||
implements ActionListener, ChannelEventListener
|
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger( ChannelEditor.class );
|
private final static Logger mLog = LoggerFactory.getLogger( ChannelEditor.class );
|
||||||
|
|
||||||
private NameConfigurationEditor mNameConfigurationEditor;
|
private NameConfigurationEditor mNameConfigurationEditor;
|
||||||
private DecodeComponentEditor mDecodeEditor;
|
private SourceConfigurationEditor mSourceConfigurationEditor;
|
||||||
private AuxDecodeComponentEditor mAuxDecodeEditor;
|
private DecodeConfigurationEditor mDecodeConfigurationEditor;
|
||||||
private EventLogComponentEditor mEventLogEditor;
|
private AuxDecodeConfigurationEditor mAuxDecodeConfigurationEditor;
|
||||||
private RecordComponentEditor mRecordEditor;
|
private EventLogConfigurationEditor mEventLogConfiguraitonEditor;
|
||||||
private SourceComponentEditor mSourceEditor;
|
private RecordConfigurationEditor mRecordConfigurationEditor;
|
||||||
|
|
||||||
private Channel mChannel;
|
|
||||||
|
|
||||||
private JButton mEnableButton = new JButton( "Enable" );
|
private JButton mEnableButton = new JButton( "Enable" );
|
||||||
private JLabel mChannelName = new JLabel( "Channel:" );
|
private JLabel mChannelName = new JLabel( "Channel:" );
|
||||||
|
|
||||||
@@ -77,30 +72,42 @@ public class ChannelEditor extends JPanel
|
|||||||
SourceManager sourceManager,
|
SourceManager sourceManager,
|
||||||
AliasModel aliasModel )
|
AliasModel aliasModel )
|
||||||
{
|
{
|
||||||
super();
|
|
||||||
|
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
mChannelMapModel = channelMapModel;
|
mChannelMapModel = channelMapModel;
|
||||||
mSourceManager = sourceManager;
|
mSourceManager = sourceManager;
|
||||||
|
mNameConfigurationEditor = new NameConfigurationEditor( aliasModel, mChannelModel );
|
||||||
mNameConfigurationEditor = new NameConfigurationEditor( aliasModel,
|
|
||||||
mChannelModel );
|
|
||||||
|
|
||||||
initGUI();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel configuration in each of the channel editor components
|
* Sets the channel configuration in each of the channel editor components
|
||||||
* Note: this method must be invoked on the swing event dispatch thread
|
* Note: this method must be invoked on the swing event dispatch thread
|
||||||
*/
|
*/
|
||||||
public void setChannel( final Channel channel )
|
public void setItem( final Channel channel )
|
||||||
{
|
{
|
||||||
mNameConfigurationEditor.setConfiguration( channel );
|
//Check if the current channel configuration has changed
|
||||||
mSourceEditor.setConfiguration( channel );
|
if( hasItem() &&
|
||||||
mDecodeEditor.setConfiguration( channel );
|
( mNameConfigurationEditor.isModified() ) )
|
||||||
mAuxDecodeEditor.setConfiguration( channel );
|
{
|
||||||
mEventLogEditor.setConfiguration( channel );
|
int option = JOptionPane.showConfirmDialog( ChannelEditor.this,
|
||||||
mRecordEditor.setConfiguration( channel );
|
"This channel configuration has changed. Do you want to save these changes?",
|
||||||
|
"Save Changes?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
|
||||||
|
|
||||||
|
if( option == JOptionPane.YES_OPTION )
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
mNameConfigurationEditor.setItem( channel );
|
||||||
|
mSourceConfigurationEditor.setItem( channel );
|
||||||
|
mDecodeConfigurationEditor.setItem( channel );
|
||||||
|
mAuxDecodeConfigurationEditor.setItem( channel );
|
||||||
|
mEventLogConfiguraitonEditor.setItem( channel );
|
||||||
|
mRecordConfigurationEditor.setItem( channel );
|
||||||
|
|
||||||
if( channel != null )
|
if( channel != null )
|
||||||
{
|
{
|
||||||
@@ -116,77 +123,73 @@ public class ChannelEditor extends JPanel
|
|||||||
mEnableButton.setEnabled( false );
|
mEnableButton.setEnabled( false );
|
||||||
mEnableButton.setBackground( getBackground() );
|
mEnableButton.setBackground( getBackground() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mChannel = channel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGUI()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][][][grow]" ) );
|
setLayout( new MigLayout( "fill,wrap 3", "[grow,fill][grow,fill][grow,fill]", "[][][][][grow]" ) );
|
||||||
|
|
||||||
mEnableButton.addActionListener( this );
|
add( mChannelName, "wrap" );
|
||||||
mEnableButton.setEnabled( false );
|
|
||||||
add( mEnableButton, "growx,push" );
|
|
||||||
add( mChannelName, "growx,push" );
|
|
||||||
|
|
||||||
add( new JSeparator( JSeparator.HORIZONTAL ), "span,growx,push" );
|
|
||||||
JideTabbedPane tabs = new JideTabbedPane();
|
JideTabbedPane tabs = new JideTabbedPane();
|
||||||
tabs.setFont( this.getFont() );
|
tabs.setFont( this.getFont() );
|
||||||
tabs.setForeground( Color.BLACK );
|
tabs.setForeground( Color.BLACK );
|
||||||
|
|
||||||
|
tabs.setTabTrailingComponent( mChannelName );
|
||||||
tabs.addTab( "Name/Alias", mNameConfigurationEditor );
|
tabs.addTab( "Name/Alias", mNameConfigurationEditor );
|
||||||
|
|
||||||
mSourceEditor = new SourceComponentEditor( mSourceManager );
|
mSourceConfigurationEditor = new SourceConfigurationEditor( mSourceManager );
|
||||||
tabs.addTab( "Source", mSourceEditor );
|
tabs.addTab( "Source", mSourceConfigurationEditor );
|
||||||
|
|
||||||
mDecodeEditor = new DecodeComponentEditor( mChannelMapModel );
|
mDecodeConfigurationEditor = new DecodeConfigurationEditor( mChannelMapModel );
|
||||||
tabs.addTab( "Decoder", mDecodeEditor );
|
tabs.addTab( "Decoder", mDecodeConfigurationEditor );
|
||||||
|
|
||||||
mAuxDecodeEditor = new AuxDecodeComponentEditor();
|
mAuxDecodeConfigurationEditor = new AuxDecodeConfigurationEditor();
|
||||||
tabs.addTab( "Aux Decoders", mAuxDecodeEditor );
|
tabs.addTab( "Aux Decoders", mAuxDecodeConfigurationEditor );
|
||||||
|
|
||||||
mEventLogEditor = new EventLogComponentEditor();
|
mEventLogConfiguraitonEditor = new EventLogConfigurationEditor();
|
||||||
tabs.addTab( "Logging", mEventLogEditor );
|
tabs.addTab( "Logging", mEventLogConfiguraitonEditor );
|
||||||
|
|
||||||
mRecordEditor = new RecordComponentEditor();
|
mRecordConfigurationEditor = new RecordConfigurationEditor();
|
||||||
tabs.addTab( "Recording", mRecordEditor );
|
tabs.addTab( "Recording", mRecordConfigurationEditor );
|
||||||
|
|
||||||
|
add( tabs, "span" );
|
||||||
|
|
||||||
|
mEnableButton.addActionListener( this );
|
||||||
|
mEnableButton.setEnabled( false );
|
||||||
|
add( mEnableButton );
|
||||||
|
|
||||||
add( tabs, "span,grow,push" );
|
|
||||||
|
|
||||||
JButton btnSave = new JButton( "Save" );
|
JButton btnSave = new JButton( "Save" );
|
||||||
btnSave.addActionListener( ChannelEditor.this );
|
btnSave.addActionListener( ChannelEditor.this );
|
||||||
add( btnSave, "growx,push" );
|
add( btnSave );
|
||||||
|
|
||||||
JButton btnReset = new JButton( "Reset" );
|
JButton btnReset = new JButton( "Reset" );
|
||||||
btnReset.addActionListener( ChannelEditor.this );
|
btnReset.addActionListener( ChannelEditor.this );
|
||||||
add( btnReset, "growx,push" );
|
add( btnReset );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelChanged( ChannelEvent event )
|
public void channelChanged( ChannelEvent event )
|
||||||
{
|
{
|
||||||
if( mChannel != null && mChannel == event.getChannel() )
|
if( hasItem() && getItem() == event.getChannel() )
|
||||||
{
|
{
|
||||||
switch( event.getEvent() )
|
switch( event.getEvent() )
|
||||||
{
|
{
|
||||||
case NOTIFICATION_CONFIGURATION_CHANGE:
|
case NOTIFICATION_CONFIGURATION_CHANGE:
|
||||||
case NOTIFICATION_PROCESSING_START:
|
case NOTIFICATION_PROCESSING_START:
|
||||||
case NOTIFICATION_PROCESSING_STOP:
|
case NOTIFICATION_PROCESSING_STOP:
|
||||||
setChannel( mChannel );
|
setItem( getItem() );
|
||||||
mChannelEnableRequested = false;
|
mChannelEnableRequested = false;
|
||||||
break;
|
break;
|
||||||
case NOTIFICATION_DELETE:
|
case NOTIFICATION_DELETE:
|
||||||
mChannel = null;
|
setItem( null );
|
||||||
setChannel( mChannel );
|
|
||||||
break;
|
break;
|
||||||
case NOTIFICATION_ENABLE_REJECTED:
|
case NOTIFICATION_ENABLE_REJECTED:
|
||||||
if( mChannelEnableRequested )
|
if( mChannelEnableRequested )
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog( ChannelEditor.this,
|
JOptionPane.showMessageDialog( ChannelEditor.this, "Channel could not be "
|
||||||
"Channel could not be enabled. This is likely because "
|
+ "enabled. This is likely because there are no tuner channels "
|
||||||
+ "there are no tuner channels available", "Couldn't "
|
+ "available", "Couldn't enable channel", JOptionPane.INFORMATION_MESSAGE );
|
||||||
+ "enable channel", JOptionPane.INFORMATION_MESSAGE );
|
|
||||||
|
|
||||||
mChannelEnableRequested = false;
|
mChannelEnableRequested = false;
|
||||||
}
|
}
|
||||||
@@ -195,7 +198,6 @@ public class ChannelEditor extends JPanel
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -205,17 +207,17 @@ public class ChannelEditor extends JPanel
|
|||||||
|
|
||||||
if( command.contentEquals( "Enable" ) )
|
if( command.contentEquals( "Enable" ) )
|
||||||
{
|
{
|
||||||
if( mChannel != null )
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
mChannelEnableRequested = true;
|
mChannelEnableRequested = true;
|
||||||
mChannelModel.broadcast( new ChannelEvent( mChannel, Event.REQUEST_ENABLE ) );
|
mChannelModel.broadcast( new ChannelEvent( getItem(), Event.REQUEST_ENABLE ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( command.contentEquals( "Disable" ) )
|
else if( command.contentEquals( "Disable" ) )
|
||||||
{
|
{
|
||||||
if( mChannel != null )
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
mChannelModel.broadcast( new ChannelEvent( mChannel, Event.REQUEST_DISABLE ) );
|
mChannelModel.broadcast( new ChannelEvent( getItem(), Event.REQUEST_DISABLE ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( command.contentEquals( "Save" ) )
|
else if( command.contentEquals( "Save" ) )
|
||||||
@@ -224,90 +226,50 @@ public class ChannelEditor extends JPanel
|
|||||||
}
|
}
|
||||||
else if( command.contentEquals( "Reset" ) )
|
else if( command.contentEquals( "Reset" ) )
|
||||||
{
|
{
|
||||||
setChannel( mChannel );
|
setItem( getItem() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
try
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
//Validate each of the configuration editors to check for errors
|
// try
|
||||||
mNameConfigurationEditor.validateConfiguration();
|
// {
|
||||||
mSourceEditor.validateConfiguration();
|
//TODO: validate the source editor against the decode editor
|
||||||
mDecodeEditor.validateConfiguration();
|
//TODO: validate the aux editor against the decode editor - verify no aux decoders with P25
|
||||||
mAuxDecodeEditor.validateConfiguration();
|
// }
|
||||||
mEventLogEditor.validateConfiguration();
|
// catch( ConfigurationValidationException e )
|
||||||
|
// {
|
||||||
//Validate the source configuration against the decode editor to
|
// /* ChannelValidationException can be thrown by any of the component
|
||||||
//ensure that the source type is compatible with the decode type
|
// * editors. Show the validation error text in a popup menu to the
|
||||||
|
// * user and set the focus on the error component */
|
||||||
//Validate the aux decoders against the primary decoder
|
// JOptionPane.showMessageDialog( ChannelEditor.this,
|
||||||
//TODO: make sure that no aux decoders are running with P25
|
// validationException.getMessage(),
|
||||||
|
// "Channel Configuration Error",
|
||||||
// /**
|
// JOptionPane.ERROR_MESSAGE );
|
||||||
// * Validate the source configuration against the other component
|
|
||||||
// * configuration editors
|
|
||||||
// */
|
|
||||||
// validate( mSourceEditor.getSourceEditor() );
|
|
||||||
//
|
//
|
||||||
// mSourceEditor.save();
|
// Component component = validationException.getComponent();
|
||||||
// mDecodeEditor.save();
|
//
|
||||||
// mAuxDecodeEditor.save();
|
// if( component != null )
|
||||||
// mEventLogEditor.save();
|
// {
|
||||||
// mRecordEditor.save();
|
// component.requestFocus();
|
||||||
//
|
// }
|
||||||
// mChannel.setName( mChannelName.getText() );
|
//
|
||||||
// mChannel.setEnabled( mChannelEnabled.isSelected() );
|
// return;
|
||||||
//
|
// }
|
||||||
// AliasList selected = mComboAliasLists.getItemAt(
|
|
||||||
// mComboAliasLists.getSelectedIndex() );
|
|
||||||
// if( selected != null )
|
|
||||||
// {
|
|
||||||
// mChannel.setAliasListName( selected.getName() );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
catch ( ConfigurationValidationException validationException )
|
|
||||||
{
|
|
||||||
/* ChannelValidationException can be thrown by any of the component
|
|
||||||
* editors. Show the validation error text in a popup menu to the
|
|
||||||
* user and set the focus on the error component */
|
|
||||||
JOptionPane.showMessageDialog( ChannelEditor.this,
|
|
||||||
validationException.getMessage(),
|
|
||||||
"Channel Configuration Error",
|
|
||||||
JOptionPane.ERROR_MESSAGE );
|
|
||||||
|
|
||||||
Component component = validationException.getComponent();
|
mNameConfigurationEditor.save();
|
||||||
|
mSourceConfigurationEditor.save();
|
||||||
if( component != null )
|
mDecodeConfigurationEditor.save();
|
||||||
{
|
mAuxDecodeConfigurationEditor.save();
|
||||||
component.requestFocus();
|
mEventLogConfiguraitonEditor.save();
|
||||||
}
|
mRecordConfigurationEditor.save();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Save the contents of each editor to the channel configuration
|
//Broadcast a channel configuration change event
|
||||||
mNameConfigurationEditor.save();
|
mChannelModel.broadcast( new ChannelEvent( getItem(), Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
|
||||||
mSourceEditor.save();
|
}
|
||||||
mDecodeEditor.save();
|
|
||||||
mAuxDecodeEditor.save();
|
setModified( false );
|
||||||
mEventLogEditor.save();
|
|
||||||
|
|
||||||
//Broadcast a channel configuration change event
|
|
||||||
mChannelModel.broadcast( new ChannelEvent( mChannel,
|
|
||||||
Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
|
|
||||||
}
|
}
|
||||||
// /**
|
|
||||||
// * Validate the specified editor against each of the component editors
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public void validate( ChannelConfigurationEditor editor ) throws ConfigurationValidationException
|
|
||||||
// {
|
|
||||||
// mSourceEditor.validate( editor );
|
|
||||||
// mDecodeEditor.validate( editor );
|
|
||||||
// mAuxDecodeEditor.validate( editor );
|
|
||||||
// mEventLogEditor.validate( editor );
|
|
||||||
// mRecordEditor.validate( editor );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -24,43 +26,55 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.event.DocumentEvent;
|
||||||
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import playlist.PlaylistManager;
|
|
||||||
import alias.AliasModel;
|
import alias.AliasModel;
|
||||||
|
|
||||||
public class NameConfigurationEditor extends ChannelConfigurationEditor
|
public class NameConfigurationEditor extends Editor<Channel> implements DocumentListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final String DEFAULT_NAME = "Please select a channel to view/edit";
|
private final static Logger mLog = LoggerFactory.getLogger( NameConfigurationEditor.class );
|
||||||
|
|
||||||
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
||||||
|
|
||||||
private AliasModel mAliasModel;
|
private AliasModel mAliasModel;
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
|
|
||||||
private JTextField mChannelName = new JTextField( DEFAULT_NAME );
|
private JTextField mChannelName;
|
||||||
private JComboBox<String> mSystemNameCombo = new JComboBox<>( EMPTY_MODEL );
|
private JComboBox<String> mSystemNameCombo;
|
||||||
private JComboBox<String> mSiteNameCombo = new JComboBox<>( EMPTY_MODEL );
|
private JComboBox<String> mSiteNameCombo;
|
||||||
private JComboBox<String> mAliasListCombo;
|
private JComboBox<String> mAliasListCombo;
|
||||||
|
|
||||||
private Channel mChannel;
|
|
||||||
|
|
||||||
public NameConfigurationEditor( AliasModel aliasModel, ChannelModel model )
|
public NameConfigurationEditor( AliasModel aliasModel, ChannelModel model )
|
||||||
{
|
{
|
||||||
mAliasModel = aliasModel;
|
mAliasModel = aliasModel;
|
||||||
mChannelModel = model;
|
mChannelModel = model;
|
||||||
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right][]", "[][][][][][grow]" ) );
|
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( new JLabel( "Name:" ) );
|
||||||
add( mChannelName, "growx" );
|
add( mChannelName );
|
||||||
|
|
||||||
|
mSystemNameCombo = new JComboBox<>( EMPTY_MODEL );
|
||||||
|
mSystemNameCombo.setEnabled( false );
|
||||||
mSystemNameCombo.setEditable( true );
|
mSystemNameCombo.setEditable( true );
|
||||||
mSystemNameCombo.addActionListener( new ActionListener()
|
mSystemNameCombo.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@@ -75,9 +89,9 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
|||||||
|
|
||||||
List<String> sites = mChannelModel.getSites( system );
|
List<String> sites = mChannelModel.getSites( system );
|
||||||
|
|
||||||
if( !sites.contains( mChannel.getSite() ) )
|
if( !sites.contains( getItem().getSite() ) )
|
||||||
{
|
{
|
||||||
sites.add( mChannel.getSite() );
|
sites.add( getItem().getSite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sites.isEmpty() )
|
if( sites.isEmpty() )
|
||||||
@@ -90,110 +104,99 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
|||||||
sites.toArray( new String[ sites.size() ] ) ) );;
|
sites.toArray( new String[ sites.size() ] ) ) );;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSiteNameCombo.setSelectedItem( mChannel.getSite() );
|
mSiteNameCombo.setSelectedItem( getItem().getSite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setModified( true );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
add( new JLabel( "System:" ) );
|
add( new JLabel( "System:" ) );
|
||||||
add( mSystemNameCombo, "growx" );
|
add( mSystemNameCombo );
|
||||||
|
|
||||||
mSiteNameCombo.setEditable( true );
|
|
||||||
|
|
||||||
add( new JLabel( "Site:" ) );
|
|
||||||
add( mSiteNameCombo, "growx" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ComboBox: Alias Lists
|
|
||||||
*/
|
|
||||||
add( new JLabel( "Alias List:" ) );
|
|
||||||
|
|
||||||
mAliasListCombo = new JComboBox<String>();
|
mAliasListCombo = new JComboBox<String>();
|
||||||
|
mAliasListCombo.setEnabled( false );
|
||||||
List<String> lists = mAliasModel.getListNames();
|
mAliasListCombo.setEditable( true );
|
||||||
|
mAliasListCombo.addActionListener( new ActionListener()
|
||||||
Collections.sort( lists );
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
mAliasListCombo.setModel( new DefaultComboBoxModel<String>(
|
add( new JLabel( "Alias List:" ) );
|
||||||
lists.toArray( new String[ lists.size() ] ) ) );
|
add( mAliasListCombo );
|
||||||
|
|
||||||
add( mAliasListCombo, "growx" );
|
mSiteNameCombo = new JComboBox<>( EMPTY_MODEL );
|
||||||
|
mSiteNameCombo.setEnabled( false );
|
||||||
|
mSiteNameCombo.setEditable( true );
|
||||||
|
mSiteNameCombo.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
add( new JLabel() );
|
add( new JLabel( "Site:" ) );
|
||||||
|
add( mSiteNameCombo );
|
||||||
final JButton aliasListButton = new JButton( "New Alias List ..." );
|
|
||||||
|
|
||||||
// aliasListButton.addActionListener( new ActionListener()
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public void actionPerformed( ActionEvent e )
|
|
||||||
// {
|
|
||||||
// String name = JOptionPane.showInputDialog( aliasListButton,
|
|
||||||
// "Please enter an Alias List name:" );
|
|
||||||
//
|
|
||||||
// if( name != null && !name.isEmpty() )
|
|
||||||
// {
|
|
||||||
// AliasListOld aliasList = new AliasListOld( name );
|
|
||||||
//
|
|
||||||
// mPlaylistManager.getPlayist().getAliasDirectory()
|
|
||||||
// .addAliasList( aliasList );
|
|
||||||
//
|
|
||||||
// mPlaylistManager.save();
|
|
||||||
//
|
|
||||||
// List<AliasListOld> lists = mPlaylistManager.getPlayist()
|
|
||||||
// .getAliasDirectory().getAliasList();
|
|
||||||
//
|
|
||||||
// Collections.sort( lists );
|
|
||||||
//
|
|
||||||
// mAliasListCombo.setModel( new DefaultComboBoxModel<AliasListOld>(
|
|
||||||
// lists.toArray( new AliasListOld[ lists.size() ] ) ) );
|
|
||||||
//
|
|
||||||
// mAliasListCombo.setSelectedItem( aliasList );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } );
|
|
||||||
|
|
||||||
add( aliasListButton, "growx" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if( mChannel != null )
|
if( hasItem() && isModified() )
|
||||||
{
|
{
|
||||||
mChannel.setName( mChannelName.getText() );
|
getItem().setName( mChannelName.getText() );
|
||||||
|
|
||||||
Object system = mSystemNameCombo.getSelectedItem();
|
Object system = mSystemNameCombo.getSelectedItem();
|
||||||
mChannel.setSystem( ( system == null ? null : (String)system ) );
|
getItem().setSystem( ( system == null ? null : (String)system ) );
|
||||||
|
|
||||||
Object site = mSiteNameCombo.getSelectedItem();
|
Object site = mSiteNameCombo.getSelectedItem();
|
||||||
mChannel.setSite( ( site == null ? null : (String)site ) );
|
getItem().setSite( ( site == null ? null : (String)site ) );
|
||||||
|
|
||||||
Object aliasList = mAliasListCombo.getSelectedItem();
|
Object aliasList = mAliasListCombo.getSelectedItem();
|
||||||
mChannel.setAliasListName( aliasList == null ? null : (String)aliasList );
|
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
|
@Override
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
public void setItem( Channel channel )
|
||||||
{
|
{
|
||||||
//System and site can be null, but we must (should?) have a channel name
|
super.setItem( channel );
|
||||||
String name = mChannelName.getText();
|
|
||||||
|
|
||||||
if( name == null || name.isEmpty() )
|
if( hasItem() )
|
||||||
{
|
|
||||||
throw new ConfigurationValidationException(
|
|
||||||
mChannelName, "Channel name cannot be empty" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
mChannel = channel;
|
|
||||||
|
|
||||||
if( mChannel != null )
|
|
||||||
{
|
{
|
||||||
|
setControlsEnabled( true );
|
||||||
|
|
||||||
mChannelName.setText( channel.getName() );
|
mChannelName.setText( channel.getName() );
|
||||||
|
|
||||||
List<String> systems = mChannelModel.getSystems();
|
List<String> systems = mChannelModel.getSystems();
|
||||||
@@ -221,21 +224,43 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
|||||||
mSiteNameCombo.setModel( new DefaultComboBoxModel<String>(
|
mSiteNameCombo.setModel( new DefaultComboBoxModel<String>(
|
||||||
sites.toArray( new String[ sites.size() ] ) ) );;
|
sites.toArray( new String[ sites.size() ] ) ) );;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSiteNameCombo.setSelectedItem( channel.getSite() );
|
|
||||||
|
|
||||||
String aliasListName = mChannel.getAliasListName();
|
|
||||||
|
|
||||||
if( aliasListName != null )
|
if( channel.getSite() != null )
|
||||||
{
|
{
|
||||||
mAliasListCombo.setSelectedItem( aliasListName );
|
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
|
else
|
||||||
{
|
{
|
||||||
mChannelName.setText( DEFAULT_NAME );
|
setControlsEnabled( false );
|
||||||
mSystemNameCombo.setModel( EMPTY_MODEL );
|
mChannelName.setText( null );
|
||||||
mSiteNameCombo.setModel( EMPTY_MODEL );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertUpdate( DocumentEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changedUpdate( DocumentEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeUpdate( DocumentEvent e ) {}
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/gui/editor/EditorValidationException.java
Normal file
25
src/gui/editor/EditorValidationException.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package gui.editor;
|
||||||
|
|
||||||
|
public class EditorValidationException extends Exception
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Editor<?> mEditor;
|
||||||
|
private String mReason;
|
||||||
|
|
||||||
|
public EditorValidationException( Editor<?> editor, String reason )
|
||||||
|
{
|
||||||
|
mEditor = editor;
|
||||||
|
mReason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Editor<?> getEditor()
|
||||||
|
{
|
||||||
|
return mEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return mReason;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/gui/editor/EmptyValidatingEditor.java
Normal file
37
src/gui/editor/EmptyValidatingEditor.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package gui.editor;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
public class EmptyValidatingEditor<T> extends ValidatingEditor<T>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public EmptyValidatingEditor( String descriptor )
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "insets 0 0 0 0", "[center]", "[grow]" ) );
|
||||||
|
add( new JLabel( "Please select " + descriptor ), "wrap" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmptyValidatingEditor()
|
||||||
|
{
|
||||||
|
this( "an item" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid( Editor<T> editor ) throws EditorValidationException
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/gui/editor/ValidatingEditor.java
Normal file
15
src/gui/editor/ValidatingEditor.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package gui.editor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Editor class that allows other editors to be validated for configuration with this editor
|
||||||
|
*/
|
||||||
|
public abstract class ValidatingEditor<T> extends Editor<T>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the editor argument is valid according to the settings of this editor
|
||||||
|
*/
|
||||||
|
public abstract boolean isValid( Editor<T> editor ) throws EditorValidationException;
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JDesktopPane;
|
import javax.swing.JDesktopPane;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
|
|
||||||
import module.decode.DecodeComponentEditor;
|
import module.decode.DecodeConfigurationEditor;
|
||||||
import module.decode.config.DecodeConfiguration;
|
import module.decode.config.DecodeConfiguration;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
@@ -22,7 +22,7 @@ public class DecoderSelectionFrame extends JInternalFrame
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private DecodeComponentEditor mDecodeEditor = new DecodeComponentEditor( null );
|
private DecodeConfigurationEditor mDecodeEditor = new DecodeConfigurationEditor( null );
|
||||||
private PlaylistManager mPlaylistManager;
|
private PlaylistManager mPlaylistManager;
|
||||||
|
|
||||||
private IControllableFileSource mSource;
|
private IControllableFileSource mSource;
|
||||||
@@ -77,17 +77,17 @@ public class DecoderSelectionFrame extends JInternalFrame
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
{
|
{
|
||||||
DecodeConfiguration config = mDecodeEditor.getDecodeConfig();
|
// DecodeConfiguration config = mDecodeEditor.getDecodeConfig();
|
||||||
|
//
|
||||||
if( config != null )
|
// if( config != null )
|
||||||
{
|
// {
|
||||||
DecoderViewFrame decoderFrame = new DecoderViewFrame(
|
// DecoderViewFrame decoderFrame = new DecoderViewFrame(
|
||||||
mPlaylistManager, null, mSource );
|
// mPlaylistManager, null, mSource );
|
||||||
|
//
|
||||||
decoderFrame.setVisible( true );
|
// decoderFrame.setVisible( true );
|
||||||
|
//
|
||||||
mDesktop.add( decoderFrame );
|
// mDesktop.add( decoderFrame );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,29 +17,34 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode;
|
package module.decode;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import module.decode.config.AuxDecodeConfiguration;
|
import module.decode.config.AuxDecodeConfiguration;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
|
|
||||||
public class AuxDecodeComponentEditor extends ChannelConfigurationEditor
|
public class AuxDecodeConfigurationEditor extends Editor<Channel>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private List<AuxDecoderCheckBox> mControls = new ArrayList<>();
|
private List<AuxDecoderCheckBox> mControls = new ArrayList<>();
|
||||||
|
|
||||||
private Channel mChannel;
|
public AuxDecodeConfigurationEditor()
|
||||||
|
|
||||||
public AuxDecodeComponentEditor()
|
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "fill,wrap 1", "[]", "[][][][][grow]" ) );
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 4", "", "[][grow]" ) );
|
||||||
|
|
||||||
List<DecoderType> decoders = DecoderType.getAuxDecoders();
|
List<DecoderType> decoders = DecoderType.getAuxDecoders();
|
||||||
|
|
||||||
@@ -48,29 +53,26 @@ public class AuxDecodeComponentEditor extends ChannelConfigurationEditor
|
|||||||
for( DecoderType decoder: decoders )
|
for( DecoderType decoder: decoders )
|
||||||
{
|
{
|
||||||
AuxDecoderCheckBox control = new AuxDecoderCheckBox( decoder );
|
AuxDecoderCheckBox control = new AuxDecoderCheckBox( decoder );
|
||||||
|
control.setEnabled( false );
|
||||||
|
control.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
add( control );
|
add( control );
|
||||||
|
|
||||||
mControls.add( control );
|
mControls.add( control );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuxDecodeConfiguration getConfig()
|
|
||||||
{
|
|
||||||
if( mChannel != null )
|
|
||||||
{
|
|
||||||
return mChannel.getAuxDecodeConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new AuxDecodeConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if( mChannel != null )
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
AuxDecodeConfiguration config = mChannel.getAuxDecodeConfiguration();
|
AuxDecodeConfiguration config = getItem().getAuxDecodeConfiguration();
|
||||||
|
|
||||||
config.clearAuxDecoders();
|
config.clearAuxDecoders();
|
||||||
|
|
||||||
@@ -82,7 +84,21 @@ public class AuxDecodeComponentEditor extends ChannelConfigurationEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setControlsEnabled( boolean enabled )
|
||||||
|
{
|
||||||
|
for( AuxDecoderCheckBox box: mControls )
|
||||||
|
{
|
||||||
|
if( box.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
box.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class AuxDecoderCheckBox extends JCheckBox
|
public class AuxDecoderCheckBox extends JCheckBox
|
||||||
{
|
{
|
||||||
@@ -104,27 +120,29 @@ public class AuxDecodeComponentEditor extends ChannelConfigurationEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setConfiguration( Channel channel )
|
public void setItem( Channel channel )
|
||||||
{
|
{
|
||||||
mChannel = channel;
|
super.setItem( channel );
|
||||||
|
|
||||||
for( AuxDecoderCheckBox checkBox: mControls )
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
if( mChannel != null &&
|
setControlsEnabled( true );
|
||||||
mChannel.getAuxDecodeConfiguration().getAuxDecoders()
|
|
||||||
.contains( checkBox.getDecoderType() ) )
|
for( AuxDecoderCheckBox cb: mControls )
|
||||||
{
|
{
|
||||||
checkBox.setSelected( true );
|
if( getItem().getAuxDecodeConfiguration().getAuxDecoders().contains( cb.getDecoderType() ) )
|
||||||
}
|
{
|
||||||
else
|
cb.setSelected( true );
|
||||||
{
|
}
|
||||||
checkBox.setSelected( false );
|
else
|
||||||
}
|
{
|
||||||
|
cb.setSelected( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 module.decode;
|
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import module.decode.config.DecodeConfigFactory;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
import controller.channel.map.ChannelMapModel;
|
|
||||||
|
|
||||||
public class DecodeComponentEditor extends ChannelConfigurationEditor
|
|
||||||
{
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger( DecodeComponentEditor.class );
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JComboBox<DecoderType> mComboDecoders;
|
|
||||||
|
|
||||||
private DecodeEditor mEditor;
|
|
||||||
|
|
||||||
private Channel mChannel;
|
|
||||||
|
|
||||||
public DecodeComponentEditor( final ChannelMapModel channelMapModel )
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) );
|
|
||||||
|
|
||||||
mComboDecoders = new JComboBox<DecoderType>();
|
|
||||||
|
|
||||||
DefaultComboBoxModel<DecoderType> model =
|
|
||||||
new DefaultComboBoxModel<DecoderType>();
|
|
||||||
|
|
||||||
for( DecoderType type: DecoderType.getPrimaryDecoders() )
|
|
||||||
{
|
|
||||||
model.addElement( type );
|
|
||||||
}
|
|
||||||
|
|
||||||
mComboDecoders.setModel( model );
|
|
||||||
|
|
||||||
mComboDecoders.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
DecoderType selected = mComboDecoders
|
|
||||||
.getItemAt( mComboDecoders.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
DecodeConfiguration config;
|
|
||||||
|
|
||||||
if( mChannel == null ||
|
|
||||||
mChannel.getDecodeConfiguration().getDecoderType() != selected )
|
|
||||||
{
|
|
||||||
config = DecodeConfigFactory.getDecodeConfiguration( selected );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
config = mChannel.getDecodeConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Remove the existing one
|
|
||||||
if( mEditor != null )
|
|
||||||
{
|
|
||||||
remove( mEditor );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Change to the new one
|
|
||||||
mEditor = DecoderFactory.getEditorPanel( config, channelMapModel );
|
|
||||||
|
|
||||||
add( mEditor, "span 2,center" );
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add( new JLabel( "Decoder:" ) );
|
|
||||||
add( mComboDecoders, "wrap" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public DecodeConfiguration getDecodeConfig()
|
|
||||||
{
|
|
||||||
return mEditor.getConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
if( mEditor != null )
|
|
||||||
{
|
|
||||||
mEditor.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
mChannel.setDecodeConfiguration( mEditor.getConfig() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Validates the editor against the current decode editor
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public void validate( ChannelConfigurationEditor editor ) throws ConfigurationValidationException
|
|
||||||
// {
|
|
||||||
// super.validate( editor );
|
|
||||||
//
|
|
||||||
// mEditor.validate( editor );
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
mChannel = channel;
|
|
||||||
|
|
||||||
if( mChannel != null )
|
|
||||||
{
|
|
||||||
final DecoderType decoder = mChannel.getDecodeConfiguration().getDecoderType();
|
|
||||||
|
|
||||||
mComboDecoders.setSelectedItem( decoder );
|
|
||||||
|
|
||||||
mComboDecoders.requestFocus();
|
|
||||||
|
|
||||||
mComboDecoders.requestFocusInWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
}
|
|
||||||
129
src/module/decode/DecodeConfigurationEditor.java
Normal file
129
src/module/decode/DecodeConfigurationEditor.java
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 module.decode;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
import gui.editor.EditorValidationException;
|
||||||
|
import gui.editor.EmptyValidatingEditor;
|
||||||
|
import gui.editor.ValidatingEditor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import controller.channel.Channel;
|
||||||
|
import controller.channel.map.ChannelMapModel;
|
||||||
|
|
||||||
|
public class DecodeConfigurationEditor extends ValidatingEditor<Channel>
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger( DecodeConfigurationEditor.class );
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private JComboBox<DecoderType> mComboDecoders;
|
||||||
|
private ValidatingEditor<Channel> mCurrentEditor = new EmptyValidatingEditor<>();
|
||||||
|
|
||||||
|
public DecodeConfigurationEditor( final ChannelMapModel channelMapModel )
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 3", "[right][left][grow,fill]", "[][grow]" ) );
|
||||||
|
|
||||||
|
mComboDecoders = new JComboBox<DecoderType>();
|
||||||
|
mComboDecoders.setEnabled( false );
|
||||||
|
|
||||||
|
DefaultComboBoxModel<DecoderType> model = new DefaultComboBoxModel<DecoderType>();
|
||||||
|
|
||||||
|
for( DecoderType type: DecoderType.getPrimaryDecoders() )
|
||||||
|
{
|
||||||
|
model.addElement( type );
|
||||||
|
}
|
||||||
|
|
||||||
|
mComboDecoders.setModel( model );
|
||||||
|
mComboDecoders.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
DecoderType selected = mComboDecoders.getItemAt( mComboDecoders.getSelectedIndex() );
|
||||||
|
setEditor( DecoderFactory.getEditor( selected ) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add( new JLabel( "Decoder:" ) );
|
||||||
|
add( mComboDecoders );
|
||||||
|
add( mCurrentEditor );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEditor( ValidatingEditor<Channel> editor )
|
||||||
|
{
|
||||||
|
if( mCurrentEditor != editor )
|
||||||
|
{
|
||||||
|
remove( mCurrentEditor );
|
||||||
|
mCurrentEditor = editor;
|
||||||
|
add( mCurrentEditor );
|
||||||
|
|
||||||
|
revalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
// if( mEditor != null )
|
||||||
|
// {
|
||||||
|
// mEditor.save();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// mChannel.setDecodeConfiguration( mEditor.getConfig() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( Channel channel )
|
||||||
|
{
|
||||||
|
super.setItem( channel );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
mComboDecoders.setEnabled( true );
|
||||||
|
mCurrentEditor.setItem( channel );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mComboDecoders.setEnabled( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid( Editor<Channel> editor ) throws EditorValidationException
|
||||||
|
{
|
||||||
|
return mCurrentEditor.isValid( editor );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,7 +25,9 @@ import message.Message;
|
|||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import module.decode.am.AMDecoder;
|
import module.decode.am.AMDecoder;
|
||||||
|
import module.decode.am.AMDecoderEditor;
|
||||||
import module.decode.am.AMDecoderPanel;
|
import module.decode.am.AMDecoderPanel;
|
||||||
|
import module.decode.am.DecodeConfigAM;
|
||||||
import module.decode.config.AuxDecodeConfiguration;
|
import module.decode.config.AuxDecodeConfiguration;
|
||||||
import module.decode.config.DecodeConfiguration;
|
import module.decode.config.DecodeConfiguration;
|
||||||
import module.decode.fleetsync2.Fleetsync2Decoder;
|
import module.decode.fleetsync2.Fleetsync2Decoder;
|
||||||
@@ -38,32 +40,29 @@ import module.decode.lj1200.LJ1200DecoderState;
|
|||||||
import module.decode.lj1200.LJ1200MessageFilter;
|
import module.decode.lj1200.LJ1200MessageFilter;
|
||||||
import module.decode.ltrnet.DecodeConfigLTRNet;
|
import module.decode.ltrnet.DecodeConfigLTRNet;
|
||||||
import module.decode.ltrnet.LTRNetDecoder;
|
import module.decode.ltrnet.LTRNetDecoder;
|
||||||
|
import module.decode.ltrnet.LTRNetDecoderEditor;
|
||||||
import module.decode.ltrnet.LTRNetDecoderPanel;
|
import module.decode.ltrnet.LTRNetDecoderPanel;
|
||||||
import module.decode.ltrnet.LTRNetDecoderState;
|
import module.decode.ltrnet.LTRNetDecoderState;
|
||||||
import module.decode.ltrnet.LTRNetEditor;
|
|
||||||
import module.decode.ltrnet.LTRNetMessageFilter;
|
import module.decode.ltrnet.LTRNetMessageFilter;
|
||||||
import module.decode.ltrstandard.DecodeConfigLTRStandard;
|
import module.decode.ltrstandard.DecodeConfigLTRStandard;
|
||||||
import module.decode.ltrstandard.LTRStandardDecoder;
|
import module.decode.ltrstandard.LTRStandardDecoder;
|
||||||
import module.decode.ltrstandard.LTRStandardDecoderPanel;
|
import module.decode.ltrstandard.LTRStandardDecoderPanel;
|
||||||
import module.decode.ltrstandard.LTRStandardDecoderState;
|
import module.decode.ltrstandard.LTRStandardDecoderState;
|
||||||
import module.decode.ltrstandard.LTRStandardEditor;
|
|
||||||
import module.decode.ltrstandard.LTRStandardMessageFilter;
|
import module.decode.ltrstandard.LTRStandardMessageFilter;
|
||||||
import module.decode.mdc1200.MDCDecoder;
|
import module.decode.mdc1200.MDCDecoder;
|
||||||
import module.decode.mdc1200.MDCDecoderPanel;
|
import module.decode.mdc1200.MDCDecoderPanel;
|
||||||
import module.decode.mdc1200.MDCDecoderState;
|
import module.decode.mdc1200.MDCDecoderState;
|
||||||
import module.decode.mdc1200.MDCMessageFilter;
|
import module.decode.mdc1200.MDCMessageFilter;
|
||||||
import module.decode.mpt1327.DecodeConfigMPT1327;
|
import module.decode.mpt1327.DecodeConfigMPT1327;
|
||||||
import module.decode.mpt1327.MPT1327ConfigEditor;
|
|
||||||
import module.decode.mpt1327.MPT1327Decoder;
|
import module.decode.mpt1327.MPT1327Decoder;
|
||||||
import module.decode.mpt1327.MPT1327Decoder.Sync;
|
import module.decode.mpt1327.MPT1327Decoder.Sync;
|
||||||
import module.decode.mpt1327.MPT1327DecoderPanel;
|
import module.decode.mpt1327.MPT1327DecoderPanel;
|
||||||
import module.decode.mpt1327.MPT1327DecoderState;
|
import module.decode.mpt1327.MPT1327DecoderState;
|
||||||
import module.decode.mpt1327.MPT1327MessageFilter;
|
import module.decode.mpt1327.MPT1327MessageFilter;
|
||||||
|
import module.decode.nbfm.DecodeConfigNBFM;
|
||||||
import module.decode.nbfm.NBFMDecoder;
|
import module.decode.nbfm.NBFMDecoder;
|
||||||
import module.decode.nbfm.NBFMDecoderPanel;
|
import module.decode.nbfm.NBFMDecoderPanel;
|
||||||
import module.decode.nbfm.NBFMEditor;
|
|
||||||
import module.decode.p25.DecodeConfigP25Phase1;
|
import module.decode.p25.DecodeConfigP25Phase1;
|
||||||
import module.decode.p25.P25DecodeEditor;
|
|
||||||
import module.decode.p25.P25Decoder.Modulation;
|
import module.decode.p25.P25Decoder.Modulation;
|
||||||
import module.decode.p25.P25DecoderPanel;
|
import module.decode.p25.P25DecoderPanel;
|
||||||
import module.decode.p25.P25DecoderState;
|
import module.decode.p25.P25DecoderState;
|
||||||
@@ -71,10 +70,10 @@ import module.decode.p25.P25_C4FMDecoder;
|
|||||||
import module.decode.p25.P25_LSMDecoder;
|
import module.decode.p25.P25_LSMDecoder;
|
||||||
import module.decode.p25.audio.P25AudioModule;
|
import module.decode.p25.audio.P25AudioModule;
|
||||||
import module.decode.p25.message.filter.P25MessageFilterSet;
|
import module.decode.p25.message.filter.P25MessageFilterSet;
|
||||||
|
import module.decode.passport.DecodeConfigPassport;
|
||||||
import module.decode.passport.PassportDecoder;
|
import module.decode.passport.PassportDecoder;
|
||||||
import module.decode.passport.PassportDecoderPanel;
|
import module.decode.passport.PassportDecoderPanel;
|
||||||
import module.decode.passport.PassportDecoderState;
|
import module.decode.passport.PassportDecoderState;
|
||||||
import module.decode.passport.PassportEditor;
|
|
||||||
import module.decode.passport.PassportMessageFilter;
|
import module.decode.passport.PassportMessageFilter;
|
||||||
import module.decode.state.AlwaysUnsquelchedDecoderState;
|
import module.decode.state.AlwaysUnsquelchedDecoderState;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
@@ -90,7 +89,6 @@ import module.demodulate.fm.FMDemodulatorModule;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
|
||||||
import properties.SystemProperties;
|
import properties.SystemProperties;
|
||||||
import record.RecorderType;
|
import record.RecorderType;
|
||||||
import record.config.RecordConfiguration;
|
import record.config.RecordConfiguration;
|
||||||
@@ -108,6 +106,8 @@ import controller.channel.map.ChannelMapModel;
|
|||||||
import filter.AllPassFilter;
|
import filter.AllPassFilter;
|
||||||
import filter.FilterSet;
|
import filter.FilterSet;
|
||||||
import filter.IFilter;
|
import filter.IFilter;
|
||||||
|
import gui.editor.EmptyValidatingEditor;
|
||||||
|
import gui.editor.ValidatingEditor;
|
||||||
|
|
||||||
public class DecoderFactory
|
public class DecoderFactory
|
||||||
{
|
{
|
||||||
@@ -432,41 +432,132 @@ public class DecoderFactory
|
|||||||
|
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DecodeEditor getEditorPanel( DecodeConfiguration config,
|
public static DecodeConfiguration getDefaultDecodeConfiguration()
|
||||||
ChannelMapModel channelMapModel )
|
|
||||||
{
|
{
|
||||||
DecodeEditor configuredPanel;
|
return getDecodeConfiguration( DecoderType.NBFM );
|
||||||
|
}
|
||||||
switch( config.getDecoderType() )
|
|
||||||
|
public static DecodeConfiguration getDecodeConfiguration( DecoderType decoder )
|
||||||
|
{
|
||||||
|
DecodeConfiguration retVal;
|
||||||
|
|
||||||
|
switch( decoder )
|
||||||
{
|
{
|
||||||
case NBFM:
|
case AM:
|
||||||
configuredPanel = new NBFMEditor( config );
|
return new DecodeConfigAM();
|
||||||
break;
|
|
||||||
case LTR_STANDARD:
|
|
||||||
configuredPanel = new LTRStandardEditor( config );
|
|
||||||
break;
|
|
||||||
case LTR_NET:
|
case LTR_NET:
|
||||||
configuredPanel = new LTRNetEditor( config );
|
return new DecodeConfigLTRNet();
|
||||||
|
case LTR_STANDARD:
|
||||||
|
return new DecodeConfigLTRStandard();
|
||||||
|
case MPT1327:
|
||||||
|
return new DecodeConfigMPT1327();
|
||||||
|
case NBFM:
|
||||||
|
return new DecodeConfigNBFM();
|
||||||
|
case PASSPORT:
|
||||||
|
return new DecodeConfigPassport();
|
||||||
|
case P25_PHASE1:
|
||||||
|
return new DecodeConfigP25Phase1();
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException( "DecodeConfigFactory - unknown decoder type ["
|
||||||
|
+ decoder.toString() + "]" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ValidatingEditor<Channel> getEditor( DecoderType type )
|
||||||
|
{
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case AM:
|
||||||
|
return new AMDecoderEditor();
|
||||||
|
case LTR_NET:
|
||||||
|
return new LTRNetDecoderEditor();
|
||||||
|
case LTR_STANDARD:
|
||||||
break;
|
break;
|
||||||
case MPT1327:
|
case MPT1327:
|
||||||
configuredPanel = new MPT1327ConfigEditor( config,
|
|
||||||
channelMapModel );
|
|
||||||
break;
|
break;
|
||||||
case PASSPORT:
|
case NBFM:
|
||||||
configuredPanel = new PassportEditor( config );
|
|
||||||
break;
|
break;
|
||||||
case P25_PHASE1:
|
case P25_PHASE1:
|
||||||
configuredPanel = new P25DecodeEditor( config );
|
break;
|
||||||
|
case PASSPORT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
configuredPanel = new DecodeEditor( config );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return configuredPanel;
|
return new EmptyValidatingEditor<Channel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a copy of the configuration
|
||||||
|
*/
|
||||||
|
public static DecodeConfiguration copy( DecodeConfiguration config )
|
||||||
|
{
|
||||||
|
if( config != null )
|
||||||
|
{
|
||||||
|
switch( config.getDecoderType() )
|
||||||
|
{
|
||||||
|
case AM:
|
||||||
|
DecodeConfigAM originalAM = (DecodeConfigAM)config;
|
||||||
|
DecodeConfigAM copyAM = new DecodeConfigAM();
|
||||||
|
copyAM.setAFC( originalAM.getAFC() );
|
||||||
|
copyAM.setAFCMaximumCorrection( originalAM.getAFCMaximumCorrection() );
|
||||||
|
return copyAM;
|
||||||
|
case LTR_NET:
|
||||||
|
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet)config;
|
||||||
|
DecodeConfigLTRNet copyLTRNet = new DecodeConfigLTRNet();
|
||||||
|
copyLTRNet.setAFC( originalLTRNet.getAFC() );
|
||||||
|
copyLTRNet.setAFCMaximumCorrection( originalLTRNet.getAFCMaximumCorrection() );
|
||||||
|
copyLTRNet.setMessageDirection( originalLTRNet.getMessageDirection() );
|
||||||
|
return copyLTRNet;
|
||||||
|
case LTR_STANDARD:
|
||||||
|
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard)config;
|
||||||
|
DecodeConfigLTRStandard copyLTRStandard = new DecodeConfigLTRStandard();
|
||||||
|
copyLTRStandard.setAFC( originalLTRStandard.getAFC() );
|
||||||
|
copyLTRStandard.setAFCMaximumCorrection( originalLTRStandard.getAFCMaximumCorrection() );
|
||||||
|
copyLTRStandard.setMessageDirection( originalLTRStandard.getMessageDirection() );
|
||||||
|
return copyLTRStandard;
|
||||||
|
case MPT1327:
|
||||||
|
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327)config;
|
||||||
|
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
|
||||||
|
copyMPT.setAFC( originalMPT.getAFC() );
|
||||||
|
copyMPT.setAFCMaximumCorrection( originalMPT.getAFCMaximumCorrection() );
|
||||||
|
copyMPT.setCallTimeout( originalMPT.getCallTimeout() );
|
||||||
|
copyMPT.setChannelMapName( originalMPT.getChannelMapName() );
|
||||||
|
copyMPT.setSync( originalMPT.getSync() );
|
||||||
|
copyMPT.setTrafficChannelPoolSize( originalMPT.getTrafficChannelPoolSize() );
|
||||||
|
return copyMPT;
|
||||||
|
case NBFM:
|
||||||
|
DecodeConfigNBFM originalNBFM = (DecodeConfigNBFM)config;
|
||||||
|
DecodeConfigNBFM copyNBFM = new DecodeConfigNBFM();
|
||||||
|
copyNBFM.setAFC( originalNBFM.getAFC() );
|
||||||
|
copyNBFM.setAFCMaximumCorrection( originalNBFM.getAFCMaximumCorrection() );
|
||||||
|
return copyNBFM;
|
||||||
|
case P25_PHASE1:
|
||||||
|
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1)config;
|
||||||
|
DecodeConfigP25Phase1 copyP25 = new DecodeConfigP25Phase1();
|
||||||
|
copyP25.setAFC( originalP25.getAFC() );
|
||||||
|
copyP25.setAFCMaximumCorrection( originalP25.getAFCMaximumCorrection() );
|
||||||
|
copyP25.setIgnoreDataCalls( originalP25.getIgnoreDataCalls() );
|
||||||
|
copyP25.setModulation( originalP25.getModulation() );
|
||||||
|
copyP25.setTrafficChannelPoolSize( originalP25.getTrafficChannelPoolSize() );
|
||||||
|
return copyP25;
|
||||||
|
case PASSPORT:
|
||||||
|
DecodeConfigPassport originalPass = (DecodeConfigPassport)config;
|
||||||
|
DecodeConfigPassport copyPass = new DecodeConfigPassport();
|
||||||
|
copyPass.setAFC( originalPass.getAFC() );
|
||||||
|
copyPass.setAFCMaximumCorrection( originalPass.getAFCMaximumCorrection() );
|
||||||
|
return copyPass;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException( "Unrecognized decoder "
|
||||||
|
+ "configuration type:" + config.getDecoderType() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getRecordingFilename( String token )
|
public static String getRecordingFilename( String token )
|
||||||
{
|
{
|
||||||
//Get the base recording filename
|
//Get the base recording filename
|
||||||
|
|||||||
@@ -17,15 +17,33 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.am;
|
package module.decode.am;
|
||||||
|
|
||||||
import module.decode.DecodeEditor;
|
import gui.editor.Editor;
|
||||||
import module.decode.config.DecodeConfiguration;
|
import gui.editor.EditorValidationException;
|
||||||
|
import gui.editor.ValidatingEditor;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
|
||||||
public class AMEditor extends DecodeEditor
|
public class AMDecoderEditor extends ValidatingEditor<Channel>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public AMEditor( DecodeConfiguration config )
|
public AMDecoderEditor()
|
||||||
{
|
{
|
||||||
super( config );
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid( Editor<Channel> editor ) throws EditorValidationException
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && isModified() )
|
||||||
|
{
|
||||||
|
getItem().setDecodeConfiguration( new DecodeConfigAM() );
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 module.decode.config;
|
|
||||||
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import module.decode.am.DecodeConfigAM;
|
|
||||||
import module.decode.ltrnet.DecodeConfigLTRNet;
|
|
||||||
import module.decode.ltrstandard.DecodeConfigLTRStandard;
|
|
||||||
import module.decode.mpt1327.DecodeConfigMPT1327;
|
|
||||||
import module.decode.nbfm.DecodeConfigNBFM;
|
|
||||||
import module.decode.p25.DecodeConfigP25Phase1;
|
|
||||||
import module.decode.passport.DecodeConfigPassport;
|
|
||||||
|
|
||||||
public class DecodeConfigFactory
|
|
||||||
{
|
|
||||||
public static DecodeConfiguration getDefaultDecodeConfiguration()
|
|
||||||
{
|
|
||||||
return getDecodeConfiguration( DecoderType.NBFM );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DecodeConfiguration
|
|
||||||
getDecodeConfiguration( DecoderType decoder )
|
|
||||||
{
|
|
||||||
DecodeConfiguration retVal;
|
|
||||||
|
|
||||||
switch( decoder )
|
|
||||||
{
|
|
||||||
case AM:
|
|
||||||
retVal = new DecodeConfigAM();
|
|
||||||
break;
|
|
||||||
case LTR_NET:
|
|
||||||
retVal = new DecodeConfigLTRNet();
|
|
||||||
break;
|
|
||||||
case LTR_STANDARD:
|
|
||||||
retVal = new DecodeConfigLTRStandard();
|
|
||||||
break;
|
|
||||||
case MPT1327:
|
|
||||||
retVal = new DecodeConfigMPT1327();
|
|
||||||
break;
|
|
||||||
case NBFM:
|
|
||||||
retVal = new DecodeConfigNBFM();
|
|
||||||
break;
|
|
||||||
case PASSPORT:
|
|
||||||
retVal = new DecodeConfigPassport();
|
|
||||||
break;
|
|
||||||
case P25_PHASE1:
|
|
||||||
retVal = new DecodeConfigP25Phase1();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException( "DecodeConfigFactory - "
|
|
||||||
+ "unknown decoder type [" + decoder.toString() + "]" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a copy of the configuration
|
|
||||||
*/
|
|
||||||
public static DecodeConfiguration copy( DecodeConfiguration config )
|
|
||||||
{
|
|
||||||
if( config != null )
|
|
||||||
{
|
|
||||||
switch( config.getDecoderType() )
|
|
||||||
{
|
|
||||||
case AM:
|
|
||||||
DecodeConfigAM originalAM = (DecodeConfigAM)config;
|
|
||||||
DecodeConfigAM copyAM = new DecodeConfigAM();
|
|
||||||
copyAM.setAFC( originalAM.getAFC() );
|
|
||||||
copyAM.setAFCMaximumCorrection( originalAM.getAFCMaximumCorrection() );
|
|
||||||
return copyAM;
|
|
||||||
case LTR_NET:
|
|
||||||
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet)config;
|
|
||||||
DecodeConfigLTRNet copyLTRNet = new DecodeConfigLTRNet();
|
|
||||||
copyLTRNet.setAFC( originalLTRNet.getAFC() );
|
|
||||||
copyLTRNet.setAFCMaximumCorrection( originalLTRNet.getAFCMaximumCorrection() );
|
|
||||||
copyLTRNet.setMessageDirection( originalLTRNet.getMessageDirection() );
|
|
||||||
return copyLTRNet;
|
|
||||||
case LTR_STANDARD:
|
|
||||||
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard)config;
|
|
||||||
DecodeConfigLTRStandard copyLTRStandard = new DecodeConfigLTRStandard();
|
|
||||||
copyLTRStandard.setAFC( originalLTRStandard.getAFC() );
|
|
||||||
copyLTRStandard.setAFCMaximumCorrection( originalLTRStandard.getAFCMaximumCorrection() );
|
|
||||||
copyLTRStandard.setMessageDirection( originalLTRStandard.getMessageDirection() );
|
|
||||||
return copyLTRStandard;
|
|
||||||
case MPT1327:
|
|
||||||
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327)config;
|
|
||||||
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
|
|
||||||
copyMPT.setAFC( originalMPT.getAFC() );
|
|
||||||
copyMPT.setAFCMaximumCorrection( originalMPT.getAFCMaximumCorrection() );
|
|
||||||
copyMPT.setCallTimeout( originalMPT.getCallTimeout() );
|
|
||||||
copyMPT.setChannelMapName( originalMPT.getChannelMapName() );
|
|
||||||
copyMPT.setSync( originalMPT.getSync() );
|
|
||||||
copyMPT.setTrafficChannelPoolSize( originalMPT.getTrafficChannelPoolSize() );
|
|
||||||
return copyMPT;
|
|
||||||
case NBFM:
|
|
||||||
DecodeConfigNBFM originalNBFM = (DecodeConfigNBFM)config;
|
|
||||||
DecodeConfigNBFM copyNBFM = new DecodeConfigNBFM();
|
|
||||||
copyNBFM.setAFC( originalNBFM.getAFC() );
|
|
||||||
copyNBFM.setAFCMaximumCorrection( originalNBFM.getAFCMaximumCorrection() );
|
|
||||||
return copyNBFM;
|
|
||||||
case P25_PHASE1:
|
|
||||||
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1)config;
|
|
||||||
DecodeConfigP25Phase1 copyP25 = new DecodeConfigP25Phase1();
|
|
||||||
copyP25.setAFC( originalP25.getAFC() );
|
|
||||||
copyP25.setAFCMaximumCorrection( originalP25.getAFCMaximumCorrection() );
|
|
||||||
copyP25.setIgnoreDataCalls( originalP25.getIgnoreDataCalls() );
|
|
||||||
copyP25.setModulation( originalP25.getModulation() );
|
|
||||||
copyP25.setTrafficChannelPoolSize( originalP25.getTrafficChannelPoolSize() );
|
|
||||||
return copyP25;
|
|
||||||
case PASSPORT:
|
|
||||||
DecodeConfigPassport originalPass = (DecodeConfigPassport)config;
|
|
||||||
DecodeConfigPassport copyPass = new DecodeConfigPassport();
|
|
||||||
copyPass.setAFC( originalPass.getAFC() );
|
|
||||||
copyPass.setAFCMaximumCorrection( originalPass.getAFCMaximumCorrection() );
|
|
||||||
return copyPass;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException( "Unrecognized decoder "
|
|
||||||
+ "configuration type:" + config.getDecoderType() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
156
src/module/decode/ltrnet/LTRNetDecoderEditor.java
Normal file
156
src/module/decode/ltrnet/LTRNetDecoderEditor.java
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 module.decode.ltrnet;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
import gui.editor.EditorValidationException;
|
||||||
|
import gui.editor.ValidatingEditor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import message.MessageDirection;
|
||||||
|
import module.decode.config.DecodeConfiguration;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
|
||||||
|
public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
protected JCheckBox mAFC;
|
||||||
|
protected JSpinner mAFCMaximumCorrection;
|
||||||
|
private JComboBox<MessageDirection> mComboDirection;
|
||||||
|
|
||||||
|
public LTRNetDecoderEditor()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 5", "[left][right][grow,fill][right][grow,fill]",
|
||||||
|
"[][grow]" ) );
|
||||||
|
|
||||||
|
mAFC = new JCheckBox( "AFC" );
|
||||||
|
mAFC.setEnabled( false );
|
||||||
|
mAFC.setToolTipText( "AFC automatically adjusts the center frequency of the channel to "
|
||||||
|
+ "correct/compensate for inaccuracies and frequency drift in the tuner" );
|
||||||
|
mAFC.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( mAFC );
|
||||||
|
|
||||||
|
mAFCMaximumCorrection = new JSpinner( new SpinnerNumberModel( 3000, 0, 15000, 1 ) );
|
||||||
|
mAFCMaximumCorrection.setEnabled( false );
|
||||||
|
JSpinner.NumberEditor editor = (JSpinner.NumberEditor)mAFCMaximumCorrection.getEditor();
|
||||||
|
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
|
||||||
|
mAFCMaximumCorrection.setToolTipText( "Sets the maximum frequency correction value in hertz, 0 - 15kHz" );
|
||||||
|
mAFCMaximumCorrection.addChangeListener( new ChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void stateChanged( ChangeEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( new JLabel( "Correction Limit Hz:" ) );
|
||||||
|
add( mAFCMaximumCorrection );
|
||||||
|
|
||||||
|
mComboDirection = new JComboBox<MessageDirection>();
|
||||||
|
mComboDirection.setModel( new DefaultComboBoxModel<MessageDirection>( MessageDirection.values() ) );
|
||||||
|
mComboDirection.setEnabled( false );
|
||||||
|
mComboDirection.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( new JLabel( "Format:" ) );
|
||||||
|
add( mComboDirection );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid( Editor<Channel> editor ) throws EditorValidationException
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( Channel item )
|
||||||
|
{
|
||||||
|
super.setItem( item );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
mComboDirection.setEnabled( true );
|
||||||
|
|
||||||
|
DecodeConfiguration config = getItem().getDecodeConfiguration();
|
||||||
|
|
||||||
|
if( config instanceof DecodeConfigLTRNet )
|
||||||
|
{
|
||||||
|
DecodeConfigLTRNet ltr = (DecodeConfigLTRNet)config;
|
||||||
|
mComboDirection.setSelectedItem( ltr.getMessageDirection() );
|
||||||
|
mAFC.setSelected( ltr.isAFCEnabled() );
|
||||||
|
mAFCMaximumCorrection.setValue( ltr.getAFCMaximumCorrection() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mComboDirection.setEnabled( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && isModified() )
|
||||||
|
{
|
||||||
|
DecodeConfigLTRNet ltr = new DecodeConfigLTRNet();
|
||||||
|
ltr.setAFC( mAFC.isSelected() );
|
||||||
|
|
||||||
|
int value = ((SpinnerNumberModel)mAFCMaximumCorrection.getModel()).getNumber().intValue();
|
||||||
|
ltr.setAFCMaximumCorrection( value );
|
||||||
|
|
||||||
|
ltr.setMessageDirection( (MessageDirection)mComboDirection.getSelectedItem() );
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 module.decode.ltrnet;
|
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import message.MessageDirection;
|
|
||||||
import module.decode.DecodeEditor;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
|
|
||||||
public class LTRNetEditor extends DecodeEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JComboBox<MessageDirection> mComboDirection;
|
|
||||||
|
|
||||||
public LTRNetEditor( DecodeConfiguration config )
|
|
||||||
{
|
|
||||||
super( config );
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
mComboDirection = new JComboBox<MessageDirection>();
|
|
||||||
|
|
||||||
mComboDirection.setModel(
|
|
||||||
new DefaultComboBoxModel<MessageDirection>( MessageDirection.values() ) );
|
|
||||||
|
|
||||||
mComboDirection.setSelectedItem( ((DecodeConfigLTRNet)mConfig).getMessageDirection() );
|
|
||||||
|
|
||||||
mComboDirection.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
MessageDirection selected = mComboDirection
|
|
||||||
.getItemAt( mComboDirection.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
((DecodeConfigLTRNet)mConfig).setMessageDirection( selected );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
add( new JLabel( "Format:" ) );
|
|
||||||
add( mComboDirection, "wrap" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,8 +32,8 @@ import module.decode.p25.P25Decoder.Modulation;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import source.SourceEditor;
|
import source.SourceConfigurationEditor;
|
||||||
import source.tuner.TunerEditorOld;
|
import source.tuner.TunerSourceEditor;
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
import controller.channel.ChannelConfigurationEditor;
|
||||||
import controller.channel.ConfigurationValidationException;
|
import controller.channel.ConfigurationValidationException;
|
||||||
|
|
||||||
|
|||||||
@@ -17,34 +17,71 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.log;
|
package module.log;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import module.log.config.EventLogConfiguration;
|
import module.log.config.EventLogConfiguration;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
|
|
||||||
public class EventLogComponentEditor extends ChannelConfigurationEditor
|
public class EventLogConfigurationEditor extends Editor<Channel>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private JCheckBox mBinaryLogger = new JCheckBox( "Binary Messages" );
|
private JCheckBox mBinaryLogger;
|
||||||
private JCheckBox mDecodedLogger = new JCheckBox( "Decoded Messages" );
|
private JCheckBox mDecodedLogger;
|
||||||
private JCheckBox mCallEventLogger = new JCheckBox( "Call Events" );
|
private JCheckBox mCallEventLogger;
|
||||||
|
|
||||||
private Channel mChannel;
|
|
||||||
|
|
||||||
public EventLogComponentEditor()
|
public EventLogConfigurationEditor()
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "fill,wrap 1", "[]", "[][][][grow]" ) );
|
init();
|
||||||
|
|
||||||
add( mBinaryLogger );
|
|
||||||
add( mDecodedLogger );
|
|
||||||
add( mCallEventLogger );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 4", "", "[][grow]" ) );
|
||||||
|
|
||||||
|
mBinaryLogger = new JCheckBox( "Binary Messages" );
|
||||||
|
mBinaryLogger.setEnabled( false );
|
||||||
|
mBinaryLogger.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mBinaryLogger );
|
||||||
|
|
||||||
|
mDecodedLogger = new JCheckBox( "Decoded Messages" );
|
||||||
|
mDecodedLogger.setEnabled( false );
|
||||||
|
mDecodedLogger.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mDecodedLogger );
|
||||||
|
|
||||||
|
mCallEventLogger = new JCheckBox( "Call Events" );
|
||||||
|
mCallEventLogger.setEnabled( false );
|
||||||
|
mCallEventLogger.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mCallEventLogger );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current configuration as the stored configuration
|
* Saves the current configuration as the stored configuration
|
||||||
@@ -52,9 +89,9 @@ public class EventLogComponentEditor extends ChannelConfigurationEditor
|
|||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if( mChannel != null )
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
EventLogConfiguration config = mChannel.getEventLogConfiguration();
|
EventLogConfiguration config = getItem().getEventLogConfiguration();
|
||||||
|
|
||||||
config.clear();
|
config.clear();
|
||||||
|
|
||||||
@@ -71,31 +108,45 @@ public class EventLogComponentEditor extends ChannelConfigurationEditor
|
|||||||
config.addLogger( EventLogType.CALL_EVENT );
|
config.addLogger( EventLogType.CALL_EVENT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setConfiguration( Channel channel )
|
public void setItem( Channel channel )
|
||||||
{
|
{
|
||||||
mChannel = channel;
|
super.setItem( channel );
|
||||||
|
|
||||||
if( mChannel != null )
|
if( hasItem() )
|
||||||
{
|
{
|
||||||
List<EventLogType> loggers = mChannel.getEventLogConfiguration().getLoggers();
|
setControlsEnabled( true );
|
||||||
|
|
||||||
|
List<EventLogType> loggers = getItem().getEventLogConfiguration().getLoggers();
|
||||||
mBinaryLogger.setSelected( loggers.contains( EventLogType.BINARY_MESSAGE ) );
|
mBinaryLogger.setSelected( loggers.contains( EventLogType.BINARY_MESSAGE ) );
|
||||||
mDecodedLogger.setSelected( loggers.contains( EventLogType.DECODED_MESSAGE ) );
|
mDecodedLogger.setSelected( loggers.contains( EventLogType.DECODED_MESSAGE ) );
|
||||||
mCallEventLogger.setSelected( loggers.contains( EventLogType.CALL_EVENT ) );
|
mCallEventLogger.setSelected( loggers.contains( EventLogType.CALL_EVENT ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mBinaryLogger.setSelected( false );
|
setControlsEnabled( false );
|
||||||
mDecodedLogger.setSelected( false );
|
|
||||||
mCallEventLogger.setSelected( false );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setControlsEnabled( boolean enabled )
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
{
|
||||||
|
if( mBinaryLogger.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mBinaryLogger.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mDecodedLogger.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mDecodedLogger.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mCallEventLogger.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mCallEventLogger.setEnabled( enabled );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 record;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import record.config.RecordConfiguration;
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
|
|
||||||
public class RecordComponentEditor extends ChannelConfigurationEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JCheckBox mAudioRecorder = new JCheckBox( "Audio" );
|
|
||||||
private JCheckBox mBasebandRecorder = new JCheckBox( "Baseband I/Q" );
|
|
||||||
private JCheckBox mTrafficBasebandRecorder = new JCheckBox( "Traffic Channel Baseband I/Q" );
|
|
||||||
|
|
||||||
private Channel mChannel;
|
|
||||||
|
|
||||||
public RecordComponentEditor()
|
|
||||||
{
|
|
||||||
setLayout( new MigLayout( "fill,wrap 1", "[]", "[][][][grow]" ) );
|
|
||||||
|
|
||||||
add( mAudioRecorder );
|
|
||||||
add( mBasebandRecorder );
|
|
||||||
add( mTrafficBasebandRecorder );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
if( mChannel != null )
|
|
||||||
{
|
|
||||||
RecordConfiguration config = mChannel.getRecordConfiguration();
|
|
||||||
|
|
||||||
config.clearRecorders();
|
|
||||||
|
|
||||||
if( mAudioRecorder.isSelected() )
|
|
||||||
{
|
|
||||||
config.addRecorder( RecorderType.AUDIO );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mBasebandRecorder.isSelected() )
|
|
||||||
{
|
|
||||||
config.addRecorder( RecorderType.BASEBAND );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mTrafficBasebandRecorder.isSelected() )
|
|
||||||
{
|
|
||||||
config.addRecorder( RecorderType.TRAFFIC_BASEBAND );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
mChannel = channel;
|
|
||||||
|
|
||||||
if( mChannel != null )
|
|
||||||
{
|
|
||||||
List<RecorderType> recorders = mChannel.getRecordConfiguration().getRecorders();
|
|
||||||
|
|
||||||
mAudioRecorder.setSelected( recorders.contains( RecorderType.AUDIO ) );
|
|
||||||
mBasebandRecorder.setSelected( recorders.contains( RecorderType.BASEBAND ) );
|
|
||||||
mTrafficBasebandRecorder.setSelected( recorders.contains( RecorderType.TRAFFIC_BASEBAND ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mAudioRecorder.setSelected( false );
|
|
||||||
mBasebandRecorder.setSelected( false );
|
|
||||||
mTrafficBasebandRecorder.setSelected( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
152
src/record/RecordConfigurationEditor.java
Normal file
152
src/record/RecordConfigurationEditor.java
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 record;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import record.config.RecordConfiguration;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
|
||||||
|
public class RecordConfigurationEditor extends Editor<Channel>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private JCheckBox mAudioRecorder;
|
||||||
|
private JCheckBox mBasebandRecorder;
|
||||||
|
private JCheckBox mTrafficBasebandRecorder;
|
||||||
|
|
||||||
|
public RecordConfigurationEditor()
|
||||||
|
{
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 4", "", "[][grow]" ) );
|
||||||
|
|
||||||
|
mAudioRecorder = new JCheckBox( "Audio" );
|
||||||
|
mAudioRecorder.setEnabled( false );
|
||||||
|
mAudioRecorder.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mAudioRecorder );
|
||||||
|
|
||||||
|
mBasebandRecorder = new JCheckBox( "Baseband I/Q" );
|
||||||
|
mBasebandRecorder.setEnabled( false );
|
||||||
|
mBasebandRecorder.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mBasebandRecorder );
|
||||||
|
|
||||||
|
mTrafficBasebandRecorder = new JCheckBox( "Traffic Channel Baseband I/Q" );
|
||||||
|
mTrafficBasebandRecorder.setEnabled( false );
|
||||||
|
mTrafficBasebandRecorder.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
add( mTrafficBasebandRecorder );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setControlsEnabled( boolean enabled )
|
||||||
|
{
|
||||||
|
if( mAudioRecorder.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mAudioRecorder.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mBasebandRecorder.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mBasebandRecorder.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mTrafficBasebandRecorder.isEnabled() != enabled )
|
||||||
|
{
|
||||||
|
mTrafficBasebandRecorder.setEnabled( enabled );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && isModified() )
|
||||||
|
{
|
||||||
|
RecordConfiguration config = getItem().getRecordConfiguration();
|
||||||
|
|
||||||
|
config.clearRecorders();
|
||||||
|
|
||||||
|
if( mAudioRecorder.isSelected() )
|
||||||
|
{
|
||||||
|
config.addRecorder( RecorderType.AUDIO );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mBasebandRecorder.isSelected() )
|
||||||
|
{
|
||||||
|
config.addRecorder( RecorderType.BASEBAND );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mTrafficBasebandRecorder.isSelected() )
|
||||||
|
{
|
||||||
|
config.addRecorder( RecorderType.TRAFFIC_BASEBAND );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( Channel channel )
|
||||||
|
{
|
||||||
|
super.setItem( channel );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
setControlsEnabled( true );
|
||||||
|
|
||||||
|
List<RecorderType> recorders = getItem().getRecordConfiguration().getRecorders();
|
||||||
|
mAudioRecorder.setSelected( recorders.contains( RecorderType.AUDIO ) );
|
||||||
|
mBasebandRecorder.setSelected( recorders.contains( RecorderType.BASEBAND ) );
|
||||||
|
mTrafficBasebandRecorder.setSelected( recorders.contains( RecorderType.TRAFFIC_BASEBAND ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setControlsEnabled( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 source;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
import source.config.SourceConfiguration;
|
|
||||||
|
|
||||||
public class EmptySourceEditor extends SourceEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public EmptySourceEditor( SourceManager resourceManager,
|
|
||||||
SourceConfiguration config )
|
|
||||||
{
|
|
||||||
super( resourceManager, config );
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {}
|
|
||||||
|
|
||||||
public void save() {}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
JLabel selectLabel = new JLabel( "Please select a source" );
|
|
||||||
add( selectLabel );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 source;
|
|
||||||
|
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import source.config.SourceConfigFactory;
|
|
||||||
import source.config.SourceConfiguration;
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
|
|
||||||
public class SourceComponentEditor extends ChannelConfigurationEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private JComboBox<SourceType> mComboSources;
|
|
||||||
private SourceEditor mEditor;
|
|
||||||
private SourceManager mSourceManager;
|
|
||||||
private Channel mChannel = null;
|
|
||||||
|
|
||||||
public SourceComponentEditor( SourceManager sourceManager )
|
|
||||||
{
|
|
||||||
mSourceManager = sourceManager;
|
|
||||||
|
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) );
|
|
||||||
|
|
||||||
mComboSources = new JComboBox<SourceType>();
|
|
||||||
mComboSources.setModel( new DefaultComboBoxModel<SourceType>( SourceType.values() ) );
|
|
||||||
mComboSources.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
SourceType selected = mComboSources.getItemAt( mComboSources.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
SourceConfiguration config;
|
|
||||||
|
|
||||||
if( mChannel == null ||
|
|
||||||
mChannel.getSourceConfiguration().getSourceType() != selected )
|
|
||||||
{
|
|
||||||
config = SourceConfigFactory.getSourceConfiguration( selected );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
config = mChannel.getSourceConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Remove the existing one
|
|
||||||
if( mEditor != null )
|
|
||||||
{
|
|
||||||
remove( mEditor );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Change to the new one
|
|
||||||
mEditor = mSourceManager.getPanel( config );
|
|
||||||
|
|
||||||
//Add it to the jpanel
|
|
||||||
add( mEditor, "span 2" );
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
add( new JLabel( "Source:" ) );
|
|
||||||
add( mComboSources, "wrap" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public SourceEditor getSourceEditor()
|
|
||||||
{
|
|
||||||
return mEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
mEditor.save();
|
|
||||||
|
|
||||||
//Let the calling save method send the config change event
|
|
||||||
mChannel.setSourceConfiguration( mEditor.getConfig() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the channel configuration. Note: this method must be invoked from
|
|
||||||
* the swing event dispatch thread.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
mChannel = channel;
|
|
||||||
|
|
||||||
if( mChannel != null )
|
|
||||||
{
|
|
||||||
mComboSources.setSelectedItem(
|
|
||||||
mChannel.getSourceConfiguration().getSourceType() );
|
|
||||||
|
|
||||||
mComboSources.requestFocus();
|
|
||||||
|
|
||||||
mComboSources.requestFocusInWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
128
src/source/SourceConfigurationEditor.java
Normal file
128
src/source/SourceConfigurationEditor.java
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 source;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
import gui.editor.EmptyEditor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import source.mixer.MixerSourceEditor;
|
||||||
|
import source.tuner.TunerSourceEditor;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
|
||||||
|
public class SourceConfigurationEditor extends Editor<Channel>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private JComboBox<SourceType> mComboSources;
|
||||||
|
private MixerSourceEditor mMixerSourceEditor;
|
||||||
|
private TunerSourceEditor mTunerSourceEditor;
|
||||||
|
private Editor<Channel> mCurrentEditor;
|
||||||
|
|
||||||
|
public SourceConfigurationEditor( SourceManager sourceManager )
|
||||||
|
{
|
||||||
|
mMixerSourceEditor = new MixerSourceEditor( sourceManager );
|
||||||
|
mTunerSourceEditor = new TunerSourceEditor();
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 3", "[right][left][grow,fill]", "[][grow]" ) );
|
||||||
|
|
||||||
|
mComboSources = new JComboBox<SourceType>();
|
||||||
|
mComboSources.setModel( new DefaultComboBoxModel<SourceType>( SourceType.getTypes() ) );
|
||||||
|
mComboSources.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
SourceType selected = (SourceType)mComboSources.getSelectedItem();
|
||||||
|
|
||||||
|
switch( selected )
|
||||||
|
{
|
||||||
|
case MIXER:
|
||||||
|
setEditor( mMixerSourceEditor );
|
||||||
|
break;
|
||||||
|
case TUNER:
|
||||||
|
setEditor( mTunerSourceEditor );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setEditor( new EmptyEditor<Channel>() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add( new JLabel( "Source:" ) );
|
||||||
|
add( mComboSources );
|
||||||
|
|
||||||
|
mCurrentEditor = mTunerSourceEditor;
|
||||||
|
add( mCurrentEditor );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEditor( Editor<Channel> editor )
|
||||||
|
{
|
||||||
|
if( mCurrentEditor != editor )
|
||||||
|
{
|
||||||
|
remove( mCurrentEditor );
|
||||||
|
mCurrentEditor = editor;
|
||||||
|
add( mCurrentEditor );
|
||||||
|
|
||||||
|
revalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && mCurrentEditor.isModified() )
|
||||||
|
{
|
||||||
|
mCurrentEditor.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModified()
|
||||||
|
{
|
||||||
|
return super.isModified() || mCurrentEditor.isModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the channel configuration. Note: this method must be invoked from
|
||||||
|
* the swing event dispatch thread.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setItem( Channel channel )
|
||||||
|
{
|
||||||
|
super.setItem( channel );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
mMixerSourceEditor.setItem( channel );
|
||||||
|
mTunerSourceEditor.setItem( channel );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 source;
|
|
||||||
|
|
||||||
import source.config.SourceConfiguration;
|
|
||||||
import controller.channel.ChannelConfigurationEditor;
|
|
||||||
|
|
||||||
public abstract class SourceEditor extends ChannelConfigurationEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
protected SourceManager mSourceManager;
|
|
||||||
protected SourceConfiguration mConfig;
|
|
||||||
|
|
||||||
public SourceEditor( SourceManager sourceManager, SourceConfiguration config )
|
|
||||||
{
|
|
||||||
mSourceManager = sourceManager;
|
|
||||||
mConfig = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SourceConfiguration getConfig()
|
|
||||||
{
|
|
||||||
return mConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SourceManager getSourceManager()
|
|
||||||
{
|
|
||||||
return mSourceManager;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,11 +20,8 @@ package source;
|
|||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.config.SourceConfigTuner;
|
import source.config.SourceConfigTuner;
|
||||||
import source.config.SourceConfiguration;
|
import source.config.SourceConfiguration;
|
||||||
import source.mixer.MixerEditor;
|
|
||||||
import source.mixer.MixerManager;
|
import source.mixer.MixerManager;
|
||||||
import source.recording.RecordingEditor;
|
|
||||||
import source.recording.RecordingSourceManager;
|
import source.recording.RecordingSourceManager;
|
||||||
import source.tuner.TunerEditorOld;
|
|
||||||
import source.tuner.TunerManager;
|
import source.tuner.TunerManager;
|
||||||
import source.tuner.TunerModel;
|
import source.tuner.TunerModel;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
@@ -86,28 +83,4 @@ public class SourceManager
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceEditor getPanel( SourceConfiguration config )
|
|
||||||
{
|
|
||||||
SourceEditor configuredPanel;
|
|
||||||
|
|
||||||
switch( config.getSourceType() )
|
|
||||||
{
|
|
||||||
case MIXER:
|
|
||||||
configuredPanel = new MixerEditor( this, config );
|
|
||||||
break;
|
|
||||||
case TUNER:
|
|
||||||
configuredPanel = new TunerEditorOld( this, config );
|
|
||||||
break;
|
|
||||||
case RECORDING:
|
|
||||||
configuredPanel = new RecordingEditor( this, config );
|
|
||||||
break;
|
|
||||||
case NONE:
|
|
||||||
default:
|
|
||||||
configuredPanel = new EmptySourceEditor( this, config );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return configuredPanel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,11 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source;
|
package source;
|
||||||
|
|
||||||
|
|
||||||
public enum SourceType
|
public enum SourceType
|
||||||
{
|
{
|
||||||
NONE( "No Source" ),
|
NONE( "No Source" ),
|
||||||
MIXER( "Mixer/Sound Card" ),
|
MIXER( "Sound Card" ),
|
||||||
TUNER( "Tuner" ),
|
TUNER( "Tuner" ),
|
||||||
RECORDING( "IQ Recording" );
|
RECORDING( "IQ Recording" );
|
||||||
|
|
||||||
@@ -31,6 +32,15 @@ public enum SourceType
|
|||||||
mDisplayString = displayString;
|
mDisplayString = displayString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SourceType[] getTypes()
|
||||||
|
{
|
||||||
|
SourceType[] types = new SourceType[ 2 ];
|
||||||
|
types[ 0 ] = SourceType.TUNER;
|
||||||
|
types[ 1 ] = SourceType.MIXER;
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplayString()
|
public String getDisplayString()
|
||||||
{
|
{
|
||||||
return mDisplayString;
|
return mDisplayString;
|
||||||
|
|||||||
@@ -26,21 +26,17 @@ public class SourceConfigFactory
|
|||||||
return getSourceConfiguration( SourceType.TUNER );
|
return getSourceConfiguration( SourceType.TUNER );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SourceConfiguration
|
public static SourceConfiguration getSourceConfiguration( SourceType source )
|
||||||
getSourceConfiguration( SourceType source )
|
|
||||||
{
|
{
|
||||||
SourceConfiguration retVal;
|
SourceConfiguration retVal;
|
||||||
|
|
||||||
switch( source )
|
switch( source )
|
||||||
{
|
{
|
||||||
case MIXER:
|
|
||||||
retVal = new SourceConfigMixer();
|
|
||||||
break;
|
|
||||||
case TUNER:
|
case TUNER:
|
||||||
retVal = new SourceConfigTuner();
|
retVal = new SourceConfigTuner();
|
||||||
break;
|
break;
|
||||||
case RECORDING:
|
case MIXER:
|
||||||
retVal = new SourceConfigRecording();
|
retVal = new SourceConfigMixer();
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -30,7 +30,7 @@ public class SourceConfigTuner extends SourceConfiguration
|
|||||||
private static DecimalFormat sFORMAT = new DecimalFormat( "0.00000" );
|
private static DecimalFormat sFORMAT = new DecimalFormat( "0.00000" );
|
||||||
|
|
||||||
private long mFrequency = 0;
|
private long mFrequency = 0;
|
||||||
private int mBandwidth = 15000;
|
private int mBandwidth = 12500;
|
||||||
|
|
||||||
public SourceConfigTuner()
|
public SourceConfigTuner()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,175 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 source.mixer;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
import javax.sound.sampled.Mixer;
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
import source.SourceEditor;
|
|
||||||
import source.SourceManager;
|
|
||||||
import source.config.SourceConfigMixer;
|
|
||||||
import source.config.SourceConfiguration;
|
|
||||||
import source.mixer.MixerManager.InputMixerConfiguration;
|
|
||||||
|
|
||||||
public class MixerEditor extends SourceEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private JComboBox<InputMixerConfiguration> mComboMixers;
|
|
||||||
private JComboBox<MixerChannel>mComboChannels;
|
|
||||||
protected Mixer.Info mSelectedMixer = null;
|
|
||||||
|
|
||||||
|
|
||||||
public MixerEditor( SourceManager sourceManager,
|
|
||||||
SourceConfiguration config )
|
|
||||||
{
|
|
||||||
super( sourceManager, config );
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
JLabel mixerLabel = new JLabel( "Mixer:" );
|
|
||||||
add( mixerLabel, "align right" );
|
|
||||||
|
|
||||||
mComboMixers = new JComboBox<InputMixerConfiguration>();
|
|
||||||
|
|
||||||
add( mComboMixers, "wrap" );
|
|
||||||
|
|
||||||
resetMixers();
|
|
||||||
|
|
||||||
JLabel channelLabel = new JLabel( "Channel:" );
|
|
||||||
add( channelLabel, "align right" );
|
|
||||||
|
|
||||||
mComboChannels = new JComboBox<MixerChannel>();
|
|
||||||
|
|
||||||
add( mComboChannels, "wrap" );
|
|
||||||
|
|
||||||
resetChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
resetMixers();
|
|
||||||
resetChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
SourceConfigMixer config = (SourceConfigMixer)mConfig;
|
|
||||||
|
|
||||||
InputMixerConfiguration selectedMixer =
|
|
||||||
mComboMixers.getItemAt( mComboMixers.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( selectedMixer != null )
|
|
||||||
{
|
|
||||||
config.setMixer( selectedMixer.getMixerName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
MixerChannel channel = mComboChannels.getItemAt(
|
|
||||||
mComboChannels.getSelectedIndex() );
|
|
||||||
|
|
||||||
if( channel != null )
|
|
||||||
{
|
|
||||||
if( config.getChannel() != channel )
|
|
||||||
{
|
|
||||||
config.setChannel( channel );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetMixers()
|
|
||||||
{
|
|
||||||
|
|
||||||
javax.swing.SwingUtilities.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
InputMixerConfiguration[] mixers = mSourceManager
|
|
||||||
.getMixerManager().getInputMixers();
|
|
||||||
|
|
||||||
mComboMixers.setModel(
|
|
||||||
new DefaultComboBoxModel<InputMixerConfiguration>( mixers ) );
|
|
||||||
|
|
||||||
SourceConfigMixer config = (SourceConfigMixer)mConfig;
|
|
||||||
|
|
||||||
String mixer = config.getMixer();
|
|
||||||
|
|
||||||
if( mixer != null )
|
|
||||||
{
|
|
||||||
mComboMixers.setSelectedItem( mixer );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Mixer either hasn't been set yet, or it was set to a
|
|
||||||
//mixer that is no longer available. Set the mixer to the
|
|
||||||
//first item, and then store the value
|
|
||||||
if( mixers.length > 0 )
|
|
||||||
{
|
|
||||||
mComboMixers.setSelectedIndex( 0 );
|
|
||||||
|
|
||||||
InputMixerConfiguration selectedMixer =
|
|
||||||
(InputMixerConfiguration)mComboMixers.getSelectedItem();
|
|
||||||
|
|
||||||
config.setMixer( selectedMixer.getMixerName() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetChannels()
|
|
||||||
{
|
|
||||||
javax.swing.SwingUtilities.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
EnumSet<MixerChannel> channels = MixerChannel.getTargetChannels();
|
|
||||||
|
|
||||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
|
||||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
|
||||||
|
|
||||||
MixerChannel channel = ((SourceConfigMixer)mConfig).getChannel();
|
|
||||||
|
|
||||||
mComboChannels.setSelectedItem( channel );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
155
src/source/mixer/MixerSourceEditor.java
Normal file
155
src/source/mixer/MixerSourceEditor.java
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 source.mixer;
|
||||||
|
|
||||||
|
import gui.editor.Editor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import source.SourceManager;
|
||||||
|
import source.config.SourceConfigMixer;
|
||||||
|
import source.config.SourceConfiguration;
|
||||||
|
import source.mixer.MixerManager.InputMixerConfiguration;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
|
||||||
|
public class MixerSourceEditor extends Editor<Channel>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JComboBox<InputMixerConfiguration> mComboMixers;
|
||||||
|
private JComboBox<MixerChannel>mComboChannels;
|
||||||
|
|
||||||
|
private SourceManager mSourceManager;
|
||||||
|
|
||||||
|
public MixerSourceEditor( SourceManager sourceManager )
|
||||||
|
{
|
||||||
|
mSourceManager = sourceManager;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]", "[][grow]" ) );
|
||||||
|
|
||||||
|
mComboMixers = new JComboBox<InputMixerConfiguration>();
|
||||||
|
InputMixerConfiguration[] inputMixers = mSourceManager.getMixerManager().getInputMixers();
|
||||||
|
mComboMixers.setModel( new DefaultComboBoxModel<InputMixerConfiguration>( inputMixers ) );
|
||||||
|
mComboMixers.setEnabled( false );
|
||||||
|
mComboMixers.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
InputMixerConfiguration selected = (InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||||
|
|
||||||
|
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||||
|
|
||||||
|
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||||
|
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||||
|
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( new JLabel( "Mixer:" ) );
|
||||||
|
add( mComboMixers );
|
||||||
|
|
||||||
|
mComboChannels = new JComboBox<MixerChannel>();
|
||||||
|
mComboChannels.setEnabled( false );
|
||||||
|
mComboChannels.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( new JLabel( "Channel:" ) );
|
||||||
|
add( mComboChannels );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem( Channel item )
|
||||||
|
{
|
||||||
|
super.setItem( item );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
mComboMixers.setEnabled( true );
|
||||||
|
mComboChannels.setEnabled( true );
|
||||||
|
|
||||||
|
SourceConfiguration config = item.getSourceConfiguration();
|
||||||
|
|
||||||
|
if( config instanceof SourceConfigMixer )
|
||||||
|
{
|
||||||
|
SourceConfigMixer mixer = (SourceConfigMixer)config;
|
||||||
|
|
||||||
|
for( InputMixerConfiguration inputMixer: mSourceManager.getMixerManager().getInputMixers() )
|
||||||
|
{
|
||||||
|
if( inputMixer.getMixerName().equalsIgnoreCase( mixer.getMixer() ) )
|
||||||
|
{
|
||||||
|
mComboMixers.setSelectedItem( inputMixer );
|
||||||
|
|
||||||
|
for( MixerChannel channel: inputMixer.getChannels() )
|
||||||
|
{
|
||||||
|
if( channel.getLabel().equalsIgnoreCase( mixer.getChannel().getLabel() ) )
|
||||||
|
{
|
||||||
|
mComboChannels.setSelectedItem( channel );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mComboMixers.setEnabled( false );
|
||||||
|
mComboChannels.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
if( hasItem() && isModified() )
|
||||||
|
{
|
||||||
|
SourceConfigMixer config = new SourceConfigMixer();
|
||||||
|
|
||||||
|
InputMixerConfiguration selected =
|
||||||
|
(InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||||
|
config.setMixer( selected.getMixerName() );
|
||||||
|
|
||||||
|
MixerChannel channel = (MixerChannel)mComboChannels.getSelectedItem();
|
||||||
|
config.setChannel( channel );
|
||||||
|
|
||||||
|
getItem().setSourceConfiguration( config );
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* 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 source.recording;
|
|
||||||
|
|
||||||
import gui.control.JFrequencyControl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
import source.SourceEditor;
|
|
||||||
import source.SourceManager;
|
|
||||||
import source.config.SourceConfigRecording;
|
|
||||||
import source.config.SourceConfigTuner;
|
|
||||||
import source.config.SourceConfiguration;
|
|
||||||
|
|
||||||
public class RecordingEditor extends SourceEditor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private JComboBox<Recording> mComboRecordings;
|
|
||||||
private JFrequencyControl mFrequencyControl;
|
|
||||||
|
|
||||||
public RecordingEditor( SourceManager sourceManager, SourceConfiguration config )
|
|
||||||
{
|
|
||||||
super( sourceManager, config );
|
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
mFrequencyControl.setFrequency(
|
|
||||||
((SourceConfigTuner)mConfig).getFrequency(), false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
SourceConfigRecording config = (SourceConfigRecording)mConfig;
|
|
||||||
|
|
||||||
Recording selected = (Recording)mComboRecordings.getSelectedItem();
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
config.setRecordingAlias( selected
|
|
||||||
.getRecordingConfiguration().getAlias() );
|
|
||||||
}
|
|
||||||
|
|
||||||
config.setFrequency( mFrequencyControl.getFrequency() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
|
||||||
add( new JLabel( "Recording" ) );
|
|
||||||
|
|
||||||
mComboRecordings = new JComboBox<Recording>();
|
|
||||||
|
|
||||||
add( mComboRecordings, "wrap" );
|
|
||||||
|
|
||||||
mFrequencyControl = new JFrequencyControl();
|
|
||||||
|
|
||||||
mFrequencyControl.setFrequency(
|
|
||||||
((SourceConfigRecording)mConfig).getFrequency(), false );
|
|
||||||
|
|
||||||
add( mFrequencyControl, "span" );
|
|
||||||
|
|
||||||
resetRecordings();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetRecordings()
|
|
||||||
{
|
|
||||||
SwingUtilities.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
List<Recording> recordings = getSourceManager()
|
|
||||||
.getRecordingSourceManager().getRecordings();
|
|
||||||
|
|
||||||
mComboRecordings.setModel(
|
|
||||||
new DefaultComboBoxModel<Recording>(
|
|
||||||
recordings.toArray( new Recording[ recordings.size()] ) ) );
|
|
||||||
|
|
||||||
SourceConfigRecording config = (SourceConfigRecording)mConfig;
|
|
||||||
|
|
||||||
String recordingAlias = config.getRecordingAlias();
|
|
||||||
|
|
||||||
if( recordingAlias != null )
|
|
||||||
{
|
|
||||||
Recording selected = mSourceManager
|
|
||||||
.getRecordingSourceManager()
|
|
||||||
.getRecordingFromAlias( recordingAlias );
|
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
|
||||||
mComboRecordings.setSelectedItem( selected );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,59 +17,74 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner;
|
package source.tuner;
|
||||||
|
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ConfigurationValidationException;
|
|
||||||
import gui.control.JFrequencyControl;
|
import gui.control.JFrequencyControl;
|
||||||
import source.SourceEditor;
|
import gui.editor.Editor;
|
||||||
import source.SourceManager;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import source.config.SourceConfigTuner;
|
import source.config.SourceConfigTuner;
|
||||||
import source.config.SourceConfiguration;
|
import source.config.SourceConfiguration;
|
||||||
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||||
|
import controller.channel.Channel;
|
||||||
|
|
||||||
public class TunerEditorOld extends SourceEditor
|
public class TunerSourceEditor extends Editor<Channel>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private JFrequencyControl mFrequencyControl;
|
private JFrequencyControl mFrequencyControl;
|
||||||
|
|
||||||
public TunerEditorOld( SourceManager sourceManager,
|
public TunerSourceEditor()
|
||||||
SourceConfiguration config )
|
|
||||||
{
|
{
|
||||||
super( sourceManager, config );
|
init();
|
||||||
|
|
||||||
initGUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset()
|
private void init()
|
||||||
{
|
|
||||||
mFrequencyControl.setFrequency(
|
|
||||||
((SourceConfigTuner)mConfig).getFrequency(), false );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
((SourceConfigTuner)mConfig).setFrequency( mFrequencyControl.getFrequency() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGUI()
|
|
||||||
{
|
{
|
||||||
|
setLayout( new MigLayout( "fill", "[left]", "[][grow]" ) );
|
||||||
mFrequencyControl = new JFrequencyControl();
|
mFrequencyControl = new JFrequencyControl();
|
||||||
|
mFrequencyControl.setEnabled( false );
|
||||||
mFrequencyControl.setFrequency(
|
mFrequencyControl.addListener( new IFrequencyChangeProcessor()
|
||||||
((SourceConfigTuner)mConfig).getFrequency(), false );
|
{
|
||||||
|
@Override
|
||||||
|
public void frequencyChanged( FrequencyChangeEvent event )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
add( mFrequencyControl );
|
add( mFrequencyControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void save()
|
||||||
public void setConfiguration( Channel channel )
|
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
if( hasItem() && isModified() )
|
||||||
|
{
|
||||||
}
|
SourceConfigTuner config = new SourceConfigTuner();
|
||||||
|
config.setFrequency( mFrequencyControl.getFrequency() );
|
||||||
|
getItem().setSourceConfiguration( config );
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateConfiguration() throws ConfigurationValidationException
|
public void setItem( Channel item )
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
super.setItem( item );
|
||||||
|
|
||||||
|
if( hasItem() )
|
||||||
|
{
|
||||||
|
SourceConfiguration config = getItem().getSourceConfiguration();
|
||||||
|
|
||||||
|
if( config instanceof SourceConfigTuner )
|
||||||
|
{
|
||||||
|
mFrequencyControl.setFrequency( ((SourceConfigTuner)config).getFrequency(), false );
|
||||||
|
}
|
||||||
|
|
||||||
|
mFrequencyControl.setEnabled( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mFrequencyControl.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user