34: Redesign Channel Management 

Task-Url: http://github.com/DSheirer/sdrtrunk/issues/issue/34
This commit is contained in:
denny
2016-03-17 21:16:21 -04:00
parent 6eade2b7ea
commit f518c15a06
5 changed files with 100 additions and 77 deletions

View File

@@ -14,8 +14,8 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.RowFilter; import javax.swing.RowFilter;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableRowSorter; import javax.swing.table.TableRowSorter;
@@ -25,8 +25,8 @@ import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import source.SourceException;
import source.tuner.configuration.TunerConfiguration; import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationEditor;
import source.tuner.configuration.TunerConfigurationFactory; import source.tuner.configuration.TunerConfigurationFactory;
import source.tuner.configuration.TunerConfigurationModel; import source.tuner.configuration.TunerConfigurationModel;
@@ -45,6 +45,9 @@ public class TunerEditor extends Editor<Tuner>
private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" ); private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" );
private JButton mNewConfigurationButton = new JButton( "New" ); private JButton mNewConfigurationButton = new JButton( "New" );
private JButton mDeleteConfigurationButton = new JButton( "Delete" ); private JButton mDeleteConfigurationButton = new JButton( "Delete" );
private JScrollPane mEditorScroller;
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>();
private JideSplitPane mEditorSplitPane = new JideSplitPane();
public TunerEditor( TunerConfigurationModel tunerConfigurationModel ) public TunerEditor( TunerConfigurationModel tunerConfigurationModel )
{ {
@@ -90,8 +93,10 @@ public class TunerEditor extends Editor<Tuner>
} }
} ); } );
JScrollPane tableScroller = new JScrollPane( mTunerConfigurationTable );
tableScroller.setHorizontalScrollBarPolicy( ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
listPanel.add( new JLabel( "Tuner Configurations" ), "span" ); listPanel.add( new JLabel( "Tuner Configurations" ), "span" );
listPanel.add( mTunerConfigurationTable, "span" ); listPanel.add( tableScroller, "span" );
mNewConfigurationButton.setEnabled( false ); mNewConfigurationButton.setEnabled( false );
mNewConfigurationButton.addActionListener( new ActionListener() mNewConfigurationButton.addActionListener( new ActionListener()
@@ -141,20 +146,18 @@ public class TunerEditor extends Editor<Tuner>
listPanel.add( mDeleteConfigurationButton ); listPanel.add( mDeleteConfigurationButton );
//Set preferred size on both scrollers to same width, so they split the space //Set preferred size on both scrollers to same width, so they split the space
listPanel.setPreferredSize( new Dimension( 100, 80 ) );
JScrollPane listScroller = new JScrollPane( listPanel ); JScrollPane listScroller = new JScrollPane( listPanel );
listScroller.setPreferredSize( new Dimension( 200, 80 ) ); listScroller.setPreferredSize( new Dimension( 100, 80 ) );
//TODO: this has to be changed mEditorScroller = new JScrollPane( mEditor );
JPanel editorPanel = new EmptyEditor<TunerConfiguration>(); mEditorScroller.setPreferredSize( new Dimension( 100, 80 ) );
JScrollPane editorScroller = new JScrollPane( editorPanel );
editorScroller.setPreferredSize( new Dimension( 200, 80 ) );
JideSplitPane splitPane = mEditorSplitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT ); mEditorSplitPane.add( listScroller );
splitPane.add( listScroller ); mEditorSplitPane.add( mEditorScroller );
splitPane.add( editorScroller );
add( splitPane ); add( mEditorSplitPane );
} }
@Override @Override
@@ -211,6 +214,9 @@ public class TunerEditor extends Editor<Tuner>
//Set the displayed frequency without adjusting the tuner's frequency //Set the displayed frequency without adjusting the tuner's frequency
mFrequencyControl.setFrequency( mFrequencyControl.setFrequency(
tuner.getTunerController().getFrequency(), false ); tuner.getTunerController().getFrequency(), false );
mEditor = TunerConfigurationFactory
.getEditor( getItem(), mTunerConfigurationModel );
} }
else else
{ {
@@ -219,19 +225,35 @@ public class TunerEditor extends Editor<Tuner>
mTunerConfigurationTable.setEnabled( false ); mTunerConfigurationTable.setEnabled( false );
mNewConfigurationButton.setEnabled( false ); mNewConfigurationButton.setEnabled( false );
mRowSorter.setRowFilter( null ); mRowSorter.setRowFilter( null );
mEditor = new EmptyEditor<TunerConfiguration>();
} }
//Swap out the editor
int split = mEditorSplitPane.getDividerLocation( 0 );
mEditorSplitPane.remove( mEditorScroller );
mEditorScroller = new JScrollPane( mEditor );
mEditorSplitPane.add( mEditorScroller );
mEditorSplitPane.setDividerLocation( 0, split );
} }
private void setConfigurationEditor( TunerConfiguration config ) private void setConfigurationEditor( TunerConfiguration config )
{ {
if( config != null ) if( config != null )
{ {
mDeleteConfigurationButton.setEnabled( true ); if( !mDeleteConfigurationButton.isEnabled() )
{
mDeleteConfigurationButton.setEnabled( true );
}
} }
else else
{ {
mDeleteConfigurationButton.setEnabled( false ); if( mDeleteConfigurationButton.isEnabled() )
{
mDeleteConfigurationButton.setEnabled( false );
}
} }
mEditor.setItem( config );
} }
public class ConfigurationRowFilter extends RowFilter<TunerConfigurationModel,Integer> public class ConfigurationRowFilter extends RowFilter<TunerConfigurationModel,Integer>

View File

@@ -1,6 +1,7 @@
package source.tuner.configuration; package source.tuner.configuration;
import gui.editor.Editor; import gui.editor.Editor;
import source.tuner.TunerType;
public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration> public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration>
{ {
@@ -13,6 +14,8 @@ public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration
mTunerConfigurationModel = model; mTunerConfigurationModel = model;
} }
public abstract boolean canEdit( TunerType tunerType );
public TunerConfigurationModel getTunerConfigurationModel() public TunerConfigurationModel getTunerConfigurationModel()
{ {
return mTunerConfigurationModel; return mTunerConfigurationModel;

View File

@@ -1,5 +1,7 @@
package source.tuner.configuration; package source.tuner.configuration;
import gui.editor.Editor;
import gui.editor.EmptyEditor;
import source.tuner.Tuner; import source.tuner.Tuner;
import source.tuner.TunerType; import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerConfiguration; import source.tuner.airspy.AirspyTunerConfiguration;
@@ -36,7 +38,7 @@ public class TunerConfigurationFactory
} }
} }
public static TunerConfigurationEditor getEditor( Tuner tuner, public static Editor<TunerConfiguration> getEditor( Tuner tuner,
TunerConfigurationModel model ) TunerConfigurationModel model )
{ {
switch( tuner.getTunerType() ) switch( tuner.getTunerType() )
@@ -58,7 +60,7 @@ public class TunerConfigurationFactory
break; break;
} }
return null; return new EmptyEditor<TunerConfiguration>();
} }
} }

View File

@@ -3,16 +3,13 @@ package source.tuner.configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.RowFilter;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import sample.Listener; import sample.Listener;
import source.tuner.TunerType; import source.tuner.TunerType;
import source.tuner.TunerViewPanel;
import source.tuner.configuration.TunerConfigurationEvent.Event; import source.tuner.configuration.TunerConfigurationEvent.Event;
public class TunerConfigurationModel extends AbstractTableModel public class TunerConfigurationModel extends AbstractTableModel
@@ -237,12 +234,10 @@ public class TunerConfigurationModel extends AbstractTableModel
if( config.getTunerType() == type && if( config.getTunerType() == type &&
config.getName().contentEquals( name ) ) config.getName().contentEquals( name ) )
{ {
mLog.debug( "Returning true for name: " + name );
return true; return true;
} }
} }
mLog.debug( "Returning false for name: " + name );
return false; return false;
} }
@@ -382,5 +377,4 @@ public class TunerConfigurationModel extends AbstractTableModel
return null; return null;
} }
} }

View File

@@ -29,6 +29,7 @@ import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner; import javax.swing.JSpinner;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SpinnerModel; import javax.swing.SpinnerModel;
@@ -45,6 +46,7 @@ import org.slf4j.LoggerFactory;
import org.usb4java.LibUsbException; import org.usb4java.LibUsbException;
import source.SourceException; import source.SourceException;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration; import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationEditor; import source.tuner.configuration.TunerConfigurationEditor;
import source.tuner.configuration.TunerConfigurationEvent; import source.tuner.configuration.TunerConfigurationEvent;
@@ -85,6 +87,12 @@ public class R820TTunerEditor extends TunerConfigurationEditor
} }
@Override @Override
public boolean canEdit( TunerType tunerType )
{
return tunerType == TunerType.RAFAELMICRO_R820T;
}
@Override
public void save() public void save()
{ {
if( hasItem() ) if( hasItem() )
@@ -147,9 +155,10 @@ public class R820TTunerEditor extends TunerConfigurationEditor
private void init() private void init()
{ {
setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow]" ) ); setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]",
"[][][][][][][grow]" ) );
add( new JLabel( "R820T Tuner" ), "span, align center" ); add( new JLabel( "R820T Tuner Configuration" ), "span, align center" );
/** /**
* Tuner Configuration Name * Tuner Configuration Name
@@ -166,8 +175,39 @@ public class R820TTunerEditor extends TunerConfigurationEditor
public void focusGained( FocusEvent e ) {} public void focusGained( FocusEvent e ) {}
} ); } );
add( new JLabel( "Configuration:" ) ); add( new JLabel( "Name:" ) );
add( mConfigurationName, "growx,push" ); add( mConfigurationName, "span,grow" );
mComboSampleRate = new JComboBox<>( SampleRate.values() );
mComboSampleRate.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
SampleRate sampleRate =
(SampleRate)mComboSampleRate.getSelectedItem();
try
{
mController.setSampleRate( sampleRate );
save();
}
catch ( SourceException | LibUsbException eSampleRate )
{
JOptionPane.showMessageDialog(
R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply sample "
+ "rate setting [" + sampleRate.getLabel() + "]",
eSampleRate );
}
}
} );
add( new JLabel( "Sample Rate:" ) );
add( mComboSampleRate );
/** /**
* Frequency Correction * Frequency Correction
@@ -208,50 +248,14 @@ public class R820TTunerEditor extends TunerConfigurationEditor
} }
} ); } );
add( new JLabel( "Correction PPM:" ) ); add( new JLabel( "PPM:" ) );
add( mFrequencyCorrection, "growx,push" ); add( mFrequencyCorrection );
/** add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
* Sample Rate
*/
mComboSampleRate = new JComboBox<>( SampleRate.values() );
mComboSampleRate.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
SampleRate sampleRate =
(SampleRate)mComboSampleRate.getSelectedItem();
try
{
mController.setSampleRate( sampleRate );
save();
}
catch ( SourceException | LibUsbException eSampleRate )
{
JOptionPane.showMessageDialog(
R820TTunerEditor.this,
"R820T Tuner Controller - couldn't apply the sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
mLog.error( "R820T Tuner Controller - couldn't apply sample "
+ "rate setting [" + sampleRate.getLabel() + "]",
eSampleRate );
}
}
} );
add( new JLabel( "Sample Rate:" ) );
add( mComboSampleRate, "growx,push" );
/** /**
* Gain Controls * Gain Controls
*/ */
JPanel gainPanel = new JPanel();
gainPanel.setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
/* Master Gain Control */ /* Master Gain Control */
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() ); mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
@@ -308,8 +312,8 @@ public class R820TTunerEditor extends TunerConfigurationEditor
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>" + "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
+ "settings, or one of the individual gain settings for<br>" + "settings, or one of the individual gain settings for<br>"
+ "semi-manual gain control</html>" ); + "semi-manual gain control</html>" );
gainPanel.add( new JLabel( "Master" ) ); add( new JLabel( "Master:" ) );
gainPanel.add( mComboMasterGain ); add( mComboMasterGain );
/* Mixer Gain Control */ /* Mixer Gain Control */
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() ); mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
@@ -356,8 +360,8 @@ public class R820TTunerEditor extends TunerConfigurationEditor
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain " mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
+ "to <b>MASTER</b> to enable adjustment</html>" ); + "to <b>MASTER</b> to enable adjustment</html>" );
mComboMixerGain.setEnabled( false ); mComboMixerGain.setEnabled( false );
gainPanel.add( new JLabel( "Mixer" ) ); add( new JLabel( "Mixer:" ) );
gainPanel.add( mComboMixerGain, "wrap" ); add( mComboMixerGain );
/* LNA Gain Control */ /* LNA Gain Control */
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() ); mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
@@ -397,8 +401,8 @@ public class R820TTunerEditor extends TunerConfigurationEditor
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain " mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" ); + "to <b>MANUAL</b> to enable adjustment</html>" );
mComboLNAGain.setEnabled( false ); mComboLNAGain.setEnabled( false );
gainPanel.add( new JLabel( "LNA" ) ); add( new JLabel( "LNA:" ) );
gainPanel.add( mComboLNAGain ); add( mComboLNAGain );
/* VGA Gain Control */ /* VGA Gain Control */
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() ); mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
@@ -438,9 +442,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain " mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" ); + "to <b>MANUAL</b> to enable adjustment</html>" );
mComboVGAGain.setEnabled( false ); mComboVGAGain.setEnabled( false );
gainPanel.add( new JLabel( "VGA" ) ); add( new JLabel( "VGA:" ) );
gainPanel.add( mComboVGAGain, "wrap" ); add( mComboVGAGain );
add( gainPanel, "span" );
} }
} }