mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
WIP #34: added channel map manager and new editor window. Removed a
number of unused classes. Removed playlist manager from a number of classes and replaced with the alias, channel and channel map models. Updated playlist manager to no longer retain a playlist except for when loading to models or when storing from models. Extracted version 1 to version 2 playlist conversion and changed playlist manager to keep the original version 1 playlist and create a new version 2 (playlist_v2.xml) file. On startup, try to load a v2, and if not, look for a v1 to convert. Otherwise, don't create a playlist and one will be created once the user adds items to the models.
This commit is contained in:
@@ -27,12 +27,11 @@ import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import playlist.PlaylistManager;
|
||||
import alias.AliasList;
|
||||
import alias.AliasModel;
|
||||
|
||||
public class NameConfigurationEditor extends ChannelConfigurationEditor
|
||||
{
|
||||
@@ -42,21 +41,20 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
||||
|
||||
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private ChannelModel mChannelModel;
|
||||
private PlaylistManager mPlaylistManager;
|
||||
|
||||
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;
|
||||
private JComboBox<String> mAliasListCombo;
|
||||
|
||||
private Channel mChannel;
|
||||
|
||||
public NameConfigurationEditor( ChannelModel model,
|
||||
PlaylistManager playlistManager )
|
||||
public NameConfigurationEditor( AliasModel aliasModel, ChannelModel model )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mChannelModel = model;
|
||||
mPlaylistManager = playlistManager;
|
||||
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][]", "[][][][][][grow]" ) );
|
||||
|
||||
@@ -110,15 +108,14 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
||||
*/
|
||||
add( new JLabel( "Alias List:" ) );
|
||||
|
||||
mAliasListCombo = new JComboBox<AliasList>();
|
||||
mAliasListCombo = new JComboBox<String>();
|
||||
|
||||
List<AliasList> lists = mPlaylistManager.getPlayist()
|
||||
.getAliasDirectory().getAliasList();
|
||||
List<String> lists = mAliasModel.getListNames();
|
||||
|
||||
Collections.sort( lists );
|
||||
|
||||
mAliasListCombo.setModel( new DefaultComboBoxModel<AliasList>(
|
||||
lists.toArray( new AliasList[ lists.size() ] ) ) );
|
||||
mAliasListCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
lists.toArray( new String[ lists.size() ] ) ) );
|
||||
|
||||
add( mAliasListCombo, "growx" );
|
||||
|
||||
@@ -126,35 +123,35 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
||||
|
||||
final JButton aliasListButton = new JButton( "New Alias List ..." );
|
||||
|
||||
aliasListButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String name = JOptionPane.showInputDialog( aliasListButton,
|
||||
"Please enter an Alias List name:" );
|
||||
|
||||
if( name != null && !name.isEmpty() )
|
||||
{
|
||||
AliasList aliasList = new AliasList( name );
|
||||
|
||||
mPlaylistManager.getPlayist().getAliasDirectory()
|
||||
.addAliasList( aliasList );
|
||||
|
||||
mPlaylistManager.save();
|
||||
|
||||
List<AliasList> lists = mPlaylistManager.getPlayist()
|
||||
.getAliasDirectory().getAliasList();
|
||||
|
||||
Collections.sort( lists );
|
||||
|
||||
mAliasListCombo.setModel( new DefaultComboBoxModel<AliasList>(
|
||||
lists.toArray( new AliasList[ lists.size() ] ) ) );
|
||||
|
||||
mAliasListCombo.setSelectedItem( aliasList );
|
||||
}
|
||||
}
|
||||
} );
|
||||
// aliasListButton.addActionListener( new ActionListener()
|
||||
// {
|
||||
// @Override
|
||||
// public void actionPerformed( ActionEvent e )
|
||||
// {
|
||||
// String name = JOptionPane.showInputDialog( aliasListButton,
|
||||
// "Please enter an Alias List name:" );
|
||||
//
|
||||
// if( name != null && !name.isEmpty() )
|
||||
// {
|
||||
// AliasListOld aliasList = new AliasListOld( name );
|
||||
//
|
||||
// mPlaylistManager.getPlayist().getAliasDirectory()
|
||||
// .addAliasList( aliasList );
|
||||
//
|
||||
// mPlaylistManager.save();
|
||||
//
|
||||
// List<AliasListOld> lists = mPlaylistManager.getPlayist()
|
||||
// .getAliasDirectory().getAliasList();
|
||||
//
|
||||
// Collections.sort( lists );
|
||||
//
|
||||
// mAliasListCombo.setModel( new DefaultComboBoxModel<AliasListOld>(
|
||||
// lists.toArray( new AliasListOld[ lists.size() ] ) ) );
|
||||
//
|
||||
// mAliasListCombo.setSelectedItem( aliasList );
|
||||
// }
|
||||
// }
|
||||
// } );
|
||||
|
||||
add( aliasListButton, "growx" );
|
||||
}
|
||||
@@ -173,8 +170,7 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
||||
mChannel.setSite( ( site == null ? null : (String)site ) );
|
||||
|
||||
Object aliasList = mAliasListCombo.getSelectedItem();
|
||||
mChannel.setAliasListName( aliasList == null ? null :
|
||||
((AliasList)aliasList).getName() );
|
||||
mChannel.setAliasListName( aliasList == null ? null : (String)aliasList );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,10 +228,7 @@ public class NameConfigurationEditor extends ChannelConfigurationEditor
|
||||
|
||||
if( aliasListName != null )
|
||||
{
|
||||
AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory()
|
||||
.getAliasList( aliasListName );
|
||||
|
||||
mAliasListCombo.setSelectedItem( selected );
|
||||
mAliasListCombo.setSelectedItem( aliasListName );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user