mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 00:27:26 -05:00
Identifier Framework and Message/Event Processing Overhaul (#455)
* WIP on new P25 message framer. * WIP on new P25 message framer. * Adds new 1/2 and 3/4 rate trellis decoders. Still trying to chase down why there is a sync pattern mismatch in the NID buffer queue. * WIP - new p25 message framer works correctly now. PDU's are dectected and decoded using the 1/2 and 3/4 rate trellis decoders. Packet Sequences are assembled. Need to add a new packet sequence message factory that can detect Motorola Auto Registration Service (ARS) formatted UDP/ID packets and SNDCP command packets. * WIP - removes nullify on channel results queue. * WIP - updates message framer for TSBK 1/2/3 processing. * WIP removing P25 sync pattern and nid bits from all message parsers. * WIP - merges identifier framework branch changes into this branch. * WIP on updating link control words to new format and identifier framework. * WIP - implements rest of link control words for extended formats * WIP - initial work on ISP/OSP TSBK message restructuring. * WIP - adds more TSBK ISP and OSP messages * WIP - finished updating most of the TSBK ISP and OSP messages. Converted all messages to no longer include the NID (nac + dataunitID) so that each message can simply hold the parsed values. Removed AliasList as an argument to each message and updated all messges to use the new IIdentifer and IAPCO25Channel interfaces. Removed legacy TDU and LDU link control messages and replaced with a single LinkControlWord class hierarchy. P25 decoder state is not yet updated for the new message structure. PDU message parsing is not fully implemented. * WIP - adds some Multi-Block trunking control messages with Alternate and Unconfirmed formats. * WIP - Fully implements AMBTC and UMBTC PDU message parsers. Some package restructuring. * WIP - Resolves Link control parsing in LDU1 and 2 messages. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. Adds support for moto ARS service, IPV4 decoding, and UDP/IP packets. * WIP - finishes SNDCP packet data with header parsing. Compressed IP or UDP headers are not yet supported, but are logged as such. * WIP - converts all talkgroup identifiers to integers and updates alias list to create a per-protocol map of talkgroup id's to alias. Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.) conversion utility to convert existing legacy (string) talkgroups to new integer talkgroup format. Creates an audio packet manager to insert metadata into audio packets before streaming packets for playback, recording, and/or streaming. Creates identifier collection to manage current identifiers in each of the channel and decoder states. Creates simplified channel metadata to maintain the now playing display. Moves channel attributes (alias list, system, site, name) as configuration identifiers in the channel state. Many other refactoring and updates. * WIP - numerous updates to push use of identifier collection throughout the system. Updates the channel metadata and audio packet processing logic. Implements a large portion of the P25 decode state processing. Updates traffic channel management. Adds user preferences for timestamp and identifier formatting, however doesn't add a user interface yet. * WIP - initial implementation of user preferences editor window. * WIP - updates preferences editor window to close and dispose window but retain javafx event thread running. * WIP - fully updates p25 decoder state and traffic channel processing to use the new identifier framework. Cleans up channel event processing and removes channel model as the sole broadcaster of channel events. Channel processing manager now listens for all start/stop events and requestors dispatch event directly to the channel processing manager. Resolves issue in airspy that was causing user interface to lock-up. The issue appears to occur when the dongle is plugged into a usb port that can't fully support the data rate. sdrtrunk now recognizes these errors and warns the user that they should use another usb port. * WIP - updates alias action manager and adds new talkgroup range alias identifier. Updates playlist to incorporate a version number so that the playlist updater only runs when needed, to update a playlist to the correct version format. Updates user preferences to use the google event bus to broadcast preference update notifications to remove the need for listeners to register directly on the user preferences instance. * WIP - updates alias id editors to flag invalid values and moves legacy alias ids to legacy package. Updates event logging configuration to add traffic channel decode events and decoded message logging. Removes binary message logging since that is now replaced with demodulated bitstream recording. * Removes system properties from user preferences. Preferences are stored in the OS-dependent settings store (windows - registry) * Updates MapService to use new PlottableDecodeEvent instead of monitoring all of the decoded messages. Updates Fleetsync decoder and related messages to identifier framework. * Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier framework and adds support for user preferences for formatting of LTR-Net and fleetsync talkgroup identifiers. Breaks LTR-Net messages into various message types and uses a new message factory. Removes alias list from message processing for ltr-net, fleetsync and lj1200. * Updates LTR-Standard messages to Identifier framework. * Removes Plottable and IPlottable from codebase. * wip * WIP on MPT-1327 messages. * Updates MPT1327 decoder to identifier framework and new traffic channel manager. This decoder still needs to be updated with a new message parser factory and a sync detector like what is now used for P25. * Updates MDC1200 decoder and message to identifier framework. * Updates Tait1200 and Passport decoders to identifier framework. * Merges changes from master branch. * Removes legacy alias support classes. Updates passport message processor to only pass valid messages. Adds support to playlist updater for converting passport mobile ids to become passport talkgroup values. * Updates P25 decoder state and channel state to better track allocated traffic channels. Resolves issue in timestamp manager for trackig message timestamps. Resolves issue in airspy tuner that was causing the tuner to stop sending samples to the application. * Update P25 Decoder state to process SNDCP management messages and PDU messages. Updates P25 activity summary to display network and site details. Resolves issue with overlay panel that prevented enabled channels from rendering correctly when zoomed in. * Creates a new FilePreferences as part of the user preferences to begin the transition of SystemProperties over to user preferences and consolidate file preferences in one location. Updates playlist manager to use the new file preferences and to use default.xml as the new default playlist name, following conversion of a playlist_v2.xml format to the new format. In the near future, the user will be able to edit file locations and to create/use other playlists. Resolved an issue with all decoder states where not all identifiers were being included in decode events.
This commit is contained in:
@@ -41,254 +41,257 @@ import java.awt.event.ActionListener;
|
||||
|
||||
public class ChannelController extends JPanel implements ActionListener, ListSelectionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private JTable mChannelTable;
|
||||
private TableFilterHeader mTableFilterHeader;
|
||||
private ChannelEditor mEditor;
|
||||
|
||||
private static final String NEW_CHANNEL = "New";
|
||||
private static final String COPY_CHANNEL = "Copy";
|
||||
private static final String DELETE_CHANNEL = "Delete";
|
||||
|
||||
private JButton mNewChannelButton = new JButton( NEW_CHANNEL );
|
||||
private JButton mCopyChannelButton = new JButton( COPY_CHANNEL );
|
||||
private JButton mDeleteChannelButton = new JButton( DELETE_CHANNEL );
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
private JTable mChannelTable;
|
||||
private TableFilterHeader mTableFilterHeader;
|
||||
private ChannelEditor mEditor;
|
||||
|
||||
public ChannelController( ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
SourceManager sourceManager,
|
||||
AliasModel aliasModel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
private static final String NEW_CHANNEL = "New";
|
||||
private static final String COPY_CHANNEL = "Copy";
|
||||
private static final String DELETE_CHANNEL = "Delete";
|
||||
|
||||
mEditor = new ChannelEditor( channelModel, channelMapModel, sourceManager, aliasModel );
|
||||
mChannelModel.addListener( mEditor );
|
||||
private JButton mNewChannelButton = new JButton(NEW_CHANNEL);
|
||||
private JButton mCopyChannelButton = new JButton(COPY_CHANNEL);
|
||||
private JButton mDeleteChannelButton = new JButton(DELETE_CHANNEL);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]") );
|
||||
public ChannelController(ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
ChannelMapModel channelMapModel,
|
||||
SourceManager sourceManager,
|
||||
AliasModel aliasModel)
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mEditor = new ChannelEditor(channelModel, channelProcessingManager, channelMapModel, sourceManager, aliasModel);
|
||||
mChannelModel.addListener(mEditor);
|
||||
mChannelProcessingManager.addChannelEventListener(mEditor);
|
||||
|
||||
//System Configuration View and Editor
|
||||
mChannelTable = new JTable( mChannelModel );
|
||||
mChannelTable.setDefaultRenderer( String.class, new ChannelTableCellRenderer() );
|
||||
mChannelTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
mChannelTable.getSelectionModel().addListSelectionListener( this );
|
||||
mChannelTable.setAutoCreateRowSorter( true );
|
||||
|
||||
mTableFilterHeader = new TableFilterHeader( mChannelTable, AutoChoices.ENABLED );
|
||||
mTableFilterHeader.setFilterOnUpdates( true );
|
||||
|
||||
JScrollPane channelScroller = new JScrollPane( mChannelTable );
|
||||
init();
|
||||
}
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
|
||||
buttonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]") );
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("", "[grow,fill]", "[grow,fill]"));
|
||||
|
||||
mNewChannelButton.addActionListener( this );
|
||||
mNewChannelButton.setToolTipText( "Create a new channel configuration" );
|
||||
buttonsPanel.add( mNewChannelButton );
|
||||
|
||||
mCopyChannelButton.addActionListener( this );
|
||||
mCopyChannelButton.setEnabled( false );
|
||||
mCopyChannelButton.setToolTipText( "Create a copy of the currently selected channel configuration" );
|
||||
buttonsPanel.add( mCopyChannelButton );
|
||||
//System Configuration View and Editor
|
||||
mChannelTable = new JTable(mChannelModel);
|
||||
mChannelTable.setDefaultRenderer(String.class, new ChannelTableCellRenderer());
|
||||
mChannelTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
mChannelTable.getSelectionModel().addListSelectionListener(this);
|
||||
mChannelTable.setAutoCreateRowSorter(true);
|
||||
|
||||
mDeleteChannelButton.addActionListener( this );
|
||||
mDeleteChannelButton.setEnabled( false );
|
||||
mDeleteChannelButton.setToolTipText( "Delete the currently selected channel configuration" );
|
||||
buttonsPanel.add( mDeleteChannelButton );
|
||||
|
||||
JPanel listAndButtonsPanel = new JPanel();
|
||||
mTableFilterHeader = new TableFilterHeader(mChannelTable, AutoChoices.ENABLED);
|
||||
mTableFilterHeader.setFilterOnUpdates(true);
|
||||
|
||||
listAndButtonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill][]") );
|
||||
JScrollPane channelScroller = new JScrollPane(mChannelTable);
|
||||
|
||||
listAndButtonsPanel.add( channelScroller, "wrap" );
|
||||
listAndButtonsPanel.add( buttonsPanel );
|
||||
|
||||
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.VERTICAL_SPLIT );
|
||||
splitPane.setDividerSize( 5 );
|
||||
splitPane.setShowGripper( true );
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
|
||||
//Shrink this guy so that he'll eventually be expanded to the scroller preferred size
|
||||
listAndButtonsPanel.setPreferredSize( new Dimension( 10, 10 ) );
|
||||
buttonsPanel.setLayout(
|
||||
new MigLayout("insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]"));
|
||||
|
||||
//Attempt to get a 60:40 vertical sizing preference
|
||||
JScrollPane listScroller = new JScrollPane( listAndButtonsPanel );
|
||||
listScroller.setPreferredSize( new Dimension( 800, 58 ) );
|
||||
|
||||
JScrollPane editorScroller = new JScrollPane( mEditor );
|
||||
editorScroller.setPreferredSize( new Dimension( 800, 42 ) );
|
||||
mNewChannelButton.addActionListener(this);
|
||||
mNewChannelButton.setToolTipText("Create a new channel configuration");
|
||||
buttonsPanel.add(mNewChannelButton);
|
||||
|
||||
splitPane.add( listScroller );
|
||||
splitPane.add( editorScroller );
|
||||
mCopyChannelButton.addActionListener(this);
|
||||
mCopyChannelButton.setEnabled(false);
|
||||
mCopyChannelButton.setToolTipText("Create a copy of the currently selected channel configuration");
|
||||
buttonsPanel.add(mCopyChannelButton);
|
||||
|
||||
add( splitPane );
|
||||
}
|
||||
mDeleteChannelButton.addActionListener(this);
|
||||
mDeleteChannelButton.setEnabled(false);
|
||||
mDeleteChannelButton.setToolTipText("Delete the currently selected channel configuration");
|
||||
buttonsPanel.add(mDeleteChannelButton);
|
||||
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
//This limits event firing to only when selection is complete
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int selectedRow = mChannelTable.getSelectedRow();
|
||||
|
||||
if( selectedRow != -1 )
|
||||
{
|
||||
int index = mChannelTable.convertRowIndexToModel( mChannelTable.getSelectedRow() );
|
||||
|
||||
Channel channel = mChannelModel.getChannelAtIndex( index );
|
||||
|
||||
if( channel != null )
|
||||
{
|
||||
mEditor.setItem( channel );
|
||||
mCopyChannelButton.setEnabled( true );
|
||||
mDeleteChannelButton.setEnabled( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mEditor.setItem( null );
|
||||
mCopyChannelButton.setEnabled( false );
|
||||
mDeleteChannelButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
JPanel listAndButtonsPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Adds the channel to the channel model/table and scrolls to view it
|
||||
*/
|
||||
private void addChannel( Channel channel )
|
||||
{
|
||||
//HACK: when inserting a row to the model, the JTable gets
|
||||
//notified and attempts to tell the coderazzi table filter
|
||||
//adaptive choices filter to refresh before the table filter is
|
||||
//notified of the row additions, causing an index out of bounds
|
||||
//exception. We turn off adaptive choices temporarily, add the
|
||||
//channel, and turn on adaptive choices again.
|
||||
mTableFilterHeader.setAdaptiveChoices( false );
|
||||
|
||||
int index = mChannelModel.addChannel( channel );
|
||||
listAndButtonsPanel.setLayout(
|
||||
new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill][]"));
|
||||
|
||||
mTableFilterHeader.setAdaptiveChoices( true );
|
||||
listAndButtonsPanel.add(channelScroller, "wrap");
|
||||
listAndButtonsPanel.add(buttonsPanel);
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
int translatedIndex = mChannelTable.convertRowIndexToView( index );
|
||||
JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
|
||||
splitPane.setDividerSize(5);
|
||||
splitPane.setShowGripper(true);
|
||||
|
||||
if(translatedIndex >= 0)
|
||||
{
|
||||
mChannelTable.setRowSelectionInterval( translatedIndex, translatedIndex );
|
||||
mChannelTable.scrollRectToVisible(
|
||||
new Rectangle( mChannelTable.getCellRect( translatedIndex, 0, true ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Channel getSelectedChannel()
|
||||
{
|
||||
int index = mChannelTable.getSelectedRow();
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
return mChannelModel.getChannelAtIndex(
|
||||
mChannelTable.convertRowIndexToModel( index ) );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
//Shrink this guy so that he'll eventually be expanded to the scroller preferred size
|
||||
listAndButtonsPanel.setPreferredSize(new Dimension(10, 10));
|
||||
|
||||
/**
|
||||
* Responds to New, Copy and Delete Channel button invocations
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent event )
|
||||
{
|
||||
switch( event.getActionCommand() )
|
||||
{
|
||||
case NEW_CHANNEL:
|
||||
addChannel( new Channel( "New Channel" ) );
|
||||
break;
|
||||
case COPY_CHANNEL:
|
||||
Channel selected = getSelectedChannel();
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
addChannel( selected.copyOf() );
|
||||
}
|
||||
break;
|
||||
case DELETE_CHANNEL:
|
||||
Channel toDelete = getSelectedChannel();
|
||||
//Attempt to get a 60:40 vertical sizing preference
|
||||
JScrollPane listScroller = new JScrollPane(listAndButtonsPanel);
|
||||
listScroller.setPreferredSize(new Dimension(800, 58));
|
||||
|
||||
if( toDelete != null )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( ChannelController.this,
|
||||
"Do you want to delete this channel?", "Delete Channel?",
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
mChannelModel.removeChannel( toDelete );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public class ChannelTableCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
JScrollPane editorScroller = new JScrollPane(mEditor);
|
||||
editorScroller.setPreferredSize(new Dimension(800, 42));
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column )
|
||||
{
|
||||
Component component = super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column );
|
||||
splitPane.add(listScroller);
|
||||
splitPane.add(editorScroller);
|
||||
|
||||
ChannelModel model = (ChannelModel)table.getModel();
|
||||
add(splitPane);
|
||||
}
|
||||
|
||||
int index = table.convertRowIndexToModel( row );
|
||||
|
||||
Channel channel = model.getChannelAtIndex( index );
|
||||
|
||||
boolean enabled = channel.isProcessing();
|
||||
|
||||
if( isSelected )
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
component.setBackground( Color.YELLOW );
|
||||
}
|
||||
else
|
||||
{
|
||||
component.setBackground( table.getSelectionBackground() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
component.setBackground( Color.GREEN );
|
||||
}
|
||||
else
|
||||
{
|
||||
component.setBackground( table.getBackground() );
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent event)
|
||||
{
|
||||
//This limits event firing to only when selection is complete
|
||||
if(!event.getValueIsAdjusting())
|
||||
{
|
||||
int selectedRow = mChannelTable.getSelectedRow();
|
||||
|
||||
if(selectedRow != -1)
|
||||
{
|
||||
int index = mChannelTable.convertRowIndexToModel(mChannelTable.getSelectedRow());
|
||||
|
||||
Channel channel = mChannelModel.getChannelAtIndex(index);
|
||||
|
||||
if(channel != null)
|
||||
{
|
||||
mEditor.setItem(channel);
|
||||
mCopyChannelButton.setEnabled(true);
|
||||
mDeleteChannelButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mEditor.setItem(null);
|
||||
mCopyChannelButton.setEnabled(false);
|
||||
mDeleteChannelButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the channel to the channel model/table and scrolls to view it
|
||||
*/
|
||||
private void addChannel(Channel channel)
|
||||
{
|
||||
//HACK: when inserting a row to the model, the JTable gets
|
||||
//notified and attempts to tell the coderazzi table filter
|
||||
//adaptive choices filter to refresh before the table filter is
|
||||
//notified of the row additions, causing an index out of bounds
|
||||
//exception. We turn off adaptive choices temporarily, add the
|
||||
//channel, and turn on adaptive choices again.
|
||||
mTableFilterHeader.setAdaptiveChoices(false);
|
||||
|
||||
int index = mChannelModel.addChannel(channel);
|
||||
|
||||
mTableFilterHeader.setAdaptiveChoices(true);
|
||||
|
||||
if(index >= 0)
|
||||
{
|
||||
int translatedIndex = mChannelTable.convertRowIndexToView(index);
|
||||
|
||||
if(translatedIndex >= 0)
|
||||
{
|
||||
mChannelTable.setRowSelectionInterval(translatedIndex, translatedIndex);
|
||||
mChannelTable.scrollRectToVisible(
|
||||
new Rectangle(mChannelTable.getCellRect(translatedIndex, 0, true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Channel getSelectedChannel()
|
||||
{
|
||||
int index = mChannelTable.getSelectedRow();
|
||||
|
||||
if(index >= 0)
|
||||
{
|
||||
return mChannelModel.getChannelAtIndex(
|
||||
mChannelTable.convertRowIndexToModel(index));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to New, Copy and Delete Channel button invocations
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
switch(event.getActionCommand())
|
||||
{
|
||||
case NEW_CHANNEL:
|
||||
addChannel(new Channel("New Channel"));
|
||||
break;
|
||||
case COPY_CHANNEL:
|
||||
Channel selected = getSelectedChannel();
|
||||
|
||||
if(selected != null)
|
||||
{
|
||||
addChannel(selected.copyOf());
|
||||
}
|
||||
break;
|
||||
case DELETE_CHANNEL:
|
||||
Channel toDelete = getSelectedChannel();
|
||||
|
||||
if(toDelete != null)
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog(ChannelController.this,
|
||||
"Do you want to delete this channel?", "Delete Channel?",
|
||||
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
|
||||
if(choice == JOptionPane.YES_OPTION)
|
||||
{
|
||||
mChannelModel.removeChannel(toDelete);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public class ChannelTableCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column)
|
||||
{
|
||||
Component component = super.getTableCellRendererComponent(
|
||||
table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
ChannelModel model = (ChannelModel)table.getModel();
|
||||
|
||||
int index = table.convertRowIndexToModel(row);
|
||||
|
||||
Channel channel = model.getChannelAtIndex(index);
|
||||
|
||||
boolean enabled = channel.isProcessing();
|
||||
|
||||
if(isSelected)
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
component.setBackground(Color.YELLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
component.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
component.setBackground(Color.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
component.setBackground(table.getBackground());
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user