mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
wip #34 - adds enable/disable to tuner editor components and frequency
control
This commit is contained in:
@@ -129,6 +129,17 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
|
||||
|
||||
revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled( boolean enabled )
|
||||
{
|
||||
super.setEnabled( enabled );
|
||||
|
||||
for( Digit digit: mDigits.values() )
|
||||
{
|
||||
digit.setEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives a frequency change event invoked by another control. We don't
|
||||
@@ -246,7 +257,10 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
|
||||
|
||||
public void increment( boolean fireChangeEvent )
|
||||
{
|
||||
set( mValue + 1, fireChangeEvent );
|
||||
if( isEnabled() )
|
||||
{
|
||||
set( mValue + 1, fireChangeEvent );
|
||||
}
|
||||
}
|
||||
|
||||
public void decrement()
|
||||
@@ -256,7 +270,10 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
|
||||
|
||||
public void decrement( boolean fireChangeEvent )
|
||||
{
|
||||
set( mValue - 1, fireChangeEvent );
|
||||
if( isEnabled() )
|
||||
{
|
||||
set( mValue - 1, fireChangeEvent );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.usb.UsbDeviceDescriptor;
|
||||
|
||||
public enum TunerClass
|
||||
{
|
||||
AIRSPY( TunerType.AIRSPY_R820T, "1D50", "60A1", "Airspy.com", "Airspy" ),
|
||||
AIRSPY( TunerType.AIRSPY_R820T, "1D50", "60A1", "Airspy", "Airspy" ),
|
||||
GENERIC_2832( TunerType.RTL2832_VARIOUS, "0BDA", "2832", "RTL2832", "SDR" ),
|
||||
GENERIC_2838( TunerType.RTL2832_VARIOUS, "0BDA", "2838", "RTL2832", "SDR" ),
|
||||
COMPRO_VIDEOMATE_U620F( TunerType.ELONICS_E4000, "185B", "0620", "Compro", "Videomate U620F" ),
|
||||
|
||||
@@ -11,7 +11,10 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.RowFilter;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -35,6 +38,9 @@ public class TunerEditor extends Editor<Tuner>
|
||||
private JTable mTunerConfigurationTable;
|
||||
private TableRowSorter<TunerConfigurationModel> mRowSorter;
|
||||
private JFrequencyControl mFrequencyControl = new JFrequencyControl();
|
||||
private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" );
|
||||
private JButton mNewConfigurationButton = new JButton( "New" );
|
||||
private JButton mDeleteConfigurationButton = new JButton( "Delete" );
|
||||
|
||||
public TunerEditor( TunerConfigurationModel tunerConfigurationModel )
|
||||
{
|
||||
@@ -47,33 +53,53 @@ public class TunerEditor extends Editor<Tuner>
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]" ) );
|
||||
|
||||
JPanel listPanel = new JPanel();
|
||||
listPanel.setLayout( new MigLayout( "fill,wrap 1",
|
||||
"[grow,fill]", "[][][grow,fill][]" ) );
|
||||
listPanel.add( mFrequencyControl );
|
||||
listPanel.setLayout( new MigLayout( "fill,wrap 2", "[grow,fill]", "[][][][grow,fill][]" ) );
|
||||
|
||||
listPanel.add( mSelectedTunerType, "span" );
|
||||
|
||||
mFrequencyControl.setEnabled( false );
|
||||
listPanel.add( mFrequencyControl, "span" );
|
||||
|
||||
mTunerConfigurationTable = new JTable( mTunerConfigurationModel );
|
||||
mRowSorter = new TableRowSorter<>( mTunerConfigurationModel );
|
||||
mTunerConfigurationTable.setRowSorter( mRowSorter );
|
||||
mTunerConfigurationTable.setEnabled( false );
|
||||
mTunerConfigurationTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int row = mTunerConfigurationTable.getSelectedRow();
|
||||
|
||||
if( row >= 0 )
|
||||
{
|
||||
int modelRow = mTunerConfigurationTable.convertRowIndexToModel( row );
|
||||
|
||||
listPanel.add( new JLabel( "Tuner Configurations" ) );
|
||||
listPanel.add( mTunerConfigurationTable );
|
||||
if( modelRow >= 0 )
|
||||
{
|
||||
setConfigurationEditor( mTunerConfigurationModel.getTunerConfiguration( modelRow ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout( new MigLayout( "insets 0 0 0 0",
|
||||
"[grow,fill][grow,fill]", "[grow,fill]" ) );
|
||||
|
||||
JButton newButton = new JButton( "New" );
|
||||
buttonPanel.add( newButton );
|
||||
|
||||
JButton deleteButton = new JButton( "Delete" );
|
||||
buttonPanel.add( deleteButton );
|
||||
|
||||
listPanel.add( buttonPanel );
|
||||
listPanel.add( new JLabel( "Tuner Configurations" ), "span" );
|
||||
listPanel.add( mTunerConfigurationTable, "span" );
|
||||
|
||||
mNewConfigurationButton.setEnabled( false );
|
||||
listPanel.add( mNewConfigurationButton );
|
||||
|
||||
mDeleteConfigurationButton.setEnabled( false );
|
||||
listPanel.add( mDeleteConfigurationButton );
|
||||
|
||||
//Set preferred size on both scrollers to same width, so they split the space
|
||||
JScrollPane listScroller = new JScrollPane( listPanel );
|
||||
listScroller.setPreferredSize( new Dimension( 200, 80 ) );
|
||||
|
||||
//TODO: this has to be changed
|
||||
JPanel editorPanel = new EmptyEditor<TunerConfiguration>();
|
||||
JScrollPane editorScroller = new JScrollPane( editorPanel );
|
||||
editorScroller.setPreferredSize( new Dimension( 200, 80 ) );
|
||||
@@ -107,6 +133,11 @@ public class TunerEditor extends Editor<Tuner>
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mSelectedTunerType.setText( tuner.getName() );
|
||||
mFrequencyControl.setEnabled( true );
|
||||
mTunerConfigurationTable.setEnabled( true );
|
||||
mNewConfigurationButton.setEnabled( true );
|
||||
|
||||
mRowSorter.setRowFilter( new ConfigurationRowFilter( tuner.getTunerType() ) );
|
||||
|
||||
TunerConfiguration assigned = mTunerConfigurationModel
|
||||
@@ -138,10 +169,26 @@ public class TunerEditor extends Editor<Tuner>
|
||||
}
|
||||
else
|
||||
{
|
||||
mSelectedTunerType.setText( "No Tuner Selected" );
|
||||
mFrequencyControl.setEnabled( false );
|
||||
mTunerConfigurationTable.setEnabled( false );
|
||||
mNewConfigurationButton.setEnabled( false );
|
||||
mRowSorter.setRowFilter( null );
|
||||
}
|
||||
}
|
||||
|
||||
private void setConfigurationEditor( TunerConfiguration config )
|
||||
{
|
||||
if( config != null )
|
||||
{
|
||||
mDeleteConfigurationButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mDeleteConfigurationButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
public class ConfigurationRowFilter extends RowFilter<TunerConfigurationModel,Integer>
|
||||
{
|
||||
private TunerType mTunerType;
|
||||
|
||||
@@ -27,8 +27,8 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger( TunerModel.class );
|
||||
|
||||
public static final int TUNER_CLASS = 0;
|
||||
public static final int TUNER_TYPE = 1;
|
||||
public static final int TUNER_TYPE = 0;
|
||||
public static final int TUNER_ID = 1;
|
||||
public static final int SAMPLE_RATE = 2;
|
||||
public static final int FREQUENCY = 3;
|
||||
public static final int CHANNEL_COUNT = 4;
|
||||
@@ -37,7 +37,7 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
|
||||
|
||||
private static final String MHZ = " MHz";
|
||||
private static final String[] COLUMNS =
|
||||
{ "Class", "Type", "Sample Rate", "Frequency", "Channels", "Spectral", "Display" };
|
||||
{ "Tuner", "ID", "Sample Rate", "Frequency", "Channels", "Spectral", "Display" };
|
||||
|
||||
private List<Tuner> mTuners = new ArrayList<>();
|
||||
private List<Listener<TunerEvent>> mTunerEventListeners = new ArrayList<>();
|
||||
@@ -217,10 +217,10 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
|
||||
|
||||
switch( columnIndex )
|
||||
{
|
||||
case TUNER_CLASS:
|
||||
return tuner.getTunerClass().getVendorDescription();
|
||||
case TUNER_TYPE:
|
||||
return tuner.getTunerType().getLabel();
|
||||
case TUNER_ID:
|
||||
return tuner.getUniqueID();
|
||||
case SAMPLE_RATE:
|
||||
int sampleRate = tuner.getTunerController().getSampleRate();
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import source.tuner.TunerClass;
|
||||
import source.tuner.TunerEvent;
|
||||
import source.tuner.TunerType;
|
||||
import source.tuner.airspy.AirspyTunerController.BoardID;
|
||||
import source.tuner.configuration.TunerConfiguration;
|
||||
|
||||
public class AirspyTuner extends Tuner
|
||||
{
|
||||
@@ -40,7 +39,7 @@ public class AirspyTuner extends Tuner
|
||||
|
||||
public AirspyTuner( AirspyTunerController controller )
|
||||
{
|
||||
super( "Airspy", controller );
|
||||
super( "Airspy " + controller.getDeviceInfo().getSerialNumber(), controller );
|
||||
}
|
||||
|
||||
public AirspyTunerController getController()
|
||||
@@ -57,7 +56,7 @@ public class AirspyTuner extends Tuner
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
mLog.error( "error gettting serial number", e );
|
||||
mLog.error( "error getting serial number", e );
|
||||
}
|
||||
|
||||
return BoardID.AIRSPY.getLabel();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RTL2832Tuner extends Tuner
|
||||
throws SourceException
|
||||
{
|
||||
super( tunerClass.getVendorDeviceLabel() + "/" +
|
||||
controller.getTunerType().getLabel() + " #" +
|
||||
controller.getTunerType().getLabel() + " " +
|
||||
controller.getUniqueID(), controller );
|
||||
|
||||
mTunerClass = tunerClass;
|
||||
|
||||
Reference in New Issue
Block a user