Initial code check in continued

This commit is contained in:
dennis.sheirer
2014-04-26 19:48:24 +00:00
parent 960a6f9952
commit 3dfedcf8d1
474 changed files with 76613 additions and 0 deletions

126
src/alias/Alias.java Normal file
View File

@@ -0,0 +1,126 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import java.awt.Color;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAttribute;
import audio.AudioType;
public class Alias
{
private String mName;
private int mColor;
private String mIconName;
private ArrayList<AliasID> mAliasIDs = new ArrayList<AliasID>();
public Alias()
{
}
public String toString()
{
return "Alias: " + mName;
}
@XmlAttribute
public String getName()
{
return mName;
}
public void setName( String name )
{
mName = name;
}
@XmlAttribute
public int getColor()
{
return mColor;
}
public void setColor( int color )
{
mColor = color;
}
public Color getMapColor()
{
return new Color( mColor );
}
@XmlAttribute
public String getIconName()
{
return mIconName;
}
public void setIconName( String iconName )
{
mIconName = iconName;
}
public ArrayList<AliasID> getId()
{
return mAliasIDs;
}
public void setId( ArrayList<AliasID> id )
{
mAliasIDs = id;
}
public void addAliasID( AliasID id )
{
mAliasIDs.add( id );
}
public void removeAliasID( AliasID id )
{
mAliasIDs.remove( id );
}
public boolean hasAudioType()
{
for( AliasID id: mAliasIDs )
{
if( id.hasAudioType() )
{
return true;
}
}
return false;
}
public AudioType getAudioType()
{
for( AliasID id: mAliasIDs )
{
if( id.hasAudioType() )
{
return id.getAudioType();
}
}
return AudioType.NORMAL;
}
}

View File

@@ -0,0 +1,82 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso( { AliasList.class} )
@XmlRootElement( name = "alias_directory" )
public class AliasDirectory
{
private ArrayList<AliasList> mAliasList = new ArrayList<AliasList>();
public AliasDirectory()
{
}
public void refresh()
{
for( AliasList list: mAliasList )
{
list.update();
}
}
@XmlElement( name = "alias_list" )
public ArrayList<AliasList> getAliasList()
{
return mAliasList;
}
public void setAliasList( ArrayList<AliasList> lists )
{
mAliasList = lists;
}
public void addAliasList( AliasList list )
{
mAliasList.add( list );
}
public void removeAliasList( AliasList list )
{
mAliasList.remove( list );
}
/**
* Gets the named alias list, or returns an empty alias list
*/
public AliasList getAliasList( String name )
{
AliasList retVal = new AliasList();
for( AliasList list: mAliasList )
{
if( list.getName().equalsIgnoreCase( name ) )
{
return list;
}
}
return retVal;
}
}

View File

@@ -0,0 +1,91 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import controller.ConfigurableNode;
public class AliasDirectoryNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public AliasDirectoryNode( AliasDirectory directory )
{
super( directory );
}
public AliasDirectory getAliasDirectory()
{
return (AliasDirectory)getUserObject();
}
public void init()
{
for( AliasList list: getAliasDirectory().getAliasList() )
{
AliasListNode node = new AliasListNode( 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( list );
getModel().addNode( node,
AliasDirectoryNode.this,
AliasDirectoryNode.this.getChildCount() );
sort();
getModel().showNode( node );
}
} );
retVal.add( addItem );
return retVal;
}
}

205
src/alias/AliasEditor.java Normal file
View File

@@ -0,0 +1,205 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.tree.TreePath;
import map.MapIcon;
import map.MapIconListCellRenderer;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
import controller.ConfigurableNode;
import controller.ResourceManager;
public class AliasEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private AliasNode mAliasNode;
private ResourceManager mResourceManager;
private JLabel mLabelName;
private JTextField mTextAlias;
private JLabel mLabelMapColor;
private JButton mButtonColor;
private JComboBox<MapIcon> mComboMapIcon;
private JButton mBtnIconManager;
public AliasEditor( AliasNode aliasNode, ResourceManager resourceManager )
{
mAliasNode = aliasNode;
mResourceManager = resourceManager;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Alias" ) );
mLabelName = new JLabel( "Name:" );
add( mLabelName, "align right" );
mTextAlias = new JTextField( mAliasNode.getAlias().getName() );
add( mTextAlias, "grow, wrap" );
mLabelMapColor = new JLabel( "Map Color:" );
add( mLabelMapColor, "align right" );
mButtonColor = new JButton( "Map Color" );
mButtonColor.setBackground( mAliasNode.getAlias().getMapColor() );
mButtonColor.setForeground( mAliasNode.getAlias().getMapColor() );
mButtonColor.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
Color newColor = JColorChooser.showDialog(
AliasEditor.this,
"Choose color for map labels and routes",
mAliasNode.getAlias().getMapColor() );
mButtonColor.setForeground( newColor );
mButtonColor.setBackground( newColor );
}
} );
add( mButtonColor, "wrap" );
add( new JLabel( "Map Icon:" ), "align right" );
mComboMapIcon = new JComboBox<MapIcon>(
mResourceManager.getSettingsManager().getMapIcons() );
MapIconListCellRenderer renderer = new MapIconListCellRenderer();
renderer.setPreferredSize( new Dimension( 200, 30 ) );
mComboMapIcon.setRenderer( renderer );
String iconName = mAliasNode.getAlias().getIconName();
if( iconName == null )
{
iconName = SettingsManager.DEFAULT_ICON;
}
MapIcon savedIcon = mResourceManager.getSettingsManager()
.getMapIcon( iconName );
if( savedIcon != null )
{
mComboMapIcon.setSelectedItem( savedIcon );
}
add( mComboMapIcon, "wrap" );
//Dummy place holder
add( new JLabel() );
mBtnIconManager = new JButton( "Icon Manager" );
mBtnIconManager.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
mResourceManager.getController().showIconManager();
}
} );
add( mBtnIconManager, "span 2,wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( AliasEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( AliasEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String alias = mTextAlias.getText();
if( alias != null )
{
boolean expanded = mAliasNode.getModel().getTree()
.isExpanded( new TreePath( mAliasNode ) );
mAliasNode.getAlias().setName( alias );
((ConfigurableNode)mAliasNode.getParent()).sort();
mAliasNode.getAlias().setColor(
mButtonColor.getBackground().getRGB() );
MapIcon selectedIcon = (MapIcon)mComboMapIcon.getSelectedItem();
if( selectedIcon != null )
{
mAliasNode.getAlias().setIconName( selectedIcon.getName() );
}
mAliasNode.save();
mAliasNode.show();
if( expanded )
{
mAliasNode.getModel().getTree()
.expandPath( new TreePath( mAliasNode ) );
}
}
else
{
JOptionPane.showMessageDialog( AliasEditor.this, "Please enter an alias name" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextAlias.setText( mAliasNode.getAlias().getName() );
mButtonColor.setBackground( mAliasNode.getAlias().getMapColor() );
mButtonColor.setForeground( mAliasNode.getAlias().getMapColor() );
MapIcon savedIcon = mResourceManager.getSettingsManager()
.getMapIcon( mAliasNode.getAlias().getIconName() );
mComboMapIcon.setSelectedItem( savedIcon );
}
mAliasNode.refresh();
}
}

41
src/alias/AliasID.java Normal file
View File

@@ -0,0 +1,41 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import audio.AudioType;
public abstract class AliasID
{
public AliasID()
{
}
public abstract AliasIDType getType();
public boolean hasAudioType()
{
return false;
}
public AudioType getAudioType()
{
return AudioType.NORMAL;
}
public abstract boolean matches( AliasID id );
}

View File

@@ -0,0 +1,35 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import controller.ConfigurableNode;
public class AliasIDNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public AliasIDNode( AliasID id )
{
super( id );
}
public void save()
{
getModel().getResourceManager().getPlaylistManager().save();
}
}

View File

@@ -0,0 +1,31 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
public enum AliasIDType
{
ESN,
Fleetsync,
LTRNetUID,
MDC1200,
MIN,
MPT1327,
Site,
Status,
Talkgroup;
}

409
src/alias/AliasList.java Normal file
View File

@@ -0,0 +1,409 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import java.util.ArrayList;
import java.util.HashMap;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import alias.esn.Esn;
import alias.fleetsync.FleetsyncID;
import alias.fleetsync.StatusID;
import alias.mdc.MDC1200ID;
import alias.mobileID.Min;
import alias.mpt1327.MPT1327ID;
import alias.siteID.SiteID;
import alias.talkgroup.TalkgroupID;
import alias.uniqueID.UniqueID;
@XmlSeeAlso( { Alias.class,
AliasID.class,
FleetsyncID.class,
Esn.class,
Group.class,
MDC1200ID.class,
Min.class,
MPT1327ID.class,
UniqueID.class,
SiteID.class,
StatusID.class,
TalkgroupID.class } )
@XmlRootElement( name = "alias_list" )
public class AliasList implements Comparable<AliasList>
{
private String mName;
private ArrayList<Group> mGroups = new ArrayList<Group>();
private HashMap<String,Alias> mESN = new HashMap<String,Alias>();
private HashMap<String,Alias> mFleetsync = new HashMap<String,Alias>();
private HashMap<String,Alias> mMDC1200 = new HashMap<String,Alias>();
private HashMap<String,Alias> mMobileID = new HashMap<String,Alias>();
private HashMap<String,Alias> mMPT1327 = new HashMap<String,Alias>();
private HashMap<Integer, Alias> mSiteID = new HashMap<Integer,Alias>();
private HashMap<Integer, Alias> mStatus = new HashMap<Integer,Alias>();
private HashMap<String,Alias> mTalkgroup = new HashMap<String,Alias>();
private HashMap<Integer,Alias> mUniqueID = new HashMap<Integer,Alias>();
private boolean mESNWildcard = false;
private boolean mFleetsyncWildcard = false;
private boolean mMDC1200Wildcard = false;
private boolean mMPT1327Wildcard = false;
private boolean mTalkgroupWildcard = false;
public AliasList()
{
this( null );
}
public AliasList( String name )
{
mName = name;
update();
}
/**
* Load/Reload all lookup hashmaps
*/
public void update()
{
//Clear hashmaps
mESN.clear();
mFleetsync.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;
//Replace (*) wildcard with regex wildcard (.)
mESN.put( esn.getEsn().replace( "*", "." ), alias );
}
else
{
mESN.put( esn.getEsn(), alias );
}
break;
case Fleetsync:
FleetsyncID fs = (FleetsyncID)id;
if( fs.getIdent().contains( "*" ) )
{
mFleetsyncWildcard = true;
//Replace (*) wildcard with regex wildcard (.)
mFleetsync.put( fs.getIdent().replace( "*", "." ), alias );
}
else
{
mFleetsync.put( fs.getIdent(), alias );
}
break;
case MDC1200:
MDC1200ID mdc = (MDC1200ID)id;
if( mdc.getIdent().contains( "*" ) )
{
mMDC1200Wildcard = true;
//Replace (*) wildcard with regex wildcard (.)
mMDC1200.put( mdc.getIdent().replace( "*", "." ), 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( ident.replace( "*", "." ), alias );
}
else
{
mMPT1327.put( ident, alias );
}
}
break;
case MIN:
Min min = (Min)id;
mMobileID.put( min.getMin(), alias );
break;
case LTRNetUID:
UniqueID uid = (UniqueID)id;
mUniqueID.put( uid.getUid(), alias );
break;
case Site:
mSiteID.put( ((SiteID)id).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( tgid.getTalkgroup()
.replace( "*", "." ), alias );
}
else
{
mTalkgroup.put( tgid.getTalkgroup(), alias );
}
break;
}
}
}
}
}
public Alias getSiteID( int siteID )
{
return mSiteID.get( siteID );
}
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 )
{
Alias retVal = null;
if( mESNWildcard )
{
for( String key: mESN.keySet() )
{
if( esn.matches( key ) )
{
return mESN.get( key );
}
}
}
else
{
return mESN.get( esn );
}
}
return null;
}
public Alias getFleetsyncAlias( String ident )
{
if( ident != null )
{
Alias retVal = null;
if( mFleetsyncWildcard )
{
for( String key: mFleetsync.keySet() )
{
if( ident.matches( key ) )
{
return mFleetsync.get( key );
}
}
}
else
{
return mFleetsync.get( ident );
}
}
return null;
}
public Alias getMDC1200Alias( String ident )
{
if( ident != null )
{
Alias retVal = null;
if( mMDC1200Wildcard )
{
for( String key: mMDC1200.keySet() )
{
if( ident.matches( key ) )
{
return mMDC1200.get( key );
}
}
}
else
{
return mMDC1200.get( ident );
}
}
return null;
}
public Alias getMPT1327Alias( String ident )
{
if( ident != null )
{
Alias retVal = null;
if( mMPT1327Wildcard )
{
for( String key: mMPT1327.keySet() )
{
if( ident.matches( key ) )
{
return mMPT1327.get( key );
}
}
}
else
{
return mMPT1327.get( ident );
}
}
return null;
}
public Group getGroup( Alias alias )
{
if( alias != null )
{
for( Group group: mGroups )
{
if( group.contians( alias ) )
{
return group;
}
}
}
return null;
}
public Alias getMobileIDNumberAlias( String ident )
{
return mMobileID.get( ident );
}
public Alias getTalkgroupAlias( String tgid )
{
if( tgid != null )
{
Alias retVal = null;
if( mTalkgroupWildcard )
{
for( String key: mTalkgroup.keySet() )
{
if( tgid.matches( key ) )
{
return mTalkgroup.get( key );
}
}
}
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<Group> getGroup()
{
return mGroups;
}
public void setGroup( ArrayList<Group> 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() );
}
}

View File

@@ -0,0 +1,126 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
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 controller.ConfigurableNode;
public class AliasListNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public AliasListNode( AliasList list )
{
super( list );
}
@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( 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( 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;
}
}

373
src/alias/AliasNode.java Normal file
View File

@@ -0,0 +1,373 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
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 javax.swing.JSeparator;
import map.MapIcon;
import alias.esn.ESNNode;
import alias.esn.Esn;
import alias.fleetsync.FleetsyncID;
import alias.fleetsync.FleetsyncIDNode;
import alias.fleetsync.StatusID;
import alias.fleetsync.StatusIDNode;
import alias.mdc.MDC1200ID;
import alias.mdc.MDC1200IDNode;
import alias.mobileID.MINNode;
import alias.mobileID.Min;
import alias.mpt1327.MPT1327ID;
import alias.mpt1327.MPT1327IDNode;
import alias.siteID.SiteID;
import alias.siteID.SiteIDNode;
import alias.talkgroup.TalkgroupID;
import alias.talkgroup.TalkgroupIDNode;
import alias.uniqueID.UniqueID;
import alias.uniqueID.UniqueIDNode;
import controller.ConfigurableNode;
public class AliasNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public AliasNode( Alias alias )
{
super( alias );
}
@Override
public JPanel getEditor()
{
return new AliasEditor( this, getModel().getResourceManager() );
}
public Alias getAlias()
{
return (Alias)getUserObject();
}
public String getIconPath()
{
String icon = getAlias().getIconName();
MapIcon mapIcon = getModel().getResourceManager()
.getSettingsManager().getMapIcon( icon );
if( mapIcon != null )
{
return mapIcon.getPath();
}
else
{
return null;
}
}
public void init()
{
for( AliasID aliasID: getAlias().getId() )
{
if( aliasID instanceof Esn )
{
getModel().addNode( new ESNNode( (Esn)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof FleetsyncID )
{
getModel().addNode( new FleetsyncIDNode( (FleetsyncID)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof MDC1200ID )
{
getModel().addNode( new MDC1200IDNode( (MDC1200ID)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof Min )
{
getModel().addNode( new MINNode( (Min)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof MPT1327ID )
{
getModel().addNode( new MPT1327IDNode( (MPT1327ID)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof SiteID )
{
getModel().addNode( new SiteIDNode( (SiteID)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof StatusID )
{
getModel().addNode( new StatusIDNode( (StatusID)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof TalkgroupID )
{
getModel().addNode( new TalkgroupIDNode( (TalkgroupID)aliasID ),
AliasNode.this, getChildCount() );
}
else if( aliasID instanceof UniqueID )
{
getModel().addNode( new UniqueIDNode( (UniqueID)aliasID ),
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( 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( fs );
getModel().addNode( node,
AliasNode.this,
AliasNode.this.getChildCount() );
node.show();
}
} );
addIDMenu.add( addFleetsyncItem );
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( 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( 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( 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( 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( 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( 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( uid );
getModel().addNode( node,
AliasNode.this,
AliasNode.this.getChildCount() );
node.show();
}
} );
addIDMenu.add( addUniqueIDItem );
retVal.add( addIDMenu );
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 )
{
GroupNode parent = (GroupNode)getParent();
parent.getGroup().removeAlias( getAlias() );
save();
getModel().removeNodeFromParent( AliasNode.this );
}
}
} );
retVal.add( deleteItem );
return retVal;
}
}

73
src/alias/Group.java Normal file
View File

@@ -0,0 +1,73 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAttribute;
public class Group
{
private String mName;
private ArrayList<Alias> mAliases = new ArrayList<Alias>();
public Group()
{
}
public String toString()
{
return "Group: " + mName;
}
@XmlAttribute
public String getName()
{
return mName;
}
public void setName( String name )
{
mName = name;
}
public ArrayList<Alias> getAlias()
{
return mAliases;
}
public void setAlias( ArrayList<Alias> aliases )
{
mAliases = aliases;
}
public void addAlias( Alias alias )
{
mAliases.add( alias );
}
public void removeAlias( Alias alias )
{
mAliases.remove( alias );
}
public boolean contians( Alias alias )
{
return mAliases.contains( alias );
}
}

110
src/alias/GroupEditor.java Normal file
View File

@@ -0,0 +1,110 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
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() );
setBorder( BorderFactory.createTitledBorder( "Group" ) );
mLabelName = new JLabel( "Name:" );
add( mLabelName, "align right" );
mTextGroup = new JTextField( mGroupNode.getGroup().getName() );
add( mTextGroup, "grow, 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();
}
}

126
src/alias/GroupNode.java Normal file
View File

@@ -0,0 +1,126 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
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 controller.ConfigurableNode;
public class GroupNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public GroupNode( Group group )
{
super( group );
}
@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( 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( 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;
}
}

107
src/alias/ListEditor.java Normal file
View File

@@ -0,0 +1,107 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
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() );
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();
}
}

View File

@@ -0,0 +1,100 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.esn;
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 net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class ESNEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private ESNNode mESNNode;
private JLabel mLabelName;
private JTextField mTextESN;
public ESNEditor( ESNNode esnNode )
{
mESNNode = esnNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "ESN" ) );
mLabelName = new JLabel( "ESN:" );
add( mLabelName, "align right" );
mTextESN = new JTextField( mESNNode.getESN().getEsn() );
add( mTextESN, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( ESNEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( ESNEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String esn = mTextESN.getText();
if( esn != null )
{
mESNNode.getESN().setEsn( esn );
((ConfigurableNode)mESNNode.getParent()).sort();
mESNNode.save();
mESNNode.show();
}
else
{
JOptionPane.showMessageDialog( ESNEditor.this, "Please enter an ESN" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextESN.setText( mESNNode.getESN().getEsn() );
}
mESNNode.refresh();
}
}

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class ESNNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public ESNNode( Esn esn )
{
super( esn );
}
@Override
public JPanel getEditor()
{
return new ESNEditor( this );
}
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;
}
}

72
src/alias/esn/Esn.java Normal file
View File

@@ -0,0 +1,72 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.esn;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class Esn extends AliasID
{
private String mEsn;
public Esn()
{
}
@XmlAttribute
public String getEsn()
{
return mEsn;
}
public void setEsn( String esn )
{
mEsn = esn;
}
public String toString()
{
return "ESN: " + mEsn;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( mEsn != null && id instanceof Esn )
{
Esn esn = (Esn)id;
//Create a pattern - replace * wildcards with regex single-char wildcard
String pattern = mEsn.replace( "*", ".?" );
retVal = esn.getEsn().matches( pattern );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.ESN;
}
}

View File

@@ -0,0 +1,73 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.fleetsync;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class FleetsyncID extends AliasID
{
private String mID;
public FleetsyncID()
{
}
@XmlAttribute
public String getIdent()
{
return mID;
}
public void setIdent( String ident )
{
mID = ident;
}
public String toString()
{
return "Fleetsync: " + mID;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( mID != null && id instanceof FleetsyncID )
{
FleetsyncID tgid = (FleetsyncID)id;
//Create a pattern - replace * wildcards with regex single-char wildcard
String pattern = mID.replace( "*", ".?" );
retVal = tgid.getIdent().matches( pattern );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.Fleetsync;
}
}

View File

@@ -0,0 +1,109 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.fleetsync;
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.JTextArea;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class FleetsyncIDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private FleetsyncIDNode mFleetsyncIDNode;
private JLabel mLabelName;
private JTextField mTextIdent;
private String mHelpText = "Enter a formatted fleetsync identifier.\n\n"
+ "Format: PPP-IIII (P=Prefix, I=Identifier)\n\n"
+ "Wildcard: use one or more asterisks (*) for any talkgroup "
+ "digits.\n\n";
public FleetsyncIDEditor( FleetsyncIDNode fsNode )
{
mFleetsyncIDNode = fsNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Fleetsync" ) );
mLabelName = new JLabel( "Ident:" );
add( mLabelName, "align right" );
mTextIdent = new JTextField( mFleetsyncIDNode.getFleetsyncID().getIdent() );
add( mTextIdent, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( FleetsyncIDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( FleetsyncIDEditor.this );
add( btnReset, "wrap" );
JTextArea helpText = new JTextArea( mHelpText );
helpText.setLineWrap( true );
add( helpText, "span,grow" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String ident = mTextIdent.getText();
if( ident != null )
{
mFleetsyncIDNode.getFleetsyncID().setIdent( ident );
((ConfigurableNode)mFleetsyncIDNode.getParent()).sort();
mFleetsyncIDNode.save();
mFleetsyncIDNode.show();
}
else
{
JOptionPane.showMessageDialog( FleetsyncIDEditor.this, "Please enter an ident" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextIdent.setText( mFleetsyncIDNode.getFleetsyncID().getIdent() );
}
mFleetsyncIDNode.refresh();
}
}

View File

@@ -0,0 +1,97 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class FleetsyncIDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public FleetsyncIDNode( FleetsyncID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new FleetsyncIDEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,69 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.fleetsync;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class StatusID extends AliasID
{
private int mStatus;
public StatusID()
{
}
@XmlAttribute
public int getStatus()
{
return mStatus;
}
public void setStatus( int status )
{
this.mStatus = status;
}
public String toString()
{
return "Status: " + mStatus;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( id instanceof StatusID )
{
StatusID statusId = (StatusID)id;
retVal = ( mStatus == statusId.getStatus() );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.Status;
}
}

View File

@@ -0,0 +1,114 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.fleetsync;
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 log.Log;
import net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class StatusIDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private StatusIDNode mStatusIDNode;
private JLabel mLabelName;
private JTextField mTextStatusID;
public StatusIDEditor( StatusIDNode statusIDNode )
{
mStatusIDNode = statusIDNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Status Code" ) );
mLabelName = new JLabel( "Status Code:" );
add( mLabelName, "align right" );
mTextStatusID = new JTextField(
String.valueOf( mStatusIDNode.getStatusID().getStatus() ) );
add( mTextStatusID, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( StatusIDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( StatusIDEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String statusIDString = mTextStatusID.getText();
if( statusIDString != null )
{
try
{
int id = Integer.parseInt( statusIDString );
mStatusIDNode.getStatusID().setStatus( id );
((ConfigurableNode)mStatusIDNode.getParent()).sort();
mStatusIDNode.save();
mStatusIDNode.show();
}
catch( Exception ex )
{
Log.error( "StatusIDEditor - error parsing int status " +
"id from [" + statusIDString + "]" );
}
}
else
{
JOptionPane.showMessageDialog( StatusIDEditor.this,
"Please enter a status ID code" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextStatusID.setText(
String.valueOf( mStatusIDNode.getStatusID().getStatus() ) );
}
mStatusIDNode.refresh();
}
}

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class StatusIDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public StatusIDNode( StatusID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new StatusIDEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,73 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.mdc;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class MDC1200ID extends AliasID
{
private String mID;
public MDC1200ID()
{
}
@XmlAttribute
public String getIdent()
{
return mID;
}
public void setIdent( String ident )
{
mID = ident;
}
public String toString()
{
return "MDC-1200: " + mID;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( mID != null && id instanceof MDC1200ID )
{
MDC1200ID tgid = (MDC1200ID)id;
//Create a pattern - replace * wildcards with regex single-char wildcard
String pattern = mID.replace( "*", ".?" );
retVal = tgid.getIdent().matches( pattern );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.MDC1200;
}
}

View File

@@ -0,0 +1,99 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.mdc;
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 net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class MDC1200IDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private MDC1200IDNode mMDC1200IDNode;
private JLabel mLabelName;
private JTextField mTextIdent;
public MDC1200IDEditor( MDC1200IDNode fsNode )
{
mMDC1200IDNode = fsNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "MDC-1200" ) );
mLabelName = new JLabel( "Unit ID:" );
add( mLabelName, "align right" );
mTextIdent = new JTextField( mMDC1200IDNode.getMDC1200ID().getIdent() );
add( mTextIdent, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( MDC1200IDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( MDC1200IDEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String ident = mTextIdent.getText();
if( ident != null )
{
mMDC1200IDNode.getMDC1200ID().setIdent( ident );
((ConfigurableNode)mMDC1200IDNode.getParent()).sort();
mMDC1200IDNode.save();
mMDC1200IDNode.show();
}
else
{
JOptionPane.showMessageDialog( MDC1200IDEditor.this, "Please enter a unit ID" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextIdent.setText( mMDC1200IDNode.getMDC1200ID().getIdent() );
}
mMDC1200IDNode.refresh();
}
}

View File

@@ -0,0 +1,91 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class MDC1200IDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public MDC1200IDNode( MDC1200ID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new MDC1200IDEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,100 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.mobileID;
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 net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class MINEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private MINNode mMINNode;
private JLabel mLabelName;
private JTextField mTextMIN;
public MINEditor( MINNode minNode )
{
mMINNode = minNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Mobile ID Number (MIN)" ) );
mLabelName = new JLabel( "MIN:" );
add( mLabelName, "align right" );
mTextMIN = new JTextField( mMINNode.getMIN().getMin() );
add( mTextMIN, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( MINEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( MINEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String esn = mTextMIN.getText();
if( esn != null )
{
mMINNode.getMIN().setMin( esn );
((ConfigurableNode)mMINNode.getParent()).sort();
mMINNode.save();
mMINNode.show();
}
else
{
JOptionPane.showMessageDialog( MINEditor.this, "Please enter an ESN" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextMIN.setText( mMINNode.getMIN().getMin() );
}
mMINNode.refresh();
}
}

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class MINNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public MINNode( Min min )
{
super( min );
}
@Override
public JPanel getEditor()
{
return new MINEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,75 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.mobileID;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
/**
* Mobile ID Number
*/
public class Min extends AliasID
{
private String mMin;
public Min()
{
}
@XmlAttribute
public String getMin()
{
return mMin;
}
public void setMin( String min )
{
mMin = min;
}
public String toString()
{
return "MIN: " + mMin;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( mMin != null && id instanceof Min )
{
Min min = (Min)id;
//Create a pattern - replace * wildcards with regex single-char wildcard
String pattern = mMin.replace( "*", ".?" );
retVal = min.getMin().matches( pattern );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.MIN;
}
}

View File

@@ -0,0 +1,72 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.mpt1327;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class MPT1327ID extends AliasID
{
private String mID;
public MPT1327ID()
{
}
@XmlAttribute
public String getIdent()
{
return mID;
}
public void setIdent( String ident )
{
mID = ident;
}
public String toString()
{
return "MPT-1327: " + mID;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( mID != null && id instanceof MPT1327ID )
{
MPT1327ID tgid = (MPT1327ID)id;
//Create a pattern - replace * wildcards with regex single-char wildcard
String pattern = mID.replace( "*", ".?" );
retVal = tgid.getIdent().matches( pattern );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.MPT1327;
}
}

View File

@@ -0,0 +1,99 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.mpt1327;
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 net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class MPT1327IDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private MPT1327IDNode mMPT1327IDNode;
private JLabel mLabelName;
private JTextField mTextIdent;
public MPT1327IDEditor( MPT1327IDNode fsNode )
{
mMPT1327IDNode = fsNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "MPT-1327" ) );
mLabelName = new JLabel( "Unit ID:" );
add( mLabelName, "align right" );
mTextIdent = new JTextField( mMPT1327IDNode.getMPT1327ID().getIdent() );
add( mTextIdent, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( MPT1327IDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( MPT1327IDEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String ident = mTextIdent.getText();
if( ident != null )
{
mMPT1327IDNode.getMPT1327ID().setIdent( ident );
((ConfigurableNode)mMPT1327IDNode.getParent()).sort();
mMPT1327IDNode.save();
mMPT1327IDNode.show();
}
else
{
JOptionPane.showMessageDialog( MPT1327IDEditor.this, "Please enter a MPT1327 unit ID" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextIdent.setText( mMPT1327IDNode.getMPT1327ID().getIdent() );
}
mMPT1327IDNode.refresh();
}
}

View File

@@ -0,0 +1,91 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class MPT1327IDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public MPT1327IDNode( MPT1327ID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new MPT1327IDEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,69 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.siteID;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class SiteID extends AliasID
{
private int mSite;
public SiteID()
{
}
@XmlAttribute
public int getSite()
{
return mSite;
}
public void setSite( int site )
{
this.mSite = site;
}
public String toString()
{
return "Site: " + mSite;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( id instanceof SiteID )
{
SiteID uid = (SiteID)id;
retVal = ( mSite == uid.getSite() );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.Site;
}
}

View File

@@ -0,0 +1,114 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.siteID;
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 log.Log;
import net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class SiteIDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private SiteIDNode mSiteIDNode;
private JLabel mLabelName;
private JTextField mTextSiteID;
public SiteIDEditor( SiteIDNode siteIDNode )
{
mSiteIDNode = siteIDNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Site ID" ) );
mLabelName = new JLabel( "Site ID:" );
add( mLabelName, "align right" );
mTextSiteID = new JTextField(
String.valueOf( mSiteIDNode.getSiteID().getSite() ) );
add( mTextSiteID, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( SiteIDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( SiteIDEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String siteIDString = mTextSiteID.getText();
if( siteIDString != null )
{
try
{
int id = Integer.parseInt( siteIDString );
mSiteIDNode.getSiteID().setSite( id );
((ConfigurableNode)mSiteIDNode.getParent()).sort();
mSiteIDNode.save();
mSiteIDNode.show();
}
catch( Exception ex )
{
Log.error( "SiteIDEditor - error parsing int site " +
"id from [" + siteIDString + "]" );
}
}
else
{
JOptionPane.showMessageDialog( SiteIDEditor.this,
"Please enter a site ID" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextSiteID.setText(
String.valueOf( mSiteIDNode.getSiteID().getSite() ) );
}
mSiteIDNode.refresh();
}
}

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class SiteIDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public SiteIDNode( SiteID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new SiteIDEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,102 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.talkgroup;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
import audio.AudioType;
public class TalkgroupID extends AliasID
{
private String mTalkgroup;
private AudioType mAudioType;
public TalkgroupID()
{
}
@XmlAttribute
public String getTalkgroup()
{
return mTalkgroup;
}
public void setTalkgroup( String talkgroup )
{
mTalkgroup = talkgroup;
}
@XmlAttribute
public AudioType getAudioType()
{
return mAudioType;
}
public void setAudioType( AudioType type )
{
mAudioType = type;
}
public boolean hasAudioType()
{
return mAudioType != null;
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( "Talkgroup: " + mTalkgroup );
if( mAudioType != null )
{
sb.append( " [Audio " );
sb.append( mAudioType.getShortDisplayString() );
sb.append( "]" );
}
return sb.toString();
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( id instanceof TalkgroupID )
{
TalkgroupID tgid = (TalkgroupID)id;
//Create a pattern - replace * wildcards with regex single-char wildcard
String pattern = mTalkgroup.replace( "*", ".?" );
retVal = tgid.getTalkgroup().matches( pattern );
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.Talkgroup;
}
}

View File

@@ -0,0 +1,151 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.talkgroup;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
import audio.AudioType;
import controller.ConfigurableNode;
public class TalkgroupIDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private TalkgroupIDNode mTalkgroupIDNode;
private JLabel mLabelName;
private JTextField mTextTalkgroupID;
private JLabel mLabelAudio;
private JComboBox<AudioType> mComboAudioTypes;
private String mHelpText = "Enter a formatted talkgroup identifier.\n\n"
+ "LTR Talkgroup Format: A-HH-TTT (A=Area, H=Home Repeater, "
+ "T=Talkgroup)\n\n"
+ "Passport Talkgroup Format: xxxxx (up to 5-digit number)\n\n"
+ "Wildcard: use one or more asterisks (*) for any talkgroup digits.\n\n"
+ "Audio: if the talkgroup uses simple frequency inversion, specify"
+ " the inversion frequency from the dropdown list to automatically"
+ " un-invert audio for this specific talkgroup";
public TalkgroupIDEditor( TalkgroupIDNode talkgroupIDNode )
{
mTalkgroupIDNode = talkgroupIDNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Talkgroup ID" ) );
mLabelName = new JLabel( "TGID:" );
add( mLabelName, "align right" );
mTextTalkgroupID = new JTextField();
mTextTalkgroupID.setText( mTalkgroupIDNode.getTalkgroupID().getTalkgroup() );
add( mTextTalkgroupID, "grow, wrap" );
mLabelAudio = new JLabel( "Audio:" );
add( mLabelAudio, "align right" );
mComboAudioTypes = new JComboBox<AudioType>();
mComboAudioTypes.setModel(
new DefaultComboBoxModel<AudioType>( AudioType.values() ) );
AudioType audioType = mTalkgroupIDNode.getTalkgroupID().getAudioType();
if( audioType != null )
{
mComboAudioTypes.setSelectedItem( audioType );
}
add( mComboAudioTypes, "wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( TalkgroupIDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( TalkgroupIDEditor.this );
add( btnReset, "wrap" );
JTextArea helpText = new JTextArea( mHelpText );
helpText.setLineWrap( true );
add( helpText, "span,grow" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String tgid = mTextTalkgroupID.getText();
if( tgid != null )
{
mTalkgroupIDNode.getTalkgroupID().setTalkgroup( tgid );
((ConfigurableNode)mTalkgroupIDNode.getParent()).sort();
AudioType selected = mComboAudioTypes
.getItemAt( mComboAudioTypes.getSelectedIndex() );
if( selected != null )
{
mTalkgroupIDNode.getTalkgroupID().setAudioType( selected );
}
mTalkgroupIDNode.save();
mTalkgroupIDNode.show();
}
else
{
JOptionPane.showMessageDialog( TalkgroupIDEditor.this,
"Please enter a talkgroup ID" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextTalkgroupID.setText(
mTalkgroupIDNode.getTalkgroupID().getTalkgroup() );
mComboAudioTypes.setSelectedItem(
mTalkgroupIDNode.getTalkgroupID().getAudioType() );
}
mTalkgroupIDNode.refresh();
}
}

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class TalkgroupIDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public TalkgroupIDNode( TalkgroupID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new TalkgroupIDEditor( this );
}
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;
}
}

View File

@@ -0,0 +1,69 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.uniqueID;
import javax.xml.bind.annotation.XmlAttribute;
import alias.AliasID;
import alias.AliasIDType;
public class UniqueID extends AliasID
{
private int mUid;
public UniqueID()
{
}
@XmlAttribute
public int getUid()
{
return mUid;
}
public void setUid( int uid )
{
this.mUid = uid;
}
public String toString()
{
return "UniqueID: " + mUid;
}
@Override
public boolean matches( AliasID id )
{
boolean retVal = false;
if( id instanceof UniqueID )
{
UniqueID uid = (UniqueID)id;
retVal = mUid == uid.getUid();
}
return retVal;
}
@Override
public AliasIDType getType()
{
return AliasIDType.LTRNetUID;
}
}

View File

@@ -0,0 +1,114 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.uniqueID;
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 log.Log;
import net.miginfocom.swing.MigLayout;
import controller.ConfigurableNode;
public class UniqueIDEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private UniqueIDNode mUniqueIDNode;
private JLabel mLabelUniqueID;
private JTextField mTextUniqueID;
public UniqueIDEditor( UniqueIDNode uniqueIDNode )
{
mUniqueIDNode = uniqueIDNode;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout() );
setBorder( BorderFactory.createTitledBorder( "Unique ID" ) );
mLabelUniqueID = new JLabel( "Unique ID:" );
add( mLabelUniqueID, "align right" );
mTextUniqueID = new JTextField(
String.valueOf( mUniqueIDNode.getUniqueID().getUid() ) );
add( mTextUniqueID, "grow, wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( UniqueIDEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.addActionListener( UniqueIDEditor.this );
add( btnReset, "wrap" );
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
{
String uid = mTextUniqueID.getText();
if( uid != null )
{
try
{
int uidInt = Integer.parseInt( uid );
mUniqueIDNode.getUniqueID().setUid( uidInt );
((ConfigurableNode)mUniqueIDNode.getParent()).sort();
mUniqueIDNode.save();
mUniqueIDNode.show();
}
catch( Exception ex )
{
Log.error( "UniqueIDEditor - exception trying to parse " +
"int from uid [" + uid + "]" );
}
}
else
{
JOptionPane.showMessageDialog( UniqueIDEditor.this,
"Please enter a site number and unique ID" );
}
}
else if( command.contentEquals( "Reset" ) )
{
mTextUniqueID.setText(
String.valueOf( mUniqueIDNode.getUniqueID().getUid() ) );
}
mUniqueIDNode.refresh();
}
}

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* 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 <http://www.gnu.org/licenses/>
******************************************************************************/
package alias.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 alias.AliasIDNode;
import alias.AliasNode;
public class UniqueIDNode extends AliasIDNode
{
private static final long serialVersionUID = 1L;
public UniqueIDNode( UniqueID id )
{
super( id );
}
@Override
public JPanel getEditor()
{
return new UniqueIDEditor( this );
}
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;
}
}