package com.fangxuele.tool.push.ui.listener;

import com.fangxuele.tool.push.App;
import com.fangxuele.tool.push.logic.MessageTypeEnum;
import com.fangxuele.tool.push.ui.form.MessageTypeForm;

import static com.fangxuele.tool.push.ui.form.MessageTypeForm.messageTypeForm;

/**
 * <pre>
 * 消息类型form事件监听
 * </pre>
 *
 * @author <a href="https://github.com/rememberber">RememBerBer</a>
 * @since 2019/5/10.
 */
public class MessageTypeListener {

    public static void addListeners() {
        messageTypeForm.getMpTemplateRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.MP_TEMPLATE_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getMaTemplateRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.MA_TEMPLATE_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getKefuRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.KEFU_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getKefuPriorityRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.KEFU_PRIORITY_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getAliYunRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.ALI_YUN_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getAliTemplateRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.ALI_TEMPLATE_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getTxYunRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.TX_YUN_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getYunPianRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.YUN_PIAN_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getUpYunRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.UP_YUN_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getHwYunRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.HW_YUN_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
        messageTypeForm.getEMailRadioButton().addActionListener(e -> {
            App.config.setMsgType(MessageTypeEnum.EMAIL_CODE);
            App.config.save();
            MessageTypeForm.init();
        });
    }
}

@@ -638,59 +638,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -819,59 +819,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -987,59 +987,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -1172,59 +1172,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -1345,59 +1345,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -1528,59 +1528,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -1699,59 +1699,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -1874,59 +1874,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -2045,59 +2045,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -2216,59 +2216,16 @@
     
-App.config.save();%0A            MessageTypeForm.init
+saveType
 ();%0A
@@ -2366,32 +2366,138 @@
 MAIL_CODE);%0A    
+        saveType();%0A        %7D);%0A    %7D%0A%0A    /**%0A     * %E4%BF%9D%E5%AD%98%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%0A     */%0A    private static void saveType() %7B%0A
         App.conf
@@ -2515,20 +2515,16 @@
         
- 
-   
 MessageT
@@ -2535,32 +2535,20 @@
 orm.init();%0A
-        %7D);%0A
     %7D%0A%7D%0A

refactor:消息类型save