mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Merges #34 Major redesign of Tuner, Channel and Alias management.
Changes to model, view and controller components and updates all gui editors. Removes the configuration panel and tree and replaces with 3 new panels. Updates playlist.xml to a new playlist_v2.xml format.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,29 +22,44 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import alias.action.AliasAction;
|
||||
import alias.priority.Priority;
|
||||
import audio.inverted.AudioType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
import alias.id.nonrecordable.NonRecordable;
|
||||
import alias.id.priority.Priority;
|
||||
|
||||
@XmlSeeAlso( { AliasID.class, AliasAction.class } )
|
||||
@XmlRootElement( name = "alias" )
|
||||
public class Alias
|
||||
{
|
||||
private String mList;
|
||||
private String mGroup;
|
||||
private String mName;
|
||||
private int mColor;
|
||||
private String mIconName;
|
||||
private ArrayList<AliasID> mAliasIDs = new ArrayList<AliasID>();
|
||||
private List<AliasID> mAliasIDs = new ArrayList<AliasID>();
|
||||
private List<AliasAction> mAliasActions = new ArrayList<AliasAction>();
|
||||
|
||||
public Alias()
|
||||
{
|
||||
}
|
||||
|
||||
public Alias( String name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
@XmlAttribute( name="name" )
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
@@ -55,6 +70,38 @@ public class Alias
|
||||
mName = name;
|
||||
}
|
||||
|
||||
@XmlAttribute( name="list" )
|
||||
public String getList()
|
||||
{
|
||||
return mList;
|
||||
}
|
||||
|
||||
public void setList( String list )
|
||||
{
|
||||
mList = list;
|
||||
}
|
||||
|
||||
public boolean hasList()
|
||||
{
|
||||
return mList != null;
|
||||
}
|
||||
|
||||
@XmlAttribute( name="group" )
|
||||
public String getGroup()
|
||||
{
|
||||
return mGroup;
|
||||
}
|
||||
|
||||
public void setGroup( String group )
|
||||
{
|
||||
mGroup = group;
|
||||
}
|
||||
|
||||
public boolean hasGroup()
|
||||
{
|
||||
return mGroup != null;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public int getColor()
|
||||
{
|
||||
@@ -82,7 +129,8 @@ public class Alias
|
||||
mIconName = iconName;
|
||||
}
|
||||
|
||||
public ArrayList<AliasID> getId()
|
||||
@XmlElement( name="id" )
|
||||
public List<AliasID> getId()
|
||||
{
|
||||
return mAliasIDs;
|
||||
}
|
||||
@@ -102,6 +150,7 @@ public class Alias
|
||||
mAliasIDs.remove( id );
|
||||
}
|
||||
|
||||
@XmlElement( name="action" )
|
||||
public List<AliasAction> getAction()
|
||||
{
|
||||
return mAliasActions;
|
||||
@@ -127,35 +176,10 @@ public class Alias
|
||||
return !mAliasActions.isEmpty();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the priority level of this alias, if defined, or the default priority
|
||||
*/
|
||||
@XmlTransient
|
||||
public int getCallPriority()
|
||||
{
|
||||
for( AliasID id: mAliasIDs )
|
||||
@@ -169,7 +193,7 @@ public class Alias
|
||||
return Priority.DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
public boolean hasPriority()
|
||||
public boolean hasCallPriority()
|
||||
{
|
||||
for( AliasID id: mAliasIDs )
|
||||
{
|
||||
@@ -181,10 +205,35 @@ public class Alias
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or updates the call priority
|
||||
*/
|
||||
public void setCallPriority( int priority )
|
||||
{
|
||||
if( priority == Priority.DO_NOT_MONITOR ||
|
||||
( Priority.MIN_PRIORITY <= priority && priority <= Priority.MAX_PRIORITY ) )
|
||||
{
|
||||
for( AliasID id: mAliasIDs )
|
||||
{
|
||||
if( id.getType() == AliasIDType.Priority )
|
||||
{
|
||||
((Priority)id).setPriority( priority );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If we don't find a priority id, create one
|
||||
Priority p = new Priority();
|
||||
p.setPriority( priority );
|
||||
addAliasID( p );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspects the alias for a non-recordable alias id. Default is true;
|
||||
*/
|
||||
@XmlTransient
|
||||
public boolean isRecordable()
|
||||
{
|
||||
for( AliasID id: getId() )
|
||||
@@ -197,4 +246,41 @@ public class Alias
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or removes the non-recordable alias ID for this alias.
|
||||
*/
|
||||
public void setRecordable( boolean recordable )
|
||||
{
|
||||
if( recordable )
|
||||
{
|
||||
AliasID toRemove = null;
|
||||
|
||||
for( AliasID id: getId() )
|
||||
{
|
||||
if( id.getType() == AliasIDType.NonRecordable )
|
||||
{
|
||||
toRemove = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( toRemove != null )
|
||||
{
|
||||
removeAliasID( toRemove );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( AliasID id: getId() )
|
||||
{
|
||||
if( id.getType() == AliasIDType.NonRecordable )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
addAliasID( new NonRecordable() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
368
src/alias/AliasController.java
Normal file
368
src/alias/AliasController.java
Normal file
@@ -0,0 +1,368 @@
|
||||
package alias;
|
||||
|
||||
import gui.editor.Editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import net.coderazzi.filters.gui.AutoChoices;
|
||||
import net.coderazzi.filters.gui.TableFilterHeader;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
|
||||
public class AliasController extends JPanel
|
||||
implements ActionListener, ListSelectionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private JTable mAliasTable;
|
||||
private TableFilterHeader mTableFilterHeader;
|
||||
private AliasEditor mAliasEditor;
|
||||
private MultipleAliasEditor mMultipleAliasEditor;
|
||||
private JideSplitPane mSplitPane;
|
||||
|
||||
private static final String NEW_ALIAS = "New";
|
||||
private static final String COPY_ALIAS = "Copy";
|
||||
private static final String DELETE_ALIAS = "Delete";
|
||||
|
||||
private JButton mNewButton = new JButton( NEW_ALIAS );
|
||||
private JButton mCopyButton = new JButton( COPY_ALIAS );
|
||||
private JButton mDeleteButton = new JButton( DELETE_ALIAS );
|
||||
|
||||
private IconCellRenderer mIconCellRenderer;
|
||||
|
||||
public AliasController( AliasModel aliasModel, SettingsManager settingsManager )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
|
||||
mAliasEditor = new AliasEditor( mAliasModel, settingsManager );
|
||||
mMultipleAliasEditor = new MultipleAliasEditor( mAliasModel, settingsManager );
|
||||
|
||||
mIconCellRenderer = new IconCellRenderer( settingsManager );
|
||||
|
||||
init();
|
||||
|
||||
mAliasModel.addListener( mAliasEditor );
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0",
|
||||
"[grow,fill]",
|
||||
"[grow,fill]") );
|
||||
|
||||
//System Configuration View and Editor
|
||||
mAliasTable = new JTable( mAliasModel );
|
||||
mAliasTable.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
|
||||
mAliasTable.getSelectionModel().addListSelectionListener( this );
|
||||
mAliasTable.setAutoCreateRowSorter( true );
|
||||
|
||||
mAliasTable.getColumnModel().getColumn( AliasModel.COLUMN_COLOR )
|
||||
.setCellRenderer( new ColorCellRenderer() );
|
||||
|
||||
mAliasTable.getColumnModel().getColumn( AliasModel.COLUMN_ICON )
|
||||
.setCellRenderer( mIconCellRenderer );
|
||||
|
||||
mTableFilterHeader = new TableFilterHeader( mAliasTable, AutoChoices.ENABLED );
|
||||
mTableFilterHeader.setFilterOnUpdates( true );
|
||||
|
||||
JScrollPane tableScroller = new JScrollPane( mAliasTable );
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
|
||||
buttonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]") );
|
||||
|
||||
mNewButton.addActionListener( this );
|
||||
mNewButton.setToolTipText( "Adds a new alias" );
|
||||
buttonsPanel.add( mNewButton );
|
||||
|
||||
mCopyButton.addActionListener( this );
|
||||
mCopyButton.setEnabled( false );
|
||||
mCopyButton.setToolTipText( "Creates a copy of the currently selected alias and adds it" );
|
||||
buttonsPanel.add( mCopyButton );
|
||||
|
||||
mDeleteButton.addActionListener( this );
|
||||
mDeleteButton.setEnabled( false );
|
||||
mDeleteButton.setToolTipText( "Deletes the currently selected alias" );
|
||||
buttonsPanel.add( mDeleteButton );
|
||||
|
||||
JPanel listAndButtonsPanel = new JPanel();
|
||||
|
||||
listAndButtonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill][]") );
|
||||
|
||||
listAndButtonsPanel.add( tableScroller, "wrap" );
|
||||
listAndButtonsPanel.add( buttonsPanel );
|
||||
|
||||
mSplitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
mSplitPane.setDividerSize( 5 );
|
||||
mSplitPane.setShowGripper( true );
|
||||
mSplitPane.add( listAndButtonsPanel );
|
||||
mSplitPane.add( mAliasEditor );
|
||||
|
||||
add( mSplitPane );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the editor argument as the currently visible alias editor
|
||||
*/
|
||||
private void setEditor( Editor<?> editor )
|
||||
{
|
||||
if( mSplitPane.getComponentCount() == 3 )
|
||||
{
|
||||
Component component = mSplitPane.getComponent( 2 );
|
||||
|
||||
if( component instanceof Editor<?> && component != editor )
|
||||
{
|
||||
//Get current divider location so that we can reapply it after
|
||||
//changing out the editors, so that the interface doesn't move
|
||||
int location = mSplitPane.getDividerLocation( 0 );
|
||||
|
||||
((Editor<?>)component).setItem( null );
|
||||
|
||||
mSplitPane.remove( component );
|
||||
editor.setPreferredSize( new Dimension( 100, 100 ) );
|
||||
mSplitPane.add( editor );
|
||||
|
||||
mSplitPane.validate();
|
||||
mSplitPane.setDividerLocation( 0, location );
|
||||
mSplitPane.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Alias getAlias( int selectedRow )
|
||||
{
|
||||
if( selectedRow >= 0 )
|
||||
{
|
||||
int index = mAliasTable.convertRowIndexToModel( selectedRow );
|
||||
|
||||
return mAliasModel.getAliasAtIndex( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
//Limits event firing to only when selection is complete
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int[] selectedRows = mAliasTable.getSelectedRows();
|
||||
|
||||
if( selectedRows.length == 0 )
|
||||
{
|
||||
mAliasEditor.setItem( null );
|
||||
mCopyButton.setEnabled( false );
|
||||
mDeleteButton.setEnabled( false );
|
||||
}
|
||||
else if( selectedRows.length == 1 )
|
||||
{
|
||||
setEditor( mAliasEditor );
|
||||
|
||||
Alias selectedAlias = getAlias( selectedRows[ 0 ] );
|
||||
|
||||
mAliasEditor.setItem( selectedAlias );
|
||||
|
||||
if( selectedAlias != null )
|
||||
{
|
||||
mCopyButton.setEnabled( true );
|
||||
mDeleteButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCopyButton.setEnabled( false );
|
||||
mDeleteButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEditor( mMultipleAliasEditor );
|
||||
|
||||
mCopyButton.setEnabled( true );
|
||||
mDeleteButton.setEnabled( true );
|
||||
|
||||
List<Alias> selectedAliases = new ArrayList<Alias>();
|
||||
|
||||
for( int selectedRow: selectedRows )
|
||||
{
|
||||
Alias alias = getAlias( selectedRow );
|
||||
|
||||
selectedAliases.add( alias );
|
||||
}
|
||||
|
||||
mMultipleAliasEditor.setItem( selectedAliases );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the alias to the alias table/model and scrolls the view it
|
||||
*/
|
||||
private void addAlias( Alias alias )
|
||||
{
|
||||
//HACK: when inserting a row to the model, the JTable gets
|
||||
//notified and attempts to tell the coderazzi table filter
|
||||
//adaptive choices filter to refresh before the table filter is
|
||||
//notified of the row additions, causing an index out of bounds
|
||||
//exception. We turn off adaptive choices temporarily, add the
|
||||
//channel, and turn on adaptive choices again.
|
||||
mTableFilterHeader.setAdaptiveChoices( false );
|
||||
|
||||
int index = mAliasModel.addAlias( alias );
|
||||
|
||||
mTableFilterHeader.setAdaptiveChoices( true );
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
int translatedIndex = mAliasTable.convertRowIndexToView( index );
|
||||
mAliasTable.setRowSelectionInterval( translatedIndex, translatedIndex );
|
||||
mAliasTable.scrollRectToVisible(
|
||||
new Rectangle( mAliasTable.getCellRect( translatedIndex, 0, true ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
private List<Alias> getSelectedAliases()
|
||||
{
|
||||
List<Alias> selected = new ArrayList<>();
|
||||
|
||||
int[] rows = mAliasTable.getSelectedRows();
|
||||
|
||||
for( int row: rows )
|
||||
{
|
||||
if( row >= 0 )
|
||||
{
|
||||
Alias alias = mAliasModel.getAliasAtIndex( mAliasTable.convertRowIndexToModel( row ) );
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
selected.add( alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to New, Copy and Delete Channel button invocations
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent event )
|
||||
{
|
||||
switch( event.getActionCommand() )
|
||||
{
|
||||
case NEW_ALIAS:
|
||||
addAlias( new Alias( "New Alias" ) );
|
||||
break;
|
||||
case COPY_ALIAS:
|
||||
for( Alias alias: getSelectedAliases() )
|
||||
{
|
||||
addAlias( AliasFactory.copyOf( alias ) );
|
||||
}
|
||||
break;
|
||||
case DELETE_ALIAS:
|
||||
List<Alias> toDelete = getSelectedAliases();
|
||||
|
||||
if( toDelete != null && !toDelete.isEmpty() )
|
||||
{
|
||||
String title = toDelete.size() == 1 ? "Delete Alias?" : "Delete Aliases?";
|
||||
String prompt = toDelete.size() == 1 ? "Do you want to delete this alias?" :
|
||||
"Do you want to delete these " + toDelete.size() + " aliases?";
|
||||
|
||||
int choice = JOptionPane.showConfirmDialog( AliasController.this,
|
||||
prompt, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
for( Alias alias: toDelete )
|
||||
{
|
||||
mAliasModel.removeAlias( alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorizes the cell based on the cell's integer value
|
||||
*/
|
||||
public class ColorCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column )
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent( table,
|
||||
value, isSelected, hasFocus, row, column );
|
||||
|
||||
label.setBackground( new Color( (int)value ) );
|
||||
|
||||
label.setText( "" );
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays cell's icon and name
|
||||
*/
|
||||
public class IconCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public IconCellRenderer( SettingsManager settingsManager )
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column )
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent( table,
|
||||
value, isSelected, hasFocus, row, column );
|
||||
|
||||
ImageIcon icon = mSettingsManager.getImageIcon( label.getText(), 12 );
|
||||
|
||||
if( icon != null )
|
||||
{
|
||||
label.setIcon( icon );
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,189 +17,146 @@
|
||||
******************************************************************************/
|
||||
package alias;
|
||||
|
||||
import gui.editor.Editor;
|
||||
|
||||
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 javax.swing.JSeparator;
|
||||
|
||||
import map.MapIcon;
|
||||
import map.MapIconListCellRenderer;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
import controller.ConfigurableNode;
|
||||
import controller.ResourceManager;
|
||||
import alias.action.AliasActionEditor;
|
||||
import alias.id.AliasIdentifierEditor;
|
||||
|
||||
public class AliasEditor extends JPanel implements ActionListener
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
public class AliasEditor extends Editor<Alias>
|
||||
implements ActionListener, Listener<AliasEvent>
|
||||
{
|
||||
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 static final String DEFAULT_NAME = "select an alias";
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
|
||||
private void initGUI()
|
||||
private JLabel mAliasLabel;
|
||||
private AliasNameEditor mAliasNameEditor;
|
||||
private AliasIdentifierEditor mAliasIdentifierEditor;
|
||||
private AliasActionEditor mAliasActionEditor;
|
||||
|
||||
public AliasEditor( AliasModel aliasModel, SettingsManager settingsManager )
|
||||
{
|
||||
setLayout( new MigLayout( "", "[right][grow,fill]", "[][][][][][grow][]" ) );
|
||||
mAliasModel = aliasModel;
|
||||
mAliasNameEditor = new AliasNameEditor( mAliasModel, settingsManager );
|
||||
mAliasIdentifierEditor = new AliasIdentifierEditor( aliasModel );
|
||||
mAliasActionEditor = new AliasActionEditor( aliasModel );
|
||||
|
||||
mAliasModel.addListener( this );
|
||||
|
||||
setBorder( BorderFactory.createTitledBorder( "Alias" ) );
|
||||
init();
|
||||
}
|
||||
|
||||
mLabelName = new JLabel( "Name:" );
|
||||
add( mLabelName );
|
||||
|
||||
@Override
|
||||
public void setItem( Alias alias )
|
||||
{
|
||||
super.setItem( alias );
|
||||
|
||||
mTextAlias = new JTextField( mAliasNode.getAlias().getName() );
|
||||
add( mTextAlias, "wrap" );
|
||||
|
||||
mLabelMapColor = new JLabel( "Map Color:" );
|
||||
add( mLabelMapColor );
|
||||
|
||||
mButtonColor = new JButton( "Map Color" );
|
||||
mButtonColor.setBackground( mAliasNode.getAlias().getMapColor() );
|
||||
mButtonColor.setForeground( mAliasNode.getAlias().getMapColor() );
|
||||
mButtonColor.addActionListener( new ActionListener()
|
||||
if( hasItem() )
|
||||
{
|
||||
@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( "Icon:" ) );
|
||||
|
||||
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 )
|
||||
mAliasLabel.setText( getItem().getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
iconName = SettingsManager.DEFAULT_ICON;
|
||||
mAliasLabel.setText( DEFAULT_NAME );
|
||||
}
|
||||
|
||||
MapIcon savedIcon = mResourceManager.getSettingsManager()
|
||||
.getMapIcon( iconName );
|
||||
mAliasNameEditor.setItem( alias );
|
||||
mAliasIdentifierEditor.setItem( alias );
|
||||
mAliasActionEditor.setItem( alias );
|
||||
}
|
||||
|
||||
if( savedIcon != null )
|
||||
{
|
||||
mComboMapIcon.setSelectedItem( savedIcon );
|
||||
}
|
||||
|
||||
add( mComboMapIcon, "wrap" );
|
||||
|
||||
//Dummy place holder
|
||||
add( new JLabel() );
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[grow,fill][grow,fill]",
|
||||
"[][][][][][grow,fill]" ) );
|
||||
|
||||
mBtnIconManager = new JButton( "Icon Manager" );
|
||||
mBtnIconManager.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
mResourceManager.getController().showIconManager();
|
||||
}
|
||||
} );
|
||||
add( mBtnIconManager, "span 2,wrap" );
|
||||
add( new JLabel( "Alias:" ), "align right" );
|
||||
mAliasLabel = new JLabel( DEFAULT_NAME );
|
||||
add( mAliasLabel, "align left" );
|
||||
|
||||
add( new JSeparator( JSeparator.HORIZONTAL ), "span,growx,push" );
|
||||
|
||||
JideTabbedPane tabs = new JideTabbedPane();
|
||||
tabs.setFont( this.getFont() );
|
||||
tabs.setForeground( Color.BLACK );
|
||||
|
||||
tabs.addTab( "Alias", mAliasNameEditor );
|
||||
tabs.addTab( "Audio / Identifier", mAliasIdentifierEditor );
|
||||
tabs.addTab( "Action", mAliasActionEditor );
|
||||
add( tabs, "span,grow" );
|
||||
|
||||
//Playlist management buttons
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.setToolTipText( "Save alias changes to the playlist" );
|
||||
btnSave.addActionListener( AliasEditor.this );
|
||||
add( btnSave );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.setToolTipText( "Reset alias changes since last save" );
|
||||
btnReset.addActionListener( AliasEditor.this );
|
||||
add( btnReset, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( AliasEvent event )
|
||||
{
|
||||
//If this is the currently displayed alias, reload it
|
||||
if( hasItem() && getItem() == event.getAlias() )
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case CHANGE:
|
||||
//Alias changed - reset the editor with changed alias
|
||||
setItem( event.getAlias() );
|
||||
break;
|
||||
case DELETE:
|
||||
setItem( null );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
if( hasItem() )
|
||||
{
|
||||
String alias = mTextAlias.getText();
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( alias != null )
|
||||
if( command.contentEquals( "Save" ) )
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
save();
|
||||
}
|
||||
else
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
{
|
||||
JOptionPane.showMessageDialog( AliasEditor.this, "Please enter an alias name" );
|
||||
reset();
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
mAliasNameEditor.save();
|
||||
mAliasIdentifierEditor.save();
|
||||
mAliasActionEditor.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,25 +17,39 @@
|
||||
******************************************************************************/
|
||||
package alias;
|
||||
|
||||
import audio.inverted.AudioType;
|
||||
|
||||
public abstract class AliasID
|
||||
public class AliasEvent
|
||||
{
|
||||
public AliasID()
|
||||
private Alias mAlias;
|
||||
private Event mEvent;
|
||||
|
||||
/**
|
||||
* AliasEvent - event describing any changes to an alias
|
||||
* @param alias - alias that changed
|
||||
* @param event - change event
|
||||
*/
|
||||
public AliasEvent( Alias alias, Event event )
|
||||
{
|
||||
mAlias = alias;
|
||||
mEvent = event;
|
||||
}
|
||||
|
||||
public abstract AliasIDType getType();
|
||||
|
||||
public boolean hasAudioType()
|
||||
public Alias getAlias()
|
||||
{
|
||||
return false;
|
||||
return mAlias;
|
||||
}
|
||||
|
||||
public AudioType getAudioType()
|
||||
public Event getEvent()
|
||||
{
|
||||
return AudioType.NORMAL;
|
||||
return mEvent;
|
||||
}
|
||||
|
||||
public abstract boolean matches( AliasID id );
|
||||
/**
|
||||
* Channel events to describe the specific event
|
||||
*/
|
||||
public enum Event
|
||||
{
|
||||
ADD,
|
||||
CHANGE,
|
||||
DELETE;
|
||||
}
|
||||
}
|
||||
292
src/alias/AliasFactory.java
Normal file
292
src/alias/AliasFactory.java
Normal file
@@ -0,0 +1,292 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias;
|
||||
|
||||
import gui.editor.Editor;
|
||||
import gui.editor.EmptyEditor;
|
||||
import alias.action.AliasAction;
|
||||
import alias.action.AliasActionType;
|
||||
import alias.action.beep.BeepAction;
|
||||
import alias.action.beep.BeepActionEditor;
|
||||
import alias.action.clip.ClipAction;
|
||||
import alias.action.clip.ClipActionEditor;
|
||||
import alias.action.script.ScriptAction;
|
||||
import alias.action.script.ScriptActionEditor;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
import alias.id.esn.ESNEditor;
|
||||
import alias.id.esn.Esn;
|
||||
import alias.id.fleetsync.FleetsyncID;
|
||||
import alias.id.fleetsync.FleetsyncIDEditor;
|
||||
import alias.id.lojack.LoJackFunctionAndID;
|
||||
import alias.id.lojack.LoJackIDEditor;
|
||||
import alias.id.mdc.MDC1200ID;
|
||||
import alias.id.mdc.MDC1200IDEditor;
|
||||
import alias.id.mobileID.MINEditor;
|
||||
import alias.id.mobileID.Min;
|
||||
import alias.id.mpt1327.MPT1327ID;
|
||||
import alias.id.mpt1327.MPT1327IDEditor;
|
||||
import alias.id.nonrecordable.NonRecordable;
|
||||
import alias.id.nonrecordable.NonRecordableEditor;
|
||||
import alias.id.priority.Priority;
|
||||
import alias.id.priority.PriorityEditor;
|
||||
import alias.id.siteID.SiteID;
|
||||
import alias.id.siteID.SiteIDEditor;
|
||||
import alias.id.status.StatusID;
|
||||
import alias.id.status.StatusIDEditor;
|
||||
import alias.id.talkgroup.TalkgroupID;
|
||||
import alias.id.talkgroup.TalkgroupIDEditor;
|
||||
import alias.id.uniqueID.UniqueID;
|
||||
import alias.id.uniqueID.UniqueIDEditor;
|
||||
|
||||
public class AliasFactory
|
||||
{
|
||||
public static AliasID copyOf( AliasID id )
|
||||
{
|
||||
switch( id.getType() )
|
||||
{
|
||||
case ESN:
|
||||
Esn originalESN = (Esn)id;
|
||||
Esn copyESN = new Esn();
|
||||
copyESN.setEsn( originalESN.getEsn() );
|
||||
return copyESN;
|
||||
case Fleetsync:
|
||||
FleetsyncID originalFleetsyncID = (FleetsyncID)id;
|
||||
FleetsyncID copyFleetsyncID = new FleetsyncID();
|
||||
copyFleetsyncID.setIdent( originalFleetsyncID.getIdent() );
|
||||
return copyFleetsyncID;
|
||||
case LTRNetUID:
|
||||
UniqueID originalUniqueID = (UniqueID)id;
|
||||
UniqueID copyUniqueID = new UniqueID();
|
||||
copyUniqueID.setUid( originalUniqueID.getUid() );
|
||||
return copyUniqueID;
|
||||
case LoJack:
|
||||
LoJackFunctionAndID originalLoJackFunctionAndID = (LoJackFunctionAndID)id;
|
||||
LoJackFunctionAndID copyLoJackFunctionAndID = new LoJackFunctionAndID();
|
||||
copyLoJackFunctionAndID.setFunction( originalLoJackFunctionAndID.getFunction() );
|
||||
copyLoJackFunctionAndID.setID( originalLoJackFunctionAndID.getID() );
|
||||
return copyLoJackFunctionAndID;
|
||||
case MDC1200:
|
||||
MDC1200ID originalMDC1200ID = (MDC1200ID)id;
|
||||
MDC1200ID copyMDC1200ID = new MDC1200ID();
|
||||
copyMDC1200ID.setIdent( originalMDC1200ID.getIdent() );
|
||||
return copyMDC1200ID;
|
||||
case MIN:
|
||||
Min originalMin = (Min)id;
|
||||
Min copyMin = new Min();
|
||||
copyMin.setMin( originalMin.getMin() );
|
||||
return copyMin;
|
||||
case MPT1327:
|
||||
MPT1327ID originalMPT1327ID = (MPT1327ID)id;
|
||||
MPT1327ID copyMPT1327ID = new MPT1327ID();
|
||||
copyMPT1327ID.setIdent( originalMPT1327ID.getIdent() );
|
||||
return copyMPT1327ID;
|
||||
case NonRecordable:
|
||||
return new NonRecordable();
|
||||
case Priority:
|
||||
Priority originalPriority = (Priority)id;
|
||||
Priority copyPriority = new Priority();
|
||||
copyPriority.setPriority( originalPriority.getPriority() );
|
||||
return copyPriority;
|
||||
case Site:
|
||||
SiteID originalSiteID = (SiteID)id;
|
||||
SiteID copySiteID = new SiteID();
|
||||
copySiteID.setSite( originalSiteID.getSite() );
|
||||
return copySiteID;
|
||||
case Talkgroup:
|
||||
TalkgroupID originalTalkgroupID = (TalkgroupID)id;
|
||||
TalkgroupID copyTalkgroupID = new TalkgroupID();
|
||||
copyTalkgroupID.setTalkgroup( originalTalkgroupID.getTalkgroup() );
|
||||
return copyTalkgroupID;
|
||||
case Status:
|
||||
StatusID originalStatusID = (StatusID)id;
|
||||
StatusID copyStatusID = new StatusID();
|
||||
copyStatusID.setStatus( originalStatusID.getStatus() );
|
||||
return copyStatusID;
|
||||
default:
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AliasAction copyOf( AliasAction action )
|
||||
{
|
||||
if( action instanceof BeepAction )
|
||||
{
|
||||
return new BeepAction();
|
||||
}
|
||||
else if( action instanceof ClipAction )
|
||||
{
|
||||
ClipAction originalClip = (ClipAction)action;
|
||||
ClipAction copyClip = new ClipAction();
|
||||
copyClip.setInterval( originalClip.getInterval() );
|
||||
copyClip.setPath( originalClip.getPath() );
|
||||
copyClip.setPeriod( originalClip.getPeriod() );
|
||||
return copyClip;
|
||||
}
|
||||
else if( action instanceof ScriptAction )
|
||||
{
|
||||
ScriptAction originalScript = (ScriptAction)action;
|
||||
ScriptAction copyScript = new ScriptAction();
|
||||
copyScript.setInterval( originalScript.getInterval() );
|
||||
copyScript.setPeriod( originalScript.getPeriod() );
|
||||
copyScript.setScript( originalScript.getScript() );
|
||||
return copyScript;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Alias copyOf( Alias original )
|
||||
{
|
||||
Alias copy = new Alias( original.getName() );
|
||||
copy.setList( original.getList() );
|
||||
copy.setGroup( original.getGroup() );
|
||||
copy.setColor( original.getColor() );
|
||||
copy.setIconName( original.getIconName() );
|
||||
|
||||
for( AliasID id: original.getId() )
|
||||
{
|
||||
AliasID copyID = copyOf( id );
|
||||
|
||||
if( copyID != null )
|
||||
{
|
||||
copy.addAliasID( copyID );
|
||||
}
|
||||
}
|
||||
|
||||
for( AliasAction action: original.getAction() )
|
||||
{
|
||||
AliasAction copyAction = copyOf( action );
|
||||
|
||||
if( copyAction != null )
|
||||
{
|
||||
copy.addAliasAction( copyAction );
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static Editor<AliasID> getEditor( AliasID aliasID )
|
||||
{
|
||||
if( aliasID != null )
|
||||
{
|
||||
switch( aliasID.getType() )
|
||||
{
|
||||
case ESN:
|
||||
return new ESNEditor( aliasID );
|
||||
case Fleetsync:
|
||||
return new FleetsyncIDEditor( aliasID );
|
||||
case LTRNetUID:
|
||||
return new UniqueIDEditor( aliasID );
|
||||
case LoJack:
|
||||
return new LoJackIDEditor( aliasID );
|
||||
case MDC1200:
|
||||
return new MDC1200IDEditor( aliasID );
|
||||
case MIN:
|
||||
return new MINEditor( aliasID );
|
||||
case MPT1327:
|
||||
return new MPT1327IDEditor( aliasID );
|
||||
case NonRecordable:
|
||||
return new NonRecordableEditor( aliasID );
|
||||
case Priority:
|
||||
return new PriorityEditor( aliasID );
|
||||
case Site:
|
||||
return new SiteIDEditor( aliasID );
|
||||
case Status:
|
||||
return new StatusIDEditor( aliasID );
|
||||
case Talkgroup:
|
||||
return new TalkgroupIDEditor( aliasID );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new EmptyEditor<AliasID>();
|
||||
}
|
||||
|
||||
public static Editor<AliasAction> getEditor( AliasAction aliasAction )
|
||||
{
|
||||
if( aliasAction != null )
|
||||
{
|
||||
switch( aliasAction.getType() )
|
||||
{
|
||||
case BEEP:
|
||||
return new BeepActionEditor( aliasAction );
|
||||
case CLIP:
|
||||
return new ClipActionEditor( aliasAction );
|
||||
case SCRIPT:
|
||||
return new ScriptActionEditor( aliasAction );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new EmptyEditor<AliasAction>();
|
||||
}
|
||||
|
||||
public static AliasID getAliasID( AliasIDType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case ESN:
|
||||
return new Esn();
|
||||
case Fleetsync:
|
||||
return new FleetsyncID();
|
||||
case LTRNetUID:
|
||||
return new UniqueID();
|
||||
case LoJack:
|
||||
return new LoJackFunctionAndID();
|
||||
case MDC1200:
|
||||
return new MDC1200ID();
|
||||
case MIN:
|
||||
return new Min();
|
||||
case MPT1327:
|
||||
return new MPT1327ID();
|
||||
case NonRecordable:
|
||||
return new NonRecordable();
|
||||
case Priority:
|
||||
return new Priority();
|
||||
case Site:
|
||||
return new SiteID();
|
||||
case Status:
|
||||
return new StatusID();
|
||||
case Talkgroup:
|
||||
return new TalkgroupID();
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized Alias ID type: " + type );
|
||||
}
|
||||
}
|
||||
|
||||
public static AliasAction getAliasAction( AliasActionType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case BEEP:
|
||||
return new BeepAction();
|
||||
case CLIP:
|
||||
return new ClipAction();
|
||||
case SCRIPT:
|
||||
return new ScriptAction();
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized Alias Action type: " + type );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,69 +19,35 @@ package alias;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
import module.decode.lj1200.LJ1200Message.Function;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.action.AliasAction;
|
||||
import alias.action.beep.BeepAction;
|
||||
import alias.action.clip.ClipAction;
|
||||
import alias.action.script.ScriptAction;
|
||||
import sample.Listener;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.esn.Esn;
|
||||
import alias.id.fleetsync.FleetsyncID;
|
||||
import alias.id.fleetsync.StatusID;
|
||||
import alias.id.lojack.LoJackFunctionAndID;
|
||||
import alias.id.mdc.MDC1200ID;
|
||||
import alias.id.mobileID.Min;
|
||||
import alias.id.mpt1327.MPT1327ID;
|
||||
import alias.id.siteID.SiteID;
|
||||
import alias.id.status.StatusID;
|
||||
import alias.id.talkgroup.TalkgroupID;
|
||||
import alias.id.uniqueID.UniqueID;
|
||||
import alias.priority.Priority;
|
||||
import alias.record.NonRecordable;
|
||||
import audio.metadata.MetadataType;
|
||||
|
||||
@XmlSeeAlso( { Alias.class,
|
||||
|
||||
/* Alias ID's */
|
||||
AliasID.class,
|
||||
FleetsyncID.class,
|
||||
Esn.class,
|
||||
Group.class,
|
||||
LoJackFunctionAndID.class,
|
||||
MDC1200ID.class,
|
||||
Min.class,
|
||||
MPT1327ID.class,
|
||||
UniqueID.class,
|
||||
SiteID.class,
|
||||
StatusID.class,
|
||||
TalkgroupID.class,
|
||||
|
||||
/* Alias Attributes */
|
||||
NonRecordable.class,
|
||||
Priority.class,
|
||||
|
||||
/* Alias Actions */
|
||||
AliasAction.class,
|
||||
BeepAction.class,
|
||||
ClipAction.class,
|
||||
ScriptAction.class } )
|
||||
|
||||
@XmlRootElement( name = "alias_list" )
|
||||
public class AliasList implements Comparable<AliasList>
|
||||
public class AliasList implements Listener<AliasEvent>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( AliasList.class );
|
||||
|
||||
private String mName;
|
||||
private ArrayList<Group> mGroups = new ArrayList<Group>();
|
||||
|
||||
private List<Alias> mAliases = new ArrayList<>();
|
||||
private Map<String,Alias> mESN = new HashMap<>();
|
||||
private Map<String,Alias> mFleetsync = new HashMap<>();
|
||||
private Map<LoJackFunctionAndID,Alias> mLoJack = new HashMap<>();
|
||||
@@ -101,167 +67,326 @@ public class AliasList implements Comparable<AliasList>
|
||||
private boolean mSiteWildcard = false;
|
||||
private boolean mTalkgroupWildcard = false;
|
||||
|
||||
public AliasList()
|
||||
{
|
||||
this( null );
|
||||
}
|
||||
private String mName;
|
||||
|
||||
/**
|
||||
* List of aliases where all aliases share the same list name. Contains
|
||||
* several methods for alias lookup from identifier values, like talkgroups.
|
||||
*
|
||||
* Responds to alias change events to keep the internal alias list updated.
|
||||
*/
|
||||
public AliasList( String name )
|
||||
{
|
||||
mName = name;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load/Reload all lookup hashmaps
|
||||
* Adds the alias to this list
|
||||
*/
|
||||
public void update()
|
||||
public void addAlias( Alias alias )
|
||||
{
|
||||
//Clear hashmaps
|
||||
mESN.clear();
|
||||
mFleetsync.clear();
|
||||
mLoJack.clear();
|
||||
mMDC1200.clear();
|
||||
mMobileID.clear();
|
||||
mMPT1327.clear();
|
||||
mSiteID.clear();
|
||||
mStatus.clear();
|
||||
mTalkgroup.clear();
|
||||
mUniqueID.clear();
|
||||
|
||||
for( Group group: mGroups )
|
||||
if( alias != null )
|
||||
{
|
||||
for( Alias alias: group.getAlias() )
|
||||
mAliases.add( alias );
|
||||
|
||||
for( AliasID aliasID: alias.getId() )
|
||||
{
|
||||
for( AliasID id: alias.getId() )
|
||||
addAliasID( aliasID, alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the alias and alias identifier to the internal type mapping.
|
||||
*/
|
||||
private void addAliasID( AliasID id, Alias alias )
|
||||
{
|
||||
switch( id.getType() )
|
||||
{
|
||||
case ESN:
|
||||
Esn esn = (Esn)id;
|
||||
if( esn.getEsn().contains( "*" ) )
|
||||
{
|
||||
switch( id.getType() )
|
||||
mESNWildcard = true;
|
||||
|
||||
mESN.put( fixWildcard( esn.getEsn() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mESN.put( esn.getEsn(), alias );
|
||||
}
|
||||
break;
|
||||
case Fleetsync:
|
||||
FleetsyncID fs = (FleetsyncID)id;
|
||||
|
||||
if( fs.getIdent().contains( "*" ) )
|
||||
{
|
||||
mFleetsyncWildcard = true;
|
||||
|
||||
mFleetsync.put( fixWildcard( fs.getIdent() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFleetsync.put( fs.getIdent(), alias );
|
||||
}
|
||||
break;
|
||||
case LoJack:
|
||||
mLoJack.put( (LoJackFunctionAndID)id, alias );
|
||||
break;
|
||||
case MDC1200:
|
||||
MDC1200ID mdc = (MDC1200ID)id;
|
||||
|
||||
if( mdc.getIdent().contains( "*" ) )
|
||||
{
|
||||
mMDC1200Wildcard = true;
|
||||
|
||||
//Replace (*) wildcard with regex wildcard (.)
|
||||
mMDC1200.put( fixWildcard( mdc.getIdent() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMDC1200.put( mdc.getIdent(), alias );
|
||||
}
|
||||
break;
|
||||
case MPT1327:
|
||||
MPT1327ID mpt = (MPT1327ID)id;
|
||||
|
||||
String ident = mpt.getIdent();
|
||||
|
||||
if( ident != null )
|
||||
{
|
||||
if( ident.contains( "*" ) )
|
||||
{
|
||||
case ESN:
|
||||
Esn esn = (Esn)id;
|
||||
if( esn.getEsn().contains( "*" ) )
|
||||
{
|
||||
mESNWildcard = true;
|
||||
|
||||
mESN.put( fixWildcard( esn.getEsn() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mESN.put( esn.getEsn(), alias );
|
||||
}
|
||||
break;
|
||||
case Fleetsync:
|
||||
FleetsyncID fs = (FleetsyncID)id;
|
||||
|
||||
if( fs.getIdent().contains( "*" ) )
|
||||
{
|
||||
mFleetsyncWildcard = true;
|
||||
|
||||
mFleetsync.put( fixWildcard( fs.getIdent() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFleetsync.put( fs.getIdent(), alias );
|
||||
}
|
||||
break;
|
||||
case LoJack:
|
||||
mLoJack.put( (LoJackFunctionAndID)id, alias );
|
||||
break;
|
||||
case MDC1200:
|
||||
MDC1200ID mdc = (MDC1200ID)id;
|
||||
|
||||
if( mdc.getIdent().contains( "*" ) )
|
||||
{
|
||||
mMDC1200Wildcard = true;
|
||||
|
||||
//Replace (*) wildcard with regex wildcard (.)
|
||||
mMDC1200.put( fixWildcard( mdc.getIdent() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMDC1200.put( mdc.getIdent(), alias );
|
||||
}
|
||||
break;
|
||||
case MPT1327:
|
||||
MPT1327ID mpt = (MPT1327ID)id;
|
||||
|
||||
String ident = mpt.getIdent();
|
||||
|
||||
if( ident != null )
|
||||
{
|
||||
if( ident.contains( "*" ) )
|
||||
{
|
||||
mMPT1327Wildcard = true;
|
||||
|
||||
//Replace (*) wildcard with regex wildcard (.)
|
||||
mMPT1327.put( fixWildcard( ident ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMPT1327.put( ident, alias );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MIN:
|
||||
Min min = (Min)id;
|
||||
|
||||
if( min.getMin().contains( "*" ) )
|
||||
{
|
||||
mMobileIDWildcard = true;
|
||||
mMobileID.put( fixWildcard( min.getMin() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMobileID.put( min.getMin(), alias );
|
||||
}
|
||||
break;
|
||||
case LTRNetUID:
|
||||
UniqueID uid = (UniqueID)id;
|
||||
|
||||
mUniqueID.put( uid.getUid(), alias );
|
||||
break;
|
||||
case Site:
|
||||
SiteID siteID = (SiteID)id;
|
||||
|
||||
if( siteID.getSite().contains( "*" ) )
|
||||
{
|
||||
mSiteWildcard = true;
|
||||
mSiteID.put( fixWildcard( siteID.getSite() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mSiteID.put( siteID.getSite(), alias );
|
||||
}
|
||||
|
||||
break;
|
||||
case Status:
|
||||
mStatus.put( ((StatusID)id).getStatus(), alias );
|
||||
break;
|
||||
case Talkgroup:
|
||||
TalkgroupID tgid = (TalkgroupID)id;
|
||||
|
||||
if( tgid.getTalkgroup().contains( "*" ) )
|
||||
{
|
||||
mTalkgroupWildcard = true;
|
||||
|
||||
//Replace (*) wildcard with regex wildcard (.)
|
||||
mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTalkgroup.put( tgid.getTalkgroup(), alias );
|
||||
}
|
||||
break;
|
||||
case NonRecordable:
|
||||
case Priority:
|
||||
//We don't maintain lookups for these items
|
||||
break;
|
||||
default:
|
||||
mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() );
|
||||
break;
|
||||
mMPT1327Wildcard = true;
|
||||
|
||||
//Replace (*) wildcard with regex wildcard (.)
|
||||
mMPT1327.put( fixWildcard( ident ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMPT1327.put( ident, alias );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MIN:
|
||||
Min min = (Min)id;
|
||||
|
||||
if( min.getMin().contains( "*" ) )
|
||||
{
|
||||
mMobileIDWildcard = true;
|
||||
mMobileID.put( fixWildcard( min.getMin() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mMobileID.put( min.getMin(), alias );
|
||||
}
|
||||
break;
|
||||
case LTRNetUID:
|
||||
UniqueID uid = (UniqueID)id;
|
||||
|
||||
mUniqueID.put( uid.getUid(), alias );
|
||||
break;
|
||||
case Site:
|
||||
SiteID siteID = (SiteID)id;
|
||||
|
||||
if( siteID.getSite().contains( "*" ) )
|
||||
{
|
||||
mSiteWildcard = true;
|
||||
mSiteID.put( fixWildcard( siteID.getSite() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mSiteID.put( siteID.getSite(), alias );
|
||||
}
|
||||
|
||||
break;
|
||||
case Status:
|
||||
mStatus.put( ((StatusID)id).getStatus(), alias );
|
||||
break;
|
||||
case Talkgroup:
|
||||
TalkgroupID tgid = (TalkgroupID)id;
|
||||
|
||||
if( tgid.getTalkgroup().contains( "*" ) )
|
||||
{
|
||||
mTalkgroupWildcard = true;
|
||||
|
||||
//Replace (*) wildcard with regex wildcard (.)
|
||||
mTalkgroup.put( fixWildcard( tgid.getTalkgroup() ), alias );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTalkgroup.put( tgid.getTalkgroup(), alias );
|
||||
}
|
||||
break;
|
||||
case NonRecordable:
|
||||
case Priority:
|
||||
//We don't maintain lookups for these items
|
||||
break;
|
||||
default:
|
||||
mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the alias from this list
|
||||
*/
|
||||
public void removeAlias( Alias alias )
|
||||
{
|
||||
if( alias != null )
|
||||
{
|
||||
for( AliasID aliasID: alias.getId() )
|
||||
{
|
||||
removeAliasID( aliasID, alias );
|
||||
}
|
||||
|
||||
mAliases.remove( alias );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the alias and alias identifier from internal mappings.
|
||||
*/
|
||||
private void removeAliasID( AliasID id, Alias alias )
|
||||
{
|
||||
switch( id.getType() )
|
||||
{
|
||||
case ESN:
|
||||
Esn esn = (Esn)id;
|
||||
if( mESN.containsKey( esn.getEsn() ) )
|
||||
{
|
||||
Alias esnAlias = mESN.get( esn.getEsn() );
|
||||
|
||||
if( esnAlias != null && esnAlias == alias )
|
||||
{
|
||||
mESN.remove( esn.getEsn() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Fleetsync:
|
||||
FleetsyncID fs = (FleetsyncID)id;
|
||||
|
||||
if( mFleetsync.containsKey( fs.getIdent() ) )
|
||||
{
|
||||
Alias fsAlias = mFleetsync.get( fs.getIdent() );
|
||||
|
||||
if( fsAlias != null && fsAlias == alias )
|
||||
{
|
||||
mFleetsync.remove( fs.getIdent() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LoJack:
|
||||
LoJackFunctionAndID lj = (LoJackFunctionAndID)id;
|
||||
|
||||
if( mLoJack.containsKey( lj ) )
|
||||
{
|
||||
Alias ljAlias = mLoJack.get( lj );
|
||||
|
||||
if( ljAlias != null && ljAlias == alias )
|
||||
{
|
||||
mLoJack.remove( lj );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MDC1200:
|
||||
MDC1200ID mdc = (MDC1200ID)id;
|
||||
|
||||
if( mMDC1200.containsKey( mdc.getIdent() ) )
|
||||
{
|
||||
Alias mdcAlias = mMDC1200.get( mdc.getIdent() );
|
||||
|
||||
if( mdcAlias != null && mdcAlias == alias )
|
||||
{
|
||||
mMDC1200.remove( mdc.getIdent() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MPT1327:
|
||||
MPT1327ID mpt = (MPT1327ID)id;
|
||||
|
||||
if( mMPT1327.containsKey( mpt.getIdent() ) )
|
||||
{
|
||||
Alias mptAlias = mMDC1200.get( mpt.getIdent() );
|
||||
|
||||
if( mptAlias != null && mptAlias == alias )
|
||||
{
|
||||
mMPT1327.remove( mpt.getIdent() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MIN:
|
||||
Min min = (Min)id;
|
||||
|
||||
if( mMobileID.containsKey( min.getMin() ) )
|
||||
{
|
||||
Alias minAlias = mMobileID.get( min.getMin() );
|
||||
|
||||
if( minAlias != null && minAlias == alias )
|
||||
{
|
||||
mMobileID.remove( min.getMin() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LTRNetUID:
|
||||
UniqueID uid = (UniqueID)id;
|
||||
|
||||
if( mUniqueID.containsKey( uid.getUid() ) )
|
||||
{
|
||||
Alias uidAlias = mUniqueID.get( uid.getUid() );
|
||||
|
||||
if( uidAlias != null && uidAlias == alias )
|
||||
{
|
||||
mUniqueID.remove( uid.getUid() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Site:
|
||||
SiteID sid = (SiteID)id;
|
||||
|
||||
if( mSiteID.containsKey( sid.getSite() ) )
|
||||
{
|
||||
Alias sidAlias = mSiteID.get( sid.getSite() );
|
||||
|
||||
if( sidAlias != null && sidAlias == alias )
|
||||
{
|
||||
mSiteID.remove( sid.getSite() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Status:
|
||||
StatusID stat = (StatusID)id;
|
||||
|
||||
if( mStatus.containsKey( stat.getStatus() ) )
|
||||
{
|
||||
Alias statAlias = mStatus.get( stat.getStatus() );
|
||||
|
||||
if( statAlias != null && statAlias == alias )
|
||||
{
|
||||
mStatus.remove( stat.getStatus() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Talkgroup:
|
||||
TalkgroupID tg = (TalkgroupID)id;
|
||||
|
||||
if( mTalkgroup.containsKey( tg.getTalkgroup() ) )
|
||||
{
|
||||
Alias tgAlias = mTalkgroup.get( tg.getTalkgroup() );
|
||||
|
||||
if( tgAlias != null && tgAlias == alias )
|
||||
{
|
||||
mTalkgroup.remove( tg.getTalkgroup() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NonRecordable:
|
||||
case Priority:
|
||||
//We don't maintain lookups for these items
|
||||
break;
|
||||
default:
|
||||
mLog.warn( "Unrecognized Alias ID Type:" + id.getType().name() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +403,10 @@ public class AliasList implements Comparable<AliasList>
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lookup alias by site ID
|
||||
*/
|
||||
public Alias getSiteID( String siteID )
|
||||
{
|
||||
if( siteID != null )
|
||||
@@ -301,17 +429,26 @@ public class AliasList implements Comparable<AliasList>
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lookup alias by status ID
|
||||
*/
|
||||
public Alias getStatus( int status )
|
||||
{
|
||||
return mStatus.get( status );
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by Unique ID (UID)
|
||||
*/
|
||||
public Alias getUniqueID( int uniqueID )
|
||||
{
|
||||
return mUniqueID.get( uniqueID );
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by ESN
|
||||
*/
|
||||
public Alias getESNAlias( String esn )
|
||||
{
|
||||
if( esn != null )
|
||||
@@ -335,7 +472,9 @@ public class AliasList implements Comparable<AliasList>
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lookup alias by fleetsync ID
|
||||
*/
|
||||
public Alias getFleetsyncAlias( String ident )
|
||||
{
|
||||
if( ident != null )
|
||||
@@ -359,6 +498,9 @@ public class AliasList implements Comparable<AliasList>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by lojack function and ID
|
||||
*/
|
||||
public Alias getLoJackAlias( Function function, String id )
|
||||
{
|
||||
if( id != null )
|
||||
@@ -375,6 +517,9 @@ public class AliasList implements Comparable<AliasList>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by MDC1200 ID
|
||||
*/
|
||||
public Alias getMDC1200Alias( String ident )
|
||||
{
|
||||
if( ident != null )
|
||||
@@ -398,6 +543,9 @@ public class AliasList implements Comparable<AliasList>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by MPT1327 Ident
|
||||
*/
|
||||
public Alias getMPT1327Alias( String ident )
|
||||
{
|
||||
if( ident != null )
|
||||
@@ -421,22 +569,9 @@ public class AliasList implements Comparable<AliasList>
|
||||
return null;
|
||||
}
|
||||
|
||||
public Group getGroup( Alias alias )
|
||||
{
|
||||
if( alias != null )
|
||||
{
|
||||
for( Group group: mGroups )
|
||||
{
|
||||
if( group.contains( alias ) )
|
||||
{
|
||||
return group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by Mobile ID Number (MIN)
|
||||
*/
|
||||
public Alias getMobileIDNumberAlias( String ident )
|
||||
{
|
||||
if( ident != null )
|
||||
@@ -460,6 +595,9 @@ public class AliasList implements Comparable<AliasList>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup alias by talkgroup
|
||||
*/
|
||||
public Alias getTalkgroupAlias( String tgid )
|
||||
{
|
||||
if( tgid != null )
|
||||
@@ -482,49 +620,27 @@ public class AliasList implements Comparable<AliasList>
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alias list name
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias list name
|
||||
*/
|
||||
@XmlAttribute
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public ArrayList<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() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup an alias by metadata type and string value
|
||||
*/
|
||||
public Alias getAlias( String value, MetadataType type )
|
||||
{
|
||||
switch( type )
|
||||
@@ -576,5 +692,48 @@ public class AliasList implements Comparable<AliasList>
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Receive alias change event notifications and modify this list accordingly
|
||||
*/
|
||||
@Override
|
||||
public void receive( AliasEvent event )
|
||||
{
|
||||
Alias alias = event.getAlias();
|
||||
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case ADD:
|
||||
if( alias.getList() != null &&
|
||||
getName().equalsIgnoreCase( alias.getList() ) )
|
||||
{
|
||||
addAlias( alias );
|
||||
}
|
||||
break;
|
||||
case CHANGE:
|
||||
if( alias.getList() != null &&
|
||||
getName().equalsIgnoreCase( alias.getList() ) )
|
||||
{
|
||||
if( !mAliases.contains( alias ) )
|
||||
{
|
||||
//Alias was moved to this list - add it
|
||||
addAlias( alias );
|
||||
}
|
||||
}
|
||||
else if( mAliases.contains( alias ) )
|
||||
{
|
||||
//An alias in this list was moved to another list
|
||||
removeAlias( alias );
|
||||
}
|
||||
break;
|
||||
case DELETE:
|
||||
if( mAliases.contains( alias ) )
|
||||
{
|
||||
removeAlias( alias );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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;
|
||||
}
|
||||
}
|
||||
311
src/alias/AliasModel.java
Normal file
311
src/alias/AliasModel.java
Normal file
@@ -0,0 +1,311 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import sample.Broadcaster;
|
||||
import sample.Listener;
|
||||
import alias.AliasEvent.Event;
|
||||
|
||||
/**
|
||||
* Alias Model
|
||||
*/
|
||||
public class AliasModel extends AbstractTableModel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int COLUMN_LIST = 0;
|
||||
public static final int COLUMN_GROUP = 1;
|
||||
public static final int COLUMN_NAME = 2;
|
||||
public static final int COLUMN_ICON = 3;
|
||||
public static final int COLUMN_COLOR = 4;
|
||||
|
||||
private List<Alias> mAliases = new CopyOnWriteArrayList<>();
|
||||
private Broadcaster<AliasEvent> mAliasEventBroadcaster = new Broadcaster<>();
|
||||
private Map<String,AliasList> mAliasListMap = new HashMap<>();
|
||||
|
||||
public AliasModel()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmodifiable list of all aliases currently in the model
|
||||
*/
|
||||
public List<Alias> getAliases()
|
||||
{
|
||||
return Collections.unmodifiableList( mAliases );
|
||||
}
|
||||
|
||||
public Alias getAliasAtIndex( int row )
|
||||
{
|
||||
if( mAliases.size() >= row )
|
||||
{
|
||||
return mAliases.get( row );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public AliasList getAliasList( String name )
|
||||
{
|
||||
if( mAliasListMap.containsKey( name ) )
|
||||
{
|
||||
return mAliasListMap.get( name );
|
||||
}
|
||||
|
||||
AliasList aliasList = new AliasList( name );
|
||||
|
||||
for( Alias alias: mAliases )
|
||||
{
|
||||
if( alias.getList().equalsIgnoreCase( name ) )
|
||||
{
|
||||
aliasList.addAlias( alias );
|
||||
}
|
||||
}
|
||||
|
||||
mAliasListMap.put( name, aliasList );
|
||||
|
||||
//Register the new alias list to receive updates from this model
|
||||
addListener( aliasList );
|
||||
|
||||
return aliasList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of unique alias list names from across the alias set
|
||||
*/
|
||||
public List<String> getListNames()
|
||||
{
|
||||
List<String> listNames = new ArrayList<>();
|
||||
|
||||
for( Alias alias: mAliases )
|
||||
{
|
||||
if( alias.hasList() && !listNames.contains( alias.getList() ) )
|
||||
{
|
||||
listNames.add( alias.getList() );
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort( listNames );
|
||||
|
||||
return listNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of alias group names for all aliases
|
||||
*/
|
||||
public List<String> getGroupNames()
|
||||
{
|
||||
List<String> groupNames = new ArrayList<>();
|
||||
|
||||
for( Alias alias: mAliases )
|
||||
{
|
||||
if( alias.hasGroup() && !groupNames.contains( alias.getGroup() ) )
|
||||
{
|
||||
groupNames.add( alias.getGroup() );
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort( groupNames );
|
||||
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of alias group names for all aliases that have a matching
|
||||
* list name value
|
||||
*/
|
||||
public List<String> getGroupNames( String listName )
|
||||
{
|
||||
List<String> groupNames = new ArrayList<>();
|
||||
|
||||
if( listName != null )
|
||||
{
|
||||
for( Alias alias: mAliases )
|
||||
{
|
||||
if( alias.hasList() &&
|
||||
alias.hasGroup() &&
|
||||
listName.equals( alias.getList() ) &&
|
||||
!groupNames.contains( alias.getGroup() ) )
|
||||
{
|
||||
groupNames.add( alias.getGroup() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort( groupNames );
|
||||
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk loading of aliases
|
||||
*/
|
||||
public void addAliases( List<Alias> aliases )
|
||||
{
|
||||
for( Alias alias: aliases )
|
||||
{
|
||||
addAlias( alias );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the alias to the model
|
||||
*/
|
||||
public int addAlias( Alias alias )
|
||||
{
|
||||
if( alias != null )
|
||||
{
|
||||
mAliases.add( alias );
|
||||
|
||||
int index = mAliases.size() - 1;
|
||||
|
||||
fireTableRowsInserted( index, index );
|
||||
|
||||
broadcast( new AliasEvent( alias, Event.ADD ) );
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the channel from the model and broadcasts a channel remove event
|
||||
*/
|
||||
public void removeAlias( Alias alias )
|
||||
{
|
||||
if( alias != null )
|
||||
{
|
||||
int index = mAliases.indexOf( alias );
|
||||
|
||||
mAliases.remove( alias );
|
||||
|
||||
fireTableRowsDeleted( index, index );
|
||||
|
||||
broadcast( new AliasEvent( alias, Event.DELETE ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mAliases.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName( int columnIndex )
|
||||
{
|
||||
switch( columnIndex )
|
||||
{
|
||||
case COLUMN_LIST:
|
||||
return "List";
|
||||
case COLUMN_GROUP:
|
||||
return "Group";
|
||||
case COLUMN_NAME:
|
||||
return "Name";
|
||||
case COLUMN_ICON:
|
||||
return "Icon";
|
||||
case COLUMN_COLOR:
|
||||
return "Color";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass( int columnIndex )
|
||||
{
|
||||
if( columnIndex == COLUMN_COLOR )
|
||||
{
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable( int rowIndex, int columnIndex )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt( int rowIndex, int columnIndex )
|
||||
{
|
||||
Alias alias = mAliases.get( rowIndex );
|
||||
|
||||
switch( columnIndex )
|
||||
{
|
||||
case COLUMN_LIST:
|
||||
return alias.getList();
|
||||
case COLUMN_GROUP:
|
||||
return alias.getGroup();
|
||||
case COLUMN_NAME:
|
||||
return alias.getName();
|
||||
case COLUMN_ICON:
|
||||
return alias.getIconName();
|
||||
case COLUMN_COLOR:
|
||||
return alias.getColor();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt( Object aValue, int rowIndex, int columnIndex )
|
||||
{
|
||||
throw new IllegalArgumentException( "Not yet implemented" );
|
||||
}
|
||||
|
||||
public void broadcast( AliasEvent event )
|
||||
{
|
||||
if( event.getEvent() == Event.CHANGE )
|
||||
{
|
||||
int index = mAliases.indexOf( event.getAlias() );
|
||||
|
||||
fireTableRowsUpdated( index, index );
|
||||
}
|
||||
|
||||
mAliasEventBroadcaster.broadcast( event );
|
||||
}
|
||||
|
||||
public void addListener( Listener<AliasEvent> listener )
|
||||
{
|
||||
mAliasEventBroadcaster.addListener( listener );
|
||||
}
|
||||
|
||||
public void removeListener( Listener<AliasEvent> listener )
|
||||
{
|
||||
mAliasEventBroadcaster.removeListener( listener );
|
||||
}
|
||||
}
|
||||
291
src/alias/AliasNameEditor.java
Normal file
291
src/alias/AliasNameEditor.java
Normal file
@@ -0,0 +1,291 @@
|
||||
package alias;
|
||||
|
||||
import gui.editor.Editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import map.IconManager;
|
||||
import map.MapIcon;
|
||||
import map.MapIconListCellRenderer;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
import alias.AliasEvent.Event;
|
||||
|
||||
public class AliasNameEditor extends Editor<Alias>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
||||
|
||||
private JComboBox<String> mListCombo = new JComboBox<>( EMPTY_MODEL );
|
||||
private JComboBox<String> mGroupCombo = new JComboBox<>( EMPTY_MODEL );
|
||||
private JComboBox<MapIcon> mMapIconCombo;
|
||||
private JTextField mName;
|
||||
private JButton mButtonColor;
|
||||
private JButton mBtnIconManager;
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public AliasNameEditor( AliasModel aliasModel, SettingsManager settingsManager )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mSettingsManager = settingsManager;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][grow,fill]",
|
||||
"[][][][][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Name:" ) );
|
||||
mName = new JTextField();
|
||||
mName.getDocument().addDocumentListener( new DocumentListener()
|
||||
{
|
||||
@Override
|
||||
public void removeUpdate( DocumentEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate( DocumentEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate( DocumentEvent e ){}
|
||||
} );
|
||||
add( mName, "wrap" );
|
||||
|
||||
add( new JLabel( "List:" ) );
|
||||
mListCombo.setEditable( true );
|
||||
mListCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
if( mListCombo.getSelectedItem() != null )
|
||||
{
|
||||
List<String> groups = mAliasModel
|
||||
.getGroupNames( (String)mListCombo.getSelectedItem() );
|
||||
|
||||
if( groups.isEmpty() )
|
||||
{
|
||||
mGroupCombo.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
groups.toArray( new String[ groups.size() ] ) ) );;
|
||||
}
|
||||
}
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mListCombo, "wrap" );
|
||||
|
||||
add( new JLabel( "Group:" ) );
|
||||
mGroupCombo.setEditable( true );
|
||||
mGroupCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mGroupCombo, "wrap" );
|
||||
|
||||
add( new JLabel( "Color:" ) );
|
||||
|
||||
mButtonColor = new JButton( "Select ..." );
|
||||
mButtonColor.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
Color newColor = JColorChooser.showDialog(
|
||||
AliasNameEditor.this,
|
||||
"Choose color for this alias",
|
||||
( hasItem() ? getItem().getMapColor() : null ) );
|
||||
|
||||
if( newColor != null )
|
||||
{
|
||||
mButtonColor.setForeground( newColor );
|
||||
mButtonColor.setBackground( newColor );
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mButtonColor, "wrap" );
|
||||
|
||||
add( new JLabel( "Icon:" ) );
|
||||
|
||||
mMapIconCombo = new JComboBox<MapIcon>( mSettingsManager.getMapIcons() );
|
||||
|
||||
MapIconListCellRenderer renderer = new MapIconListCellRenderer();
|
||||
renderer.setPreferredSize( new Dimension( 200, 30 ) );
|
||||
mMapIconCombo.setRenderer( renderer );
|
||||
mMapIconCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
|
||||
add( mMapIconCombo, "wrap" );
|
||||
|
||||
//Dummy place holder
|
||||
add( new JLabel() );
|
||||
|
||||
mBtnIconManager = new JButton( "Icon Manager" );
|
||||
mBtnIconManager.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
final IconManager iconManager =
|
||||
new IconManager( mSettingsManager, AliasNameEditor.this );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
iconManager.setVisible( true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
add( mBtnIconManager, "span 2,wrap" );
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( Alias alias )
|
||||
{
|
||||
super.setItem( alias );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mName.setText( alias.getName() );
|
||||
|
||||
List<String> listNames = mAliasModel.getListNames();
|
||||
|
||||
if( listNames.isEmpty() )
|
||||
{
|
||||
mListCombo.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
mListCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
listNames.toArray( new String[ listNames.size() ] ) ) );;
|
||||
}
|
||||
|
||||
mListCombo.setSelectedItem( alias.getList() );
|
||||
|
||||
List<String> groupNames = mAliasModel.getGroupNames( alias.getList() );
|
||||
|
||||
if( groupNames.isEmpty() )
|
||||
{
|
||||
mGroupCombo.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
groupNames.toArray( new String[ groupNames.size() ] ) ) );;
|
||||
}
|
||||
|
||||
mGroupCombo.setSelectedItem( alias.getGroup() );
|
||||
|
||||
Color color = alias.getMapColor();
|
||||
|
||||
mButtonColor.setBackground( color );
|
||||
mButtonColor.setForeground( color );
|
||||
|
||||
String iconName = alias.getIconName();
|
||||
|
||||
if( iconName == null )
|
||||
{
|
||||
iconName = SettingsManager.DEFAULT_ICON;
|
||||
}
|
||||
|
||||
MapIcon savedIcon = mSettingsManager.getMapIcon( iconName );
|
||||
|
||||
if( savedIcon != null )
|
||||
{
|
||||
mMapIconCombo.setSelectedItem( savedIcon );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mListCombo.setModel( EMPTY_MODEL );
|
||||
mGroupCombo.setModel( EMPTY_MODEL );
|
||||
mName.setText( null );
|
||||
|
||||
mButtonColor.setBackground( getBackground() );
|
||||
mButtonColor.setForeground( getForeground() );
|
||||
}
|
||||
|
||||
repaint();
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
Alias alias = getItem();
|
||||
|
||||
if( mListCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setList( (String)mListCombo.getSelectedItem() );
|
||||
}
|
||||
|
||||
if( mGroupCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setGroup( (String)mGroupCombo.getSelectedItem() );
|
||||
}
|
||||
|
||||
alias.setName( mName.getText() );
|
||||
|
||||
alias.setColor( mButtonColor.getBackground().getRGB() );
|
||||
|
||||
if( mMapIconCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setIconName( ((MapIcon)mMapIconCombo.getSelectedItem()).getName() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
//Broadcast an alias change event to save the updates
|
||||
mAliasModel.broadcast( new AliasEvent( getItem(), Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,562 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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 map.MapIcon;
|
||||
import alias.action.AliasAction;
|
||||
import alias.action.beep.BeepAction;
|
||||
import alias.action.beep.BeepActionNode;
|
||||
import alias.action.clip.ClipAction;
|
||||
import alias.action.clip.ClipActionNode;
|
||||
import alias.action.script.ScriptAction;
|
||||
import alias.action.script.ScriptActionNode;
|
||||
import alias.id.esn.ESNNode;
|
||||
import alias.id.esn.Esn;
|
||||
import alias.id.fleetsync.FleetsyncID;
|
||||
import alias.id.fleetsync.FleetsyncIDNode;
|
||||
import alias.id.fleetsync.StatusID;
|
||||
import alias.id.fleetsync.StatusIDNode;
|
||||
import alias.id.lojack.LoJackFunctionAndID;
|
||||
import alias.id.lojack.LoJackIDNode;
|
||||
import alias.id.mdc.MDC1200ID;
|
||||
import alias.id.mdc.MDC1200IDNode;
|
||||
import alias.id.mobileID.MINNode;
|
||||
import alias.id.mobileID.Min;
|
||||
import alias.id.mpt1327.MPT1327ID;
|
||||
import alias.id.mpt1327.MPT1327IDNode;
|
||||
import alias.id.siteID.SiteID;
|
||||
import alias.id.siteID.SiteIDNode;
|
||||
import alias.id.talkgroup.TalkgroupID;
|
||||
import alias.id.talkgroup.TalkgroupIDNode;
|
||||
import alias.id.uniqueID.UniqueID;
|
||||
import alias.id.uniqueID.UniqueIDNode;
|
||||
import alias.priority.Priority;
|
||||
import alias.priority.PriorityNode;
|
||||
import alias.record.NonRecordable;
|
||||
import alias.record.NonRecordableNode;
|
||||
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() )
|
||||
{
|
||||
switch( aliasID.getType() )
|
||||
{
|
||||
case ESN:
|
||||
getModel().addNode( new ESNNode( (Esn)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case Fleetsync:
|
||||
getModel().addNode( new FleetsyncIDNode( (FleetsyncID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case LoJack:
|
||||
getModel().addNode( new LoJackIDNode( (LoJackFunctionAndID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case LTRNetUID:
|
||||
getModel().addNode( new UniqueIDNode( (UniqueID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case MDC1200:
|
||||
getModel().addNode( new MDC1200IDNode( (MDC1200ID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case MIN:
|
||||
getModel().addNode( new MINNode( (Min)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case MPT1327:
|
||||
getModel().addNode( new MPT1327IDNode( (MPT1327ID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case NonRecordable:
|
||||
getModel().addNode( new NonRecordableNode( (NonRecordable)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case Priority:
|
||||
getModel().addNode( new PriorityNode( (Priority)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case Site:
|
||||
getModel().addNode( new SiteIDNode( (SiteID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case Status:
|
||||
getModel().addNode( new StatusIDNode( (StatusID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
case Talkgroup:
|
||||
getModel().addNode( new TalkgroupIDNode( (TalkgroupID)aliasID ),
|
||||
AliasNode.this, getChildCount() );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized alias ID [" +
|
||||
aliasID.getType() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
for( AliasAction action: getAlias().getAction() )
|
||||
{
|
||||
if( action instanceof BeepAction )
|
||||
{
|
||||
getModel().addNode( new BeepActionNode( (BeepAction)action ),
|
||||
AliasNode.this, getChildCount() );
|
||||
}
|
||||
else if( action instanceof ClipAction )
|
||||
{
|
||||
getModel().addNode( new ClipActionNode( (ClipAction)action ),
|
||||
AliasNode.this, getChildCount() );
|
||||
}
|
||||
else if( action instanceof ScriptAction )
|
||||
{
|
||||
getModel().addNode( new ScriptActionNode( (ScriptAction)action ),
|
||||
AliasNode.this, getChildCount() );
|
||||
}
|
||||
}
|
||||
|
||||
sort();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return getAlias().getName() + " [" + this.getChildCount() + "]";
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenu addIDMenu = new JMenu( "Add ID" );
|
||||
|
||||
JMenuItem addESNItem = new JMenuItem( "ESN" );
|
||||
addESNItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
Esn esn = new Esn();
|
||||
|
||||
getAlias().addAliasID( esn );
|
||||
|
||||
ESNNode node = new ESNNode( 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 addLoJackItem = new JMenuItem( "LoJack" );
|
||||
addLoJackItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
LoJackFunctionAndID lj = new LoJackFunctionAndID();
|
||||
|
||||
getAlias().addAliasID( lj );
|
||||
|
||||
LoJackIDNode node = new LoJackIDNode( lj );
|
||||
|
||||
getModel().addNode( node,
|
||||
AliasNode.this,
|
||||
AliasNode.this.getChildCount() );
|
||||
|
||||
node.show();
|
||||
}
|
||||
} );
|
||||
addIDMenu.add( addLoJackItem );
|
||||
|
||||
JMenuItem addMDCItem = new JMenuItem( "MDC-1200" );
|
||||
addMDCItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
MDC1200ID mdc = new MDC1200ID();
|
||||
|
||||
getAlias().addAliasID( mdc );
|
||||
|
||||
MDC1200IDNode node = new MDC1200IDNode( 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 );
|
||||
|
||||
JMenu addActionMenu = new JMenu( "Add Action" );
|
||||
|
||||
JMenuItem addClipItem = new JMenuItem( "Audio Clip" );
|
||||
|
||||
addClipItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ClipAction clipAction = new ClipAction();
|
||||
|
||||
getAlias().addAliasAction( clipAction );
|
||||
|
||||
ClipActionNode node = new ClipActionNode( clipAction );
|
||||
|
||||
getModel().addNode( node,
|
||||
AliasNode.this,
|
||||
AliasNode.this.getChildCount() );
|
||||
|
||||
node.show();
|
||||
}
|
||||
} );
|
||||
|
||||
addActionMenu.add( addClipItem );
|
||||
|
||||
JMenuItem addBeepItem = new JMenuItem( "Beep" );
|
||||
|
||||
addBeepItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
BeepAction beepAction = new BeepAction();
|
||||
|
||||
getAlias().addAliasAction( beepAction );
|
||||
|
||||
BeepActionNode node = new BeepActionNode( beepAction );
|
||||
|
||||
getModel().addNode( node,
|
||||
AliasNode.this,
|
||||
AliasNode.this.getChildCount() );
|
||||
|
||||
node.show();
|
||||
}
|
||||
} );
|
||||
|
||||
addActionMenu.add( addBeepItem );
|
||||
|
||||
JMenuItem addScriptItem = new JMenuItem( "Script" );
|
||||
|
||||
addScriptItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ScriptAction scriptAction = new ScriptAction();
|
||||
|
||||
getAlias().addAliasAction( scriptAction );
|
||||
|
||||
ScriptActionNode node = new ScriptActionNode( scriptAction );
|
||||
|
||||
getModel().addNode( node,
|
||||
AliasNode.this,
|
||||
AliasNode.this.getChildCount() );
|
||||
|
||||
node.show();
|
||||
}
|
||||
} );
|
||||
|
||||
addActionMenu.add( addScriptItem );
|
||||
|
||||
retVal.add( addActionMenu );
|
||||
|
||||
retVal.addSeparator();
|
||||
|
||||
if( getAlias().isRecordable() )
|
||||
{
|
||||
JMenuItem nonRecordableItem = new JMenuItem( "Set Non-Recordable" );
|
||||
|
||||
nonRecordableItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
NonRecordable non = new NonRecordable();
|
||||
|
||||
getAlias().addAliasID( non );
|
||||
|
||||
NonRecordableNode node = new NonRecordableNode( non );
|
||||
|
||||
getModel().addNode( node,
|
||||
AliasNode.this,
|
||||
AliasNode.this.getChildCount() );
|
||||
|
||||
node.show();
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( nonRecordableItem );
|
||||
retVal.addSeparator();
|
||||
}
|
||||
|
||||
if( !getAlias().hasPriority() )
|
||||
{
|
||||
JMenuItem priorityItem = new JMenuItem( "Set Call Priority" );
|
||||
|
||||
priorityItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
Priority priority = new Priority();
|
||||
|
||||
getAlias().addAliasID( priority );
|
||||
|
||||
PriorityNode node = new PriorityNode( priority );
|
||||
|
||||
getModel().addNode( node,
|
||||
AliasNode.this,
|
||||
AliasNode.this.getChildCount() );
|
||||
|
||||
node.show();
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( priorityItem );
|
||||
retVal.addSeparator();
|
||||
}
|
||||
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
GroupNode parent = (GroupNode)getParent();
|
||||
|
||||
parent.getGroup().removeAlias( getAlias() );
|
||||
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( AliasNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( deleteItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
121
src/alias/ComponentEditor.java
Normal file
121
src/alias/ComponentEditor.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
public abstract class ComponentEditor<T> extends JPanel implements DocumentListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean mModified;
|
||||
private ComponentModificationListener mListener;
|
||||
protected T mComponent;
|
||||
|
||||
/**
|
||||
* Abstract class for editor with notifications when contents are modified
|
||||
* and methods for saving or resetting the component values with the
|
||||
* contents of the editor.
|
||||
*/
|
||||
public ComponentEditor( T component )
|
||||
{
|
||||
mComponent = component;
|
||||
}
|
||||
|
||||
public ComponentEditor()
|
||||
{
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mComponent = null;
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public T getComponent()
|
||||
{
|
||||
return mComponent;
|
||||
}
|
||||
|
||||
protected void setModified( boolean modified )
|
||||
{
|
||||
mModified = modified;
|
||||
|
||||
if( modified && mListener != null )
|
||||
{
|
||||
mListener.componentModified();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the contents of the editor have been modified
|
||||
*/
|
||||
public boolean isModified()
|
||||
{
|
||||
return mModified;
|
||||
}
|
||||
|
||||
public void setComponentModificationListener( ComponentModificationListener listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or resets the editable component
|
||||
*/
|
||||
public abstract void setComponent( T t );
|
||||
|
||||
/**
|
||||
* Saves changed editor values to the component
|
||||
*/
|
||||
public abstract void save();
|
||||
|
||||
/**
|
||||
* Reloads the editor contents from the source component and resets the
|
||||
* modified flag
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
setComponent( getComponent() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate contents of other editors against this component editor before
|
||||
* saving. Override this method to allow controller to pass other editors
|
||||
* to this editor for content inspection/validation before indicating that
|
||||
* this editor passes validation. This allows for validating editor contents
|
||||
* that are contingent on settings in other editors.
|
||||
*
|
||||
* @throws ComponentValidationException if the contents of the editor
|
||||
* argument cannot be validated, with the exception containing a detailed
|
||||
* description of the issue.
|
||||
*/
|
||||
public void validate( ComponentEditor<?> editor ) throws ComponentValidationException
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener interface to receive notification that the contents of the
|
||||
* editor have been modified from the original component value and either
|
||||
* need to be saved or reset
|
||||
*/
|
||||
public interface ComponentModificationListener
|
||||
{
|
||||
public void componentModified();
|
||||
}
|
||||
}
|
||||
14
src/alias/ComponentValidationException.java
Normal file
14
src/alias/ComponentValidationException.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package alias;
|
||||
|
||||
public class ComponentValidationException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Component editor contents validation error
|
||||
*/
|
||||
public ComponentValidationException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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( "", "[right][grow,fill]", "[][][grow]" ) );
|
||||
|
||||
setBorder( BorderFactory.createTitledBorder( "Group" ) );
|
||||
|
||||
mLabelName = new JLabel( "Name:" );
|
||||
add( mLabelName, "align right" );
|
||||
|
||||
mTextGroup = new JTextField( mGroupNode.getGroup().getName() );
|
||||
add( mTextGroup, "wrap" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( GroupEditor.this );
|
||||
add( btnSave );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( GroupEditor.this );
|
||||
add( btnReset, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
{
|
||||
String group = mTextGroup.getText();
|
||||
|
||||
if( group != null )
|
||||
{
|
||||
boolean expanded = mGroupNode.getModel().getTree()
|
||||
.isExpanded( new TreePath( mGroupNode ) );
|
||||
|
||||
mGroupNode.getGroup().setName( group );
|
||||
|
||||
((ConfigurableNode)mGroupNode.getParent()).sort();
|
||||
|
||||
mGroupNode.save();
|
||||
|
||||
mGroupNode.show();
|
||||
|
||||
if( expanded )
|
||||
{
|
||||
mGroupNode.getModel().getTree()
|
||||
.expandPath( new TreePath( mGroupNode ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( GroupEditor.this, "Please enter a group name" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
{
|
||||
mTextGroup.setText( mGroupNode.getGroup().getName() );
|
||||
}
|
||||
|
||||
mGroupNode.refresh();
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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;
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <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( "", "[right][grow,fill]", "[][][grow]" ) );
|
||||
|
||||
setBorder( BorderFactory.createTitledBorder( "List" ) );
|
||||
|
||||
mLabelName = new JLabel( "Name:" );
|
||||
add( mLabelName, "align right" );
|
||||
|
||||
mTextGroup = new JTextField( mListNode.getList().getName() );
|
||||
add( mTextGroup, "grow, wrap" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( ListEditor.this );
|
||||
add( btnSave );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( ListEditor.this );
|
||||
add( btnReset, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
{
|
||||
String group = mTextGroup.getText();
|
||||
|
||||
if( group != null )
|
||||
{
|
||||
boolean expanded = mListNode.getModel().getTree()
|
||||
.isExpanded( new TreePath( mListNode ) );
|
||||
|
||||
mListNode.getList().setName( group );
|
||||
((ConfigurableNode)mListNode.getParent()).sort();
|
||||
mListNode.save();
|
||||
|
||||
mListNode.show();
|
||||
|
||||
if( expanded )
|
||||
{
|
||||
mListNode.getModel().getTree().expandPath( new TreePath( mListNode ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( ListEditor.this, "Please enter a list name" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
{
|
||||
mTextGroup.setText( mListNode.getList().getName() );
|
||||
}
|
||||
|
||||
mListNode.refresh();
|
||||
}
|
||||
}
|
||||
417
src/alias/MultipleAliasEditor.java
Normal file
417
src/alias/MultipleAliasEditor.java
Normal file
@@ -0,0 +1,417 @@
|
||||
package alias;
|
||||
|
||||
import gui.editor.Editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import map.IconManager;
|
||||
import map.MapIcon;
|
||||
import map.MapIconListCellRenderer;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
import alias.AliasEvent.Event;
|
||||
import alias.id.priority.Priority;
|
||||
|
||||
public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
implements Listener<AliasEvent>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( MultipleAliasEditor.class );
|
||||
|
||||
private static String HELP_TEXT =
|
||||
"<html>Select attributes below to change for all selected aliases</html>";
|
||||
|
||||
private JLabel mAliasCountLabel;
|
||||
private JLabel mAliasCount;
|
||||
|
||||
private JCheckBox mListCheckBox = new JCheckBox( "List" );
|
||||
private JComboBox<String> mListCombo = new JComboBox<>();
|
||||
private JCheckBox mGroupCheckBox = new JCheckBox( "Group" );
|
||||
private JComboBox<String> mGroupCombo = new JComboBox<>();
|
||||
private JCheckBox mIconCheckBox = new JCheckBox( "Icon" );
|
||||
private JComboBox<MapIcon> mMapIconCombo;
|
||||
private JCheckBox mColorCheckBox = new JCheckBox( "Color" );
|
||||
private JButton mButtonColor;
|
||||
private JButton mBtnIconManager;
|
||||
private JCheckBox mRecordCheckBox = new JCheckBox( "Record" );
|
||||
private JComboBox<Record> mRecordActionCombo = new JComboBox<>( Record.values() );
|
||||
private JCheckBox mPriorityCheckBox = new JCheckBox( "Priority" );
|
||||
private JSlider mPrioritySlider;
|
||||
private JLabel mPrioritySliderLabel;
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public MultipleAliasEditor( AliasModel aliasModel, SettingsManager settingsManager )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mAliasModel.addListener( this );
|
||||
|
||||
mSettingsManager = settingsManager;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public List<Alias> getAliases()
|
||||
{
|
||||
if( hasItem() )
|
||||
{
|
||||
return (List<Alias>)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[grow,fill][grow,fill]",
|
||||
"[][][][][][][][][][][][][grow,fill]" ) );
|
||||
|
||||
mAliasCountLabel = new JLabel( "Alias:" );
|
||||
add( mAliasCountLabel );
|
||||
|
||||
mAliasCount = new JLabel( "Multiple" );
|
||||
add( mAliasCount, "span" );
|
||||
|
||||
add( new JSeparator(), "span" );
|
||||
|
||||
add( new JLabel( HELP_TEXT ), "span" );
|
||||
|
||||
add( mListCheckBox );
|
||||
|
||||
mListCombo.setEditable( true );
|
||||
add( mListCombo, "wrap" );
|
||||
|
||||
add( mGroupCheckBox );
|
||||
|
||||
mGroupCombo.setEditable( true );
|
||||
add( mGroupCombo, "wrap" );
|
||||
|
||||
add( mColorCheckBox );
|
||||
|
||||
mButtonColor = new JButton( "Select ..." );
|
||||
mButtonColor.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
Color newColor = JColorChooser.showDialog(
|
||||
MultipleAliasEditor.this,
|
||||
"Choose color for this alias", null );
|
||||
|
||||
if( newColor != null )
|
||||
{
|
||||
mButtonColor.setForeground( newColor );
|
||||
mButtonColor.setBackground( newColor );
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mButtonColor, "wrap" );
|
||||
|
||||
add( mIconCheckBox );
|
||||
|
||||
mMapIconCombo = new JComboBox<MapIcon>( mSettingsManager.getMapIcons() );
|
||||
|
||||
MapIconListCellRenderer renderer = new MapIconListCellRenderer();
|
||||
renderer.setPreferredSize( new Dimension( 200, 30 ) );
|
||||
mMapIconCombo.setRenderer( renderer );
|
||||
add( mMapIconCombo, "wrap" );
|
||||
|
||||
//Dummy place holder
|
||||
add( new JLabel() );
|
||||
|
||||
mBtnIconManager = new JButton( "Icon Manager" );
|
||||
mBtnIconManager.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
final IconManager iconManager =
|
||||
new IconManager( mSettingsManager, MultipleAliasEditor.this );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
iconManager.setVisible( true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
add( mBtnIconManager, "span,wrap" );
|
||||
|
||||
add( mRecordCheckBox );
|
||||
add( mRecordActionCombo );
|
||||
|
||||
//Placeholder
|
||||
add( new JLabel( " " ) );
|
||||
mPrioritySliderLabel = new JLabel( "Priority: " + Priority.MIN_PRIORITY );
|
||||
add( mPrioritySliderLabel );
|
||||
|
||||
add( mPriorityCheckBox );
|
||||
|
||||
mPrioritySlider = new JSlider( JSlider.HORIZONTAL,
|
||||
Priority.MIN_PRIORITY,
|
||||
Priority.MAX_PRIORITY + 1,
|
||||
Priority.MIN_PRIORITY );
|
||||
|
||||
mPrioritySlider.setMajorTickSpacing( 20 );
|
||||
mPrioritySlider.setMinorTickSpacing( 5 );
|
||||
mPrioritySlider.setPaintTicks( true );
|
||||
mPrioritySlider.setLabelTable( mPrioritySlider.createStandardLabels( 25, 25 ) );
|
||||
mPrioritySlider.setPaintLabels( true );
|
||||
mPrioritySlider.addChangeListener( new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
int priority = mPrioritySlider.getValue();
|
||||
|
||||
if( priority > Priority.MAX_PRIORITY )
|
||||
{
|
||||
mPrioritySliderLabel.setText( "Priority: Do Not Monitor" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mPrioritySliderLabel.setText( "Priority: " + mPrioritySlider.getValue() );
|
||||
}
|
||||
}
|
||||
} );
|
||||
mPrioritySlider.setToolTipText( HELP_TEXT );
|
||||
|
||||
add( mPrioritySlider );
|
||||
|
||||
JButton saveButton = new JButton( "Save" );
|
||||
saveButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
save();
|
||||
}
|
||||
} );
|
||||
add( saveButton );
|
||||
|
||||
JButton resetButton = new JButton( "Reset" );
|
||||
resetButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
reset();
|
||||
}
|
||||
} );
|
||||
add( resetButton );
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( List<Alias> item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( "Multiple Selected [ " );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
sb.append( String.valueOf( getAliases().size() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "0" );
|
||||
}
|
||||
|
||||
sb.append( " ]" );
|
||||
|
||||
mAliasCount.setText( sb.toString() );
|
||||
|
||||
List<String> listNames = mAliasModel.getListNames();
|
||||
listNames.add( 0, "" );
|
||||
mListCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
listNames.toArray( new String[ listNames.size() ] ) ) );
|
||||
|
||||
List<String> groupNames = mAliasModel.getGroupNames();
|
||||
groupNames.add( 0, "" );
|
||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
groupNames.toArray( new String[ groupNames.size() ] ) ) );
|
||||
|
||||
setCheckBoxesUnselected();
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
private void setCheckBoxesUnselected()
|
||||
{
|
||||
mListCheckBox.setSelected( false );
|
||||
mGroupCheckBox.setSelected( false );
|
||||
mColorCheckBox.setSelected( false );
|
||||
mIconCheckBox.setSelected( false );
|
||||
mRecordCheckBox.setSelected( false );
|
||||
mPriorityCheckBox.setSelected( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
List<String> listNames = mAliasModel.getListNames();
|
||||
listNames.add( 0, "" );
|
||||
mListCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
listNames.toArray( new String[ listNames.size() ] ) ) );
|
||||
|
||||
List<String> groupNames = mAliasModel.getGroupNames();
|
||||
groupNames.add( 0, "" );
|
||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
groupNames.toArray( new String[ groupNames.size() ] ) ) );
|
||||
|
||||
mButtonColor.setForeground( getForeground() );
|
||||
mButtonColor.setBackground( getBackground() );
|
||||
|
||||
super.reset();
|
||||
}
|
||||
|
||||
private boolean hasRequestedChanges()
|
||||
{
|
||||
return mListCheckBox.isSelected() ||
|
||||
mGroupCheckBox.isSelected() ||
|
||||
mColorCheckBox.isSelected() ||
|
||||
mIconCheckBox.isSelected() ||
|
||||
mRecordCheckBox.isSelected() ||
|
||||
mPriorityCheckBox.isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( hasRequestedChanges() && hasItem() )
|
||||
{
|
||||
List<Alias> aliases = getAliases();
|
||||
|
||||
for( Alias alias: aliases )
|
||||
{
|
||||
if( mListCheckBox.isSelected() )
|
||||
{
|
||||
String list = null;
|
||||
|
||||
if( mListCombo.getSelectedItem() != null )
|
||||
{
|
||||
list = (String)mListCombo.getSelectedItem();
|
||||
}
|
||||
|
||||
alias.setList( list );
|
||||
}
|
||||
|
||||
if( mGroupCheckBox.isSelected() )
|
||||
{
|
||||
String group = null;
|
||||
|
||||
if( mGroupCombo.getSelectedItem() != null )
|
||||
{
|
||||
group = (String)mGroupCombo.getSelectedItem();
|
||||
}
|
||||
|
||||
alias.setGroup( group );
|
||||
}
|
||||
|
||||
if( mColorCheckBox.isSelected() )
|
||||
{
|
||||
alias.setColor( mButtonColor.getForeground().getRGB() );
|
||||
}
|
||||
|
||||
if( mIconCheckBox.isSelected() )
|
||||
{
|
||||
if( mMapIconCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setIconName( ((MapIcon)mMapIconCombo.getSelectedItem()).getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
alias.setIconName( null );
|
||||
}
|
||||
}
|
||||
|
||||
if( mRecordCheckBox.isSelected() )
|
||||
{
|
||||
Record action =
|
||||
(Record)mRecordActionCombo.getSelectedItem();
|
||||
|
||||
alias.setRecordable( action == Record.RECORDABLE );
|
||||
}
|
||||
|
||||
if( mPriorityCheckBox.isSelected() )
|
||||
{
|
||||
int priority = mPrioritySlider.getValue();
|
||||
|
||||
//This is a work-around -- we use max priority + 1 in the
|
||||
//gui to indicate do not monitor, and change the value here
|
||||
if( priority == Priority.MAX_PRIORITY + 1 )
|
||||
{
|
||||
priority = Priority.DO_NOT_MONITOR;
|
||||
}
|
||||
|
||||
alias.setCallPriority( priority );
|
||||
}
|
||||
}
|
||||
|
||||
for( Alias alias: aliases )
|
||||
{
|
||||
//Broadcast an alias change event to save the updates
|
||||
mAliasModel.broadcast( new AliasEvent( alias, Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( AliasEvent event )
|
||||
{
|
||||
if( event.getEvent() == Event.DELETE &&
|
||||
hasItem() &&
|
||||
getAliases().contains( event.getAlias() ) )
|
||||
{
|
||||
getAliases().remove( event.getAlias() );
|
||||
setItem( getAliases() );
|
||||
}
|
||||
}
|
||||
|
||||
public enum Record
|
||||
{
|
||||
NON_RECORDABLE( "Non-Recordable" ),
|
||||
RECORDABLE( "Recordable" );
|
||||
|
||||
private String mLabel;
|
||||
|
||||
private Record( String label )
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.action;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import message.Message;
|
||||
import alias.Alias;
|
||||
import alias.action.beep.BeepAction;
|
||||
import alias.action.clip.ClipAction;
|
||||
import alias.action.script.ScriptAction;
|
||||
import controller.ThreadPoolManager;
|
||||
|
||||
/**
|
||||
* Alias action defines an action to execute when an alias is detected active.
|
||||
*/
|
||||
@XmlSeeAlso( { BeepAction.class, ClipAction.class, ScriptAction.class } )
|
||||
@XmlRootElement( name = "action" )
|
||||
public abstract class AliasAction
|
||||
{
|
||||
public AliasAction()
|
||||
{
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public abstract AliasActionType getType();
|
||||
|
||||
/**
|
||||
* Task to execute when an alias action is defined. The message argument is
|
||||
|
||||
350
src/alias/action/AliasActionEditor.java
Normal file
350
src/alias/action/AliasActionEditor.java
Normal file
@@ -0,0 +1,350 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.action;
|
||||
|
||||
import gui.editor.Editor;
|
||||
import gui.editor.EmptyEditor;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.Alias;
|
||||
import alias.AliasEvent;
|
||||
import alias.AliasEvent.Event;
|
||||
import alias.AliasFactory;
|
||||
import alias.AliasModel;
|
||||
|
||||
public class AliasActionEditor extends Editor<Alias>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static ListModel<AliasAction> EMPTY_MODEL = new DefaultListModel<>();
|
||||
private JList<AliasAction> mAliasActionList = new JList<>( EMPTY_MODEL );
|
||||
private JButton mNewActionButton;
|
||||
private JButton mCloneActionButton;
|
||||
private JButton mDeleteActionButton;
|
||||
private EditorContainer mEditorContainer = new EditorContainer();
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
|
||||
public AliasActionEditor( AliasModel model )
|
||||
{
|
||||
mAliasModel = model;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 3",
|
||||
"[grow,fill][grow,fill][grow,fill]", "[][grow,fill][]" ) );
|
||||
|
||||
mAliasActionList.setVisibleRowCount( 6 );
|
||||
mAliasActionList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
mAliasActionList.setLayoutOrientation( JList.VERTICAL );
|
||||
mAliasActionList.addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
JList<?> list = (JList<?>)event.getSource();
|
||||
|
||||
Object selectedItem = list.getSelectedValue();
|
||||
|
||||
if( selectedItem != null && selectedItem instanceof AliasAction )
|
||||
{
|
||||
AliasAction selected = (AliasAction)selectedItem;
|
||||
|
||||
mEditorContainer.setAliasAction( selected );
|
||||
|
||||
mCloneActionButton.setEnabled( true );
|
||||
mDeleteActionButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCloneActionButton.setEnabled( false );
|
||||
mDeleteActionButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
JScrollPane scroller = new JScrollPane( mAliasActionList );
|
||||
add( scroller, "span,grow" );
|
||||
|
||||
add( mEditorContainer, "span,grow" );
|
||||
|
||||
mNewActionButton = new JButton( "New ..." );
|
||||
mNewActionButton.setToolTipText( "Create a new Alias Action" );
|
||||
mNewActionButton.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
|
||||
menu.add( new AddAliasActionItem( AliasActionType.BEEP ) );
|
||||
menu.add( new AddAliasActionItem( AliasActionType.CLIP ) );
|
||||
menu.add( new AddAliasActionItem( AliasActionType.SCRIPT ) );
|
||||
|
||||
menu.show( e.getComponent(), e.getX(), e.getY() );
|
||||
}
|
||||
} );
|
||||
|
||||
add( mNewActionButton );
|
||||
|
||||
mCloneActionButton = new JButton( "Clone" );
|
||||
mCloneActionButton.setToolTipText( "Create a copy of the currently selected action" );
|
||||
mCloneActionButton.setEnabled( false );
|
||||
mCloneActionButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
AliasAction selected = mAliasActionList.getSelectedValue();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
AliasAction clone = AliasFactory.copyOf( selected );
|
||||
|
||||
if( clone != null )
|
||||
{
|
||||
addAliasActionToList( clone );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mCloneActionButton );
|
||||
|
||||
mDeleteActionButton = new JButton( "Delete" );
|
||||
mDeleteActionButton.setToolTipText( "Delete the currently selected action" );
|
||||
mDeleteActionButton.setEnabled( false );
|
||||
mDeleteActionButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
final AliasAction selected = mAliasActionList.getSelectedValue();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( mDeleteActionButton,
|
||||
"Do you want to delete [" + selected.toString() + "]",
|
||||
"Are you sure?", JOptionPane.YES_NO_OPTION );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION && hasItem() )
|
||||
{
|
||||
Alias alias = getItem();
|
||||
|
||||
alias.removeAliasAction( selected );
|
||||
|
||||
mAliasModel.broadcast( new AliasEvent( alias, Event.CHANGE ) );
|
||||
|
||||
setItem( alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mDeleteActionButton, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( Alias alias )
|
||||
{
|
||||
super.setItem( alias );
|
||||
|
||||
if( alias == null || alias.getAction().isEmpty() )
|
||||
{
|
||||
mAliasActionList.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultListModel<AliasAction> model = new DefaultListModel<>();
|
||||
|
||||
List<AliasAction> actions = alias.getAction();
|
||||
|
||||
Collections.sort( actions, new Comparator<AliasAction>()
|
||||
{
|
||||
@Override
|
||||
public int compare( AliasAction o1, AliasAction o2 )
|
||||
{
|
||||
return o1.toString().compareTo( o2.toString() );
|
||||
}
|
||||
} );
|
||||
|
||||
for( AliasAction action: actions )
|
||||
{
|
||||
model.addElement( action );
|
||||
}
|
||||
|
||||
mAliasActionList.setModel( model );
|
||||
}
|
||||
|
||||
mEditorContainer.setAliasAction( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( isModified() || mEditorContainer.isModified() )
|
||||
{
|
||||
if( mEditorContainer.isModified() )
|
||||
{
|
||||
mEditorContainer.save();
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mAliasModel.broadcast( new AliasEvent( getItem(), Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EditorContainer extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Editor<AliasAction> mEditor = new EmptyEditor<>();
|
||||
|
||||
public EditorContainer()
|
||||
{
|
||||
setLayout( new MigLayout( "","[grow,fill]", "[grow,fill]" ) );
|
||||
|
||||
add( mEditor );
|
||||
}
|
||||
|
||||
public boolean isModified()
|
||||
{
|
||||
if( mEditor != null )
|
||||
{
|
||||
return mEditor.isModified();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if( mEditor != null )
|
||||
{
|
||||
mEditor.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAliasAction( AliasAction aliasAction )
|
||||
{
|
||||
if( mEditor != null )
|
||||
{
|
||||
if( mEditor.isModified() )
|
||||
{
|
||||
int option = JOptionPane.showConfirmDialog(
|
||||
EditorContainer.this,
|
||||
"Action settings have changed. Do you want to save these changes?",
|
||||
"Save Changes?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE );
|
||||
|
||||
if( option == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mEditor.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
removeAll();
|
||||
|
||||
//This will always give us an editor
|
||||
mEditor = AliasFactory.getEditor( aliasAction );
|
||||
|
||||
add( mEditor );
|
||||
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void addAliasActionToList( final AliasAction action )
|
||||
{
|
||||
if( action != null && hasItem() )
|
||||
{
|
||||
final Alias alias = getItem();
|
||||
|
||||
alias.addAliasAction( action );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
setItem( alias );
|
||||
|
||||
mAliasActionList.setSelectedValue( action, true );
|
||||
|
||||
AliasActionEditor.this.setModified( true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public class AddAliasActionItem extends JMenuItem
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private AliasActionType mAliasActionType;
|
||||
|
||||
public AddAliasActionItem( AliasActionType type )
|
||||
{
|
||||
super( type.toString() );
|
||||
|
||||
mAliasActionType = type;
|
||||
|
||||
addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
final AliasAction action =
|
||||
AliasFactory.getAliasAction( mAliasActionType );
|
||||
|
||||
addAliasActionToList( action );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,11 +15,18 @@
|
||||
* 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 buffer;
|
||||
package alias.action;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import alias.AliasEvent;
|
||||
|
||||
public interface ByteBufferListener
|
||||
/**
|
||||
* Interface for receiving alias events. Each listener will receive
|
||||
* notification of all alias events.
|
||||
*/
|
||||
public interface AliasActionListener
|
||||
{
|
||||
public void receive( ByteBuffer buffer );
|
||||
/**
|
||||
* Notifies the listener that an alias event has occurred
|
||||
*/
|
||||
public void aliasChanged( AliasEvent event );
|
||||
}
|
||||
@@ -3,13 +3,9 @@ package alias.action;
|
||||
import java.util.List;
|
||||
|
||||
import message.Message;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import alias.Alias;
|
||||
import controller.ResourceManager;
|
||||
import controller.ThreadPoolManager;
|
||||
|
||||
/**
|
||||
* Manages all alias action events. Each received message is interrogated for
|
||||
@@ -20,14 +16,11 @@ import controller.ResourceManager;
|
||||
*/
|
||||
public class AliasActionManager implements Listener<Message>
|
||||
{
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( AliasActionManager.class );
|
||||
|
||||
private ResourceManager mResourceManager;
|
||||
private ThreadPoolManager mThreadPoolManager;
|
||||
|
||||
public AliasActionManager( ResourceManager resourceManager )
|
||||
public AliasActionManager( ThreadPoolManager threadPoolManager )
|
||||
{
|
||||
mResourceManager = resourceManager;
|
||||
mThreadPoolManager = threadPoolManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,8 +44,7 @@ public class AliasActionManager implements Listener<Message>
|
||||
* action needs to setup a timer, and provide the original
|
||||
* message to be used as part of the action (e.g. sending
|
||||
* the message as a text message to a cell phone */
|
||||
action.execute( mResourceManager.getThreadPoolManager(),
|
||||
alias, message );
|
||||
action.execute( mThreadPoolManager, alias, message );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.action;
|
||||
|
||||
import controller.ConfigurableNode;
|
||||
|
||||
public class AliasActionNode extends ConfigurableNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AliasActionNode( AliasAction action )
|
||||
{
|
||||
super( action );
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
getModel().getResourceManager().getPlaylistManager().save();
|
||||
}
|
||||
|
||||
public String getIconPath()
|
||||
{
|
||||
return "images/action.png";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,12 +15,23 @@
|
||||
* 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 source.tuner.frequency;
|
||||
package alias.action;
|
||||
|
||||
|
||||
public interface FrequencyChangeBroadcaster
|
||||
public enum AliasActionType
|
||||
{
|
||||
public abstract void addListener( FrequencyChangeListener listener );
|
||||
BEEP( "Beep" ),
|
||||
CLIP( "Play Clip" ),
|
||||
SCRIPT( "Run Script" );
|
||||
|
||||
public abstract void removeListener( FrequencyChangeListener listener );
|
||||
private String mLabel;
|
||||
|
||||
private AliasActionType( String label )
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,27 @@ package alias.action.beep;
|
||||
|
||||
import message.Message;
|
||||
import alias.Alias;
|
||||
import alias.action.AliasActionType;
|
||||
import alias.action.RecurringAction;
|
||||
|
||||
public class BeepAction extends RecurringAction
|
||||
{
|
||||
|
||||
@Override
|
||||
public AliasActionType getType()
|
||||
{
|
||||
return AliasActionType.BEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performAction( Alias alias, Message message )
|
||||
{
|
||||
System.out.println( "\007" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Beep";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,59 +17,75 @@
|
||||
******************************************************************************/
|
||||
package alias.action.beep;
|
||||
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SpinnerModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.action.AliasAction;
|
||||
import alias.action.RecurringAction.Interval;
|
||||
|
||||
public class BeepActionEditor extends JPanel implements ActionListener
|
||||
public class BeepActionEditor extends DocumentListenerEditor<AliasAction>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( BeepActionEditor.class );
|
||||
|
||||
private BeepActionNode mBeepActionNode;
|
||||
private JTextField mTextSiteID;
|
||||
private JComboBox<Interval> mComboInterval;
|
||||
private JSpinner mSpinnerPeriod;
|
||||
private static final String HELP_TEXT =
|
||||
"<html><h3>Beep Action</h3>"
|
||||
+ "This action will sound a beep according to the interval<br>"
|
||||
+ "that you select:<br><br>"
|
||||
+ "<b>Once:</b> Beep the first time the alias is active and<br>"
|
||||
+ "never again<br><br>"
|
||||
+ "<b>Once, Reset After Delay:</b> Beep once and suppress<br>"
|
||||
+ "subsequent beeps for the specified period in seconds.<br>"
|
||||
+ "After the reset period, beep again when the alias is active.<br><br>"
|
||||
+ "<b>Until Dismissed:</b> Beep every period seconds until you<br>"
|
||||
+ "click OK on the dialog that appears. Alerting is suppressed<br>"
|
||||
+ "for 15 seconds after you click OK.<br>"
|
||||
+ "</html>";
|
||||
|
||||
public BeepActionEditor( BeepActionNode beepActionNode )
|
||||
private JComboBox<Interval> mComboInterval;
|
||||
private JSlider mPeriodSlider;
|
||||
private JLabel mPeriodSliderLabel;
|
||||
|
||||
public BeepActionEditor( AliasAction aliasAction )
|
||||
{
|
||||
mBeepActionNode = beepActionNode;
|
||||
|
||||
initGUI();
|
||||
init();
|
||||
|
||||
setItem( aliasAction );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
public BeepAction getBeepAction()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Action: Beep" ), "span,align center" );
|
||||
if( getItem() instanceof BeepAction )
|
||||
{
|
||||
return (BeepAction)getItem();
|
||||
}
|
||||
|
||||
add( new JLabel( "Interval:" ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][]" ) );
|
||||
|
||||
add( new JLabel( "Beep Interval:" ) );
|
||||
|
||||
mComboInterval = new JComboBox<Interval>( Interval.values() );
|
||||
|
||||
mComboInterval.setSelectedItem( mBeepActionNode.getBeepAction().getInterval() );
|
||||
|
||||
mComboInterval.setToolTipText( HELP_TEXT );
|
||||
mComboInterval.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -81,71 +97,97 @@ public class BeepActionEditor extends JPanel implements ActionListener
|
||||
if( selected != null )
|
||||
{
|
||||
/* Enable/disable period spinner based on selection */
|
||||
mSpinnerPeriod.setEnabled( selected != Interval.ONCE );
|
||||
boolean enabled = selected != Interval.ONCE;
|
||||
|
||||
mBeepActionNode.getBeepAction().setInterval( selected );
|
||||
mPeriodSlider.setEnabled( enabled );
|
||||
mPeriodSliderLabel.setEnabled( enabled );
|
||||
}
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
});
|
||||
|
||||
add( mComboInterval, "wrap" );
|
||||
|
||||
final SpinnerModel model = new SpinnerNumberModel(
|
||||
mBeepActionNode.getBeepAction().getPeriod(), 1, 30, 1 );
|
||||
|
||||
final SpinnerModel model = new SpinnerNumberModel( 1, 1, 30, 1 );
|
||||
model.addChangeListener( new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mBeepActionNode.getBeepAction().setPeriod( (int)model.getValue() );
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
|
||||
mSpinnerPeriod = new JSpinner( model );
|
||||
|
||||
if( mBeepActionNode.getBeepAction().getInterval() == Interval.ONCE )
|
||||
mPeriodSlider = new JSlider( JSlider.HORIZONTAL, 1, 60, 1 );
|
||||
mPeriodSlider.setMajorTickSpacing( 10 );
|
||||
mPeriodSlider.setMinorTickSpacing( 2 );
|
||||
mPeriodSlider.setPaintTicks( true );
|
||||
mPeriodSlider.setLabelTable( mPeriodSlider.createStandardLabels( 10, 10 ) );
|
||||
mPeriodSlider.setPaintLabels( true );
|
||||
mPeriodSlider.addChangeListener( new ChangeListener()
|
||||
{
|
||||
mSpinnerPeriod.setEnabled( false );
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mPeriodSliderLabel.setText( "Period: " + mPeriodSlider.getValue() );
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
mPeriodSlider.setToolTipText( HELP_TEXT );
|
||||
|
||||
mPeriodSliderLabel = new JLabel( "Period: " + mPeriodSlider.getValue() + " " );
|
||||
add( mPeriodSliderLabel );
|
||||
add( mPeriodSlider, "wrap,grow" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( BeepActionEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( AliasAction item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
BeepAction beep = getBeepAction();
|
||||
|
||||
Interval interval = beep.getInterval();
|
||||
|
||||
mComboInterval.setSelectedItem( interval );
|
||||
|
||||
boolean enabled = interval != Interval.ONCE;
|
||||
|
||||
mPeriodSliderLabel.setEnabled( enabled );
|
||||
mPeriodSlider.setEnabled( enabled );
|
||||
mPeriodSlider.setValue( beep.getPeriod() );
|
||||
}
|
||||
|
||||
add( new JLabel( "Period:" ) );
|
||||
add( mSpinnerPeriod, "wrap" );
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "This action will sound a beep according to the interval that you select.\n\n" );
|
||||
sb.append( "Once - Beep the first time the alias is active and never again.\n\n" );
|
||||
sb.append( "Once, Reset After Delay - Beep once and suppress subsequent beeps for the specified period in seconds. After the reset period, it will beep again when the alias is active.\n\n" );
|
||||
sb.append( "Until Dismissed - Beep every period seconds until you click OK on the dialog that appears. Alerting is suppressed for 15 seconds after you click OK." );
|
||||
|
||||
JTextArea description = new JTextArea( sb.toString() );
|
||||
|
||||
description.setLineWrap( true );
|
||||
description.setBackground( getBackground() );
|
||||
|
||||
add( description, "growx,span" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( BeepActionEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( BeepActionEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
mBeepActionNode.save();
|
||||
mBeepActionNode.show();
|
||||
BeepAction beep = getBeepAction();
|
||||
|
||||
beep.setInterval( (Interval)mComboInterval.getSelectedItem() );
|
||||
beep.setPeriod( mPeriodSlider.getValue() );
|
||||
}
|
||||
|
||||
mBeepActionNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.action.beep;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import alias.AliasNode;
|
||||
import alias.action.AliasActionNode;
|
||||
|
||||
public class BeepActionNode extends AliasActionNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BeepActionNode( BeepAction beepAction )
|
||||
{
|
||||
super( beepAction );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new BeepActionEditor( this );
|
||||
}
|
||||
|
||||
public BeepAction getBeepAction()
|
||||
{
|
||||
return (BeepAction)getUserObject();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Action: Beep";
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
AliasNode parent = (AliasNode)getParent();
|
||||
|
||||
parent.getAlias().removeAliasAction( getBeepAction() );
|
||||
|
||||
/* Save before removing the node ... so that we still have
|
||||
* a reference to the parent's resources */
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( BeepActionNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( deleteItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.Alias;
|
||||
import alias.action.AliasActionType;
|
||||
import alias.action.RecurringAction;
|
||||
|
||||
public class ClipAction extends RecurringAction
|
||||
@@ -28,9 +29,14 @@ public class ClipAction extends RecurringAction
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliasActionType getType()
|
||||
{
|
||||
return AliasActionType.CLIP;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
|
||||
return mFilePath;
|
||||
}
|
||||
|
||||
@@ -87,4 +93,18 @@ public class ClipAction extends RecurringAction
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if( mFilePath == null )
|
||||
{
|
||||
return "Play Clip";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Play Clip: " + mFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,9 +17,14 @@
|
||||
******************************************************************************/
|
||||
package alias.action.clip;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JButton;
|
||||
@@ -27,9 +32,7 @@ import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpinnerModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
@@ -37,43 +40,58 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.action.AliasAction;
|
||||
import alias.action.RecurringAction.Interval;
|
||||
|
||||
public class ClipActionEditor extends JPanel implements ActionListener
|
||||
public class ClipActionEditor extends DocumentListenerEditor<AliasAction>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( ClipActionEditor.class );
|
||||
|
||||
private ClipActionNode mClipActionNode;
|
||||
private static final String PLEASE_SELECT_A_FILE = "Please select a file";
|
||||
private static final String HELP_TEXT =
|
||||
"<html><h3>Clip Action</h3>"
|
||||
+ "This action will play an audio clip according to the interval<br>"
|
||||
+ "that you select:<br><br>"
|
||||
+ "<b>Once:</b> play the first time the alias is active and<br>"
|
||||
+ "never again<br><br>"
|
||||
+ "<b>Once, Reset After Delay:</b> play once and suppress<br>"
|
||||
+ "subsequent runs for the specified period in seconds.<br>"
|
||||
+ "After the reset period, play again when the alias is active.<br><br>"
|
||||
+ "<b>Until Dismissed:</b> play every period seconds until you<br>"
|
||||
+ "click OK on the dialog that appears. Alerting is suppressed<br>"
|
||||
+ "for 15 seconds after you click OK.<br>"
|
||||
+ "</html>";
|
||||
|
||||
private JComboBox<Interval> mComboInterval;
|
||||
private JSpinner mSpinnerPeriod;
|
||||
private JSlider mPeriodSlider;
|
||||
private JLabel mPeriodSliderLabel;
|
||||
private JTextField mTextFilePath;
|
||||
|
||||
public ClipActionEditor( ClipActionNode clipActionNode )
|
||||
public ClipActionEditor( AliasAction aliasAction )
|
||||
{
|
||||
mClipActionNode = clipActionNode;
|
||||
|
||||
initGUI();
|
||||
init();
|
||||
|
||||
setItem( aliasAction );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
public ClipAction getClipAction()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Action: Audio Clip" ), "span,align center" );
|
||||
if( getItem() instanceof ClipAction )
|
||||
{
|
||||
return (ClipAction)getItem();
|
||||
}
|
||||
|
||||
add( new JLabel( "Interval:" ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][]" ) );
|
||||
|
||||
add( new JLabel( "Play Interval:" ) );
|
||||
|
||||
mComboInterval = new JComboBox<Interval>( Interval.values() );
|
||||
|
||||
mComboInterval.setSelectedItem( mClipActionNode.getClipAction().getInterval() );
|
||||
|
||||
mComboInterval.setToolTipText( HELP_TEXT );
|
||||
mComboInterval.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -84,37 +102,51 @@ public class ClipActionEditor extends JPanel implements ActionListener
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
/* Enable/disable period spinner based on selection */
|
||||
mSpinnerPeriod.setEnabled( selected != Interval.ONCE );
|
||||
/* Enable/disable period slider based on selection */
|
||||
boolean enabled = selected != Interval.ONCE;
|
||||
|
||||
mClipActionNode.getClipAction().setInterval( selected );
|
||||
mPeriodSlider.setEnabled( enabled );
|
||||
mPeriodSliderLabel.setEnabled( enabled );
|
||||
}
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
});
|
||||
|
||||
add( mComboInterval, "wrap" );
|
||||
add( mComboInterval );
|
||||
|
||||
final SpinnerModel model = new SpinnerNumberModel(
|
||||
mClipActionNode.getClipAction().getPeriod(), 1, 30, 1 );
|
||||
|
||||
final SpinnerModel model = new SpinnerNumberModel( 1, 1, 30, 1 );
|
||||
model.addChangeListener( new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mClipActionNode.getClipAction().setPeriod( (int)model.getValue() );
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
|
||||
mSpinnerPeriod = new JSpinner( model );
|
||||
|
||||
if( mClipActionNode.getClipAction().getInterval() == Interval.ONCE )
|
||||
mPeriodSlider = new JSlider( JSlider.HORIZONTAL, 1, 60, 1 );
|
||||
mPeriodSlider.setMajorTickSpacing( 10 );
|
||||
mPeriodSlider.setMinorTickSpacing( 2 );
|
||||
mPeriodSlider.setPaintTicks( true );
|
||||
mPeriodSlider.setLabelTable( mPeriodSlider.createStandardLabels( 10, 10 ) );
|
||||
mPeriodSlider.setPaintLabels( true );
|
||||
mPeriodSlider.addChangeListener( new ChangeListener()
|
||||
{
|
||||
mSpinnerPeriod.setEnabled( false );
|
||||
}
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mPeriodSliderLabel.setText( "Period: " + mPeriodSlider.getValue() );
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
mPeriodSlider.setToolTipText( HELP_TEXT );
|
||||
|
||||
add( new JLabel( "Period:" ) );
|
||||
add( mSpinnerPeriod, "wrap" );
|
||||
mPeriodSliderLabel = new JLabel( "Period: " + mPeriodSlider.getValue() + " " );
|
||||
add( mPeriodSliderLabel );
|
||||
add( mPeriodSlider, "wrap,grow" );
|
||||
|
||||
mTextFilePath = new JTextField( PLEASE_SELECT_A_FILE );
|
||||
add( mTextFilePath, "growx,span" );
|
||||
|
||||
JButton fileButton = new JButton( "File" );
|
||||
|
||||
@@ -131,88 +163,134 @@ public class ClipActionEditor extends JPanel implements ActionListener
|
||||
{
|
||||
File file = chooser.getSelectedFile();
|
||||
|
||||
mClipActionNode.getClipAction().setPath( file.getAbsolutePath() );
|
||||
mTextFilePath.setText( file.getAbsolutePath() );
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
add( fileButton );
|
||||
add( fileButton, "grow" );
|
||||
|
||||
JButton testButton = new JButton( "Test" );
|
||||
testButton.addActionListener( new ActionListener()
|
||||
|
||||
testButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent actionEvent )
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String path = mClipActionNode.getClipAction().getPath();
|
||||
|
||||
if( path == null || path.trim().isEmpty() )
|
||||
if( hasItem() )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||
"Please select an audio file", "Please select file",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
String path = mTextFilePath.getText();
|
||||
|
||||
if( path == null || path.trim().isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
mClipActionNode.getClipAction().play();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||
"Couldn't play audio clip [" + e.getMessage() + "]",
|
||||
"Error", JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||
"Please select an audio file", PLEASE_SELECT_A_FILE,
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
} );
|
||||
else
|
||||
{
|
||||
if( isModified() )
|
||||
{
|
||||
int option = JOptionPane.showConfirmDialog(
|
||||
ClipActionEditor.this,
|
||||
"Settings have changed. Do you want to save these changes?",
|
||||
"Save Changes?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE );
|
||||
|
||||
if( option == JOptionPane.YES_OPTION )
|
||||
{
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
new Thread( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
getClipAction().play();
|
||||
}
|
||||
catch( Exception e1 )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||
"Couldn't play audio clip [" + e1.getMessage() + "]",
|
||||
"Error", JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
add( testButton, "wrap" );
|
||||
|
||||
mTextFilePath = new JTextField( mClipActionNode.getClipAction().getPath() );
|
||||
add( mTextFilePath, "growx,span" );
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
add( testButton, "grow,wrap" );
|
||||
|
||||
sb.append( "This action will play the audio clip according to the interval that you select.\n\n" );
|
||||
sb.append( "Once - Play the first time the alias is active and never again.\n\n" );
|
||||
sb.append( "Once, Reset After Delay - Play once and suppress subsequent plays for the specified period in seconds. After the reset period, it will play again when the alias is active.\n\n" );
|
||||
sb.append( "Until Dismissed - Play audio clip every period seconds until you click OK on the dialog that appears. Alerting is suppressed for 15 seconds after you click OK." );
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( AliasAction item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
JTextArea description = new JTextArea( sb.toString() );
|
||||
|
||||
description.setLineWrap( true );
|
||||
description.setBackground( getBackground() );
|
||||
|
||||
add( description, "growx,span" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( ClipActionEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
if( hasItem() )
|
||||
{
|
||||
ClipAction clip = getClipAction();
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( ClipActionEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
Interval interval = clip.getInterval();
|
||||
|
||||
mComboInterval.setSelectedItem( interval );
|
||||
|
||||
boolean enabled = interval != Interval.ONCE;
|
||||
|
||||
mPeriodSliderLabel.setEnabled( enabled );
|
||||
mPeriodSlider.setEnabled( enabled );
|
||||
mPeriodSlider.setValue( clip.getPeriod() );
|
||||
|
||||
String filepath = clip.getPath();
|
||||
|
||||
if( filepath != null && !filepath.isEmpty() )
|
||||
{
|
||||
mTextFilePath.setText( filepath );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextFilePath.setText( PLEASE_SELECT_A_FILE );
|
||||
}
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
mClipActionNode.save();
|
||||
mClipActionNode.show();
|
||||
ClipAction script = getClipAction();
|
||||
|
||||
script.setInterval( (Interval)mComboInterval.getSelectedItem() );
|
||||
script.setPeriod( mPeriodSlider.getValue() );
|
||||
script.setPath( mTextFilePath.getText() );
|
||||
}
|
||||
|
||||
mClipActionNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.action.clip;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import alias.AliasNode;
|
||||
import alias.action.AliasActionNode;
|
||||
|
||||
public class ClipActionNode extends AliasActionNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ClipActionNode( ClipAction clipAction )
|
||||
{
|
||||
super( clipAction );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new ClipActionEditor( this );
|
||||
}
|
||||
|
||||
public ClipAction getClipAction()
|
||||
{
|
||||
return (ClipAction)getUserObject();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Action: Audio Clip";
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
AliasNode parent = (AliasNode)getParent();
|
||||
|
||||
parent.getAlias().removeAliasAction( getClipAction() );
|
||||
|
||||
/* Save before removing the node ... so that we still have
|
||||
* a reference to the parent's resources */
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( ClipActionNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( deleteItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.Alias;
|
||||
import alias.action.AliasActionType;
|
||||
import alias.action.RecurringAction;
|
||||
|
||||
public class ScriptAction extends RecurringAction
|
||||
@@ -21,6 +22,12 @@ public class ScriptAction extends RecurringAction
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliasActionType getType()
|
||||
{
|
||||
return AliasActionType.SCRIPT;
|
||||
}
|
||||
|
||||
public String getScript()
|
||||
{
|
||||
return mScript;
|
||||
@@ -75,4 +82,17 @@ public class ScriptAction extends RecurringAction
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if( mScript == null )
|
||||
{
|
||||
return "Run Script";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Run Script: " + mScript;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,9 +17,14 @@
|
||||
******************************************************************************/
|
||||
package alias.action.script;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JButton;
|
||||
@@ -27,9 +32,7 @@ import javax.swing.JComboBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpinnerModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
@@ -37,43 +40,58 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.action.AliasAction;
|
||||
import alias.action.RecurringAction.Interval;
|
||||
|
||||
public class ScriptActionEditor extends JPanel implements ActionListener
|
||||
public class ScriptActionEditor extends DocumentListenerEditor<AliasAction>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( ScriptActionEditor.class );
|
||||
|
||||
private ScriptActionNode mScriptActionNode;
|
||||
private static final String PLEASE_SELECT_A_FILE = "Please select a file";
|
||||
private static final String HELP_TEXT =
|
||||
"<html><h3>Script Action</h3>"
|
||||
+ "This action will run a script according to the interval<br>"
|
||||
+ "that you select:<br><br>"
|
||||
+ "<b>Once:</b> run the first time the alias is active and<br>"
|
||||
+ "never again<br><br>"
|
||||
+ "<b>Once, Reset After Delay:</b> run once and suppress<br>"
|
||||
+ "subsequent runs for the specified period in seconds.<br>"
|
||||
+ "After the reset period, run again when the alias is active.<br><br>"
|
||||
+ "<b>Until Dismissed:</b> run every period seconds until you<br>"
|
||||
+ "click OK on the dialog that appears. Alerting is suppressed<br>"
|
||||
+ "for 15 seconds after you click OK.<br>"
|
||||
+ "</html>";
|
||||
|
||||
private JComboBox<Interval> mComboInterval;
|
||||
private JSpinner mSpinnerPeriod;
|
||||
private JSlider mPeriodSlider;
|
||||
private JLabel mPeriodSliderLabel;
|
||||
private JTextField mTextFilePath;
|
||||
|
||||
public ScriptActionEditor( ScriptActionNode clipActionNode )
|
||||
public ScriptActionEditor( AliasAction aliasAction )
|
||||
{
|
||||
mScriptActionNode = clipActionNode;
|
||||
|
||||
initGUI();
|
||||
init();
|
||||
|
||||
setItem( aliasAction );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
public ScriptAction getScriptAction()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Action: Script" ), "span,align center" );
|
||||
if( getItem() instanceof ScriptAction )
|
||||
{
|
||||
return (ScriptAction)getItem();
|
||||
}
|
||||
|
||||
add( new JLabel( "Interval:" ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][]" ) );
|
||||
|
||||
add( new JLabel( "Run Interval:" ) );
|
||||
|
||||
mComboInterval = new JComboBox<Interval>( Interval.values() );
|
||||
|
||||
mComboInterval.setSelectedItem( mScriptActionNode.getScriptAction().getInterval() );
|
||||
|
||||
mComboInterval.setToolTipText( HELP_TEXT );
|
||||
mComboInterval.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -84,37 +102,51 @@ public class ScriptActionEditor extends JPanel implements ActionListener
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
/* Enable/disable period spinner based on selection */
|
||||
mSpinnerPeriod.setEnabled( selected != Interval.ONCE );
|
||||
/* Enable/disable period slider based on selection */
|
||||
boolean enabled = selected != Interval.ONCE;
|
||||
|
||||
mScriptActionNode.getScriptAction().setInterval( selected );
|
||||
mPeriodSlider.setEnabled( enabled );
|
||||
mPeriodSliderLabel.setEnabled( enabled );
|
||||
}
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
});
|
||||
|
||||
add( mComboInterval, "wrap" );
|
||||
add( mComboInterval );
|
||||
|
||||
final SpinnerModel model = new SpinnerNumberModel(
|
||||
mScriptActionNode.getScriptAction().getPeriod(), 1, 30, 1 );
|
||||
|
||||
final SpinnerModel model = new SpinnerNumberModel( 1, 1, 30, 1 );
|
||||
model.addChangeListener( new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mScriptActionNode.getScriptAction().setPeriod( (int)model.getValue() );
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
|
||||
mSpinnerPeriod = new JSpinner( model );
|
||||
|
||||
if( mScriptActionNode.getScriptAction().getInterval() == Interval.ONCE )
|
||||
mPeriodSlider = new JSlider( JSlider.HORIZONTAL, 1, 60, 1 );
|
||||
mPeriodSlider.setMajorTickSpacing( 10 );
|
||||
mPeriodSlider.setMinorTickSpacing( 2 );
|
||||
mPeriodSlider.setPaintTicks( true );
|
||||
mPeriodSlider.setLabelTable( mPeriodSlider.createStandardLabels( 10, 10 ) );
|
||||
mPeriodSlider.setPaintLabels( true );
|
||||
mPeriodSlider.addChangeListener( new ChangeListener()
|
||||
{
|
||||
mSpinnerPeriod.setEnabled( false );
|
||||
}
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mPeriodSliderLabel.setText( "Period: " + mPeriodSlider.getValue() );
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
mPeriodSlider.setToolTipText( HELP_TEXT );
|
||||
|
||||
add( new JLabel( "Period:" ) );
|
||||
add( mSpinnerPeriod, "wrap" );
|
||||
mPeriodSliderLabel = new JLabel( "Period: " + mPeriodSlider.getValue() + " " );
|
||||
add( mPeriodSliderLabel );
|
||||
add( mPeriodSlider, "wrap,grow" );
|
||||
|
||||
mTextFilePath = new JTextField( PLEASE_SELECT_A_FILE );
|
||||
add( mTextFilePath, "growx,span" );
|
||||
|
||||
JButton fileButton = new JButton( "File" );
|
||||
|
||||
@@ -131,13 +163,14 @@ public class ScriptActionEditor extends JPanel implements ActionListener
|
||||
{
|
||||
File file = chooser.getSelectedFile();
|
||||
|
||||
mScriptActionNode.getScriptAction().setScript( file.getAbsolutePath() );
|
||||
mTextFilePath.setText( file.getAbsolutePath() );
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
add( fileButton );
|
||||
add( fileButton, "grow" );
|
||||
|
||||
JButton testButton = new JButton( "Test" );
|
||||
testButton.addActionListener( new ActionListener()
|
||||
@@ -145,74 +178,115 @@ public class ScriptActionEditor extends JPanel implements ActionListener
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent actionEvent )
|
||||
{
|
||||
String script = mScriptActionNode.getScriptAction().getScript();
|
||||
String script = mTextFilePath.getText();
|
||||
|
||||
if( script == null || script.trim().isEmpty() )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ScriptActionEditor.this,
|
||||
"Please select a script file", "Please select file",
|
||||
"Please select a script file", PLEASE_SELECT_A_FILE,
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
else
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
if( isModified() )
|
||||
{
|
||||
try
|
||||
int option = JOptionPane.showConfirmDialog(
|
||||
ScriptActionEditor.this,
|
||||
"Settings have changed. Do you want to save these changes?",
|
||||
"Save Changes?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE );
|
||||
|
||||
if( option == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mScriptActionNode.getScriptAction().play();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ScriptActionEditor.this,
|
||||
"Couldn't run script [" + e.getMessage() + "]",
|
||||
"Error", JOptionPane.ERROR_MESSAGE );
|
||||
save();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
new Thread( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
getScriptAction().play();
|
||||
}
|
||||
catch( Exception e1 )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ScriptActionEditor.this,
|
||||
e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
add( testButton, "wrap" );
|
||||
add( testButton, "grow,wrap" );
|
||||
|
||||
mTextFilePath = new JTextField( mScriptActionNode.getScriptAction().getScript() );
|
||||
add( mTextFilePath, "growx,span" );
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ScriptActionEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( AliasAction item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
ScriptAction script = getScriptAction();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "This action will run the script according to the interval that you select.\n\n" );
|
||||
sb.append( "Once - Run script the first time the alias is active and never again.\n\n" );
|
||||
sb.append( "Once, Reset After Delay - Run once and suppress subsequent runs for the specified period in seconds. After the reset period, it will play again when the alias is active.\n\n" );
|
||||
sb.append( "Until Dismissed - Run script every period seconds until you click OK on the dialog that appears. Alerting is suppressed for 15 seconds after you click OK." );
|
||||
|
||||
JTextArea description = new JTextArea( sb.toString() );
|
||||
|
||||
description.setLineWrap( true );
|
||||
description.setBackground( getBackground() );
|
||||
|
||||
add( description, "growx,span" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( ScriptActionEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
Interval interval = script.getInterval();
|
||||
|
||||
mComboInterval.setSelectedItem( interval );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( ScriptActionEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
boolean enabled = interval != Interval.ONCE;
|
||||
|
||||
mPeriodSliderLabel.setEnabled( enabled );
|
||||
mPeriodSlider.setEnabled( enabled );
|
||||
mPeriodSlider.setValue( script.getPeriod() );
|
||||
|
||||
String filepath = script.getScript();
|
||||
|
||||
if( filepath != null && !filepath.isEmpty() )
|
||||
{
|
||||
mTextFilePath.setText( filepath );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextFilePath.setText( PLEASE_SELECT_A_FILE );
|
||||
}
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
mScriptActionNode.save();
|
||||
mScriptActionNode.show();
|
||||
ScriptAction script = getScriptAction();
|
||||
|
||||
script.setInterval( (Interval)mComboInterval.getSelectedItem() );
|
||||
script.setPeriod( mPeriodSlider.getValue() );
|
||||
script.setScript( mTextFilePath.getText() );
|
||||
}
|
||||
|
||||
mScriptActionNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.action.script;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import alias.AliasNode;
|
||||
import alias.action.AliasActionNode;
|
||||
|
||||
public class ScriptActionNode extends AliasActionNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ScriptActionNode( ScriptAction scriptAction )
|
||||
{
|
||||
super( scriptAction );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new ScriptActionEditor( this );
|
||||
}
|
||||
|
||||
public ScriptAction getScriptAction()
|
||||
{
|
||||
return (ScriptAction)getUserObject();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Action: Script";
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
AliasNode parent = (AliasNode)getParent();
|
||||
|
||||
parent.getAlias().removeAliasAction( getScriptAction() );
|
||||
|
||||
/* Save before removing the node ... so that we still have
|
||||
* a reference to the parent's resources */
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( ScriptActionNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( deleteItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
52
src/alias/id/AliasID.java
Normal file
52
src/alias/id/AliasID.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
import playlist.version1.Group;
|
||||
import alias.id.esn.Esn;
|
||||
import alias.id.fleetsync.FleetsyncID;
|
||||
import alias.id.lojack.LoJackFunctionAndID;
|
||||
import alias.id.mdc.MDC1200ID;
|
||||
import alias.id.mobileID.Min;
|
||||
import alias.id.mpt1327.MPT1327ID;
|
||||
import alias.id.nonrecordable.NonRecordable;
|
||||
import alias.id.priority.Priority;
|
||||
import alias.id.siteID.SiteID;
|
||||
import alias.id.status.StatusID;
|
||||
import alias.id.talkgroup.TalkgroupID;
|
||||
import alias.id.uniqueID.UniqueID;
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
@XmlSeeAlso( { Esn.class, FleetsyncID.class, Group.class, LoJackFunctionAndID.class,
|
||||
MDC1200ID.class, Min.class, MPT1327ID.class, NonRecordable.class,
|
||||
Priority.class, SiteID.class, StatusID.class, TalkgroupID.class,
|
||||
UniqueID.class } )
|
||||
@XmlRootElement( name = "id" )
|
||||
public abstract class AliasID
|
||||
{
|
||||
public AliasID()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract AliasIDType getType();
|
||||
|
||||
public abstract boolean matches( AliasID id );
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,20 +15,35 @@
|
||||
* 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;
|
||||
package alias.id;
|
||||
|
||||
public enum AliasIDType
|
||||
{
|
||||
ESN,
|
||||
Fleetsync,
|
||||
LoJack,
|
||||
LTRNetUID,
|
||||
MDC1200,
|
||||
MIN,
|
||||
MPT1327,
|
||||
NonRecordable,
|
||||
Priority,
|
||||
Site,
|
||||
Status,
|
||||
Talkgroup;
|
||||
ESN( "ESN" ),
|
||||
Fleetsync( "Fleetsync" ),
|
||||
LoJack( "LoJack" ),
|
||||
LTRNetUID( "LTR-Net UID" ),
|
||||
MDC1200( "MDC-1200" ),
|
||||
MIN( "Passport MIN" ),
|
||||
MPT1327( "MPT-1327" ),
|
||||
Site( "Site" ),
|
||||
Status( "Status" ),
|
||||
Talkgroup( "Talkgroup" ),
|
||||
|
||||
Invert( "Audio Inversion" ),
|
||||
Priority( "Audio Priority" ),
|
||||
NonRecordable( "Audio Non-Recordable" ),
|
||||
Streaming( "Audio Streaming" );
|
||||
|
||||
private String mLabel;
|
||||
|
||||
private AliasIDType( String label )
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
}
|
||||
385
src/alias/id/AliasIdentifierEditor.java
Normal file
385
src/alias/id/AliasIdentifierEditor.java
Normal file
@@ -0,0 +1,385 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id;
|
||||
|
||||
import gui.editor.Editor;
|
||||
import gui.editor.EmptyEditor;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.Alias;
|
||||
import alias.AliasEvent;
|
||||
import alias.AliasEvent.Event;
|
||||
import alias.AliasFactory;
|
||||
import alias.AliasModel;
|
||||
|
||||
public class AliasIdentifierEditor extends Editor<Alias>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static ListModel<AliasID> EMPTY_MODEL = new DefaultListModel<>();
|
||||
private JList<AliasID> mAliasIDList = new JList<>( EMPTY_MODEL );
|
||||
private JButton mNewIDButton;
|
||||
private JButton mCloneIDButton;
|
||||
private JButton mDeleteIDButton;
|
||||
private EditorContainer mEditorContainer = new EditorContainer();
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
|
||||
public AliasIdentifierEditor( AliasModel model )
|
||||
{
|
||||
mAliasModel = model;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 3",
|
||||
"[grow,fill][grow,fill][grow,fill]", "[][grow,fill][]" ) );
|
||||
|
||||
mAliasIDList.setVisibleRowCount( 6 );
|
||||
mAliasIDList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
mAliasIDList.setLayoutOrientation( JList.VERTICAL );
|
||||
mAliasIDList.addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
JList<?> list = (JList<?>)event.getSource();
|
||||
|
||||
Object selectedItem = list.getSelectedValue();
|
||||
|
||||
if( selectedItem != null && selectedItem instanceof AliasID )
|
||||
{
|
||||
AliasID selected = (AliasID)selectedItem;
|
||||
|
||||
mEditorContainer.setAliasID( selected );
|
||||
|
||||
mCloneIDButton.setEnabled( true );
|
||||
mDeleteIDButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCloneIDButton.setEnabled( false );
|
||||
mDeleteIDButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
JScrollPane scroller = new JScrollPane( mAliasIDList );
|
||||
add( scroller, "span,grow" );
|
||||
|
||||
add( mEditorContainer, "span,grow" );
|
||||
|
||||
mNewIDButton = new JButton( "New ..." );
|
||||
mNewIDButton.setToolTipText( "Create a new Alias Identifier" );
|
||||
mNewIDButton.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.ESN ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.Fleetsync ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.LoJack ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.LTRNetUID ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.MDC1200 ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.MPT1327 ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.MIN ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.Site ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.Status ) );
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.Talkgroup ) );
|
||||
|
||||
boolean separatorAdded = false;
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
Alias alias = getItem();
|
||||
|
||||
if( !alias.hasCallPriority() )
|
||||
{
|
||||
if( !separatorAdded )
|
||||
{
|
||||
menu.addSeparator();
|
||||
separatorAdded = true;
|
||||
}
|
||||
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.Priority ) );
|
||||
}
|
||||
|
||||
if( alias.isRecordable() )
|
||||
{
|
||||
if( !separatorAdded )
|
||||
{
|
||||
menu.addSeparator();
|
||||
separatorAdded = true;
|
||||
}
|
||||
|
||||
menu.add( new AddAliasIdentifierItem( AliasIDType.NonRecordable ) );
|
||||
}
|
||||
}
|
||||
|
||||
menu.show( e.getComponent(), e.getX(), e.getY() );
|
||||
}
|
||||
} );
|
||||
|
||||
add( mNewIDButton );
|
||||
|
||||
mCloneIDButton = new JButton( "Clone" );
|
||||
mCloneIDButton.setToolTipText( "Create a copy of the currently selected identifier" );
|
||||
mCloneIDButton.setEnabled( false );
|
||||
mCloneIDButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
AliasID selected = mAliasIDList.getSelectedValue();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
AliasID clone = AliasFactory.copyOf( selected );
|
||||
|
||||
if( clone != null )
|
||||
{
|
||||
addAliasIDToList( clone );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mCloneIDButton );
|
||||
|
||||
mDeleteIDButton = new JButton( "Delete" );
|
||||
mDeleteIDButton.setToolTipText( "Delete the currently selected identifier" );
|
||||
mDeleteIDButton.setEnabled( false );
|
||||
mDeleteIDButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
final AliasID selected = mAliasIDList.getSelectedValue();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( mDeleteIDButton,
|
||||
"Do you want to delete [" + selected.toString() + "]",
|
||||
"Are you sure?", JOptionPane.YES_NO_OPTION );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION && hasItem() )
|
||||
{
|
||||
Alias alias = getItem();
|
||||
|
||||
alias.removeAliasID( selected );
|
||||
|
||||
mAliasModel.broadcast( new AliasEvent( alias, Event.CHANGE ) );
|
||||
|
||||
setItem( alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
add( mDeleteIDButton, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( Alias alias )
|
||||
{
|
||||
super.setItem( alias );
|
||||
|
||||
if( alias == null || alias.getId().isEmpty() )
|
||||
{
|
||||
mAliasIDList.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultListModel<AliasID> model = new DefaultListModel<AliasID>();
|
||||
|
||||
List<AliasID> ids = alias.getId();
|
||||
|
||||
Collections.sort( ids, new Comparator<AliasID>()
|
||||
{
|
||||
@Override
|
||||
public int compare( AliasID o1, AliasID o2 )
|
||||
{
|
||||
return o1.toString().compareTo( o2.toString() );
|
||||
}
|
||||
} );
|
||||
|
||||
for( AliasID id: ids )
|
||||
{
|
||||
model.addElement( id );
|
||||
}
|
||||
|
||||
mAliasIDList.setModel( model );
|
||||
}
|
||||
|
||||
mEditorContainer.setAliasID( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( isModified() || mEditorContainer.isModified() )
|
||||
{
|
||||
if( mEditorContainer.isModified() )
|
||||
{
|
||||
mEditorContainer.save();
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mAliasModel.broadcast( new AliasEvent( getItem(), Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EditorContainer extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Editor<AliasID> mEditor = new EmptyEditor<>();
|
||||
|
||||
public EditorContainer()
|
||||
{
|
||||
setLayout( new MigLayout( "","[grow,fill]", "[grow,fill]" ) );
|
||||
|
||||
add( mEditor );
|
||||
}
|
||||
|
||||
public boolean isModified()
|
||||
{
|
||||
if( mEditor != null )
|
||||
{
|
||||
return mEditor.isModified();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if( mEditor != null )
|
||||
{
|
||||
mEditor.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAliasID( AliasID aliasID )
|
||||
{
|
||||
if( mEditor != null )
|
||||
{
|
||||
if( mEditor.isModified() )
|
||||
{
|
||||
int option = JOptionPane.showConfirmDialog(
|
||||
EditorContainer.this,
|
||||
"Identifier settings have changed. Do you want to save these changes?",
|
||||
"Save Changes?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE );
|
||||
|
||||
if( option == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mEditor.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
removeAll();
|
||||
|
||||
//This will always give us an editor
|
||||
mEditor = AliasFactory.getEditor( aliasID );
|
||||
|
||||
add( mEditor );
|
||||
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void addAliasIDToList( final AliasID id )
|
||||
{
|
||||
if( id != null && hasItem() )
|
||||
{
|
||||
final Alias alias = getItem();
|
||||
|
||||
alias.addAliasID( id );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
setItem( alias );
|
||||
|
||||
mAliasIDList.setSelectedValue( id, true );
|
||||
|
||||
AliasIdentifierEditor.this.setModified( true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public class AddAliasIdentifierItem extends JMenuItem
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private AliasIDType mAliasIDType;
|
||||
|
||||
public AddAliasIdentifierItem( AliasIDType type )
|
||||
{
|
||||
super( type.toString() );
|
||||
|
||||
mAliasIDType = type;
|
||||
|
||||
addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
final AliasID id = AliasFactory.getAliasID( mAliasIDType );
|
||||
|
||||
addAliasIDToList( id );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,79 +17,102 @@
|
||||
******************************************************************************/
|
||||
package alias.id.esn;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
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;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class ESNEditor extends JPanel implements ActionListener
|
||||
public class ESNEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private ESNNode mESNNode;
|
||||
private JTextField mTextESN;
|
||||
|
||||
public ESNEditor( ESNNode esnNode )
|
||||
private static final String HELP_TEXT =
|
||||
"<html><h3>Electronic Serial Number (ESN)</h3>"
|
||||
+ "<b>ESN:</b> hexadecimal 0-9, A-F (e.g. <u>ABCD1234</u> )<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) to wildcard individual<br>"
|
||||
+ "digits (e.g. <u>ABCD123*</u> or <u>AB**1**4</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public ESNEditor( AliasID aliasID )
|
||||
{
|
||||
mESNNode = esnNode;
|
||||
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Electronic Serial Number ID" ), "span,align center" );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "ESN:" ) );
|
||||
mTextESN = new JTextField( mESNNode.getESN().getEsn() );
|
||||
add( mTextESN, "growx,push" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( ESNEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
mTextField = new JTextField();
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( ESNEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( ESNEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public Esn getEsn()
|
||||
{
|
||||
if( getItem() instanceof Esn )
|
||||
{
|
||||
return (Esn)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
Esn esn = getEsn();
|
||||
|
||||
if( esn != null )
|
||||
{
|
||||
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() );
|
||||
mTextField.setText( esn.getEsn() );
|
||||
}
|
||||
|
||||
mESNNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
Esn esn = getEsn();
|
||||
|
||||
if( esn != null )
|
||||
{
|
||||
esn.setEsn( mTextField.getText() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.esn;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package alias.id.esn;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class Esn extends AliasID
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@ package alias.id.fleetsync;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
|
||||
public class FleetsyncID extends AliasID
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,92 +17,123 @@
|
||||
******************************************************************************/
|
||||
package alias.id.fleetsync;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.text.MaskFormatter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import controller.ConfigurableNode;
|
||||
|
||||
public class FleetsyncIDEditor extends JPanel implements ActionListener
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class FleetsyncIDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private FleetsyncIDNode mFleetsyncIDNode;
|
||||
|
||||
private JLabel mLabelName;
|
||||
private JTextField mTextIdent;
|
||||
private final static Logger mLog = LoggerFactory.getLogger( FleetsyncIDEditor.class );
|
||||
|
||||
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";
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FleetsyncIDEditor( FleetsyncIDNode fsNode )
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>Fleetsync Identifier</h3>"
|
||||
+ "<b>Fleetsync:</b> ggg-uuuu where g=Group and u=Unit (e.g. <u>001-0001</u>)<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) for each digit (e.g. <u>001-****</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public FleetsyncIDEditor( AliasID aliasID )
|
||||
{
|
||||
mFleetsyncIDNode = fsNode;
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "Fleetsync ID" ), "span,align center" );
|
||||
add( new JLabel( "Fleetsync ID:" ) );
|
||||
|
||||
add( new JLabel( "Ident:" ) );
|
||||
mTextIdent = new JTextField( mFleetsyncIDNode.getFleetsyncID().getIdent() );
|
||||
MaskFormatter formatter = null;
|
||||
|
||||
add( mTextIdent, "grow, wrap" );
|
||||
try
|
||||
{
|
||||
//Mask: 3 digits - 4 digits
|
||||
formatter = new MaskFormatter( "###-####" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, the mask was invalid
|
||||
}
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( FleetsyncIDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
mTextField = new JFormattedTextField( formatter );
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( FleetsyncIDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JTextArea helpText = new JTextArea( mHelpText );
|
||||
helpText.setLineWrap( true );
|
||||
helpText.setBackground( getBackground() );
|
||||
add( helpText, "span,grow,push" );
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( FleetsyncIDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public FleetsyncID getFleetsyncID()
|
||||
{
|
||||
if( getItem() instanceof FleetsyncID )
|
||||
{
|
||||
return (FleetsyncID)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
FleetsyncID fleetsync = getFleetsyncID();
|
||||
|
||||
if( fleetsync != null )
|
||||
{
|
||||
String ident = mTextIdent.getText();
|
||||
|
||||
if( ident != null )
|
||||
{
|
||||
mFleetsyncIDNode.getFleetsyncID().setIdent( ident );
|
||||
mTextField.setText( fleetsync.getIdent() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
((ConfigurableNode)mFleetsyncIDNode.getParent()).sort();
|
||||
|
||||
mFleetsyncIDNode.save();
|
||||
|
||||
mFleetsyncIDNode.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( FleetsyncIDEditor.this, "Please enter an ident" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
FleetsyncID fleetsync = getFleetsyncID();
|
||||
|
||||
if( fleetsync != null )
|
||||
{
|
||||
mTextIdent.setText( mFleetsyncIDNode.getFleetsyncID().getIdent() );
|
||||
fleetsync.setIdent( mTextField.getText() );
|
||||
}
|
||||
|
||||
mFleetsyncIDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.fleetsync;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.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 net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import controller.ConfigurableNode;
|
||||
|
||||
public class StatusIDEditor extends JPanel implements ActionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( StatusIDEditor.class );
|
||||
|
||||
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 )
|
||||
{
|
||||
mLog.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();
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.fleetsync;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import module.decode.lj1200.LJ1200Message;
|
||||
import module.decode.lj1200.LJ1200Message.Function;
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class LoJackFunctionAndID extends AliasID
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2015 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,112 +17,151 @@
|
||||
******************************************************************************/
|
||||
package alias.id.lojack;
|
||||
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.text.MaskFormatter;
|
||||
|
||||
import module.decode.lj1200.LJ1200Message;
|
||||
import module.decode.lj1200.LJ1200Message.Function;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import controller.ConfigurableNode;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class LoJackIDEditor extends JPanel implements ActionListener
|
||||
public class LoJackIDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private LoJackIDNode mLoJackIDNode;
|
||||
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
private JComboBox<LJ1200Message.Function> mFunctionCombo;
|
||||
private JTextField mTextIdent;
|
||||
|
||||
private String mHelpText = "Select a LoJack message function code and enter"
|
||||
+ " a five character reply code/identifier in the ID field.\n\n"
|
||||
+ "Wildcard: use an asterisk (*) to wildcard any character in the "
|
||||
+ "five character reply code (e.g. AB*CD or ***12 or *****)\n\n"
|
||||
+ "Reply codes are five characters where the middle character"
|
||||
+ " identifies the entity (tower/site or transponder) as follows:\n"
|
||||
+ "X,Y\t\tTower\n"
|
||||
+ "0-9,A,C-H,J-N,P-W\tTransponder\n"
|
||||
+ "B,I,O,Z\t\tNot Used";
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>LoJack Function and Identifier</h3>"
|
||||
+ "<b>Function Code:</b> <u>1Y-SITE ID</u><br>"
|
||||
+ "<b>ID:</b> 5 numbers or characters (e.g. <u>1BN47</u>)<br>"
|
||||
+ "<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) to wildcard ID<br>"
|
||||
+ "characters (e.g. <u>AB*CD</u> or <u>***12</u> or <u>*****</u>)<br><br>"
|
||||
+ "The middle character in a reply ID code identifies the<br>"
|
||||
+ "entity. Valid ID middle characters are:<br>"
|
||||
+ "<li><b>Tower:</b> X,Y</li>"
|
||||
+ "<li><b>Transponder:</b> 0-9,A,C-H,J-N,P-W</li>"
|
||||
+ "<li><b>Not Used:</b> B,I,O,Z</li>"
|
||||
+ "</html>";
|
||||
|
||||
public LoJackIDEditor( LoJackIDNode lojackNode )
|
||||
public LoJackIDEditor( AliasID aliasID )
|
||||
{
|
||||
mLoJackIDNode = lojackNode;
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "LoJack Function and ID" ), "span,align center" );
|
||||
|
||||
LoJackFunctionAndID lojack = mLoJackIDNode.getLoJackID();
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][]" ) );
|
||||
|
||||
add( new JLabel( "Function:" ) );
|
||||
mFunctionCombo = new JComboBox<LJ1200Message.Function>( Function.values() );
|
||||
mFunctionCombo.setSelectedItem( lojack.getFunction() );
|
||||
add( mFunctionCombo, "grow, wrap" );
|
||||
mFunctionCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
mFunctionCombo.setToolTipText( HELP_TEXT );
|
||||
add( mFunctionCombo, "growx, push" );
|
||||
|
||||
add( new JLabel( "ID:" ) );
|
||||
mTextIdent = new JTextField( lojack.getID() );
|
||||
|
||||
add( mTextIdent, "grow, wrap" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( LoJackIDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
MaskFormatter formatter = null;
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( LoJackIDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
try
|
||||
{
|
||||
//Mask: any character or number, 5 places
|
||||
formatter = new MaskFormatter( "AAAAA" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, the mask was invalid
|
||||
}
|
||||
|
||||
JTextArea helpText = new JTextArea( mHelpText );
|
||||
helpText.setLineWrap( true );
|
||||
helpText.setBackground( getBackground() );
|
||||
add( helpText, "span,grow,push" );
|
||||
mTextField = new JFormattedTextField( formatter );
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( LoJackIDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public LoJackFunctionAndID getLoJackID()
|
||||
{
|
||||
if( getItem() instanceof LoJackFunctionAndID )
|
||||
{
|
||||
return (LoJackFunctionAndID)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
final LoJackFunctionAndID lojack = mLoJackIDNode.getLoJackID();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
{
|
||||
String id = mTextIdent.getText();
|
||||
|
||||
if( id != null )
|
||||
{
|
||||
|
||||
lojack.setID( id );
|
||||
lojack.setFunction( (Function)mFunctionCombo.getSelectedItem() );
|
||||
|
||||
((ConfigurableNode)mLoJackIDNode.getParent()).sort();
|
||||
|
||||
mLoJackIDNode.save();
|
||||
|
||||
mLoJackIDNode.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( LoJackIDEditor.this, "Please enter an ident" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
LoJackFunctionAndID lojack = getLoJackID();
|
||||
|
||||
if( lojack != null )
|
||||
{
|
||||
mFunctionCombo.setSelectedItem( lojack.getFunction() );
|
||||
mTextIdent.setText( lojack.getID() );
|
||||
mTextField.setText( lojack.getID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFunctionCombo.setSelectedItem( null );
|
||||
mTextField.setText( null );
|
||||
}
|
||||
|
||||
mLoJackIDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
LoJackFunctionAndID lojack = getLoJackID();
|
||||
|
||||
if( lojack != null )
|
||||
{
|
||||
lojack.setID( mTextField.getText() );
|
||||
lojack.setFunction( (Function)mFunctionCombo.getSelectedItem() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.lojack;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import alias.AliasIDNode;
|
||||
import alias.AliasNode;
|
||||
|
||||
public class LoJackIDNode extends AliasIDNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public LoJackIDNode( LoJackFunctionAndID id )
|
||||
{
|
||||
super( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new LoJackIDEditor( this );
|
||||
}
|
||||
|
||||
public LoJackFunctionAndID getLoJackID()
|
||||
{
|
||||
return (LoJackFunctionAndID)getUserObject();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return getLoJackID().toString();
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
AliasNode parent = (AliasNode)getParent();
|
||||
|
||||
parent.getAlias().removeAliasID( getLoJackID() );
|
||||
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( LoJackIDNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( deleteItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package alias.id.mdc;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
|
||||
public class MDC1200ID extends AliasID
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,79 +17,117 @@
|
||||
******************************************************************************/
|
||||
package alias.id.mdc;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.text.MaskFormatter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import controller.ConfigurableNode;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class MDC1200IDEditor extends JPanel implements ActionListener
|
||||
public class MDC1200IDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private MDC1200IDNode mMDC1200IDNode;
|
||||
|
||||
private JTextField mTextIdent;
|
||||
|
||||
public MDC1200IDEditor( MDC1200IDNode fsNode )
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>MDC-1200 Identifier</h3>"
|
||||
+ "<b>MDC-1200:</b> four digit [0-9] value (e.g. <u>1234</u>)<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) to wildcard individual<br>"
|
||||
+ "digits (e.g. <u>123*</u> or <u>**34</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public MDC1200IDEditor( AliasID aliasID )
|
||||
{
|
||||
mMDC1200IDNode = fsNode;
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "MDC-1200 " ), "span,align center" );
|
||||
add( new JLabel( "MDC-1200 ID:" ) );
|
||||
|
||||
add( new JLabel( "Unit ID:" ) );
|
||||
mTextIdent = new JTextField( mMDC1200IDNode.getMDC1200ID().getIdent() );
|
||||
add( mTextIdent, "growx,push" );
|
||||
MaskFormatter formatter = null;
|
||||
|
||||
try
|
||||
{
|
||||
//Mask: 4 digits
|
||||
formatter = new MaskFormatter( "####" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, the mask was invalid
|
||||
}
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( MDC1200IDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( MDC1200IDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
mTextField = new JFormattedTextField( formatter );
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( MDC1200IDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public MDC1200ID getMDC1200ID()
|
||||
{
|
||||
if( getItem() instanceof MDC1200ID )
|
||||
{
|
||||
return (MDC1200ID)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
MDC1200ID mdc = getMDC1200ID();
|
||||
|
||||
if( mdc != null )
|
||||
{
|
||||
String ident = mTextIdent.getText();
|
||||
|
||||
if( ident != null )
|
||||
{
|
||||
mMDC1200IDNode.getMDC1200ID().setIdent( ident );
|
||||
mTextField.setText( mdc.getIdent() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
((ConfigurableNode)mMDC1200IDNode.getParent()).sort();
|
||||
|
||||
mMDC1200IDNode.save();
|
||||
|
||||
mMDC1200IDNode.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( MDC1200IDEditor.this, "Please enter a unit ID" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
MDC1200ID mdc = getMDC1200ID();
|
||||
|
||||
if( mdc != null )
|
||||
{
|
||||
mTextIdent.setText( mMDC1200IDNode.getMDC1200ID().getIdent() );
|
||||
mdc.setIdent( mTextField.getText() );
|
||||
}
|
||||
|
||||
mMDC1200IDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.mdc;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,82 +17,117 @@
|
||||
******************************************************************************/
|
||||
package alias.id.mobileID;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.text.MaskFormatter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import controller.ConfigurableNode;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class MINEditor extends JPanel implements ActionListener
|
||||
public class MINEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private MINNode mMINNode;
|
||||
|
||||
private JLabel mLabelName;
|
||||
private JTextField mTextMIN;
|
||||
|
||||
public MINEditor( MINNode minNode )
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>Passport Mobile ID (MIN)</h3>"
|
||||
+ "<b>MIN:</b> six character hex value (e.g. <u>AB12CD</u>)<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) to wildcard individual<br>"
|
||||
+ "digits (e.g. <u>AB**CD</u> or <u>AB12**</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public MINEditor( AliasID aliasID )
|
||||
{
|
||||
mMINNode = minNode;
|
||||
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Mobile ID Number (MIN)" ), "span,align center" );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "MIN:" ) );
|
||||
|
||||
mTextMIN = new JTextField( mMINNode.getMIN().getMin() );
|
||||
add( mTextMIN, "growx,push" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( MINEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( MINEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
MaskFormatter formatter = null;
|
||||
|
||||
try
|
||||
{
|
||||
//Mask: 6 hex characters
|
||||
formatter = new MaskFormatter( "HHHHHH" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, the mask was invalid
|
||||
}
|
||||
|
||||
mTextField = new JFormattedTextField( formatter );
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( MINEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public Min getMin()
|
||||
{
|
||||
if( getItem() instanceof Min )
|
||||
{
|
||||
return (Min)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
Min min = getMin();
|
||||
|
||||
if( min != null )
|
||||
{
|
||||
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() );
|
||||
mTextField.setText( min.getMin() );
|
||||
}
|
||||
|
||||
mMINNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
Min min = getMin();
|
||||
|
||||
if( min != null )
|
||||
{
|
||||
min.setMin( mTextField.getText() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.mobileID;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package alias.id.mobileID;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
/**
|
||||
* Mobile ID Number
|
||||
|
||||
@@ -19,8 +19,8 @@ package alias.id.mpt1327;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class MPT1327ID extends AliasID
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,80 +17,119 @@
|
||||
******************************************************************************/
|
||||
package alias.id.mpt1327;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.text.MaskFormatter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import controller.ConfigurableNode;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class MPT1327IDEditor extends JPanel implements ActionListener
|
||||
public class MPT1327IDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private MPT1327IDNode mMPT1327IDNode;
|
||||
|
||||
private JTextField mTextIdent;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MPT1327IDEditor( MPT1327IDNode fsNode )
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>MPT-1327 Identifier</h3>"
|
||||
+ "<b>MPT-1327:</b> decimal (0-9) format ppp-iiii where<br>"
|
||||
+ "p=Prefix and i=Ident (e.g. <u>123-0001</u>)<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) to wildcard individual<br>"
|
||||
+ "digits (e.g. <u>ABCD123*</u> or <u>AB**1**4</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public MPT1327IDEditor( AliasID aliasID )
|
||||
{
|
||||
mMPT1327IDNode = fsNode;
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "MPT-1327 Radio or Group ID" ), "span,align center" );
|
||||
add( new JLabel( "MPT-1327 ID:" ) );
|
||||
|
||||
add( new JLabel( "ID:" ) );
|
||||
MaskFormatter formatter = null;
|
||||
|
||||
try
|
||||
{
|
||||
//Mask: 3 digits - 4 digits
|
||||
formatter = new MaskFormatter( "###-####" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, the mask was invalid
|
||||
}
|
||||
|
||||
mTextIdent = new JTextField( mMPT1327IDNode.getMPT1327ID().getIdent() );
|
||||
add( mTextIdent, "growx,push" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( MPT1327IDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
mTextField = new JFormattedTextField( formatter );
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( MPT1327IDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( MPT1327IDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public MPT1327ID getMPT1327ID()
|
||||
{
|
||||
if( getItem() instanceof MPT1327ID )
|
||||
{
|
||||
return (MPT1327ID)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
MPT1327ID mpt = getMPT1327ID();
|
||||
|
||||
if( mpt != null )
|
||||
{
|
||||
String ident = mTextIdent.getText();
|
||||
|
||||
if( ident != null )
|
||||
{
|
||||
mMPT1327IDNode.getMPT1327ID().setIdent( ident );
|
||||
mTextField.setText( mpt.getIdent() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
((ConfigurableNode)mMPT1327IDNode.getParent()).sort();
|
||||
|
||||
mMPT1327IDNode.save();
|
||||
|
||||
mMPT1327IDNode.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( MPT1327IDEditor.this, "Please enter a MPT1327 unit ID" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
MPT1327ID mpt = getMPT1327ID();
|
||||
|
||||
if( mpt != null )
|
||||
{
|
||||
mTextIdent.setText( mMPT1327IDNode.getMPT1327ID().getIdent() );
|
||||
mpt.setIdent( mTextField.getText() );
|
||||
}
|
||||
|
||||
mMPT1327IDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.mpt1327;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package alias.record;
|
||||
package alias.id.nonrecordable;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class NonRecordable extends AliasID
|
||||
{
|
||||
@@ -16,4 +16,10 @@ public class NonRecordable extends AliasID
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Audio Non-Recordable";
|
||||
}
|
||||
}
|
||||
78
src/alias/id/nonrecordable/NonRecordableEditor.java
Normal file
78
src/alias/id/nonrecordable/NonRecordableEditor.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.nonrecordable;
|
||||
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class NonRecordableEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>Audio Non-Recordable</h3>"
|
||||
+ "This identifies an alias as non-recordable.<br><br>"
|
||||
+ "The alias can still be monitored but associated audio will<br>"
|
||||
+ "not be recorded.<br><br>"
|
||||
+ "The default behavior when audio recording is enabled for a<br>"
|
||||
+ "channel is to record all aliases except any alias with a<br>"
|
||||
+ "non-recordable identifier";
|
||||
|
||||
public NonRecordableEditor( AliasID aliasID )
|
||||
{
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 1", "[]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "Non-Recordable" ), "wrap" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( NonRecordableEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@
|
||||
* 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.priority;
|
||||
package alias.id.priority;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
/**
|
||||
* Specifies an (audio) priority level for this alias.
|
||||
@@ -60,7 +60,7 @@ public class Priority extends AliasID
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Priority: " + ( isDoNotMonitor() ? "Do Not Monitor" : mPriority );
|
||||
return "Audio Priority: " + ( isDoNotMonitor() ? "Do Not Monitor" : mPriority );
|
||||
}
|
||||
|
||||
@Override
|
||||
168
src/alias/id/priority/PriorityEditor.java
Normal file
168
src/alias/id/priority/PriorityEditor.java
Normal file
@@ -0,0 +1,168 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.priority;
|
||||
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class PriorityEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String DO_NOT_MONITOR = "Do Not Monitor";
|
||||
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>Call Audio Priority</h3>"
|
||||
+ "Priority determines which calls have priority for playback<br>"
|
||||
+ "over your computer speakers, or designates an alias for<br>"
|
||||
+ "no-monitoring if you don't want to hear calls from an alias.<br><br>"
|
||||
+ "Lower values indicate higher priority levels.<br><br>"
|
||||
+ "<b>Do Not Monitor: </b> slide priority all the way to the right"
|
||||
+ "</html>";
|
||||
|
||||
private JSlider mPrioritySlider;
|
||||
private JLabel mPrioritySliderLabel;
|
||||
|
||||
public PriorityEditor( AliasID aliasID )
|
||||
{
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
mPrioritySlider = new JSlider( JSlider.HORIZONTAL,
|
||||
Priority.MIN_PRIORITY,
|
||||
Priority.MAX_PRIORITY + 1,
|
||||
Priority.MIN_PRIORITY );
|
||||
|
||||
mPrioritySlider.setMajorTickSpacing( 20 );
|
||||
mPrioritySlider.setMinorTickSpacing( 5 );
|
||||
mPrioritySlider.setPaintTicks( true );
|
||||
mPrioritySlider.setLabelTable( mPrioritySlider.createStandardLabels( 20, 20 ) );
|
||||
mPrioritySlider.setPaintLabels( true );
|
||||
mPrioritySlider.addChangeListener( new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
int priority = mPrioritySlider.getValue();
|
||||
|
||||
if( priority == Priority.MAX_PRIORITY + 1 )
|
||||
{
|
||||
mPrioritySliderLabel.setText( "Priority: Do Not Monitor" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mPrioritySliderLabel.setText( "Priority: " + priority );
|
||||
}
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
mPrioritySlider.setToolTipText( HELP_TEXT );
|
||||
|
||||
mPrioritySliderLabel = new JLabel( "Priority: " + mPrioritySlider.getValue() + " " );
|
||||
add( mPrioritySliderLabel, "span,align center" );
|
||||
add( mPrioritySlider, "span,grow" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( PriorityEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public Priority getPriority()
|
||||
{
|
||||
if( getItem() instanceof Priority )
|
||||
{
|
||||
return (Priority)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
Priority priority = getPriority();
|
||||
|
||||
if( priority != null )
|
||||
{
|
||||
int value = priority.getPriority();
|
||||
|
||||
if( value == Priority.DO_NOT_MONITOR )
|
||||
{
|
||||
value = Priority.MAX_PRIORITY + 1;
|
||||
}
|
||||
|
||||
mPrioritySlider.setValue( value );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
Priority priority = getPriority();
|
||||
|
||||
if( priority != null )
|
||||
{
|
||||
int value = mPrioritySlider.getValue();
|
||||
|
||||
if( value == Priority.MAX_PRIORITY + 1 )
|
||||
{
|
||||
value = Priority.DO_NOT_MONITOR;
|
||||
}
|
||||
|
||||
priority.setPriority( value );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package alias.id.siteID;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class SiteID extends AliasID
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,95 +17,105 @@
|
||||
******************************************************************************/
|
||||
package alias.id.siteID;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
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 alias.id.AliasID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SiteIDEditor extends JPanel implements ActionListener
|
||||
public class SiteIDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( SiteIDEditor.class );
|
||||
private SiteIDNode mSiteIDNode;
|
||||
private JTextField mTextSiteID;
|
||||
|
||||
public SiteIDEditor( SiteIDNode siteIDNode )
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>Site Identifier</h3>"
|
||||
+ "<b>LTR-Net:</b> decimal (0-9) (e.g. <u>019</u>)<br>"
|
||||
+ "<b>MPT-1327:</b> 5 digits (0-9) (e.g. <u>23619</u>)<br>"
|
||||
+ "<b>Passport:</b> 3 digits (0-9) (e.g. <u>019</u>)<br>"
|
||||
+ "<b>P25:</b> hex (0-9, A-F) format RR-SS where RR = RF Subsystem<br>"
|
||||
+ "and SS = Site Number (e.g. RFSS 1 Site 1F: <u>01-1F</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public SiteIDEditor( AliasID aliasID )
|
||||
{
|
||||
mSiteIDNode = siteIDNode;
|
||||
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][grow]" ) );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "Site ID" ), "span,align center" );
|
||||
add( new JLabel( "Site ID:" ) );
|
||||
mTextField = new JTextField();
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
add( new JLabel( "Site:" ) );
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( SiteIDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
|
||||
mTextSiteID = new JTextField(
|
||||
String.valueOf( mSiteIDNode.getSiteID().getSite() ) );
|
||||
add( mTextSiteID, "growx,push" );
|
||||
|
||||
JTextArea description = new JTextArea( "Enter a site number. "
|
||||
+ "For P25 systems, use the format RR-SS, where RR = RF "
|
||||
+ "Subsystem and SS = Site Number. For example, RFSS 1 and "
|
||||
+ "Site 3 would be: 01-03");
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public SiteID getSiteID()
|
||||
{
|
||||
if( getItem() instanceof SiteID )
|
||||
{
|
||||
return (SiteID)getItem();
|
||||
}
|
||||
|
||||
description.setLineWrap( true );
|
||||
description.setBackground( getBackground() );
|
||||
|
||||
add( description, "growx,span" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( SiteIDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( SiteIDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
SiteID siteID = getSiteID();
|
||||
|
||||
if( siteID != null )
|
||||
{
|
||||
String siteIDString = mTextSiteID.getText();
|
||||
|
||||
if( siteIDString != null )
|
||||
{
|
||||
mSiteIDNode.getSiteID().setSite( siteIDString );
|
||||
mTextField.setText( siteID.getSite() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
mSiteIDNode.save();
|
||||
|
||||
mSiteIDNode.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( SiteIDEditor.this,
|
||||
"Please enter a site ID" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
SiteID siteID = getSiteID();
|
||||
|
||||
if( siteID != null )
|
||||
{
|
||||
mTextSiteID.setText( mSiteIDNode.getSiteID().getSite() );
|
||||
siteID.setSite( mTextField.getText() );
|
||||
}
|
||||
|
||||
mSiteIDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.siteID;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@
|
||||
* 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.id.fleetsync;
|
||||
package alias.id.status;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class StatusID extends AliasID
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public class StatusID extends AliasID
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Status: " + mStatus;
|
||||
return "Status: " + String.format( "%03d", mStatus );
|
||||
}
|
||||
|
||||
@Override
|
||||
146
src/alias/id/status/StatusIDEditor.java
Normal file
146
src/alias/id/status/StatusIDEditor.java
Normal file
@@ -0,0 +1,146 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.status;
|
||||
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.text.MaskFormatter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class StatusIDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>Status Identifier</h3>"
|
||||
+ "Status numbers are used in some protocols like Fleetsync.<br><br>"
|
||||
+ "The status number is assigned a meaning in the radio. You<br>"
|
||||
+ "can assign a 3 digit status code (use leading zeros) to an<br>"
|
||||
+ "alias where the alias contains the status meaning.<br><br>"
|
||||
+ "<b>Status:</b> <u>001</u> engine start"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public StatusIDEditor( AliasID aliasID )
|
||||
{
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "Status:" ) );
|
||||
|
||||
MaskFormatter formatter = null;
|
||||
|
||||
try
|
||||
{
|
||||
//Mask: 3 digits
|
||||
formatter = new MaskFormatter( "###" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, the mask was invalid
|
||||
}
|
||||
|
||||
mTextField = new JFormattedTextField( formatter );
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( StatusIDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public StatusID getStatusID()
|
||||
{
|
||||
if( getItem() instanceof StatusID )
|
||||
{
|
||||
return (StatusID)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
StatusID statusID = getStatusID();
|
||||
|
||||
if( statusID != null )
|
||||
{
|
||||
mTextField.setText( String.format( "%03d", statusID.getStatus() ) );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
StatusID statusID = getStatusID();
|
||||
|
||||
if( statusID != null )
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
try
|
||||
{
|
||||
status = Integer.valueOf( mTextField.getText() );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
//Do nothing, we couldn't parse the value
|
||||
}
|
||||
|
||||
statusID.setStatus( status );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,8 @@ package alias.id.talkgroup;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import audio.inverted.AudioType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
|
||||
public class TalkgroupID extends AliasID
|
||||
@@ -43,11 +42,6 @@ public class TalkgroupID extends AliasID
|
||||
mTalkgroup = talkgroup;
|
||||
}
|
||||
|
||||
public boolean hasAudioType()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -17,99 +17,105 @@
|
||||
******************************************************************************/
|
||||
package alias.id.talkgroup;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
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;
|
||||
import alias.id.AliasID;
|
||||
|
||||
public class TalkgroupIDEditor extends JPanel implements ActionListener
|
||||
public class TalkgroupIDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private TalkgroupIDNode mTalkgroupIDNode;
|
||||
|
||||
private JTextField mTextTalkgroupID;
|
||||
|
||||
private String mHelpText = "Enter a formatted talkgroup identifier.\n\n"
|
||||
+ "P25 Talkgroup Format: hexadecimal value, 4 characters for "
|
||||
+ "talkgroup or 6 characters for a mobile radio\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.";
|
||||
|
||||
public TalkgroupIDEditor( TalkgroupIDNode talkgroupIDNode )
|
||||
private static final String HELP_TEXT =
|
||||
"<html><h3>Talkgroup Identifier</h3>"
|
||||
+ "<b>P25:</b> 4 or 6 hex characters (e.g. <u>AB12</u> or <u>ABC123</u>)<br>"
|
||||
+ "<b>LTR:</b> A-HH-TTT where A=Area H=Home T=Talkgroup (<u>0-01-128</u>)<br>"
|
||||
+ "<b>Passport</b>: 5-digit number (<u>12345</u> or <u>00023</u>)<br>"
|
||||
+ "<br>"
|
||||
+ "<b>Wildcard:</b> use an asterisk (*) in place of each talkgroup digit (e.g. <u>0*1*5</u>)"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public TalkgroupIDEditor( AliasID aliasID )
|
||||
{
|
||||
mTalkgroupIDNode = talkgroupIDNode;
|
||||
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][grow]" ) );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "Talkgroup:" ) );
|
||||
|
||||
add( new JLabel( "Talkgroup ID" ), "span,align center" );
|
||||
mTextField = new JTextField();
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( TalkgroupIDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public TalkgroupID getTalkgroupID()
|
||||
{
|
||||
if( getItem() instanceof TalkgroupID )
|
||||
{
|
||||
return (TalkgroupID)getItem();
|
||||
}
|
||||
|
||||
add( new JLabel( "TGID:" ) );
|
||||
mTextTalkgroupID = new JTextField();
|
||||
|
||||
mTextTalkgroupID.setText( mTalkgroupIDNode.getTalkgroupID().getTalkgroup() );
|
||||
|
||||
add( mTextTalkgroupID, "growx,push" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( TalkgroupIDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( TalkgroupIDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
|
||||
JTextArea helpText = new JTextArea( mHelpText );
|
||||
helpText.setBackground( getBackground() );
|
||||
helpText.setLineWrap( true );
|
||||
add( helpText, "span,grow,push" );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
TalkgroupID talkgroup = getTalkgroupID();
|
||||
|
||||
if( talkgroup != null )
|
||||
{
|
||||
String tgid = mTextTalkgroupID.getText();
|
||||
|
||||
if( tgid != null )
|
||||
{
|
||||
mTalkgroupIDNode.getTalkgroupID().setTalkgroup( tgid );
|
||||
|
||||
((ConfigurableNode)mTalkgroupIDNode.getParent()).sort();
|
||||
mTextField.setText( talkgroup.getTalkgroup() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
mTalkgroupIDNode.save();
|
||||
|
||||
mTalkgroupIDNode.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( TalkgroupIDEditor.this,
|
||||
"Please enter a talkgroup ID" );
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
TalkgroupID talkgroup = getTalkgroupID();
|
||||
|
||||
if( talkgroup != null )
|
||||
{
|
||||
mTextTalkgroupID.setText(
|
||||
mTalkgroupIDNode.getTalkgroupID().getTalkgroup() );
|
||||
talkgroup.setTalkgroup( mTextField.getText() );
|
||||
}
|
||||
|
||||
mTalkgroupIDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.talkgroup;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package alias.id.uniqueID;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import alias.AliasID;
|
||||
import alias.AliasIDType;
|
||||
import alias.id.AliasID;
|
||||
import alias.id.AliasIDType;
|
||||
|
||||
public class UniqueID extends AliasID
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,101 +17,112 @@
|
||||
******************************************************************************/
|
||||
package alias.id.uniqueID;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
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 alias.id.AliasID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import controller.ConfigurableNode;
|
||||
|
||||
public class UniqueIDEditor extends JPanel implements ActionListener
|
||||
public class UniqueIDEditor extends DocumentListenerEditor<AliasID>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( UniqueIDEditor.class );
|
||||
private UniqueIDNode mUniqueIDNode;
|
||||
|
||||
private JLabel mLabelUniqueID;
|
||||
private JTextField mTextUniqueID;
|
||||
|
||||
public UniqueIDEditor( UniqueIDNode uniqueIDNode )
|
||||
private static final String HELP_TEXT = "<html>"
|
||||
+ "<h3>LTR-Net Unique ID (UID)</h3>"
|
||||
+ "<b>UID:</b> identifier assigned to each radio in<br>"
|
||||
+ "the range <u>1 - 2097152</u>"
|
||||
+ "</html>";
|
||||
|
||||
private JTextField mTextField;
|
||||
|
||||
public UniqueIDEditor( AliasID aliasID )
|
||||
{
|
||||
mUniqueIDNode = uniqueIDNode;
|
||||
|
||||
initGUI();
|
||||
|
||||
setItem( aliasID );
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "LTR-Net Radio Unique ID" ), "span,align center" );
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][]" ) );
|
||||
|
||||
add( new JLabel( "Unique ID:" ) );
|
||||
|
||||
mTextUniqueID = new JTextField(
|
||||
String.valueOf( mUniqueIDNode.getUniqueID().getUid() ) );
|
||||
add( mTextUniqueID, "growx,push" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( UniqueIDEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
mTextField = new JTextField();
|
||||
mTextField.getDocument().addDocumentListener( this );
|
||||
mTextField.setToolTipText( HELP_TEXT );
|
||||
add( mTextField, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( UniqueIDEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
JLabel help = new JLabel( "Help ..." );
|
||||
help.setForeground( Color.BLUE.brighter() );
|
||||
help.setCursor( new Cursor( Cursor.HAND_CURSOR ) );
|
||||
help.addMouseListener( new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( UniqueIDEditor.this,
|
||||
HELP_TEXT, "Help", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
} );
|
||||
add( help, "align left" );
|
||||
}
|
||||
|
||||
public UniqueID getUniqueID()
|
||||
{
|
||||
if( getItem() instanceof UniqueID )
|
||||
{
|
||||
return (UniqueID)getItem();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
public void setItem( AliasID aliasID )
|
||||
{
|
||||
super.setItem( aliasID );
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
UniqueID uid = getUniqueID();
|
||||
|
||||
if( uid != null )
|
||||
{
|
||||
String uid = mTextUniqueID.getText();
|
||||
mTextField.setText( String.valueOf( uid.getUid() ) );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
UniqueID uid = getUniqueID();
|
||||
|
||||
if( uid != null )
|
||||
{
|
||||
int id = 0;
|
||||
|
||||
if( uid != null )
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
int uidInt = Integer.parseInt( uid );
|
||||
|
||||
mUniqueIDNode.getUniqueID().setUid( uidInt );
|
||||
|
||||
((ConfigurableNode)mUniqueIDNode.getParent()).sort();
|
||||
|
||||
mUniqueIDNode.save();
|
||||
|
||||
mUniqueIDNode.show();
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
mLog.error( "UniqueIDEditor - exception trying to parse " +
|
||||
"int from uid [" + uid + "]", ex );
|
||||
}
|
||||
id = Integer.parseInt( mTextField.getText() );
|
||||
}
|
||||
else
|
||||
catch( Exception e )
|
||||
{
|
||||
JOptionPane.showMessageDialog( UniqueIDEditor.this,
|
||||
"Please enter a site number and unique ID" );
|
||||
//Do nothing, we couldn't parse the value
|
||||
}
|
||||
}
|
||||
else if( command.contentEquals( "Reset" ) )
|
||||
{
|
||||
mTextUniqueID.setText(
|
||||
String.valueOf( mUniqueIDNode.getUniqueID().getUid() ) );
|
||||
|
||||
uid.setUid( id );
|
||||
}
|
||||
|
||||
mUniqueIDNode.refresh();
|
||||
}
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.id.uniqueID;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2015 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.priority;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import controller.ConfigurableNode;
|
||||
|
||||
public class PriorityEditor extends JPanel implements ActionListener
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( PriorityEditor.class );
|
||||
|
||||
public static final String DO_NOT_MONITOR = "Do Not Monitor";
|
||||
public static final String SAVE = "Save";
|
||||
public static final String RESET = "Reset";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private PriorityNode mPriorityNode;
|
||||
private JCheckBox mDoNotMonitorCheckBox = new JCheckBox( DO_NOT_MONITOR );
|
||||
private JSlider mPrioritySlider;
|
||||
private JLabel mPrioritySliderLabel;
|
||||
|
||||
public PriorityEditor( PriorityNode priorityNode )
|
||||
{
|
||||
mPriorityNode = priorityNode;
|
||||
|
||||
initGUI();
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
|
||||
|
||||
add( new JLabel( "Priority" ), "span,align center" );
|
||||
|
||||
boolean doNotMonitor = mPriorityNode.getPriority().isDoNotMonitor();
|
||||
|
||||
mDoNotMonitorCheckBox.addActionListener( this );
|
||||
|
||||
if( doNotMonitor )
|
||||
{
|
||||
mDoNotMonitorCheckBox.setSelected( true );
|
||||
}
|
||||
|
||||
add( mDoNotMonitorCheckBox, "span,align center" );
|
||||
|
||||
int priority = mPriorityNode.getPriority().getPriority();
|
||||
|
||||
/* Adjust the displayable priority value to within the min/max bounds
|
||||
* so we don't get an error in the jslider control. If the actual
|
||||
* priority is -1 (ie do not follow), the controls will be updated
|
||||
* to reflect that state */
|
||||
if( priority < Priority.MIN_PRIORITY )
|
||||
{
|
||||
priority = Priority.DEFAULT_PRIORITY;
|
||||
}
|
||||
else if( priority > Priority.MAX_PRIORITY )
|
||||
{
|
||||
priority = Priority.DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
mPrioritySlider = new JSlider( JSlider.HORIZONTAL,
|
||||
Priority.MIN_PRIORITY,
|
||||
Priority.MAX_PRIORITY,
|
||||
priority );
|
||||
|
||||
mPrioritySlider.setMajorTickSpacing( 20 );
|
||||
mPrioritySlider.setMinorTickSpacing( 5 );
|
||||
mPrioritySlider.setPaintTicks( true );
|
||||
|
||||
mPrioritySlider.setLabelTable( mPrioritySlider.createStandardLabels( 20, 20 ) );
|
||||
mPrioritySlider.setPaintLabels( true );
|
||||
|
||||
mPrioritySliderLabel = new JLabel( "Priority: " + mPrioritySlider.getValue() + " " );
|
||||
|
||||
mPrioritySlider.addChangeListener( new ChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void stateChanged( ChangeEvent e )
|
||||
{
|
||||
mPrioritySliderLabel.setText( "Priority: " + mPrioritySlider.getValue() );
|
||||
}
|
||||
} );
|
||||
|
||||
if( doNotMonitor )
|
||||
{
|
||||
mPrioritySlider.setEnabled( false );
|
||||
mPrioritySliderLabel.setEnabled( false );
|
||||
}
|
||||
|
||||
add( mPrioritySliderLabel );
|
||||
add( mPrioritySlider, "wrap,grow" );
|
||||
|
||||
JButton btnSave = new JButton( SAVE );
|
||||
btnSave.addActionListener( PriorityEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( RESET );
|
||||
btnReset.addActionListener( PriorityEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( "Select a value for audio priority within the range " );
|
||||
sb.append( Priority.MIN_PRIORITY );
|
||||
sb.append( " and " );
|
||||
sb.append( Priority.MAX_PRIORITY );
|
||||
sb.append( ". Lower values indicate higher priority levels." );
|
||||
|
||||
JTextArea helpText = new JTextArea( sb.toString() );
|
||||
helpText.setLineWrap( true );
|
||||
add( helpText, "span,grow,push" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( SAVE ) )
|
||||
{
|
||||
if( mDoNotMonitorCheckBox.isSelected() )
|
||||
{
|
||||
mPriorityNode.getPriority().setPriority( Priority.DO_NOT_MONITOR );
|
||||
}
|
||||
else
|
||||
{
|
||||
mPriorityNode.getPriority().setPriority( mPrioritySlider.getValue() );
|
||||
}
|
||||
|
||||
((ConfigurableNode)mPriorityNode.getParent()).sort();
|
||||
|
||||
mPriorityNode.save();
|
||||
|
||||
mPriorityNode.show();
|
||||
}
|
||||
else if( command.contentEquals( RESET ) )
|
||||
{
|
||||
mPrioritySlider.setValue( mPriorityNode.getPriority().getPriority() );
|
||||
}
|
||||
else if( command.contentEquals( DO_NOT_MONITOR ) )
|
||||
{
|
||||
if( mDoNotMonitorCheckBox.isSelected() )
|
||||
{
|
||||
mPriorityNode.getPriority().setPriority( Priority.DO_NOT_MONITOR );
|
||||
mPrioritySlider.setEnabled( false );
|
||||
mPrioritySliderLabel.setEnabled( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
mPriorityNode.getPriority().setPriority( Priority.DEFAULT_PRIORITY );
|
||||
mPrioritySlider.setEnabled( true );
|
||||
mPrioritySliderLabel.setEnabled( true );
|
||||
}
|
||||
|
||||
mPriorityNode.save();
|
||||
mPriorityNode.show();
|
||||
}
|
||||
|
||||
mPriorityNode.refresh();
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2015 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.priority;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import alias.AliasIDNode;
|
||||
import alias.AliasNode;
|
||||
|
||||
public class PriorityNode extends AliasIDNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PriorityNode( Priority priority )
|
||||
{
|
||||
super( priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new PriorityEditor( this );
|
||||
}
|
||||
|
||||
public Priority getPriority()
|
||||
{
|
||||
return (Priority)getUserObject();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return getPriority().toString();
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenuItem addSystemItem = new JMenuItem( "Delete" );
|
||||
addSystemItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
AliasNode parent = (AliasNode)getParent();
|
||||
|
||||
parent.getAlias().removeAliasID( getPriority() );
|
||||
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( PriorityNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( addSystemItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.record;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
public class NonRecordableEditor extends JPanel implements ActionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private NonRecordableNode mNode;
|
||||
|
||||
public NonRecordableEditor( NonRecordableNode node )
|
||||
{
|
||||
mNode = node;
|
||||
initGUI();
|
||||
}
|
||||
|
||||
private void initGUI()
|
||||
{
|
||||
setLayout( new MigLayout( "fill", "[left]", "[grow]" ) );
|
||||
|
||||
JTextArea description = new JTextArea( "Non-Recordable. Any audio where"
|
||||
+ " this alias is a participant in the call will not be recorded." );
|
||||
|
||||
description.setLineWrap( true );
|
||||
description.setBackground( getBackground() );
|
||||
|
||||
add( description, "growx,span" );
|
||||
|
||||
JButton btnSave = new JButton( "Save" );
|
||||
btnSave.addActionListener( NonRecordableEditor.this );
|
||||
add( btnSave, "growx,push" );
|
||||
|
||||
JButton btnReset = new JButton( "Reset" );
|
||||
btnReset.addActionListener( NonRecordableEditor.this );
|
||||
add( btnReset, "growx,push" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
String command = e.getActionCommand();
|
||||
|
||||
if( command.contentEquals( "Save" ) )
|
||||
{
|
||||
mNode.save();
|
||||
mNode.show();
|
||||
}
|
||||
|
||||
mNode.refresh();
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package alias.record;
|
||||
|
||||
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.AliasID;
|
||||
import alias.AliasIDNode;
|
||||
import alias.AliasNode;
|
||||
|
||||
public class NonRecordableNode extends AliasIDNode
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public NonRecordableNode( NonRecordable id )
|
||||
{
|
||||
super( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getEditor()
|
||||
{
|
||||
return new NonRecordableEditor( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconPath()
|
||||
{
|
||||
return "images/no_record.png";
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Non-Recordable";
|
||||
}
|
||||
|
||||
public JPopupMenu getContextMenu()
|
||||
{
|
||||
JPopupMenu retVal = new JPopupMenu();
|
||||
|
||||
JMenuItem addSystemItem = new JMenuItem( "Delete" );
|
||||
addSystemItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int n = JOptionPane.showConfirmDialog( getModel().getTree(),
|
||||
"Are you sure you want to permanently delete this node?" );
|
||||
|
||||
if( n == JOptionPane.YES_OPTION )
|
||||
{
|
||||
AliasNode parent = (AliasNode)getParent();
|
||||
|
||||
parent.getAlias().removeAliasID( (AliasID)getUserObject() );
|
||||
|
||||
save();
|
||||
|
||||
getModel().removeNodeFromParent( NonRecordableNode.this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
retVal.add( addSystemItem );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,8 @@ import java.awt.Font;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import settings.ColorSetting;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
@@ -30,8 +25,6 @@ public class AudioChannelPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Logger mLog = LoggerFactory.getLogger( AudioChannelPanel.class );
|
||||
|
||||
private Font mFont = new Font( Font.MONOSPACED, Font.PLAIN, 12 );
|
||||
private Color mLabelColor;
|
||||
private Color mDetailsColor;
|
||||
@@ -48,11 +41,8 @@ public class AudioChannelPanel extends JPanel
|
||||
private JLabel mFromLabel = new JLabel( "FROM:" );
|
||||
private JLabel mFrom = new JLabel( "" );
|
||||
private JLabel mFromAlias = new JLabel( "" );
|
||||
|
||||
private enum AudioStatus { STARTED,STOPPED };
|
||||
private AudioStatus mAudioStatus = AudioStatus.STOPPED;
|
||||
|
||||
private AudioMetadata mAudioMetadata;
|
||||
private boolean mConfigured = false;
|
||||
|
||||
public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
|
||||
{
|
||||
@@ -127,9 +117,6 @@ public class AudioChannelPanel extends JPanel
|
||||
mFromAlias.setForeground( mLabelColor );
|
||||
add( mFromAlias,"wrap" );
|
||||
|
||||
JSeparator separator = new JSeparator( JSeparator.HORIZONTAL );
|
||||
separator.setBackground( Color.DARK_GRAY );
|
||||
add( separator, "span,growx" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,19 +124,15 @@ public class AudioChannelPanel extends JPanel
|
||||
{
|
||||
switch( audioEvent.getType() )
|
||||
{
|
||||
case AUDIO_STARTED:
|
||||
synchronized( mAudioStatus )
|
||||
{
|
||||
mAudioStatus = AudioStatus.STARTED;
|
||||
updateLabels();
|
||||
}
|
||||
break;
|
||||
case AUDIO_STOPPED:
|
||||
synchronized( mAudioStatus )
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
mAudioStatus = AudioStatus.STOPPED;
|
||||
resetLabels();
|
||||
}
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
resetLabels();
|
||||
}
|
||||
} );
|
||||
break;
|
||||
case AUDIO_MUTED:
|
||||
case AUDIO_UNMUTED:
|
||||
@@ -173,55 +156,13 @@ public class AudioChannelPanel extends JPanel
|
||||
*/
|
||||
private void resetLabels()
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mFrom.setText( "" );
|
||||
updateAlias( mFromAlias, null );
|
||||
|
||||
mTo.setText( "" );
|
||||
updateAlias( mToAlias, null );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void updateLabels()
|
||||
{
|
||||
if( mAudioMetadata != null )
|
||||
{
|
||||
final Metadata from = mAudioMetadata.getMetadata( MetadataType.FROM );
|
||||
|
||||
final Metadata to = mAudioMetadata.getMetadata( MetadataType.TO );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if( from != null )
|
||||
{
|
||||
mFrom.setText( from.getValue() );
|
||||
updateAlias( mFromAlias, from.getAlias() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFrom.setText( "-----" );
|
||||
}
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mTo.setText( to.getValue() );
|
||||
updateAlias( mToAlias, to.getAlias() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTo.setText( "-----" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
mFrom.setText( "" );
|
||||
updateAlias( mFromAlias, null );
|
||||
|
||||
mTo.setText( "" );
|
||||
updateAlias( mToAlias, null );
|
||||
|
||||
mConfigured = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,17 +204,40 @@ public class AudioChannelPanel extends JPanel
|
||||
@Override
|
||||
public void receive( AudioMetadata audioMetadata )
|
||||
{
|
||||
mAudioMetadata = audioMetadata;
|
||||
|
||||
if( audioMetadata.isUpdated() )
|
||||
if( !mConfigured || audioMetadata.isUpdated() )
|
||||
{
|
||||
synchronized( mAudioStatus )
|
||||
final Metadata from = audioMetadata.getMetadata( MetadataType.FROM );
|
||||
|
||||
final Metadata to = audioMetadata.getMetadata( MetadataType.TO );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
if( mAudioStatus == AudioStatus.STARTED )
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
updateLabels();
|
||||
if( from != null )
|
||||
{
|
||||
mFrom.setText( from.getValue() );
|
||||
updateAlias( mFromAlias, from.getAlias() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFrom.setText( "-----" );
|
||||
}
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mTo.setText( to.getValue() );
|
||||
updateAlias( mToAlias, to.getAlias() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTo.setText( "-----" );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
mConfigured = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
@@ -21,17 +22,30 @@ public class AudioChannelsPanel extends JPanel
|
||||
setBackground( Color.BLACK );
|
||||
|
||||
List<AudioOutput> outputs = controller.getAudioOutputs();
|
||||
|
||||
for( AudioOutput audioOutput: controller.getAudioOutputs() )
|
||||
|
||||
for( int x = 0; x < outputs.size(); x++ )
|
||||
{
|
||||
add( new AudioChannelPanel( settingsManager, audioOutput ), "wrap" );
|
||||
add( new AudioChannelPanel( settingsManager, outputs.get( x ) ), "wrap" );
|
||||
|
||||
if( x < outputs.size() - 1 )
|
||||
{
|
||||
addSeparator();
|
||||
}
|
||||
}
|
||||
|
||||
/* Add an empty channel panel so that the panel is sized appropriately
|
||||
* for either a single channel or two channels */
|
||||
if( outputs.size() == 1 )
|
||||
{
|
||||
addSeparator();
|
||||
add( new AudioChannelPanel( settingsManager, null ), "wrap" );
|
||||
}
|
||||
}
|
||||
|
||||
private void addSeparator()
|
||||
{
|
||||
JSeparator separator = new JSeparator( JSeparator.HORIZONTAL );
|
||||
separator.setBackground( Color.DARK_GRAY );
|
||||
add( separator, "span,growx" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,17 +73,19 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
||||
|
||||
private ThreadPoolManager mThreadPoolManager;
|
||||
private ScheduledFuture<?> mProcessingTask;
|
||||
|
||||
private MixerManager mMixerManager;
|
||||
private MixerChannelConfiguration mMixerChannelConfiguration;
|
||||
|
||||
|
||||
/**
|
||||
* Processes all audio produced by the decoding channels and routes audio
|
||||
* packets to any combination of outputs based on any alias audio routing
|
||||
* options specified by the user.
|
||||
*/
|
||||
public AudioManager( ThreadPoolManager manager )
|
||||
public AudioManager( ThreadPoolManager manager, MixerManager mixerManager )
|
||||
{
|
||||
mThreadPoolManager = manager;
|
||||
mMixerManager = mixerManager;
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
@@ -100,8 +102,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
||||
|
||||
String channels = properties.get( AUDIO_CHANNELS_PROPERTY, MixerChannel.MONO.name() );
|
||||
|
||||
MixerChannelConfiguration[] mixerConfigurations =
|
||||
MixerManager.getInstance().getOutputMixers();
|
||||
MixerChannelConfiguration[] mixerConfigurations = mMixerManager.getOutputMixers();
|
||||
|
||||
for( MixerChannelConfiguration mixerConfig: mixerConfigurations )
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package audio;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import module.Module;
|
||||
|
||||
@@ -8,7 +9,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import sample.real.IRealBufferListener;
|
||||
import sample.real.IFilteredRealBufferListener;
|
||||
import sample.real.RealBuffer;
|
||||
import audio.metadata.AudioMetadata;
|
||||
import audio.metadata.IMetadataListener;
|
||||
@@ -18,7 +19,6 @@ import audio.squelch.SquelchState;
|
||||
import controller.channel.ChannelEvent;
|
||||
import controller.channel.IChannelEventListener;
|
||||
import dsp.filter.Filters;
|
||||
import dsp.filter.dc.DCRemovalFilter_RB;
|
||||
import dsp.filter.fir.real.RealFIRFilter_R_R;
|
||||
|
||||
/**
|
||||
@@ -32,49 +32,31 @@ import dsp.filter.fir.real.RealFIRFilter_R_R;
|
||||
public class AudioModule extends Module implements IAudioPacketProvider,
|
||||
IChannelEventListener,
|
||||
IMetadataListener,
|
||||
IRealBufferListener,
|
||||
IFilteredRealBufferListener,
|
||||
ISquelchStateListener,
|
||||
Listener<RealBuffer>
|
||||
{
|
||||
protected static final Logger mLog = LoggerFactory.getLogger( AudioModule.class );
|
||||
|
||||
/* Determines responsiveness of DC filter to frequency changes */
|
||||
private static final float DC_REMOVAL_RATIO = 0.000003f;
|
||||
|
||||
/* Provides a unique identifier for this audio module instance to use as a
|
||||
* source identifier for all audio packets */
|
||||
private static int UNIQUE_ID = 0;
|
||||
private int mSourceID;
|
||||
|
||||
private AudioMetadata mAudioMetadata;
|
||||
|
||||
private ChannelEventListener mChannelEventListener = new ChannelEventListener();
|
||||
|
||||
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
||||
private SquelchState mSquelchState = SquelchState.SQUELCH;
|
||||
|
||||
private RealFIRFilter_R_R mAudioFilter = new RealFIRFilter_R_R(
|
||||
Filters.FIR_BANDPASS_AUDIO_48KHZ.getCoefficients(), 2.0f );
|
||||
|
||||
private DCRemovalFilter_RB mDCRemovalFilter;
|
||||
|
||||
private Listener<AudioPacket> mAudioPacketListener;
|
||||
|
||||
//TODO: remove this -- is being replaced by the DemodulatedAudioFilterModule
|
||||
private RealFIRFilter_R_R mAudioFilter = new RealFIRFilter_R_R(
|
||||
Filters.FIR_BANDPASS_AUDIO_48KHZ.getCoefficients(), 2.0f );
|
||||
|
||||
private boolean mRemoveDC = false;
|
||||
|
||||
public AudioModule( boolean record, boolean removeDC )
|
||||
public AudioModule( boolean record )
|
||||
{
|
||||
mSourceID = ++UNIQUE_ID;
|
||||
|
||||
mAudioMetadata = new AudioMetadata( mSourceID, record );
|
||||
|
||||
mRemoveDC = removeDC;
|
||||
|
||||
if( mRemoveDC )
|
||||
{
|
||||
mDCRemovalFilter = new DCRemovalFilter_RB( DC_REMOVAL_RATIO );
|
||||
mDCRemovalFilter.setListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +73,7 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
/* No start operations provided */
|
||||
}
|
||||
@@ -132,13 +114,8 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<RealBuffer> getRealBufferListener()
|
||||
public Listener<RealBuffer> getFilteredRealBufferListener()
|
||||
{
|
||||
if( mRemoveDC )
|
||||
{
|
||||
return mDCRemovalFilter;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -183,10 +160,10 @@ public class AudioModule extends Module implements IAudioPacketProvider,
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case CHANNEL_STATE_RESET:
|
||||
case NOTIFICATION_STATE_RESET:
|
||||
mAudioMetadata.reset();
|
||||
break;
|
||||
case CHANGE_SELECTED:
|
||||
case NOTIFICATION_SELECTION_CHANGE:
|
||||
mAudioMetadata.setSelected( event.getChannel().isSelected() );
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
import source.SourceManager;
|
||||
import source.mixer.MixerChannelConfiguration;
|
||||
import source.mixer.MixerManager;
|
||||
import audio.output.AudioOutput;
|
||||
|
||||
public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||
@@ -43,14 +43,18 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||
new ImageIcon( "images/audio_unmuted.png" ), 38 );
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
private SourceManager mSourceManager;
|
||||
private IAudioController mController;
|
||||
|
||||
private JButton mMuteButton;
|
||||
private AudioChannelsPanel mAudioChannelsPanel;
|
||||
|
||||
public AudioPanel( SettingsManager settingsManager, IAudioController controller )
|
||||
public AudioPanel( SettingsManager settingsManager,
|
||||
SourceManager sourceManager,
|
||||
IAudioController controller )
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
mSourceManager = sourceManager;
|
||||
mController = controller;
|
||||
|
||||
mController.addControllerListener( this );
|
||||
@@ -148,7 +152,7 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||
JMenu outputMenu = new JMenu( "Audio Output" );
|
||||
|
||||
MixerChannelConfiguration[] mixerConfigurations =
|
||||
MixerManager.getInstance().getOutputMixers();
|
||||
mSourceManager.getMixerManager().getOutputMixers();
|
||||
|
||||
for( MixerChannelConfiguration mixerConfig: mixerConfigurations )
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import alias.Alias;
|
||||
import alias.priority.Priority;
|
||||
import alias.id.priority.Priority;
|
||||
|
||||
public class AudioMetadata implements Listener<Metadata>
|
||||
{
|
||||
@@ -305,6 +305,7 @@ public class AudioMetadata implements Listener<Metadata>
|
||||
sb.append( getPriority() );
|
||||
sb.append( " updated:" + isUpdated() );
|
||||
sb.append( " " );
|
||||
|
||||
for( Entry<MetadataType,Metadata> entry: getMetadata().entrySet() )
|
||||
{
|
||||
sb.append( entry.getValue().getKey() );
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package audio.metadata;
|
||||
|
||||
import alias.Alias;
|
||||
@@ -142,5 +159,4 @@ public class Metadata
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package audio.output;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -147,8 +164,7 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
||||
|
||||
public void reset()
|
||||
{
|
||||
broadcast( new AudioEvent( AudioEvent.Type.AUDIO_STOPPED,
|
||||
getChannelName() ) );
|
||||
broadcast( new AudioEvent( AudioEvent.Type.AUDIO_STOPPED, getChannelName() ) );
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package audio.output;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package audio.output;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -19,15 +19,10 @@ package bits;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import edac.CRC;
|
||||
|
||||
public class BinaryMessage extends BitSet
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( BinaryMessage.class );
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,9 +64,9 @@ public class MessageFramer implements Listener<Boolean>,
|
||||
{
|
||||
assembler.dispose();
|
||||
}
|
||||
|
||||
mMessageAssemblers.clear();
|
||||
}
|
||||
|
||||
mMessageAssemblers.clear();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
@@ -154,8 +154,9 @@ public class MessageFramer implements Listener<Boolean>,
|
||||
{
|
||||
mMessageAssemblers.add( assembler );
|
||||
}
|
||||
|
||||
private void removeMessageAssembler( MessageAssembler assembler )
|
||||
|
||||
@SuppressWarnings( "unused" )
|
||||
private void removeMessageAssembler( MessageAssembler assembler )
|
||||
{
|
||||
mMessageAssemblers.remove( assembler );
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
public class BufferOverflowException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BufferOverflowException( String text )
|
||||
{
|
||||
super( text );
|
||||
}
|
||||
|
||||
public BufferOverflowException( String text, Throwable exc )
|
||||
{
|
||||
super( text, exc );
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
public interface BufferOverflowListener
|
||||
{
|
||||
public void overflow( Object source, String message );
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
public class ByteArrayDelayBuffer
|
||||
{
|
||||
private int mBufferSize;
|
||||
private byte[][] mBuffer = null;
|
||||
private int mBufferPointer = 0;
|
||||
|
||||
/**
|
||||
* Implements a delay buffer for byte arrays. As a new byte[] is placed
|
||||
* into the buffer, the oldest byte[] is returned
|
||||
* @param bufferSize - number of byte arrays to buffer
|
||||
*/
|
||||
public ByteArrayDelayBuffer( int bufferSize )
|
||||
{
|
||||
mBufferSize = bufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts new bytes into the buffer
|
||||
*
|
||||
* @return - oldest byte[] from the buffer, or null if the buffer is not
|
||||
* yet full
|
||||
*/
|
||||
public byte[] get( byte[] bytes )
|
||||
{
|
||||
if( mBuffer == null )
|
||||
{
|
||||
mBuffer = new byte[ mBufferSize ][ bytes.length ];
|
||||
}
|
||||
|
||||
byte[] returnBytes = mBuffer[ mBufferPointer ];
|
||||
|
||||
mBuffer[ mBufferPointer++ ] = bytes;
|
||||
|
||||
if( mBufferPointer >= mBufferSize )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
return returnBytes;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
public interface ByteArrayListener
|
||||
{
|
||||
public void receive( byte[] data );
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
|
||||
|
||||
public interface ByteBufferProvider
|
||||
{
|
||||
/**
|
||||
* Adds a sample listener to receive samples
|
||||
*/
|
||||
public void addByteBufferListener( ByteBufferListener listener );
|
||||
|
||||
/**
|
||||
* Removes the sample listener, if it is currently registered as a listener
|
||||
*/
|
||||
public void removeByteBufferListener( ByteBufferListener listener );
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sample.complex.Complex;
|
||||
|
||||
/**
|
||||
* Provides a complex sample enumeration wrapper around a byte array containing
|
||||
* interleaved byte-length I & Q sample values in the range of 0 - 255, converting
|
||||
* those samples into complex samples with value range of -128 to 0 to 127.
|
||||
*/
|
||||
public class ComplexByteBuffer implements Enumeration<Complex>
|
||||
{
|
||||
private static float[] mValues;
|
||||
|
||||
/**
|
||||
* Creates a lookup table that converts the 8-bit valued range from 0 - 255
|
||||
* into scaled float values of -128 to 0 to 127
|
||||
*/
|
||||
static
|
||||
{
|
||||
mValues = new float[ 256 ];
|
||||
|
||||
float scale = (float)( 1.0f / 127.0f );
|
||||
|
||||
for( int x = 0; x < 256; x++ )
|
||||
{
|
||||
mValues[ x ] = (float)( x - 128 ) * scale;
|
||||
}
|
||||
}
|
||||
|
||||
private ByteBuffer mBytes;
|
||||
// private byte[] mBytes;
|
||||
// private int mPointer;
|
||||
|
||||
public ComplexByteBuffer( byte[] bytes )
|
||||
{
|
||||
mBytes = ByteBuffer.wrap( bytes );
|
||||
// mBytes = bytes;
|
||||
// mPointer = 0;
|
||||
}
|
||||
|
||||
public byte[] toArray()
|
||||
{
|
||||
// return mBytes;
|
||||
return mBytes.array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there are more complex samples remaining.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasMoreElements()
|
||||
{
|
||||
// return mPointer < mBytes.length;
|
||||
return mBytes.hasRemaining();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next complex sample.
|
||||
*
|
||||
* Note: does not check for buffer overrun. Use the hasMoreElements()
|
||||
* method to ensure you do not read past the end of the buffer.
|
||||
*/
|
||||
@Override
|
||||
public Complex nextElement()
|
||||
{
|
||||
// return new ComplexSample( mValues[ ( mBytes[ mPointer++ ] & 0xFF ) ],
|
||||
// mValues[ ( mBytes[ mPointer++ ] & 0xFF ) ] );
|
||||
return new Complex( mValues[ ( mBytes.get() & 0xFF ) ],
|
||||
mValues[ ( mBytes.get() & 0xFF ) ] );
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
public interface ComplexByteBufferListener
|
||||
{
|
||||
public void receive( ComplexByteBuffer buffer );
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
|
||||
import sample.complex.Complex;
|
||||
|
||||
public class ComplexSampleBufferAssembler
|
||||
{
|
||||
private ByteBuffer mByteBuffer;
|
||||
private int mSizeInBytes;
|
||||
|
||||
public ComplexSampleBufferAssembler( int size )
|
||||
{
|
||||
mSizeInBytes = size * 4;
|
||||
|
||||
//Allocate a byte buffer with 4 bytes per sample (ie 2 x 16-bit samples)
|
||||
mByteBuffer = ByteBuffer.allocate( mSizeInBytes );
|
||||
mByteBuffer.order( ByteOrder.LITTLE_ENDIAN );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the sample's bytes, left then right, little endian, into the
|
||||
* backing byte array
|
||||
*/
|
||||
public void put( Complex sample )
|
||||
{
|
||||
mByteBuffer.putShort( (short)( sample.left() * Short.MAX_VALUE ) );
|
||||
mByteBuffer.putShort( (short)( sample.right() * Short.MAX_VALUE ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is room for more samples in the buffer, or if it is full
|
||||
*/
|
||||
public boolean hasRemaining()
|
||||
{
|
||||
return mByteBuffer.hasRemaining();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the byte array backing this buffer
|
||||
*/
|
||||
public ByteBuffer get()
|
||||
{
|
||||
return ByteBuffer.wrap( Arrays.copyOf( mByteBuffer.array(), mSizeInBytes ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the bytes from the underlying buffer and reset the pointer to 0.
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
mByteBuffer.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import sample.Listener;
|
||||
|
||||
/**
|
||||
* Delay Buffer - implements a circular delay buffer backed by an object array
|
||||
*/
|
||||
public class DelayBuffer<T> implements Listener<T>
|
||||
{
|
||||
private Object[] mBuffer;
|
||||
private int mBufferPointer = 0;
|
||||
private Listener<T> mListener;
|
||||
|
||||
public DelayBuffer( int length )
|
||||
{
|
||||
mBuffer = new Object[ length ];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public void receive( T value )
|
||||
{
|
||||
Object delayed = mBuffer[ mBufferPointer ];
|
||||
|
||||
mBuffer[ mBufferPointer ] = value;
|
||||
|
||||
mBufferPointer++;
|
||||
|
||||
/* Wrap the buffer pointer around to 0 when necessary */
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
if( mListener != null && delayed != null )
|
||||
{
|
||||
mListener.receive( (T)delayed );
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener( Listener<T> listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void removeListener( Listener<T> listener )
|
||||
{
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FloatArrayCircularAveragingBuffer
|
||||
{
|
||||
private ArrayList<float[]> mBuffer;
|
||||
private int mBufferPointer;
|
||||
private int mBufferSize;
|
||||
private float[] mAverage;
|
||||
|
||||
public FloatArrayCircularAveragingBuffer( int bufferSize )
|
||||
{
|
||||
mBufferSize = bufferSize;
|
||||
mBuffer = new ArrayList<float[]>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the oldest float array element in the buffer with this new
|
||||
* float array element, and then returns the average of the buffer contents
|
||||
* with the newElement values included in the average array
|
||||
*/
|
||||
public float[] get( float[] newElement )
|
||||
{
|
||||
/**
|
||||
* If we've never setup the average array, or the newElements length is
|
||||
* different than what we've been processing, reset the buffer & averages
|
||||
*/
|
||||
if( mAverage == null || mAverage.length != newElement.length )
|
||||
{
|
||||
reset( newElement.length );
|
||||
}
|
||||
|
||||
float[] oldElement = mBuffer.get( mBufferPointer );
|
||||
|
||||
for( int x = 0; x < newElement.length; x++ )
|
||||
{
|
||||
/**
|
||||
* Change the current average value in each array element by the
|
||||
* difference of the new element minus the old element, divided
|
||||
* by the buffer size ... average it
|
||||
*/
|
||||
mAverage[ x ] +=
|
||||
( ( newElement[ x ] - oldElement[ x ] ) / mBufferSize );
|
||||
}
|
||||
|
||||
mBuffer.set( mBufferPointer, newElement );
|
||||
|
||||
mBufferPointer++;
|
||||
|
||||
if( mBufferPointer >= mBufferSize )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
return mAverage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears buffer and average and fills buffer with zero-valued float arrays
|
||||
*/
|
||||
private void reset( int arrayLength )
|
||||
{
|
||||
mAverage = new float[ arrayLength ];
|
||||
Arrays.fill( mAverage, 0.0f );
|
||||
|
||||
mBuffer.clear();
|
||||
mBufferPointer = 0;
|
||||
|
||||
float[] emptyArray = new float[ arrayLength ];
|
||||
Arrays.fill( emptyArray, 0.0f );
|
||||
|
||||
for( int x = 0; x < mBufferSize; x++ )
|
||||
{
|
||||
mBuffer.add( emptyArray );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import sample.Listener;
|
||||
|
||||
|
||||
/**
|
||||
* Assembles single samples into sample blocks (ie arrays) for broadcast to
|
||||
* registered SampleBlockListeners
|
||||
*/
|
||||
public class FloatBufferAssembler implements Listener<Float>
|
||||
{
|
||||
private Float[] mFloatBuffer;
|
||||
private int mBufferSize;
|
||||
private int mBufferPointer = 0;
|
||||
private Listener<Float[]> mListener;
|
||||
|
||||
public FloatBufferAssembler( int bufferSize )
|
||||
{
|
||||
mBufferSize = bufferSize;
|
||||
mFloatBuffer = new Float[ mBufferSize ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores received samples in the sample block and manages the storage
|
||||
* pointer. Sends sample blocks when full.
|
||||
*/
|
||||
@Override
|
||||
public void receive( Float sample )
|
||||
{
|
||||
mFloatBuffer[ mBufferPointer++ ] = sample;
|
||||
|
||||
if( mBufferPointer == mBufferSize )
|
||||
{
|
||||
if( mListener != null )
|
||||
{
|
||||
mListener.receive( Arrays.copyOf( mFloatBuffer, mBufferSize ) );
|
||||
}
|
||||
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new sampleblock listener to receive sample blocks as they are
|
||||
* assembled from the sample stream
|
||||
*/
|
||||
public void setListener( Listener<Float[]> listener )
|
||||
{
|
||||
mListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Circular sample buffer - allocates a buffer and stores samples in a circular
|
||||
* fashion, overwriting older samples with newly arrived samples. Initially
|
||||
* fills buffer with 0-valued samples
|
||||
*
|
||||
* Produces no output. Obtain the average buffer value on-demand via the
|
||||
* getAverage() method
|
||||
*/
|
||||
public class FloatCircularAveragingBuffer
|
||||
{
|
||||
private float[] mBuffer;
|
||||
private int mBufferPointer = 0;
|
||||
private int mSampleCountForAveraging;
|
||||
private int mCurrentSampleCount = 0;
|
||||
private float mAverage = 0.0f;
|
||||
|
||||
public FloatCircularAveragingBuffer( int size, int sampleCountForAveraging )
|
||||
{
|
||||
mBuffer = new float[ size ];
|
||||
mSampleCountForAveraging = sampleCountForAveraging;
|
||||
Arrays.fill( mBuffer, 0.0f );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience wrapper to throw away to put the new sample and throwaway
|
||||
* the oldest sample
|
||||
*/
|
||||
public void put( float newestSample )
|
||||
{
|
||||
get( newestSample );
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the newest sample into the buffer and returns the oldest sample
|
||||
*/
|
||||
public float get( float newestSample )
|
||||
{
|
||||
float oldestSample = mBuffer[ mBufferPointer ];
|
||||
|
||||
mBuffer[ mBufferPointer ] = newestSample;
|
||||
|
||||
mBufferPointer++;
|
||||
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
mCurrentSampleCount++;
|
||||
|
||||
if( mCurrentSampleCount >= mSampleCountForAveraging )
|
||||
{
|
||||
calculateAverage();
|
||||
|
||||
mCurrentSampleCount = 0;
|
||||
}
|
||||
|
||||
return oldestSample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the average of the maximum and minimum values present in
|
||||
* the buffer
|
||||
*/
|
||||
private void calculateAverage()
|
||||
{
|
||||
float min = mBuffer[ 0 ];
|
||||
float max = mBuffer[ 0 ];
|
||||
|
||||
for( int x = 0; x < mBuffer.length; x++ )
|
||||
{
|
||||
if( mBuffer[ x ] < min )
|
||||
{
|
||||
min = mBuffer[ x ];
|
||||
}
|
||||
if( mBuffer[ x ] > max )
|
||||
{
|
||||
max = mBuffer[ x ];
|
||||
}
|
||||
}
|
||||
|
||||
mAverage = (float)( ( min + max ) / 2.0f );
|
||||
}
|
||||
|
||||
public float getAverage()
|
||||
{
|
||||
return mAverage;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package buffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Circular sample buffer - stores samples in a circular buffer
|
||||
* overwriting older samples with newly arrived samples. Initially
|
||||
* fills buffer with 0-valued samples
|
||||
*
|
||||
* Continuously calculates the average of the samples in the buffer, with the
|
||||
* average available from the average() method.
|
||||
*/
|
||||
public class FloatCircularAveragingBuffer2
|
||||
{
|
||||
private float[] mBuffer;
|
||||
private int mBufferPointer = 0;
|
||||
private float mAverage = 0.0f;
|
||||
|
||||
public FloatCircularAveragingBuffer2( int size )
|
||||
{
|
||||
mBuffer = new float[ size ];
|
||||
Arrays.fill( mBuffer, 0.0f );
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the newest sample into the buffer and returns the oldest sample
|
||||
*/
|
||||
public float get( float newestSample )
|
||||
{
|
||||
float oldestSample = mBuffer[ mBufferPointer ];
|
||||
|
||||
mBuffer[ mBufferPointer ] = newestSample;
|
||||
|
||||
mBufferPointer++;
|
||||
|
||||
if( mBufferPointer >= mBuffer.length )
|
||||
{
|
||||
mBufferPointer = 0;
|
||||
}
|
||||
|
||||
mAverage = mAverage - ( oldestSample / mBuffer.length ) +
|
||||
( newestSample / mBuffer.length );
|
||||
|
||||
return oldestSample;
|
||||
}
|
||||
|
||||
public float average()
|
||||
{
|
||||
return mAverage;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user