mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-19 20:17:25 -05:00
Alias actions. Adds capability to alert when an alias is active in one of the decoded messages. Alias actions include: beep, play an audio clip, or run a script. Additional actions can easily be added.
This commit is contained in:
BIN
images/action.png
Normal file
BIN
images/action.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 522 B |
@@ -19,9 +19,11 @@ package alias;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
|
||||||
|
import alias.action.AliasAction;
|
||||||
import audio.AudioType;
|
import audio.AudioType;
|
||||||
|
|
||||||
public class Alias
|
public class Alias
|
||||||
@@ -30,6 +32,7 @@ public class Alias
|
|||||||
private int mColor;
|
private int mColor;
|
||||||
private String mIconName;
|
private String mIconName;
|
||||||
private ArrayList<AliasID> mAliasIDs = new ArrayList<AliasID>();
|
private ArrayList<AliasID> mAliasIDs = new ArrayList<AliasID>();
|
||||||
|
private List<AliasAction> mAliasActions = new ArrayList<AliasAction>();
|
||||||
|
|
||||||
public Alias()
|
public Alias()
|
||||||
{
|
{
|
||||||
@@ -98,6 +101,31 @@ public class Alias
|
|||||||
mAliasIDs.remove( id );
|
mAliasIDs.remove( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<AliasAction> getAction()
|
||||||
|
{
|
||||||
|
return mAliasActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction( List<AliasAction> actions )
|
||||||
|
{
|
||||||
|
mAliasActions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAliasAction( AliasAction action )
|
||||||
|
{
|
||||||
|
mAliasActions.add( action );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAliasAction( AliasAction action )
|
||||||
|
{
|
||||||
|
mAliasActions.remove( action );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasActions()
|
||||||
|
{
|
||||||
|
return !mAliasActions.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasAudioType()
|
public boolean hasAudioType()
|
||||||
{
|
{
|
||||||
for( AliasID id: mAliasIDs )
|
for( AliasID id: mAliasIDs )
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import javax.xml.bind.annotation.XmlSeeAlso;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import decode.p25.P25ActivitySummary;
|
import alias.action.AliasAction;
|
||||||
|
import alias.action.beep.BeepAction;
|
||||||
|
import alias.action.clip.ClipAction;
|
||||||
|
import alias.action.script.ScriptAction;
|
||||||
import alias.esn.Esn;
|
import alias.esn.Esn;
|
||||||
import alias.fleetsync.FleetsyncID;
|
import alias.fleetsync.FleetsyncID;
|
||||||
import alias.fleetsync.StatusID;
|
import alias.fleetsync.StatusID;
|
||||||
@@ -49,7 +52,14 @@ import alias.uniqueID.UniqueID;
|
|||||||
UniqueID.class,
|
UniqueID.class,
|
||||||
SiteID.class,
|
SiteID.class,
|
||||||
StatusID.class,
|
StatusID.class,
|
||||||
TalkgroupID.class } )
|
TalkgroupID.class,
|
||||||
|
|
||||||
|
/* Alias Actions */
|
||||||
|
AliasAction.class,
|
||||||
|
BeepAction.class,
|
||||||
|
ClipAction.class,
|
||||||
|
ScriptAction.class } )
|
||||||
|
|
||||||
@XmlRootElement( name = "alias_list" )
|
@XmlRootElement( name = "alias_list" )
|
||||||
public class AliasList implements Comparable<AliasList>
|
public class AliasList implements Comparable<AliasList>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ import javax.swing.JMenuItem;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
import map.MapIcon;
|
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.esn.ESNNode;
|
import alias.esn.ESNNode;
|
||||||
import alias.esn.Esn;
|
import alias.esn.Esn;
|
||||||
import alias.fleetsync.FleetsyncID;
|
import alias.fleetsync.FleetsyncID;
|
||||||
@@ -136,6 +142,25 @@ public class AliasNode extends ConfigurableNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +367,80 @@ public class AliasNode extends ConfigurableNode
|
|||||||
|
|
||||||
retVal.add( addIDMenu );
|
retVal.add( addIDMenu );
|
||||||
|
|
||||||
retVal.add( new JSeparator() );
|
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();
|
||||||
|
|
||||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||||
deleteItem.addActionListener( new ActionListener()
|
deleteItem.addActionListener( new ActionListener()
|
||||||
|
|||||||
30
src/alias/action/AliasAction.java
Normal file
30
src/alias/action/AliasAction.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package alias.action;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
import alias.Alias;
|
||||||
|
import controller.ThreadPoolManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias action defines an action to execute when an alias is detected active.
|
||||||
|
*/
|
||||||
|
public abstract class AliasAction
|
||||||
|
{
|
||||||
|
public AliasAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task to execute when an alias action is defined. The message argument is
|
||||||
|
* the original message containing one or more aliases that have an alias
|
||||||
|
* action attached. The alias argument is the parent alias containing the
|
||||||
|
* alias action.
|
||||||
|
*/
|
||||||
|
public abstract void execute( ThreadPoolManager threadPoolManager,
|
||||||
|
Alias alias,
|
||||||
|
Message message );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dismiss a persistent alias action
|
||||||
|
*/
|
||||||
|
public abstract void dismiss( boolean reset );
|
||||||
|
}
|
||||||
59
src/alias/action/AliasActionManager.java
Normal file
59
src/alias/action/AliasActionManager.java
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package alias.action;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
import sample.Listener;
|
||||||
|
import alias.Alias;
|
||||||
|
import controller.ResourceManager;
|
||||||
|
import decode.p25.P25Decoder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages all alias action events. Each received message is interrogated for
|
||||||
|
* any alias entries and then each alias is interrogated for any alias actions.
|
||||||
|
*
|
||||||
|
* Each alias action is executed and provided a copy of the source message so
|
||||||
|
* that the contents of the message can be used as part of the action.
|
||||||
|
*/
|
||||||
|
public class AliasActionManager implements Listener<Message>
|
||||||
|
{
|
||||||
|
private final static Logger mLog =
|
||||||
|
LoggerFactory.getLogger( AliasActionManager.class );
|
||||||
|
|
||||||
|
private ResourceManager mResourceManager;
|
||||||
|
|
||||||
|
public AliasActionManager( ResourceManager resourceManager )
|
||||||
|
{
|
||||||
|
mResourceManager = resourceManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive( Message message )
|
||||||
|
{
|
||||||
|
List<Alias> aliases = message.getAliases();
|
||||||
|
|
||||||
|
if( aliases != null )
|
||||||
|
{
|
||||||
|
for( Alias alias: aliases )
|
||||||
|
{
|
||||||
|
if( alias.hasActions() )
|
||||||
|
{
|
||||||
|
List<AliasAction> actions = alias.getAction();
|
||||||
|
|
||||||
|
for( AliasAction action: actions )
|
||||||
|
{
|
||||||
|
/* Provide access to the thread pool manager in case the
|
||||||
|
* 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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/alias/action/AliasActionNode.java
Normal file
40
src/alias/action/AliasActionNode.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
188
src/alias/action/RecurringAction.java
Normal file
188
src/alias/action/RecurringAction.java
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
package alias.action;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
import alias.Alias;
|
||||||
|
import controller.ThreadPoolManager;
|
||||||
|
import controller.ThreadPoolManager.ThreadType;
|
||||||
|
|
||||||
|
public abstract class RecurringAction extends AliasAction
|
||||||
|
{
|
||||||
|
@XmlTransient
|
||||||
|
protected AtomicBoolean mRunning = new AtomicBoolean( false );
|
||||||
|
@XmlTransient
|
||||||
|
private ScheduledFuture<?> mPerpetualAction;
|
||||||
|
|
||||||
|
protected Interval mInterval = Interval.ONCE;
|
||||||
|
protected int mPeriod = 5;
|
||||||
|
|
||||||
|
protected ThreadPoolManager mThreadPoolManager;
|
||||||
|
|
||||||
|
public abstract void performAction( Alias alias, Message message );
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute( ThreadPoolManager threadPoolManager,
|
||||||
|
Alias alias,
|
||||||
|
Message message )
|
||||||
|
{
|
||||||
|
mThreadPoolManager = threadPoolManager;
|
||||||
|
|
||||||
|
if( mRunning.compareAndSet( false, true ) )
|
||||||
|
{
|
||||||
|
switch( mInterval )
|
||||||
|
{
|
||||||
|
case ONCE:
|
||||||
|
performThreadedAction( alias, message );
|
||||||
|
/* Don't reset */
|
||||||
|
break;
|
||||||
|
case DELAYED_RESET:
|
||||||
|
performThreadedAction( alias, message );
|
||||||
|
mThreadPoolManager.scheduleOnce( new ResetTask(),
|
||||||
|
mPeriod, TimeUnit.SECONDS );
|
||||||
|
break;
|
||||||
|
case UNTIL_DISMISSED:
|
||||||
|
mPerpetualAction = mThreadPoolManager
|
||||||
|
.scheduleFixedRate( ThreadType.DECODER,
|
||||||
|
new PerformActionTask( alias, message ),
|
||||||
|
mPeriod, TimeUnit.SECONDS );
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append( "<html><div width='250'>Alias [" );
|
||||||
|
sb.append( alias.getName() );
|
||||||
|
sb.append( "] is active in message [" );
|
||||||
|
sb.append( message.toString() );
|
||||||
|
sb.append( "]</div></html>" );
|
||||||
|
|
||||||
|
final String text = sb.toString();
|
||||||
|
|
||||||
|
EventQueue.invokeLater( new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( null, text,
|
||||||
|
"Alias Alert", JOptionPane.INFORMATION_MESSAGE );
|
||||||
|
|
||||||
|
dismiss( false );
|
||||||
|
|
||||||
|
mThreadPoolManager.scheduleOnce( new ResetTask(),
|
||||||
|
15, TimeUnit.SECONDS );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spawns the performAction() event into a new thread so that it doesn't
|
||||||
|
* delay any decoder actions.
|
||||||
|
*/
|
||||||
|
private void performThreadedAction( final Alias alias, final Message message )
|
||||||
|
{
|
||||||
|
mThreadPoolManager.scheduleOnce( new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
performAction( alias, message );
|
||||||
|
}}, 0, TimeUnit.SECONDS );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dismiss( boolean reset )
|
||||||
|
{
|
||||||
|
if( mPerpetualAction != null )
|
||||||
|
{
|
||||||
|
mPerpetualAction.cancel( true );
|
||||||
|
|
||||||
|
mPerpetualAction = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( reset )
|
||||||
|
{
|
||||||
|
mRunning.set( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
public int getPeriod()
|
||||||
|
{
|
||||||
|
return mPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriod( int period )
|
||||||
|
{
|
||||||
|
mPeriod = period;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute
|
||||||
|
public Interval getInterval()
|
||||||
|
{
|
||||||
|
return mInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterval( Interval interval )
|
||||||
|
{
|
||||||
|
mInterval = interval;
|
||||||
|
|
||||||
|
mRunning.set( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Interval
|
||||||
|
{
|
||||||
|
ONCE( "Once" ),
|
||||||
|
DELAYED_RESET( "Once, Reset After Delay" ),
|
||||||
|
UNTIL_DISMISSED( "Until Dismissed" );
|
||||||
|
|
||||||
|
private String mLabel;
|
||||||
|
|
||||||
|
private Interval( String label )
|
||||||
|
{
|
||||||
|
mLabel = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return mLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PerformActionTask implements Runnable
|
||||||
|
{
|
||||||
|
private Alias mAlias;
|
||||||
|
private Message mMessage;
|
||||||
|
|
||||||
|
public PerformActionTask( Alias alias, Message message )
|
||||||
|
{
|
||||||
|
mAlias = alias;
|
||||||
|
mMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
/* Don't use the performThreadedAction() method, since this is
|
||||||
|
* already running in a separate thread */
|
||||||
|
performAction( mAlias, mMessage );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ResetTask implements Runnable
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
mRunning.set( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/alias/action/beep/BeepAction.java
Normal file
14
src/alias/action/beep/BeepAction.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package alias.action.beep;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.action.RecurringAction;
|
||||||
|
|
||||||
|
public class BeepAction extends RecurringAction
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void performAction( Alias alias, Message message )
|
||||||
|
{
|
||||||
|
System.out.println( "\007" );
|
||||||
|
}
|
||||||
|
}
|
||||||
151
src/alias/action/beep/BeepActionEditor.java
Normal file
151
src/alias/action/beep/BeepActionEditor.java
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* SDR Trunk
|
||||||
|
* Copyright (C) 2014 Dennis Sheirer
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
******************************************************************************/
|
||||||
|
package alias.action.beep;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
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.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.RecurringAction.Interval;
|
||||||
|
|
||||||
|
public class BeepActionEditor extends JPanel implements ActionListener
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
public BeepActionEditor( BeepActionNode beepActionNode )
|
||||||
|
{
|
||||||
|
mBeepActionNode = beepActionNode;
|
||||||
|
|
||||||
|
initGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initGUI()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
|
||||||
|
|
||||||
|
add( new JLabel( "Action: Beep" ), "span,align center" );
|
||||||
|
|
||||||
|
add( new JLabel( "Interval:" ) );
|
||||||
|
|
||||||
|
mComboInterval = new JComboBox<Interval>( Interval.values() );
|
||||||
|
|
||||||
|
mComboInterval.setSelectedItem( mBeepActionNode.getBeepAction().getInterval() );
|
||||||
|
|
||||||
|
mComboInterval.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
Interval selected = mComboInterval
|
||||||
|
.getItemAt( mComboInterval.getSelectedIndex() );
|
||||||
|
|
||||||
|
if( selected != null )
|
||||||
|
{
|
||||||
|
/* Enable/disable period spinner based on selection */
|
||||||
|
mSpinnerPeriod.setEnabled( selected != Interval.ONCE );
|
||||||
|
|
||||||
|
mBeepActionNode.getBeepAction().setInterval( selected );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add( mComboInterval, "wrap" );
|
||||||
|
|
||||||
|
final SpinnerModel model = new SpinnerNumberModel(
|
||||||
|
mBeepActionNode.getBeepAction().getPeriod(), 1, 30, 1 );
|
||||||
|
|
||||||
|
model.addChangeListener( new ChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void stateChanged( ChangeEvent e )
|
||||||
|
{
|
||||||
|
mBeepActionNode.getBeepAction().setPeriod( (int)model.getValue() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
mSpinnerPeriod = new JSpinner( model );
|
||||||
|
|
||||||
|
if( mBeepActionNode.getBeepAction().getInterval() == Interval.ONCE )
|
||||||
|
{
|
||||||
|
mSpinnerPeriod.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
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" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
String command = e.getActionCommand();
|
||||||
|
|
||||||
|
if( command.contentEquals( "Save" ) )
|
||||||
|
{
|
||||||
|
mBeepActionNode.save();
|
||||||
|
mBeepActionNode.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
mBeepActionNode.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/alias/action/beep/BeepActionNode.java
Normal file
88
src/alias/action/beep/BeepActionNode.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
90
src/alias/action/clip/ClipAction.java
Normal file
90
src/alias/action/clip/ClipAction.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package alias.action.clip;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.Clip;
|
||||||
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.action.RecurringAction;
|
||||||
|
|
||||||
|
public class ClipAction extends RecurringAction
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger( ClipAction.class );
|
||||||
|
|
||||||
|
private String mFilePath;
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
|
private Clip mClip;
|
||||||
|
|
||||||
|
public ClipAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
|
||||||
|
return mFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath( String path )
|
||||||
|
{
|
||||||
|
mFilePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void performAction( Alias alias, Message message )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
play();
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
mLog.debug( "Couldn't play audio clip", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void play() throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( mFilePath != null )
|
||||||
|
{
|
||||||
|
if( mClip == null )
|
||||||
|
{
|
||||||
|
mClip = AudioSystem.getClip();
|
||||||
|
|
||||||
|
AudioInputStream ais =
|
||||||
|
AudioSystem.getAudioInputStream( new File( mFilePath ) );
|
||||||
|
|
||||||
|
mClip.open( ais );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mClip.isRunning() )
|
||||||
|
{
|
||||||
|
mClip.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
mClip.setFramePosition( 0 );
|
||||||
|
|
||||||
|
mClip.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
mClip = null;
|
||||||
|
|
||||||
|
mLog.error( "Error playing sound clip [" + mFilePath + "] - " + e.getMessage() );
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
220
src/alias/action/clip/ClipActionEditor.java
Normal file
220
src/alias/action/clip/ClipActionEditor.java
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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.EventQueue;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
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.JTextField;
|
||||||
|
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.RecurringAction.Interval;
|
||||||
|
import alias.action.script.ScriptActionEditor;
|
||||||
|
|
||||||
|
public class ClipActionEditor extends JPanel implements ActionListener
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final static Logger mLog =
|
||||||
|
LoggerFactory.getLogger( ClipActionEditor.class );
|
||||||
|
|
||||||
|
private ClipActionNode mClipActionNode;
|
||||||
|
private JTextField mTextSiteID;
|
||||||
|
private JComboBox<Interval> mComboInterval;
|
||||||
|
private JSpinner mSpinnerPeriod;
|
||||||
|
private JTextField mTextFilePath;
|
||||||
|
|
||||||
|
public ClipActionEditor( ClipActionNode clipActionNode )
|
||||||
|
{
|
||||||
|
mClipActionNode = clipActionNode;
|
||||||
|
|
||||||
|
initGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initGUI()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
|
||||||
|
|
||||||
|
add( new JLabel( "Action: Audio Clip" ), "span,align center" );
|
||||||
|
|
||||||
|
add( new JLabel( "Interval:" ) );
|
||||||
|
|
||||||
|
mComboInterval = new JComboBox<Interval>( Interval.values() );
|
||||||
|
|
||||||
|
mComboInterval.setSelectedItem( mClipActionNode.getClipAction().getInterval() );
|
||||||
|
|
||||||
|
mComboInterval.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
Interval selected = mComboInterval
|
||||||
|
.getItemAt( mComboInterval.getSelectedIndex() );
|
||||||
|
|
||||||
|
if( selected != null )
|
||||||
|
{
|
||||||
|
/* Enable/disable period spinner based on selection */
|
||||||
|
mSpinnerPeriod.setEnabled( selected != Interval.ONCE );
|
||||||
|
|
||||||
|
mClipActionNode.getClipAction().setInterval( selected );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add( mComboInterval, "wrap" );
|
||||||
|
|
||||||
|
final SpinnerModel model = new SpinnerNumberModel(
|
||||||
|
mClipActionNode.getClipAction().getPeriod(), 1, 30, 1 );
|
||||||
|
|
||||||
|
model.addChangeListener( new ChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void stateChanged( ChangeEvent e )
|
||||||
|
{
|
||||||
|
mClipActionNode.getClipAction().setPeriod( (int)model.getValue() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
mSpinnerPeriod = new JSpinner( model );
|
||||||
|
|
||||||
|
if( mClipActionNode.getClipAction().getInterval() == Interval.ONCE )
|
||||||
|
{
|
||||||
|
mSpinnerPeriod.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
add( new JLabel( "Period:" ) );
|
||||||
|
add( mSpinnerPeriod, "wrap" );
|
||||||
|
|
||||||
|
JButton fileButton = new JButton( "File" );
|
||||||
|
|
||||||
|
fileButton.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
final JFileChooser chooser = new JFileChooser();
|
||||||
|
|
||||||
|
int value = chooser.showOpenDialog( ClipActionEditor.this );
|
||||||
|
|
||||||
|
if( value == JFileChooser.APPROVE_OPTION )
|
||||||
|
{
|
||||||
|
File file = chooser.getSelectedFile();
|
||||||
|
|
||||||
|
mClipActionNode.getClipAction().setPath( file.getAbsolutePath() );
|
||||||
|
mTextFilePath.setText( file.getAbsolutePath() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( fileButton );
|
||||||
|
|
||||||
|
JButton testButton = new JButton( "Test" );
|
||||||
|
testButton.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent actionEvent )
|
||||||
|
{
|
||||||
|
String path = mClipActionNode.getClipAction().getPath();
|
||||||
|
|
||||||
|
if( path == null || path.trim().isEmpty() )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||||
|
"Please select an audio file", "Please select file",
|
||||||
|
JOptionPane.ERROR_MESSAGE );
|
||||||
|
}
|
||||||
|
|
||||||
|
EventQueue.invokeLater( new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mClipActionNode.getClipAction().play();
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( ClipActionEditor.this,
|
||||||
|
"Couldn't play audio clip [" + e.getMessage() + "]",
|
||||||
|
"Error", JOptionPane.ERROR_MESSAGE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( testButton, "wrap" );
|
||||||
|
|
||||||
|
mTextFilePath = new JTextField( mClipActionNode.getClipAction().getPath() );
|
||||||
|
add( mTextFilePath, "growx,span" );
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
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." );
|
||||||
|
|
||||||
|
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" );
|
||||||
|
|
||||||
|
JButton btnReset = new JButton( "Reset" );
|
||||||
|
btnReset.addActionListener( ClipActionEditor.this );
|
||||||
|
add( btnReset, "growx,push" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
String command = e.getActionCommand();
|
||||||
|
|
||||||
|
if( command.contentEquals( "Save" ) )
|
||||||
|
{
|
||||||
|
mClipActionNode.save();
|
||||||
|
mClipActionNode.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
mClipActionNode.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/alias/action/clip/ClipActionNode.java
Normal file
88
src/alias/action/clip/ClipActionNode.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
80
src/alias/action/script/ScriptAction.java
Normal file
80
src/alias/action/script/ScriptAction.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package alias.action.script;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.action.RecurringAction;
|
||||||
|
|
||||||
|
public class ScriptAction extends RecurringAction
|
||||||
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger( ScriptAction.class );
|
||||||
|
|
||||||
|
private String mScript;
|
||||||
|
|
||||||
|
public ScriptAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScript()
|
||||||
|
{
|
||||||
|
return mScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScript( String script )
|
||||||
|
{
|
||||||
|
mScript = script;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void performAction( Alias alias, Message message )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
play();
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
mLog.debug( "Couldn't execute script [" + mScript + "]", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void play() throws Exception
|
||||||
|
{
|
||||||
|
if( mScript != null )
|
||||||
|
{
|
||||||
|
mLog.debug( "Running Script ..." );
|
||||||
|
|
||||||
|
ProcessBuilder pb = new ProcessBuilder( mScript );
|
||||||
|
|
||||||
|
pb.redirectErrorStream( true );
|
||||||
|
|
||||||
|
Process p = pb.start();
|
||||||
|
|
||||||
|
int exitCode = p.waitFor();
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader( p.getInputStream() ) );
|
||||||
|
|
||||||
|
String line = "";
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
while( ( line = reader.readLine() ) != null )
|
||||||
|
{
|
||||||
|
sb.append(line + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if( exitCode != 0 )
|
||||||
|
{
|
||||||
|
throw new RuntimeException( "Exit Code: " + exitCode +
|
||||||
|
" Console:" + sb.toString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
218
src/alias/action/script/ScriptActionEditor.java
Normal file
218
src/alias/action/script/ScriptActionEditor.java
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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.EventQueue;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
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.JTextField;
|
||||||
|
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.RecurringAction.Interval;
|
||||||
|
|
||||||
|
public class ScriptActionEditor extends JPanel implements ActionListener
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final static Logger mLog =
|
||||||
|
LoggerFactory.getLogger( ScriptActionEditor.class );
|
||||||
|
|
||||||
|
private ScriptActionNode mScriptActionNode;
|
||||||
|
private JComboBox<Interval> mComboInterval;
|
||||||
|
private JSpinner mSpinnerPeriod;
|
||||||
|
private JTextField mTextFilePath;
|
||||||
|
|
||||||
|
public ScriptActionEditor( ScriptActionNode clipActionNode )
|
||||||
|
{
|
||||||
|
mScriptActionNode = clipActionNode;
|
||||||
|
|
||||||
|
initGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initGUI()
|
||||||
|
{
|
||||||
|
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
|
||||||
|
|
||||||
|
add( new JLabel( "Action: Script" ), "span,align center" );
|
||||||
|
|
||||||
|
add( new JLabel( "Interval:" ) );
|
||||||
|
|
||||||
|
mComboInterval = new JComboBox<Interval>( Interval.values() );
|
||||||
|
|
||||||
|
mComboInterval.setSelectedItem( mScriptActionNode.getScriptAction().getInterval() );
|
||||||
|
|
||||||
|
mComboInterval.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
Interval selected = mComboInterval
|
||||||
|
.getItemAt( mComboInterval.getSelectedIndex() );
|
||||||
|
|
||||||
|
if( selected != null )
|
||||||
|
{
|
||||||
|
/* Enable/disable period spinner based on selection */
|
||||||
|
mSpinnerPeriod.setEnabled( selected != Interval.ONCE );
|
||||||
|
|
||||||
|
mScriptActionNode.getScriptAction().setInterval( selected );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add( mComboInterval, "wrap" );
|
||||||
|
|
||||||
|
final SpinnerModel model = new SpinnerNumberModel(
|
||||||
|
mScriptActionNode.getScriptAction().getPeriod(), 1, 30, 1 );
|
||||||
|
|
||||||
|
model.addChangeListener( new ChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void stateChanged( ChangeEvent e )
|
||||||
|
{
|
||||||
|
mScriptActionNode.getScriptAction().setPeriod( (int)model.getValue() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
mSpinnerPeriod = new JSpinner( model );
|
||||||
|
|
||||||
|
if( mScriptActionNode.getScriptAction().getInterval() == Interval.ONCE )
|
||||||
|
{
|
||||||
|
mSpinnerPeriod.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
add( new JLabel( "Period:" ) );
|
||||||
|
add( mSpinnerPeriod, "wrap" );
|
||||||
|
|
||||||
|
JButton fileButton = new JButton( "File" );
|
||||||
|
|
||||||
|
fileButton.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
final JFileChooser chooser = new JFileChooser();
|
||||||
|
|
||||||
|
int value = chooser.showOpenDialog( ScriptActionEditor.this );
|
||||||
|
|
||||||
|
if( value == JFileChooser.APPROVE_OPTION )
|
||||||
|
{
|
||||||
|
File file = chooser.getSelectedFile();
|
||||||
|
|
||||||
|
mScriptActionNode.getScriptAction().setScript( file.getAbsolutePath() );
|
||||||
|
mTextFilePath.setText( file.getAbsolutePath() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( fileButton );
|
||||||
|
|
||||||
|
JButton testButton = new JButton( "Test" );
|
||||||
|
testButton.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent actionEvent )
|
||||||
|
{
|
||||||
|
String script = mScriptActionNode.getScriptAction().getScript();
|
||||||
|
|
||||||
|
if( script == null || script.trim().isEmpty() )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( ScriptActionEditor.this,
|
||||||
|
"Please select a script file", "Please select file",
|
||||||
|
JOptionPane.ERROR_MESSAGE );
|
||||||
|
}
|
||||||
|
|
||||||
|
EventQueue.invokeLater( new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mScriptActionNode.getScriptAction().play();
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog( ScriptActionEditor.this,
|
||||||
|
"Couldn't run script [" + e.getMessage() + "]",
|
||||||
|
"Error", JOptionPane.ERROR_MESSAGE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
add( testButton, "wrap" );
|
||||||
|
|
||||||
|
mTextFilePath = new JTextField( mScriptActionNode.getScriptAction().getScript() );
|
||||||
|
add( mTextFilePath, "growx,span" );
|
||||||
|
|
||||||
|
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" );
|
||||||
|
|
||||||
|
JButton btnReset = new JButton( "Reset" );
|
||||||
|
btnReset.addActionListener( ScriptActionEditor.this );
|
||||||
|
add( btnReset, "growx,push" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
String command = e.getActionCommand();
|
||||||
|
|
||||||
|
if( command.contentEquals( "Save" ) )
|
||||||
|
{
|
||||||
|
mScriptActionNode.save();
|
||||||
|
mScriptActionNode.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
mScriptActionNode.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
88
src/alias/action/script/ScriptActionNode.java
Normal file
88
src/alias/action/script/ScriptActionNode.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -121,7 +121,7 @@ public class ControllerPanel extends JPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add mapping services and map panel to a new tab
|
* Add mapping services and map panel to a new tab
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller;
|
package controller;
|
||||||
|
|
||||||
|
import alias.action.AliasActionManager;
|
||||||
import map.MapService;
|
import map.MapService;
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
import record.RecorderManager;
|
import record.RecorderManager;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package controller.channel;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import alias.action.AliasActionManager;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import controller.ResourceManager;
|
import controller.ResourceManager;
|
||||||
@@ -31,10 +32,17 @@ public class ChannelManager implements ChannelEventListener
|
|||||||
new ArrayList<ChannelEventListener>();
|
new ArrayList<ChannelEventListener>();
|
||||||
private ArrayList<Listener<Message>> mMessageListeners =
|
private ArrayList<Listener<Message>> mMessageListeners =
|
||||||
new ArrayList<Listener<Message>>();
|
new ArrayList<Listener<Message>>();
|
||||||
|
|
||||||
|
private AliasActionManager mAliasActionManager;
|
||||||
|
|
||||||
public ChannelManager( ResourceManager resourceManager )
|
public ChannelManager( ResourceManager resourceManager )
|
||||||
{
|
{
|
||||||
|
mAliasActionManager = new AliasActionManager( resourceManager );
|
||||||
|
|
||||||
mChannelListeners.add( this );
|
mChannelListeners.add( this );
|
||||||
|
|
||||||
|
/* Add alias action manager as listener to all channels/messages */
|
||||||
|
mMessageListeners.add( mAliasActionManager );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
package decode.fleetsync1;
|
package decode.fleetsync1;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -172,4 +175,28 @@ public class Fleetsync1Message extends Message
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ package decode.fleetsync2;
|
|||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -860,4 +862,35 @@ public class FleetsyncMessage extends Message
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias status = getStatusAlias();
|
||||||
|
|
||||||
|
if( status != null )
|
||||||
|
{
|
||||||
|
aliases.add( status );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
package decode.lj1200;
|
package decode.lj1200;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -364,4 +366,35 @@ public class LJ1200Message extends Message
|
|||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias site = getSiteIDAlias();
|
||||||
|
|
||||||
|
if( site != null )
|
||||||
|
{
|
||||||
|
aliases.add( site );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package decode.ltrnet;
|
package decode.ltrnet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
@@ -309,4 +311,35 @@ public class LTRNetISWMessage extends LTRNetMessage
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias esn = getESNAlias();
|
||||||
|
|
||||||
|
if( esn != null )
|
||||||
|
{
|
||||||
|
aliases.add( esn );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package decode.ltrnet;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
@@ -590,4 +591,49 @@ public class LTRNetOSWMessage extends LTRNetMessage
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias neighbor = getNeighborIDAlias();
|
||||||
|
|
||||||
|
if( neighbor != null )
|
||||||
|
{
|
||||||
|
aliases.add( neighbor );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias uid = getRadioUniqueIDAlias();
|
||||||
|
|
||||||
|
if( uid != null )
|
||||||
|
{
|
||||||
|
aliases.add( uid );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias site = getSiteIDAlias();
|
||||||
|
|
||||||
|
if( site != null )
|
||||||
|
{
|
||||||
|
aliases.add( site );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package decode.ltrstandard;
|
package decode.ltrstandard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
@@ -209,4 +211,28 @@ public class LTRStandardISWMessage extends LTRStandardMessage
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package decode.ltrstandard;
|
package decode.ltrstandard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
@@ -219,4 +221,28 @@ public class LTRStandardOSWMessage extends LTRStandardMessage
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
package decode.mdc1200;
|
package decode.mdc1200;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -313,6 +315,30 @@ public class MDCMessage extends Message
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
private enum PacketType { CMND, DATA };
|
private enum PacketType { CMND, DATA };
|
||||||
private enum Acknowledge { YES, NO };
|
private enum Acknowledge { YES, NO };
|
||||||
private enum Direction { IN, OUT };
|
private enum Direction { IN, OUT };
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.BitSet;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -1535,6 +1536,31 @@ public class MPT1327Message extends Message
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SDM Message format ICDs
|
* SDM Message format ICDs
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ package decode.passport;
|
|||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -621,4 +623,27 @@ public class PassportMessage extends Message
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias talkgroup = getTalkgroupIDAlias();
|
||||||
|
|
||||||
|
if( talkgroup != null )
|
||||||
|
{
|
||||||
|
aliases.add( talkgroup );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias mid = getMobileIDAlias();
|
||||||
|
|
||||||
|
if( mid != null )
|
||||||
|
{
|
||||||
|
aliases.add( mid );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
package decode.tait;
|
package decode.tait;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
@@ -250,4 +252,28 @@ public class Tait1200ANIMessage extends Message
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,11 @@
|
|||||||
package decode.tait;
|
package decode.tait;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
@@ -386,4 +388,28 @@ public class Tait1200GPSMessage extends Message
|
|||||||
return new Plottable( getGPSTime(), getGPSLocation(), getFromID(),
|
return new Plottable( getGPSTime(), getGPSLocation(), getFromID(),
|
||||||
getFromIDAlias() );
|
getFromIDAlias() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
List<Alias> aliases = new ArrayList<Alias>();
|
||||||
|
|
||||||
|
Alias from = getFromIDAlias();
|
||||||
|
|
||||||
|
if( from != null )
|
||||||
|
{
|
||||||
|
aliases.add( from );
|
||||||
|
}
|
||||||
|
|
||||||
|
Alias to = getToIDAlias();
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
aliases.add( to );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,12 @@
|
|||||||
package message;
|
package message;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
|
import alias.Alias;
|
||||||
import controller.activity.MessageDetailsProvider;
|
import controller.activity.MessageDetailsProvider;
|
||||||
|
|
||||||
public abstract class Message implements MessageDetailsProvider
|
public abstract class Message implements MessageDetailsProvider
|
||||||
@@ -59,5 +62,12 @@ public abstract class Message implements MessageDetailsProvider
|
|||||||
{
|
{
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a listing of aliases contained in the message.
|
||||||
|
*/
|
||||||
|
public List<Alias> getAliases()
|
||||||
|
{
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user