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 RedirectModule {
      public JPanel parentPanel;
      private JCheckBox sendRedirectCheckBox;
      private JTextArea sendRedirectArea;
      private JCheckBox stringRedirectCheckBox;
      private JTextArea returnStringArea;
      private JCheckBox mavRedirectCheckBox;
      private JTextArea mavArea;
      private JButton saveConfigButton;
  
      public RedirectModule(HashMap<String, Boolean> redirectOption) {
          sendRedirectCheckBox.setSelected(redirectOption.getOrDefault(
                  Const.REDIRECT_SEND_RESPONSE_TYPE, false));
          stringRedirectCheckBox.setSelected(redirectOption.getOrDefault(
                  Const.REDIRECT_STRING_TYPE, false));
          mavRedirectCheckBox.setSelected(redirectOption.getOrDefault(
                  Const.REDIRECT_MODEL_AND_VIEW_TYPE, false));
          saveConfigButton.addActionListener(e -> {
              redirectOption.put(Const.REDIRECT_MODEL_AND_VIEW_TYPE, mavRedirectCheckBox.isSelected());
              redirectOption.put(Const.REDIRECT_STRING_TYPE, stringRedirectCheckBox.isSelected());
              redirectOption.put(Const.REDIRECT_SEND_RESPONSE_TYPE, sendRedirectCheckBox.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(4, 2, new Insets(0, 0, 0, 0), -1, -1));
          parentPanel.setBorder(BorderFactory.createTitledBorder(null, "Redirect Module", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
          sendRedirectCheckBox = new JCheckBox();
          sendRedirectCheckBox.setText("servlet send redirect");
          parentPanel.add(sendRedirectCheckBox, 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));
          sendRedirectArea = new JTextArea();
          sendRedirectArea.setEditable(false);
          Font sendRedirectAreaFont = this.$$$getFont$$$("Consolas", -1, 12, sendRedirectArea.getFont());
          if (sendRedirectAreaFont != null) sendRedirectArea.setFont(sendRedirectAreaFont);
          sendRedirectArea.setForeground(new Color(-9097));
          sendRedirectArea.setText("@RequestMapping(\"/redirect\")\npublic void redirect1(HttpServletRequest request,\n                      HttpServletResponse response) {\n    String newUrl = request.getParameter(\"input\");\n    response.sendRedirect(newUrl);\n}\n");
          parentPanel.add(sendRedirectArea, 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));
          stringRedirectCheckBox = new JCheckBox();
          stringRedirectCheckBox.setText("return string redirect");
          parentPanel.add(stringRedirectCheckBox, 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));
          returnStringArea = new JTextArea();
          returnStringArea.setEditable(false);
          Font returnStringAreaFont = this.$$$getFont$$$("Consolas", -1, 12, returnStringArea.getFont());
          if (returnStringAreaFont != null) returnStringArea.setFont(returnStringAreaFont);
          returnStringArea.setForeground(new Color(-9097));
          returnStringArea.setText("@RequestMapping(\"/redirect\")\npublic String redirect(String input) {\n    String redirect = \"redirect://\" + input;\n    return redirect;\n}");
          parentPanel.add(returnStringArea, 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));
          mavRedirectCheckBox = new JCheckBox();
          mavRedirectCheckBox.setText("model and view redirect");
          parentPanel.add(mavRedirectCheckBox, 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));
          mavArea = new JTextArea();
          mavArea.setEditable(false);
          Font mavAreaFont = this.$$$getFont$$$("Consolas", -1, 12, mavArea.getFont());
          if (mavAreaFont != null) mavArea.setFont(mavAreaFont);
          mavArea.setForeground(new Color(-9097));
          mavArea.setText("@RequestMapping(\"/redirect\")\npublic ModelAndView redirect(String input) {\n    String redirect = \"redirect://\" + input;\n    return new ModelAndView(redirect);\n}");
          parentPanel.add(mavArea, 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));
          saveConfigButton = new JButton();
          saveConfigButton.setText("Save Config");
          parentPanel.add(saveConfigButton, new GridConstraints(3, 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;
      }
  
  }
  