Merge pull request #371 from DSheirer/370-tuner-editor-lock-state

Resolved #370 Tuner Editor Lock State
This commit is contained in:
Denny Sheirer
2018-07-15 05:55:46 -04:00
committed by GitHub
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.Editor;
import io.github.dsheirer.gui.editor.EmptyEditor; import io.github.dsheirer.gui.editor.EmptyEditor;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; 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.TunerConfigurationFactory;
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationModel; import io.github.dsheirer.source.tuner.configuration.TunerConfigurationModel;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
@@ -66,6 +67,22 @@ public class TunerEditor extends Editor<Tuner>
init(); 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() public void init()
{ {
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]")); 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()) switch(tunerEvent.getEvent())
{ {
case LOCK_STATE_CHANGE: case LOCK_STATE_CHANGE:
int row = mTunerTable.getSelectedRow(); if(tunerEvent.getTuner() != null)
if(row >= 0)
{ {
int modelRow = mTunerTable.convertRowIndexToModel(row); int row = mTunerTable.getSelectedRow();
mTunerEditor.setItem(mTunerModel.getTuner(modelRow));
if(row >= 0)
{
int modelRow = mTunerTable.convertRowIndexToModel(row);
Tuner selectedTuner = mTunerModel.getTuner(modelRow);
if(selectedTuner == tunerEvent.getTuner())
{
mTunerEditor.setTunerLockState(selectedTuner.getTunerController().isLocked());
}
}
} }
break; 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 * Sets all controls to the argument enabled state
*/ */

View File

@@ -32,4 +32,12 @@ public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration
{ {
return mTunerConfigurationModel; 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); add(mCorrectionPhase);
} }
@Override
public void setTunerLockState(boolean locked)
{
//no-op
}
/** /**
* Sets each of the tuner configuration controls to the enabled argument state * 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); add(mMixerGain);
} }
@Override
public void setTunerLockState(boolean locked)
{
//no-op
}
/** /**
* Sets each of the tuner configuration controls to the enabled argument state * 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 * 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 * 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 * Sets each of the tuner configuration controls to the enabled argument state
*/ */