mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 18:47:33 -05:00
wip #34 - resolved various issues with alias controller and editors.
Added synchronized method to channel processing manager to ensure that we don't have contention during channel changes.
This commit is contained in:
@@ -9,6 +9,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
@@ -177,8 +178,14 @@ public class AliasController extends JPanel
|
|||||||
if( !event.getValueIsAdjusting() )
|
if( !event.getValueIsAdjusting() )
|
||||||
{
|
{
|
||||||
int[] selectedRows = mAliasTable.getSelectedRows();
|
int[] selectedRows = mAliasTable.getSelectedRows();
|
||||||
|
|
||||||
if( selectedRows.length <= 1 )
|
if( selectedRows.length == 0 )
|
||||||
|
{
|
||||||
|
mAliasEditor.setItem( null );
|
||||||
|
mCopyButton.setEnabled( false );
|
||||||
|
mDeleteButton.setEnabled( false );
|
||||||
|
}
|
||||||
|
else if( selectedRows.length == 1 )
|
||||||
{
|
{
|
||||||
setEditor( mAliasEditor );
|
setEditor( mAliasEditor );
|
||||||
|
|
||||||
@@ -244,17 +251,26 @@ public class AliasController extends JPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Alias getSelectedAlias()
|
private List<Alias> getSelectedAliases()
|
||||||
{
|
{
|
||||||
int index = mAliasTable.getSelectedRow();
|
List<Alias> selected = new ArrayList<>();
|
||||||
|
|
||||||
if( index >= 0 )
|
int[] rows = mAliasTable.getSelectedRows();
|
||||||
|
|
||||||
|
for( int row: rows )
|
||||||
{
|
{
|
||||||
return mAliasModel.getAliasAtIndex(
|
if( row >= 0 )
|
||||||
mAliasTable.convertRowIndexToModel( index ) );
|
{
|
||||||
|
Alias alias = mAliasModel.getAliasAtIndex( mAliasTable.convertRowIndexToModel( row ) );
|
||||||
|
|
||||||
|
if( alias != null )
|
||||||
|
{
|
||||||
|
selected.add( alias );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,25 +285,29 @@ public class AliasController extends JPanel
|
|||||||
addAlias( new Alias( "New Alias" ) );
|
addAlias( new Alias( "New Alias" ) );
|
||||||
break;
|
break;
|
||||||
case COPY_ALIAS:
|
case COPY_ALIAS:
|
||||||
Alias selected = getSelectedAlias();
|
for( Alias alias: getSelectedAliases() )
|
||||||
|
|
||||||
if( selected != null )
|
|
||||||
{
|
{
|
||||||
addAlias( AliasFactory.copyOf( selected ) );
|
addAlias( AliasFactory.copyOf( alias ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DELETE_ALIAS:
|
case DELETE_ALIAS:
|
||||||
Alias toDelete = getSelectedAlias();
|
List<Alias> toDelete = getSelectedAliases();
|
||||||
|
|
||||||
if( toDelete != null )
|
if( toDelete != null && !toDelete.isEmpty() )
|
||||||
{
|
{
|
||||||
|
String title = toDelete.size() == 1 ? "Delete Alias?" : "Delete Aliases?";
|
||||||
|
String prompt = toDelete.size() == 1 ? "Do you want to delete this alias?" :
|
||||||
|
"Do you want to delete these " + toDelete.size() + " aliases?";
|
||||||
|
|
||||||
int choice = JOptionPane.showConfirmDialog( AliasController.this,
|
int choice = JOptionPane.showConfirmDialog( AliasController.this,
|
||||||
"Do you want to delete this alias?", "Delete Alias?",
|
prompt, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
||||||
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
|
||||||
|
|
||||||
if( choice == JOptionPane.YES_OPTION )
|
if( choice == JOptionPane.YES_OPTION )
|
||||||
{
|
{
|
||||||
mAliasModel.removeAlias( toDelete );
|
for( Alias alias: toDelete )
|
||||||
|
{
|
||||||
|
mAliasModel.removeAlias( alias );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -255,6 +255,8 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
mButtonColor.setForeground( getForeground() );
|
mButtonColor.setForeground( getForeground() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
|
||||||
setModified( false );
|
setModified( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,21 +261,25 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
groupNames.add( 0, "" );
|
groupNames.add( 0, "" );
|
||||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||||
groupNames.toArray( new String[ groupNames.size() ] ) ) );
|
groupNames.toArray( new String[ groupNames.size() ] ) ) );
|
||||||
|
|
||||||
|
setCheckBoxesUnselected();
|
||||||
|
|
||||||
setModified( false );
|
setModified( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setCheckBoxesUnselected()
|
||||||
public void reset()
|
|
||||||
{
|
{
|
||||||
//Reset multi-editor controls
|
|
||||||
mListCheckBox.setSelected( false );
|
mListCheckBox.setSelected( false );
|
||||||
mGroupCheckBox.setSelected( false );
|
mGroupCheckBox.setSelected( false );
|
||||||
mColorCheckBox.setSelected( false );
|
mColorCheckBox.setSelected( false );
|
||||||
mIconCheckBox.setSelected( false );
|
mIconCheckBox.setSelected( false );
|
||||||
mRecordCheckBox.setSelected( false );
|
mRecordCheckBox.setSelected( false );
|
||||||
mPriorityCheckBox.setSelected( false );
|
mPriorityCheckBox.setSelected( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
List<String> listNames = mAliasModel.getListNames();
|
List<String> listNames = mAliasModel.getListNames();
|
||||||
listNames.add( 0, "" );
|
listNames.add( 0, "" );
|
||||||
mListCombo.setModel( new DefaultComboBoxModel<String>(
|
mListCombo.setModel( new DefaultComboBoxModel<String>(
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -33,7 +32,6 @@ import module.log.EventLogManager;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
|
||||||
import record.RecorderManager;
|
import record.RecorderManager;
|
||||||
import record.RecorderType;
|
import record.RecorderType;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
@@ -44,7 +42,6 @@ import alias.AliasModel;
|
|||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.metadata.Metadata;
|
import audio.metadata.Metadata;
|
||||||
import audio.metadata.MetadataType;
|
import audio.metadata.MetadataType;
|
||||||
import controller.ThreadPoolManager;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
import controller.channel.map.ChannelMapModel;
|
import controller.channel.map.ChannelMapModel;
|
||||||
@@ -65,15 +62,13 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
private EventLogManager mEventLogManager;
|
private EventLogManager mEventLogManager;
|
||||||
private RecorderManager mRecorderManager;
|
private RecorderManager mRecorderManager;
|
||||||
private SourceManager mSourceManager;
|
private SourceManager mSourceManager;
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
|
||||||
|
|
||||||
public ChannelProcessingManager( ChannelModel channelModel,
|
public ChannelProcessingManager( ChannelModel channelModel,
|
||||||
ChannelMapModel channelMapModel,
|
ChannelMapModel channelMapModel,
|
||||||
AliasModel aliasModel,
|
AliasModel aliasModel,
|
||||||
EventLogManager eventLogManager,
|
EventLogManager eventLogManager,
|
||||||
RecorderManager recorderManager,
|
RecorderManager recorderManager,
|
||||||
SourceManager sourceManager,
|
SourceManager sourceManager )
|
||||||
ThreadPoolManager threadPoolManager )
|
|
||||||
{
|
{
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
mChannelMapModel = channelMapModel;
|
mChannelMapModel = channelMapModel;
|
||||||
@@ -81,7 +76,6 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
mEventLogManager = eventLogManager;
|
mEventLogManager = eventLogManager;
|
||||||
mRecorderManager = recorderManager;
|
mRecorderManager = recorderManager;
|
||||||
mSourceManager = sourceManager;
|
mSourceManager = sourceManager;
|
||||||
mThreadPoolManager = threadPoolManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +102,7 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelChanged( ChannelEvent event )
|
public synchronized void channelChanged( ChannelEvent event )
|
||||||
{
|
{
|
||||||
Channel channel = event.getChannel();
|
Channel channel = event.getChannel();
|
||||||
|
|
||||||
|
|||||||
@@ -136,10 +136,8 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
SourceManager sourceManager = new SourceManager( tunerModel,
|
SourceManager sourceManager = new SourceManager( tunerModel,
|
||||||
mSettingsManager, threadPoolManager );
|
mSettingsManager, threadPoolManager );
|
||||||
|
|
||||||
ChannelProcessingManager channelProcessingManager =
|
ChannelProcessingManager channelProcessingManager = new ChannelProcessingManager(
|
||||||
new ChannelProcessingManager( channelModel, channelMapModel,
|
channelModel, channelMapModel, aliasModel, eventLogManager, recorderManager, sourceManager );
|
||||||
aliasModel, eventLogManager, recorderManager,
|
|
||||||
sourceManager, threadPoolManager );
|
|
||||||
channelProcessingManager.addAudioPacketListener( recorderManager );
|
channelProcessingManager.addAudioPacketListener( recorderManager );
|
||||||
|
|
||||||
channelModel.addListener( channelProcessingManager );
|
channelModel.addListener( channelProcessingManager );
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class DecoderViewFrame extends JInternalFrame
|
|||||||
|
|
||||||
ChannelProcessingManager channelProcessingManager =
|
ChannelProcessingManager channelProcessingManager =
|
||||||
new ChannelProcessingManager( channelModel, channelMapModel,
|
new ChannelProcessingManager( channelModel, channelMapModel,
|
||||||
new AliasModel(), new EventLogManager(), null, null, new ThreadPoolManager() );
|
new AliasModel(), new EventLogManager(), null, null );
|
||||||
|
|
||||||
List<Module> modules = DecoderFactory.getModules( channelModel,
|
List<Module> modules = DecoderFactory.getModules( channelModel,
|
||||||
channelMapModel, channelProcessingManager, new AliasModel(), channel );
|
channelMapModel, channelProcessingManager, new AliasModel(), channel );
|
||||||
|
|||||||
Reference in New Issue
Block a user