mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
WIP #34 - adds tuner model and view tab, preparing to remove the
configuration panel from the controller view.
This commit is contained in:
@@ -1,28 +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 sample.SampleType;
|
||||
|
||||
public interface SampleProvider
|
||||
{
|
||||
/**
|
||||
* Real or Complex
|
||||
*/
|
||||
public abstract SampleType getSampleType();
|
||||
}
|
||||
88
src/source/TunerModel.java
Normal file
88
src/source/TunerModel.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package source;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
|
||||
import source.tuner.Tuner;
|
||||
|
||||
public class TunerModel extends AbstractListModel<Tuner>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<Tuner> mTuners = new ArrayList<>();
|
||||
|
||||
public TunerModel()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* List of Tuners currently in the model
|
||||
*/
|
||||
public List<Tuner> getTuners()
|
||||
{
|
||||
return mTuners;
|
||||
}
|
||||
|
||||
public void addTuners( List<Tuner> Tuners )
|
||||
{
|
||||
for( Tuner tuner: Tuners )
|
||||
{
|
||||
addTuner( tuner );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Tuner to this model
|
||||
*/
|
||||
public void addTuner( Tuner tuner )
|
||||
{
|
||||
if( !mTuners.contains( tuner ) )
|
||||
{
|
||||
mTuners.add( tuner );
|
||||
|
||||
int index = mTuners.indexOf( tuner );
|
||||
|
||||
fireIntervalAdded( this, index, index );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Tuner from this model
|
||||
*/
|
||||
public void removeTuner( Tuner tuner )
|
||||
{
|
||||
if( mTuners.contains( tuner ) )
|
||||
{
|
||||
int index = mTuners.indexOf( tuner );
|
||||
|
||||
mTuners.remove( tuner );
|
||||
|
||||
fireIntervalRemoved( this, index, index );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of Tuners in this model
|
||||
*/
|
||||
@Override
|
||||
public int getSize()
|
||||
{
|
||||
return mTuners.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Tuner at the specified index
|
||||
*/
|
||||
@Override
|
||||
public Tuner getElementAt( int index )
|
||||
{
|
||||
if( index <= mTuners.size() )
|
||||
{
|
||||
return mTuners.get( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
94
src/source/TunerViewPanel.java
Normal file
94
src/source/TunerViewPanel.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package source;
|
||||
|
||||
import gui.editor.EmptyEditor;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.tuner.Tuner;
|
||||
import source.tuner.TunerManager;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
|
||||
public class TunerViewPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( TunerViewPanel.class );
|
||||
|
||||
private TunerModel mTunerModel;
|
||||
private SettingsManager mSettingsManager;
|
||||
private JideSplitPane mSplitPane;
|
||||
private JList<Tuner> mTunerList;
|
||||
|
||||
public TunerViewPanel( TunerModel tunerModel, SettingsManager settingsManager )
|
||||
{
|
||||
mTunerModel = tunerModel;
|
||||
mSettingsManager = settingsManager;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 1 1 1 1", "[fill,grow]", "[fill,grow]" ) );
|
||||
|
||||
mTunerList = new JList<>( mTunerModel );
|
||||
mTunerList.setLayoutOrientation( JList.VERTICAL );
|
||||
mTunerList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
mTunerList.addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
Tuner selected = mTunerList.getSelectedValue();
|
||||
|
||||
Component component = null;
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
JPanel tunerEditor = TunerManager
|
||||
.getEditor( mSettingsManager, selected );
|
||||
|
||||
component = new JScrollPane( tunerEditor );
|
||||
}
|
||||
else
|
||||
{
|
||||
component = new EmptyEditor<Tuner>();
|
||||
}
|
||||
|
||||
int split = mSplitPane.getDividerLocation( 0 );
|
||||
|
||||
mSplitPane.remove( 2 );
|
||||
mSplitPane.add( component );
|
||||
mSplitPane.setDividerLocation( 0, split );
|
||||
validate();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
JScrollPane listScroller = new JScrollPane( mTunerList );
|
||||
|
||||
JScrollPane editorScroller = new JScrollPane( new EmptyEditor<Tuner>() );
|
||||
|
||||
mSplitPane = new JideSplitPane();
|
||||
mSplitPane.setOrientation( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
mSplitPane.add( listScroller );
|
||||
mSplitPane.add( editorScroller );
|
||||
|
||||
add( mSplitPane );
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,16 @@
|
||||
******************************************************************************/
|
||||
package source.tuner;
|
||||
|
||||
import gui.editor.EmptyEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.usb4java.Device;
|
||||
@@ -38,6 +42,7 @@ import source.config.SourceConfiguration;
|
||||
import source.mixer.MixerManager;
|
||||
import source.tuner.airspy.AirspyTuner;
|
||||
import source.tuner.airspy.AirspyTunerController;
|
||||
import source.tuner.airspy.AirspyTunerEditorPanel;
|
||||
import source.tuner.fcd.FCDTuner;
|
||||
import source.tuner.fcd.proV1.FCD1TunerController;
|
||||
import source.tuner.fcd.proplusV2.FCD2TunerController;
|
||||
@@ -46,6 +51,7 @@ import source.tuner.hackrf.HackRFTunerController;
|
||||
import source.tuner.rtl.RTL2832Tuner;
|
||||
import source.tuner.rtl.RTL2832TunerController;
|
||||
import source.tuner.rtl.e4k.E4KTunerController;
|
||||
import source.tuner.rtl.e4k.E4KTunerEditorPanel;
|
||||
import source.tuner.rtl.r820t.R820TTunerController;
|
||||
import controller.ThreadPoolManager;
|
||||
|
||||
@@ -618,4 +624,16 @@ public class TunerManager
|
||||
return mTuner != null;
|
||||
}
|
||||
}
|
||||
|
||||
public static JPanel getEditor( SettingsManager settingsManager, Tuner tuner )
|
||||
{
|
||||
JPanel editor = tuner.getEditor( settingsManager );
|
||||
|
||||
if( editor != null )
|
||||
{
|
||||
return editor;
|
||||
}
|
||||
|
||||
return new EmptyEditor<Tuner>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user