wip #34 - finished updating all channel configuration editors and

completed preliminary functional testing.
This commit is contained in:
denny
2016-03-25 14:26:08 -04:00
parent e89e7bd361
commit 112083a22f
32 changed files with 1328 additions and 946 deletions

View File

@@ -25,9 +25,9 @@ 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.SourceConfiguration;
import source.mixer.MixerSourceEditor;
import source.tuner.TunerSourceEditor;
import controller.channel.Channel;
@@ -44,13 +44,22 @@ public class SourceConfigurationEditor extends Editor<Channel>
public SourceConfigurationEditor( SourceManager sourceManager )
{
mMixerSourceEditor = new MixerSourceEditor( sourceManager );
mMixerSourceEditor.setSaveRequestListener( this );
mTunerSourceEditor = new TunerSourceEditor();
mTunerSourceEditor.setSaveRequestListener( this );
init();
}
public SourceConfiguration getSourceConfiguration()
{
return hasItem() ? getItem().getSourceConfiguration() : null;
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 3", "[right][left][grow,fill]", "[][grow]" ) );
setLayout( new MigLayout( "wrap 2", "[][grow,fill]", "[align top][grow]" ) );
mComboSources = new JComboBox<SourceType>();
mComboSources.setModel( new DefaultComboBoxModel<SourceType>( SourceType.getTypes() ) );
@@ -76,7 +85,6 @@ public class SourceConfigurationEditor extends Editor<Channel>
}
});
add( new JLabel( "Source:" ) );
add( mComboSources );
mCurrentEditor = mTunerSourceEditor;
@@ -87,10 +95,16 @@ public class SourceConfigurationEditor extends Editor<Channel>
{
if( mCurrentEditor != editor )
{
//Set channel to null to force a save prompt as required
mCurrentEditor.setItem( null );
remove( mCurrentEditor );
mCurrentEditor = editor;
mCurrentEditor.setSaveRequestListener( this );
add( mCurrentEditor );
mCurrentEditor.setItem( getItem() );
revalidate();
}
}
@@ -98,18 +112,12 @@ public class SourceConfigurationEditor extends Editor<Channel>
@Override
public void save()
{
if( hasItem() && mCurrentEditor.isModified() )
if( hasItem() )
{
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.
@@ -121,8 +129,9 @@ public class SourceConfigurationEditor extends Editor<Channel>
if( hasItem() )
{
mMixerSourceEditor.setItem( channel );
mTunerSourceEditor.setItem( channel );
mComboSources.setSelectedItem( getItem().getSourceConfiguration().getSourceType() );
repaint();
mCurrentEditor.setItem( channel );
}
}
}

View File

@@ -50,7 +50,7 @@ public class MixerSourceEditor extends Editor<Channel>
private void init()
{
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]", "[][grow]" ) );
setLayout( new MigLayout( "insets 0 0 0 0,wrap 4", "[right][grow,fill][right][grow,fill]", "" ) );
mComboMixers = new JComboBox<InputMixerConfiguration>();
InputMixerConfiguration[] inputMixers = mSourceManager.getMixerManager().getInputMixers();
@@ -68,6 +68,8 @@ public class MixerSourceEditor extends Editor<Channel>
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
repaint();
setModified( true );
}
} );
@@ -76,6 +78,17 @@ public class MixerSourceEditor extends Editor<Channel>
add( mComboMixers );
mComboChannels = new JComboBox<MixerChannel>();
InputMixerConfiguration selected = (InputMixerConfiguration)mComboMixers.getSelectedItem();
if( selected != null )
{
EnumSet<MixerChannel> channels = selected.getChannels();
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
}
mComboChannels.setEnabled( false );
mComboChannels.addActionListener( new ActionListener()
{
@@ -114,24 +127,33 @@ public class MixerSourceEditor extends Editor<Channel>
for( MixerChannel channel: inputMixer.getChannels() )
{
if( channel.getLabel().equalsIgnoreCase( mixer.getChannel().getLabel() ) )
if( channel.getLabel() != null && mixer.getChannel() != null )
{
mComboChannels.setSelectedItem( channel );
if( channel.getLabel().equalsIgnoreCase( mixer.getChannel().getLabel() ) )
{
mComboChannels.setSelectedItem( channel );
}
}
}
continue;
}
}
setModified( false );
}
else
{
setModified( true );
}
}
else
{
mComboMixers.setEnabled( false );
mComboChannels.setEnabled( false );
setModified( false );
}
setModified( false );
}
public void save()

View File

@@ -38,7 +38,7 @@ public class TunerSourceEditor extends Editor<Channel>
private void init()
{
setLayout( new MigLayout( "fill", "[left]", "[][grow]" ) );
setLayout( new MigLayout( "insets 0 0 0 0", "[left]", "" ) );
mFrequencyControl = new JFrequencyControl();
mFrequencyControl.setEnabled( false );
mFrequencyControl.addListener( new IFrequencyChangeProcessor()
@@ -73,18 +73,23 @@ public class TunerSourceEditor extends Editor<Channel>
{
SourceConfiguration config = getItem().getSourceConfiguration();
mFrequencyControl.setEnabled( true );
if( config instanceof SourceConfigTuner )
{
mFrequencyControl.setFrequency( ((SourceConfigTuner)config).getFrequency(), false );
setModified( false );
}
else
{
mFrequencyControl.setFrequency( 101000000, false );
setModified( true );
}
mFrequencyControl.setEnabled( true );
}
else
{
mFrequencyControl.setEnabled( false );
setModified( false );
}
setModified( false );
}
}