Resolved #370 Tuner Editor Lock State

Resolves an issue with the previous implementation where the tuner
editor was being refreshed repeatedly to update the lock state for the
tuner, rendering the editor almost completely unusable.

Now updates only the frequency control and the sample rate control to
reflect the tuner's lock state.
This commit is contained in:
Denny
2018-07-15 05:55:28 -04:00
parent b3d5daea8b
commit 0d69f11e65
9 changed files with 75 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ import io.github.dsheirer.gui.control.JFrequencyControl;
import io.github.dsheirer.gui.editor.Editor;
import io.github.dsheirer.gui.editor.EmptyEditor;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationEditor;
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationFactory;
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationModel;
import net.miginfocom.swing.MigLayout;
@@ -66,6 +67,22 @@ public class TunerEditor extends Editor<Tuner>
init();
}
/**
* Updates the lock state of the tuner so that the frequency control and sample rate controls
* can be adjusted accordingly.
*
* @param locked true if the tuner is locked and the controls should be locked.
*/
public void setTunerLockState(boolean locked)
{
mFrequencyControl.setEnabled(!locked);
if(mEditor instanceof TunerConfigurationEditor)
{
((TunerConfigurationEditor)mEditor).setTunerLockState(locked);
}
}
public void init()
{
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));

View File

@@ -100,12 +100,20 @@ public class TunerViewPanel extends JPanel
switch(tunerEvent.getEvent())
{
case LOCK_STATE_CHANGE:
int row = mTunerTable.getSelectedRow();
if(row >= 0)
if(tunerEvent.getTuner() != null)
{
int modelRow = mTunerTable.convertRowIndexToModel(row);
mTunerEditor.setItem(mTunerModel.getTuner(modelRow));
int row = mTunerTable.getSelectedRow();
if(row >= 0)
{
int modelRow = mTunerTable.convertRowIndexToModel(row);
Tuner selectedTuner = mTunerModel.getTuner(modelRow);
if(selectedTuner == tunerEvent.getTuner())
{
mTunerEditor.setTunerLockState(selectedTuner.getTunerController().isLocked());
}
}
}
break;
}

View File

@@ -611,6 +611,12 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
}
}
@Override
public void setTunerLockState(boolean locked)
{
mSampleRateCombo.setEnabled(!locked);
}
/**
* Sets all controls to the argument enabled state
*/

View File

@@ -32,4 +32,12 @@ public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration
{
return mTunerConfigurationModel;
}
/**
* Sets the lock state for the tuner so that the frequency and sample rate controls can be
* enabled/disabled.
*
* @param locked true if the tuner is locked.
*/
public abstract void setTunerLockState(boolean locked);
}

View File

@@ -303,6 +303,12 @@ public class FCD1TunerEditor extends TunerConfigurationEditor
add(mCorrectionPhase);
}
@Override
public void setTunerLockState(boolean locked)
{
//no-op
}
/**
* Sets each of the tuner configuration controls to the enabled argument state
*/

View File

@@ -207,6 +207,12 @@ public class FCD2TunerEditor extends TunerConfigurationEditor
add(mMixerGain);
}
@Override
public void setTunerLockState(boolean locked)
{
//no-op
}
/**
* Sets each of the tuner configuration controls to the enabled argument state
*/

View File

@@ -298,6 +298,12 @@ public class HackRFTunerEditor extends TunerConfigurationEditor
}
}
@Override
public void setTunerLockState(boolean locked)
{
mComboSampleRate.setEnabled(!locked);
}
/**
* Sets each of the tuner configuration controls to the enabled argument state
*/

View File

@@ -355,6 +355,13 @@ public class E4KTunerEditor extends TunerConfigurationEditor
}
}
@Override
public void setTunerLockState(boolean locked)
{
mComboSampleRate.setEnabled(!locked);
}
/**
* Sets each of the tuner configuration controls to the enabled argument state
*/

View File

@@ -409,6 +409,12 @@ public class R820TTunerEditor extends TunerConfigurationEditor
}
}
@Override
public void setTunerLockState(boolean locked)
{
mComboSampleRate.setEnabled(!locked);
}
/**
* Sets each of the tuner configuration controls to the enabled argument state
*/