mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
Restores context menus for channels in configuration window, channel
processing window, and spectral display window.
This commit is contained in:
@@ -20,6 +20,7 @@ package controller.channel;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
|
|
||||||
@@ -155,8 +156,16 @@ public class ChannelNode extends ConfigurableNode implements ChannelEventListene
|
|||||||
|
|
||||||
public JPopupMenu getContextMenu()
|
public JPopupMenu getContextMenu()
|
||||||
{
|
{
|
||||||
JPopupMenu popupMenu = new JPopupMenu( "Channel Menu" );
|
JPopupMenu popupMenu = new JPopupMenu();
|
||||||
// popupMenu.add( getChannel().getContextMenu() );
|
|
||||||
|
JMenu channelMenu = ChannelUtils.getContextMenu(
|
||||||
|
getModel().getResourceManager().getPlaylistManager(),
|
||||||
|
getChannel(), getModel().getTree() );
|
||||||
|
|
||||||
|
if( channelMenu != null )
|
||||||
|
{
|
||||||
|
popupMenu.add( channelMenu );
|
||||||
|
}
|
||||||
|
|
||||||
return popupMenu;
|
return popupMenu;
|
||||||
}
|
}
|
||||||
|
|||||||
126
src/controller/channel/ChannelUtils.java
Normal file
126
src/controller/channel/ChannelUtils.java
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
package controller.channel;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
|
import module.decode.event.ActivitySummaryFrame;
|
||||||
|
import module.decode.state.DecoderState;
|
||||||
|
import playlist.PlaylistManager;
|
||||||
|
import controller.channel.ChannelEvent.Event;
|
||||||
|
|
||||||
|
public class ChannelUtils
|
||||||
|
{
|
||||||
|
private static final boolean ENABLED = true;
|
||||||
|
private static final boolean DISABLED = false;
|
||||||
|
private static final boolean BROADCAST_CHANGE = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a context menu for the channel argument
|
||||||
|
*/
|
||||||
|
public static JMenu getContextMenu( final PlaylistManager playlistManager,
|
||||||
|
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 )
|
||||||
|
{
|
||||||
|
channel.setEnabled( DISABLED, BROADCAST_CHANGE );
|
||||||
|
|
||||||
|
if( playlistManager != null )
|
||||||
|
{
|
||||||
|
playlistManager.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
for( DecoderState decoderState: channel
|
||||||
|
.getProcessingChain().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 )
|
||||||
|
{
|
||||||
|
channel.setEnabled( ENABLED, BROADCAST_CHANGE );
|
||||||
|
|
||||||
|
if( playlistManager != null )
|
||||||
|
{
|
||||||
|
playlistManager.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
menu.add( enable );
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.add( new JSeparator() );
|
||||||
|
|
||||||
|
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
||||||
|
deleteItem.addActionListener( new ActionListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e )
|
||||||
|
{
|
||||||
|
/* Disable the channel */
|
||||||
|
channel.setEnabled( DISABLED, BROADCAST_CHANGE );
|
||||||
|
|
||||||
|
/* Broadcast channel deleted event */
|
||||||
|
channel.fireChannelEvent( Event.CHANNEL_DELETED );
|
||||||
|
|
||||||
|
if( playlistManager != null )
|
||||||
|
{
|
||||||
|
playlistManager.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
menu.add( deleteItem );
|
||||||
|
|
||||||
|
return menu;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -592,7 +592,19 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.IDLE ) );
|
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.IDLE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the talkgroup is different than the talkgroup specified in
|
||||||
|
* the current call event
|
||||||
|
*/
|
||||||
|
private boolean isDifferentTalkgroup( String talkgroup )
|
||||||
|
{
|
||||||
|
return talkgroup != null &&
|
||||||
|
mCurrentCallEvent != null &&
|
||||||
|
mCurrentCallEvent.getToID() != null &&
|
||||||
|
!mCurrentCallEvent.getToID().contentEquals( talkgroup );
|
||||||
|
}
|
||||||
|
|
||||||
private void processCallMessage( LTRNetMessage message )
|
private void processCallMessage( LTRNetMessage message )
|
||||||
{
|
{
|
||||||
int group = message.getGroup();
|
int group = message.getGroup();
|
||||||
@@ -609,11 +621,11 @@ public class LTRNetDecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
String talkgroup = message.getTalkgroupID();
|
String talkgroup = message.getTalkgroupID();
|
||||||
|
|
||||||
LTRCallEvent current = getCurrentLTRCallEvent();
|
final LTRCallEvent current = getCurrentLTRCallEvent();
|
||||||
|
|
||||||
/* If this is a new call or the talkgroup is different from the current
|
/* If this is a new call or the talkgroup is different from the current
|
||||||
* call, create a new call event */
|
* call, create a new call event */
|
||||||
if( current == null || !current.getToID().contentEquals( talkgroup ) )
|
if( current == null || isDifferentTalkgroup( talkgroup ) )
|
||||||
{
|
{
|
||||||
/* Invalidate the current call */
|
/* Invalidate the current call */
|
||||||
if( current != null )
|
if( current != null )
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014,2015 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import java.util.List;
|
|||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
@@ -142,9 +143,4 @@ public class ChannelCollectionPanel extends JPanel
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTrafficChannel( Channel channel )
|
|
||||||
{
|
|
||||||
//TODO: add logic to handle traffic channels.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import settings.Setting;
|
|||||||
import settings.SettingChangeListener;
|
import settings.SettingChangeListener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
|
import controller.channel.ChannelUtils;
|
||||||
|
|
||||||
public class ChannelStatePanel extends JPanel
|
public class ChannelStatePanel extends JPanel
|
||||||
implements Listener<ChangedAttribute>, SettingChangeListener
|
implements Listener<ChangedAttribute>, SettingChangeListener
|
||||||
@@ -414,90 +415,7 @@ public class ChannelStatePanel extends JPanel
|
|||||||
|
|
||||||
public JMenu getContextMenu()
|
public JMenu getContextMenu()
|
||||||
{
|
{
|
||||||
JMenu menu = new JMenu( "Channel: " + mChannel.getName() );
|
return ChannelUtils.getContextMenu( mPlaylistManager, mChannel,
|
||||||
|
ChannelStatePanel.this );
|
||||||
if( mChannel.getEnabled() )
|
|
||||||
{
|
|
||||||
JMenuItem disable = new JMenuItem( "Disable" );
|
|
||||||
disable.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
mChannel.setEnabled( DISABLED, BROADCAST_CHANGE );
|
|
||||||
|
|
||||||
if( mPlaylistManager != null )
|
|
||||||
{
|
|
||||||
mPlaylistManager.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
for( DecoderState decoderState: mChannel.getProcessingChain().getDecoderStates() )
|
|
||||||
{
|
|
||||||
sb.append( decoderState.getActivitySummary() );
|
|
||||||
}
|
|
||||||
|
|
||||||
new ActivitySummaryFrame( sb.toString(), ChannelStatePanel.this );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
menu.add( actySummaryItem );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
JMenuItem enable = new JMenuItem( "Enable" );
|
|
||||||
enable.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
mChannel.setEnabled( ENABLED, BROADCAST_CHANGE );
|
|
||||||
|
|
||||||
if( mPlaylistManager != null )
|
|
||||||
{
|
|
||||||
mPlaylistManager.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
menu.add( enable );
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.add( new JSeparator() );
|
|
||||||
|
|
||||||
JMenuItem deleteItem = new JMenuItem( "Delete" );
|
|
||||||
deleteItem.addActionListener( new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed( ActionEvent e )
|
|
||||||
{
|
|
||||||
dispose();
|
|
||||||
|
|
||||||
if( mPlaylistManager != null )
|
|
||||||
{
|
|
||||||
mPlaylistManager.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
menu.add( deleteItem );
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ import controller.ResourceManager;
|
|||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
import controller.channel.ChannelEventListener;
|
import controller.channel.ChannelEventListener;
|
||||||
|
import controller.channel.ChannelUtils;
|
||||||
import dsp.filter.Window.WindowType;
|
import dsp.filter.Window.WindowType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -517,15 +518,17 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
ArrayList<Channel> channels =
|
ArrayList<Channel> channels =
|
||||||
mOverlayPanel.getChannelsAtFrequency( frequency );
|
mOverlayPanel.getChannelsAtFrequency( frequency );
|
||||||
|
|
||||||
// for( Channel channel: channels )
|
for( Channel channel: channels )
|
||||||
// {
|
{
|
||||||
// JMenu menu = channel.getContextMenu();
|
JMenu channelMenu = ChannelUtils.getContextMenu(
|
||||||
//
|
mResourceManager.getPlaylistManager(),
|
||||||
// if( menu != null )
|
channel, SpectralDisplayPanel.this );
|
||||||
// {
|
|
||||||
// contextMenu.add( menu );
|
if( channelMenu != null )
|
||||||
// }
|
{
|
||||||
// }
|
contextMenu.add( channelMenu );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !channels.isEmpty() )
|
if( !channels.isEmpty() )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user