diff --git a/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataPanel.java b/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataPanel.java index 661739d4..e89b4042 100644 --- a/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataPanel.java +++ b/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataPanel.java @@ -25,7 +25,8 @@ import io.github.dsheirer.channel.state.State; import io.github.dsheirer.controller.channel.Channel; import io.github.dsheirer.controller.channel.ChannelModel; import io.github.dsheirer.controller.channel.ChannelProcessingManager; -import io.github.dsheirer.controller.channel.ChannelUtils; +import io.github.dsheirer.eventbus.MyEventBus; +import io.github.dsheirer.gui.playlist.channel.ViewChannelRequest; import io.github.dsheirer.icon.IconModel; import io.github.dsheirer.identifier.Identifier; import io.github.dsheirer.identifier.configuration.FrequencyConfigurationIdentifier; @@ -412,11 +413,12 @@ public class ChannelMetadataPanel extends JPanel implements ListSelectionListene if(channel != null) { - popupMenu.add(ChannelUtils.getContextMenu(mChannelModel, mChannelProcessingManager, channel, mTable)); + JMenuItem viewChannel = new JMenuItem("View/Edit: " + channel.getShortTitle()); + viewChannel.addActionListener(e2 -> MyEventBus.getGlobalEventBus().post(new ViewChannelRequest(channel))); + popupMenu.add(viewChannel); populated = true; } } - } } diff --git a/src/main/java/io/github/dsheirer/controller/channel/Channel.java b/src/main/java/io/github/dsheirer/controller/channel/Channel.java index fb54c1e7..31dc9a96 100644 --- a/src/main/java/io/github/dsheirer/controller/channel/Channel.java +++ b/src/main/java/io/github/dsheirer/controller/channel/Channel.java @@ -126,8 +126,6 @@ public class Channel extends Configuration implements Listener mChannelID = UNIQUE_ID++; } - - /** * Creates a (new) deep copy of this channel */ @@ -183,6 +181,69 @@ public class Channel extends Configuration implements Listener return channel; } + /** + * Creates a short title containing the system, site and channel name where each value is constrained to + * ten characters each. + * @return short title + */ + public String getShortTitle() + { + StringBuilder sb = new StringBuilder(); + + if(getSystem() != null) + { + if(getSystem().length() > 10) + { + sb.append(getSystem().substring(0, 10)).append(".."); + } + else + { + sb.append(getSystem()); + } + } + else + { + sb.append("No System"); + } + + sb.append("/"); + + if(getSite() != null) + { + if(getSite().length() > 10) + { + sb.append(getSite().substring(0, 10)).append(".."); + } + else + { + sb.append(getSite()); + } + } + else + { + sb.append("No Site"); + } + sb.append("/"); + + if(getName() != null) + { + if(getName().length() > 10) + { + sb.append(getName().substring(0, 10)).append(".."); + } + else + { + sb.append(getName()); + } + } + else + { + sb.append("No Channel"); + } + + return sb.toString(); + } + /** * Updates the frequencies property as the source configuration changes or is initialized. */ diff --git a/src/main/java/io/github/dsheirer/controller/channel/ChannelUtils.java b/src/main/java/io/github/dsheirer/controller/channel/ChannelUtils.java deleted file mode 100644 index 5cc173d3..00000000 --- a/src/main/java/io/github/dsheirer/controller/channel/ChannelUtils.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * ****************************************************************************** - * sdrtrunk - * Copyright (C) 2014-2018 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 - * ***************************************************************************** - */ - -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.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JSeparator; -import java.awt.Component; -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.isProcessing()) - { - JMenuItem disable = new JMenuItem("Disable"); - disable.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - channelProcessingManager.receive(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) - { - channelProcessingManager.receive(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.receive(new ChannelEvent(channel, ChannelEvent.Event.REQUEST_DELETE)); - } - } - }); - - menu.add(deleteItem); - - return menu; - - } - - return null; - } - -} diff --git a/src/main/java/io/github/dsheirer/spectrum/SpectralDisplayPanel.java b/src/main/java/io/github/dsheirer/spectrum/SpectralDisplayPanel.java index 3e635a8c..4e3d9a6c 100644 --- a/src/main/java/io/github/dsheirer/spectrum/SpectralDisplayPanel.java +++ b/src/main/java/io/github/dsheirer/spectrum/SpectralDisplayPanel.java @@ -25,9 +25,10 @@ import com.jidesoft.swing.JideSplitPane; import io.github.dsheirer.controller.channel.Channel; import io.github.dsheirer.controller.channel.ChannelModel; import io.github.dsheirer.controller.channel.ChannelProcessingManager; -import io.github.dsheirer.controller.channel.ChannelUtils; import io.github.dsheirer.dsp.filter.Window.WindowType; import io.github.dsheirer.dsp.filter.smoothing.SmoothingFilter.SmoothingType; +import io.github.dsheirer.eventbus.MyEventBus; +import io.github.dsheirer.gui.playlist.channel.ViewChannelRequest; import io.github.dsheirer.playlist.PlaylistManager; import io.github.dsheirer.properties.SystemProperties; import io.github.dsheirer.sample.Listener; @@ -635,26 +636,22 @@ public class SpectralDisplayPanel extends JPanel implements Listener channels = - mOverlayPanel.getChannelsAtFrequency(frequency); + ArrayList channels = mOverlayPanel.getChannelsAtFrequency(frequency); + JMenu channelMenu = new JMenu("Channels"); for(Channel channel : channels) { - JMenu channelMenu = ChannelUtils.getContextMenu(mChannelModel, - mChannelProcessingManager, channel, - SpectralDisplayPanel.this); - - if(channelMenu != null) - { - contextMenu.add(channelMenu); - } + JMenuItem viewChannel = new JMenuItem("View/Edit: " + channel.getShortTitle()); + viewChannel.addActionListener(e -> MyEventBus.getGlobalEventBus().post(new ViewChannelRequest(channel))); + channelMenu.add(viewChannel); } + contextMenu.add(channelMenu); + if(!channels.isEmpty()) { contextMenu.add(new JSeparator()); } - } /**