mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
Work in progress.
-Started work on new channel editor channel viewer/controller -Removed a number of unused buffer package classes -Moved automatic frequency control to be a module and removed special handling -Added IUnfilteredRealBufferListener & Provider interfaces -Completely removed the ResourceManager class
This commit is contained in:
88
src/playlist/PlaylistEditor.java
Normal file
88
src/playlist/PlaylistEditor.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package playlist;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.coderazzi.filters.gui.AutoChoices;
|
||||
import net.coderazzi.filters.gui.TableFilterHeader;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import source.SourceManager;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEditor;
|
||||
import controller.channel.ChannelModel;
|
||||
|
||||
public class PlaylistEditor extends JPanel implements ListSelectionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( PlaylistEditor.class );
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private JTable mChannelTable;
|
||||
private ChannelEditor mEditor;
|
||||
|
||||
public PlaylistEditor( ChannelModel channelModel,
|
||||
PlaylistManager playlistManager,
|
||||
SourceManager sourceManager )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
|
||||
mEditor = new ChannelEditor( channelModel, playlistManager, sourceManager );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0",
|
||||
"[grow,fill]",
|
||||
"[grow,fill]") );
|
||||
|
||||
//System Configuration View and Editor
|
||||
mChannelTable = new JTable( mChannelModel );
|
||||
mChannelTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
mChannelTable.getSelectionModel().addListSelectionListener( this );
|
||||
mChannelTable.setAutoCreateRowSorter( true );
|
||||
|
||||
TableFilterHeader channelHeaderFilter = new TableFilterHeader( mChannelTable );
|
||||
channelHeaderFilter.setAutoChoices( AutoChoices.ENABLED );
|
||||
|
||||
JScrollPane channelScroller = new JScrollPane( mChannelTable );
|
||||
|
||||
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
splitPane.setDividerSize( 5 );
|
||||
splitPane.add( channelScroller );
|
||||
splitPane.add( mEditor );
|
||||
|
||||
add( splitPane );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
//This limits event firing to only when selection is complete
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int index = mChannelTable.convertRowIndexToModel( mChannelTable.getSelectedRow() );
|
||||
|
||||
mLog.debug( "Index:" + index );
|
||||
|
||||
Channel channel = mChannelModel.getChannels().get( index );
|
||||
|
||||
if( channel != null )
|
||||
{
|
||||
mEditor.setChannel( channel );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,6 @@ public class PlaylistManager
|
||||
public PlaylistManager( ChannelModel channelModel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
init();
|
||||
}
|
||||
|
||||
public Playlist getPlayist()
|
||||
@@ -73,7 +72,7 @@ public class PlaylistManager
|
||||
* Loads playlist from the current playlist file, or the default playlist file,
|
||||
* as specified in the current SDRTRunk system settings
|
||||
*/
|
||||
private void init()
|
||||
public void init()
|
||||
{
|
||||
SystemProperties props = SystemProperties.getInstance();
|
||||
|
||||
@@ -163,6 +162,75 @@ public class PlaylistManager
|
||||
}
|
||||
}
|
||||
|
||||
private void createBackupPlaylist()
|
||||
{
|
||||
SystemProperties props = SystemProperties.getInstance();
|
||||
|
||||
Path playlistPath = props.getApplicationFolder( "playlist" );
|
||||
|
||||
String playlistDefault = props.get( "playlist.defaultfilename",
|
||||
"playlist.xml" );
|
||||
|
||||
String playlistCurrent = props.get( "playlist.currentfilename",
|
||||
playlistDefault );
|
||||
|
||||
Path current = playlistPath.resolve( playlistCurrent );
|
||||
|
||||
if( Files.exists( current ) )
|
||||
{
|
||||
int revision = 1;
|
||||
|
||||
String playlistBackup = playlistCurrent.replace( ".xml", "_backup_" + revision + ".xml" );
|
||||
|
||||
Path filePath = playlistPath.resolve( playlistBackup );
|
||||
|
||||
while( Files.exists( filePath ) )
|
||||
{
|
||||
revision++;
|
||||
|
||||
playlistBackup = playlistCurrent.replace( ".xml", "_backup_" + revision + ".xml" );
|
||||
|
||||
filePath = playlistPath.resolve( playlistBackup );
|
||||
|
||||
if( revision > 10 )
|
||||
{
|
||||
mLog.error( "Couldn't create playlist backup - maximum revisions exceeded" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File outputFile = new File( filePath.toString() );
|
||||
|
||||
try
|
||||
{
|
||||
if( !outputFile.exists() )
|
||||
{
|
||||
outputFile.createNewFile();
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
mLog.error( "PlaylistManager - couldn't create file to save "
|
||||
+ "playlist backup [" + filePath.toString() + "]" );
|
||||
}
|
||||
|
||||
try( OutputStream out = new FileOutputStream( outputFile ) )
|
||||
{
|
||||
Files.copy( current, out );
|
||||
|
||||
mLog.info( "Playlist backed up to:" + filePath );
|
||||
}
|
||||
catch( IOException ioe )
|
||||
{
|
||||
mLog.error( "Error copying playlist to backup file [" + filePath + "]" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.error( "Couldn't create backup playlist - original playlist does not exist" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases current playlist and loads playlist from the playlistPath filename,
|
||||
* if it exists.
|
||||
@@ -238,6 +306,8 @@ public class PlaylistManager
|
||||
{
|
||||
mLog.info( "Legacy playlist format detected - converting ..." );
|
||||
|
||||
createBackupPlaylist();
|
||||
|
||||
//Playlist version 1 to version 2 format conversion. In order to keep
|
||||
//backwards compatibility, transfer all of the System-Site-Channel
|
||||
//objects over to the new channel list format
|
||||
|
||||
@@ -19,10 +19,14 @@ package playlist;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.SourceManager;
|
||||
import alias.AliasDirectory;
|
||||
import alias.AliasDirectoryNode;
|
||||
import controller.BaseNode;
|
||||
import controller.EmptyEditor;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.map.ChannelMapList;
|
||||
import controller.channel.map.ChannelMapListNode;
|
||||
import controller.system.SystemList;
|
||||
@@ -35,11 +39,27 @@ public class PlaylistNode extends BaseNode
|
||||
private ChannelMapListNode mChannelMapListNode;
|
||||
private SystemListNode mSystemListNode;
|
||||
|
||||
public PlaylistNode()
|
||||
{
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
private PlaylistManager mPlaylistManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
public PlaylistNode( ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
PlaylistManager playlistManager,
|
||||
SettingsManager settingsManager,
|
||||
SourceManager sourceManager )
|
||||
{
|
||||
super( null );
|
||||
}
|
||||
|
||||
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mPlaylistManager = playlistManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mSourceManager = sourceManager;
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
/**
|
||||
@@ -58,7 +78,8 @@ public class PlaylistNode extends BaseNode
|
||||
getPlaylist().setAliasDirectory( directory );
|
||||
}
|
||||
|
||||
mAliasDirectoryNode = new AliasDirectoryNode( directory );
|
||||
mAliasDirectoryNode = new AliasDirectoryNode( mPlaylistManager,
|
||||
mSettingsManager, directory );
|
||||
|
||||
getModel().insertNodeInto( mAliasDirectoryNode, this, 0 );
|
||||
|
||||
@@ -74,7 +95,7 @@ public class PlaylistNode extends BaseNode
|
||||
channelMapList = new ChannelMapList();
|
||||
}
|
||||
|
||||
mChannelMapListNode = new ChannelMapListNode( channelMapList );
|
||||
mChannelMapListNode = new ChannelMapListNode( mPlaylistManager, channelMapList );
|
||||
|
||||
getModel().insertNodeInto( mChannelMapListNode, this, 1 );
|
||||
|
||||
@@ -91,7 +112,8 @@ public class PlaylistNode extends BaseNode
|
||||
getPlaylist().setSystemList( list );
|
||||
}
|
||||
|
||||
mSystemListNode = new SystemListNode( list );
|
||||
mSystemListNode = new SystemListNode( list, mChannelModel,
|
||||
mChannelProcessingManager, mPlaylistManager, mSourceManager );
|
||||
|
||||
getModel().insertNodeInto( mSystemListNode, this, 2 );
|
||||
|
||||
@@ -112,8 +134,7 @@ public class PlaylistNode extends BaseNode
|
||||
|
||||
public void loadPlaylist()
|
||||
{
|
||||
Playlist playlist =
|
||||
getModel().getResourceManager().getPlaylistManager().getPlayist();
|
||||
Playlist playlist = mPlaylistManager.getPlayist();
|
||||
|
||||
setUserObject( playlist );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user