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

View File

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

View File

@@ -91,6 +91,7 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
mComboDirection = new JComboBox<MessageDirection>();
mComboDirection.setModel( new DefaultComboBoxModel<MessageDirection>( MessageDirection.values() ) );
mComboDirection.setSelectedItem( MessageDirection.OSW );
mComboDirection.setEnabled( false );
mComboDirection.addActionListener( new ActionListener()
{
@@ -106,9 +107,8 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
}
@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() )
{
mAFC.setEnabled( true );
mAFCMaximumCorrection.setEnabled( true );
mComboDirection.setEnabled( true );
DecodeConfiguration config = getItem().getDecodeConfiguration();
@@ -133,6 +135,8 @@ public class LTRNetDecoderEditor extends ValidatingEditor<Channel>
}
else
{
mAFC.setEnabled( false );
mAFCMaximumCorrection.setEnabled( false );
mComboDirection.setEnabled( false );
}
}