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

@@ -78,7 +78,7 @@ public class JFrequencyControl extends JPanel implements IFrequencyChangeProcess
private void init()
{
setLayout( new MigLayout( "", "[]0[]", "" ) );
setLayout( new MigLayout( "insets 0 0 0 0", "[]0[]", "" ) );
Font font = new Font( Font.MONOSPACED, Font.BOLD, 30 );

View File

@@ -6,10 +6,19 @@ import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import alias.id.AliasIdentifierEditor;
/**
* Generic editor with change detection, save and reset functions.
*
* This editor supports hierarchical nesting of sub-component editors where changes are detected
* at the lowest editor in the tree and percolated up to the top-level editor for managing the
* configuration set as a whole.
*
* To configure this editor as a collective, register each parent editor as a saveRequestListener
* on each child editor. If no save request listener is registered, the editor will simply invoke
* save when a change is detected and the user opts to save the contents.
*
* The top-level editor can override the saveRequest() method to perform custom save operations
* and validation.
*/
public abstract class Editor<T> extends JPanel
{
@@ -19,19 +28,51 @@ public abstract class Editor<T> extends JPanel
protected T mItem;
protected boolean mModified = false;
protected Editor<?> mSaveRequestListener;
public Editor()
{
}
/**
* Requests to save the contents of this editor.
*
* If a save request listener is registered, the listener is notified that a save is requested,
* otherwise the save is request is processed by the instance.
*
* This allows for a save event to be percolated up the hierarchical set of editors so that
* a top-level editor can invoke custom operations such as configuration validation.
*/
protected void saveRequest()
{
if( mSaveRequestListener != null )
{
mSaveRequestListener.saveRequest();
}
else
{
save();
}
}
/**
* Registers the editor to be notified when this editor contents have been saved.
*/
public void setSaveRequestListener( Editor<?> listener )
{
mSaveRequestListener = listener;
}
/**
* Sets the object to be edited
* Sets the object to be edited. If the contents from the previous object have changed, this
* prompts the user to save these changes. A saveRequest() is issued and either this editor
* or the parent editor will respond to the save request and invoke the save() method.
*/
public void setItem( T item )
{
if( isModified() )
{
mLog.debug( "Editor that is modified: " + getClass() );
int option = JOptionPane.showConfirmDialog(
Editor.this,
"This item has changed. Do you want to save these changes?",
@@ -41,7 +82,7 @@ public abstract class Editor<T> extends JPanel
if( option == JOptionPane.YES_OPTION )
{
save();
saveRequest();
}
setModified( false );

View File

@@ -10,7 +10,7 @@ public class EmptyValidatingEditor<T> extends ValidatingEditor<T>
public EmptyValidatingEditor( String descriptor )
{
setLayout( new MigLayout( "insets 0 0 0 0", "[center]", "[grow]" ) );
setLayout( new MigLayout( "insets 0 0 0 0", "", "" ) );
add( new JLabel( "Please select " + descriptor ), "wrap" );
}