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

@@ -129,12 +129,12 @@ public class ControllerPanel extends JPanel
mTabbedPane = new JideTabbedPane();
mTabbedPane.setFont( this.getFont() );
mTabbedPane.setForeground( Color.BLACK );
mTabbedPane.addTab( "Channels", mPlaylistEditor );
mTabbedPane.addTab( "Configuration", mSystemControlSplitPane );
mTabbedPane.addTab( "Channel Spectrum", mChannelSpectrumPanel );
mTabbedPane.addTab( "Events", mCallEventPanel );
mTabbedPane.addTab( "Messages", mMessageActivityPanel );
mTabbedPane.addTab( "Playlist", mPlaylistEditor );
mTabbedPane.addTab( "Map", mMapPanel );
/**
* Change listener to enable/disable the channel spectrum display
@@ -160,11 +160,6 @@ public class ControllerPanel extends JPanel
}
} );
/**
* Add mapping services and map panel to a new tab
*/
mTabbedPane.addTab( "Map", mMapPanel );
/* Register each of the components to receive channel events when the
* channels are selected or change */
mChannelModel.addListener( mCallEventPanel );
@@ -176,7 +171,6 @@ public class ControllerPanel extends JPanel
channelStateListScroll.getViewport().setView( mChannelStateList );
channelStateListScroll.setPreferredSize( new Dimension( 200, 300 ) );
JideSplitPane audioChannelListSplit = new JideSplitPane( JideSplitPane.VERTICAL_SPLIT );
audioChannelListSplit.setDividerSize( 5 );
audioChannelListSplit.add( mAudioPanel );

View File

@@ -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
@@ -20,6 +20,7 @@ package controller.channel;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -63,11 +64,10 @@ public class ChannelEditor extends JPanel
private RecordComponentEditor mRecordEditor;
private SourceComponentEditor mSourceEditor;
private JTextField mChannelName;
private JCheckBox mChannelEnabled = new JCheckBox();
private JComboBox<AliasList> mComboAliasLists;
private Channel mChannel;
private JCheckBox mChannelEnabled = new JCheckBox();
private ChannelModel mChannelModel;
private PlaylistManager mPlaylistManager;
private SourceManager mSourceManager;
@@ -88,9 +88,18 @@ public class ChannelEditor extends JPanel
initGUI();
}
public void setChannel( Channel channel )
/**
* Sets the channel configuration in each of the channel editor components
* Note: this method must be invoked on the swing event dispatch thread
*/
public void setChannel( final Channel channel )
{
mNameConfigurationEditor.setConfiguration( channel );
mSourceEditor.setConfiguration( channel );
mDecodeEditor.setConfiguration( channel );
mAuxDecodeEditor.setConfiguration( channel );
mEventLogEditor.setConfiguration( channel );
mRecordEditor.setConfiguration( channel );
mChannel = channel;
}
@@ -103,27 +112,28 @@ public class ChannelEditor extends JPanel
add( new JLabel( "Enabled:" ), "wrap" );
add( mNameConfigurationEditor );
add( mNameConfigurationEditor, "growx" );
JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
tabs.addTab( "Name/Alias", mNameConfigurationEditor );
// mSourceEditor = new SourceComponentEditor( mSourceManager, mChannel );
// tabs.addTab( "Source", mSourceEditor );
//
// mDecodeEditor = new DecodeComponentEditor( mPlaylistManager, mChannel );
// tabs.addTab( "Decoder", mDecodeEditor );
//
// mAuxDecodeEditor = new AuxDecodeComponentEditor( mChannel );
// tabs.addTab( "Aux", mAuxDecodeEditor );
//
// mEventLogEditor = new EventLogComponentEditor( mChannel );
// tabs.addTab( "Event Log", mEventLogEditor );
//
// mRecordEditor = new RecordComponentEditor( mChannel );
// tabs.addTab( "Record", mRecordEditor );
mSourceEditor = new SourceComponentEditor( mSourceManager );
tabs.addTab( "Source", mSourceEditor );
mDecodeEditor = new DecodeComponentEditor( mPlaylistManager );
tabs.addTab( "Decoder", mDecodeEditor );
mAuxDecodeEditor = new AuxDecodeComponentEditor();
tabs.addTab( "Aux Decoders", mAuxDecodeEditor );
mEventLogEditor = new EventLogComponentEditor();
tabs.addTab( "Logging", mEventLogEditor );
mRecordEditor = new RecordComponentEditor();
tabs.addTab( "Recording", mRecordEditor );
add( tabs, "span,grow,push" );
@@ -139,7 +149,28 @@ public class ChannelEditor extends JPanel
@Override
public void channelChanged( ChannelEvent event )
{
if( !EventQueue.isDispatchThread() )
{
mLog.debug( "Not on the swing thread!!!!" );
}
if( mChannel != null && mChannel == event.getChannel() )
{
switch( event.getEvent() )
{
case NOTIFICATION_CONFIGURATION_CHANGE:
case NOTIFICATION_PROCESSING_START:
case NOTIFICATION_PROCESSING_STOP:
setChannel( mChannel );
break;
case NOTIFICATION_DELETE:
mChannel = null;
setChannel( mChannel );
break;
default:
break;
}
}
}
@Override
@@ -163,6 +194,17 @@ public class ChannelEditor extends JPanel
{
//Validate each of the configuration editors to check for errors
mNameConfigurationEditor.validateConfiguration();
mSourceEditor.validateConfiguration();
mDecodeEditor.validateConfiguration();
mAuxDecodeEditor.validateConfiguration();
mEventLogEditor.validateConfiguration();
//Validate the source configuration against the decode editor to
//ensure that the source type is compatible with the decode type
//Validate the aux decoders against the primary decoder
//TODO: make sure that no aux decoders are running with P25
// /**
// * Validate the source configuration against the other component
// * configuration editors
@@ -207,6 +249,10 @@ public class ChannelEditor extends JPanel
//Save the contents of each editor to the channel configuration
mNameConfigurationEditor.save();
mSourceEditor.save();
mDecodeEditor.save();
mAuxDecodeEditor.save();
mEventLogEditor.save();
//Broadcast a channel configuration change event
mChannelModel.broadcast( new ChannelEvent( mChannel,

View File

@@ -255,14 +255,32 @@ public class ChannelProcessingManager implements ChannelEventListener
channel.setEnabled( true );
mProcessingChains.put( channel.getChannelID(), processingChain );
mChannelModel.broadcast(
new ChannelEvent( channel, Event.NOTIFICATION_PROCESSING_START ) );
}
private void stopProcessing( Channel channel, boolean remove )
{
mChannelModel.broadcast(
new ChannelEvent( channel, Event.NOTIFICATION_PROCESSING_STOP ) );
if( mProcessingChains.containsKey( channel.getChannelID() ) )
{
ProcessingChain chain = mProcessingChains.get( channel.getChannelID() );
chain.stop();
mChannelModel.broadcast(
new ChannelEvent( channel, Event.NOTIFICATION_PROCESSING_STOP ) );
if( remove )
{
mProcessingChains.remove( channel.getChannelID() );
chain.dispose();
}
}
channel.setEnabled( false );
}
/**

View File

@@ -1,3 +1,20 @@
/*******************************************************************************
* 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 controller.channel;
import java.awt.event.ActionEvent;
@@ -13,9 +30,6 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.miginfocom.swing.MigLayout;
import playlist.PlaylistManager;
import alias.AliasList;
@@ -24,14 +38,14 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( NameConfigurationEditor.class );
private static final String DEFAULT_NAME = "Please select a channel to view/edit";
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
private ChannelModel mChannelModel;
private PlaylistManager mPlaylistManager;
private JTextField mChannelName = new JTextField( "Please select a channel to edit" );
private JTextField mChannelName = new JTextField( DEFAULT_NAME );
private JComboBox<String> mSystemNameCombo = new JComboBox<>( EMPTY_MODEL );
private JComboBox<String> mSiteNameCombo = new JComboBox<>( EMPTY_MODEL );
private JComboBox<AliasList> mAliasListCombo;
@@ -44,7 +58,7 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
mChannelModel = model;
mPlaylistManager = playlistManager;
setLayout( new MigLayout( "fill,wrap 2", "[right][]", "[][][][grow]" ) );
setLayout( new MigLayout( "fill,wrap 2", "[right][]", "[][][][][][grow]" ) );
add( new JLabel( "Name:" ) );
add( mChannelName, "growx" );
@@ -156,7 +170,11 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
mChannel.setSystem( ( system == null ? null : (String)system ) );
Object site = mSiteNameCombo.getSelectedItem();
mChannel.setSystem( ( site == null ? null : (String)site ) );
mChannel.setSite( ( site == null ? null : (String)site ) );
Object aliasList = mAliasListCombo.getSelectedItem();
mChannel.setAliasListName( aliasList == null ? null :
((AliasList)aliasList).getName() );
}
}
@@ -178,44 +196,54 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
{
mChannel = channel;
mChannelName.setText( channel.getName() );
List<String> systems = mChannelModel.getSystems();
if( systems.isEmpty() )
if( mChannel != null )
{
mChannelName.setText( channel.getName() );
List<String> systems = mChannelModel.getSystems();
if( systems.isEmpty() )
{
mSystemNameCombo.setModel( EMPTY_MODEL );
}
else
{
mSystemNameCombo.setModel( new DefaultComboBoxModel<String>(
systems.toArray( new String[ systems.size() ] ) ) );;
}
mSystemNameCombo.setSelectedItem( channel.getSystem() );
List<String> sites = mChannelModel.getSites( channel.getSystem() );
if( sites.isEmpty() )
{
mSiteNameCombo.setModel( EMPTY_MODEL );
}
else
{
mSiteNameCombo.setModel( new DefaultComboBoxModel<String>(
sites.toArray( new String[ sites.size() ] ) ) );;
}
mSiteNameCombo.setSelectedItem( channel.getSite() );
String aliasListName = mChannel.getAliasListName();
if( aliasListName != null )
{
AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
.getAliasList( aliasListName );
mAliasListCombo.setSelectedItem( selected );
}
}
else
{
mChannelName.setText( DEFAULT_NAME );
mSystemNameCombo.setModel( EMPTY_MODEL );
}
else
{
mSystemNameCombo.setModel( new DefaultComboBoxModel<String>(
systems.toArray( new String[ systems.size() ] ) ) );;
}
mSystemNameCombo.setSelectedItem( channel.getSystem() );
List<String> sites = mChannelModel.getSites( channel.getSystem() );
if( sites.isEmpty() )
{
mSiteNameCombo.setModel( EMPTY_MODEL );
mAliasListCombo.setSelectedIndex( 0 );
}
else
{
mSiteNameCombo.setModel( new DefaultComboBoxModel<String>(
sites.toArray( new String[ sites.size() ] ) ) );;
}
mSiteNameCombo.setSelectedItem( channel.getSite() );
String aliasListName = mChannel.getAliasListName();
if( aliasListName != null )
{
AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
.getAliasList( aliasListName );
mAliasListCombo.setSelectedItem( selected );
}
}
}

View File

@@ -132,19 +132,19 @@ public class OldChannelEditor extends ChannelConfigurationEditor implements Acti
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
mSourceEditor = new SourceComponentEditor( mSourceManager, mChannel );
mSourceEditor = new SourceComponentEditor( mSourceManager );
tabs.addTab( "Source", mSourceEditor );
mDecodeEditor = new DecodeComponentEditor( mPlaylistManager, mChannel );
mDecodeEditor = new DecodeComponentEditor( mPlaylistManager );
tabs.addTab( "Decoder", mDecodeEditor );
mAuxDecodeEditor = new AuxDecodeComponentEditor( mChannel );
mAuxDecodeEditor = new AuxDecodeComponentEditor();
tabs.addTab( "Aux", mAuxDecodeEditor );
mEventLogEditor = new EventLogComponentEditor( mChannel );
mEventLogEditor = new EventLogComponentEditor();
tabs.addTab( "Event Log", mEventLogEditor );
mRecordEditor = new RecordComponentEditor( mChannel );
mRecordEditor = new RecordComponentEditor();
tabs.addTab( "Record", mRecordEditor );
add( tabs, "span,grow,push" );