wip #34 - finished updating all channel configuration editors and

completed preliminary functional testing.
This commit is contained in:
denny
2016-03-25 14:26:08 -04:00
parent e89e7bd361
commit 112083a22f
32 changed files with 1328 additions and 946 deletions

View File

@@ -1,41 +0,0 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel;
public abstract class AbstractChannelEditor extends ChannelConfigurationEditor
{
private static final long serialVersionUID = 1L;
protected Channel mChannel;
public AbstractChannelEditor( Channel channel )
{
super();
mChannel = channel;
}
public Channel getChannel()
{
return mChannel;
}
public abstract void save();
public abstract void reset();
}

View File

@@ -1,44 +0,0 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014-2016 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 controller.channel;
import javax.swing.JPanel;
public abstract class ChannelConfigurationEditor extends JPanel
{
private static final long serialVersionUID = 1L;
/**
* Sets or resets the configuration editor components
*/
public abstract void setConfiguration( Channel channel );
/**
* Saves the contents of the editor components to the configuration
*/
public abstract void save();
/**
* Validates the contents of the editor components prior to saving the
* content to the configuration.
*
* @throws ConfigurationValidationException if the content is invalid
*/
public abstract void validateConfiguration() throws ConfigurationValidationException;
}

View File

@@ -85,17 +85,17 @@ public class ChannelController extends JPanel
new MigLayout( "insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]") );
mNewChannelButton.addActionListener( this );
mNewChannelButton.setToolTipText( "Adds a new default channel" );
mNewChannelButton.setToolTipText( "Create a new channel configuration" );
buttonsPanel.add( mNewChannelButton );
mCopyChannelButton.addActionListener( this );
mCopyChannelButton.setEnabled( false );
mCopyChannelButton.setToolTipText( "Creates a copy of the currently selected channel and adds it" );
mCopyChannelButton.setToolTipText( "Create a copy of the currently selected channel configuration" );
buttonsPanel.add( mCopyChannelButton );
mDeleteChannelButton.addActionListener( this );
mDeleteChannelButton.setEnabled( false );
mDeleteChannelButton.setToolTipText( "Deletes the currently selected channel" );
mDeleteChannelButton.setToolTipText( "Delete the currently selected channel configuration" );
buttonsPanel.add( mDeleteChannelButton );
JPanel listAndButtonsPanel = new JPanel();
@@ -115,10 +115,10 @@ public class ChannelController extends JPanel
//Attempt to get a 60:40 vertical sizing preference
JScrollPane listScroller = new JScrollPane( listAndButtonsPanel );
listScroller.setPreferredSize( new Dimension( 800, 60 ) );
listScroller.setPreferredSize( new Dimension( 800, 58 ) );
JScrollPane editorScroller = new JScrollPane( mEditor );
editorScroller.setPreferredSize( new Dimension( 800, 40 ) );
editorScroller.setPreferredSize( new Dimension( 800, 42 ) );
splitPane.add( listScroller );
splitPane.add( editorScroller );

View File

@@ -81,51 +81,6 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
init();
}
/**
* Sets the channel configuration in each of the channel editor components
* Note: this method must be invoked on the swing event dispatch thread
*/
public void setItem( final Channel channel )
{
//Check if the current channel configuration has changed
if( hasItem() &&
( mNameConfigurationEditor.isModified() ) )
{
int option = JOptionPane.showConfirmDialog( ChannelEditor.this,
"This channel configuration has changed. Do you want to save these changes?",
"Save Changes?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE );
if( option == JOptionPane.YES_OPTION )
{
save();
}
setModified( false );
}
mNameConfigurationEditor.setItem( channel );
mSourceConfigurationEditor.setItem( channel );
mDecodeConfigurationEditor.setItem( channel );
mAuxDecodeConfigurationEditor.setItem( channel );
mEventLogConfigurationEditor.setItem( channel );
mRecordConfigurationEditor.setItem( channel );
if( channel != null )
{
mChannelName.setText( "Channel: " + channel.getName() );
mEnableButton.setText( channel.getEnabled() ? "Disable" : "Enable" );
mEnableButton.setEnabled( true );
mEnableButton.setBackground( channel.getEnabled() ? Color.GREEN : getBackground() );
}
else
{
mChannelName.setText( "Channel: " );
mEnableButton.setText( "Enable" );
mEnableButton.setEnabled( false );
mEnableButton.setBackground( getBackground() );
}
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 3", "[grow,fill][grow,fill][grow,fill]", "[grow,fill][]" ) );
@@ -135,38 +90,48 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
tabs.setForeground( Color.BLACK );
tabs.setTabTrailingComponent( mChannelName );
mNameConfigurationEditor.setSaveRequestListener( this );
tabs.addTab( "Name/Alias", mNameConfigurationEditor );
mSourceConfigurationEditor = new SourceConfigurationEditor( mSourceManager );
mSourceConfigurationEditor.setSaveRequestListener( this );
tabs.addTab( "Source", mSourceConfigurationEditor );
mDecodeConfigurationEditor = new DecodeConfigurationEditor( mChannelMapModel );
mDecodeConfigurationEditor.setSaveRequestListener( this );
tabs.addTab( "Decoder", mDecodeConfigurationEditor );
mAuxDecodeConfigurationEditor = new AuxDecodeConfigurationEditor();
mAuxDecodeConfigurationEditor.setSaveRequestListener( this );
tabs.addTab( "Aux Decoders", mAuxDecodeConfigurationEditor );
mEventLogConfigurationEditor = new EventLogConfigurationEditor();
mEventLogConfigurationEditor.setSaveRequestListener( this );
tabs.addTab( "Logging", mEventLogConfigurationEditor );
mRecordConfigurationEditor = new RecordConfigurationEditor();
mRecordConfigurationEditor.setSaveRequestListener( this );
tabs.addTab( "Recording", mRecordConfigurationEditor );
add( tabs, "span" );
mEnableButton.addActionListener( this );
mEnableButton.setEnabled( false );
mEnableButton.setToolTipText( "Start the currently selected channel running/decoding" );
add( mEnableButton );
JButton btnSave = new JButton( "Save" );
btnSave.setToolTipText( "Save changes to the currently selected channel" );
btnSave.addActionListener( ChannelEditor.this );
add( btnSave );
JButton btnReset = new JButton( "Reset" );
btnReset.setToolTipText( "Reload the currently selected channel" );
btnReset.addActionListener( ChannelEditor.this );
add( btnReset );
}
@Override
public void channelChanged( ChannelEvent event )
{
@@ -229,10 +194,48 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
}
}
/**
* Sets the channel configuration in each of the channel editor components
* Note: this method must be invoked on the swing event dispatch thread
*/
public void setItem( final Channel channel )
{
super.setItem( channel );
mNameConfigurationEditor.setItem( channel );
mSourceConfigurationEditor.setItem( channel );
mDecodeConfigurationEditor.setItem( channel );
mAuxDecodeConfigurationEditor.setItem( channel );
mEventLogConfigurationEditor.setItem( channel );
mRecordConfigurationEditor.setItem( channel );
if( channel != null )
{
mChannelName.setText( "Channel: " + channel.getName() );
mEnableButton.setText( channel.getEnabled() ? "Disable" : "Enable" );
mEnableButton.setEnabled( true );
mEnableButton.setBackground( channel.getEnabled() ? Color.GREEN : getBackground() );
}
else
{
mChannelName.setText( "Channel: " );
mEnableButton.setText( "Enable" );
mEnableButton.setEnabled( false );
mEnableButton.setBackground( getBackground() );
}
}
public void save()
{
if( hasItem() )
{
mNameConfigurationEditor.save();
mSourceConfigurationEditor.save();
mDecodeConfigurationEditor.save();
mAuxDecodeConfigurationEditor.save();
mEventLogConfigurationEditor.save();
mRecordConfigurationEditor.save();
try
{
mDecodeConfigurationEditor.validate( mSourceConfigurationEditor );
@@ -240,33 +243,17 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
}
catch( EditorValidationException e )
{
JOptionPane.showMessageDialog( ChannelEditor.this, e.getReason(),
"Configuration Error", JOptionPane.ERROR_MESSAGE );
e.getEditor().requestFocus();
JOptionPane.showMessageDialog( e.getEditor(), e.getReason(),
"Configuration Error", JOptionPane.ERROR_MESSAGE );
return;
}
boolean changed = mNameConfigurationEditor.isModified() ||
mSourceConfigurationEditor.isModified() ||
mDecodeConfigurationEditor.isModified() ||
mAuxDecodeConfigurationEditor.isModified() ||
mEventLogConfigurationEditor.isModified() ||
mRecordConfigurationEditor.isModified();
mNameConfigurationEditor.save();
mSourceConfigurationEditor.save();
mDecodeConfigurationEditor.save();
mAuxDecodeConfigurationEditor.save();
mEventLogConfigurationEditor.save();
mRecordConfigurationEditor.save();
if( changed )
{
mChannelModel.broadcast( new ChannelEvent( getItem(),
mChannelModel.broadcast( new ChannelEvent( getItem(),
Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
}
}
setModified( false );

View File

@@ -262,5 +262,8 @@ public class NameConfigurationEditor extends Editor<Channel> implements Document
}
@Override
public void removeUpdate( DocumentEvent e ) {}
public void removeUpdate( DocumentEvent e )
{
setModified( true );
}
}