Work in progress - updates channel component editors and changes

functionality so that the editor starts up without a channel displayed
and as each channel row is selected in the channels table, the editor is
updated with the channel configuration.

Likewise, the channel editor is now a channel event listener on the
channel model and will maintain channel state if the user changes
channel configuration in any of the external channel controllers like
the spectral display or the channel list.
This commit is contained in:
denny
2016-01-11 20:35:53 -05:00
parent 4be63d4b95
commit 7d1ec344de
13 changed files with 381 additions and 323 deletions

View File

@@ -28,22 +28,21 @@ import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
import source.config.SourceConfigFactory;
import source.config.SourceConfiguration;
import controller.channel.AbstractChannelEditor;
import controller.channel.Channel;
import controller.channel.ChannelConfigurationEditor;
import controller.channel.ConfigurationValidationException;
public class SourceComponentEditor extends AbstractChannelEditor
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, Channel channel )
public SourceComponentEditor( SourceManager sourceManager )
{
super( channel );
mSourceManager = sourceManager;
setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) );
@@ -60,15 +59,15 @@ public class SourceComponentEditor extends AbstractChannelEditor
if( selected != null )
{
SourceConfiguration config;
if( selected == mChannel.getSourceConfiguration().getSourceType() )
if( mChannel == null ||
mChannel.getSourceConfiguration().getSourceType() != selected )
{
config = mChannel.getSourceConfiguration();
config = SourceConfigFactory.getSourceConfiguration( selected );
}
else
{
config = SourceConfigFactory
.getSourceConfiguration( selected );
config = mChannel.getSourceConfiguration();
}
//Remove the existing one
@@ -91,8 +90,6 @@ public class SourceComponentEditor extends AbstractChannelEditor
add( new JLabel( "Source:" ) );
add( mComboSources, "wrap" );
reset();
}
public SourceEditor getSourceEditor()
@@ -100,24 +97,6 @@ public class SourceComponentEditor extends AbstractChannelEditor
return mEditor;
}
public void reset()
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
mComboSources.setSelectedItem(
mChannel.getSourceConfiguration().getSourceType() );
mComboSources.requestFocus();
mComboSources.requestFocusInWindow();
}
});
}
@Override
public void save()
{
@@ -127,17 +106,29 @@ public class SourceComponentEditor extends AbstractChannelEditor
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 )
{
// TODO Auto-generated method stub
mChannel = channel;
if( mChannel != null )
{
mComboSources.setSelectedItem(
mChannel.getSourceConfiguration().getSourceType() );
mComboSources.requestFocus();
mComboSources.requestFocusInWindow();
}
}
@Override
public void validateConfiguration() throws ConfigurationValidationException
{
// TODO Auto-generated method stub
}
}