mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#961 Resolves issue where invoking channel actions from Swing thread causes error on JavaFX GUI thread. Removes the Start/Disable/Delete commands from the Swing menu options and replaces with a single View/Edit call to the JavaFX channel editor. Although this reduces ease/functionality, it sidesteps code complications until the main GUI can be recreated in JavaFX. (#964)
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +126,6 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
||||
mChannelID = UNIQUE_ID++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a (new) deep copy of this channel
|
||||
*/
|
||||
@@ -183,6 +181,69 @@ public class Channel extends Configuration implements Listener<SourceEvent>
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<ReusableCom
|
||||
|
||||
if(event.getComponent() == mOverlayPanel)
|
||||
{
|
||||
ArrayList<Channel> channels =
|
||||
mOverlayPanel.getChannelsAtFrequency(frequency);
|
||||
ArrayList<Channel> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user