mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Updates pull request from Roman Tsypuk to convert the build system from
ant to gradle. Removes linux and windows application launch scripts and produces an executable jar with all resources included.
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package io.github.dsheirer.controller.channel;
|
||||
|
||||
import io.github.dsheirer.channel.state.DecoderState;
|
||||
import io.github.dsheirer.module.ProcessingChain;
|
||||
import io.github.dsheirer.module.decode.event.ActivitySummaryFrame;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelUtils
|
||||
{
|
||||
/**
|
||||
* Creates a context menu for the channel argument
|
||||
*/
|
||||
public static JMenu getContextMenu( final ChannelModel channelModel,
|
||||
final ChannelProcessingManager channelProcessingManager,
|
||||
final Channel channel,
|
||||
final Component anchor )
|
||||
{
|
||||
if( channel != null )
|
||||
{
|
||||
JMenu menu = new JMenu( "Channel: " + channel.getName() );
|
||||
|
||||
if( channel.getEnabled() )
|
||||
{
|
||||
JMenuItem disable = new JMenuItem( "Disable" );
|
||||
disable.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
channelModel.broadcast(
|
||||
new ChannelEvent( channel, ChannelEvent.Event.REQUEST_DISABLE ) );
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( disable );
|
||||
|
||||
menu.add( new JSeparator() );
|
||||
|
||||
JMenuItem actySummaryItem =
|
||||
new JMenuItem( "Activity Summary" );
|
||||
|
||||
actySummaryItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
ProcessingChain chain = channelProcessingManager.getProcessingChain( channel );
|
||||
|
||||
if( chain != null )
|
||||
{
|
||||
for( DecoderState decoderState: chain.getDecoderStates() )
|
||||
{
|
||||
sb.append( decoderState.getActivitySummary() );
|
||||
}
|
||||
}
|
||||
|
||||
new ActivitySummaryFrame( sb.toString(), anchor );
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( actySummaryItem );
|
||||
}
|
||||
else
|
||||
{
|
||||
JMenuItem enable = new JMenuItem( "Enable" );
|
||||
enable.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
channelModel.broadcast(
|
||||
new ChannelEvent( channel, ChannelEvent.Event.REQUEST_ENABLE ) );
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( enable );
|
||||
}
|
||||
|
||||
menu.add( new JSeparator() );
|
||||
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int response = JOptionPane.showConfirmDialog( anchor,
|
||||
"Do you want to delete channel " + channel.getName() + "?",
|
||||
"Are you sure?", JOptionPane.YES_NO_CANCEL_OPTION );
|
||||
|
||||
if( response == JOptionPane.YES_OPTION )
|
||||
{
|
||||
channelModel.broadcast(
|
||||
new ChannelEvent( channel, ChannelEvent.Event.REQUEST_DELETE ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
menu.add( deleteItem );
|
||||
|
||||
return menu;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user