content: package code.inspector.form.module;
  
  import code.inspector.core.Const;
  import com.intellij.uiDesigner.core.GridConstraints;
  import com.intellij.uiDesigner.core.GridLayoutManager;
  
  import javax.swing.*;
  import javax.swing.border.TitledBorder;
  import javax.swing.plaf.FontUIResource;
  import javax.swing.text.StyleContext;
  import java.awt.*;
  import java.util.HashMap;
  import java.util.Locale;
  
  public class SQLModule {
      public JPanel parentPanel;
      private JCheckBox jdbcTemplateUpdateCheckBox;
      private JTextArea templateUpdateArea;
      private JCheckBox jdbcTemplateExecuteCheckBox;
      private JTextArea templateExecuteArea;
      private JCheckBox jdbcTemplateQueryCheckBox;
      private JTextArea queryAnyArea;
      private JCheckBox executeQueryCheckBox;
      private JTextArea executeQueryArea;
      private JCheckBox executeUpdateCheckBox;
      private JCheckBox executeCheckBox;
      private JTextArea executeArea;
      private JTextArea executeUpdateArea;
      private JButton saveConfigButton;
  
      public SQLModule(HashMap<String, Boolean> option) {
          jdbcTemplateExecuteCheckBox.setSelected(option.getOrDefault(
                  Const.SQL_JDBC_TEMPLATE_EXECUTE, false));
          jdbcTemplateUpdateCheckBox.setSelected(option.getOrDefault(
                  Const.SQL_JDBC_TEMPLATE_UPDATE, false));
          jdbcTemplateQueryCheckBox.setSelected(option.getOrDefault(
                  Const.SQL_JDBC_TEMPLATE_QUERY_ANY, false));
          executeQueryCheckBox.setSelected(option.getOrDefault(
                  Const.SQL_EXECUTE_QUERY, false));
          executeUpdateCheckBox.setSelected(option.getOrDefault(
                  Const.SQL_EXECUTE_UPDATE, false));
          executeCheckBox.setSelected(option.getOrDefault(
                  Const.SQL_EXECUTE, false));
          saveConfigButton.addActionListener(e -> {
              option.put(Const.SQL_JDBC_TEMPLATE_EXECUTE, jdbcTemplateExecuteCheckBox.isSelected());
              option.put(Const.SQL_JDBC_TEMPLATE_UPDATE, jdbcTemplateUpdateCheckBox.isSelected());
              option.put(Const.SQL_JDBC_TEMPLATE_QUERY_ANY, jdbcTemplateQueryCheckBox.isSelected());
              option.put(Const.SQL_EXECUTE_QUERY, executeQueryCheckBox.isSelected());
              option.put(Const.SQL_EXECUTE_UPDATE, executeUpdateCheckBox.isSelected());
              option.put(Const.SQL_EXECUTE, executeCheckBox.isSelected());
              JOptionPane.showMessageDialog(parentPanel, "success!");
          });
      }
  
      {
  // GUI initializer generated by IntelliJ IDEA GUI Designer
  // >>> IMPORTANT!! <<<
  // DO NOT EDIT OR ADD ANY CODE HERE!
          $$$setupUI$$$();
      }
  
      /**
       * Method generated by IntelliJ IDEA GUI Designer
       * >>> IMPORTANT!! <<<
       * DO NOT edit this method OR call it in your code!
       *
       * @noinspection ALL
       */
      private void $$$setupUI$$$() {
          parentPanel = new JPanel();
          parentPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1));
          parentPanel.setBorder(BorderFactory.createTitledBorder(null, "SQL Injection Module", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
          jdbcTemplateUpdateCheckBox = new JCheckBox();
          jdbcTemplateUpdateCheckBox.setText("jdbc template update");
          parentPanel.add(jdbcTemplateUpdateCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          templateUpdateArea = new JTextArea();
          templateUpdateArea.setEditable(false);
          Font templateUpdateAreaFont = this.$$$getFont$$$("Consolas", -1, 12, templateUpdateArea.getFont());
          if (templateUpdateAreaFont != null) templateUpdateArea.setFont(templateUpdateAreaFont);
          templateUpdateArea.setForeground(new Color(-9097));
          templateUpdateArea.setText("String sql = \"sql\" + input + \"sql\";\njdbcTemplate.update(sql);");
          parentPanel.add(templateUpdateArea, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          jdbcTemplateExecuteCheckBox = new JCheckBox();
          jdbcTemplateExecuteCheckBox.setText("jdbc template execute");
          parentPanel.add(jdbcTemplateExecuteCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          templateExecuteArea = new JTextArea();
          templateExecuteArea.setEditable(false);
          Font templateExecuteAreaFont = this.$$$getFont$$$("Consolas", -1, 12, templateExecuteArea.getFont());
          if (templateExecuteAreaFont != null) templateExecuteArea.setFont(templateExecuteAreaFont);
          templateExecuteArea.setForeground(new Color(-9097));
          templateExecuteArea.setText("String sql = \"sql\" + input + \"sql\";\njdbcTemplate.execute(sql);");
          parentPanel.add(templateExecuteArea, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          jdbcTemplateQueryCheckBox = new JCheckBox();
          jdbcTemplateQueryCheckBox.setText("jdbc template query");
          parentPanel.add(jdbcTemplateQueryCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          queryAnyArea = new JTextArea();
          queryAnyArea.setEditable(false);
          Font queryAnyAreaFont = this.$$$getFont$$$("Consolas", -1, 12, queryAnyArea.getFont());
          if (queryAnyAreaFont != null) queryAnyArea.setFont(queryAnyAreaFont);
          queryAnyArea.setForeground(new Color(-9097));
          queryAnyArea.setText("String sql = \"sql\" + input + \"sql\";\njdbcTemplate.queryForList(sql);\njdbcTemplate.queryForMap(sql);\njdbcTemplate.queryForRowSet(sql);\njdbcTemplate.queryForStream(sql, new BeanPropertyRowMapper<>(User.class));\njdbcTemplate.query(sql, new BeanPropertyRowMapper<>(User.class));\njdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(User.class));");
          parentPanel.add(queryAnyArea, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          executeQueryCheckBox = new JCheckBox();
          executeQueryCheckBox.setText("execute query");
          parentPanel.add(executeQueryCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          executeQueryArea = new JTextArea();
          executeQueryArea.setEditable(false);
          Font executeQueryAreaFont = this.$$$getFont$$$("Consolas", -1, 12, executeQueryArea.getFont());
          if (executeQueryAreaFont != null) executeQueryArea.setFont(executeQueryAreaFont);
          executeQueryArea.setForeground(new Color(-9097));
          executeQueryArea.setText("String sql = \"sql\" + input + \"sql\";\nStatement stmt = conn.createStatement();\nstmt.executeQuery(sql);");
          parentPanel.add(executeQueryArea, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          executeUpdateCheckBox = new JCheckBox();
          executeUpdateCheckBox.setText("execute update");
          parentPanel.add(executeUpdateCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          executeUpdateArea = new JTextArea();
          executeUpdateArea.setEditable(false);
          Font executeUpdateAreaFont = this.$$$getFont$$$("Consolas", -1, 12, executeUpdateArea.getFont());
          if (executeUpdateAreaFont != null) executeUpdateArea.setFont(executeUpdateAreaFont);
          executeUpdateArea.setForeground(new Color(-9097));
          executeUpdateArea.setText("String sql = \"sql\" + input + \"sql\";\nStatement stmt = conn.createStatement();\nstmt.executeUpdate(sql);");
          parentPanel.add(executeUpdateArea, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          executeCheckBox = new JCheckBox();
          executeCheckBox.setText("execute");
          parentPanel.add(executeCheckBox, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          executeArea = new JTextArea();
          executeArea.setEditable(false);
          Font executeAreaFont = this.$$$getFont$$$("Consolas", -1, 12, executeArea.getFont());
          if (executeAreaFont != null) executeArea.setFont(executeAreaFont);
          executeArea.setForeground(new Color(-9097));
          executeArea.setText("String sql = \"sql\" + input + \"sql\";\nStatement stmt = conn.createStatement();\nstmt.execute(sql);");
          parentPanel.add(executeArea, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          saveConfigButton = new JButton();
          saveConfigButton.setText("Save Config");
          parentPanel.add(saveConfigButton, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
      }
  
      /**
       * @noinspection ALL
       */
      private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) {
          if (currentFont == null) return null;
          String resultName;
          if (fontName == null) {
              resultName = currentFont.getName();
          } else {
              Font testFont = new Font(fontName, Font.PLAIN, 10);
              if (testFont.canDisplay('a') && testFont.canDisplay('1')) {
                  resultName = fontName;
              } else {
                  resultName = currentFont.getName();
              }
          }
          Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
          boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
          Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
          return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
      }
  
      /**
       * @noinspection ALL
       */
      public JComponent $$$getRootComponent$$$() {
          return parentPanel;
      }
  
  }
  