mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Work in progress - updates channel component editors and changes
functionality so that the editor starts up without a channel displayed and as each channel row is selected in the channels table, the editor is updated with the channel configuration. Likewise, the channel editor is now a channel event listener on the channel model and will maintain channel state if the user changes channel configuration in any of the external channel controllers like the spectral display or the channel list.
This commit is contained in:
@@ -17,84 +17,70 @@
|
||||
******************************************************************************/
|
||||
package module.decode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import module.decode.config.AuxDecodeConfiguration;
|
||||
import controller.channel.AbstractChannelEditor;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelConfigurationEditor;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
|
||||
public class AuxDecodeComponentEditor extends AbstractChannelEditor
|
||||
public class AuxDecodeComponentEditor extends ChannelConfigurationEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private HashMap<DecoderType,AuxDecoderCheckBox> mControls =
|
||||
new HashMap<DecoderType,AuxDecoderCheckBox>();
|
||||
private List<AuxDecoderCheckBox> mControls = new ArrayList<>();
|
||||
|
||||
public AuxDecodeComponentEditor( Channel channel )
|
||||
private Channel mChannel;
|
||||
|
||||
public AuxDecodeComponentEditor()
|
||||
{
|
||||
super( channel );
|
||||
|
||||
List<DecoderType> decoders = DecoderType.getAuxDecoders();
|
||||
|
||||
Collections.sort( decoders );
|
||||
|
||||
|
||||
for( DecoderType decoder: decoders )
|
||||
{
|
||||
AuxDecoderCheckBox control = new AuxDecoderCheckBox( decoder );
|
||||
|
||||
if( getConfig().getAuxDecoders().contains( decoder ) )
|
||||
{
|
||||
control.setSelected( true );
|
||||
}
|
||||
|
||||
add( control, "wrap" );
|
||||
|
||||
mControls.put( decoder, control );
|
||||
mControls.add( control );
|
||||
}
|
||||
}
|
||||
|
||||
public AuxDecodeConfiguration getConfig()
|
||||
{
|
||||
return getChannel().getAuxDecodeConfiguration();
|
||||
if( mChannel != null )
|
||||
{
|
||||
return mChannel.getAuxDecodeConfiguration();
|
||||
}
|
||||
|
||||
return new AuxDecodeConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
getConfig().clearAuxDecoders();
|
||||
|
||||
for( DecoderType decoder: mControls.keySet() )
|
||||
if( mChannel != null )
|
||||
{
|
||||
if( mControls.get( decoder ) .isSelected() )
|
||||
AuxDecodeConfiguration config = mChannel.getAuxDecodeConfiguration();
|
||||
|
||||
config.clearAuxDecoders();
|
||||
|
||||
for( AuxDecoderCheckBox checkBox: mControls )
|
||||
{
|
||||
getConfig().addAuxDecoder( decoder );
|
||||
if( checkBox.isSelected() )
|
||||
{
|
||||
config.addAuxDecoder( checkBox.getDecoderType() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for( DecoderType decoder: mControls.keySet() )
|
||||
{
|
||||
mControls.get( decoder ).setSelected(
|
||||
getConfig().getAuxDecoders().contains( decoder ) );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public class AuxDecoderCheckBox extends JCheckBox
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -107,19 +93,35 @@ public class AuxDecodeComponentEditor extends AbstractChannelEditor
|
||||
|
||||
mDecoderType = decoder;
|
||||
}
|
||||
|
||||
public DecoderType getDecoderType()
|
||||
{
|
||||
return mDecoderType;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
mChannel = channel;
|
||||
|
||||
for( AuxDecoderCheckBox checkBox: mControls )
|
||||
{
|
||||
if( mChannel != null &&
|
||||
mChannel.getAuxDecodeConfiguration().getAuxDecoders()
|
||||
.contains( checkBox.getDecoderType() ) )
|
||||
{
|
||||
checkBox.setSelected( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBox.setSelected( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConfiguration() throws ConfigurationValidationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/*******************************************************************************
|
||||
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
@@ -24,43 +23,38 @@ import java.awt.event.ActionListener;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import module.decode.config.DecodeConfigFactory;
|
||||
import module.decode.config.DecodeConfiguration;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import playlist.PlaylistManager;
|
||||
import controller.channel.AbstractChannelEditor;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelConfigurationEditor;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
|
||||
public class DecodeComponentEditor extends AbstractChannelEditor
|
||||
public class DecodeComponentEditor extends ChannelConfigurationEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( DecodeComponentEditor.class );
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PlaylistManager mPlaylistManager;
|
||||
private JComboBox<DecoderType> mComboDecoders;
|
||||
|
||||
private DecodeEditor mEditor;
|
||||
|
||||
private PlaylistManager mPlaylistManager;
|
||||
|
||||
private Channel mChannel;
|
||||
|
||||
public DecodeComponentEditor( PlaylistManager playlistManager )
|
||||
{
|
||||
this( playlistManager, new Channel() );
|
||||
}
|
||||
|
||||
public DecodeComponentEditor( PlaylistManager playlistMangager, Channel channel )
|
||||
{
|
||||
super( channel );
|
||||
mPlaylistManager = playlistManager;
|
||||
|
||||
mPlaylistManager = playlistMangager;
|
||||
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) );
|
||||
|
||||
/**
|
||||
* ComboBox: Decoders
|
||||
*/
|
||||
mComboDecoders = new JComboBox<DecoderType>();
|
||||
|
||||
DefaultComboBoxModel<DecoderType> model =
|
||||
@@ -84,14 +78,15 @@ public class DecodeComponentEditor extends AbstractChannelEditor
|
||||
if( selected != null )
|
||||
{
|
||||
DecodeConfiguration config;
|
||||
|
||||
if( mChannel.getDecodeConfiguration().getDecoderType() == selected )
|
||||
|
||||
if( mChannel == null ||
|
||||
mChannel.getDecodeConfiguration().getDecoderType() != selected )
|
||||
{
|
||||
config = mChannel.getDecodeConfiguration();
|
||||
config = DecodeConfigFactory.getDecodeConfiguration( selected );
|
||||
}
|
||||
else
|
||||
{
|
||||
config = DecodeConfigFactory.getDecodeConfiguration( selected );
|
||||
config = mChannel.getDecodeConfiguration();
|
||||
}
|
||||
|
||||
//Remove the existing one
|
||||
@@ -111,29 +106,11 @@ public class DecodeComponentEditor extends AbstractChannelEditor
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add( new JLabel( "Decoder:" ) );
|
||||
add( mComboDecoders, "wrap" );
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
final DecoderType decoder = mChannel.getDecodeConfiguration().getDecoderType();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
mComboDecoders.setSelectedItem( decoder );
|
||||
|
||||
mComboDecoders.requestFocus();
|
||||
|
||||
mComboDecoders.requestFocusInWindow();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public DecodeConfiguration getDecodeConfig()
|
||||
{
|
||||
return mEditor.getConfig();
|
||||
@@ -147,7 +124,6 @@ public class DecodeComponentEditor extends AbstractChannelEditor
|
||||
mEditor.save();
|
||||
}
|
||||
|
||||
//The component that calls save will invoke the change broadcast
|
||||
mChannel.setDecodeConfiguration( mEditor.getConfig() );
|
||||
}
|
||||
|
||||
@@ -165,14 +141,23 @@ public class DecodeComponentEditor extends AbstractChannelEditor
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,18 +106,25 @@ public class ChannelStatePanel extends JPanel
|
||||
ProcessingChain processingChain =
|
||||
channelProcessingManager.getProcessingChain( mChannel );
|
||||
|
||||
mChannelState = processingChain.getChannelState();
|
||||
|
||||
mChannelState.setChangedAttributeListener( this );
|
||||
|
||||
init();
|
||||
if( processingChain != null )
|
||||
{
|
||||
mChannelState = processingChain.getChannelState();
|
||||
|
||||
mChannelState.setChangedAttributeListener( this );
|
||||
|
||||
init();
|
||||
|
||||
for( DecoderState decoderState: processingChain.getDecoderStates() )
|
||||
{
|
||||
DecoderPanel panel = DecoderFactory.getDecoderPanel( mSettingsManager, decoderState );
|
||||
mDecoderPanels.add( panel );
|
||||
add( panel, "grow,span" );
|
||||
}
|
||||
for( DecoderState decoderState: processingChain.getDecoderStates() )
|
||||
{
|
||||
DecoderPanel panel = DecoderFactory.getDecoderPanel( mSettingsManager, decoderState );
|
||||
mDecoderPanels.add( panel );
|
||||
add( panel, "grow,span" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.error( "Processing Chain was null!" );
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
|
||||
Reference in New Issue
Block a user