📄 sglconfiguration.java
字号:
objSGLModel.getSGL_MODE_SEL().getSoundType() ? 1 : 0);
cmbSGLMode.getCmb().setIndexValue(
objSGLModel.getSGL_MODE_SEL().getSGLMode());
cmbMuxAChannelSelect.getCmb().setIndexValue(
objSGLModel.getSGL_MODE_SEL().getMuxAChannelSelect());
cmbMuxBChannelSelect.getCmb().setIndexValue(
objSGLModel.getSGL_MODE_SEL().getMuxBChannelSelect());
txtPrescaler.getTextField().setText(
Long.toString(objSGLModel.getSGL_MODE_SEL().getPrescaler() + 1));
ProjectManager.getInstance().getSGLModel().isEnable_hex();
chkEnableHex.setSelected(objSGLModel.isEnable_hex());
boolean bolValue = chkEnableHex.isSelected();
setHexFlag(bolValue);
if(objSGLModel.isEnable_hex())
{
txtSoundDuration.getTextField().setText(
"0x"
+ ( Long.toHexString(objSGLModel.getSGL_SOUND_DUR()
.getSoundDuration()).toLowerCase() ));
}
else
{
txtSoundDuration.getTextField().setText(
Long.toString(objSGLModel.getSGL_SOUND_DUR().getSoundDuration()));
}
if(objSGLModel.isEnable_hex())
{
txtHighPeriod.getTextField().setText(
"0x"
+ ( Long.toHexString(objSGLModel.getSGL_HIGH_PER()
.getHighPeriod()).toLowerCase() ));
}
else
{
txtHighPeriod.getTextField().setText(
Long.toString(objSGLModel.getSGL_HIGH_PER().getHighPeriod()));
}
if(objSGLModel.isEnable_hex())
{
txtLowPeriod.getTextField().setText(
"0x"
+ ( Long.toHexString(objSGLModel.getSGL_LOW_PER()
.getLowPeriod()).toLowerCase() ));
}
else
{
txtLowPeriod.getTextField().setText(
Long.toString(objSGLModel.getSGL_LOW_PER().getLowPeriod()));
}
SGLModeValidation(SGLModeIndexValue);
SoundTypeValidation(SoundTypeIndexVal);
updateCalculationsOfLabels();
refreshForm();
}
void setButtonAction(RJButton button, boolean state)
{
button.updateStatus(!state, state ? "EN" : "DI");
}
boolean buttonAction(RJButton button)
{
boolean state = button.getText().equalsIgnoreCase("DI") ? true : false;
button.updateStatus(!state, state ? "EN" : "DI");
return state;
}
public void button_ActionPerformed(ActionEvent event)
{
SGLModel objSGLModel = SGLController.getInstance().getSGLModel();
if(event.getSource() == btnSoundGenerationCompleteInterrupt.getButton())
{
objSGLModel.getSGL_MODE_SEL().setSoundGenerationCompleteInterrupt(
buttonAction(btnSoundGenerationCompleteInterrupt.getButton()));
}
else if(event.getSource() == chkEnableHex)
{
objSGLModel.setEnable_hex(chkEnableHex.isSelected());
}
SGLController.getInstance().setSGLDirty(true);
refreshForm();
}
public void setHexFlag(Boolean bolVal)
{
if(bolVal)
{
txtSoundDuration.getTextField().setHexFlag(bolVal);
txtHighPeriod.getTextField().setHexFlag(bolVal);
txtLowPeriod.getTextField().setHexFlag(bolVal);
}
else
{
txtSoundDuration.getTextField().setHexFlag(false);
txtHighPeriod.getTextField().setHexFlag(false);
txtLowPeriod.getTextField().setHexFlag(false);
txtSoundDuration.getTextField().setNumericFlag(true);
txtHighPeriod.getTextField().setNumericFlag(true);
txtLowPeriod.getTextField().setNumericFlag(true);
}
}
public void loadHexValue_ItemStateChanged(ItemEvent event)
{
boolean bolValue = chkEnableHex.isSelected();
setHexFlag(bolValue);
SGLModel objSGLModel = SGLController.getInstance().getSGLModel();
objSGLModel.setEnable_hex(bolValue);
SGLController.getInstance().setSGLDirty(true);
updateUIFromControllerModel();
}
public void cmboBox_itemStateChanged(ItemEvent event)
{
SGLModel objSGLModel = SGLController.getInstance().getSGLModel();
RJComboBox source = (RJComboBox) event.getSource();
try
{
if(source == cmbSoundType.getCmb())
{
objSGLModel.getSGL_MODE_SEL().setSoundType(
cmbSoundType.getCmb().getSelectedIndex() != 0 ? true : false);
SoundTypeIndexVal = cmbSoundType.getCmb().getSelectedIndex();
SoundTypeValidation(SoundTypeIndexVal);
}
else if(source == cmbSGLMode.getCmb())
{
objSGLModel.getSGL_MODE_SEL().setSGLMode(
cmbSGLMode.getCmb().getIndexValue());
SGLModeIndexValue = cmbSGLMode.getCmb().getSelectedIndex();
SGLModeValidation(SGLModeIndexValue);
}
else if(source == cmbMuxAChannelSelect.getCmb())
{
objSGLModel.getSGL_MODE_SEL().setMuxAChannelSelect(
cmbMuxAChannelSelect.getCmb().getIndexValue());
}
else if(source == cmbMuxBChannelSelect.getCmb())
{
objSGLModel.getSGL_MODE_SEL().setMuxBChannelSelect(
cmbMuxBChannelSelect.getCmb().getIndexValue());
}
}
catch (Exception e)
{
logger.ERROR("Exception in " + this.getClass(), e);
}
SGLController.getInstance().setSGLDirty(true);
refreshForm();
}
public void EditBox_KeyTyped(KeyEvent event)
{
SGLController.getInstance().setSGLDirty(true);
refreshForm();
}
public void EditBox_Prescalar_FocusLost(FocusEvent event)
{
SGLModel objSGLModel = SGLController.getInstance().getSGLModel();
long val = 0;
JTextField txtField = ( (JTextField) event.getSource() );
String strVal = txtField.getText();
if(strVal != null)
{
if(strVal.length() != 0)
{
val = Long.decode(strVal).longValue();
}
}
if(txtField == txtPrescaler.getTextField())
{
strVal = txtPrescaler.getTextField().getText();
val = Long.decode(strVal).longValue();
objSGLModel.getSGL_MODE_SEL().setPrescaler(val - 1);
prescalerFlag = true;
updateCalculationsOfLabels();
}
refreshForm();
}
public void EditBox_Hex_FocusLost(FocusEvent event)
{
SGLModel objSGLModel = SGLController.getInstance().getSGLModel();
long val = 0;
JTextField txtField = ( (JTextField) event.getSource() );
String strVal = txtField.getText();
if(strVal != null)
{
if(strVal.length() != 0)
{
if(objSGLModel.isEnable_hex())
{
if(!( strVal.startsWith("0x") || strVal.startsWith("0X") ))
{
strVal = "0x" + strVal;
}
val = Long.decode(strVal).longValue();
}
else
{
val = Long.decode(strVal).longValue();
}
}
}
if(txtField == txtSoundDuration.getTextField())
{
strVal = txtSoundDuration.getTextField().getText();
if(objSGLModel.isEnable_hex())
{
if(!( strVal.startsWith("0x") || strVal.startsWith("0X") ))
{
strVal = "0x" + strVal;
}
val = Long.decode(strVal).longValue();
}
else
{
val = Long.decode(strVal).longValue();
}
objSGLModel.getSGL_SOUND_DUR().setSoundDuration(val);
if(objSGLModel.isEnable_hex())
{
txtSoundDuration.getTextField().setText(
"0x" + Long.toHexString(val).toLowerCase());
}
else
{
txtSoundDuration.getTextField().setText(Long.toString(val));
}
soundDurationFlag = true;
highPeriodFlag = false;
lowPeriodFlag = false;
prescalerFlag = false;
updateCalculationsOfLabels();
}
else if(txtField == txtHighPeriod.getTextField())
{
strVal = txtHighPeriod.getTextField().getText();
if(objSGLModel.isEnable_hex())
{
if(!( strVal.startsWith("0x") || strVal.startsWith("0X") ))
{
strVal = "0x" + strVal;
}
val = Long.decode(strVal).longValue();
}
else
{
val = Long.decode(strVal).longValue();
}
objSGLModel.getSGL_HIGH_PER().setHighPeriod(val);
if(objSGLModel.isEnable_hex())
{
txtHighPeriod.getTextField().setText(
"0x" + Long.toHexString(val).toLowerCase());
}
else
{
txtHighPeriod.getTextField().setText(Long.toString(val));
}
soundDurationFlag = false;
highPeriodFlag = true;
lowPeriodFlag = false;
prescalerFlag = false;
updateCalculationsOfLabels();
}
else if(txtField == txtLowPeriod.getTextField())
{
strVal = txtLowPeriod.getTextField().getText();
if(objSGLModel.isEnable_hex())
{
if(!( strVal.startsWith("0x") || strVal.startsWith("0X") ))
{
strVal = "0x" + strVal;
}
val = Long.decode(strVal).longValue();
}
else
{
val = Long.decode(strVal).longValue();
}
objSGLModel.getSGL_LOW_PER().setLowPeriod(val);
if(objSGLModel.isEnable_hex())
{
txtLowPeriod.getTextField().setText(
"0x" + Long.toHexString(val).toLowerCase());
}
else
{
txtLowPeriod.getTextField().setText(Long.toString(val));
}
soundDurationFlag = false;
highPeriodFlag = false;
lowPeriodFlag = true;
prescalerFlag = false;
updateCalculationsOfLabels();
}
refreshForm();
}
class ActionListener_SoundConfiguration implements ActionListener
{
private SGLConfiguration adaptee;
public ActionListener_SoundConfiguration(SGLConfiguration adpatee)
{
this.adaptee = adpatee;
}
public void actionPerformed(ActionEvent event)
{
adaptee.button_ActionPerformed(event);
}
}
class SoundConfig_ComboBox_ItemListener implements ItemListener
{
private SGLConfiguration adaptee;
public SoundConfig_ComboBox_ItemListener(SGLConfiguration adaptee)
{
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent event)
{
adaptee.cmboBox_itemStateChanged(event);
}
}
class SoundConfig_HexCheckBox_ItemListener implements ItemListener
{
private SGLConfiguration adaptee;
public SoundConfig_HexCheckBox_ItemListener(SGLConfiguration adaptee)
{
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent event)
{
adaptee.loadHexValue_ItemStateChanged(event);
}
}
class SoundConfigFocusLost_Prescalar_Adapter implements FocusListener
{
SGLConfiguration adaptee;
SoundConfigFocusLost_Prescalar_Adapter(SGLConfiguration form)
{
this.adaptee = form;
SGLController.getInstance().setSGLDirty(true);
}
public void focusLost(FocusEvent event)
{
adaptee.EditBox_Prescalar_FocusLost(event);
}
public void focusGained(FocusEvent arg0)
{
}
}
class SoundConfigFocusLostAdapter implements FocusListener
{
SGLConfiguration adaptee;
SoundConfigFocusLostAdapter(SGLConfiguration form)
{
this.adaptee = form;
SGLController.getInstance().setSGLDirty(true);
}
public void focusGained(FocusEvent event)
{
}
public void focusLost(FocusEvent event)
{
adaptee.EditBox_Hex_FocusLost(event);
}
}
class SoundConfigKeyListnerAdapter implements KeyListener
{
SGLConfiguration adaptee = null;
SoundConfigKeyListnerAdapter(SGLConfiguration adaptee)
{
this.adaptee = adaptee;
}
public void keyPressed(KeyEvent arg0)
{
}
public void keyReleased(KeyEvent event)
{
}
public void keyTyped(KeyEvent event)
{
adaptee.EditBox_KeyTyped(event);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -