mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 16:17:24 -05:00
wip: #34
This commit is contained in:
@@ -5,9 +5,12 @@ import gui.editor.Editor;
|
||||
import gui.editor.EmptyEditor;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
@@ -24,6 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import source.SourceException;
|
||||
import source.tuner.configuration.TunerConfiguration;
|
||||
import source.tuner.configuration.TunerConfigurationFactory;
|
||||
import source.tuner.configuration.TunerConfigurationModel;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
@@ -90,6 +94,47 @@ public class TunerEditor extends Editor<Tuner>
|
||||
listPanel.add( mTunerConfigurationTable, "span" );
|
||||
|
||||
mNewConfigurationButton.setEnabled( false );
|
||||
mNewConfigurationButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
Tuner tuner = getItem();
|
||||
|
||||
int counter = 0;
|
||||
|
||||
String name = tuner.getUniqueID() + "-New";
|
||||
|
||||
while( counter < 10 && mTunerConfigurationModel
|
||||
.hasTunerConfiguration( tuner.getTunerType(), name ) )
|
||||
{
|
||||
counter++;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( tuner.getUniqueID() );
|
||||
sb.append( "-New(" );
|
||||
sb.append( String.valueOf( counter ) );
|
||||
sb.append( ")" );
|
||||
|
||||
name = sb.toString();
|
||||
}
|
||||
|
||||
if( counter < 10 )
|
||||
{
|
||||
TunerConfiguration config = TunerConfigurationFactory
|
||||
.getTunerConfiguration( tuner.getTunerType(), name );
|
||||
|
||||
mTunerConfigurationModel.addTunerConfiguration( config );
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( TunerEditor.this,
|
||||
"Can't create configuration - maximum limit reached",
|
||||
"Error",
|
||||
JOptionPane.OK_OPTION );
|
||||
}
|
||||
}
|
||||
} );
|
||||
listPanel.add( mNewConfigurationButton );
|
||||
|
||||
mDeleteConfigurationButton.setEnabled( false );
|
||||
|
||||
@@ -202,7 +202,7 @@ public class TunerConfigurationModel extends AbstractTableModel
|
||||
|
||||
if( configurationName == null )
|
||||
{
|
||||
configurationName = "Default-" + uniqueID;
|
||||
configurationName = uniqueID;
|
||||
}
|
||||
|
||||
List<TunerConfiguration> configs = getTunerConfigurations( type );
|
||||
@@ -229,6 +229,22 @@ public class TunerConfigurationModel extends AbstractTableModel
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public boolean hasTunerConfiguration( TunerType type, String name )
|
||||
{
|
||||
for( TunerConfiguration config: mTunerConfigurations )
|
||||
{
|
||||
if( config.getTunerType() == type &&
|
||||
config.getName().contentEquals( name ) )
|
||||
{
|
||||
mLog.debug( "Returning true for name: " + name );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
mLog.debug( "Returning false for name: " + name );
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the tuner configuration to the tuner identified by the uniqueID
|
||||
|
||||
Reference in New Issue
Block a user