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.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.RowFilter;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableRowSorter;
@@ -25,8 +25,8 @@ import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import source.SourceException;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationEditor;
import source.tuner.configuration.TunerConfigurationFactory;
import source.tuner.configuration.TunerConfigurationModel;
@@ -45,6 +45,9 @@ public class TunerEditor extends Editor<Tuner>
private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" );
private JButton mNewConfigurationButton = new JButton( "New" );
private JButton mDeleteConfigurationButton = new JButton( "Delete" );
private JScrollPane mEditorScroller;
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>();
private JideSplitPane mEditorSplitPane = new JideSplitPane();
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( mTunerConfigurationTable, "span" );
listPanel.add( tableScroller, "span" );
mNewConfigurationButton.setEnabled( false );
mNewConfigurationButton.addActionListener( new ActionListener()
@@ -141,20 +146,18 @@ public class TunerEditor extends Editor<Tuner>
listPanel.add( mDeleteConfigurationButton );
//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 );
listScroller.setPreferredSize( new Dimension( 200, 80 ) );
listScroller.setPreferredSize( new Dimension( 100, 80 ) );
//TODO: this has to be changed
JPanel editorPanel = new EmptyEditor<TunerConfiguration>();
JScrollPane editorScroller = new JScrollPane( editorPanel );
editorScroller.setPreferredSize( new Dimension( 200, 80 ) );
mEditorScroller = new JScrollPane( mEditor );
mEditorScroller.setPreferredSize( new Dimension( 100, 80 ) );
JideSplitPane splitPane =
new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
splitPane.add( listScroller );
splitPane.add( editorScroller );
mEditorSplitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
mEditorSplitPane.add( listScroller );
mEditorSplitPane.add( mEditorScroller );
add( splitPane );
add( mEditorSplitPane );
}
@Override
@@ -211,6 +214,9 @@ public class TunerEditor extends Editor<Tuner>
//Set the displayed frequency without adjusting the tuner's frequency
mFrequencyControl.setFrequency(
tuner.getTunerController().getFrequency(), false );
mEditor = TunerConfigurationFactory
.getEditor( getItem(), mTunerConfigurationModel );
}
else
{
@@ -219,19 +225,35 @@ public class TunerEditor extends Editor<Tuner>
mTunerConfigurationTable.setEnabled( false );
mNewConfigurationButton.setEnabled( false );
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 )
{
if( config != null )
{
mDeleteConfigurationButton.setEnabled( true );
if( !mDeleteConfigurationButton.isEnabled() )
{
mDeleteConfigurationButton.setEnabled( true );
}
}
else
{
mDeleteConfigurationButton.setEnabled( false );
if( mDeleteConfigurationButton.isEnabled() )
{
mDeleteConfigurationButton.setEnabled( false );
}
}
mEditor.setItem( config );
}
public class ConfigurationRowFilter extends RowFilter<TunerConfigurationModel,Integer>

View File

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

View File

@@ -1,5 +1,7 @@
package source.tuner.configuration;
import gui.editor.Editor;
import gui.editor.EmptyEditor;
import source.tuner.Tuner;
import source.tuner.TunerType;
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 )
{
switch( tuner.getTunerType() )
@@ -58,7 +60,7 @@ public class TunerConfigurationFactory
break;
}
return null;
return new EmptyEditor<TunerConfiguration>();
}
}

View File

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

View File

@@ -29,6 +29,7 @@ import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
@@ -45,6 +46,7 @@ import org.slf4j.LoggerFactory;
import org.usb4java.LibUsbException;
import source.SourceException;
import source.tuner.TunerType;
import source.tuner.configuration.TunerConfiguration;
import source.tuner.configuration.TunerConfigurationEditor;
import source.tuner.configuration.TunerConfigurationEvent;
@@ -83,8 +85,14 @@ public class R820TTunerEditor extends TunerConfigurationEditor
init();
}
@Override
public boolean canEdit( TunerType tunerType )
{
return tunerType == TunerType.RAFAELMICRO_R820T;
}
@Override
public void save()
{
if( hasItem() )
@@ -147,9 +155,10 @@ public class R820TTunerEditor extends TunerConfigurationEditor
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
@@ -166,9 +175,40 @@ public class R820TTunerEditor extends TunerConfigurationEditor
public void focusGained( FocusEvent e ) {}
} );
add( new JLabel( "Configuration:" ) );
add( mConfigurationName, "growx,push" );
add( new JLabel( "Name:" ) );
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
*/
@@ -208,50 +248,14 @@ public class R820TTunerEditor extends TunerConfigurationEditor
}
} );
add( new JLabel( "Correction PPM:" ) );
add( mFrequencyCorrection, "growx,push" );
add( new JLabel( "PPM:" ) );
add( mFrequencyCorrection );
/**
* 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" );
add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
/**
* Gain Controls
*/
JPanel gainPanel = new JPanel();
gainPanel.setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
/* Master Gain Control */
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>"
+ "settings, or one of the individual gain settings for<br>"
+ "semi-manual gain control</html>" );
gainPanel.add( new JLabel( "Master" ) );
gainPanel.add( mComboMasterGain );
add( new JLabel( "Master:" ) );
add( mComboMasterGain );
/* Mixer Gain Control */
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
@@ -356,8 +360,8 @@ public class R820TTunerEditor extends TunerConfigurationEditor
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
+ "to <b>MASTER</b> to enable adjustment</html>" );
mComboMixerGain.setEnabled( false );
gainPanel.add( new JLabel( "Mixer" ) );
gainPanel.add( mComboMixerGain, "wrap" );
add( new JLabel( "Mixer:" ) );
add( mComboMixerGain );
/* LNA Gain Control */
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
@@ -397,8 +401,8 @@ public class R820TTunerEditor extends TunerConfigurationEditor
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" );
mComboLNAGain.setEnabled( false );
gainPanel.add( new JLabel( "LNA" ) );
gainPanel.add( mComboLNAGain );
add( new JLabel( "LNA:" ) );
add( mComboLNAGain );
/* VGA Gain Control */
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
@@ -438,9 +442,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" );
mComboVGAGain.setEnabled( false );
gainPanel.add( new JLabel( "VGA" ) );
gainPanel.add( mComboVGAGain, "wrap" );
add( gainPanel, "span" );
add( new JLabel( "VGA:" ) );
add( mComboVGAGain );
}
}