wip #34 - updating the decoder editors to the new editor format

This commit is contained in:
denny
2016-03-21 18:30:19 -04:00
parent d93f497b33
commit e89e7bd361
6 changed files with 53 additions and 49 deletions

View File

@@ -18,6 +18,7 @@
package controller.channel; package controller.channel;
import gui.editor.Editor; import gui.editor.Editor;
import gui.editor.EditorValidationException;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@@ -55,7 +56,7 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
private SourceConfigurationEditor mSourceConfigurationEditor; private SourceConfigurationEditor mSourceConfigurationEditor;
private DecodeConfigurationEditor mDecodeConfigurationEditor; private DecodeConfigurationEditor mDecodeConfigurationEditor;
private AuxDecodeConfigurationEditor mAuxDecodeConfigurationEditor; private AuxDecodeConfigurationEditor mAuxDecodeConfigurationEditor;
private EventLogConfigurationEditor mEventLogConfiguraitonEditor; private EventLogConfigurationEditor mEventLogConfigurationEditor;
private RecordConfigurationEditor mRecordConfigurationEditor; private RecordConfigurationEditor mRecordConfigurationEditor;
private JButton mEnableButton = new JButton( "Enable" ); private JButton mEnableButton = new JButton( "Enable" );
@@ -106,7 +107,7 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
mSourceConfigurationEditor.setItem( channel ); mSourceConfigurationEditor.setItem( channel );
mDecodeConfigurationEditor.setItem( channel ); mDecodeConfigurationEditor.setItem( channel );
mAuxDecodeConfigurationEditor.setItem( channel ); mAuxDecodeConfigurationEditor.setItem( channel );
mEventLogConfiguraitonEditor.setItem( channel ); mEventLogConfigurationEditor.setItem( channel );
mRecordConfigurationEditor.setItem( channel ); mRecordConfigurationEditor.setItem( channel );
if( channel != null ) if( channel != null )
@@ -127,9 +128,7 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
private void init() private void init()
{ {
setLayout( new MigLayout( "fill,wrap 3", "[grow,fill][grow,fill][grow,fill]", "[][][][][grow]" ) ); setLayout( new MigLayout( "fill,wrap 3", "[grow,fill][grow,fill][grow,fill]", "[grow,fill][]" ) );
add( mChannelName, "wrap" );
JideTabbedPane tabs = new JideTabbedPane(); JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() ); tabs.setFont( this.getFont() );
@@ -147,8 +146,8 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
mAuxDecodeConfigurationEditor = new AuxDecodeConfigurationEditor(); mAuxDecodeConfigurationEditor = new AuxDecodeConfigurationEditor();
tabs.addTab( "Aux Decoders", mAuxDecodeConfigurationEditor ); tabs.addTab( "Aux Decoders", mAuxDecodeConfigurationEditor );
mEventLogConfiguraitonEditor = new EventLogConfigurationEditor(); mEventLogConfigurationEditor = new EventLogConfigurationEditor();
tabs.addTab( "Logging", mEventLogConfiguraitonEditor ); tabs.addTab( "Logging", mEventLogConfigurationEditor );
mRecordConfigurationEditor = new RecordConfigurationEditor(); mRecordConfigurationEditor = new RecordConfigurationEditor();
tabs.addTab( "Recording", mRecordConfigurationEditor ); tabs.addTab( "Recording", mRecordConfigurationEditor );
@@ -234,40 +233,40 @@ public class ChannelEditor extends Editor<Channel> implements ActionListener, Ch
{ {
if( hasItem() ) if( hasItem() )
{ {
// try try
// { {
//TODO: validate the source editor against the decode editor mDecodeConfigurationEditor.validate( mSourceConfigurationEditor );
//TODO: validate the aux editor against the decode editor - verify no aux decoders with P25 mDecodeConfigurationEditor.validate( mAuxDecodeConfigurationEditor );
// } }
// catch( ConfigurationValidationException e ) catch( EditorValidationException e )
// { {
// /* ChannelValidationException can be thrown by any of the component JOptionPane.showMessageDialog( ChannelEditor.this, e.getReason(),
// * editors. Show the validation error text in a popup menu to the "Configuration Error", JOptionPane.ERROR_MESSAGE );
// * user and set the focus on the error component */
// JOptionPane.showMessageDialog( ChannelEditor.this, e.getEditor().requestFocus();
// validationException.getMessage(),
// "Channel Configuration Error", return;
// JOptionPane.ERROR_MESSAGE ); }
//
// Component component = validationException.getComponent(); boolean changed = mNameConfigurationEditor.isModified() ||
// mSourceConfigurationEditor.isModified() ||
// if( component != null ) mDecodeConfigurationEditor.isModified() ||
// { mAuxDecodeConfigurationEditor.isModified() ||
// component.requestFocus(); mEventLogConfigurationEditor.isModified() ||
// } mRecordConfigurationEditor.isModified();
//
// return;
// }
mNameConfigurationEditor.save(); mNameConfigurationEditor.save();
mSourceConfigurationEditor.save(); mSourceConfigurationEditor.save();
mDecodeConfigurationEditor.save(); mDecodeConfigurationEditor.save();
mAuxDecodeConfigurationEditor.save(); mAuxDecodeConfigurationEditor.save();
mEventLogConfiguraitonEditor.save(); mEventLogConfigurationEditor.save();
mRecordConfigurationEditor.save(); mRecordConfigurationEditor.save();
//Broadcast a channel configuration change event if( changed )
mChannelModel.broadcast( new ChannelEvent( getItem(), Event.NOTIFICATION_CONFIGURATION_CHANGE ) ); {
mChannelModel.broadcast( new ChannelEvent( getItem(),
Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
}
} }
setModified( false ); setModified( false );

View File

@@ -30,8 +30,7 @@ public class EmptyValidatingEditor<T> extends ValidatingEditor<T>
} }
@Override @Override
public boolean isValid( Editor<T> editor ) throws EditorValidationException public void validate( Editor<T> editor ) throws EditorValidationException
{ {
return true;
} }
} }

View File

@@ -11,5 +11,5 @@ public abstract class ValidatingEditor<T> extends Editor<T>
/** /**
* Indicates if the editor argument is valid according to the settings of this editor * Indicates if the editor argument is valid according to the settings of this editor
*/ */
public abstract boolean isValid( Editor<T> editor ) throws EditorValidationException; public abstract void validate( Editor<T> editor ) throws EditorValidationException;
} }

View File

@@ -87,6 +87,7 @@ public class DecodeConfigurationEditor extends ValidatingEditor<Channel>
{ {
remove( mCurrentEditor ); remove( mCurrentEditor );
mCurrentEditor = editor; mCurrentEditor = editor;
mCurrentEditor.setItem( getItem() );
add( mCurrentEditor ); add( mCurrentEditor );
revalidate(); revalidate();
@@ -97,12 +98,12 @@ public class DecodeConfigurationEditor extends ValidatingEditor<Channel>
@Override @Override
public void save() public void save()
{ {
// if( mEditor != null ) if( hasItem() && mCurrentEditor != null )
// { {
// mEditor.save(); mCurrentEditor.save();
// } }
//
// mChannel.setDecodeConfiguration( mEditor.getConfig() ); setModified( false );
} }
@Override @Override
@@ -119,11 +120,13 @@ public class DecodeConfigurationEditor extends ValidatingEditor<Channel>
{ {
mComboDecoders.setEnabled( false ); mComboDecoders.setEnabled( false );
} }
setModified( false );
} }
@Override @Override
public boolean isValid( Editor<Channel> editor ) throws EditorValidationException public void validate( Editor<Channel> editor ) throws EditorValidationException
{ {
return mCurrentEditor.isValid( editor ); mCurrentEditor.validate( editor );
} }
} }

View File

@@ -31,9 +31,8 @@ public class AMDecoderEditor extends ValidatingEditor<Channel>
} }
@Override @Override
public boolean isValid( Editor<Channel> editor ) throws EditorValidationException public void validate( Editor<Channel> editor ) throws EditorValidationException
{ {
return true;
} }
@Override @Override

View File

@@ -91,6 +91,7 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
mComboDirection = new JComboBox<MessageDirection>(); mComboDirection = new JComboBox<MessageDirection>();
mComboDirection.setModel( new DefaultComboBoxModel<MessageDirection>( MessageDirection.values() ) ); mComboDirection.setModel( new DefaultComboBoxModel<MessageDirection>( MessageDirection.values() ) );
mComboDirection.setSelectedItem( MessageDirection.OSW );
mComboDirection.setEnabled( false ); mComboDirection.setEnabled( false );
mComboDirection.addActionListener( new ActionListener() mComboDirection.addActionListener( new ActionListener()
{ {
@@ -106,9 +107,8 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
} }
@Override @Override
public boolean isValid( Editor<Channel> editor ) throws EditorValidationException public void validate( Editor<Channel> editor ) throws EditorValidationException
{ {
return true;
} }
@@ -119,6 +119,8 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
if( hasItem() ) if( hasItem() )
{ {
mAFC.setEnabled( true );
mAFCMaximumCorrection.setEnabled( true );
mComboDirection.setEnabled( true ); mComboDirection.setEnabled( true );
DecodeConfiguration config = getItem().getDecodeConfiguration(); DecodeConfiguration config = getItem().getDecodeConfiguration();
@@ -133,6 +135,8 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
} }
else else
{ {
mAFC.setEnabled( false );
mAFCMaximumCorrection.setEnabled( false );
mComboDirection.setEnabled( false ); mComboDirection.setEnabled( false );
} }
} }