mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 10:37:26 -05:00
Adds AliasModel and AliasEvent and support for conversion from legacy
playlist format. Renames PlaylistEditor to ChannelController
This commit is contained in:
@@ -29,6 +29,8 @@ import audio.inverted.AudioType;
|
|||||||
|
|
||||||
public class Alias
|
public class Alias
|
||||||
{
|
{
|
||||||
|
private String mList;
|
||||||
|
private String mGroup;
|
||||||
private String mName;
|
private String mName;
|
||||||
private int mColor;
|
private int mColor;
|
||||||
private String mIconName;
|
private String mIconName;
|
||||||
@@ -44,7 +46,7 @@ public class Alias
|
|||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute( name="name" )
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
@@ -55,6 +57,38 @@ public class Alias
|
|||||||
mName = name;
|
mName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlAttribute( name="list" )
|
||||||
|
public String getList()
|
||||||
|
{
|
||||||
|
return mList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList( String list )
|
||||||
|
{
|
||||||
|
mList = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasList()
|
||||||
|
{
|
||||||
|
return mList != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute( name="group" )
|
||||||
|
public String getGroup()
|
||||||
|
{
|
||||||
|
return mGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup( String group )
|
||||||
|
{
|
||||||
|
mGroup = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasGroup()
|
||||||
|
{
|
||||||
|
return mGroup != null;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
public int getColor()
|
public int getColor()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ public class AliasDirectory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearAliasLists()
|
||||||
|
{
|
||||||
|
mAliasList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement( name = "alias_list" )
|
@XmlElement( name = "alias_list" )
|
||||||
public ArrayList<AliasList> getAliasList()
|
public ArrayList<AliasList> getAliasList()
|
||||||
{
|
{
|
||||||
|
|||||||
55
src/alias/AliasEvent.java
Normal file
55
src/alias/AliasEvent.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 alias;
|
||||||
|
|
||||||
|
public class AliasEvent
|
||||||
|
{
|
||||||
|
private Alias mAlias;
|
||||||
|
private Event mEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AliasEvent - event describing any changes to an alias
|
||||||
|
* @param alias - alias that changed
|
||||||
|
* @param event - change event
|
||||||
|
*/
|
||||||
|
public AliasEvent( Alias alias, Event event )
|
||||||
|
{
|
||||||
|
mAlias = alias;
|
||||||
|
mEvent = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Alias getAlias()
|
||||||
|
{
|
||||||
|
return mAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Event getEvent()
|
||||||
|
{
|
||||||
|
return mEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel events to describe the specific event
|
||||||
|
*/
|
||||||
|
public enum Event
|
||||||
|
{
|
||||||
|
ADD,
|
||||||
|
CHANGE,
|
||||||
|
DELETE;
|
||||||
|
}
|
||||||
|
}
|
||||||
273
src/alias/AliasModel.java
Normal file
273
src/alias/AliasModel.java
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 alias;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
|
import javax.swing.event.TableModelListener;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import alias.AliasEvent.Event;
|
||||||
|
import sample.Broadcaster;
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias Model
|
||||||
|
*/
|
||||||
|
public class AliasModel implements TableModel
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger( AliasModel.class );
|
||||||
|
|
||||||
|
private List<Alias> mAliases = new ArrayList<>();
|
||||||
|
private List<TableModelListener> mTableModelListeners = new CopyOnWriteArrayList<>();
|
||||||
|
private Broadcaster<AliasEvent> mAliasEventBroadcaster = new Broadcaster<>();
|
||||||
|
|
||||||
|
public AliasModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unmodifiable list of all aliases currently in the model
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList( mAliases );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Alias getAliasAtIndex( int row )
|
||||||
|
{
|
||||||
|
if( mAliases.size() >= row )
|
||||||
|
{
|
||||||
|
return mAliases.get( row );
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of unique alias list names from across the alias set
|
||||||
|
*/
|
||||||
|
public List<String> getListNames()
|
||||||
|
{
|
||||||
|
List<String> listNames = new ArrayList<>();
|
||||||
|
|
||||||
|
for( Alias alias: mAliases )
|
||||||
|
{
|
||||||
|
if( alias.hasList() && !listNames.contains( alias.getList() ) )
|
||||||
|
{
|
||||||
|
listNames.add( alias.getList() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort( listNames );
|
||||||
|
|
||||||
|
return listNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of alias group names for all aliases that have a matching
|
||||||
|
* list name value
|
||||||
|
*/
|
||||||
|
public List<String> getGroupNames( String listName )
|
||||||
|
{
|
||||||
|
List<String> groupNames = new ArrayList<>();
|
||||||
|
|
||||||
|
if( listName != null )
|
||||||
|
{
|
||||||
|
for( Alias alias: mAliases )
|
||||||
|
{
|
||||||
|
if( alias.hasList() &&
|
||||||
|
alias.hasGroup() &&
|
||||||
|
listName.equals( alias.getList() ) &&
|
||||||
|
!groupNames.contains( alias.getGroup() ) )
|
||||||
|
{
|
||||||
|
groupNames.add( alias.getGroup() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort( groupNames );
|
||||||
|
|
||||||
|
return groupNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bulk loading of aliases
|
||||||
|
*/
|
||||||
|
public void addAliases( List<Alias> aliases )
|
||||||
|
{
|
||||||
|
for( Alias alias: aliases )
|
||||||
|
{
|
||||||
|
addAlias( alias );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the alias to the model
|
||||||
|
*/
|
||||||
|
public int addAlias( Alias alias )
|
||||||
|
{
|
||||||
|
if( alias != null )
|
||||||
|
{
|
||||||
|
mAliases.add( alias );
|
||||||
|
|
||||||
|
int index = mAliases.size() - 1;
|
||||||
|
|
||||||
|
broadcast( new TableModelEvent( this, index, index,
|
||||||
|
TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT ) );
|
||||||
|
|
||||||
|
broadcast( new AliasEvent( alias, Event.ADD ) );
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the channel from the model and broadcasts a channel remove event
|
||||||
|
*/
|
||||||
|
public void removeAlias( Alias alias )
|
||||||
|
{
|
||||||
|
if( alias != null )
|
||||||
|
{
|
||||||
|
int index = mAliases.indexOf( alias );
|
||||||
|
|
||||||
|
mAliases.remove( alias );
|
||||||
|
|
||||||
|
broadcast( new TableModelEvent( this, index, index,
|
||||||
|
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE ) );
|
||||||
|
|
||||||
|
broadcast( new AliasEvent( alias, Event.DELETE ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowCount()
|
||||||
|
{
|
||||||
|
return mAliases.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getColumnName( int columnIndex )
|
||||||
|
{
|
||||||
|
switch( columnIndex )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return "List";
|
||||||
|
case 1:
|
||||||
|
return "Group";
|
||||||
|
case 2:
|
||||||
|
return "Name";
|
||||||
|
case 3:
|
||||||
|
return "Icon";
|
||||||
|
case 4:
|
||||||
|
return "Color";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getColumnClass( int columnIndex )
|
||||||
|
{
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable( int rowIndex, int columnIndex )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValueAt( int rowIndex, int columnIndex )
|
||||||
|
{
|
||||||
|
Alias alias = mAliases.get( rowIndex );
|
||||||
|
|
||||||
|
switch( columnIndex )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return alias.getList();
|
||||||
|
case 1:
|
||||||
|
return alias.getGroup();
|
||||||
|
case 2:
|
||||||
|
return alias.getName();
|
||||||
|
case 3:
|
||||||
|
return alias.getIconName();
|
||||||
|
case 4:
|
||||||
|
return alias.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValueAt( Object aValue, int rowIndex, int columnIndex )
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException( "Not yet implemented" );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void broadcast( TableModelEvent event )
|
||||||
|
{
|
||||||
|
for( TableModelListener listener: mTableModelListeners )
|
||||||
|
{
|
||||||
|
listener.tableChanged( event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTableModelListener( TableModelListener listener )
|
||||||
|
{
|
||||||
|
mTableModelListeners.add( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeTableModelListener( TableModelListener listener )
|
||||||
|
{
|
||||||
|
mTableModelListeners.remove( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void broadcast( AliasEvent event )
|
||||||
|
{
|
||||||
|
mAliasEventBroadcaster.broadcast( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAliasEventListener( Listener<AliasEvent> listener )
|
||||||
|
{
|
||||||
|
mAliasEventBroadcaster.addListener( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAliasEventListener( Listener<AliasEvent> listener )
|
||||||
|
{
|
||||||
|
mAliasEventBroadcaster.removeListener( listener );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,11 +43,6 @@ public class TalkgroupID extends AliasID
|
|||||||
mTalkgroup = talkgroup;
|
mTalkgroup = talkgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAudioType()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ public class TalkgroupIDEditor extends JPanel implements ActionListener
|
|||||||
private TalkgroupIDNode mTalkgroupIDNode;
|
private TalkgroupIDNode mTalkgroupIDNode;
|
||||||
|
|
||||||
private JTextField mTextTalkgroupID;
|
private JTextField mTextTalkgroupID;
|
||||||
|
<<<<<<< Upstream, based on origin/master
|
||||||
|
=======
|
||||||
|
private JLabel mLabelAudio;
|
||||||
|
>>>>>>> 92e63f7 Adds AliasModel and AliasEvent and support for conversion from legacy playlist format.
|
||||||
|
|
||||||
private String mHelpText = "Enter a formatted talkgroup identifier.\n\n"
|
private String mHelpText = "Enter a formatted talkgroup identifier.\n\n"
|
||||||
+ "P25 Talkgroup Format: hexadecimal value, 4 characters for "
|
+ "P25 Talkgroup Format: hexadecimal value, 4 characters for "
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import module.decode.event.CallEventPanel;
|
|||||||
import module.decode.event.MessageActivityPanel;
|
import module.decode.event.MessageActivityPanel;
|
||||||
import module.decode.state.ChannelList;
|
import module.decode.state.ChannelList;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import playlist.PlaylistEditor;
|
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceManager;
|
import source.SourceManager;
|
||||||
@@ -44,6 +43,7 @@ import audio.AudioPanel;
|
|||||||
import com.jidesoft.swing.JideSplitPane;
|
import com.jidesoft.swing.JideSplitPane;
|
||||||
import com.jidesoft.swing.JideTabbedPane;
|
import com.jidesoft.swing.JideTabbedPane;
|
||||||
|
|
||||||
|
import controller.channel.ChannelController;
|
||||||
import controller.channel.ChannelModel;
|
import controller.channel.ChannelModel;
|
||||||
import controller.channel.ChannelProcessingManager;
|
import controller.channel.ChannelProcessingManager;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class ControllerPanel extends JPanel
|
|||||||
|
|
||||||
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
||||||
|
|
||||||
private PlaylistEditor mPlaylistEditor;
|
private ChannelController mPlaylistEditor;
|
||||||
|
|
||||||
private JideTabbedPane mTabbedPane;
|
private JideTabbedPane mTabbedPane;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ public class ControllerPanel extends JPanel
|
|||||||
mChannelStateList = new ChannelList( channelModel, channelProcessingManager,
|
mChannelStateList = new ChannelList( channelModel, channelProcessingManager,
|
||||||
playlistManager, mSettingsManager );
|
playlistManager, mSettingsManager );
|
||||||
|
|
||||||
mPlaylistEditor = new PlaylistEditor( channelModel, playlistManager, sourceManager );
|
mPlaylistEditor = new ChannelController( channelModel, playlistManager, sourceManager );
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package playlist;
|
package controller.channel;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -20,19 +20,16 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import playlist.PlaylistManager;
|
||||||
import source.SourceManager;
|
import source.SourceManager;
|
||||||
|
|
||||||
import com.jidesoft.swing.JideSplitPane;
|
import com.jidesoft.swing.JideSplitPane;
|
||||||
|
|
||||||
import controller.channel.Channel;
|
public class ChannelController extends JPanel
|
||||||
import controller.channel.ChannelEditor;
|
|
||||||
import controller.channel.ChannelModel;
|
|
||||||
|
|
||||||
public class PlaylistEditor extends JPanel
|
|
||||||
implements ActionListener, ListSelectionListener
|
implements ActionListener, ListSelectionListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final static Logger mLog = LoggerFactory.getLogger( PlaylistEditor.class );
|
private final static Logger mLog = LoggerFactory.getLogger( ChannelController.class );
|
||||||
|
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
private JTable mChannelTable;
|
private JTable mChannelTable;
|
||||||
@@ -47,7 +44,7 @@ public class PlaylistEditor extends JPanel
|
|||||||
private JButton mCopyChannelButton = new JButton( COPY_CHANNEL );
|
private JButton mCopyChannelButton = new JButton( COPY_CHANNEL );
|
||||||
private JButton mDeleteChannelButton = new JButton( DELETE_CHANNEL );
|
private JButton mDeleteChannelButton = new JButton( DELETE_CHANNEL );
|
||||||
|
|
||||||
public PlaylistEditor( ChannelModel channelModel,
|
public ChannelController( ChannelModel channelModel,
|
||||||
PlaylistManager playlistManager,
|
PlaylistManager playlistManager,
|
||||||
SourceManager sourceManager )
|
SourceManager sourceManager )
|
||||||
{
|
{
|
||||||
@@ -205,7 +202,7 @@ public class PlaylistEditor extends JPanel
|
|||||||
|
|
||||||
if( toDelete != null )
|
if( toDelete != null )
|
||||||
{
|
{
|
||||||
int choice = JOptionPane.showConfirmDialog( PlaylistEditor.this,
|
int choice = JOptionPane.showConfirmDialog( ChannelController.this,
|
||||||
"Do you want to delete this channel?", "Delete Channel?",
|
"Do you want to delete this channel?", "Delete Channel?",
|
||||||
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2015 Dennis Sheirer
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,11 +26,11 @@ import javax.swing.event.TableModelEvent;
|
|||||||
import javax.swing.event.TableModelListener;
|
import javax.swing.event.TableModelListener;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistEditor;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import source.tuner.Tuner;
|
|||||||
import source.tuner.TunerSelectionListener;
|
import source.tuner.TunerSelectionListener;
|
||||||
import spectrum.SpectralDisplayPanel;
|
import spectrum.SpectralDisplayPanel;
|
||||||
import util.TimeStamp;
|
import util.TimeStamp;
|
||||||
|
import alias.AliasModel;
|
||||||
import alias.action.AliasActionManager;
|
import alias.action.AliasActionManager;
|
||||||
import audio.AudioManager;
|
import audio.AudioManager;
|
||||||
|
|
||||||
@@ -118,9 +119,12 @@ public class SDRTrunk
|
|||||||
|
|
||||||
SourceManager sourceManager = new SourceManager( mSettingsManager, threadPoolManager );
|
SourceManager sourceManager = new SourceManager( mSettingsManager, threadPoolManager );
|
||||||
|
|
||||||
|
AliasModel aliasModel = new AliasModel();
|
||||||
|
|
||||||
ChannelModel channelModel = new ChannelModel();
|
ChannelModel channelModel = new ChannelModel();
|
||||||
|
|
||||||
PlaylistManager playlistManager = new PlaylistManager( threadPoolManager, channelModel );
|
PlaylistManager playlistManager = new PlaylistManager( threadPoolManager,
|
||||||
|
aliasModel, channelModel );
|
||||||
|
|
||||||
RecorderManager recorderManager = new RecorderManager( threadPoolManager );
|
RecorderManager recorderManager = new RecorderManager( threadPoolManager );
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import module.decode.config.DecodeConfiguration;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
import source.IControllableFileSource;
|
import source.IControllableFileSource;
|
||||||
|
import alias.AliasModel;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import controller.channel.ChannelModel;
|
import controller.channel.ChannelModel;
|
||||||
|
|
||||||
@@ -29,11 +30,12 @@ public class DecoderSelectionFrame extends JInternalFrame
|
|||||||
public DecoderSelectionFrame( JDesktopPane desktop,
|
public DecoderSelectionFrame( JDesktopPane desktop,
|
||||||
IControllableFileSource source )
|
IControllableFileSource source )
|
||||||
{
|
{
|
||||||
|
AliasModel aliasModel = new AliasModel();
|
||||||
ChannelModel channelModel = new ChannelModel();
|
ChannelModel channelModel = new ChannelModel();
|
||||||
|
|
||||||
ThreadPoolManager tpm = new ThreadPoolManager();
|
ThreadPoolManager tpm = new ThreadPoolManager();
|
||||||
|
|
||||||
mPlaylistManager = new PlaylistManager( tpm, channelModel );
|
mPlaylistManager = new PlaylistManager( tpm, aliasModel, channelModel );
|
||||||
|
|
||||||
mDesktop = desktop;
|
mDesktop = desktop;
|
||||||
mSource = source;
|
mSource = source;
|
||||||
|
|||||||
@@ -24,12 +24,14 @@ import javax.xml.bind.annotation.XmlElement;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
import alias.AliasDirectory;
|
import alias.AliasDirectory;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.map.ChannelMapList;
|
import controller.channel.map.ChannelMapList;
|
||||||
import controller.system.SystemList;
|
import controller.system.SystemList;
|
||||||
|
|
||||||
@XmlSeeAlso( { AliasDirectory.class,
|
@XmlSeeAlso( { AliasDirectory.class,
|
||||||
|
Alias.class,
|
||||||
Channel.class,
|
Channel.class,
|
||||||
ChannelMapList.class,
|
ChannelMapList.class,
|
||||||
SystemList.class } )
|
SystemList.class } )
|
||||||
@@ -40,12 +42,24 @@ public class Playlist
|
|||||||
private AliasDirectory mAliasDirectory = new AliasDirectory();
|
private AliasDirectory mAliasDirectory = new AliasDirectory();
|
||||||
private ChannelMapList mChannelMapList = new ChannelMapList();
|
private ChannelMapList mChannelMapList = new ChannelMapList();
|
||||||
private SystemList mSystemList = new SystemList();
|
private SystemList mSystemList = new SystemList();
|
||||||
|
private List<Alias> mAliases = new ArrayList<>();
|
||||||
private List<Channel> mChannels = new ArrayList<>();
|
private List<Channel> mChannels = new ArrayList<>();
|
||||||
|
|
||||||
public Playlist()
|
public Playlist()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElement( name = "alias" )
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
return mAliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliases( List<Alias> aliases )
|
||||||
|
{
|
||||||
|
mAliases = aliases;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement( name = "channel" )
|
@XmlElement( name = "channel" )
|
||||||
public List<Channel> getChannels()
|
public List<Channel> getChannels()
|
||||||
{
|
{
|
||||||
@@ -70,6 +84,13 @@ public class Playlist
|
|||||||
mAliasDirectory = directory;
|
mAliasDirectory = directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasAliasDirectory()
|
||||||
|
{
|
||||||
|
return mAliasDirectory != null &&
|
||||||
|
mAliasDirectory.getAliasList() != null &&
|
||||||
|
!mAliasDirectory.getAliasList().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement( name = "system_list" )
|
@XmlElement( name = "system_list" )
|
||||||
public SystemList getSystemList()
|
public SystemList getSystemList()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,10 +37,11 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import properties.SystemProperties;
|
import properties.SystemProperties;
|
||||||
import controller.channel.Channel;
|
import alias.Alias;
|
||||||
import controller.channel.ChannelModel;
|
import alias.AliasDirectory;
|
||||||
import controller.site.Site;
|
import alias.AliasList;
|
||||||
import controller.system.SystemList;
|
import alias.AliasModel;
|
||||||
|
import alias.Group;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
@@ -57,10 +58,8 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
|
|
||||||
private Playlist mPlaylist = new Playlist();
|
private Playlist mPlaylist = new Playlist();
|
||||||
|
|
||||||
private ChannelModel mChannelModel;
|
|
||||||
|
|
||||||
public PlaylistManager( ChannelModel channelModel )
|
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
|
private AliasModel mAliasModel;
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
|
|
||||||
private AtomicBoolean mPlaylistSavePending = new AtomicBoolean();
|
private AtomicBoolean mPlaylistSavePending = new AtomicBoolean();
|
||||||
@@ -77,9 +76,11 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
* @param channelModel
|
* @param channelModel
|
||||||
*/
|
*/
|
||||||
public PlaylistManager( ThreadPoolManager threadPoolManager,
|
public PlaylistManager( ThreadPoolManager threadPoolManager,
|
||||||
|
AliasModel aliasModel,
|
||||||
ChannelModel channelModel )
|
ChannelModel channelModel )
|
||||||
{
|
{
|
||||||
mThreadPoolManager = threadPoolManager;
|
mThreadPoolManager = threadPoolManager;
|
||||||
|
mAliasModel = aliasModel;
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
|
|
||||||
//Register for channel events so that we can save the playlist when
|
//Register for channel events so that we can save the playlist when
|
||||||
@@ -102,6 +103,7 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
|
|
||||||
mPlaylistLoading = true;
|
mPlaylistLoading = true;
|
||||||
|
|
||||||
|
mAliasModel.addAliases( mPlaylist.getAliases() );
|
||||||
mChannelModel.addChannels( mPlaylist.getChannels() );
|
mChannelModel.addChannels( mPlaylist.getChannels() );
|
||||||
|
|
||||||
mPlaylistLoading = false;
|
mPlaylistLoading = false;
|
||||||
@@ -168,11 +170,57 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel event listener method. Monitors channel events for events that
|
||||||
|
* indicate that the playlist has changed and queues automatic playlist
|
||||||
|
* saving.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void channelChanged( ChannelEvent event )
|
||||||
|
{
|
||||||
|
//Only save playlist for changes to standard channels (not traffic)
|
||||||
|
if( event.getChannel().getChannelType() == ChannelType.STANDARD )
|
||||||
|
{
|
||||||
|
switch( event.getEvent() )
|
||||||
|
{
|
||||||
|
case NOTIFICATION_ADD:
|
||||||
|
case NOTIFICATION_CONFIGURATION_CHANGE:
|
||||||
|
case NOTIFICATION_DELETE:
|
||||||
|
case NOTIFICATION_PROCESSING_START:
|
||||||
|
case NOTIFICATION_PROCESSING_STOP:
|
||||||
|
schedulePlaylistSave();
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_ENABLE_REJECTED:
|
||||||
|
case NOTIFICATION_SELECTION_CHANGE:
|
||||||
|
case NOTIFICATION_STATE_RESET:
|
||||||
|
case REQUEST_DELETE:
|
||||||
|
case REQUEST_DESELECT:
|
||||||
|
case REQUEST_DISABLE:
|
||||||
|
case REQUEST_ENABLE:
|
||||||
|
case REQUEST_SELECT:
|
||||||
|
//Do nothing for these event types
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//When a new event enum entry is added and received, throw an
|
||||||
|
//exception here to ensure developer adds support for the
|
||||||
|
//use case
|
||||||
|
throw new IllegalArgumentException( "Unrecognized Channel "
|
||||||
|
+ "Event [" + event.getEvent().name() + "]" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
//TODO: recreate the playlist and load values from each of the models
|
//TODO: recreate the playlist and load values from each of the models
|
||||||
|
|
||||||
|
mLog.debug( "Aliases in model:" + mAliasModel.getAliases().size() );
|
||||||
|
mPlaylist.setAliases( mAliasModel.getAliases() );
|
||||||
|
mLog.debug( "Aliases in playlist:" + mPlaylist.getAliases().size() );
|
||||||
|
|
||||||
|
mLog.debug( "Channels in model:" + mChannelModel.getChannels().size() );
|
||||||
mPlaylist.setChannels( mChannelModel.getChannels() );
|
mPlaylist.setChannels( mChannelModel.getChannels() );
|
||||||
|
mLog.debug( "Channels in playlist:" + mPlaylist.getChannels().size() );
|
||||||
|
|
||||||
JAXBContext context = null;
|
JAXBContext context = null;
|
||||||
|
|
||||||
@@ -370,16 +418,27 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
playlistPath.toString() + "]" );
|
playlistPath.toString() + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean saveRequired = false;
|
||||||
|
|
||||||
if( mPlaylist == null )
|
if( mPlaylist == null )
|
||||||
{
|
{
|
||||||
mPlaylist = new Playlist();
|
mPlaylist = new Playlist();
|
||||||
save();
|
saveRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Check for and convert from legacy play list format
|
//Check for and convert from legacy play list format
|
||||||
if( mPlaylist.hasSystemList() )
|
if( mPlaylist.hasSystemList() || mPlaylist.hasAliasDirectory() )
|
||||||
{
|
{
|
||||||
convertPlaylistFormat();
|
convertPlaylistFormat();
|
||||||
|
saveRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
transferPlaylistToModels();
|
||||||
|
|
||||||
|
if( saveRequired )
|
||||||
|
{
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,35 +447,60 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
*/
|
*/
|
||||||
private void convertPlaylistFormat()
|
private void convertPlaylistFormat()
|
||||||
{
|
{
|
||||||
mLog.info( "Legacy playlist format detected - converting ..." );
|
mLog.info( "Legacy playlist format detected - converting" );
|
||||||
|
|
||||||
createBackupPlaylist();
|
createBackupPlaylist();
|
||||||
|
|
||||||
//Playlist version 1 to version 2 format conversion. In order to keep
|
//Playlist version 1 to version 2 format conversion. In order to keep
|
||||||
//backwards compatibility, transfer all of the System-Site-Channel
|
//backwards compatibility, transfer all of the System-Site-Channel
|
||||||
//objects over to the new channel list format
|
//objects over to the new channel list format
|
||||||
SystemList systemList = mPlaylist.getSystemList();
|
if( mPlaylist.hasSystemList() )
|
||||||
|
|
||||||
for( controller.system.System system: systemList.getSystem() )
|
|
||||||
{
|
{
|
||||||
for( Site site: system.getSite() )
|
SystemList systemList = mPlaylist.getSystemList();
|
||||||
{
|
|
||||||
for( Channel channel: site.getChannel() )
|
|
||||||
{
|
|
||||||
channel.setSystem( system.getName() );
|
|
||||||
channel.setSite( site.getName() );
|
|
||||||
|
|
||||||
mPlaylist.getChannels().add( channel );
|
for( controller.system.System system: systemList.getSystem() )
|
||||||
|
{
|
||||||
|
for( Site site: system.getSite() )
|
||||||
|
{
|
||||||
|
for( Channel channel: site.getChannel() )
|
||||||
|
{
|
||||||
|
channel.setSystem( system.getName() );
|
||||||
|
channel.setSite( site.getName() );
|
||||||
|
|
||||||
|
mPlaylist.getChannels().add( channel );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPlaylist.getSystemList().clearSystems();
|
||||||
|
|
||||||
|
mLog.info( "Converted [" + mPlaylist.getChannels().size() +
|
||||||
|
"] channels to new playlist format" );
|
||||||
}
|
}
|
||||||
|
|
||||||
mPlaylist.getSystemList().clearSystems();
|
if( mPlaylist.hasAliasDirectory() )
|
||||||
|
{
|
||||||
|
AliasDirectory aliasDirectory = mPlaylist.getAliasDirectory();
|
||||||
|
|
||||||
mLog.info( "Converted [" + mPlaylist.getChannels().size() +
|
for( AliasList list: aliasDirectory.getAliasList() )
|
||||||
"] channels to new playlist format" );
|
{
|
||||||
|
for( Group group: list.getGroup() )
|
||||||
|
{
|
||||||
|
for( Alias alias: group.getAlias() )
|
||||||
|
{
|
||||||
|
alias.setList( list.getName() );
|
||||||
|
alias.setGroup( group.getName() );
|
||||||
|
|
||||||
save();
|
mPlaylist.getAliases().add( alias );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mPlaylist.getAliasDirectory().clearAliasLists();
|
||||||
|
|
||||||
|
mLog.info( "Converted [" + mPlaylist.getAliases().size() +
|
||||||
|
"] aliases to new playlist format" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -448,46 +532,5 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
|
|
||||||
mPlaylistSavePending.set( false );
|
mPlaylistSavePending.set( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for and convert from legacy play list format
|
|
||||||
if( mPlaylist.hasSystemList() )
|
|
||||||
{
|
|
||||||
convertPlaylistFormat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts playlist data over to new format
|
|
||||||
*/
|
|
||||||
private void convertPlaylistFormat()
|
|
||||||
{
|
|
||||||
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
|
|
||||||
SystemList systemList = mPlaylist.getSystemList();
|
|
||||||
|
|
||||||
for( controller.system.System system: systemList.getSystem() )
|
|
||||||
{
|
|
||||||
for( Site site: system.getSite() )
|
|
||||||
{
|
|
||||||
for( Channel channel: site.getChannel() )
|
|
||||||
{
|
|
||||||
channel.setSystem( system.getName() );
|
|
||||||
channel.setSite( site.getName() );
|
|
||||||
|
|
||||||
mPlaylist.getChannels().add( channel );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mPlaylist.getSystemList().clearSystems();
|
|
||||||
|
|
||||||
mLog.info( "Converted [" + mPlaylist.getChannels().size() + "] channels to new playlist format" );
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user