Adds call blacklisting (do not monitor) to aliases.

This commit is contained in:
denny
2015-09-12 10:59:31 -04:00
parent f354c73109
commit 82ce3c668a
22 changed files with 400 additions and 178 deletions

View File

@@ -169,6 +169,19 @@ public class Alias
return Priority.DEFAULT_PRIORITY;
}
public boolean hasPriority()
{
for( AliasID id: mAliasIDs )
{
if( id.getType() == AliasIDType.Priority )
{
return true;
}
}
return false;
}
/**
* Inspects the alias for a non-recordable alias id. Default is true;
*/

View File

@@ -52,6 +52,8 @@ 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;
@@ -127,6 +129,10 @@ public class AliasNode extends ConfigurableNode
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() );
@@ -283,27 +289,6 @@ public class AliasNode extends ConfigurableNode
} );
addIDMenu.add( addMPTItem );
JMenuItem nonRecordableItem = new JMenuItem( "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();
}
} );
addIDMenu.add( nonRecordableItem );
JMenuItem addSiteItem = new JMenuItem( "Site" );
addSiteItem.addActionListener( new ActionListener()
{
@@ -465,7 +450,62 @@ public class AliasNode extends ConfigurableNode
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()
{

View File

@@ -27,16 +27,26 @@ import alias.AliasIDType;
*/
public class Priority extends AliasID
{
public static final int DO_NOT_MONITOR = -1;
public static final int SELECTED_PRIORITY = 0;
public static final int MIN_PRIORITY = 1;
public static final int MAX_PRIORITY = 100;
public static final int DEFAULT_PRIORITY = 100;
private int mPriority;
private int mPriority = DEFAULT_PRIORITY;
public Priority()
{
}
/**
* Indicates the associated alias should not be monitored or tracked.
*/
public boolean isDoNotMonitor()
{
return mPriority == DO_NOT_MONITOR;
}
@XmlAttribute
public int getPriority()
{
@@ -50,7 +60,7 @@ public class Priority extends AliasID
public String toString()
{
return "Priority: " + mPriority;
return "Priority: " + ( isDoNotMonitor() ? "Do Not Monitor" : mPriority );
}
@Override

View File

@@ -21,6 +21,7 @@ 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;
@@ -28,14 +29,24 @@ import javax.swing.JTextArea;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import module.decode.config.DecodeConfiguration;
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;
@@ -52,11 +63,37 @@ public class PriorityEditor extends JPanel implements ActionListener
add( new JLabel( "Priority" ), "span,align center" );
mPrioritySlider = new JSlider( JSlider.HORIZONTAL,
Priority.MIN_PRIORITY,
Priority.MAX_PRIORITY,
Priority.DEFAULT_PRIORITY );
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 );
@@ -75,14 +112,20 @@ public class PriorityEditor extends JPanel implements ActionListener
}
} );
if( doNotMonitor )
{
mPrioritySlider.setEnabled( false );
mPrioritySliderLabel.setEnabled( false );
}
add( mPrioritySliderLabel );
add( mPrioritySlider, "wrap,grow" );
JButton btnSave = new JButton( "Save" );
JButton btnSave = new JButton( SAVE );
btnSave.addActionListener( PriorityEditor.this );
add( btnSave, "growx,push" );
JButton btnReset = new JButton( "Reset" );
JButton btnReset = new JButton( RESET );
btnReset.addActionListener( PriorityEditor.this );
add( btnReset, "growx,push" );
@@ -103,9 +146,16 @@ public class PriorityEditor extends JPanel implements ActionListener
{
String command = e.getActionCommand();
if( command.contentEquals( "Save" ) )
if( command.contentEquals( SAVE ) )
{
mPriorityNode.getPriority().setPriority( mPrioritySlider.getValue() );
if( mDoNotMonitorCheckBox.isSelected() )
{
mPriorityNode.getPriority().setPriority( Priority.DO_NOT_MONITOR );
}
else
{
mPriorityNode.getPriority().setPriority( mPrioritySlider.getValue() );
}
((ConfigurableNode)mPriorityNode.getParent()).sort();
@@ -113,10 +163,28 @@ public class PriorityEditor extends JPanel implements ActionListener
mPriorityNode.show();
}
else if( command.contentEquals( "Reset" ) )
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();
}

View File

@@ -50,7 +50,7 @@ public class PriorityNode extends AliasIDNode
public String toString()
{
return "Priority: " + getPriority().getPriority();
return getPriority().toString();
}
public JPopupMenu getContextMenu()

View File

@@ -43,7 +43,7 @@ public class NonRecordableEditor extends JPanel implements ActionListener
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." );
+ " this alias is a participant in the call will not be recorded." );
description.setLineWrap( true );
description.setBackground( getBackground() );

View File

@@ -47,7 +47,7 @@ public class NonRecordableNode extends AliasIDNode
@Override
public String getIconPath()
{
return "images/non_recordable.png";
return "images/no_record.png";
}
public String toString()