mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
WIP #34 - new channel map manager/editor is complete. Channel map
manager is now a separate window launched from the decoder tab, specifically the MPT1327 decoder tab.
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
package controller.channel.map;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
@@ -16,30 +23,111 @@ public class ChannelMapManager extends JPanel
|
||||
private ChannelMapModel mChannelMapModel;
|
||||
private JList<ChannelMap> mChannelMapList;
|
||||
private ChannelMapEditor mChannelMapEditor;
|
||||
private JButton mDeleteMapButton;
|
||||
private JButton mCloneMapButton;
|
||||
|
||||
public ChannelMapManager( ChannelMapModel channelMapModel )
|
||||
{
|
||||
mChannelMapModel = channelMapModel;
|
||||
mChannelMapList = new JList( mChannelMapModel );
|
||||
mChannelMapEditor = new ChannelMapEditor();
|
||||
mChannelMapList = new JList<>( mChannelMapModel );
|
||||
mChannelMapEditor = new ChannelMapEditor( mChannelMapModel );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[fill,grow]", "[fill,grow]" ) );
|
||||
setLayout( new MigLayout( "insets 1 1 1 1", "[fill,grow]", "[fill,grow]" ) );
|
||||
|
||||
JPanel listPanel = new JPanel();
|
||||
listPanel.setLayout( new MigLayout( "",
|
||||
"[fill,grow][fill,grow][fill,grow]", "[fill,grow][]" ) );
|
||||
|
||||
mChannelMapList.addListSelectionListener( mChannelMapEditor );
|
||||
mChannelMapList.addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent e )
|
||||
{
|
||||
if( mChannelMapList.getSelectedValue() != null )
|
||||
{
|
||||
mCloneMapButton.setEnabled( true );
|
||||
mDeleteMapButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCloneMapButton.setEnabled( false );
|
||||
mDeleteMapButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
} );
|
||||
mChannelMapList.setLayoutOrientation( JList.VERTICAL );
|
||||
mChannelMapList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
|
||||
JScrollPane listScroller = new JScrollPane( mChannelMapList );
|
||||
|
||||
listPanel.add( listScroller, "span" );
|
||||
|
||||
JButton newMapButton = new JButton( "New" );
|
||||
newMapButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ChannelMap channelMap = new ChannelMap( "New Channel Map" );
|
||||
mChannelMapModel.addChannelMap( channelMap );
|
||||
mChannelMapList.setSelectedValue( channelMap, true );
|
||||
}
|
||||
} );
|
||||
|
||||
listPanel.add( newMapButton );
|
||||
|
||||
mCloneMapButton = new JButton( "Clone" );
|
||||
mCloneMapButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ChannelMap selected = mChannelMapList.getSelectedValue();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
ChannelMap copy = selected.copyOf();
|
||||
mChannelMapModel.addChannelMap( copy );
|
||||
mChannelMapList.setSelectedValue( copy, true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
listPanel.add( mCloneMapButton );
|
||||
|
||||
mDeleteMapButton = new JButton( "Delete" );
|
||||
mDeleteMapButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
ChannelMap channelMap = mChannelMapList.getSelectedValue();
|
||||
|
||||
if( channelMap != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( mChannelMapList,
|
||||
"Do you want to delete this channel map?",
|
||||
"Delete Channel Map?", JOptionPane.YES_NO_OPTION );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mChannelMapModel.removeChannelMap( channelMap );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
listPanel.add( mDeleteMapButton );
|
||||
|
||||
JScrollPane editorScroller = new JScrollPane( mChannelMapEditor );
|
||||
|
||||
JideSplitPane splitPane = new JideSplitPane();
|
||||
splitPane.setOrientation( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
splitPane.add( listScroller );
|
||||
splitPane.add( listPanel );
|
||||
splitPane.add( editorScroller );
|
||||
|
||||
add( splitPane );
|
||||
|
||||
Reference in New Issue
Block a user