mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
wip #34 - reformatting the channel configuration editors.
This commit is contained in:
@@ -1,61 +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 javax.swing.JLabel;
|
||||
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
import source.config.SourceConfiguration;
|
||||
|
||||
public class EmptySourceEditor extends SourceEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EmptySourceEditor( SourceManager resourceManager,
|
||||
SourceConfiguration config )
|
||||
{
|
||||
super( resourceManager, config );
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
public void reset() {}
|
||||
|
||||
public void save() {}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
JLabel selectLabel = new JLabel( "Please select a source" );
|
||||
add( selectLabel );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConfiguration() throws ConfigurationValidationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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 java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import source.config.SourceConfigFactory;
|
||||
import source.config.SourceConfiguration;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelConfigurationEditor;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
|
||||
public class SourceComponentEditor extends ChannelConfigurationEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JComboBox<SourceType> mComboSources;
|
||||
private SourceEditor mEditor;
|
||||
private SourceManager mSourceManager;
|
||||
private Channel mChannel = null;
|
||||
|
||||
public SourceComponentEditor( SourceManager sourceManager )
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) );
|
||||
|
||||
mComboSources = new JComboBox<SourceType>();
|
||||
mComboSources.setModel( new DefaultComboBoxModel<SourceType>( SourceType.values() ) );
|
||||
mComboSources.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
SourceType selected = mComboSources.getItemAt( mComboSources.getSelectedIndex() );
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
SourceConfiguration config;
|
||||
|
||||
if( mChannel == null ||
|
||||
mChannel.getSourceConfiguration().getSourceType() != selected )
|
||||
{
|
||||
config = SourceConfigFactory.getSourceConfiguration( selected );
|
||||
}
|
||||
else
|
||||
{
|
||||
config = mChannel.getSourceConfiguration();
|
||||
}
|
||||
|
||||
//Remove the existing one
|
||||
if( mEditor != null )
|
||||
{
|
||||
remove( mEditor );
|
||||
}
|
||||
|
||||
//Change to the new one
|
||||
mEditor = mSourceManager.getPanel( config );
|
||||
|
||||
//Add it to the jpanel
|
||||
add( mEditor, "span 2" );
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add( new JLabel( "Source:" ) );
|
||||
add( mComboSources, "wrap" );
|
||||
}
|
||||
|
||||
public SourceEditor getSourceEditor()
|
||||
{
|
||||
return mEditor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
mEditor.save();
|
||||
|
||||
//Let the calling save method send the config change event
|
||||
mChannel.setSourceConfiguration( mEditor.getConfig() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel configuration. Note: this method must be invoked from
|
||||
* the swing event dispatch thread.
|
||||
*/
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
{
|
||||
mChannel = channel;
|
||||
|
||||
if( mChannel != null )
|
||||
{
|
||||
mComboSources.setSelectedItem(
|
||||
mChannel.getSourceConfiguration().getSourceType() );
|
||||
|
||||
mComboSources.requestFocus();
|
||||
|
||||
mComboSources.requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConfiguration() throws ConfigurationValidationException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
128
src/source/SourceConfigurationEditor.java
Normal file
128
src/source/SourceConfigurationEditor.java
Normal file
@@ -0,0 +1,128 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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 gui.editor.Editor;
|
||||
import gui.editor.EmptyEditor;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import source.mixer.MixerSourceEditor;
|
||||
import source.tuner.TunerSourceEditor;
|
||||
import controller.channel.Channel;
|
||||
|
||||
public class SourceConfigurationEditor extends Editor<Channel>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JComboBox<SourceType> mComboSources;
|
||||
private MixerSourceEditor mMixerSourceEditor;
|
||||
private TunerSourceEditor mTunerSourceEditor;
|
||||
private Editor<Channel> mCurrentEditor;
|
||||
|
||||
public SourceConfigurationEditor( SourceManager sourceManager )
|
||||
{
|
||||
mMixerSourceEditor = new MixerSourceEditor( sourceManager );
|
||||
mTunerSourceEditor = new TunerSourceEditor();
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 3", "[right][left][grow,fill]", "[][grow]" ) );
|
||||
|
||||
mComboSources = new JComboBox<SourceType>();
|
||||
mComboSources.setModel( new DefaultComboBoxModel<SourceType>( SourceType.getTypes() ) );
|
||||
mComboSources.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
SourceType selected = (SourceType)mComboSources.getSelectedItem();
|
||||
|
||||
switch( selected )
|
||||
{
|
||||
case MIXER:
|
||||
setEditor( mMixerSourceEditor );
|
||||
break;
|
||||
case TUNER:
|
||||
setEditor( mTunerSourceEditor );
|
||||
break;
|
||||
default:
|
||||
setEditor( new EmptyEditor<Channel>() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add( new JLabel( "Source:" ) );
|
||||
add( mComboSources );
|
||||
|
||||
mCurrentEditor = mTunerSourceEditor;
|
||||
add( mCurrentEditor );
|
||||
}
|
||||
|
||||
private void setEditor( Editor<Channel> editor )
|
||||
{
|
||||
if( mCurrentEditor != editor )
|
||||
{
|
||||
remove( mCurrentEditor );
|
||||
mCurrentEditor = editor;
|
||||
add( mCurrentEditor );
|
||||
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && mCurrentEditor.isModified() )
|
||||
{
|
||||
mCurrentEditor.save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified()
|
||||
{
|
||||
return super.isModified() || mCurrentEditor.isModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel configuration. Note: this method must be invoked from
|
||||
* the swing event dispatch thread.
|
||||
*/
|
||||
@Override
|
||||
public void setItem( Channel channel )
|
||||
{
|
||||
super.setItem( channel );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mMixerSourceEditor.setItem( channel );
|
||||
mTunerSourceEditor.setItem( channel );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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 source.config.SourceConfiguration;
|
||||
import controller.channel.ChannelConfigurationEditor;
|
||||
|
||||
public abstract class SourceEditor extends ChannelConfigurationEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected SourceManager mSourceManager;
|
||||
protected SourceConfiguration mConfig;
|
||||
|
||||
public SourceEditor( SourceManager sourceManager, SourceConfiguration config )
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
mConfig = config;
|
||||
}
|
||||
|
||||
public SourceConfiguration getConfig()
|
||||
{
|
||||
return mConfig;
|
||||
}
|
||||
|
||||
protected SourceManager getSourceManager()
|
||||
{
|
||||
return mSourceManager;
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,8 @@ package source;
|
||||
import settings.SettingsManager;
|
||||
import source.config.SourceConfigTuner;
|
||||
import source.config.SourceConfiguration;
|
||||
import source.mixer.MixerEditor;
|
||||
import source.mixer.MixerManager;
|
||||
import source.recording.RecordingEditor;
|
||||
import source.recording.RecordingSourceManager;
|
||||
import source.tuner.TunerEditorOld;
|
||||
import source.tuner.TunerManager;
|
||||
import source.tuner.TunerModel;
|
||||
import controller.ThreadPoolManager;
|
||||
@@ -86,28 +83,4 @@ public class SourceManager
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public SourceEditor getPanel( SourceConfiguration config )
|
||||
{
|
||||
SourceEditor configuredPanel;
|
||||
|
||||
switch( config.getSourceType() )
|
||||
{
|
||||
case MIXER:
|
||||
configuredPanel = new MixerEditor( this, config );
|
||||
break;
|
||||
case TUNER:
|
||||
configuredPanel = new TunerEditorOld( this, config );
|
||||
break;
|
||||
case RECORDING:
|
||||
configuredPanel = new RecordingEditor( this, config );
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
configuredPanel = new EmptySourceEditor( this, config );
|
||||
break;
|
||||
}
|
||||
|
||||
return configuredPanel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
******************************************************************************/
|
||||
package source;
|
||||
|
||||
|
||||
public enum SourceType
|
||||
{
|
||||
NONE( "No Source" ),
|
||||
MIXER( "Mixer/Sound Card" ),
|
||||
MIXER( "Sound Card" ),
|
||||
TUNER( "Tuner" ),
|
||||
RECORDING( "IQ Recording" );
|
||||
|
||||
@@ -31,6 +32,15 @@ public enum SourceType
|
||||
mDisplayString = displayString;
|
||||
}
|
||||
|
||||
public static SourceType[] getTypes()
|
||||
{
|
||||
SourceType[] types = new SourceType[ 2 ];
|
||||
types[ 0 ] = SourceType.TUNER;
|
||||
types[ 1 ] = SourceType.MIXER;
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
public String getDisplayString()
|
||||
{
|
||||
return mDisplayString;
|
||||
|
||||
@@ -26,21 +26,17 @@ public class SourceConfigFactory
|
||||
return getSourceConfiguration( SourceType.TUNER );
|
||||
}
|
||||
|
||||
public static SourceConfiguration
|
||||
getSourceConfiguration( SourceType source )
|
||||
public static SourceConfiguration getSourceConfiguration( SourceType source )
|
||||
{
|
||||
SourceConfiguration retVal;
|
||||
|
||||
switch( source )
|
||||
{
|
||||
case MIXER:
|
||||
retVal = new SourceConfigMixer();
|
||||
break;
|
||||
case TUNER:
|
||||
retVal = new SourceConfigTuner();
|
||||
break;
|
||||
case RECORDING:
|
||||
retVal = new SourceConfigRecording();
|
||||
case MIXER:
|
||||
retVal = new SourceConfigMixer();
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 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
|
||||
@@ -30,7 +30,7 @@ public class SourceConfigTuner extends SourceConfiguration
|
||||
private static DecimalFormat sFORMAT = new DecimalFormat( "0.00000" );
|
||||
|
||||
private long mFrequency = 0;
|
||||
private int mBandwidth = 15000;
|
||||
private int mBandwidth = 12500;
|
||||
|
||||
public SourceConfigTuner()
|
||||
{
|
||||
|
||||
@@ -1,175 +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.mixer;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.sound.sampled.Mixer;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
import source.SourceEditor;
|
||||
import source.SourceManager;
|
||||
import source.config.SourceConfigMixer;
|
||||
import source.config.SourceConfiguration;
|
||||
import source.mixer.MixerManager.InputMixerConfiguration;
|
||||
|
||||
public class MixerEditor extends SourceEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox<InputMixerConfiguration> mComboMixers;
|
||||
private JComboBox<MixerChannel>mComboChannels;
|
||||
protected Mixer.Info mSelectedMixer = null;
|
||||
|
||||
|
||||
public MixerEditor( SourceManager sourceManager,
|
||||
SourceConfiguration config )
|
||||
{
|
||||
super( sourceManager, config );
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
JLabel mixerLabel = new JLabel( "Mixer:" );
|
||||
add( mixerLabel, "align right" );
|
||||
|
||||
mComboMixers = new JComboBox<InputMixerConfiguration>();
|
||||
|
||||
add( mComboMixers, "wrap" );
|
||||
|
||||
resetMixers();
|
||||
|
||||
JLabel channelLabel = new JLabel( "Channel:" );
|
||||
add( channelLabel, "align right" );
|
||||
|
||||
mComboChannels = new JComboBox<MixerChannel>();
|
||||
|
||||
add( mComboChannels, "wrap" );
|
||||
|
||||
resetChannels();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
resetMixers();
|
||||
resetChannels();
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
SourceConfigMixer config = (SourceConfigMixer)mConfig;
|
||||
|
||||
InputMixerConfiguration selectedMixer =
|
||||
mComboMixers.getItemAt( mComboMixers.getSelectedIndex() );
|
||||
|
||||
if( selectedMixer != null )
|
||||
{
|
||||
config.setMixer( selectedMixer.getMixerName() );
|
||||
}
|
||||
|
||||
MixerChannel channel = mComboChannels.getItemAt(
|
||||
mComboChannels.getSelectedIndex() );
|
||||
|
||||
if( channel != null )
|
||||
{
|
||||
if( config.getChannel() != channel )
|
||||
{
|
||||
config.setChannel( channel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetMixers()
|
||||
{
|
||||
|
||||
javax.swing.SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
InputMixerConfiguration[] mixers = mSourceManager
|
||||
.getMixerManager().getInputMixers();
|
||||
|
||||
mComboMixers.setModel(
|
||||
new DefaultComboBoxModel<InputMixerConfiguration>( mixers ) );
|
||||
|
||||
SourceConfigMixer config = (SourceConfigMixer)mConfig;
|
||||
|
||||
String mixer = config.getMixer();
|
||||
|
||||
if( mixer != null )
|
||||
{
|
||||
mComboMixers.setSelectedItem( mixer );
|
||||
}
|
||||
else
|
||||
{
|
||||
//Mixer either hasn't been set yet, or it was set to a
|
||||
//mixer that is no longer available. Set the mixer to the
|
||||
//first item, and then store the value
|
||||
if( mixers.length > 0 )
|
||||
{
|
||||
mComboMixers.setSelectedIndex( 0 );
|
||||
|
||||
InputMixerConfiguration selectedMixer =
|
||||
(InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
config.setMixer( selectedMixer.getMixerName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void resetChannels()
|
||||
{
|
||||
javax.swing.SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
EnumSet<MixerChannel> channels = MixerChannel.getTargetChannels();
|
||||
|
||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||
|
||||
MixerChannel channel = ((SourceConfigMixer)mConfig).getChannel();
|
||||
|
||||
mComboChannels.setSelectedItem( channel );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConfiguration() throws ConfigurationValidationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
155
src/source/mixer/MixerSourceEditor.java
Normal file
155
src/source/mixer/MixerSourceEditor.java
Normal file
@@ -0,0 +1,155 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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.mixer;
|
||||
|
||||
import gui.editor.Editor;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import source.SourceManager;
|
||||
import source.config.SourceConfigMixer;
|
||||
import source.config.SourceConfiguration;
|
||||
import source.mixer.MixerManager.InputMixerConfiguration;
|
||||
import controller.channel.Channel;
|
||||
|
||||
public class MixerSourceEditor extends Editor<Channel>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox<InputMixerConfiguration> mComboMixers;
|
||||
private JComboBox<MixerChannel>mComboChannels;
|
||||
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
public MixerSourceEditor( SourceManager sourceManager )
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]", "[][grow]" ) );
|
||||
|
||||
mComboMixers = new JComboBox<InputMixerConfiguration>();
|
||||
InputMixerConfiguration[] inputMixers = mSourceManager.getMixerManager().getInputMixers();
|
||||
mComboMixers.setModel( new DefaultComboBoxModel<InputMixerConfiguration>( inputMixers ) );
|
||||
mComboMixers.setEnabled( false );
|
||||
mComboMixers.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
InputMixerConfiguration selected = (InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
|
||||
add( new JLabel( "Mixer:" ) );
|
||||
add( mComboMixers );
|
||||
|
||||
mComboChannels = new JComboBox<MixerChannel>();
|
||||
mComboChannels.setEnabled( false );
|
||||
mComboChannels.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
|
||||
add( new JLabel( "Channel:" ) );
|
||||
add( mComboChannels );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( Channel item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mComboMixers.setEnabled( true );
|
||||
mComboChannels.setEnabled( true );
|
||||
|
||||
SourceConfiguration config = item.getSourceConfiguration();
|
||||
|
||||
if( config instanceof SourceConfigMixer )
|
||||
{
|
||||
SourceConfigMixer mixer = (SourceConfigMixer)config;
|
||||
|
||||
for( InputMixerConfiguration inputMixer: mSourceManager.getMixerManager().getInputMixers() )
|
||||
{
|
||||
if( inputMixer.getMixerName().equalsIgnoreCase( mixer.getMixer() ) )
|
||||
{
|
||||
mComboMixers.setSelectedItem( inputMixer );
|
||||
|
||||
for( MixerChannel channel: inputMixer.getChannels() )
|
||||
{
|
||||
if( channel.getLabel().equalsIgnoreCase( mixer.getChannel().getLabel() ) )
|
||||
{
|
||||
mComboChannels.setSelectedItem( channel );
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboMixers.setEnabled( false );
|
||||
mComboChannels.setEnabled( false );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
SourceConfigMixer config = new SourceConfigMixer();
|
||||
|
||||
InputMixerConfiguration selected =
|
||||
(InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
config.setMixer( selected.getMixerName() );
|
||||
|
||||
MixerChannel channel = (MixerChannel)mComboChannels.getSelectedItem();
|
||||
config.setChannel( channel );
|
||||
|
||||
getItem().setSourceConfiguration( config );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
@@ -1,135 +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 gui.control.JFrequencyControl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
import source.SourceEditor;
|
||||
import source.SourceManager;
|
||||
import source.config.SourceConfigRecording;
|
||||
import source.config.SourceConfigTuner;
|
||||
import source.config.SourceConfiguration;
|
||||
|
||||
public class RecordingEditor extends SourceEditor
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox<Recording> mComboRecordings;
|
||||
private JFrequencyControl mFrequencyControl;
|
||||
|
||||
public RecordingEditor( SourceManager sourceManager, SourceConfiguration config )
|
||||
{
|
||||
super( sourceManager, config );
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
mFrequencyControl.setFrequency(
|
||||
((SourceConfigTuner)mConfig).getFrequency(), false );
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
SourceConfigRecording config = (SourceConfigRecording)mConfig;
|
||||
|
||||
Recording selected = (Recording)mComboRecordings.getSelectedItem();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
config.setRecordingAlias( selected
|
||||
.getRecordingConfiguration().getAlias() );
|
||||
}
|
||||
|
||||
config.setFrequency( mFrequencyControl.getFrequency() );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
add( new JLabel( "Recording" ) );
|
||||
|
||||
mComboRecordings = new JComboBox<Recording>();
|
||||
|
||||
add( mComboRecordings, "wrap" );
|
||||
|
||||
mFrequencyControl = new JFrequencyControl();
|
||||
|
||||
mFrequencyControl.setFrequency(
|
||||
((SourceConfigRecording)mConfig).getFrequency(), false );
|
||||
|
||||
add( mFrequencyControl, "span" );
|
||||
|
||||
resetRecordings();
|
||||
}
|
||||
|
||||
private void resetRecordings()
|
||||
{
|
||||
SwingUtilities.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
List<Recording> recordings = getSourceManager()
|
||||
.getRecordingSourceManager().getRecordings();
|
||||
|
||||
mComboRecordings.setModel(
|
||||
new DefaultComboBoxModel<Recording>(
|
||||
recordings.toArray( new Recording[ recordings.size()] ) ) );
|
||||
|
||||
SourceConfigRecording config = (SourceConfigRecording)mConfig;
|
||||
|
||||
String recordingAlias = config.getRecordingAlias();
|
||||
|
||||
if( recordingAlias != null )
|
||||
{
|
||||
Recording selected = mSourceManager
|
||||
.getRecordingSourceManager()
|
||||
.getRecordingFromAlias( recordingAlias );
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
mComboRecordings.setSelectedItem( selected );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConfiguration() throws ConfigurationValidationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,59 +17,74 @@
|
||||
******************************************************************************/
|
||||
package source.tuner;
|
||||
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ConfigurationValidationException;
|
||||
import gui.control.JFrequencyControl;
|
||||
import source.SourceEditor;
|
||||
import source.SourceManager;
|
||||
import gui.editor.Editor;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import source.config.SourceConfigTuner;
|
||||
import source.config.SourceConfiguration;
|
||||
import source.tuner.frequency.FrequencyChangeEvent;
|
||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||
import controller.channel.Channel;
|
||||
|
||||
public class TunerEditorOld extends SourceEditor
|
||||
public class TunerSourceEditor extends Editor<Channel>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JFrequencyControl mFrequencyControl;
|
||||
|
||||
public TunerEditorOld( SourceManager sourceManager,
|
||||
SourceConfiguration config )
|
||||
|
||||
public TunerSourceEditor()
|
||||
{
|
||||
super( sourceManager, config );
|
||||
|
||||
initGUI();
|
||||
init();
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
mFrequencyControl.setFrequency(
|
||||
((SourceConfigTuner)mConfig).getFrequency(), false );
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
((SourceConfigTuner)mConfig).setFrequency( mFrequencyControl.getFrequency() );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill", "[left]", "[][grow]" ) );
|
||||
mFrequencyControl = new JFrequencyControl();
|
||||
|
||||
mFrequencyControl.setFrequency(
|
||||
((SourceConfigTuner)mConfig).getFrequency(), false );
|
||||
|
||||
mFrequencyControl.setEnabled( false );
|
||||
mFrequencyControl.addListener( new IFrequencyChangeProcessor()
|
||||
{
|
||||
@Override
|
||||
public void frequencyChanged( FrequencyChangeEvent event )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mFrequencyControl );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration( Channel channel )
|
||||
public void save()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
SourceConfigTuner config = new SourceConfigTuner();
|
||||
config.setFrequency( mFrequencyControl.getFrequency() );
|
||||
getItem().setSourceConfiguration( config );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateConfiguration() throws ConfigurationValidationException
|
||||
public void setItem( Channel item )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
SourceConfiguration config = getItem().getSourceConfiguration();
|
||||
|
||||
if( config instanceof SourceConfigTuner )
|
||||
{
|
||||
mFrequencyControl.setFrequency( ((SourceConfigTuner)config).getFrequency(), false );
|
||||
}
|
||||
|
||||
mFrequencyControl.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFrequencyControl.setEnabled( false );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user