mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Updates playlist editor with Add, Copy/Clone and Delete channel
functionality
This commit is contained in:
@@ -23,14 +23,17 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import module.decode.DecoderType;
|
||||
import module.decode.config.AuxDecodeConfiguration;
|
||||
import module.decode.config.DecodeConfigFactory;
|
||||
import module.decode.config.DecodeConfiguration;
|
||||
import module.log.EventLogType;
|
||||
import module.log.config.EventLogConfiguration;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import record.RecorderType;
|
||||
import record.config.RecordConfiguration;
|
||||
import source.SourceType;
|
||||
import source.config.SourceConfigFactory;
|
||||
@@ -115,6 +118,50 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
||||
{
|
||||
mChannelID = UNIQUE_ID++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a (new) deep copy of this channel
|
||||
*/
|
||||
public Channel copyOf()
|
||||
{
|
||||
Channel channel = new Channel( mName );
|
||||
channel.setSystem( mSystem );
|
||||
channel.setSite( mSite );
|
||||
channel.setAliasListName( mAliasListName );
|
||||
|
||||
AuxDecodeConfiguration aux = new AuxDecodeConfiguration();
|
||||
|
||||
for( DecoderType auxType: aux.getAuxDecoders() )
|
||||
{
|
||||
aux.addAuxDecoder( auxType );
|
||||
}
|
||||
|
||||
channel.setAuxDecodeConfiguration( aux );
|
||||
|
||||
channel.setDecodeConfiguration( DecodeConfigFactory.copy( mDecodeConfiguration ) );
|
||||
|
||||
EventLogConfiguration log = new EventLogConfiguration();
|
||||
|
||||
for( EventLogType logType: mEventLogConfiguration.getLoggers() )
|
||||
{
|
||||
log.addLogger( logType );
|
||||
}
|
||||
|
||||
channel.setEventLogConfiguration( log );
|
||||
|
||||
RecordConfiguration record = new RecordConfiguration();
|
||||
|
||||
for( RecorderType recordType: mRecordConfiguration.getRecorders() )
|
||||
{
|
||||
record.addRecorder( recordType );
|
||||
}
|
||||
|
||||
channel.setRecordConfiguration( record );
|
||||
|
||||
channel.setSourceConfiguration( SourceConfigFactory.copy( mSourceConfiguration ) );
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
//TODO: remove this
|
||||
/**
|
||||
|
||||
@@ -17,21 +17,16 @@
|
||||
******************************************************************************/
|
||||
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;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import module.decode.AuxDecodeComponentEditor;
|
||||
import module.decode.DecodeComponentEditor;
|
||||
@@ -45,7 +40,6 @@ import playlist.PlaylistManager;
|
||||
import record.RecordComponentEditor;
|
||||
import source.SourceComponentEditor;
|
||||
import source.SourceManager;
|
||||
import alias.AliasList;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
@@ -169,7 +163,6 @@ public class ChannelEditor extends JPanel
|
||||
@Override
|
||||
public void channelChanged( ChannelEvent event )
|
||||
{
|
||||
mLog.debug( "Received channel event: " + event.getEvent() );
|
||||
if( mChannel != null && mChannel == event.getChannel() )
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
@@ -302,36 +295,6 @@ public class ChannelEditor extends JPanel
|
||||
mChannelModel.broadcast( new ChannelEvent( mChannel,
|
||||
Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void reset()
|
||||
// {
|
||||
// mChannelName.setText( mChannel.getName() );
|
||||
// mChannelName.requestFocus();
|
||||
// mChannelName.requestFocusInWindow();
|
||||
//
|
||||
// mChannelEnabled.setSelected( mChannel.getEnabled() );
|
||||
// mChannelEnabled.requestFocus();
|
||||
// mChannelEnabled.requestFocusInWindow();
|
||||
//
|
||||
// String aliasListName = mChannel.getAliasListName();
|
||||
//
|
||||
// if( aliasListName != null )
|
||||
// {
|
||||
// AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
|
||||
// .getAliasList( aliasListName );
|
||||
//
|
||||
// mComboAliasLists.setSelectedItem( selected );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// mSourceEditor.reset();
|
||||
// mDecodeEditor.reset();
|
||||
// mAuxDecodeEditor.reset();
|
||||
// mEventLogEditor.reset();
|
||||
// mRecordEditor.reset();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Validate the specified editor against each of the component editors
|
||||
// */
|
||||
|
||||
@@ -26,6 +26,10 @@ import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import playlist.PlaylistEditor;
|
||||
import module.decode.DecoderType;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
import controller.channel.ChannelEvent.Event;
|
||||
@@ -35,6 +39,8 @@ import controller.channel.ChannelEvent.Event;
|
||||
*/
|
||||
public class ChannelModel implements IChannelEventBroadcaster, TableModel
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( ChannelModel.class );
|
||||
|
||||
private ChannelSelectionManager mChannelSelectionManager;
|
||||
private List<Channel> mChannels = new ArrayList<>();
|
||||
private List<Channel> mTrafficChannels = new ArrayList<>();
|
||||
@@ -55,6 +61,16 @@ public class ChannelModel implements IChannelEventBroadcaster, TableModel
|
||||
return Collections.unmodifiableList( mChannels );
|
||||
}
|
||||
|
||||
public Channel getChannelAtIndex( int row )
|
||||
{
|
||||
if( mChannels.size() >= row )
|
||||
{
|
||||
return mChannels.get( row );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of unique system values from across the channel set
|
||||
*/
|
||||
@@ -150,20 +166,23 @@ public class ChannelModel implements IChannelEventBroadcaster, TableModel
|
||||
/**
|
||||
* Adds the channel to the model and broadcasts a channel add event
|
||||
*/
|
||||
public void addChannel( Channel channel )
|
||||
public int addChannel( Channel channel )
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
switch( channel.getChannelType() )
|
||||
{
|
||||
case STANDARD:
|
||||
mChannels.add( channel );
|
||||
|
||||
int index = mChannels.size() - 1;
|
||||
index = mChannels.size() - 1;
|
||||
|
||||
broadcast( new TableModelEvent( this, index, index,
|
||||
TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT ) );
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mTrafficChannels.add( channel );
|
||||
index = mChannels.size() - 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -175,6 +194,8 @@ public class ChannelModel implements IChannelEventBroadcaster, TableModel
|
||||
{
|
||||
broadcast( new ChannelEvent( channel, Event.REQUEST_ENABLE ) );
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,27 +203,30 @@ public class ChannelModel implements IChannelEventBroadcaster, TableModel
|
||||
*/
|
||||
public void removeChannel( Channel channel )
|
||||
{
|
||||
switch( channel.getChannelType() )
|
||||
if( channel != null )
|
||||
{
|
||||
case STANDARD:
|
||||
int index = mChannels.indexOf( channel );
|
||||
|
||||
mChannels.remove( channel );
|
||||
switch( channel.getChannelType() )
|
||||
{
|
||||
case STANDARD:
|
||||
int index = mChannels.indexOf( channel );
|
||||
|
||||
mChannels.remove( channel );
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
broadcast( new TableModelEvent( this, index, index,
|
||||
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE ) );
|
||||
}
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mTrafficChannels.remove( channel );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if( index >= 0 )
|
||||
{
|
||||
broadcast( new TableModelEvent( this, index, index,
|
||||
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE ) );
|
||||
}
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mTrafficChannels.remove( channel );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
broadcast( new ChannelEvent( channel, Event.NOTIFICATION_DELETE ) );
|
||||
}
|
||||
|
||||
broadcast( new ChannelEvent( channel, Event.NOTIFICATION_DELETE ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user