WIP #34 - more work on tuner model and view. Includes new tuner

configuration and tuner configuration assignment editors.  Beginning of
tuner editor panel rework.   Removes most of the remaining JTree
configuration pieces.  Updates the settings manager to load and save
tuners and refactors all of the tuner configuration management out into
the tuner configuration model.
This commit is contained in:
denny
2016-03-12 12:54:48 -05:00
parent 9d4afb8c1f
commit 218eeb1848
66 changed files with 1983 additions and 2594 deletions

View File

@@ -1,130 +0,0 @@
package source.recording;
import gui.control.JFrequencyControl;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
public class RecordingEditorPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private RecordingNode mRecordingNode;
private JTextField mRecordingAlias;
private JLabel mFilePathLabel;
public RecordingEditorPanel( RecordingNode recordingNode )
{
mRecordingNode = recordingNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][][][][grow]" ) );
add( new JLabel( "I/Q Recording" ), "span,align left" );
add( new JLabel( "Alias:" ) );
mRecordingAlias = new JTextField( mRecordingNode.getRecording()
.getRecordingConfiguration().getAlias() );
mRecordingAlias.addFocusListener( new FocusListener()
{
@Override
public void focusLost( FocusEvent arg0 )
{
String alias = mRecordingAlias.getText();
if( alias != null )
{
mRecordingNode.getRecording().setAlias( alias );
}
}
@Override
public void focusGained( FocusEvent arg0 ) {}
} );
add( mRecordingAlias, "wrap" );
JButton mFileSelectionButton = new JButton( "File ..." );
mFileSelectionButton.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
if( mRecordingNode.getRecording().hasChannels() )
{
JOptionPane.showMessageDialog( RecordingEditorPanel.this,
"This recording is currently in replay. Please "
+ "disable any channels that are using this "
+ "recording before changing the recording file." );
}
else
{
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog( RecordingEditorPanel.this );
if ( returnVal == JFileChooser.APPROVE_OPTION )
{
File file = fc.getSelectedFile();
if( file != null && file.exists() )
{
mRecordingNode.getRecording()
.getRecordingConfiguration()
.setFilePath( file.getAbsolutePath() );
if( mFilePathLabel != null )
{
mFilePathLabel.setText( file.getName() );
}
}
}
}
}
} );
add( mFileSelectionButton );
String filePath = mRecordingNode.getRecording()
.getRecordingConfiguration().getFilePath();
if( filePath != null )
{
mFilePathLabel = new JLabel( filePath );
}
else
{
mFilePathLabel = new JLabel( "Please select a recording" );
}
add( mFilePathLabel, "wrap" );
add( new JLabel( "Center Frequency:" ), "span,align left" );
JFrequencyControl frequencyControl = new JFrequencyControl(
mRecordingNode.getRecording().getRecordingConfiguration()
.getCenterFrequency() );
frequencyControl.addListener( mRecordingNode.getRecording() );
add( frequencyControl, "span,align left" );
}
}

View File

@@ -1,101 +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.recording;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import settings.SettingsManager;
import source.SourceManager;
import controller.BaseNode;
public class RecordingGroupNode extends BaseNode
{
private static final long serialVersionUID = 1L;
private SettingsManager mSettingsManager;
public RecordingGroupNode( SourceManager sourceManager, SettingsManager settingsManager )
{
super( sourceManager );
mSettingsManager = settingsManager;
}
private SourceManager getSourceManager()
{
return (SourceManager)getUserObject();
}
public String toString()
{
return "Recordings [" + this.getChildCount() + "]";
}
public JPopupMenu getContextMenu()
{
JPopupMenu menu = new JPopupMenu();
JMenuItem addRecordingItem = new JMenuItem( "Add Recording" );
addRecordingItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
RecordingConfiguration config = new RecordingConfiguration();
mSettingsManager.addRecordingConfiguration( config );
Recording recording = getSourceManager()
.getRecordingSourceManager().addRecording( config );
RecordingNode node = new RecordingNode( getSourceManager(), recording );
getModel().addNode( node, RecordingGroupNode.this, 0 );
sort();
node.show();
}
} );
menu.add( addRecordingItem );
return menu;
}
public void loadRecordings()
{
List<Recording> recordings = getSourceManager()
.getRecordingSourceManager().getRecordings();
for( Recording recording: recordings )
{
RecordingNode node = new RecordingNode( getSourceManager(), recording );
getModel().addNode( node, this, 0 );
}
sort();
}
}

View File

@@ -1,82 +0,0 @@
package source.recording;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import source.SourceManager;
import controller.BaseNode;
public class RecordingNode extends BaseNode
{
private static final long serialVersionUID = 1L;
private JPanel mEditor;
private SourceManager mSourceManager;
public RecordingNode( SourceManager sourceManager, Recording recording )
{
super( recording );
}
public Recording getRecording()
{
return (Recording)getUserObject();
}
public String toString()
{
return getRecording().toString();
}
@Override
public JPanel getEditor()
{
if( mEditor == null )
{
mEditor = new RecordingEditorPanel( this );
}
return mEditor;
}
public JPopupMenu getContextMenu()
{
JPopupMenu menu = new JPopupMenu();
JMenuItem deleteItem = new JMenuItem( "Delete" );
deleteItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
if( getRecording().hasChannels() )
{
JOptionPane.showMessageDialog( getModel().getTree(),
"Can't delete recording - currently in use. Please"
+ " disable any channel(s) that are using this "
+ "recording before deleting it",
"Can't delete recording",
JOptionPane.ERROR_MESSAGE );
}
else
{
mSourceManager.getRecordingSourceManager()
.removeRecording( getRecording() );
getModel().removeNodeFromParent( RecordingNode.this );
}
}
} );
menu.add( deleteItem );
return menu;
}
}

View File

@@ -131,7 +131,7 @@ public class RecordingSourceManager
private void loadRecordings()
{
ArrayList<RecordingConfiguration> recordingConfigurations =
List<RecordingConfiguration> recordingConfigurations =
mSettingsManager.getRecordingConfigurations();
mLog.info( "RecordingSourceManager - discovered [" +