mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
Resolves #154 - add right-click contextual channel menus for Now Playing table.
Also disables right-click channel activation from the spectral display as a clean-up action.
This commit is contained in:
@@ -22,9 +22,12 @@ import alias.Alias;
|
|||||||
import channel.state.State;
|
import channel.state.State;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.ChannelProcessingManager;
|
import controller.channel.ChannelProcessingManager;
|
||||||
|
import controller.channel.ChannelUtils;
|
||||||
import icon.IconManager;
|
import icon.IconManager;
|
||||||
import module.ProcessingChain;
|
import module.ProcessingChain;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import properties.SystemProperties;
|
import properties.SystemProperties;
|
||||||
import sample.Broadcaster;
|
import sample.Broadcaster;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
@@ -34,9 +37,13 @@ import javax.swing.event.ListSelectionEvent;
|
|||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
public class ChannelMetadataPanel extends JPanel implements ListSelectionListener
|
public class ChannelMetadataPanel extends JPanel implements ListSelectionListener
|
||||||
{
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(ChannelMetadataPanel.class);
|
||||||
|
|
||||||
private static final String PROPERTY_PREFIX_BACKGROUND = "channel.metadata.panel.state.color.";
|
private static final String PROPERTY_PREFIX_BACKGROUND = "channel.metadata.panel.state.color.";
|
||||||
private static final String PROPERTY_PREFIX_FOREGROUND = "channel.metadata.panel.text.color.";
|
private static final String PROPERTY_PREFIX_FOREGROUND = "channel.metadata.panel.text.color.";
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
private ChannelProcessingManager mChannelProcessingManager;
|
||||||
@@ -68,6 +75,7 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
|||||||
renderer.setHorizontalAlignment(SwingConstants.CENTER);
|
renderer.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
mTable.getSelectionModel().addListSelectionListener(this);
|
mTable.getSelectionModel().addListSelectionListener(this);
|
||||||
|
mTable.addMouseListener(new MouseSupport());
|
||||||
|
|
||||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_STATE)
|
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_STATE)
|
||||||
.setCellRenderer(new ColoredStateCellRenderer());
|
.setCellRenderer(new ColoredStateCellRenderer());
|
||||||
@@ -223,4 +231,52 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MouseSupport extends MouseAdapter
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e)
|
||||||
|
{
|
||||||
|
if(e.getButton() == MouseEvent.BUTTON3) //Right click for context
|
||||||
|
{
|
||||||
|
JPopupMenu popupMenu = new JPopupMenu();
|
||||||
|
|
||||||
|
boolean populated = false;
|
||||||
|
|
||||||
|
int viewRowIndex = mTable.rowAtPoint(e.getPoint());
|
||||||
|
|
||||||
|
if(viewRowIndex >= 0)
|
||||||
|
{
|
||||||
|
int modelRowIndex = mTable.convertRowIndexToModel(viewRowIndex);
|
||||||
|
|
||||||
|
if(modelRowIndex >= 0)
|
||||||
|
{
|
||||||
|
Metadata metadata = mChannelProcessingManager.getChannelMetadataModel().getMetadata(modelRowIndex);
|
||||||
|
|
||||||
|
if(metadata != null)
|
||||||
|
{
|
||||||
|
Channel channel = mChannelProcessingManager.getChannelMetadataModel()
|
||||||
|
.getChannelFromMetadata(metadata);
|
||||||
|
|
||||||
|
if(channel != null)
|
||||||
|
{
|
||||||
|
popupMenu.add(ChannelUtils.getContextMenu(mChannelProcessingManager.getChannelModel(),
|
||||||
|
mChannelProcessingManager, channel, mTable));
|
||||||
|
|
||||||
|
populated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!populated)
|
||||||
|
{
|
||||||
|
popupMenu.add(new JMenuItem("No Actions Available"));
|
||||||
|
}
|
||||||
|
|
||||||
|
popupMenu.show(mTable, e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,14 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
return mChannelMetadataModel;
|
return mChannelMetadataModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel model
|
||||||
|
*/
|
||||||
|
public ChannelModel getChannelModel()
|
||||||
|
{
|
||||||
|
return mChannelModel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if a processing chain is constructed for the channel and that
|
* Indicates if a processing chain is constructed for the channel and that
|
||||||
* the processing chain is currently processing.
|
* the processing chain is currently processing.
|
||||||
|
|||||||
@@ -636,21 +636,21 @@ public class SpectralDisplayPanel extends JPanel implements Listener<ComplexBuff
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JMenu frequencyMenu = new JMenu(
|
// JMenu frequencyMenu = new JMenu(
|
||||||
sCURSOR_FORMAT.format((float) frequency / 1000000.0f));
|
// sCURSOR_FORMAT.format((float) frequency / 1000000.0f));
|
||||||
|
//
|
||||||
JMenu decoderMenu = new JMenu("Add Decoder");
|
// JMenu decoderMenu = new JMenu("Add Decoder");
|
||||||
|
//
|
||||||
for(DecoderType type : DecoderType.getPrimaryDecoders())
|
// for(DecoderType type : DecoderType.getPrimaryDecoders())
|
||||||
{
|
// {
|
||||||
decoderMenu.add(new DecoderItem(type, frequency));
|
// decoderMenu.add(new DecoderItem(type, frequency));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
frequencyMenu.add(decoderMenu);
|
// frequencyMenu.add(decoderMenu);
|
||||||
|
//
|
||||||
contextMenu.add(frequencyMenu);
|
// contextMenu.add(frequencyMenu);
|
||||||
|
//
|
||||||
contextMenu.add(new JSeparator());
|
// contextMenu.add(new JSeparator());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color Menus
|
* Color Menus
|
||||||
|
|||||||
Reference in New Issue
Block a user