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 DoSModule {
      public JPanel parentPanel;
      private JPanel dosModulePanel;
      private JCheckBox regexDosCheckBox;
      private JTextArea forDoSArea;
      private JCheckBox forLoopDosCheckBox;
      private JTextArea reDoSArea;
      private JCheckBox arrayInitDosCheckBox;
      private JTextArea arrDoSArea;
      private JCheckBox listInitDosCheckBox;
      private JTextArea listDoSArea;
      private JButton saveConfigButton;
  
      public DoSModule(HashMap<String, Boolean> dosOption) {
          forLoopDosCheckBox.setSelected(dosOption.getOrDefault(
                  Const.DOS_FOR_TYPE, false));
          arrayInitDosCheckBox.setSelected(dosOption.getOrDefault(
                  Const.DOS_ARRAY_TYPE, false));
          regexDosCheckBox.setSelected(dosOption.getOrDefault(
                  Const.DOS_REGEX_TYPE, false));
          listInitDosCheckBox.setSelected(dosOption.getOrDefault(
                  Const.DOS_LIST_TYPE, false));
          saveConfigButton.addActionListener(e -> {
              dosOption.put(Const.DOS_FOR_TYPE, forLoopDosCheckBox.isSelected());
              dosOption.put(Const.DOS_ARRAY_TYPE, arrayInitDosCheckBox.isSelected());
              dosOption.put(Const.DOS_REGEX_TYPE, regexDosCheckBox.isSelected());
              dosOption.put(Const.DOS_LIST_TYPE, listInitDosCheckBox.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(1, 1, new Insets(0, 0, 0, 0), -1, -1));
          dosModulePanel = new JPanel();
          dosModulePanel.setLayout(new GridLayoutManager(8, 3, new Insets(0, 0, 0, 0), -1, -1));
          parentPanel.add(dosModulePanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
          dosModulePanel.setBorder(BorderFactory.createTitledBorder(null, "DoS Module", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
          forDoSArea = new JTextArea();
          forDoSArea.setEditable(false);
          Font forDoSAreaFont = this.$$$getFont$$$("Consolas", -1, 12, forDoSArea.getFont());
          if (forDoSAreaFont != null) forDoSArea.setFont(forDoSAreaFont);
          forDoSArea.setForeground(new Color(-9097));
          forDoSArea.setText("for(int i=0;i<input;i++){\n   // code  \n}");
          dosModulePanel.add(forDoSArea, new GridConstraints(0, 2, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          reDoSArea = new JTextArea();
          reDoSArea.setEditable(false);
          Font reDoSAreaFont = this.$$$getFont$$$("Consolas", -1, 12, reDoSArea.getFont());
          if (reDoSAreaFont != null) reDoSArea.setFont(reDoSAreaFont);
          reDoSArea.setForeground(new Color(-9097));
          reDoSArea.setText("\nPattern.matches(\"input1\",\"input2\");");
          dosModulePanel.add(reDoSArea, new GridConstraints(3, 2, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          forLoopDosCheckBox = new JCheckBox();
          forLoopDosCheckBox.setText("for loop dos");
          dosModulePanel.add(forLoopDosCheckBox, new GridConstraints(0, 0, 3, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          regexDosCheckBox = new JCheckBox();
          regexDosCheckBox.setText("regex dos");
          dosModulePanel.add(regexDosCheckBox, new GridConstraints(3, 0, 2, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          arrayInitDosCheckBox = new JCheckBox();
          arrayInitDosCheckBox.setText("array init dos");
          dosModulePanel.add(arrayInitDosCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          arrDoSArea = new JTextArea();
          arrDoSArea.setEditable(false);
          Font arrDoSAreaFont = this.$$$getFont$$$("Consolas", -1, 12, arrDoSArea.getFont());
          if (arrDoSAreaFont != null) arrDoSArea.setFont(arrDoSAreaFont);
          arrDoSArea.setForeground(new Color(-9097));
          arrDoSArea.setText("int[] arr1 = new int[input1];\nObject arr2 = new int[input2];");
          dosModulePanel.add(arrDoSArea, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          listInitDosCheckBox = new JCheckBox();
          listInitDosCheckBox.setText("list init dos");
          dosModulePanel.add(listInitDosCheckBox, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
          listDoSArea = new JTextArea();
          listDoSArea.setEditable(false);
          Font listDoSAreaFont = this.$$$getFont$$$("Consolas", -1, 12, listDoSArea.getFont());
          if (listDoSAreaFont != null) listDoSArea.setFont(listDoSAreaFont);
          listDoSArea.setForeground(new Color(-9097));
          listDoSArea.setText("\nArrayList<?> list = new ArrayList<>(input);");
          dosModulePanel.add(listDoSArea, new GridConstraints(6, 2, 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");
          dosModulePanel.add(saveConfigButton, new GridConstraints(7, 0, 1, 3, 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;
      }
  
  }
  