diff --git a/src/alias/AliasDirectoryNode.java b/src/alias/AliasDirectoryNode.java deleted file mode 100644 index c44d32b9..00000000 --- a/src/alias/AliasDirectoryNode.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import settings.SettingsManager; -import controller.ConfigurableNode; - -public class AliasDirectoryNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private PlaylistManager mPlaylistManager; - - private SettingsManager mSettingsManager; - - public AliasDirectoryNode( PlaylistManager playlistManager, - SettingsManager settingsManager, - AliasDirectory directory ) - { - super( playlistManager, directory ); - - mPlaylistManager = playlistManager; - - mSettingsManager = settingsManager; - } - - public AliasDirectory getAliasDirectory() - { - return (AliasDirectory)getUserObject(); - } - - public void init() - { - for( AliasList list: getAliasDirectory().getAliasList() ) - { - AliasListNode node = new AliasListNode( mPlaylistManager, mSettingsManager, list ); - - getModel().addNode( node, AliasDirectoryNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - public String toString() - { - return "Alias Lists [" + this.getChildCount() + "]"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addItem = new JMenuItem( "Add Alias List" ); - addItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - AliasList list = new AliasList(); - - getAliasDirectory().addAliasList( list ); - - AliasListNode node = new AliasListNode( mPlaylistManager, mSettingsManager, list ); - - getModel().addNode( node, - AliasDirectoryNode.this, - AliasDirectoryNode.this.getChildCount() ); - - sort(); - - getModel().showNode( node ); - } - } ); - - retVal.add( addItem ); - - return retVal; - } -} diff --git a/src/alias/AliasList.java b/src/alias/AliasList.java index e62ec72f..59f7dc9a 100644 --- a/src/alias/AliasList.java +++ b/src/alias/AliasList.java @@ -1,6 +1,6 @@ /******************************************************************************* * 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 * it under the terms of the GNU General Public License as published by @@ -19,21 +19,17 @@ package alias; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; import module.decode.lj1200.LJ1200Message.Function; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import alias.action.AliasAction; -import alias.action.beep.BeepAction; -import alias.action.clip.ClipAction; -import alias.action.script.ScriptAction; +import sample.Listener; import alias.id.AliasID; import alias.id.esn.Esn; import alias.id.fleetsync.FleetsyncID; @@ -41,48 +37,17 @@ import alias.id.lojack.LoJackFunctionAndID; import alias.id.mdc.MDC1200ID; import alias.id.mobileID.Min; import alias.id.mpt1327.MPT1327ID; -import alias.id.nonrecordable.NonRecordable; -import alias.id.priority.Priority; import alias.id.siteID.SiteID; import alias.id.status.StatusID; import alias.id.talkgroup.TalkgroupID; import alias.id.uniqueID.UniqueID; import audio.metadata.MetadataType; -@XmlSeeAlso( { Alias.class, - - /* Alias ID's */ - AliasID.class, - FleetsyncID.class, - Esn.class, - Group.class, - LoJackFunctionAndID.class, - MDC1200ID.class, - Min.class, - MPT1327ID.class, - UniqueID.class, - SiteID.class, - StatusID.class, - TalkgroupID.class, - - /* Alias Attributes */ - NonRecordable.class, - Priority.class, - - /* Alias Actions */ - AliasAction.class, - BeepAction.class, - ClipAction.class, - ScriptAction.class } ) - -@XmlRootElement( name = "alias_list" ) -public class AliasList implements Comparable +public class AliasList implements Listener { private final static Logger mLog = LoggerFactory.getLogger( AliasList.class ); - private String mName; - private ArrayList mGroups = new ArrayList(); - + private List mAliases = new ArrayList<>(); private Map mESN = new HashMap<>(); private Map mFleetsync = new HashMap<>(); private Map mLoJack = new HashMap<>(); @@ -102,167 +67,326 @@ public class AliasList implements Comparable private boolean mSiteWildcard = false; private boolean mTalkgroupWildcard = false; - public AliasList() - { - this( null ); - } + private String mName; + /** + * List of aliases where all aliases share the same list name. Contains + * several methods for alias lookup from identifier values, like talkgroups. + * + * Responds to alias change events to keep the internal alias list updated. + */ public AliasList( String name ) { mName = name; - update(); } - + /** - * Load/Reload all lookup hashmaps + * Adds the alias to this list */ - public void update() + public void addAlias( Alias alias ) { - //Clear hashmaps - mESN.clear(); - mFleetsync.clear(); - mLoJack.clear(); - mMDC1200.clear(); - mMobileID.clear(); - mMPT1327.clear(); - mSiteID.clear(); - mStatus.clear(); - mTalkgroup.clear(); - mUniqueID.clear(); - - for( Group group: mGroups ) + if( alias != null ) { - for( Alias alias: group.getAlias() ) + mAliases.add( alias ); + + for( AliasID aliasID: alias.getId() ) { - for( AliasID id: alias.getId() ) + addAliasID( aliasID, alias ); + } + } + } + + /** + * Adds the alias and alias identifier to the internal type mapping. + */ + private void addAliasID( AliasID id, Alias alias ) + { + switch( id.getType() ) + { + case ESN: + Esn esn = (Esn)id; + if( esn.getEsn().contains( "*" ) ) { - switch( id.getType() ) + mESNWildcard = true; + + mESN.put( fixWildcard( esn.getEsn() ), alias ); + } + else + { + mESN.put( esn.getEsn(), alias ); + } + break; + case Fleetsync: + FleetsyncID fs = (FleetsyncID)id; + + if( fs.getIdent().contains( "*" ) ) + { + mFleetsyncWildcard = true; + + mFleetsync.put( fixWildcard( fs.getIdent() ), alias ); + } + else + { + mFleetsync.put( fs.getIdent(), alias ); + } + break; + case LoJack: + mLoJack.put( (LoJackFunctionAndID)id, alias ); + break; + case MDC1200: + MDC1200ID mdc = (MDC1200ID)id; + + if( mdc.getIdent().contains( "*" ) ) + { + mMDC1200Wildcard = true; + + //Replace (*) wildcard with regex wildcard (.) + mMDC1200.put( fixWildcard( mdc.getIdent() ), alias ); + } + else + { + mMDC1200.put( mdc.getIdent(), alias ); + } + break; + case MPT1327: + MPT1327ID mpt = (MPT1327ID)id; + + String ident = mpt.getIdent(); + + if( ident != null ) + { + if( ident.contains( "*" ) ) { - case ESN: - Esn esn = (Esn)id; - if( esn.getEsn().contains( "*" ) ) - { - mESNWildcard = true; - - mESN.put( fixWildcard( esn.getEsn() ), alias ); - } - else - { - mESN.put( esn.getEsn(), alias ); - } - break; - case Fleetsync: - FleetsyncID fs = (FleetsyncID)id; - - if( fs.getIdent().contains( "*" ) ) - { - mFleetsyncWildcard = true; - - mFleetsync.put( fixWildcard( fs.getIdent() ), alias ); - } - else - { - mFleetsync.put( fs.getIdent(), alias ); - } - break; - case LoJack: - mLoJack.put( (LoJackFunctionAndID)id, alias ); - break; - case MDC1200: - MDC1200ID mdc = (MDC1200ID)id; - - if( mdc.getIdent().contains( "*" ) ) - { - mMDC1200Wildcard = true; - - //Replace (*) wildcard with regex wildcard (.) - mMDC1200.put( fixWildcard( mdc.getIdent() ), alias ); - } - else - { - mMDC1200.put( mdc.getIdent(), alias ); - } - break; - case MPT1327: - MPT1327ID mpt = (MPT1327ID)id; - - String ident = mpt.getIdent(); - - if( ident != null ) - { - if( ident.contains( "*" ) ) - { - mMPT1327Wildcard = true; - - //Replace (*) wildcard with regex wildcard (.) - mMPT1327.put( fixWildcard( ident ), alias ); - } - else - { - mMPT1327.put( ident, alias ); - } - } - break; - case MIN: - Min min = (Min)id; - - if( min.getMin().contains( "*" ) ) - { - mMobileIDWildcard = true; - mMobileID.put( fixWildcard( min.getMin() ), alias ); - } - else - { - mMobileID.put( min.getMin(), alias ); - } - break; - case LTRNetUID: - UniqueID uid = (UniqueID)id; - - mUniqueID.put( uid.getUid(), alias ); - break; - case Site: - SiteID siteID = (SiteID)id; - - if( siteID.getSite().contains( "*" ) ) - { - mSiteWildcard = true; - mSiteID.put( fixWildcard( siteID.getSite() ), alias ); - } - else - { - mSiteID.put( siteID.getSite(), alias ); - } - - break; - case Status: - mStatus.put( ((StatusID)id).getStatus(), alias ); - break; - case Talkgroup: - TalkgroupID tgid = (TalkgroupID)id; - - if( tgid.getTalkgroup().contains( "*" ) ) - { - mTalkgroupWildcard = true; - - //Replace (*) wildcard with regex wildcard (.) - mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias ); - } - else - { - mTalkgroup.put( tgid.getTalkgroup(), alias ); - } - break; - case NonRecordable: - case Priority: - //We don't maintain lookups for these items - break; - default: - mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() ); - break; + mMPT1327Wildcard = true; + + //Replace (*) wildcard with regex wildcard (.) + mMPT1327.put( fixWildcard( ident ), alias ); + } + else + { + mMPT1327.put( ident, alias ); } } + break; + case MIN: + Min min = (Min)id; + + if( min.getMin().contains( "*" ) ) + { + mMobileIDWildcard = true; + mMobileID.put( fixWildcard( min.getMin() ), alias ); + } + else + { + mMobileID.put( min.getMin(), alias ); + } + break; + case LTRNetUID: + UniqueID uid = (UniqueID)id; + + mUniqueID.put( uid.getUid(), alias ); + break; + case Site: + SiteID siteID = (SiteID)id; + + if( siteID.getSite().contains( "*" ) ) + { + mSiteWildcard = true; + mSiteID.put( fixWildcard( siteID.getSite() ), alias ); + } + else + { + mSiteID.put( siteID.getSite(), alias ); + } + + break; + case Status: + mStatus.put( ((StatusID)id).getStatus(), alias ); + break; + case Talkgroup: + TalkgroupID tgid = (TalkgroupID)id; + + if( tgid.getTalkgroup().contains( "*" ) ) + { + mTalkgroupWildcard = true; + + //Replace (*) wildcard with regex wildcard (.) + mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias ); + } + else + { + mTalkgroup.put( tgid.getTalkgroup(), alias ); + } + break; + case NonRecordable: + case Priority: + //We don't maintain lookups for these items + break; + default: + mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() ); + break; + } + } + + /** + * Removes the alias from this list + */ + public void removeAlias( Alias alias ) + { + if( alias != null ) + { + for( AliasID aliasID: alias.getId() ) + { + removeAliasID( aliasID, alias ); } + + mAliases.remove( alias ); + } + } + + /** + * Removes the alias and alias identifier from internal mappings. + */ + private void removeAliasID( AliasID id, Alias alias ) + { + switch( id.getType() ) + { + case ESN: + Esn esn = (Esn)id; + if( mESN.containsKey( esn.getEsn() ) ) + { + Alias esnAlias = mESN.get( esn.getEsn() ); + + if( esnAlias != null && esnAlias == alias ) + { + mESN.remove( esn.getEsn() ); + } + } + break; + case Fleetsync: + FleetsyncID fs = (FleetsyncID)id; + + if( mFleetsync.containsKey( fs.getIdent() ) ) + { + Alias fsAlias = mFleetsync.get( fs.getIdent() ); + + if( fsAlias != null && fsAlias == alias ) + { + mFleetsync.remove( fs.getIdent() ); + } + } + break; + case LoJack: + LoJackFunctionAndID lj = (LoJackFunctionAndID)id; + + if( mLoJack.containsKey( lj ) ) + { + Alias ljAlias = mLoJack.get( lj ); + + if( ljAlias != null && ljAlias == alias ) + { + mLoJack.remove( lj ); + } + } + break; + case MDC1200: + MDC1200ID mdc = (MDC1200ID)id; + + if( mMDC1200.containsKey( mdc.getIdent() ) ) + { + Alias mdcAlias = mMDC1200.get( mdc.getIdent() ); + + if( mdcAlias != null && mdcAlias == alias ) + { + mMDC1200.remove( mdc.getIdent() ); + } + } + break; + case MPT1327: + MPT1327ID mpt = (MPT1327ID)id; + + if( mMPT1327.containsKey( mpt.getIdent() ) ) + { + Alias mptAlias = mMDC1200.get( mpt.getIdent() ); + + if( mptAlias != null && mptAlias == alias ) + { + mMPT1327.remove( mpt.getIdent() ); + } + } + break; + case MIN: + Min min = (Min)id; + + if( mMobileID.containsKey( min.getMin() ) ) + { + Alias minAlias = mMobileID.get( min.getMin() ); + + if( minAlias != null && minAlias == alias ) + { + mMobileID.remove( min.getMin() ); + } + } + break; + case LTRNetUID: + UniqueID uid = (UniqueID)id; + + if( mUniqueID.containsKey( uid.getUid() ) ) + { + Alias uidAlias = mUniqueID.get( uid.getUid() ); + + if( uidAlias != null && uidAlias == alias ) + { + mUniqueID.remove( uid.getUid() ); + } + } + break; + case Site: + SiteID sid = (SiteID)id; + + if( mSiteID.containsKey( sid.getSite() ) ) + { + Alias sidAlias = mSiteID.get( sid.getSite() ); + + if( sidAlias != null && sidAlias == alias ) + { + mSiteID.remove( sid.getSite() ); + } + } + break; + case Status: + StatusID stat = (StatusID)id; + + if( mStatus.containsKey( stat.getStatus() ) ) + { + Alias statAlias = mStatus.get( stat.getStatus() ); + + if( statAlias != null && statAlias == alias ) + { + mStatus.remove( stat.getStatus() ); + } + } + break; + case Talkgroup: + TalkgroupID tg = (TalkgroupID)id; + + if( mTalkgroup.containsKey( tg.getTalkgroup() ) ) + { + Alias tgAlias = mTalkgroup.get( tg.getTalkgroup() ); + + if( tgAlias != null && tgAlias == alias ) + { + mTalkgroup.remove( tg.getTalkgroup() ); + } + } + break; + case NonRecordable: + case Priority: + //We don't maintain lookups for these items + break; + default: + mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() ); + break; } } @@ -279,7 +403,10 @@ public class AliasList implements Comparable return value; } - + + /** + * Lookup alias by site ID + */ public Alias getSiteID( String siteID ) { if( siteID != null ) @@ -302,17 +429,26 @@ public class AliasList implements Comparable return null; } - + + /** + * Lookup alias by status ID + */ public Alias getStatus( int status ) { return mStatus.get( status ); } + /** + * Lookup alias by Unique ID (UID) + */ public Alias getUniqueID( int uniqueID ) { return mUniqueID.get( uniqueID ); } + /** + * Lookup alias by ESN + */ public Alias getESNAlias( String esn ) { if( esn != null ) @@ -336,7 +472,9 @@ public class AliasList implements Comparable return null; } - + /** + * Lookup alias by fleetsync ID + */ public Alias getFleetsyncAlias( String ident ) { if( ident != null ) @@ -360,6 +498,9 @@ public class AliasList implements Comparable return null; } + /** + * Lookup alias by lojack function and ID + */ public Alias getLoJackAlias( Function function, String id ) { if( id != null ) @@ -376,6 +517,9 @@ public class AliasList implements Comparable return null; } + /** + * Lookup alias by MDC1200 ID + */ public Alias getMDC1200Alias( String ident ) { if( ident != null ) @@ -399,6 +543,9 @@ public class AliasList implements Comparable return null; } + /** + * Lookup alias by MPT1327 Ident + */ public Alias getMPT1327Alias( String ident ) { if( ident != null ) @@ -422,22 +569,9 @@ public class AliasList implements Comparable return null; } - public Group getGroup( Alias alias ) - { - if( alias != null ) - { - for( Group group: mGroups ) - { - if( group.contains( alias ) ) - { - return group; - } - } - } - - return null; - } - + /** + * Lookup alias by Mobile ID Number (MIN) + */ public Alias getMobileIDNumberAlias( String ident ) { if( ident != null ) @@ -461,6 +595,9 @@ public class AliasList implements Comparable return null; } + /** + * Lookup alias by talkgroup + */ public Alias getTalkgroupAlias( String tgid ) { if( tgid != null ) @@ -483,49 +620,27 @@ public class AliasList implements Comparable return null; } - + + /** + * Alias list name + */ public String toString() { return mName; } + /** + * Alias list name + */ @XmlAttribute public String getName() { return mName; } - - public void setName( String name ) - { - mName = name; - } - - public ArrayList getGroup() - { - return mGroups; - } - - public void setGroup( ArrayList groups ) - { - mGroups = groups; - } - - public void addGroup( Group group ) - { - mGroups.add( group ); - } - - public void removeGroup( Group group ) - { - mGroups.remove( group ); - } - - @Override - public int compareTo( AliasList otherAliasList ) - { - return getName().compareTo( otherAliasList.getName() ); - } + /** + * Lookup an alias by metadata type and string value + */ public Alias getAlias( String value, MetadataType type ) { switch( type ) @@ -577,5 +692,48 @@ public class AliasList implements Comparable return null; } - + + /** + * Receive alias change event notifications and modify this list accordingly + */ + @Override + public void receive( AliasEvent event ) + { + Alias alias = event.getAlias(); + + switch( event.getEvent() ) + { + case ADD: + if( alias.getList() != null && + getName().equalsIgnoreCase( alias.getList() ) ) + { + addAlias( alias ); + } + break; + case CHANGE: + if( alias.getList() != null && + getName().equalsIgnoreCase( alias.getList() ) ) + { + if( !mAliases.contains( alias ) ) + { + //Alias was moved to this list - add it + addAlias( alias ); + } + } + else if( mAliases.contains( alias ) ) + { + //An alias in this list was moved to another list + removeAlias( alias ); + } + break; + case DELETE: + if( mAliases.contains( alias ) ) + { + removeAlias( alias ); + } + break; + default: + break; + } + } } diff --git a/src/alias/AliasListNode.java b/src/alias/AliasListNode.java deleted file mode 100644 index 573708ce..00000000 --- a/src/alias/AliasListNode.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; - -import playlist.PlaylistManager; -import settings.SettingsManager; -import controller.ConfigurableNode; - -public class AliasListNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private PlaylistManager mPlaylistManager; - private SettingsManager mSettingsManager; - - public AliasListNode( PlaylistManager playlistManager, - SettingsManager settingsManager, - AliasList list ) - { - super( playlistManager, list ); - - mPlaylistManager = playlistManager; - mSettingsManager = settingsManager; - } - - @Override - public JPanel getEditor() - { - return new ListEditor( this ); - } - - public AliasList getList() - { - return (AliasList)getUserObject(); - } - - public void init() - { - for( Group group: getList().getGroup() ) - { - GroupNode node = new GroupNode( mPlaylistManager, mSettingsManager, group ); - - getModel().addNode( node, AliasListNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - public String toString() - { - return getList().getName() + " [" + this.getChildCount() + "]"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addItem = new JMenuItem( "Add Group" ); - addItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - Group group = new Group(); - - getList().addGroup( group ); - - GroupNode node = new GroupNode( mPlaylistManager, mSettingsManager, group ); - - getModel().addNode( node, - AliasListNode.this, - AliasListNode.this.getChildCount() ); - - sort(); - - getModel().showNode( node ); - } - } ); - - retVal.add( addItem ); - - retVal.add( new JSeparator() ); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasDirectoryNode parent = (AliasDirectoryNode)getParent(); - - parent.getAliasDirectory().removeAliasList( getList() ); - - save(); - - getModel().removeNodeFromParent( AliasListNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/AliasModel.java b/src/alias/AliasModel.java index 9e346269..54a32b13 100644 --- a/src/alias/AliasModel.java +++ b/src/alias/AliasModel.java @@ -19,7 +19,9 @@ package alias; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import javax.swing.table.AbstractTableModel; @@ -48,6 +50,7 @@ public class AliasModel extends AbstractTableModel private List mAliases = new CopyOnWriteArrayList<>(); private Broadcaster mAliasEventBroadcaster = new Broadcaster<>(); + private Map mAliasListMap = new HashMap<>(); public AliasModel() { @@ -71,6 +74,31 @@ public class AliasModel extends AbstractTableModel return null; } + public AliasList getAliasList( String name ) + { + if( mAliasListMap.containsKey( name ) ) + { + return mAliasListMap.get( name ); + } + + AliasList aliasList = new AliasList( name ); + + for( Alias alias: mAliases ) + { + if( alias.getList().equalsIgnoreCase( name ) ) + { + aliasList.addAlias( alias ); + } + } + + mAliasListMap.put( name, aliasList ); + + //Register the new alias list to receive updates from this model + addListener( aliasList ); + + return aliasList; + } + /** * Returns a list of unique alias list names from across the alias set */ diff --git a/src/alias/AliasNode.java b/src/alias/AliasNode.java deleted file mode 100644 index 2c5ec25b..00000000 --- a/src/alias/AliasNode.java +++ /dev/null @@ -1,572 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import map.MapIcon; -import playlist.PlaylistManager; -import settings.SettingsManager; -import alias.action.AliasAction; -import alias.action.beep.BeepAction; -import alias.action.beep.BeepActionNode; -import alias.action.clip.ClipAction; -import alias.action.clip.ClipActionNode; -import alias.action.script.ScriptAction; -import alias.action.script.ScriptActionNode; -import alias.id.AliasID; -import alias.id.esn.ESNNode; -import alias.id.esn.Esn; -import alias.id.fleetsync.FleetsyncID; -import alias.id.fleetsync.FleetsyncIDNode; -import alias.id.lojack.LoJackFunctionAndID; -import alias.id.lojack.LoJackIDNode; -import alias.id.mdc.MDC1200ID; -import alias.id.mdc.MDC1200IDNode; -import alias.id.mobileID.MINNode; -import alias.id.mobileID.Min; -import alias.id.mpt1327.MPT1327ID; -import alias.id.mpt1327.MPT1327IDNode; -import alias.id.nonrecordable.NonRecordable; -import alias.id.nonrecordable.NonRecordableNode; -import alias.id.priority.Priority; -import alias.id.priority.PriorityNode; -import alias.id.siteID.SiteID; -import alias.id.siteID.SiteIDNode; -import alias.id.status.StatusID; -import alias.id.status.StatusIDNode; -import alias.id.talkgroup.TalkgroupID; -import alias.id.talkgroup.TalkgroupIDNode; -import alias.id.uniqueID.UniqueID; -import alias.id.uniqueID.UniqueIDNode; -import controller.ConfigurableNode; - -public class AliasNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private SettingsManager mSettingsManager; - private PlaylistManager mPlaylistManager; - - public AliasNode( PlaylistManager playlistManager, - SettingsManager settingsManager, - Alias alias ) - { - super( playlistManager, alias ); - - mSettingsManager = settingsManager; - } - - @Override - public JPanel getEditor() - { - return null; -// return new AliasEditor( this, mSettingsManager ); - } - - public Alias getAlias() - { - return (Alias)getUserObject(); - } - - public String getIconPath() - { - String icon = getAlias().getIconName(); - - MapIcon mapIcon = mSettingsManager.getMapIcon( icon ); - - if( mapIcon != null ) - { - return mapIcon.getPath(); - } - else - { - return null; - } - } - - public void init() - { - for( AliasID aliasID: getAlias().getId() ) - { - switch( aliasID.getType() ) - { - case ESN: - getModel().addNode( new ESNNode( mPlaylistManager, (Esn)aliasID ), - AliasNode.this, getChildCount() ); - break; - case Fleetsync: - getModel().addNode( new FleetsyncIDNode( mPlaylistManager, (FleetsyncID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case LoJack: - getModel().addNode( new LoJackIDNode( mPlaylistManager, (LoJackFunctionAndID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case LTRNetUID: - getModel().addNode( new UniqueIDNode( mPlaylistManager, (UniqueID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case MDC1200: - getModel().addNode( new MDC1200IDNode( mPlaylistManager, (MDC1200ID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case MIN: - getModel().addNode( new MINNode( mPlaylistManager, (Min)aliasID ), - AliasNode.this, getChildCount() ); - break; - case MPT1327: - getModel().addNode( new MPT1327IDNode( mPlaylistManager, (MPT1327ID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case NonRecordable: - getModel().addNode( new NonRecordableNode( mPlaylistManager, (NonRecordable)aliasID ), - AliasNode.this, getChildCount() ); - break; - case Priority: - getModel().addNode( new PriorityNode( mPlaylistManager, (Priority)aliasID ), - AliasNode.this, getChildCount() ); - break; - case Site: - getModel().addNode( new SiteIDNode( mPlaylistManager, (SiteID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case Status: - getModel().addNode( new StatusIDNode( mPlaylistManager, (StatusID)aliasID ), - AliasNode.this, getChildCount() ); - break; - case Talkgroup: - getModel().addNode( new TalkgroupIDNode( mPlaylistManager, (TalkgroupID)aliasID ), - AliasNode.this, getChildCount() ); - break; - default: - throw new IllegalArgumentException( "Unrecognized alias ID [" + - aliasID.getType() + "]"); - } - } - - for( AliasAction action: getAlias().getAction() ) - { - if( action instanceof BeepAction ) - { - getModel().addNode( new BeepActionNode( mPlaylistManager, (BeepAction)action ), - AliasNode.this, getChildCount() ); - } - else if( action instanceof ClipAction ) - { - getModel().addNode( new ClipActionNode( mPlaylistManager, (ClipAction)action ), - AliasNode.this, getChildCount() ); - } - else if( action instanceof ScriptAction ) - { - getModel().addNode( new ScriptActionNode( mPlaylistManager, (ScriptAction)action ), - AliasNode.this, getChildCount() ); - } - } - - sort(); - } - - public String toString() - { - return getAlias().getName() + " [" + this.getChildCount() + "]"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenu addIDMenu = new JMenu( "Add ID" ); - - JMenuItem addESNItem = new JMenuItem( "ESN" ); - addESNItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - Esn esn = new Esn(); - - getAlias().addAliasID( esn ); - - ESNNode node = new ESNNode( mPlaylistManager, esn ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addESNItem ); - - JMenuItem addFleetsyncItem = new JMenuItem( "Fleetsync" ); - addFleetsyncItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - FleetsyncID fs = new FleetsyncID(); - - getAlias().addAliasID( fs ); - - FleetsyncIDNode node = new FleetsyncIDNode( mPlaylistManager, fs ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addFleetsyncItem ); - - JMenuItem addLoJackItem = new JMenuItem( "LoJack" ); - addLoJackItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - LoJackFunctionAndID lj = new LoJackFunctionAndID(); - - getAlias().addAliasID( lj ); - - LoJackIDNode node = new LoJackIDNode( mPlaylistManager, lj ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addLoJackItem ); - - JMenuItem addMDCItem = new JMenuItem( "MDC-1200" ); - addMDCItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - MDC1200ID mdc = new MDC1200ID(); - - getAlias().addAliasID( mdc ); - - MDC1200IDNode node = new MDC1200IDNode( mPlaylistManager, mdc ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addMDCItem ); - - JMenuItem addMINItem = new JMenuItem( "MIN" ); - addMINItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - Min min = new Min(); - - getAlias().addAliasID( min ); - - MINNode node = new MINNode( mPlaylistManager, min ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addMINItem ); - - JMenuItem addMPTItem = new JMenuItem( "MPT-1327" ); - addMPTItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - MPT1327ID mpt = new MPT1327ID(); - - getAlias().addAliasID( mpt ); - - MPT1327IDNode node = new MPT1327IDNode( mPlaylistManager, mpt ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addMPTItem ); - - JMenuItem addSiteItem = new JMenuItem( "Site" ); - addSiteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - SiteID siteID = new SiteID(); - - getAlias().addAliasID( siteID ); - - SiteIDNode node = new SiteIDNode( mPlaylistManager, siteID ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addSiteItem ); - - JMenuItem addStatusItem = new JMenuItem( "Status" ); - addStatusItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - StatusID statusID = new StatusID(); - - getAlias().addAliasID( statusID ); - - StatusIDNode node = new StatusIDNode( mPlaylistManager, statusID ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - - addIDMenu.add( addStatusItem ); - - JMenuItem addTalkgroupItem = new JMenuItem( "Talkgroup" ); - addTalkgroupItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - TalkgroupID tg = new TalkgroupID(); - - getAlias().addAliasID( tg ); - - TalkgroupIDNode node = new TalkgroupIDNode( mPlaylistManager, tg ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addTalkgroupItem ); - - JMenuItem addUniqueIDItem = new JMenuItem( "Unique ID" ); - addUniqueIDItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - UniqueID uid = new UniqueID(); - - getAlias().addAliasID( uid ); - - UniqueIDNode node = new UniqueIDNode( mPlaylistManager, uid ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - addIDMenu.add( addUniqueIDItem ); - - retVal.add( addIDMenu ); - - JMenu addActionMenu = new JMenu( "Add Action" ); - - JMenuItem addClipItem = new JMenuItem( "Audio Clip" ); - - addClipItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - ClipAction clipAction = new ClipAction(); - - getAlias().addAliasAction( clipAction ); - - ClipActionNode node = new ClipActionNode( mPlaylistManager, clipAction ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - - addActionMenu.add( addClipItem ); - - JMenuItem addBeepItem = new JMenuItem( "Beep" ); - - addBeepItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - BeepAction beepAction = new BeepAction(); - - getAlias().addAliasAction( beepAction ); - - BeepActionNode node = new BeepActionNode( mPlaylistManager, beepAction ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - - addActionMenu.add( addBeepItem ); - - JMenuItem addScriptItem = new JMenuItem( "Script" ); - - addScriptItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - ScriptAction scriptAction = new ScriptAction(); - - getAlias().addAliasAction( scriptAction ); - - ScriptActionNode node = new ScriptActionNode( mPlaylistManager, scriptAction ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - - addActionMenu.add( addScriptItem ); - - retVal.add( addActionMenu ); - - retVal.addSeparator(); - - if( getAlias().isRecordable() ) - { - JMenuItem nonRecordableItem = new JMenuItem( "Set Non-Recordable" ); - - nonRecordableItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - NonRecordable non = new NonRecordable(); - - getAlias().addAliasID( non ); - - NonRecordableNode node = new NonRecordableNode( mPlaylistManager, non ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - - retVal.add( nonRecordableItem ); - retVal.addSeparator(); - } - - if( !getAlias().hasCallPriority() ) - { - JMenuItem priorityItem = new JMenuItem( "Set Call Priority" ); - - priorityItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - Priority priority = new Priority(); - - getAlias().addAliasID( priority ); - - PriorityNode node = new PriorityNode( mPlaylistManager, priority ); - - getModel().addNode( node, - AliasNode.this, - AliasNode.this.getChildCount() ); - - node.show(); - } - } ); - - retVal.add( priorityItem ); - retVal.addSeparator(); - } - - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - GroupNode parent = (GroupNode)getParent(); - - parent.getGroup().removeAlias( getAlias() ); - - save(); - - getModel().removeNodeFromParent( AliasNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/GroupEditor.java b/src/alias/GroupEditor.java deleted file mode 100644 index 6cb6ab1d..00000000 --- a/src/alias/GroupEditor.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.tree.TreePath; - -import net.miginfocom.swing.MigLayout; -import controller.ConfigurableNode; - -public class GroupEditor extends JPanel implements ActionListener -{ - private static final long serialVersionUID = 1L; - private GroupNode mGroupNode; - - private JLabel mLabelName; - private JTextField mTextGroup; - - public GroupEditor( GroupNode groupNode ) - { - mGroupNode = groupNode; - - initGUI(); - } - - private void initGUI() - { - setLayout( new MigLayout( "", "[right][grow,fill]", "[][][grow]" ) ); - - setBorder( BorderFactory.createTitledBorder( "Group" ) ); - - mLabelName = new JLabel( "Name:" ); - add( mLabelName, "align right" ); - - mTextGroup = new JTextField( mGroupNode.getGroup().getName() ); - add( mTextGroup, "wrap" ); - - JButton btnSave = new JButton( "Save" ); - btnSave.addActionListener( GroupEditor.this ); - add( btnSave ); - - JButton btnReset = new JButton( "Reset" ); - btnReset.addActionListener( GroupEditor.this ); - add( btnReset, "wrap" ); - } - - @Override - public void actionPerformed( ActionEvent e ) - { - String command = e.getActionCommand(); - - if( command.contentEquals( "Save" ) ) - { - String group = mTextGroup.getText(); - - if( group != null ) - { - boolean expanded = mGroupNode.getModel().getTree() - .isExpanded( new TreePath( mGroupNode ) ); - - mGroupNode.getGroup().setName( group ); - - ((ConfigurableNode)mGroupNode.getParent()).sort(); - - mGroupNode.save(); - - mGroupNode.show(); - - if( expanded ) - { - mGroupNode.getModel().getTree() - .expandPath( new TreePath( mGroupNode ) ); - } - } - else - { - JOptionPane.showMessageDialog( GroupEditor.this, "Please enter a group name" ); - } - } - else if( command.contentEquals( "Reset" ) ) - { - mTextGroup.setText( mGroupNode.getGroup().getName() ); - } - - mGroupNode.refresh(); - } -} diff --git a/src/alias/GroupNode.java b/src/alias/GroupNode.java deleted file mode 100644 index f8d52904..00000000 --- a/src/alias/GroupNode.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; - -import playlist.PlaylistManager; -import settings.SettingsManager; -import controller.ConfigurableNode; - -public class GroupNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private PlaylistManager mPlaylistManager; - private SettingsManager mSettingsManager; - - public GroupNode( PlaylistManager playlistManager, - SettingsManager settingsManager, - Group group ) - { - super( playlistManager, group ); - - mSettingsManager = settingsManager; - } - - @Override - public JPanel getEditor() - { - return new GroupEditor( this ); - } - - public Group getGroup() - { - return (Group)getUserObject(); - } - - public void init() - { - for( Alias alias: getGroup().getAlias() ) - { - AliasNode node = new AliasNode( mPlaylistManager, mSettingsManager, alias ); - - getModel().addNode( node, GroupNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - public String toString() - { - return getGroup().getName() + " [" + this.getChildCount() + "]"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addItem = new JMenuItem( "Add Alias" ); - addItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - Alias alias = new Alias(); - - getGroup().addAlias( alias ); - - AliasNode node = new AliasNode( mPlaylistManager, mSettingsManager, alias ); - - getModel().addNode( node, - GroupNode.this, - GroupNode.this.getChildCount() ); - - sort(); - - getModel().showNode( node ); - } - } ); - - retVal.add( addItem ); - - retVal.add( new JSeparator() ); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasListNode parent = (AliasListNode)getParent(); - - parent.getList().removeGroup( getGroup() ); - - save(); - - getModel().removeNodeFromParent( GroupNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/ListEditor.java b/src/alias/ListEditor.java deleted file mode 100644 index b4649a5c..00000000 --- a/src/alias/ListEditor.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.tree.TreePath; - -import net.miginfocom.swing.MigLayout; -import controller.ConfigurableNode; - -public class ListEditor extends JPanel implements ActionListener -{ - private static final long serialVersionUID = 1L; - private AliasListNode mListNode; - - private JLabel mLabelName; - private JTextField mTextGroup; - - public ListEditor( AliasListNode listNode ) - { - mListNode = listNode; - - initGUI(); - } - - private void initGUI() - { - setLayout( new MigLayout( "", "[right][grow,fill]", "[][][grow]" ) ); - - setBorder( BorderFactory.createTitledBorder( "List" ) ); - - mLabelName = new JLabel( "Name:" ); - add( mLabelName, "align right" ); - - mTextGroup = new JTextField( mListNode.getList().getName() ); - add( mTextGroup, "grow, wrap" ); - - JButton btnSave = new JButton( "Save" ); - btnSave.addActionListener( ListEditor.this ); - add( btnSave ); - - JButton btnReset = new JButton( "Reset" ); - btnReset.addActionListener( ListEditor.this ); - add( btnReset, "wrap" ); - } - - @Override - public void actionPerformed( ActionEvent e ) - { - String command = e.getActionCommand(); - - if( command.contentEquals( "Save" ) ) - { - String group = mTextGroup.getText(); - - if( group != null ) - { - boolean expanded = mListNode.getModel().getTree() - .isExpanded( new TreePath( mListNode ) ); - - mListNode.getList().setName( group ); - ((ConfigurableNode)mListNode.getParent()).sort(); - mListNode.save(); - - mListNode.show(); - - if( expanded ) - { - mListNode.getModel().getTree().expandPath( new TreePath( mListNode ) ); - } - } - else - { - JOptionPane.showMessageDialog( ListEditor.this, "Please enter a list name" ); - } - } - else if( command.contentEquals( "Reset" ) ) - { - mTextGroup.setText( mListNode.getList().getName() ); - } - - mListNode.refresh(); - } -} diff --git a/src/alias/action/AliasActionNode.java b/src/alias/action/AliasActionNode.java deleted file mode 100644 index 173ecf07..00000000 --- a/src/alias/action/AliasActionNode.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.action; - -import playlist.PlaylistManager; -import controller.ConfigurableNode; - -public class AliasActionNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private PlaylistManager mPlaylistManager; - - public AliasActionNode( PlaylistManager playlistManager, AliasAction action ) - { - super( playlistManager, action ); - - mPlaylistManager = playlistManager; - } - - public void save() - { - mPlaylistManager.save(); - } - - public String getIconPath() - { - return "images/action.png"; - } -} diff --git a/src/alias/action/beep/BeepActionNode.java b/src/alias/action/beep/BeepActionNode.java deleted file mode 100644 index 96de565e..00000000 --- a/src/alias/action/beep/BeepActionNode.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.action.beep; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.action.AliasActionNode; - -public class BeepActionNode extends AliasActionNode -{ - private static final long serialVersionUID = 1L; - - public BeepActionNode( PlaylistManager playlistManager, BeepAction beepAction ) - { - super( playlistManager, beepAction ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public BeepAction getBeepAction() - { - return (BeepAction)getUserObject(); - } - - public String toString() - { - return "Action: Beep"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasAction( getBeepAction() ); - - /* Save before removing the node ... so that we still have - * a reference to the parent's resources */ - save(); - - getModel().removeNodeFromParent( BeepActionNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/action/clip/ClipActionNode.java b/src/alias/action/clip/ClipActionNode.java deleted file mode 100644 index 3e42a432..00000000 --- a/src/alias/action/clip/ClipActionNode.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.action.clip; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.action.AliasActionNode; - -public class ClipActionNode extends AliasActionNode -{ - private static final long serialVersionUID = 1L; - - public ClipActionNode( PlaylistManager playlistManager, ClipAction clipAction ) - { - super( playlistManager, clipAction ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public ClipAction getClipAction() - { - return (ClipAction)getUserObject(); - } - - public String toString() - { - return "Action: Audio Clip"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasAction( getClipAction() ); - - /* Save before removing the node ... so that we still have - * a reference to the parent's resources */ - save(); - - getModel().removeNodeFromParent( ClipActionNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/action/script/ScriptActionNode.java b/src/alias/action/script/ScriptActionNode.java deleted file mode 100644 index 74d20a44..00000000 --- a/src/alias/action/script/ScriptActionNode.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.action.script; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.action.AliasActionNode; - -public class ScriptActionNode extends AliasActionNode -{ - private static final long serialVersionUID = 1L; - - public ScriptActionNode( PlaylistManager playlistManager, ScriptAction scriptAction ) - { - super( playlistManager, scriptAction ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public ScriptAction getScriptAction() - { - return (ScriptAction)getUserObject(); - } - - public String toString() - { - return "Action: Script"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasAction( getScriptAction() ); - - /* Save before removing the node ... so that we still have - * a reference to the parent's resources */ - save(); - - getModel().removeNodeFromParent( ScriptActionNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/id/AliasID.java b/src/alias/id/AliasID.java index 63497c91..14345e9b 100644 --- a/src/alias/id/AliasID.java +++ b/src/alias/id/AliasID.java @@ -20,7 +20,7 @@ package alias.id; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; -import alias.Group; +import playlist.version1.Group; import alias.id.esn.Esn; import alias.id.fleetsync.FleetsyncID; import alias.id.lojack.LoJackFunctionAndID; diff --git a/src/alias/id/esn/ESNNode.java b/src/alias/id/esn/ESNNode.java deleted file mode 100644 index b75dc306..00000000 --- a/src/alias/id/esn/ESNNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.esn; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class ESNNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public ESNNode( PlaylistManager playlistManager, Esn esn ) - { - super( playlistManager, esn ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public Esn getESN() - { - return (Esn)getUserObject(); - } - - public String toString() - { - return "ESN " + getESN().getEsn(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getESN() ); - - save(); - - getModel().removeNodeFromParent( ESNNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/fleetsync/FleetsyncIDNode.java b/src/alias/id/fleetsync/FleetsyncIDNode.java deleted file mode 100644 index aae77b47..00000000 --- a/src/alias/id/fleetsync/FleetsyncIDNode.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.fleetsync; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class FleetsyncIDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public FleetsyncIDNode( PlaylistManager playlistManager, FleetsyncID id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public FleetsyncID getFleetsyncID() - { - return (FleetsyncID)getUserObject(); - } - - public String toString() - { - StringBuilder sb = new StringBuilder(); - - sb.append( "Fleetsync " ); - - String ident = getFleetsyncID().getIdent(); - - if( ident != null ) - { - sb.append( ident ); - } - - return sb.toString(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getFleetsyncID() ); - - save(); - - getModel().removeNodeFromParent( FleetsyncIDNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/id/lojack/LoJackIDNode.java b/src/alias/id/lojack/LoJackIDNode.java deleted file mode 100644 index 76588b38..00000000 --- a/src/alias/id/lojack/LoJackIDNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.lojack; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class LoJackIDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public LoJackIDNode( PlaylistManager playlistManager, LoJackFunctionAndID id ) - { - super( playlistManager,id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public LoJackFunctionAndID getLoJackID() - { - return (LoJackFunctionAndID)getUserObject(); - } - - public String toString() - { - return getLoJackID().toString(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getLoJackID() ); - - save(); - - getModel().removeNodeFromParent( LoJackIDNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/id/mdc/MDC1200IDNode.java b/src/alias/id/mdc/MDC1200IDNode.java deleted file mode 100644 index 06309d68..00000000 --- a/src/alias/id/mdc/MDC1200IDNode.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.mdc; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class MDC1200IDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public MDC1200IDNode( PlaylistManager playlistManager, MDC1200ID id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public MDC1200ID getMDC1200ID() - { - return (MDC1200ID)getUserObject(); - } - - public String toString() - { - StringBuilder sb = new StringBuilder(); - - sb.append( "MDC-1200 " ); - sb.append( getMDC1200ID().getIdent() ); - - return sb.toString(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getMDC1200ID() ); - - save(); - - getModel().removeNodeFromParent( MDC1200IDNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/id/mobileID/MINNode.java b/src/alias/id/mobileID/MINNode.java deleted file mode 100644 index 2c04c0e8..00000000 --- a/src/alias/id/mobileID/MINNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.mobileID; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class MINNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public MINNode( PlaylistManager playlistManager, Min min ) - { - super( playlistManager, min ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public Min getMIN() - { - return (Min)getUserObject(); - } - - public String toString() - { - return "MIN " + getMIN().getMin(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getMIN() ); - - save(); - - getModel().removeNodeFromParent( MINNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/mpt1327/MPT1327IDNode.java b/src/alias/id/mpt1327/MPT1327IDNode.java deleted file mode 100644 index da648bfe..00000000 --- a/src/alias/id/mpt1327/MPT1327IDNode.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.mpt1327; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class MPT1327IDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public MPT1327IDNode( PlaylistManager playlistManager, MPT1327ID id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public MPT1327ID getMPT1327ID() - { - return (MPT1327ID)getUserObject(); - } - - public String toString() - { - StringBuilder sb = new StringBuilder(); - - sb.append( "MPT-1327 " ); - sb.append( getMPT1327ID().getIdent() ); - - return sb.toString(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getMPT1327ID() ); - - save(); - - getModel().removeNodeFromParent( MPT1327IDNode.this ); - } - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/alias/id/nonrecordable/NonRecordableNode.java b/src/alias/id/nonrecordable/NonRecordableNode.java deleted file mode 100644 index 81f756bb..00000000 --- a/src/alias/id/nonrecordable/NonRecordableNode.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.nonrecordable; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasID; -import alias.id.AliasIDNode; - -public class NonRecordableNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public NonRecordableNode( PlaylistManager playlistManager, NonRecordable id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - @Override - public String getIconPath() - { - return "images/no_record.png"; - } - - public String toString() - { - return "Non-Recordable"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( (AliasID)getUserObject() ); - - save(); - - getModel().removeNodeFromParent( NonRecordableNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/priority/PriorityNode.java b/src/alias/id/priority/PriorityNode.java deleted file mode 100644 index 52b94cec..00000000 --- a/src/alias/id/priority/PriorityNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2015 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 - ******************************************************************************/ -package alias.id.priority; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class PriorityNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public PriorityNode( PlaylistManager playlistManager, Priority priority ) - { - super( playlistManager, priority ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public Priority getPriority() - { - return (Priority)getUserObject(); - } - - public String toString() - { - return getPriority().toString(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getPriority() ); - - save(); - - getModel().removeNodeFromParent( PriorityNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/siteID/SiteIDNode.java b/src/alias/id/siteID/SiteIDNode.java deleted file mode 100644 index a234584c..00000000 --- a/src/alias/id/siteID/SiteIDNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.siteID; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class SiteIDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public SiteIDNode( PlaylistManager playlistManager, SiteID id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public SiteID getSiteID() - { - return (SiteID)getUserObject(); - } - - public String toString() - { - return "Site " + getSiteID().getSite(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getSiteID() ); - - save(); - - getModel().removeNodeFromParent( SiteIDNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/status/StatusIDNode.java b/src/alias/id/status/StatusIDNode.java deleted file mode 100644 index 2c20df17..00000000 --- a/src/alias/id/status/StatusIDNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.status; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class StatusIDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public StatusIDNode( PlaylistManager playlistManager, StatusID id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public StatusID getStatusID() - { - return (StatusID)getUserObject(); - } - - public String toString() - { - return "Status Code " + getStatusID().getStatus(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getStatusID() ); - - save(); - - getModel().removeNodeFromParent( StatusIDNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/talkgroup/TalkgroupIDNode.java b/src/alias/id/talkgroup/TalkgroupIDNode.java deleted file mode 100644 index a58ffb05..00000000 --- a/src/alias/id/talkgroup/TalkgroupIDNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.talkgroup; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class TalkgroupIDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public TalkgroupIDNode( PlaylistManager playlistManager, TalkgroupID id ) - { - super( playlistManager,id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public TalkgroupID getTalkgroupID() - { - return (TalkgroupID)getUserObject(); - } - - public String toString() - { - return "Talkgroup " + getTalkgroupID().getTalkgroup(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getTalkgroupID() ); - - save(); - - getModel().removeNodeFromParent( TalkgroupIDNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/alias/id/uniqueID/UniqueIDNode.java b/src/alias/id/uniqueID/UniqueIDNode.java deleted file mode 100644 index 430ecdbd..00000000 --- a/src/alias/id/uniqueID/UniqueIDNode.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package alias.id.uniqueID; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import alias.AliasNode; -import alias.id.AliasIDNode; - -public class UniqueIDNode extends AliasIDNode -{ - private static final long serialVersionUID = 1L; - - public UniqueIDNode( PlaylistManager playlistManager, UniqueID id ) - { - super( playlistManager, id ); - } - - @Override - public JPanel getEditor() - { - return null; - } - - public UniqueID getUniqueID() - { - return (UniqueID)getUserObject(); - } - - public String toString() - { - return "Unique ID " + getUniqueID().getUid(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Delete" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int n = JOptionPane.showConfirmDialog( getModel().getTree(), - "Are you sure you want to permanently delete this node?" ); - - if( n == JOptionPane.YES_OPTION ) - { - AliasNode parent = (AliasNode)getParent(); - - parent.getAlias().removeAliasID( getUniqueID() ); - - save(); - - getModel().removeNodeFromParent( UniqueIDNode.this ); - } - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/controller/ConfigurationControllerModel.java b/src/controller/ConfigurationControllerModel.java index 22d3232c..c3f28c87 100644 --- a/src/controller/ConfigurationControllerModel.java +++ b/src/controller/ConfigurationControllerModel.java @@ -18,7 +18,6 @@ package controller; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -29,21 +28,14 @@ import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreePath; import module.decode.DecoderType; - -import playlist.PlaylistManager; -import playlist.PlaylistNode; - import settings.SettingsManager; import source.SourceManager; -import source.recording.RecordingGroupNode; import source.tuner.Tuner; import source.tuner.TunerGroupNode; import source.tuner.TunerNode; import source.tuner.TunerSelectionListener; import controller.channel.Channel; import controller.channel.ChannelModel; -import controller.channel.ChannelNode; - import controller.channel.ChannelProcessingManager; public class ConfigurationControllerModel extends DefaultTreeModel @@ -55,13 +47,10 @@ public class ConfigurationControllerModel extends DefaultTreeModel private ArrayList mTunerSelectionListeners = new ArrayList(); - private PlaylistNode mPlaylistNode; private TunerGroupNode mTunerGroupNode; -// private RecordingGroupNode mRecordingGroupNode; private ChannelModel mChannelModel; private ChannelProcessingManager mChannelProcessingManager; - private PlaylistManager mPlaylistManager; private SettingsManager mSettingsManager; private SourceManager mSourceManager; @@ -73,7 +62,6 @@ public class ConfigurationControllerModel extends DefaultTreeModel */ public ConfigurationControllerModel( ChannelModel channelModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, SettingsManager settingsManager, SourceManager sourceManager ) { @@ -81,7 +69,6 @@ public class ConfigurationControllerModel extends DefaultTreeModel mChannelModel = channelModel; mChannelProcessingManager = channelProcessingManager; - mPlaylistManager = playlistManager; mSettingsManager = settingsManager; mSourceManager = sourceManager; @@ -117,13 +104,13 @@ public class ConfigurationControllerModel extends DefaultTreeModel // insertNodeInto( mRecordingGroupNode, (MutableTreeNode)root, 1 ); // mRecordingGroupNode.loadRecordings(); - /** - * Add the playlist node - */ - mPlaylistNode = new PlaylistNode( mChannelModel, mChannelProcessingManager, - mPlaylistManager, mSettingsManager, mSourceManager ); - insertNodeInto( mPlaylistNode, (MutableTreeNode)root, 1 ); - mPlaylistNode.loadPlaylist(); +// /** +// * Add the playlist node +// */ +// mPlaylistNode = new PlaylistNode( mChannelModel, mChannelProcessingManager, +// mPlaylistManager, mSettingsManager, mSourceManager ); +// insertNodeInto( mPlaylistNode, (MutableTreeNode)root, 1 ); +// mPlaylistNode.loadPlaylist(); } public void showNode( DefaultMutableTreeNode node ) @@ -146,8 +133,7 @@ public class ConfigurationControllerModel extends DefaultTreeModel for( Tuner tuner: tuners ) { TunerNode child = new TunerNode( mChannelModel, - mChannelProcessingManager, mPlaylistManager, mSettingsManager, - tuner ); + mChannelProcessingManager, mSettingsManager, tuner ); insertNodeInto( child, parent, parent.getChildCount() ); @@ -250,28 +236,11 @@ public class ConfigurationControllerModel extends DefaultTreeModel public ArrayList getCurrentChannelConfigs() { - return getChannelConfigs( mPlaylistNode ); + return null; } private ArrayList getChannelConfigs( DefaultMutableTreeNode parent ) { - ArrayList configs = new ArrayList(); - - Enumeration nodes = parent.children(); - - while( nodes.hasMoreElements() ) - { - DefaultMutableTreeNode node = nodes.nextElement(); - - if( node instanceof ChannelNode ) - { - configs.add( ((ChannelNode)node).getChannel() ); - } - - //Recursive call - configs.addAll( getChannelConfigs( node ) ); - } - - return configs; + return null; } } diff --git a/src/controller/ControllerPanel.java b/src/controller/ControllerPanel.java index 8c58d145..c9018a7c 100644 --- a/src/controller/ControllerPanel.java +++ b/src/controller/ControllerPanel.java @@ -33,7 +33,6 @@ import module.decode.event.CallEventPanel; import module.decode.event.MessageActivityPanel; import module.decode.state.ChannelList; import net.miginfocom.swing.MigLayout; -import playlist.PlaylistManager; import settings.SettingsManager; import source.SourceManager; import spectrum.ChannelSpectrumPanel; @@ -48,6 +47,7 @@ import com.jidesoft.swing.JideTabbedPane; import controller.channel.ChannelController; import controller.channel.ChannelModel; import controller.channel.ChannelProcessingManager; +import controller.channel.map.ChannelMapModel; public class ControllerPanel extends JPanel { @@ -83,9 +83,9 @@ public class ControllerPanel extends JPanel ConfigurationControllerModel controller, AliasModel aliasModel, ChannelModel channelModel, + ChannelMapModel channelMapModel, ChannelProcessingManager channelProcessingManager, MapService mapService, - PlaylistManager playlistManager, SettingsManager settingsManager, SourceManager sourceManager ) { @@ -105,9 +105,10 @@ public class ControllerPanel extends JPanel channelProcessingManager ); mChannelStateList = new ChannelList( channelModel, channelProcessingManager, - playlistManager, mSettingsManager ); + mSettingsManager ); - mChannelController = new ChannelController( channelModel, playlistManager, sourceManager ); + mChannelController = new ChannelController( channelModel, channelMapModel, + sourceManager, aliasModel ); mAliasController = new AliasController( aliasModel, mSettingsManager ); diff --git a/src/controller/channel/ChannelController.java b/src/controller/channel/ChannelController.java index 498fae64..c571adf7 100644 --- a/src/controller/channel/ChannelController.java +++ b/src/controller/channel/ChannelController.java @@ -25,9 +25,12 @@ import org.slf4j.LoggerFactory; import playlist.PlaylistManager; import source.SourceManager; +import alias.AliasModel; import com.jidesoft.swing.JideSplitPane; +import controller.channel.map.ChannelMapModel; + public class ChannelController extends JPanel implements ActionListener, ListSelectionListener { @@ -47,13 +50,15 @@ public class ChannelController extends JPanel private JButton mCopyChannelButton = new JButton( COPY_CHANNEL ); private JButton mDeleteChannelButton = new JButton( DELETE_CHANNEL ); - public ChannelController( ChannelModel channelModel, - PlaylistManager playlistManager, - SourceManager sourceManager ) + public ChannelController( ChannelModel channelModel, + ChannelMapModel channelMapModel, + SourceManager sourceManager, + AliasModel aliasModel ) { mChannelModel = channelModel; - mEditor = new ChannelEditor( channelModel, playlistManager, sourceManager ); + mEditor = new ChannelEditor( channelModel, channelMapModel, + sourceManager, aliasModel ); mChannelModel.addListener( mEditor ); init(); diff --git a/src/controller/channel/ChannelEditor.java b/src/controller/channel/ChannelEditor.java index 8836a2da..79779120 100644 --- a/src/controller/channel/ChannelEditor.java +++ b/src/controller/channel/ChannelEditor.java @@ -40,10 +40,12 @@ import playlist.PlaylistManager; import record.RecordComponentEditor; import source.SourceComponentEditor; import source.SourceManager; +import alias.AliasModel; import com.jidesoft.swing.JideTabbedPane; import controller.channel.ChannelEvent.Event; +import controller.channel.map.ChannelMapModel; public class ChannelEditor extends JPanel implements ActionListener, ChannelEventListener @@ -65,23 +67,24 @@ public class ChannelEditor extends JPanel private JLabel mChannelName = new JLabel( "Channel:" ); private ChannelModel mChannelModel; - private PlaylistManager mPlaylistManager; + private ChannelMapModel mChannelMapModel; private SourceManager mSourceManager; private boolean mChannelEnableRequested = false; public ChannelEditor( ChannelModel channelModel, - PlaylistManager playlistManager, - SourceManager sourceManager ) + ChannelMapModel channelMapModel, + SourceManager sourceManager, + AliasModel aliasModel ) { super(); mChannelModel = channelModel; - mPlaylistManager = playlistManager; + mChannelMapModel = channelMapModel; mSourceManager = sourceManager; - mNameConfigurationEditor = new NameConfigurationEditor( - mChannelModel, mPlaylistManager ); + mNameConfigurationEditor = new NameConfigurationEditor( aliasModel, + mChannelModel ); initGUI(); } @@ -137,7 +140,7 @@ public class ChannelEditor extends JPanel mSourceEditor = new SourceComponentEditor( mSourceManager ); tabs.addTab( "Source", mSourceEditor ); - mDecodeEditor = new DecodeComponentEditor( mPlaylistManager ); + mDecodeEditor = new DecodeComponentEditor( mChannelMapModel ); tabs.addTab( "Decoder", mDecodeEditor ); mAuxDecodeEditor = new AuxDecodeComponentEditor(); diff --git a/src/controller/channel/ChannelNode.java b/src/controller/channel/ChannelNode.java deleted file mode 100644 index ca8e5b37..00000000 --- a/src/controller/channel/ChannelNode.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.channel; - -import java.awt.Color; -import java.text.DecimalFormat; - -import javax.swing.JMenu; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import playlist.PlaylistManager; -import source.SourceManager; -import source.tuner.TunerChannel; -import controller.ConfigurableNode; -import controller.site.SiteNode; -import controller.system.SystemNode; - -/** - * A channel has all of the pieces needed to wire together a source, decoder, - * event logger and recorder and be started and stopped. - */ -public class ChannelNode extends ConfigurableNode implements ChannelEventListener -{ - private static final long serialVersionUID = 1L; - - private final static Logger mLog = LoggerFactory.getLogger( ChannelNode.class ); - - private static DecimalFormat sFORMAT = new DecimalFormat( "0.0000" ); - - private ChannelModel mChannelModel; - private ChannelProcessingManager mChannelProcessingManager; - private SourceManager mSourceManager; - - public ChannelNode( Channel channel, - ChannelModel channelModel, - ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, - SourceManager sourceManager ) - { - super( playlistManager, channel ); - - mChannelModel = channelModel; - mChannelProcessingManager = channelProcessingManager; - mSourceManager = sourceManager; - } - - public void init() - { - /* Set the owning system and site names for the channel */ - SiteNode siteNode = (SiteNode)getParent(); - - if( siteNode != null ) - { - getChannel().setSite( siteNode.getSite().getName() ); - - SystemNode systemNode = (SystemNode)siteNode.getParent(); - - if( systemNode != null ) - { - getChannel().setSystem( systemNode.getSystem().getName() ); - } - } - - /* Add this node as listener to receive changes from underlying channel */ -// getChannel().addListener( this ); - - } - - /** - * Listener method to receive channel changes from the underlying chnannel - */ - @Override - public void channelChanged( ChannelEvent event ) - { - switch( event.getEvent() ) - { - /* Refresh the node for each of these events */ - case NOTIFICATION_SELECTION_CHANGE: - case NOTIFICATION_PROCESSING_START: - case NOTIFICATION_PROCESSING_STOP: - this.refresh(); - break; - /* We're being deleted, so cleanup */ - case NOTIFICATION_DELETE: - delete(); - break; - default: - break; - } - } - - @Override - public String getIconPath() - { - return getChannel().getDecodeConfiguration().getDecoderType() - .getIconFilename(); - } - - @Override - public Color getBackgroundColor() - { - if( getChannel().getEnabled() ) - { - if( getChannel().getEnabled() ) - { - return Color.GREEN; - } - else - { - return Color.RED; - } - } - - return null; - } - - @Override - public JPanel getEditor() - { - return new OldChannelEditor( getChannel(), mChannelModel, getPlaylistManager(), mSourceManager ); - } - - public Channel getChannel() - { - return (Channel)this.getUserObject(); - } - - public String toString() - { - StringBuilder sb = new StringBuilder(); - - sb.append( getChannel().getName() ); - - TunerChannel channel = getChannel().getTunerChannel(); - - if( channel != null ) - { - sb.append( " (" ); - sb.append( sFORMAT.format( (double)channel.getFrequency() / 1000000.0d ) + " MHz" ); - sb.append( ")" ); - - } - - return sb.toString(); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu popupMenu = new JPopupMenu(); - - JMenu channelMenu = ChannelUtils.getContextMenu( mChannelModel, - mChannelProcessingManager, getPlaylistManager(), getChannel(), - getModel().getTree() ); - - if( channelMenu != null ) - { - popupMenu.add( channelMenu ); - } - - return popupMenu; - } - - public void delete() - { - ((SiteNode)getParent()).getSite().removeChannel( getChannel() ); - - save(); - - getModel().removeNodeFromParent( ChannelNode.this ); - } -} diff --git a/src/controller/channel/ChannelProcessingManager.java b/src/controller/channel/ChannelProcessingManager.java index dac06b4d..52ab21a2 100644 --- a/src/controller/channel/ChannelProcessingManager.java +++ b/src/controller/channel/ChannelProcessingManager.java @@ -40,12 +40,14 @@ import sample.Listener; import source.Source; import source.SourceException; import source.SourceManager; +import alias.AliasModel; import audio.AudioPacket; import audio.metadata.Metadata; import audio.metadata.MetadataType; import controller.ThreadPoolManager; import controller.channel.Channel.ChannelType; import controller.channel.ChannelEvent.Event; +import controller.channel.map.ChannelMapModel; import filter.FilterSet; public class ChannelProcessingManager implements ChannelEventListener @@ -58,22 +60,25 @@ public class ChannelProcessingManager implements ChannelEventListener private List> mMessageListeners = new CopyOnWriteArrayList<>(); private ChannelModel mChannelModel; + private ChannelMapModel mChannelMapModel; + private AliasModel mAliasModel; private EventLogManager mEventLogManager; - private PlaylistManager mPlaylistManager; private RecorderManager mRecorderManager; private SourceManager mSourceManager; private ThreadPoolManager mThreadPoolManager; public ChannelProcessingManager( ChannelModel channelModel, + ChannelMapModel channelMapModel, + AliasModel aliasModel, EventLogManager eventLogManager, - PlaylistManager playlistManager, RecorderManager recorderManager, SourceManager sourceManager, ThreadPoolManager threadPoolManager ) { mChannelModel = channelModel; + mChannelMapModel = channelMapModel; + mAliasModel = aliasModel; mEventLogManager = eventLogManager; - mPlaylistManager = playlistManager; mRecorderManager = recorderManager; mSourceManager = sourceManager; mThreadPoolManager = threadPoolManager; @@ -201,7 +206,7 @@ public class ChannelProcessingManager implements ChannelEventListener /* Processing Modules */ List modules = DecoderFactory.getModules( mChannelModel, - this, mPlaylistManager, channel ); + mChannelMapModel, this, mAliasModel, channel ); processingChain.addModules( modules ); /* Setup message activity model with filtering */ diff --git a/src/controller/channel/ChannelUtils.java b/src/controller/channel/ChannelUtils.java index 9a716ea3..6434eb4c 100644 --- a/src/controller/channel/ChannelUtils.java +++ b/src/controller/channel/ChannelUtils.java @@ -9,26 +9,20 @@ import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JSeparator; -import controller.channel.ChannelEvent.Event; import module.ProcessingChain; import module.decode.event.ActivitySummaryFrame; import module.decode.state.DecoderState; -import playlist.PlaylistManager; +import controller.channel.ChannelEvent.Event; public class ChannelUtils { - private static final boolean ENABLED = true; - private static final boolean DISABLED = false; - private static final boolean BROADCAST_CHANGE = true; - /** * Creates a context menu for the channel argument */ public static JMenu getContextMenu( final ChannelModel channelModel, - final ChannelProcessingManager channelProcessingManager, - final PlaylistManager playlistManager, - final Channel channel, - final Component anchor ) + final ChannelProcessingManager channelProcessingManager, + final Channel channel, + final Component anchor ) { if( channel != null ) { diff --git a/src/controller/channel/NameConfigurationEditor.java b/src/controller/channel/NameConfigurationEditor.java index 3101e12e..f9b65bce 100644 --- a/src/controller/channel/NameConfigurationEditor.java +++ b/src/controller/channel/NameConfigurationEditor.java @@ -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 EMPTY_MODEL = new DefaultComboBoxModel<>(); + private AliasModel mAliasModel; private ChannelModel mChannelModel; - private PlaylistManager mPlaylistManager; private JTextField mChannelName = new JTextField( DEFAULT_NAME ); private JComboBox mSystemNameCombo = new JComboBox<>( EMPTY_MODEL ); private JComboBox mSiteNameCombo = new JComboBox<>( EMPTY_MODEL ); - private JComboBox mAliasListCombo; + private JComboBox 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(); + mAliasListCombo = new JComboBox(); - List lists = mPlaylistManager.getPlayist() - .getAliasDirectory().getAliasList(); + List lists = mAliasModel.getListNames(); Collections.sort( lists ); - mAliasListCombo.setModel( new DefaultComboBoxModel( - lists.toArray( new AliasList[ lists.size() ] ) ) ); + mAliasListCombo.setModel( new DefaultComboBoxModel( + 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 lists = mPlaylistManager.getPlayist() - .getAliasDirectory().getAliasList(); - - Collections.sort( lists ); - - mAliasListCombo.setModel( new DefaultComboBoxModel( - 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 lists = mPlaylistManager.getPlayist() +// .getAliasDirectory().getAliasList(); +// +// Collections.sort( lists ); +// +// mAliasListCombo.setModel( new DefaultComboBoxModel( +// 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 diff --git a/src/controller/channel/OldChannelEditor.java b/src/controller/channel/OldChannelEditor.java deleted file mode 100644 index 6882e457..00000000 --- a/src/controller/channel/OldChannelEditor.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.channel; - - -import java.awt.Color; -import java.awt.ComponentOrientation; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Collections; -import java.util.List; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JTextField; - -import module.decode.AuxDecodeComponentEditor; -import module.decode.DecodeComponentEditor; -import module.log.EventLogComponentEditor; -import net.miginfocom.swing.MigLayout; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import playlist.PlaylistManager; -import record.RecordComponentEditor; -import source.SourceComponentEditor; -import source.SourceManager; -import alias.AliasList; - -import com.jidesoft.swing.JideTabbedPane; - -public class OldChannelEditor extends ChannelConfigurationEditor implements ActionListener -{ - private final static Logger mLog = LoggerFactory.getLogger( OldChannelEditor.class ); - - private static final long serialVersionUID = 1L; - - private DecodeComponentEditor mDecodeEditor; - private AuxDecodeComponentEditor mAuxDecodeEditor; - private EventLogComponentEditor mEventLogEditor; - private RecordComponentEditor mRecordEditor; - private SourceComponentEditor mSourceEditor; - - private JTextField mChannelName; - private JCheckBox mChannelEnabled = new JCheckBox(); - private JComboBox mComboAliasLists; - - private Channel mChannel; - private ChannelModel mChannelModel; - private PlaylistManager mPlaylistManager; - private SourceManager mSourceManager; - - public OldChannelEditor( Channel channel, - ChannelModel channelModel, - PlaylistManager playlistManager, - SourceManager sourceManager ) - { - super(); - - mChannel = channel; - mChannelModel = channelModel; - mPlaylistManager = playlistManager; - mSourceManager = sourceManager; - - initGUI(); - } - - private void initGUI() - { - setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][][][grow][]" ) ); - - add( new JLabel( "Channel Configuration" ), "span, align center" ); - - add( new JLabel( "Enabled:" ) ); - - mChannelEnabled.setSelected( mChannel.getEnabled() ); - mChannelEnabled.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT ); - add( mChannelEnabled ); - - add( new JLabel( "Name:" ) ); - - mChannelName = new JTextField( mChannel.getName() ); - add( mChannelName, "growx,push" ); - - /** - * ComboBox: Alias Lists - */ - add( new JLabel( "Alias List:" ) ); - - mComboAliasLists = new JComboBox(); - - List lists = mPlaylistManager.getPlayist() - .getAliasDirectory().getAliasList(); - - Collections.sort( lists ); - - mComboAliasLists.setModel( new DefaultComboBoxModel( - lists.toArray( new AliasList[ lists.size() ] ) ) ); - - String aliasListName = mChannel.getAliasListName(); - - if( aliasListName != null ) - { - AliasList selected = mPlaylistManager.getPlayist().getAliasDirectory() - .getAliasList( aliasListName ); - - mComboAliasLists.setSelectedItem( selected ); - } - - add( mComboAliasLists, "growx,push" ); - - JideTabbedPane tabs = new JideTabbedPane(); - tabs.setFont( this.getFont() ); - tabs.setForeground( Color.BLACK ); - - mSourceEditor = new SourceComponentEditor( mSourceManager ); - tabs.addTab( "Source", mSourceEditor ); - - mDecodeEditor = new DecodeComponentEditor( mPlaylistManager ); - tabs.addTab( "Decoder", mDecodeEditor ); - - mAuxDecodeEditor = new AuxDecodeComponentEditor(); - tabs.addTab( "Aux", mAuxDecodeEditor ); - - mEventLogEditor = new EventLogComponentEditor(); - tabs.addTab( "Event Log", mEventLogEditor ); - - mRecordEditor = new RecordComponentEditor(); - tabs.addTab( "Record", mRecordEditor ); - - add( tabs, "span,grow,push" ); - - JButton btnSave = new JButton( "Save" ); - btnSave.addActionListener( OldChannelEditor.this ); - add( btnSave, "growx,push" ); - - JButton btnReset = new JButton( "Reset" ); - btnReset.addActionListener( OldChannelEditor.this ); - add( btnReset, "growx,push" ); - } - - @Override - public void actionPerformed( ActionEvent e ) - { - String command = e.getActionCommand(); - - if( command.contentEquals( "Save" ) ) - { - save(); - } - else if( command.contentEquals( "Reset" ) ) - { -// reset(); - } - } - - @Override - public void save() - { -// try -// { -// /** -// * Validate the source configuration against the other component -// * configuration editors -// */ -// validate( mSourceEditor.getSourceEditor() ); -// -// mSourceEditor.save(); -// mDecodeEditor.save(); -// mAuxDecodeEditor.save(); -// mEventLogEditor.save(); -// mRecordEditor.save(); -// -// mChannel.setName( mChannelName.getText() ); -// mChannel.setEnabled( mChannelEnabled.isSelected() ); -// -// AliasList selected = mComboAliasLists.getItemAt( -// mComboAliasLists.getSelectedIndex() ); -// if( selected != null ) -// { -// mChannel.setAliasListName( selected.getName() ); -// } -// } -// catch ( ConfigurationValidationException validationException ) -// { -// /* ChannelValidationException can be thrown by any of the component -// * editors. Show the validation error text in a popup menu to the -// * user */ -// JOptionPane.showMessageDialog( OldChannelEditor.this, -// validationException.getMessage(), -// "Channel Configuration Error", -// JOptionPane.ERROR_MESSAGE ); -// } - } - -// @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(); -// } - - @Override - public void setConfiguration( Channel channel ) - { - - } - - @Override - public void validateConfiguration() throws ConfigurationValidationException - { - mSourceEditor.validate(); - mDecodeEditor.validate(); - mAuxDecodeEditor.validate(); - mEventLogEditor.validate(); - mRecordEditor.validate(); - } - -} diff --git a/src/controller/channel/map/ChannelMapEditor.java b/src/controller/channel/map/ChannelMapEditor.java index 11ede472..85e39357 100644 --- a/src/controller/channel/map/ChannelMapEditor.java +++ b/src/controller/channel/map/ChannelMapEditor.java @@ -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 @@ -17,22 +17,22 @@ ******************************************************************************/ package controller.channel.map; +import gui.editor.DocumentListenerEditor; + import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; import javax.swing.AbstractCellEditor; import javax.swing.JButton; import javax.swing.JFormattedTextField; import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.TableCellEditor; import javax.swing.text.InternationalFormatter; @@ -41,28 +41,45 @@ import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ChannelMapEditor extends JPanel implements ActionListener +public class ChannelMapEditor extends DocumentListenerEditor + implements ListSelectionListener { private static final long serialVersionUID = 1L; private final static Logger mLog = LoggerFactory.getLogger( ChannelMapEditor.class ); - private ChannelMapNode mChannelMapNode; - private JLabel mNameLabel; private JTextField mNameText; - private ChannelMapModel mRangeModel; + private ChannelRangeModel mRangeModel; private JTable mRangeTable; private JButton mDelete; - private ChannelMap mChannelMapCopy; - public ChannelMapEditor( ChannelMapNode ChannelMap ) + public ChannelMapEditor() { - mChannelMapNode = ChannelMap; - mChannelMapCopy = mChannelMapNode.getChannelMap().copyOf(); initGUI(); } + private ChannelMap getChannelMap() + { + if( hasItem() ) + { + return (ChannelMap)getItem(); + } + + return null; + } + + @Override + public void setItem( ChannelMap item ) + { + super.setItem( item ); + + if( hasItem() ) + { + + } + } + private void initGUI() { setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow][][]" ) ); @@ -72,20 +89,11 @@ public class ChannelMapEditor extends JPanel implements ActionListener mNameLabel = new JLabel( "Name:" ); add( mNameLabel ); - mNameText = new JTextField( mChannelMapCopy.getName() ); - mNameText.addFocusListener( new FocusListener() - { - @Override public void focusGained( FocusEvent arg0 ) {} - - @Override - public void focusLost( FocusEvent arg0 ) - { - mChannelMapCopy.setName( mNameText.getText() ); - } - } ); + mNameText = new JTextField(); + mNameText.getDocument().addDocumentListener( this ); add( mNameText, "growx, push" ); - mRangeModel = new ChannelMapModel( mChannelMapCopy ); + mRangeModel = new ChannelRangeModel(); mRangeTable = new JTable( mRangeModel ); mRangeTable.setPreferredScrollableViewportSize( new Dimension( 300, 150 ) ); @@ -101,88 +109,89 @@ public class ChannelMapEditor extends JPanel implements ActionListener add( scrollPane, "span,grow,push"); JButton btnNew = new JButton( "New Range" ); - btnNew.addActionListener( ChannelMapEditor.this ); +// btnNew.addActionListener( ChannelMapEditor.this ); add( btnNew ); mDelete = new JButton( "Delete" ); - mDelete.addActionListener( ChannelMapEditor.this ); +// mDelete.addActionListener( ChannelMapEditor.this ); add( mDelete, "wrap" ); JButton btnSave = new JButton( "Save" ); - btnSave.addActionListener( ChannelMapEditor.this ); +// btnSave.addActionListener( ChannelMapEditor.this ); add( btnSave, "growx" ); JButton btnReset = new JButton( "Reset " ); - btnReset.addActionListener( ChannelMapEditor.this ); +// btnReset.addActionListener( ChannelMapEditor.this ); add( btnReset, "wrap" ); } private boolean checkForValidRanges() { - int invalidRow = mChannelMapCopy.getInvalidRange(); - - if( invalidRow != -1 && invalidRow <= mRangeTable.getRowCount() ) - { - mRangeTable.setRowSelectionInterval( invalidRow, invalidRow ); - - JOptionPane.showMessageDialog( this, - "Starting channel number must be less than ending channel number", - "Channel number range error", - JOptionPane.WARNING_MESSAGE ); - - return false; - } + mLog.error( "Fix Me!" ); +// int invalidRow = mChannelMapCopy.getInvalidRange(); +// +// if( invalidRow != -1 && invalidRow <= mRangeTable.getRowCount() ) +// { +// mRangeTable.setRowSelectionInterval( invalidRow, invalidRow ); +// +// JOptionPane.showMessageDialog( this, +// "Starting channel number must be less than ending channel number", +// "Channel number range error", +// JOptionPane.WARNING_MESSAGE ); +// +// return false; +// } return true; } - @Override - public void actionPerformed( ActionEvent e ) - { - String command = e.getActionCommand(); - - switch( command ) - { - case "New Range": - mRangeModel.addRange( new ChannelRange() ); - break; - case "Save": - if( checkForValidRanges() ) - { - mChannelMapNode.getChannelMap() - .setName( mChannelMapCopy.getName() ); - mChannelMapNode.getChannelMap() - .setRanges( mChannelMapCopy.getRanges() ); - - mChannelMapNode.save(); - - mChannelMapNode.refresh(); - - mChannelMapNode.show(); - } - case "Reset": - mChannelMapCopy = mChannelMapNode.getChannelMap(); - mRangeModel.setChannelMap( mChannelMapCopy ); - mNameText.setText( mChannelMapCopy.getName() ); - break; - case "Delete": - int row = mRangeTable.getSelectedRow(); - - if( row < 0 ) - { - JOptionPane.showMessageDialog( this, - "Please select a channel range to delete", - "Select a range", - JOptionPane.WARNING_MESSAGE ); - } - else - { - mRangeModel.removeRange( - mRangeTable.convertRowIndexToModel( row ) ); - } - break; - } - } +// @Override +// public void actionPerformed( ActionEvent e ) +// { +// String command = e.getActionCommand(); +// +// switch( command ) +// { +// case "New Range": +// mRangeModel.addRange( new ChannelRange() ); +// break; +// case "Save": +// if( checkForValidRanges() ) +// { +// mChannelMapNode.getChannelMap() +// .setName( mChannelMapCopy.getName() ); +// mChannelMapNode.getChannelMap() +// .setRanges( mChannelMapCopy.getRanges() ); +// +// mChannelMapNode.save(); +// +// mChannelMapNode.refresh(); +// +// mChannelMapNode.show(); +// } +// case "Reset": +// mChannelMapCopy = mChannelMapNode.getChannelMap(); +// mRangeModel.setChannelMap( mChannelMapCopy ); +// mNameText.setText( mChannelMapCopy.getName() ); +// break; +// case "Delete": +// int row = mRangeTable.getSelectedRow(); +// +// if( row < 0 ) +// { +// JOptionPane.showMessageDialog( this, +// "Please select a channel range to delete", +// "Select a range", +// JOptionPane.WARNING_MESSAGE ); +// } +// else +// { +// mRangeModel.removeRange( +// mRangeTable.convertRowIndexToModel( row ) ); +// } +// break; +// } +// } public class RangeTableEditor extends AbstractCellEditor implements TableCellEditor, ActionListener @@ -221,4 +230,17 @@ public class ChannelMapEditor extends JPanel implements ActionListener return mEditor; } } + + @Override + public void save() + { + // TODO Auto-generated method stub + + } + + @Override + public void valueChanged( ListSelectionEvent e ) + { + mLog.debug( "List Select Event from: " + e.getSource().getClass() ); + } } diff --git a/src/controller/channel/map/ChannelMapEvent.java b/src/controller/channel/map/ChannelMapEvent.java new file mode 100644 index 00000000..a3ca8821 --- /dev/null +++ b/src/controller/channel/map/ChannelMapEvent.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * 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 + ******************************************************************************/ +package controller.channel.map; + +public class ChannelMapEvent +{ + private ChannelMap mChannelMap; + private Event mEvent; + private String mPreviousChannelMapName; + + /** + * ChannelMapEvent - event describing any changes to a channel map + * + * @param channelMap that changed + * @param event describing the change + */ + public ChannelMapEvent( ChannelMap channelMap, Event event ) + { + mChannelMap = channelMap; + mEvent = event; + } + + /** + * ChannelMapEvent - channel map renaming event. + * + * @param channelMap that changed + * @param previousName of the channel map + */ + public ChannelMapEvent( ChannelMap channelMap, String previousName ) + { + this( channelMap, Event.RENAME ); + + mPreviousChannelMapName = previousName; + } + + public ChannelMap getChannelMap() + { + return mChannelMap; + } + + public String getPreviousChannelMapName() + { + return mPreviousChannelMapName; + } + + public Event getEvent() + { + return mEvent; + } + + /** + * Events + */ + public enum Event + { + ADD, + CHANGE, + RENAME, + DELETE; + } +} diff --git a/src/controller/channel/map/ChannelMapListNode.java b/src/controller/channel/map/ChannelMapListNode.java deleted file mode 100644 index 9259bba3..00000000 --- a/src/controller/channel/map/ChannelMapListNode.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.channel.map; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import controller.ConfigurableNode; - -public class ChannelMapListNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - public ChannelMapListNode( PlaylistManager playlistManager, ChannelMapList list ) - { - super( playlistManager, list ); - } - - public ChannelMapList getChannelMapList() - { - return (ChannelMapList)getUserObject(); - } - - public void init() - { - for( ChannelMap channelMap: getChannelMapList().getChannelMap() ) - { - ChannelMapNode node = new ChannelMapNode( getPlaylistManager(), channelMap ); - - getModel().addNode( node, ChannelMapListNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - public String toString() - { - return "Channel Maps [" + this.getChildCount() + "]"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Add Channel Map" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - ChannelMap channelMap = new ChannelMap(); - - getChannelMapList().addChannelMap( channelMap ); - - getModel().addNode( new ChannelMapNode( getPlaylistManager(), channelMap ), - ChannelMapListNode.this, - ChannelMapListNode.this.getChildCount() ); - - save(); - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/controller/channel/map/ChannelMapManager.java b/src/controller/channel/map/ChannelMapManager.java new file mode 100644 index 00000000..d92626a5 --- /dev/null +++ b/src/controller/channel/map/ChannelMapManager.java @@ -0,0 +1,47 @@ +package controller.channel.map; + +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; + +import net.miginfocom.swing.MigLayout; + +import com.jidesoft.swing.JideSplitPane; + +public class ChannelMapManager extends JPanel +{ + private static final long serialVersionUID = 1L; + + private ChannelMapModel mChannelMapModel; + private JList mChannelMapList; + private ChannelMapEditor mChannelMapEditor; + + public ChannelMapManager( ChannelMapModel channelMapModel ) + { + mChannelMapModel = channelMapModel; + mChannelMapList = new JList( mChannelMapModel ); + mChannelMapEditor = new ChannelMapEditor(); + + init(); + } + + private void init() + { + setLayout( new MigLayout( "", "[fill,grow]", "[fill,grow]" ) ); + + mChannelMapList.addListSelectionListener( mChannelMapEditor ); + mChannelMapList.setLayoutOrientation( JList.VERTICAL ); + mChannelMapList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); + JScrollPane listScroller = new JScrollPane( mChannelMapList ); + + JScrollPane editorScroller = new JScrollPane( mChannelMapEditor ); + + JideSplitPane splitPane = new JideSplitPane(); + splitPane.setOrientation( JideSplitPane.HORIZONTAL_SPLIT ); + splitPane.add( listScroller ); + splitPane.add( editorScroller ); + + add( splitPane ); + } +} diff --git a/src/alias/id/AliasIDNode.java b/src/controller/channel/map/ChannelMapManagerFrame.java similarity index 56% rename from src/alias/id/AliasIDNode.java rename to src/controller/channel/map/ChannelMapManagerFrame.java index adaf3b36..c3c48628 100644 --- a/src/alias/id/AliasIDNode.java +++ b/src/controller/channel/map/ChannelMapManagerFrame.java @@ -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 @@ -15,22 +15,28 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package alias.id; +package controller.channel.map; -import playlist.PlaylistManager; -import controller.ConfigurableNode; +import javax.swing.JFrame; -public class AliasIDNode extends ConfigurableNode +import net.miginfocom.swing.MigLayout; + +public class ChannelMapManagerFrame extends JFrame { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public AliasIDNode( PlaylistManager playlistManager, AliasID id ) + public ChannelMapManagerFrame( ChannelMapModel channelMapModel ) { - super( playlistManager, id ); + init( new ChannelMapManager( channelMapModel ) ); + } + + private void init( ChannelMapManager channelMapManager ) + { + setTitle( "Channel Map Manager" ); + setSize( 800, 400 ); + setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); + setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) ); + add( channelMapManager ); + setLocationRelativeTo( null ); } - - public void save() - { - getPlaylistManager().save(); - } } diff --git a/src/controller/channel/map/ChannelMapModel.java b/src/controller/channel/map/ChannelMapModel.java index 50da7dfe..e0b486d4 100644 --- a/src/controller/channel/map/ChannelMapModel.java +++ b/src/controller/channel/map/ChannelMapModel.java @@ -1,171 +1,155 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ package controller.channel.map; -import javax.swing.table.AbstractTableModel; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import javax.swing.AbstractListModel; -public class ChannelMapModel extends AbstractTableModel +import controller.channel.map.ChannelMapEvent.Event; +import sample.Broadcaster; +import sample.Listener; + +public class ChannelMapModel extends AbstractListModel { - private static final long serialVersionUID = 1L; - private final static Logger mLog = - LoggerFactory.getLogger( ChannelMapModel.class ); + private static final long serialVersionUID = 1L; + + private List mChannelMaps = new ArrayList<>(); + private Broadcaster mEventBroadcaster = new Broadcaster<>(); - private static final int sSTART = 0; - private static final int sSTOP = 1; - private static final int sBASE = 2; - private static final int sSIZE = 3; + public ChannelMapModel() + { + } - protected int[] mColumnWidths = { 110, 110, 110, -1 }; + /** + * Returns an unmodifiable list of channel maps currently in the model + */ + public List getChannelMaps() + { + return Collections.unmodifiableList( mChannelMaps ); + } - protected String[] mHeaders = new String[] { "Begin", - "End", - "Base", - "Size" }; - - private ChannelMap mChannelMap; - - public ChannelMapModel( ChannelMap map ) + /** + * Returns the channel map with a matching name or null + */ + public ChannelMap getChannelMap( String name ) { - mChannelMap = map; - } - - public ChannelMap getChannelMap() - { - return mChannelMap; - } - - public void setChannelMap( ChannelMap map ) - { - mChannelMap = map; - - fireTableDataChanged(); - } - - public void addRange( ChannelRange range ) - { - mChannelMap.addRange( range ); - - int index = mChannelMap.getRanges().size() - 1; - - fireTableRowsInserted( index, index ); - } - - public void removeRange( int rangeIndex ) - { - if( rangeIndex < mChannelMap.getRanges().size() ) + for( ChannelMap channelMap: mChannelMaps ) { - mChannelMap.getRanges().remove( rangeIndex ); - } - - fireTableRowsDeleted( rangeIndex, rangeIndex ); - } - - public int[] getColumnWidths() - { - return mColumnWidths; - } - - public void setColumnWidths( int[] widths ) - { - if( widths.length != 4 ) - { - throw new IllegalArgumentException( "ChannelMapRangeModel - " - + "column widths array should have 5 elements" ); - } - else - { - mColumnWidths = widths; - } - } - - @Override - public int getRowCount() - { - return mChannelMap.getRanges().size(); - } - - @Override - public int getColumnCount() - { - return mHeaders.length; - } - - public String getColumnName( int column ) - { - return mHeaders[ column ]; - } - - @Override - public Object getValueAt( int rowIndex, int columnIndex ) - { - ChannelRange range = mChannelMap.getRanges().get( rowIndex ); - - switch( columnIndex ) - { - case sSTART: - return range.getFirstChannelNumber(); - case sSTOP: - return range.getLastChannelNumber(); - case sBASE: - return range.getBase(); - case sSIZE: - return range.getSize(); + if( channelMap.getName().equalsIgnoreCase( name ) ) + { + return channelMap; + } } return null; - } - - public boolean isCellEditable( int row, int column ) - { - return true; } - - public void setValueAt( Object value, int row, int column ) + + /** + * Adds a listener to receive notifications when channel map updates occur + */ + public void addListener( Listener listener ) { - try + mEventBroadcaster.addListener( listener ); + } + + /** + * Removes the channel map update notification listener + */ + public void removeListener( Listener listener ) + { + mEventBroadcaster.removeListener( listener ); + } + + /** + * Broadcasts a channel map change. + * + * Note: use the add/remove methods to add or remove channel maps from this + * model. When using those methods, an add or delete event will automatically + * be generated. + */ + public void broadcast( ChannelMapEvent event ) + { + if( event.getEvent() == ChannelMapEvent.Event.CHANGE || + event.getEvent() == ChannelMapEvent.Event.RENAME ) { - int parsedValue = Integer.parseInt( (String)value ); + int index = mChannelMaps.indexOf( event.getChannelMap() ); - ChannelRange range = mChannelMap.getRanges().get( row ); - - switch( column ) + if( index >= 0 ) { - case sSTART: - range.setFirstChannelNumber( parsedValue ); - break; - case sSTOP: - range.setLastChannelNumber( parsedValue ); - break; - case sBASE: - range.setBase( parsedValue ); - break; - case sSIZE: - range.setSize( parsedValue ); - break; + fireContentsChanged( this, index, index ); } } - catch( Exception e ) + + mEventBroadcaster.broadcast( event ); + } + + /** + * Adds a list of channel maps to this model + */ + public void addChannelMaps( List channelMaps ) + { + for( ChannelMap channelMap: channelMaps ) { - mLog.error( "ChannelMapModel - couldn't parse integer value " - + "for [" + value + "]", e ); + addChannelMap( channelMap ); } } + + /** + * Adds the channel map to this model + */ + public void addChannelMap( ChannelMap channelMap ) + { + if( !mChannelMaps.contains( channelMap ) ) + { + mChannelMaps.add( channelMap ); + + int index = mChannelMaps.indexOf( channelMap ); + + fireIntervalAdded( this, index, index ); + + broadcast( new ChannelMapEvent( channelMap, Event.ADD ) ); + } + + } + + /** + * Removes the channel map from this model + */ + public void removeChannelMap( ChannelMap channelMap ) + { + if( mChannelMaps.contains( channelMap ) ) + { + int index = mChannelMaps.indexOf( channelMap ); + + mChannelMaps.remove( channelMap ); + + fireIntervalRemoved( this, index, index ); + + broadcast( new ChannelMapEvent( channelMap, Event.DELETE ) ); + } + } + + /** + * Size/Number of channel maps in this model + */ + @Override + public int getSize() + { + return mChannelMaps.size(); + } + + /** + * Returns the channel map at the specified index + */ + @Override + public ChannelMap getElementAt( int index ) + { + if( index <= mChannelMaps.size() ) + { + return mChannelMaps.get( index ); + } + + return null; + } } diff --git a/src/controller/channel/map/ChannelMapNode.java b/src/controller/channel/map/ChannelMapNode.java deleted file mode 100644 index ef6c6bfe..00000000 --- a/src/controller/channel/map/ChannelMapNode.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.channel.map; - - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import controller.ConfigurableNode; - -public class ChannelMapNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - public ChannelMapNode( PlaylistManager playlistManager, ChannelMap ChannelMap ) - { - super( playlistManager, ChannelMap ); - } - - public void init() - { - //For consistency, but not used - } - - @Override - public String getIconPath() - { - return "images/ChannelMap.png"; - } - - @Override - public JPanel getEditor() - { - return new ChannelMapEditor( this ); - } - - public ChannelMap getChannelMap() - { - return (ChannelMap)getUserObject(); - } - - public String toString() - { - return getChannelMap().getName(); - } - - public void delete() - { - ChannelMapListNode parent = (ChannelMapListNode)getParent(); - - parent.getChannelMapList().removeChannelMap( getChannelMap() ); - - save(); - - getModel().removeNodeFromParent( ChannelMapNode.this ); - - /* Show the first child, if one exists so that we don't have a - * collapsed list */ - if( parent.getChildCount() > 0 ) - { - ((ConfigurableNode)parent.getFirstChild()).show(); - } - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - delete(); - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/controller/channel/map/ChannelRange.java b/src/controller/channel/map/ChannelRange.java index a9814239..a57ee199 100644 --- a/src/controller/channel/map/ChannelRange.java +++ b/src/controller/channel/map/ChannelRange.java @@ -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 diff --git a/src/controller/channel/map/ChannelRangeModel.java b/src/controller/channel/map/ChannelRangeModel.java new file mode 100644 index 00000000..9e13d345 --- /dev/null +++ b/src/controller/channel/map/ChannelRangeModel.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * 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 + ******************************************************************************/ +package controller.channel.map; + +import javax.swing.table.AbstractTableModel; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ChannelRangeModel extends AbstractTableModel +{ + private static final long serialVersionUID = 1L; + private final static Logger mLog = + LoggerFactory.getLogger( ChannelRangeModel.class ); + + private static final int START = 0; + private static final int STOP = 1; + private static final int BASE = 2; + private static final int SIZE = 3; + + protected int[] mColumnWidths = { 110, 110, 110, -1 }; + + protected String[] mHeaders = new String[] { "Begin", + "End", + "Base", + "Size" }; + + private ChannelMap mChannelMap; + + public ChannelRangeModel() + { + } + + public void setChannelMap( ChannelMap channelMap ) + { + mChannelMap = channelMap; + fireTableDataChanged(); + } + + public void addRange( ChannelRange range ) + { + if( mChannelMap != null ) + { + mChannelMap.addRange( range ); + + int index = mChannelMap.getRanges().size() - 1; + + fireTableRowsInserted( index, index ); + } + } + + public void removeRange( int rangeIndex ) + { + if( mChannelMap != null ) + { + if( rangeIndex < mChannelMap.getRanges().size() ) + { + mChannelMap.getRanges().remove( rangeIndex ); + } + + fireTableRowsDeleted( rangeIndex, rangeIndex ); + } + } + + public int[] getColumnWidths() + { + return mColumnWidths; + } + + public void setColumnWidths( int[] widths ) + { + if( widths.length != 4 ) + { + throw new IllegalArgumentException( "ChannelMapRangeModel - " + + "column widths array should have 5 elements" ); + } + else + { + mColumnWidths = widths; + } + } + + @Override + public int getRowCount() + { + if( mChannelMap != null ) + { + return mChannelMap.getRanges().size(); + } + + return 0; + } + + @Override + public int getColumnCount() + { + return mHeaders.length; + } + + public String getColumnName( int column ) + { + return mHeaders[ column ]; + } + + @Override + public Object getValueAt( int rowIndex, int columnIndex ) + { + if( mChannelMap != null ) + { + ChannelRange range = mChannelMap.getRanges().get( rowIndex ); + + switch( columnIndex ) + { + case START: + return range.getFirstChannelNumber(); + case STOP: + return range.getLastChannelNumber(); + case BASE: + return range.getBase(); + case SIZE: + return range.getSize(); + } + } + + return null; + } + + public boolean isCellEditable( int row, int column ) + { + return mChannelMap != null; + } + + public void setValueAt( Object value, int row, int column ) + { + if( mChannelMap != null ) + { + try + { + int parsedValue = Integer.parseInt( (String)value ); + + ChannelRange range = mChannelMap.getRanges().get( row ); + + switch( column ) + { + case START: + range.setFirstChannelNumber( parsedValue ); + break; + case STOP: + range.setLastChannelNumber( parsedValue ); + break; + case BASE: + range.setBase( parsedValue ); + break; + case SIZE: + range.setSize( parsedValue ); + break; + } + } + catch( Exception e ) + { + mLog.error( "ChannelMapModel - couldn't parse integer value " + + "for [" + value + "]", e ); + } + } + } +} diff --git a/src/controller/site/SiteEditor.java b/src/controller/site/SiteEditor.java deleted file mode 100644 index 6008a78c..00000000 --- a/src/controller/site/SiteEditor.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.site; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.tree.TreePath; - -import net.miginfocom.swing.MigLayout; - -public class SiteEditor extends JPanel implements ActionListener -{ - private static final long serialVersionUID = 1L; - private SiteNode mSiteNode; - - private JLabel mLabelName; - private JTextField mTextSite; - - public SiteEditor( SiteNode site ) - { - mSiteNode = site; - initGUI(); - } - - private void initGUI() - { - setLayout( new MigLayout() ); - - setBorder( BorderFactory.createTitledBorder( "Site" ) ); - - mLabelName = new JLabel( "Name:" ); - add( mLabelName, "align right" ); - - mTextSite = new JTextField( mSiteNode.getSite().getName() ); - add( mTextSite, "grow, wrap" ); - - JButton btnSave = new JButton( "Save" ); - btnSave.addActionListener( SiteEditor.this ); - add( btnSave ); - - JButton btnReset = new JButton( "Reset" ); - btnReset.addActionListener( SiteEditor.this ); - add( btnReset, "wrap" ); - } - - @Override - public void actionPerformed( ActionEvent e ) - { - String command = e.getActionCommand(); - - if( command.contentEquals( "Save" ) ) - { - boolean expanded = mSiteNode.getModel().getTree() - .isExpanded( new TreePath( mSiteNode ) ); - - String name = mTextSite.getText(); - - if( name != null ) - { - mSiteNode.getSite().setName( name ); - mSiteNode.save(); - mSiteNode.show(); - - if( expanded ) - { - mSiteNode.getModel().getTree().expandPath( new TreePath( mSiteNode ) ); - } - } - else - { - JOptionPane.showMessageDialog( SiteEditor.this, "Please enter a site name" ); - } - } - else if( command.contentEquals( "Reset" ) ) - { - mTextSite.setText( mSiteNode.getSite().getName() ); - } - } -} diff --git a/src/controller/site/SiteNode.java b/src/controller/site/SiteNode.java deleted file mode 100644 index 65ad140f..00000000 --- a/src/controller/site/SiteNode.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.site; - - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Enumeration; - -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; -import javax.swing.tree.DefaultMutableTreeNode; - -import playlist.PlaylistManager; -import source.SourceManager; -import controller.ConfigurableNode; -import controller.channel.Channel; -import controller.channel.ChannelModel; -import controller.channel.ChannelNode; -import controller.channel.ChannelProcessingManager; -import controller.system.System; -import controller.system.SystemNode; - -public class SiteNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private ChannelModel mChannelModel; - private ChannelProcessingManager mChannelProcessingManager; - private SourceManager mSourceManager; - - public SiteNode( Site site, - ChannelModel channelModel, - ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, - SourceManager sourceManager ) - { - super( playlistManager, site ); - - mChannelModel = channelModel; - mChannelProcessingManager = channelProcessingManager; - mSourceManager = sourceManager; - } - - public void init() - { - for( Channel channel: getSite().getChannel() ) - { - ChannelNode node = new ChannelNode( channel, mChannelModel, - mChannelProcessingManager, getPlaylistManager(), mSourceManager ); - - getModel().insertNodeInto( node, SiteNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - public String getIconPath() - { - return "images/site.png"; - } - - @Override - public Color getBackgroundColor() - { - @SuppressWarnings( "unchecked" ) - Enumeration nodes = children(); - - while( nodes.hasMoreElements() ) - { - ChannelNode child = (ChannelNode)nodes.nextElement(); - - if( child.getBackgroundColor() != null ) - { - return Color.CYAN; - } - } - - return null; - } - - @Override - public JPanel getEditor() - { - return new SiteEditor( this ); - } - - public Site getSite() - { - return (Site)getUserObject(); - } - - public String toString() - { - return getSite().getName(); - } - - public void delete() - { - for( int x = 0; x < getChildCount(); x++ ) - { - ((ChannelNode)getChildAt( x )).delete(); - } - - ((SystemNode)getParent()).getSystem().removeSite( getSite() ); - - save(); - - getModel().removeNodeFromParent( SiteNode.this ); - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addChannelItem = new JMenuItem( "Add Channel" ); - addChannelItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - System system = ((SystemNode)getParent()).getSystem(); - - Channel channel = new Channel(); - channel.setSystem( system.getName() ); - channel.setSite( getSite().getName() ); - - getSite().addChannel( channel ); - - ChannelNode node = new ChannelNode( channel, mChannelModel, - mChannelProcessingManager, getPlaylistManager(), mSourceManager ); - - getModel().addNode( node, - SiteNode.this, - SiteNode.this.getChildCount() ); - - sort(); - save(); - node.show(); - } - } ); - - retVal.add( addChannelItem ); - - retVal.add( new JSeparator() ); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - delete(); - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/controller/system/SystemEditor.java b/src/controller/system/SystemEditor.java deleted file mode 100644 index f9c4e8b4..00000000 --- a/src/controller/system/SystemEditor.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.system; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.tree.TreePath; - -import net.miginfocom.swing.MigLayout; - -public class SystemEditor extends JPanel implements ActionListener -{ - private static final long serialVersionUID = 1L; - private SystemNode mSystemNode; - - private JLabel mLabelSystem; - private JTextField mTextSystem; - - public SystemEditor( SystemNode system ) - { - mSystemNode = system; - initGUI(); - } - - private void initGUI() - { - setLayout( new MigLayout() ); - - setBorder( BorderFactory.createTitledBorder( "System" ) ); - - mLabelSystem = new JLabel( "Name:" ); - add( mLabelSystem, "align right" ); - - mTextSystem = new JTextField( mSystemNode.getSystem().getName() ); - add( mTextSystem, "grow, wrap" ); - - JButton btnSave = new JButton( "Save" ); - btnSave.addActionListener( SystemEditor.this ); - add( btnSave ); - - JButton btnReset = new JButton( "Reset" ); - btnReset.addActionListener( SystemEditor.this ); - add( btnReset, "wrap" ); - } - - @Override - public void actionPerformed( ActionEvent e ) - { - String command = e.getActionCommand(); - - if( command.contentEquals( "Save" ) ) - { - boolean expanded = mSystemNode.getModel().getTree() - .isExpanded( new TreePath( mSystemNode ) ); - - String name = mTextSystem.getText(); - - if( name != null ) - { - mSystemNode.getSystem().setName( name ); - mSystemNode.save(); - mSystemNode.show(); - - if( expanded ) - { - mSystemNode.getModel().getTree().expandPath( new TreePath( mSystemNode ) ); - } - } - else - { - JOptionPane.showMessageDialog( SystemEditor.this, "Please enter a system name" ); - } - } - else if( command.contentEquals( "Reset" ) ) - { - mTextSystem.setText( mSystemNode.getSystem().getName() ); - } - } -} diff --git a/src/controller/system/SystemListNode.java b/src/controller/system/SystemListNode.java deleted file mode 100644 index d0e5b3a9..00000000 --- a/src/controller/system/SystemListNode.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.system; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; - -import playlist.PlaylistManager; -import source.SourceManager; -import controller.ConfigurableNode; -import controller.channel.ChannelModel; -import controller.channel.ChannelProcessingManager; - -public class SystemListNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private ChannelModel mChannelModel; - private ChannelProcessingManager mChannelProcessingManager; - private SourceManager mSourceManager; - - public SystemListNode( SystemList list, - ChannelModel channelModel, - ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, - SourceManager sourceManager ) - { - super( playlistManager, list ); - - mChannelModel = channelModel; - mChannelProcessingManager = channelProcessingManager; - mSourceManager = sourceManager; - } - - public SystemList getSystemList() - { - return (SystemList)getUserObject(); - } - - public void init() - { - for( System system: getSystemList().getSystem() ) - { - SystemNode node = new SystemNode( system, mChannelModel, - mChannelProcessingManager, getPlaylistManager(), mSourceManager ); - - getModel().addNode( node, SystemListNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - public String toString() - { - return "Systems [" + this.getChildCount() + "]"; - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSystemItem = new JMenuItem( "Add System" ); - addSystemItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - System system = new System(); - - getSystemList().addSystem( system ); - - getModel().addNode( new SystemNode( system, mChannelModel, - mChannelProcessingManager, getPlaylistManager(), mSourceManager ), - SystemListNode.this, SystemListNode.this.getChildCount() ); - } - } ); - - retVal.add( addSystemItem ); - - return retVal; - } -} diff --git a/src/controller/system/SystemNode.java b/src/controller/system/SystemNode.java deleted file mode 100644 index 39f28214..00000000 --- a/src/controller/system/SystemNode.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * SDR Trunk - * Copyright (C) 2014 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 - ******************************************************************************/ -package controller.system; - - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Enumeration; - -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; -import javax.swing.tree.DefaultMutableTreeNode; - -import playlist.PlaylistManager; -import source.SourceManager; -import controller.ConfigurableNode; -import controller.channel.ChannelModel; -import controller.channel.ChannelProcessingManager; -import controller.site.Site; -import controller.site.SiteNode; - -public class SystemNode extends ConfigurableNode -{ - private static final long serialVersionUID = 1L; - - private ChannelModel mChannelModel; - private ChannelProcessingManager mChannelProcessingManager; - private SourceManager mSourceManager; - - public SystemNode( System system, - ChannelModel channelModel, - ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, - SourceManager sourceManager ) - { - super( playlistManager, system ); - - mChannelModel = channelModel; - mChannelProcessingManager = channelProcessingManager; - mSourceManager = sourceManager; - } - - public void init() - { - for( Site site: getSystem().getSite() ) - { - SiteNode node = new SiteNode( site, mChannelModel, - mChannelProcessingManager, getPlaylistManager(), mSourceManager ); - - getModel().insertNodeInto( node, SystemNode.this, getChildCount() ); - - node.init(); - } - - sort(); - } - - @Override - public String getIconPath() - { - return "images/system.png"; - } - - @Override - public Color getBackgroundColor() - { - @SuppressWarnings( "unchecked" ) - Enumeration nodes = children(); - - while( nodes.hasMoreElements() ) - { - SiteNode child = (SiteNode)nodes.nextElement(); - - if( child.getBackgroundColor() != null ) - { - return Color.CYAN; - } - } - - return null; - } - - @Override - public JPanel getEditor() - { - return new SystemEditor( this ); - } - - public System getSystem() - { - return (System)getUserObject(); - } - - public String toString() - { - return getSystem().getName(); - } - - public void delete() - { - for( int x = 0; x < getChildCount(); x++ ) - { - ((SiteNode)getChildAt( x )).delete(); - } - - SystemListNode parent = (SystemListNode)getParent(); - - parent.getSystemList().removeSystem( getSystem() ); - - save(); - - getModel().removeNodeFromParent( SystemNode.this ); - - /* Show the first child, if one exists so that we don't have a - * collapsed list */ - if( parent.getChildCount() > 0 ) - { - ((ConfigurableNode)parent.getFirstChild()).show(); - } - } - - public JPopupMenu getContextMenu() - { - JPopupMenu retVal = new JPopupMenu(); - - JMenuItem addSiteItem = new JMenuItem( "Add Site" ); - addSiteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - Site site = new Site(); - getSystem().addSite( site ); - - SiteNode node = new SiteNode( site, mChannelModel, - mChannelProcessingManager, getPlaylistManager(), mSourceManager ); - - getModel().addNode( node, - SystemNode.this, - SystemNode.this.getChildCount() ); - - sort(); - - node.show(); - } - } ); - - retVal.add( addSiteItem ); - - retVal.add( new JSeparator() ); - - JMenuItem deleteItem = new JMenuItem( "Delete" ); - deleteItem.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - delete(); - } - } ); - - retVal.add( deleteItem ); - - return retVal; - } -} diff --git a/src/gui/SDRTrunk.java b/src/gui/SDRTrunk.java index 577c6593..505f0dd9 100644 --- a/src/gui/SDRTrunk.java +++ b/src/gui/SDRTrunk.java @@ -74,6 +74,7 @@ import controller.channel.ChannelEventListener; import controller.channel.ChannelModel; import controller.channel.ChannelProcessingManager; import controller.channel.ChannelSelectionManager; +import controller.channel.map.ChannelMapModel; public class SDRTrunk { @@ -117,26 +118,27 @@ public class SDRTrunk ThreadPoolManager threadPoolManager = new ThreadPoolManager(); - SourceManager sourceManager = new SourceManager( mSettingsManager, threadPoolManager ); - - ChannelModel channelModel = new ChannelModel(); - AliasModel aliasModel = new AliasModel(); - PlaylistManager playlistManager = new PlaylistManager( threadPoolManager, - aliasModel, channelModel ); - - RecorderManager recorderManager = new RecorderManager( threadPoolManager ); + ChannelModel channelModel = new ChannelModel(); + + ChannelMapModel channelMapModel = new ChannelMapModel(); EventLogManager eventLogManager = new EventLogManager(); + + RecorderManager recorderManager = new RecorderManager( threadPoolManager ); + SourceManager sourceManager = new SourceManager( mSettingsManager, + threadPoolManager ); + ChannelProcessingManager channelProcessingManager = - new ChannelProcessingManager( channelModel, eventLogManager, - playlistManager, recorderManager, sourceManager, threadPoolManager ); - channelModel.addListener( channelProcessingManager ); - + new ChannelProcessingManager( channelModel, channelMapModel, + aliasModel, eventLogManager, recorderManager, + sourceManager, threadPoolManager ); channelProcessingManager.addAudioPacketListener( recorderManager ); + channelModel.addListener( channelProcessingManager ); + ChannelSelectionManager channelSelectionManager = new ChannelSelectionManager( channelModel ); channelModel.addListener( channelSelectionManager ); @@ -152,27 +154,22 @@ public class SDRTrunk ConfigurationControllerModel configurationControllerModel = new ConfigurationControllerModel( channelModel, channelProcessingManager, - playlistManager, mSettingsManager, sourceManager ); + mSettingsManager, sourceManager ); mControllerPanel = new ControllerPanel( audioManager, configurationControllerModel, - aliasModel, channelModel, channelProcessingManager, mapService, playlistManager, - mSettingsManager, sourceManager ); + aliasModel, channelModel, channelMapModel, channelProcessingManager, + mapService, mSettingsManager, sourceManager ); mSpectralPanel = new SpectralDisplayPanel( configurationControllerModel, - channelModel, channelProcessingManager, playlistManager, mSettingsManager ); + channelModel, channelProcessingManager, mSettingsManager ); mTitle = getTitle(); - //TODO: move this to the end once we add the alias model, otherwise the - //configuration tree won't load correctly - //Initialize the playlist manager to load the saved playlist + PlaylistManager playlistManager = new PlaylistManager( threadPoolManager, + aliasModel, channelModel, channelMapModel ); + playlistManager.init(); - mLog.info( "starting main application gui" ); - - //Initialize the GUI - initGUI(); - if( mLogChannelAndMemoryUsage ) { Runnable cml = new ChannelMemoryLogger(); @@ -181,6 +178,11 @@ public class SDRTrunk ThreadType.DECODER, cml, 5, TimeUnit.SECONDS ); } + mLog.info( "starting main application gui" ); + + //Initialize the GUI + initGUI(); + //Start the gui EventQueue.invokeLater( new Runnable() { diff --git a/src/instrument/gui/DecoderSelectionFrame.java b/src/instrument/gui/DecoderSelectionFrame.java index d96020b1..94f1eb54 100644 --- a/src/instrument/gui/DecoderSelectionFrame.java +++ b/src/instrument/gui/DecoderSelectionFrame.java @@ -16,6 +16,7 @@ import source.IControllableFileSource; import alias.AliasModel; import controller.ThreadPoolManager; import controller.channel.ChannelModel; +import controller.channel.map.ChannelMapModel; public class DecoderSelectionFrame extends JInternalFrame { @@ -32,10 +33,11 @@ public class DecoderSelectionFrame extends JInternalFrame { AliasModel aliasModel = new AliasModel(); ChannelModel channelModel = new ChannelModel(); + ChannelMapModel channelMapModel = new ChannelMapModel(); ThreadPoolManager tpm = new ThreadPoolManager(); - mPlaylistManager = new PlaylistManager( tpm, aliasModel, channelModel ); + mPlaylistManager = new PlaylistManager( tpm, aliasModel, channelModel, channelMapModel ); mDesktop = desktop; mSource = source; diff --git a/src/instrument/gui/DecoderViewFrame.java b/src/instrument/gui/DecoderViewFrame.java index a2afb439..09ea4383 100644 --- a/src/instrument/gui/DecoderViewFrame.java +++ b/src/instrument/gui/DecoderViewFrame.java @@ -58,6 +58,7 @@ import message.Message; import module.Module; import module.decode.DecoderFactory; import module.decode.config.DecodeConfiguration; +import module.log.EventLogManager; import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; @@ -67,10 +68,12 @@ import playlist.PlaylistManager; import sample.Listener; import source.IControllableFileSource; import source.Source; +import alias.AliasModel; import controller.ThreadPoolManager; import controller.channel.Channel; import controller.channel.ChannelModel; import controller.channel.ChannelProcessingManager; +import controller.channel.map.ChannelMapModel; public class DecoderViewFrame extends JInternalFrame implements Listener @@ -97,12 +100,14 @@ public class DecoderViewFrame extends JInternalFrame mProcessingChain = new InstrumentableProcessingChain(); ChannelModel channelModel = new ChannelModel(); + ChannelMapModel channelMapModel = new ChannelMapModel(); + ChannelProcessingManager channelProcessingManager = - new ChannelProcessingManager( channelModel, null, - playlistManager, null, null, new ThreadPoolManager() ); + new ChannelProcessingManager( channelModel, channelMapModel, + new AliasModel(), new EventLogManager(), null, null, new ThreadPoolManager() ); List modules = DecoderFactory.getModules( channelModel, - channelProcessingManager, playlistManager, channel ); + channelMapModel, channelProcessingManager, new AliasModel(), channel ); mProcessingChain.addModules( modules ); diff --git a/src/module/decode/DecodeComponentEditor.java b/src/module/decode/DecodeComponentEditor.java index bd631d3b..5d460db1 100644 --- a/src/module/decode/DecodeComponentEditor.java +++ b/src/module/decode/DecodeComponentEditor.java @@ -31,10 +31,10 @@ import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import playlist.PlaylistManager; import controller.channel.Channel; import controller.channel.ChannelConfigurationEditor; import controller.channel.ConfigurationValidationException; +import controller.channel.map.ChannelMapModel; public class DecodeComponentEditor extends ChannelConfigurationEditor { @@ -42,17 +42,14 @@ public class DecodeComponentEditor extends ChannelConfigurationEditor private static final long serialVersionUID = 1L; - private PlaylistManager mPlaylistManager; private JComboBox mComboDecoders; private DecodeEditor mEditor; private Channel mChannel; - public DecodeComponentEditor( PlaylistManager playlistManager ) + public DecodeComponentEditor( final ChannelMapModel channelMapModel ) { - mPlaylistManager = playlistManager; - setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][grow]" ) ); mComboDecoders = new JComboBox(); @@ -96,8 +93,7 @@ public class DecodeComponentEditor extends ChannelConfigurationEditor } //Change to the new one - mEditor = DecoderFactory.getEditorPanel( config, - mChannel, mPlaylistManager ); + mEditor = DecoderFactory.getEditorPanel( config, channelMapModel ); add( mEditor, "span 2,center" ); diff --git a/src/module/decode/DecoderFactory.java b/src/module/decode/DecoderFactory.java index 447e7865..c9304b62 100644 --- a/src/module/decode/DecoderFactory.java +++ b/src/module/decode/DecoderFactory.java @@ -97,12 +97,14 @@ import record.config.RecordConfiguration; import settings.SettingsManager; import util.TimeStamp; import alias.AliasList; +import alias.AliasModel; import audio.AudioModule; import controller.channel.Channel; import controller.channel.Channel.ChannelType; import controller.channel.ChannelModel; import controller.channel.ChannelProcessingManager; import controller.channel.map.ChannelMap; +import controller.channel.map.ChannelMapModel; import filter.AllPassFilter; import filter.FilterSet; import filter.IFilter; @@ -123,17 +125,17 @@ public class DecoderFactory * @return list of configured decoders */ public static List getModules( ChannelModel channelModel, + ChannelMapModel channelMapModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, + AliasModel aliasModel, Channel channel ) { /* Get the optional alias list for the decode modules to use */ - AliasList aliasList = playlistManager.getPlayist() - .getAliasDirectory().getAliasList( channel.getAliasListName() ); + AliasList aliasList = aliasModel.getAliasList( channel.getAliasListName() ); - List modules = getPrimaryModules( channelModel, channelProcessingManager, - playlistManager, aliasList, channel ); + List modules = getPrimaryModules( channelModel, channelMapModel, + channelProcessingManager, aliasList, channel ); modules.addAll( getAuxiliaryDecoders( channel.getAuxDecodeConfiguration(), aliasList ) ); @@ -144,8 +146,8 @@ public class DecoderFactory * Constructs a primary decoder as specified in the decode configuration */ public static List getPrimaryModules( ChannelModel channelModel, + ChannelMapModel channelMapModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, AliasList aliasList, Channel channel ) { @@ -198,8 +200,8 @@ public class DecoderFactory case MPT1327: DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327)decodeConfig; - ChannelMap channelMap = playlistManager.getPlayist() - .getChannelMapList().getChannelMap( mptConfig.getChannelMapName() ); + ChannelMap channelMap = channelMapModel + .getChannelMap( mptConfig.getChannelMapName() ); Sync sync = mptConfig.getSync(); @@ -432,7 +434,7 @@ public class DecoderFactory } public static DecodeEditor getEditorPanel( DecodeConfiguration config, - Channel channel, PlaylistManager playlistManager ) + ChannelMapModel channelMapModel ) { DecodeEditor configuredPanel; @@ -449,7 +451,7 @@ public class DecoderFactory break; case MPT1327: configuredPanel = new MPT1327ConfigEditor( config, - channel, playlistManager ); + channelMapModel ); break; case PASSPORT: configuredPanel = new PassportEditor( config ); diff --git a/src/module/decode/mpt1327/MPT1327ConfigEditor.java b/src/module/decode/mpt1327/MPT1327ConfigEditor.java index fa036c96..586a605d 100644 --- a/src/module/decode/mpt1327/MPT1327ConfigEditor.java +++ b/src/module/decode/mpt1327/MPT1327ConfigEditor.java @@ -17,10 +17,13 @@ ******************************************************************************/ package module.decode.mpt1327; -import java.util.ArrayList; +import java.awt.EventQueue; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.List; import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JSlider; @@ -30,9 +33,9 @@ import javax.swing.event.ChangeListener; import module.decode.DecodeEditor; import module.decode.config.DecodeConfiguration; import module.decode.mpt1327.MPT1327Decoder.Sync; -import playlist.PlaylistManager; -import controller.channel.Channel; import controller.channel.map.ChannelMap; +import controller.channel.map.ChannelMapManagerFrame; +import controller.channel.map.ChannelMapModel; public class MPT1327ConfigEditor extends DecodeEditor { @@ -44,17 +47,14 @@ public class MPT1327ConfigEditor extends DecodeEditor private JSlider mCallTimeout; private JLabel mTrafficChannelPoolSizeLabel; private JSlider mTrafficChannelPoolSize; - private Channel mChannel; - private PlaylistManager mPlaylistManager; + private ChannelMapModel mChannelMapModel; public MPT1327ConfigEditor( DecodeConfiguration config, - Channel channel, - PlaylistManager playlistManager ) + ChannelMapModel channelMapModel ) { super( config ); - mChannel = channel; - mPlaylistManager = playlistManager; + mChannelMapModel = channelMapModel; initGUI(); } @@ -69,10 +69,7 @@ public class MPT1327ConfigEditor extends DecodeEditor /** * ComboBox: Alias Lists */ - List maps = ( mPlaylistManager == null ? - new ArrayList() : mPlaylistManager.getPlayist() - .getChannelMapList().getChannelMap() ); - + List maps = mChannelMapModel.getChannelMaps(); ChannelMap[] mapArray = maps.toArray( new ChannelMap[ maps.size() ] ); mComboChannelMaps = new JComboBox(); @@ -82,6 +79,27 @@ public class MPT1327ConfigEditor extends DecodeEditor add( new JLabel( "Channel Map:" ) ); add( mComboChannelMaps, "wrap" ); + JButton channelMapManager = new JButton( "Channel Map Manager ..." ); + channelMapManager.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + final ChannelMapManagerFrame manager = + new ChannelMapManagerFrame( mChannelMapModel ); + + EventQueue.invokeLater( new Runnable() + { + @Override + public void run() + { + manager.setVisible( true ); + } + } ); + } + } ); + add( channelMapManager, "wrap" ); + mComboSync = new JComboBox(); mComboSync.setModel( new DefaultComboBoxModel( Sync.values() ) ); diff --git a/src/module/decode/p25/P25Decoder.java b/src/module/decode/p25/P25Decoder.java index 5c879e5e..184c6f88 100644 --- a/src/module/decode/p25/P25Decoder.java +++ b/src/module/decode/p25/P25Decoder.java @@ -1,9 +1,9 @@ package module.decode.p25; +import alias.AliasList; import instrument.Instrumentable; import module.decode.Decoder; import module.decode.DecoderType; -import alias.AliasList; public abstract class P25Decoder extends Decoder implements Instrumentable { diff --git a/src/module/decode/p25/P25MessageProcessor.java b/src/module/decode/p25/P25MessageProcessor.java index 0ef49de5..d34437bd 100644 --- a/src/module/decode/p25/P25MessageProcessor.java +++ b/src/module/decode/p25/P25MessageProcessor.java @@ -10,8 +10,8 @@ import module.decode.p25.message.ldu.LDUMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import sample.Listener; import alias.AliasList; +import sample.Listener; public class P25MessageProcessor implements Listener { diff --git a/src/module/decode/p25/P25_C4FMDecoder.java b/src/module/decode/p25/P25_C4FMDecoder.java index c9f8ba7f..650c0cc2 100644 --- a/src/module/decode/p25/P25_C4FMDecoder.java +++ b/src/module/decode/p25/P25_C4FMDecoder.java @@ -30,13 +30,13 @@ import java.util.concurrent.ScheduledExecutorService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import alias.AliasList; import sample.Listener; import sample.real.IFilteredRealBufferListener; import sample.real.RealBuffer; import source.tuner.frequency.FrequencyChangeEvent; import source.tuner.frequency.IFrequencyChangeListener; import source.tuner.frequency.IFrequencyChangeProvider; -import alias.AliasList; import dsp.filter.FilterFactory; import dsp.filter.Window.WindowType; import dsp.filter.fir.real.RealFIRFilter_RB_RB; diff --git a/src/module/decode/p25/P25_LSMDecoder.java b/src/module/decode/p25/P25_LSMDecoder.java index b6e64bf3..011ff83d 100644 --- a/src/module/decode/p25/P25_LSMDecoder.java +++ b/src/module/decode/p25/P25_LSMDecoder.java @@ -31,11 +31,11 @@ import java.util.concurrent.ScheduledExecutorService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import alias.AliasList; import sample.Listener; import sample.complex.ComplexBuffer; import sample.complex.ComplexBufferToStreamConverter; import sample.complex.IComplexBufferListener; -import alias.AliasList; import dsp.filter.FilterFactory; import dsp.filter.Window.WindowType; import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB; diff --git a/src/module/decode/state/ChannelList.java b/src/module/decode/state/ChannelList.java index fc333914..3c781462 100644 --- a/src/module/decode/state/ChannelList.java +++ b/src/module/decode/state/ChannelList.java @@ -34,7 +34,6 @@ import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import playlist.PlaylistManager; import settings.ColorSetting.ColorSettingName; import settings.ColorSettingMenuItem; import settings.ColorSettingResetMenuItem; @@ -60,17 +59,14 @@ public class ChannelList extends JPanel implements ChannelEventListener private ChannelModel mChannelModel; private ChannelProcessingManager mChannelProcessingManager; - private PlaylistManager mPlaylistManager; private SettingsManager mSettingsManager; public ChannelList( ChannelModel channelModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, SettingsManager settingsManager ) { mChannelModel = channelModel; mChannelProcessingManager = channelProcessingManager; - mPlaylistManager = playlistManager; mSettingsManager = settingsManager; init(); @@ -105,7 +101,7 @@ public class ChannelList extends JPanel implements ChannelEventListener if( !mDisplayedPanels.containsKey( channel ) ) { ChannelPanel channelPanel = new ChannelPanel( mChannelModel, - mChannelProcessingManager, mPlaylistManager, mSettingsManager, channel ); + mChannelProcessingManager, mSettingsManager, channel ); add( channelPanel, "wrap" ); diff --git a/src/module/decode/state/ChannelPanel.java b/src/module/decode/state/ChannelPanel.java index 5dee9814..dd51716b 100644 --- a/src/module/decode/state/ChannelPanel.java +++ b/src/module/decode/state/ChannelPanel.java @@ -76,7 +76,6 @@ public class ChannelPanel extends JPanel private JLabel mSiteLabel; private JLabel mChannelLabel; - private PlaylistManager mPlaylistManager; protected SettingsManager mSettingsManager; private Channel mChannel; @@ -93,13 +92,11 @@ public class ChannelPanel extends JPanel */ public ChannelPanel( ChannelModel channelModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, SettingsManager settingsManager, Channel channel ) { mChannelModel = channelModel; mChannelProcessingManager = channelProcessingManager; - mPlaylistManager = playlistManager; mSettingsManager = settingsManager; mChannel = channel; @@ -198,8 +195,6 @@ public class ChannelPanel extends JPanel mChannelProcessingManager = null; - mPlaylistManager = null; - mSettingsManager.removeListener( this ); mSettingsManager = null; @@ -434,7 +429,7 @@ public class ChannelPanel extends JPanel public JMenu getContextMenu() { return ChannelUtils.getContextMenu( mChannelModel, mChannelProcessingManager, - mPlaylistManager, mChannel, ChannelPanel.this ); + mChannel, ChannelPanel.this ); } @Override diff --git a/src/playlist/PlaylistManager.java b/src/playlist/PlaylistManager.java index 86e447a7..df075a70 100644 --- a/src/playlist/PlaylistManager.java +++ b/src/playlist/PlaylistManager.java @@ -36,34 +36,29 @@ import javax.xml.bind.Unmarshaller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import playlist.version1.PlaylistConverterV1ToV2; import properties.SystemProperties; import sample.Listener; -import alias.Alias; -import alias.AliasDirectory; import alias.AliasEvent; -import alias.AliasList; import alias.AliasModel; -import alias.Group; import controller.ThreadPoolManager; -import controller.channel.Channel; import controller.channel.Channel.ChannelType; import controller.channel.ChannelEvent; import controller.channel.ChannelEventListener; import controller.channel.ChannelModel; -import controller.site.Site; -import controller.system.SystemList; +import controller.channel.map.ChannelMapEvent; +import controller.channel.map.ChannelMapModel; -public class PlaylistManager implements ChannelEventListener, Listener +public class PlaylistManager implements ChannelEventListener { private final static Logger mLog = LoggerFactory.getLogger( PlaylistManager.class ); - private Playlist mPlaylist = new Playlist(); - private ThreadPoolManager mThreadPoolManager; private AliasModel mAliasModel; private ChannelModel mChannelModel; - + private ChannelMapModel mChannelMapModel; + private Path mCurrentPlaylistPath; private AtomicBoolean mPlaylistSavePending = new AtomicBoolean(); private boolean mPlaylistLoading = false; @@ -79,37 +74,35 @@ public class PlaylistManager implements ChannelEventListener, Listener() + { + @Override + public void receive( AliasEvent t ) + { + schedulePlaylistSave(); + } + } ); + + mChannelMapModel.addListener( new Listener() + { + @Override + public void receive( ChannelMapEvent t ) + { + schedulePlaylistSave(); + } + } ); } /** @@ -123,41 +116,64 @@ public class PlaylistManager implements ChannelEventListener, Listener 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. + * Loads a version 2 playlist */ - public void load( Path playlistPath ) + public PlaylistV2 load( Path playlistPath ) { + mLog.info( "loading version 2 playlist file [" + playlistPath.toString() + "]" ); + + PlaylistV2 playlist = null; + if( Files.exists( playlistPath ) ) { - mLog.info( "loading playlist file [" + playlistPath.toString() + "]" ); - JAXBContext context = null; InputStream in = null; @@ -365,11 +317,11 @@ public class PlaylistManager implements ChannelEventListener, Listener - ******************************************************************************/ -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; -import controller.system.SystemListNode; - -public class PlaylistNode extends BaseNode -{ - private static final long serialVersionUID = 1L; - private AliasDirectoryNode mAliasDirectoryNode; - private ChannelMapListNode mChannelMapListNode; - private SystemListNode mSystemListNode; - - 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() - { - /** - * Delete any existing children - */ - delete(); - - /** - * Load the AliasDirectory - */ - AliasDirectory directory = getPlaylist().getAliasDirectory(); - - if( directory == null ) - { - directory = new AliasDirectory(); - getPlaylist().setAliasDirectory( directory ); - } - - mAliasDirectoryNode = new AliasDirectoryNode( mPlaylistManager, - mSettingsManager, directory ); - - getModel().insertNodeInto( mAliasDirectoryNode, this, 0 ); - - mAliasDirectoryNode.init(); - - /** - * Load the Channel Map List - */ - ChannelMapList channelMapList = getPlaylist().getChannelMapList(); - - if( channelMapList == null ) - { - channelMapList = new ChannelMapList(); - } - - mChannelMapListNode = new ChannelMapListNode( mPlaylistManager, channelMapList ); - - getModel().insertNodeInto( mChannelMapListNode, this, 1 ); - - mChannelMapListNode.init(); - - /** - * Load the SystemList - */ - SystemList list = getPlaylist().getSystemList(); - - if( list == null ) - { - list = new SystemList(); - getPlaylist().setSystemList( list ); - } - - mSystemListNode = new SystemListNode( list, mChannelModel, - mChannelProcessingManager, mPlaylistManager, mSourceManager ); - - getModel().insertNodeInto( mSystemListNode, this, 2 ); - - mSystemListNode.init(); - - mSystemListNode.show(); - } - - public SystemListNode getSystemListNode() - { - return mSystemListNode; - } - - public AliasDirectoryNode getAliasDirectoryNode() - { - return mAliasDirectoryNode; - } - - public void loadPlaylist() - { - Playlist playlist = mPlaylistManager.getPlayist(); - - setUserObject( playlist ); - - init(); - } - - - public Playlist getPlaylist() - { - Playlist retVal = null; - - Object userObject = getUserObject(); - - if( userObject != null ) - { - retVal = (Playlist)userObject; - } - - return retVal; - } - - public String toString() - { - return "Playlist"; - } - - public JPanel getEditor() - { - return new EmptyEditor(); - } -} diff --git a/src/playlist/PlaylistV2.java b/src/playlist/PlaylistV2.java new file mode 100644 index 00000000..aa3fa2fe --- /dev/null +++ b/src/playlist/PlaylistV2.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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 + ******************************************************************************/ +package playlist; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; + +import alias.Alias; +import controller.channel.Channel; +import controller.channel.map.ChannelMap; + +@XmlSeeAlso( { Alias.class,Channel.class,ChannelMap.class } ) + +@XmlRootElement( name = "playlist" ) +public class PlaylistV2 +{ + //Version 2 member variables + private List mAliases = new ArrayList<>(); + private List mChannels = new ArrayList<>(); + private List mChannelMaps = new ArrayList<>(); + + public PlaylistV2() + { + } + + @XmlElement( name = "alias" ) + public List getAliases() + { + return mAliases; + } + + public void setAliases( List aliases ) + { + mAliases = aliases; + } + + @XmlElement( name = "channel" ) + public List getChannels() + { + return mChannels; + } + + public void setChannels( List channels ) + { + mChannels = channels; + } + + @XmlElement( name = "channel_map" ) + public List getChannelMaps() + { + return mChannelMaps; + } + + public void setChannelMaps( List channelMaps ) + { + mChannelMaps = channelMaps; + } +} diff --git a/src/alias/AliasDirectory.java b/src/playlist/version1/AliasDirectory.java similarity index 76% rename from src/alias/AliasDirectory.java rename to src/playlist/version1/AliasDirectory.java index 34202b2f..49c64eb7 100644 --- a/src/alias/AliasDirectory.java +++ b/src/playlist/version1/AliasDirectory.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package alias; +package playlist.version1; import java.util.ArrayList; @@ -23,11 +23,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; +import alias.AliasList; + @XmlSeeAlso( { AliasList.class} ) @XmlRootElement( name = "alias_directory" ) +@Deprecated public class AliasDirectory { - private ArrayList mAliasList = new ArrayList(); + private ArrayList mAliasList = new ArrayList<>(); public AliasDirectory() { @@ -35,10 +38,6 @@ public class AliasDirectory public void refresh() { - for( AliasList list: mAliasList ) - { - list.update(); - } } public void clearAliasLists() @@ -47,27 +46,27 @@ public class AliasDirectory } @XmlElement( name = "alias_list" ) - public ArrayList getAliasList() + public ArrayList getAliasList() { return mAliasList; } - public void setAliasList( ArrayList lists ) + public void setAliasList( ArrayList lists ) { mAliasList = lists; if( mAliasList == null ) { - mAliasList = new ArrayList(); + mAliasList = new ArrayList(); } } - public void addAliasList( AliasList list ) + public void addAliasList( AliasListOld list ) { mAliasList.add( list ); } - public void removeAliasList( AliasList list ) + public void removeAliasList( AliasListOld list ) { mAliasList.remove( list ); } @@ -75,11 +74,11 @@ public class AliasDirectory /** * Gets the named alias list, or returns an empty alias list */ - public AliasList getAliasList( String name ) + public AliasListOld getAliasList( String name ) { - AliasList retVal = new AliasList(); + AliasListOld retVal = new AliasListOld( name ); - for( AliasList list: mAliasList ) + for( AliasListOld list: mAliasList ) { if( list.getName().equalsIgnoreCase( name ) ) { diff --git a/src/playlist/version1/AliasListOld.java b/src/playlist/version1/AliasListOld.java new file mode 100644 index 00000000..7df3c6be --- /dev/null +++ b/src/playlist/version1/AliasListOld.java @@ -0,0 +1,583 @@ +/******************************************************************************* + * SDR Trunk + * Copyright (C) 2014,2015 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 + ******************************************************************************/ +package playlist.version1; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; + +import module.decode.lj1200.LJ1200Message.Function; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import alias.Alias; +import alias.action.AliasAction; +import alias.action.beep.BeepAction; +import alias.action.clip.ClipAction; +import alias.action.script.ScriptAction; +import alias.id.AliasID; +import alias.id.esn.Esn; +import alias.id.fleetsync.FleetsyncID; +import alias.id.lojack.LoJackFunctionAndID; +import alias.id.mdc.MDC1200ID; +import alias.id.mobileID.Min; +import alias.id.mpt1327.MPT1327ID; +import alias.id.nonrecordable.NonRecordable; +import alias.id.priority.Priority; +import alias.id.siteID.SiteID; +import alias.id.status.StatusID; +import alias.id.talkgroup.TalkgroupID; +import alias.id.uniqueID.UniqueID; +import audio.metadata.MetadataType; + +@XmlSeeAlso( { Alias.class, + + /* Alias ID's */ + AliasID.class, + FleetsyncID.class, + Esn.class, + Group.class, + LoJackFunctionAndID.class, + MDC1200ID.class, + Min.class, + MPT1327ID.class, + UniqueID.class, + SiteID.class, + StatusID.class, + TalkgroupID.class, + + /* Alias Attributes */ + NonRecordable.class, + Priority.class, + + /* Alias Actions */ + AliasAction.class, + BeepAction.class, + ClipAction.class, + ScriptAction.class } ) + +@Deprecated +@XmlRootElement( name = "alias_list" ) +public class AliasListOld implements Comparable +{ + private final static Logger mLog = LoggerFactory.getLogger( AliasListOld.class ); + + private String mName; + private ArrayList mGroups = new ArrayList(); + + private Map mESN = new HashMap<>(); + private Map mFleetsync = new HashMap<>(); + private Map mLoJack = new HashMap<>(); + private Map mMDC1200 = new HashMap<>(); + private Map mMobileID = new HashMap<>(); + private Map mMPT1327 = new HashMap<>(); + private Map mSiteID = new HashMap<>(); + private Map mStatus = new HashMap<>(); + private Map mTalkgroup = new HashMap<>(); + private Map mUniqueID = new HashMap<>(); + + private boolean mESNWildcard = false; + private boolean mMobileIDWildcard = false; + private boolean mFleetsyncWildcard = false; + private boolean mMDC1200Wildcard = false; + private boolean mMPT1327Wildcard = false; + private boolean mSiteWildcard = false; + private boolean mTalkgroupWildcard = false; + + public AliasListOld() + { + this( null ); + } + + public AliasListOld( String name ) + { + mName = name; + update(); + } + + /** + * Load/Reload all lookup hashmaps + */ + public void update() + { + //Clear hashmaps + mESN.clear(); + mFleetsync.clear(); + mLoJack.clear(); + mMDC1200.clear(); + mMobileID.clear(); + mMPT1327.clear(); + mSiteID.clear(); + mStatus.clear(); + mTalkgroup.clear(); + mUniqueID.clear(); + + for( Group group: mGroups ) + { + for( Alias alias: group.getAlias() ) + { + for( AliasID id: alias.getId() ) + { + switch( id.getType() ) + { + case ESN: + Esn esn = (Esn)id; + if( esn.getEsn().contains( "*" ) ) + { + mESNWildcard = true; + + mESN.put( fixWildcard( esn.getEsn() ), alias ); + } + else + { + mESN.put( esn.getEsn(), alias ); + } + break; + case Fleetsync: + FleetsyncID fs = (FleetsyncID)id; + + if( fs.getIdent().contains( "*" ) ) + { + mFleetsyncWildcard = true; + + mFleetsync.put( fixWildcard( fs.getIdent() ), alias ); + } + else + { + mFleetsync.put( fs.getIdent(), alias ); + } + break; + case LoJack: + mLoJack.put( (LoJackFunctionAndID)id, alias ); + break; + case MDC1200: + MDC1200ID mdc = (MDC1200ID)id; + + if( mdc.getIdent().contains( "*" ) ) + { + mMDC1200Wildcard = true; + + //Replace (*) wildcard with regex wildcard (.) + mMDC1200.put( fixWildcard( mdc.getIdent() ), alias ); + } + else + { + mMDC1200.put( mdc.getIdent(), alias ); + } + break; + case MPT1327: + MPT1327ID mpt = (MPT1327ID)id; + + String ident = mpt.getIdent(); + + if( ident != null ) + { + if( ident.contains( "*" ) ) + { + mMPT1327Wildcard = true; + + //Replace (*) wildcard with regex wildcard (.) + mMPT1327.put( fixWildcard( ident ), alias ); + } + else + { + mMPT1327.put( ident, alias ); + } + } + break; + case MIN: + Min min = (Min)id; + + if( min.getMin().contains( "*" ) ) + { + mMobileIDWildcard = true; + mMobileID.put( fixWildcard( min.getMin() ), alias ); + } + else + { + mMobileID.put( min.getMin(), alias ); + } + break; + case LTRNetUID: + UniqueID uid = (UniqueID)id; + + mUniqueID.put( uid.getUid(), alias ); + break; + case Site: + SiteID siteID = (SiteID)id; + + if( siteID.getSite().contains( "*" ) ) + { + mSiteWildcard = true; + mSiteID.put( fixWildcard( siteID.getSite() ), alias ); + } + else + { + mSiteID.put( siteID.getSite(), alias ); + } + + break; + case Status: + mStatus.put( ((StatusID)id).getStatus(), alias ); + break; + case Talkgroup: + TalkgroupID tgid = (TalkgroupID)id; + + if( tgid.getTalkgroup().contains( "*" ) ) + { + mTalkgroupWildcard = true; + + //Replace (*) wildcard with regex wildcard (.) + mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias ); + } + else + { + mTalkgroup.put( tgid.getTalkgroup(), alias ); + } + break; + case NonRecordable: + case Priority: + //We don't maintain lookups for these items + break; + default: + mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() ); + break; + } + } + } + } + } + + /** + * Converts user wildcard character (*) to regex single character wildcard (.) + * but ignores a regex multi-character wildcard (.*) + */ + private String fixWildcard( String value ) + { + if( value.contains( "*" ) && !value.contains( ".*" ) ) + { + return value.replace( "*", "." ); + } + + return value; + } + + public Alias getSiteID( String siteID ) + { + if( siteID != null ) + { + if( mSiteWildcard ) + { + for( String regex: mSiteID.keySet() ) + { + if( siteID.matches( regex ) ) + { + return mSiteID.get( regex ); + } + } + } + else + { + return mSiteID.get( siteID ); + } + } + + return null; + } + + public Alias getStatus( int status ) + { + return mStatus.get( status ); + } + + public Alias getUniqueID( int uniqueID ) + { + return mUniqueID.get( uniqueID ); + } + + public Alias getESNAlias( String esn ) + { + if( esn != null ) + { + if( mESNWildcard ) + { + for( String regex: mESN.keySet() ) + { + if( esn.matches( regex ) ) + { + return mESN.get( regex ); + } + } + } + else + { + return mESN.get( esn ); + } + } + + return null; + } + + + public Alias getFleetsyncAlias( String ident ) + { + if( ident != null ) + { + if( mFleetsyncWildcard ) + { + for( String regex: mFleetsync.keySet() ) + { + if( ident.matches( regex ) ) + { + return mFleetsync.get( regex ); + } + } + } + else + { + return mFleetsync.get( ident ); + } + } + + return null; + } + + public Alias getLoJackAlias( Function function, String id ) + { + if( id != null ) + { + for( LoJackFunctionAndID lojack: mLoJack.keySet() ) + { + if( lojack.matches( function, id ) ) + { + return mLoJack.get( lojack ); + } + } + } + + return null; + } + + public Alias getMDC1200Alias( String ident ) + { + if( ident != null ) + { + if( mMDC1200Wildcard ) + { + for( String regex: mMDC1200.keySet() ) + { + if( ident.matches( regex ) ) + { + return mMDC1200.get( regex ); + } + } + } + else + { + return mMDC1200.get( ident ); + } + } + + return null; + } + + public Alias getMPT1327Alias( String ident ) + { + if( ident != null ) + { + if( mMPT1327Wildcard ) + { + for( String regex: mMPT1327.keySet() ) + { + if( ident.matches( regex ) ) + { + return mMPT1327.get( regex ); + } + } + } + else + { + return mMPT1327.get( ident ); + } + } + + return null; + } + + public Group getGroup( Alias alias ) + { + if( alias != null ) + { + for( Group group: mGroups ) + { + if( group.contains( alias ) ) + { + return group; + } + } + } + + return null; + } + + public Alias getMobileIDNumberAlias( String ident ) + { + if( ident != null ) + { + if( mMobileIDWildcard ) + { + for( String regex: mMobileID.keySet() ) + { + if( ident.matches( regex ) ) + { + return mMobileID.get( regex ); + } + } + } + else + { + return mMobileID.get( ident ); + } + } + + return null; + } + + public Alias getTalkgroupAlias( String tgid ) + { + if( tgid != null ) + { + if( mTalkgroupWildcard ) + { + for( String regex: mTalkgroup.keySet() ) + { + if( tgid.matches( regex ) ) + { + return mTalkgroup.get( regex ); + } + } + } + else + { + return mTalkgroup.get( tgid ); + } + } + + return null; + } + + public String toString() + { + return mName; + } + + @XmlAttribute + public String getName() + { + return mName; + } + + public void setName( String name ) + { + mName = name; + } + + public ArrayList getGroup() + { + return mGroups; + } + + public void setGroup( ArrayList groups ) + { + mGroups = groups; + } + + public void addGroup( Group group ) + { + mGroups.add( group ); + } + + public void removeGroup( Group group ) + { + mGroups.remove( group ); + } + + @Override + public int compareTo( AliasListOld otherAliasList ) + { + return getName().compareTo( otherAliasList.getName() ); + } + + public Alias getAlias( String value, MetadataType type ) + { + switch( type ) + { + case ESN: + return getESNAlias( value ); + case FLEETSYNC: + return getFleetsyncAlias( value ); + case MDC1200: + return getMDC1200Alias( value ); + case MOBILE_ID: + return getMobileIDNumberAlias( value ); + case MPT1327: + return getMPT1327Alias( value ); + case SITE_ID: + return getSiteID( value ); + case STATUS: + if( value != null ) + { + try + { + return getStatus( Integer.valueOf( value ) ); + } + catch( Exception e ) + { + //do nothing, we couldn't parse the int value + } + } + break; + case FROM: + case TO: + return getTalkgroupAlias( value ); + case UNIQUE_ID: + if( value != null ) + { + try + { + return getUniqueID( Integer.valueOf( value ) ); + } + catch( Exception e ) + { + //do nothing, we couldn't parse the int value + } + } + break; + default: + break; + } + + return null; + } + +} diff --git a/src/controller/channel/map/ChannelMapList.java b/src/playlist/version1/ChannelMapList.java similarity index 96% rename from src/controller/channel/map/ChannelMapList.java rename to src/playlist/version1/ChannelMapList.java index 7a43b25b..5d0f6d61 100644 --- a/src/controller/channel/map/ChannelMapList.java +++ b/src/playlist/version1/ChannelMapList.java @@ -15,14 +15,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package controller.channel.map; +package playlist.version1; import java.util.ArrayList; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlSeeAlso; +import controller.channel.map.ChannelMap; + @XmlSeeAlso( ChannelMap.class ) +@Deprecated public class ChannelMapList { private ArrayList mChannelMap = new ArrayList(); diff --git a/src/alias/Group.java b/src/playlist/version1/Group.java similarity index 96% rename from src/alias/Group.java rename to src/playlist/version1/Group.java index d5e30228..d8a17d0f 100644 --- a/src/alias/Group.java +++ b/src/playlist/version1/Group.java @@ -15,12 +15,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package alias; +package playlist.version1; import java.util.ArrayList; import javax.xml.bind.annotation.XmlAttribute; +import alias.Alias; + +@Deprecated public class Group { private String mName; diff --git a/src/playlist/version1/PlaylistConverterV1ToV2.java b/src/playlist/version1/PlaylistConverterV1ToV2.java new file mode 100644 index 00000000..ee2f3296 --- /dev/null +++ b/src/playlist/version1/PlaylistConverterV1ToV2.java @@ -0,0 +1,168 @@ +package playlist.version1; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import playlist.PlaylistV2; +import alias.Alias; +import alias.AliasList; +import controller.channel.Channel; +import controller.channel.map.ChannelMap; + +public class PlaylistConverterV1ToV2 +{ + private final static Logger mLog = + LoggerFactory.getLogger( PlaylistConverterV1ToV2.class ); + + private PlaylistV2 mConvertedPlaylist; + private List mErrors = new ArrayList<>(); + + public PlaylistConverterV1ToV2( Path path ) + { + PlaylistV1 playlistVersion1 = null; + + if( path != null && Files.exists( path ) ) + { + mLog.info( "attempting playlist v1 to v2 conversion [" + + path.toString() + "]" ); + + JAXBContext context = null; + + InputStream in = null; + + try + { + in = new FileInputStream( path.toString() ); + + try + { + context = JAXBContext.newInstance( PlaylistV1.class ); + + Unmarshaller m = context.createUnmarshaller(); + + playlistVersion1 = (PlaylistV1)m.unmarshal( in ); + } + catch ( JAXBException e ) + { + mErrors.add( "Couldn't unmarshall version 1 playlist - " + + e.getLocalizedMessage() ); + } + } + catch ( Exception e ) + { + mErrors.add( "Couldn't open version 1 playlist - [" + + path.toString() + "] - " + e.getLocalizedMessage() ); + } + finally + { + if( in != null ) + { + try + { + in.close(); + } + catch ( IOException e ) + { + mLog.error( "exception while closing " + + "the playlist file inputstream reader", e ); + } + } + } + } + else + { + mErrors.add( "version 1 playlist is null or not found [" + + path.toString() + "]" ); + } + + if( playlistVersion1 != null ) + { + mConvertedPlaylist = new PlaylistV2(); + + if( playlistVersion1.hasSystemList() ) + { + SystemList systemList = playlistVersion1.getSystemList(); + + for( playlist.version1.System system: systemList.getSystem() ) + { + for( Site site: system.getSite() ) + { + for( Channel channel: site.getChannel() ) + { + channel.setSystem( system.getName() ); + channel.setSite( site.getName() ); + + mConvertedPlaylist.getChannels().add( channel ); + } + } + } + } + + if( playlistVersion1.hasAliasDirectory() ) + { + AliasDirectory aliasDirectory = playlistVersion1.getAliasDirectory(); + + for( AliasListOld list: aliasDirectory.getAliasList() ) + { + for( Group group: list.getGroup() ) + { + for( Alias alias: group.getAlias() ) + { + alias.setList( list.getName() ); + alias.setGroup( group.getName() ); + + mConvertedPlaylist.getAliases().add( alias ); + } + } + } + } + + if( playlistVersion1.hasChannelMapList() ) + { + //Move the channel maps out of the channel map list + ChannelMapList channelMapList = playlistVersion1.getChannelMapList(); + + List channelMaps = channelMapList.getChannelMap(); + + if( channelMaps != null && !channelMaps.isEmpty() ) + { + mConvertedPlaylist.getChannelMaps().addAll( channelMaps ); + } + } + + mLog.info( "Converted [" + mConvertedPlaylist.getChannels().size() + + "] channels to new playlist format" ); + mLog.info( "Converted [" + mConvertedPlaylist.getAliases().size() + + "] aliases to new playlist format" ); + mLog.info( "Converted [" + mConvertedPlaylist.getChannelMaps().size() + + "] channel maps to new playlist format" ); + } + } + + public PlaylistV2 getConvertedPlaylist() + { + return mConvertedPlaylist; + } + + public List getErrorMessages() + { + return mErrors; + } + + public boolean hasErrorMessages() + { + return !mErrors.isEmpty(); + } +} diff --git a/src/playlist/Playlist.java b/src/playlist/version1/PlaylistV1.java similarity index 78% rename from src/playlist/Playlist.java rename to src/playlist/version1/PlaylistV1.java index d4ae9d0c..52e8dc4a 100644 --- a/src/playlist/Playlist.java +++ b/src/playlist/version1/PlaylistV1.java @@ -15,20 +15,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package playlist; - -import java.util.ArrayList; -import java.util.List; +package playlist.version1; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import alias.Alias; -import alias.AliasDirectory; import controller.channel.Channel; -import controller.channel.map.ChannelMapList; -import controller.system.SystemList; @XmlSeeAlso( { AliasDirectory.class, Alias.class, @@ -36,41 +30,19 @@ import controller.system.SystemList; ChannelMapList.class, SystemList.class } ) +@Deprecated @XmlRootElement( name = "playlist" ) -public class Playlist +public class PlaylistV1 { + //Note: these are for legacy version 1 format playlists private AliasDirectory mAliasDirectory = new AliasDirectory(); private ChannelMapList mChannelMapList = new ChannelMapList(); private SystemList mSystemList = new SystemList(); - private List mAliases = new ArrayList<>(); - private List mChannels = new ArrayList<>(); - - public Playlist() + + public PlaylistV1() { } - @XmlElement( name = "alias" ) - public List getAliases() - { - return mAliases; - } - - public void setAliases( List aliases ) - { - mAliases = aliases; - } - - @XmlElement( name = "channel" ) - public List getChannels() - { - return mChannels; - } - - public void setChannels( List channels ) - { - mChannels = channels; - } - @XmlElement( name = "alias_directory" ) public AliasDirectory getAliasDirectory() { @@ -79,6 +51,7 @@ public class Playlist return mAliasDirectory; } + public void setAliasDirectory( AliasDirectory directory ) { mAliasDirectory = directory; @@ -90,6 +63,7 @@ public class Playlist mAliasDirectory.getAliasList() != null && !mAliasDirectory.getAliasList().isEmpty(); } + @XmlElement( name = "system_list" ) public SystemList getSystemList() @@ -97,6 +71,7 @@ public class Playlist return mSystemList; } + public void setSystemList( SystemList list ) { mSystemList = list; @@ -109,12 +84,21 @@ public class Playlist !mSystemList.getSystem().isEmpty(); } + @XmlElement( name = "channel_maps" ) public ChannelMapList getChannelMapList() { return mChannelMapList; } + public boolean hasChannelMapList() + { + return mChannelMapList != null && + mChannelMapList.getChannelMap() != null && + !mChannelMapList.getChannelMap().isEmpty(); + } + + public void setChannelMapList( ChannelMapList list ) { mChannelMapList = list; diff --git a/src/controller/site/Site.java b/src/playlist/version1/Site.java similarity index 98% rename from src/controller/site/Site.java rename to src/playlist/version1/Site.java index 2cc24419..876fc30b 100644 --- a/src/controller/site/Site.java +++ b/src/playlist/version1/Site.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package controller.site; +package playlist.version1; import java.util.ArrayList; @@ -27,6 +27,7 @@ import controller.channel.Channel; @XmlSeeAlso( { Channel.class } ) @XmlRootElement( name = "site" ) +@Deprecated public class Site { private String mName; diff --git a/src/controller/system/System.java b/src/playlist/version1/System.java similarity index 97% rename from src/controller/system/System.java rename to src/playlist/version1/System.java index e88432f9..548bff7d 100644 --- a/src/controller/system/System.java +++ b/src/playlist/version1/System.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package controller.system; +package playlist.version1; import java.util.ArrayList; @@ -23,10 +23,9 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; -import controller.site.Site; - @XmlSeeAlso( { Site.class } ) @XmlRootElement( name = "system" ) +@Deprecated public class System { private String mName; diff --git a/src/controller/system/SystemList.java b/src/playlist/version1/SystemList.java similarity index 94% rename from src/controller/system/SystemList.java rename to src/playlist/version1/SystemList.java index 91fcacec..5543c078 100644 --- a/src/controller/system/SystemList.java +++ b/src/playlist/version1/SystemList.java @@ -15,16 +15,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see ******************************************************************************/ -package controller.system; +package playlist.version1; import java.util.ArrayList; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; -@XmlSeeAlso( { controller.system.System.class } ) +@XmlSeeAlso( { playlist.version1.System.class } ) @XmlRootElement( name = "system_list" ) +@Deprecated public class SystemList { private ArrayList mSystem = new ArrayList(); diff --git a/src/source/tuner/TunerNode.java b/src/source/tuner/TunerNode.java index 63aabd9c..fdba9a08 100644 --- a/src/source/tuner/TunerNode.java +++ b/src/source/tuner/TunerNode.java @@ -51,12 +51,10 @@ public class TunerNode extends BaseNode implements IFrequencyChangeProcessor private int mSampleRate; private ChannelModel mChannelModel; private ChannelProcessingManager mChannelProcessingManager; - private PlaylistManager mPlaylistManager; private SettingsManager mSettingsManager; public TunerNode( ChannelModel channelModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, SettingsManager settingsManager, Tuner tuner ) { @@ -64,7 +62,6 @@ public class TunerNode extends BaseNode implements IFrequencyChangeProcessor mChannelModel = channelModel; mChannelProcessingManager = channelProcessingManager; - mPlaylistManager = playlistManager; mSettingsManager = settingsManager; tuner.addFrequencyChangeProcessor( this ); @@ -130,8 +127,7 @@ public class TunerNode extends BaseNode implements IFrequencyChangeProcessor public void actionPerformed( ActionEvent e ) { SpectrumFrame frame = new SpectrumFrame( getModel(), mChannelModel, - mChannelProcessingManager, mPlaylistManager, - mSettingsManager, getTuner() ); + mChannelProcessingManager, mSettingsManager, getTuner() ); } } ); diff --git a/src/spectrum/SpectralDisplayPanel.java b/src/spectrum/SpectralDisplayPanel.java index 1209236e..0ef337c0 100644 --- a/src/spectrum/SpectralDisplayPanel.java +++ b/src/spectrum/SpectralDisplayPanel.java @@ -1,6 +1,6 @@ /******************************************************************************* * 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 * it under the terms of the GNU General Public License as published by @@ -53,7 +53,6 @@ import net.miginfocom.swing.MigLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import playlist.PlaylistManager; import properties.SystemProperties; import sample.Listener; import sample.SampleType; @@ -118,7 +117,6 @@ public class SpectralDisplayPanel extends JPanel private ConfigurationControllerModel mControllerModel; private ChannelModel mChannelModel; private ChannelProcessingManager mChannelProcessingManager; - private PlaylistManager mPlaylistManager; private SettingsManager mSettingsManager; private Tuner mTuner; @@ -137,13 +135,11 @@ public class SpectralDisplayPanel extends JPanel public SpectralDisplayPanel( ConfigurationControllerModel controllerModel, ChannelModel channelModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, SettingsManager settingsManager ) { mControllerModel = controllerModel; mChannelModel = channelModel; mChannelProcessingManager = channelProcessingManager; - mPlaylistManager = playlistManager; mSettingsManager = settingsManager; mSpectrumPanel = new SpectrumPanel( mSettingsManager ); @@ -200,7 +196,6 @@ public class SpectralDisplayPanel extends JPanel } mControllerModel = null; - mPlaylistManager = null; mSettingsManager = null; mDFTProcessor.dispose(); @@ -657,7 +652,7 @@ public class SpectralDisplayPanel extends JPanel for( Channel channel: channels ) { JMenu channelMenu = ChannelUtils.getContextMenu( mChannelModel, - mChannelProcessingManager, mPlaylistManager, channel, + mChannelProcessingManager, channel, SpectralDisplayPanel.this ); if( channelMenu != null ) diff --git a/src/spectrum/SpectrumFrame.java b/src/spectrum/SpectrumFrame.java index f3e6eac4..a094be24 100644 --- a/src/spectrum/SpectrumFrame.java +++ b/src/spectrum/SpectrumFrame.java @@ -24,7 +24,6 @@ import java.awt.event.WindowListener; import javax.swing.JFrame; import net.miginfocom.swing.MigLayout; -import playlist.PlaylistManager; import settings.SettingsManager; import source.tuner.Tuner; import controller.ConfigurationControllerModel; @@ -40,7 +39,6 @@ public class SpectrumFrame extends JFrame implements WindowListener public SpectrumFrame( ConfigurationControllerModel controllerModel, ChannelModel channelModel, ChannelProcessingManager channelProcessingManager, - PlaylistManager playlistManager, SettingsManager settingsManager, Tuner tuner ) { @@ -51,7 +49,7 @@ public class SpectrumFrame extends JFrame implements WindowListener setLayout( new MigLayout( "insets 0 0 0 0", "[grow]", "[grow]") ); mSpectralDisplayPanel = new SpectralDisplayPanel( controllerModel, - channelModel, channelProcessingManager, playlistManager, settingsManager ); + channelModel, channelProcessingManager, settingsManager ); mSpectralDisplayPanel.tunerSelected( tuner ); add( mSpectralDisplayPanel, "grow" );