@Override
  public void reset() {
    List<X509Certificate> original = myTrustManager.getCertificates();
    myTreeBuilder.reset(original);

    myCertificates.clear();
    myCertificates.addAll(original);

    myDetailsPanel.removeAll();
    myDetailsPanel.add(myEmptyPanel, EMPTY_PANEL);

    // fill lower panel with cards
    for (X509Certificate certificate : original) {
      addCertificatePanel(certificate);
    }

    if (!myCertificates.isEmpty()) {
      myTreeBuilder.selectFirstCertificate();
    }

    CertificateManager.Config state = CertificateManager.getInstance().getState();
    myAcceptAutomatically.setSelected(state.ACCEPT_AUTOMATICALLY);
    myCheckHostname.setSelected(state.CHECK_HOSTNAME);
    myCheckValidityPeriod.setSelected(state.CHECK_VALIDITY);
  }
 @Override
 public void reset(CodeStyleSettings settings) {
   myEnabled.setSelected(settings.getCustomSettings(EditorConfigSettings.class).ENABLED);
 }
  public void reset() {
    EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
    UISettings uiSettings = UISettings.getInstance();
    VcsApplicationSettings vcsSettings = VcsApplicationSettings.getInstance();

    // Display

    myCbSmoothScrolling.setSelected(editorSettings.isSmoothScrolling());

    // Brace highlighting

    myCbHighlightBraces.setSelected(codeInsightSettings.HIGHLIGHT_BRACES);
    myCbHighlightScope.setSelected(codeInsightSettings.HIGHLIGHT_SCOPE);
    myCbHighlightIdentifierUnderCaret.setSelected(
        codeInsightSettings.HIGHLIGHT_IDENTIFIER_UNDER_CARET);

    // Virtual space

    myCbUseSoftWrapsAtEditor.setSelected(
        editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR));
    myCbUseCustomSoftWrapIndent.setSelected(editorSettings.isUseCustomSoftWrapIndent());
    myCustomSoftWrapIndent.setText(Integer.toString(editorSettings.getCustomSoftWrapIndent()));
    myCbShowSoftWrapsOnlyOnCaretLine.setSelected(!editorSettings.isAllSoftWrapsShown());
    updateSoftWrapSettingsRepresentation();

    myCbVirtualSpace.setSelected(editorSettings.isVirtualSpace());
    myCbCaretInsideTabs.setSelected(editorSettings.isCaretInsideTabs());
    myCbVirtualPageAtBottom.setSelected(editorSettings.isAdditionalPageAtBottom());

    // Limits
    myClipboardContentLimitTextField.setText(Integer.toString(uiSettings.MAX_CLIPBOARD_CONTENTS));

    // Strip trailing spaces on save

    String stripTrailingSpaces = editorSettings.getStripTrailingSpaces();
    if (EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE.equals(stripTrailingSpaces)) {
      myStripTrailingSpacesCombo.setSelectedItem(STRIP_NONE);
    } else if (EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED.equals(
        stripTrailingSpaces)) {
      myStripTrailingSpacesCombo.setSelectedItem(STRIP_CHANGED);
    } else if (EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE.equals(
        stripTrailingSpaces)) {
      myStripTrailingSpacesCombo.setSelectedItem(STRIP_ALL);
    }
    explainTrailingSpaces(stripTrailingSpaces);

    myCbEnsureBlankLineBeforeCheckBox.setSelected(editorSettings.isEnsureNewLineAtEOF());
    myCbShowQuickDocOnMouseMove.setSelected(editorSettings.isShowQuickDocOnMouseOverElement());
    myQuickDocDelayTextField.setText(
        Long.toString(editorSettings.getQuickDocOnMouseOverElementDelayMillis()));
    myQuickDocDelayTextField.setEnabled(editorSettings.isShowQuickDocOnMouseOverElement());
    myQuickDocDelayLabel.setEnabled(editorSettings.isShowQuickDocOnMouseOverElement());

    // Advanced mouse
    myCbEnableDnD.setSelected(editorSettings.isDndEnabled());
    myCbEnableWheelFontChange.setSelected(editorSettings.isWheelFontChangeEnabled());
    myCbHonorCamelHumpsWhenSelectingByClicking.setSelected(
        editorSettings.isMouseClickSelectionHonorsCamelWords());

    myRbPreferMovingCaret.setSelected(editorSettings.isRefrainFromScrolling());
    myRbPreferScrolling.setSelected(!editorSettings.isRefrainFromScrolling());

    myRecentFilesLimitField.setText(Integer.toString(uiSettings.RECENT_FILES_LIMIT));

    myCbRenameLocalVariablesInplace.setSelected(editorSettings.isVariableInplaceRenameEnabled());
    myPreselectCheckBox.setSelected(editorSettings.isPreselectRename());
    myShowInlineDialogForCheckBox.setSelected(editorSettings.isShowInlineLocalDialog());

    myShowNotificationAfterReformatCodeCheckBox.setSelected(
        editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION);
    myShowNotificationAfterOptimizeImportsCheckBox.setSelected(
        editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION);

    myShowLSTInGutterCheckBox.setSelected(vcsSettings.SHOW_LST_GUTTER_MARKERS);
    myShowWhitespacesModificationsInLSTGutterCheckBox.setSelected(
        vcsSettings.SHOW_WHITESPACES_IN_LST);
    myShowWhitespacesModificationsInLSTGutterCheckBox.setEnabled(
        myShowLSTInGutterCheckBox.isSelected());

    myErrorHighlightingPanel.reset();

    RichCopySettings settings = RichCopySettings.getInstance();
    myCbEnableRichCopyByDefault.setSelected(settings.isEnabled());
    myRichCopyColorSchemeComboBox.removeAllItems();
    EditorColorsScheme[] schemes = EditorColorsManager.getInstance().getAllSchemes();
    myRichCopyColorSchemeComboBox.addItem(RichCopySettings.ACTIVE_GLOBAL_SCHEME_MARKER);
    for (EditorColorsScheme scheme : schemes) {
      myRichCopyColorSchemeComboBox.addItem(scheme.getName());
    }
    String toSelect = settings.getSchemeName();
    if (!StringUtil.isEmpty(toSelect)) {
      myRichCopyColorSchemeComboBox.setSelectedItem(toSelect);
    }
  }
  protected FontOptions(@NotNull ColorAndFontOptions options, final String title) {
    setLayout(new MigLayout("ins 0, gap 5, flowx"));
    Insets borderInsets =
        new Insets(
            IdeBorderFactory.TITLED_BORDER_TOP_INSET,
            IdeBorderFactory.TITLED_BORDER_LEFT_INSET,
            0,
            IdeBorderFactory.TITLED_BORDER_RIGHT_INSET);
    setBorder(IdeBorderFactory.createTitledBorder(title, false, borderInsets));
    myOptions = options;
    add(myOnlyMonospacedCheckBox, "sgx b, sx 2");

    add(new JLabel(ApplicationBundle.message("primary.font")), "newline, ax right");
    add(myPrimaryCombo, "sgx b");
    add(new JLabel(ApplicationBundle.message("editbox.font.size")), "gapleft 20");
    add(myEditorFontSizeField);
    add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), "gapleft 20");
    add(myLineSpacingField);

    add(
        new JLabel(
            ApplicationBundle.message("label.fallback.fonts.list.description"),
            MessageType.INFO.getDefaultIcon(),
            SwingConstants.LEFT),
        "newline, sx 5");
    add(myUseSecondaryFontCheckbox, "newline, ax right");
    add(mySecondaryCombo, "sgx b");
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    myEnableLigaturesCheckbox.setBorder(null);
    panel.add(myEnableLigaturesCheckbox);
    myLigaturesInfoLinkLabel =
        new LinkLabel<Void>(
            ApplicationBundle.message("ligatures.more.info"),
            null,
            new LinkListener<Void>() {
              @Override
              public void linkSelected(LinkLabel aSource, Void aLinkData) {
                BrowserUtil.browse(
                    "https://confluence.jetbrains.com/display/IDEADEV/Support+for+Ligatures+in+Editor");
              }
            });
    myLigaturesInfoLinkLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    panel.add(myLigaturesInfoLinkLabel);
    add(panel, "newline, sx 2");

    myOnlyMonospacedCheckBox.setBorder(null);
    myUseSecondaryFontCheckbox.setBorder(null);
    mySecondaryCombo.setEnabled(false);

    myOnlyMonospacedCheckBox.setSelected(
        EditorColorsManager.getInstance().isUseOnlyMonospacedFonts());
    myOnlyMonospacedCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            EditorColorsManager.getInstance()
                .setUseOnlyMonospacedFonts(myOnlyMonospacedCheckBox.isSelected());
            myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
            mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
          }
        });
    myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    myPrimaryCombo.setRenderer(RENDERER);

    mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    mySecondaryCombo.setRenderer(RENDERER);

    myUseSecondaryFontCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mySecondaryCombo.setEnabled(myUseSecondaryFontCheckbox.isSelected());
            syncFontFamilies();
          }
        });
    ItemListener itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              syncFontFamilies();
            }
          }
        };
    myPrimaryCombo.addItemListener(itemListener);
    mySecondaryCombo.addItemListener(itemListener);

    ActionListener actionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            syncFontFamilies();
          }
        };
    myPrimaryCombo.addActionListener(actionListener);
    mySecondaryCombo.addActionListener(actionListener);

    myEditorFontSizeField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange || !SwingUtilities.isEventDispatchThread()) return;
                String selectedFont = myPrimaryCombo.getFontName();
                if (selectedFont != null) {
                  FontPreferences fontPreferences = getFontPreferences();
                  fontPreferences.register(selectedFont, getFontSizeFromField());
                }
                updateDescription(true);
              }
            });
    myEditorFontSizeField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              int value = Integer.parseInt(myEditorFontSizeField.getText());
              value += (up ? 1 : -1);
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_FONT_SIZE,
                      Math.max(OptionsConstants.MIN_EDITOR_FONT_SIZE, value));
              myEditorFontSizeField.setText(String.valueOf(value));
            } catch (NumberFormatException ignored) {
            }
          }
        });

    myLineSpacingField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange) return;
                float lineSpacing = getLineSpacingFromField();
                if (getLineSpacing() != lineSpacing) {
                  setCurrentLineSpacing(lineSpacing);
                }
                updateDescription(true);
              }
            });
    myLineSpacingField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              float value = Float.parseFloat(myLineSpacingField.getText());
              value += (up ? 1 : -1) * .1F;
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_LINE_SPACING,
                      Math.max(OptionsConstants.MIN_EDITOR_LINE_SPACING, value));
              myLineSpacingField.setText(String.format(Locale.ENGLISH, "%.1f", value));
            } catch (NumberFormatException ignored) {
            }
          }
        });
    myEnableLigaturesCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            getFontPreferences().setUseLigatures(myEnableLigaturesCheckbox.isSelected());
          }
        });
  }
 @Override
 public void reset() {
   myAttachToSingleProcessWithoutDialogBox.setSelected(
       mySettings.myAttachToSingleProcessWithoutDialog);
 }
  /** Checks whether a stash or sync is needed based on the chosen target and local state. */
  private void checkSyncStashState() {
    if (myProcessResultState == null) {
      LOG.error("unexpected result state during a check sync stash state");
      return;
    }
    mySyncResult = new ProjectRepositoryValidator(myProcessResultState).checkSyncStashState();

    if (mySyncResult.needsStash() && mySyncResult.needsSync()) {
      setOKButtonText(
          isContinued()
              ? GctBundle.getString("clouddebug.continuesession")
              : GctBundle.getString("clouddebug.attach"));
      mySyncStashCheckbox.setVisible(true);
      assert mySyncResult.getTargetSyncSHA() != null;
      mySyncStashCheckbox.setText(
          GctBundle.getString(
              "clouddebug.stash.local.changes.and.sync",
              mySyncResult.getTargetSyncSHA().substring(0, 7)));
      mySyncStashCheckbox.setSelected(true);
      myWarningLabel.setVisible(false);
      myWarningLabel2.setVisible(false);
      myInfoPanel.setVisible(true);
    } else if (mySyncResult.needsStash()) {
      setOKButtonText(
          isContinued()
              ? GctBundle.getString("clouddebug.continuesession")
              : GctBundle.getString("clouddebug.attach"));
      mySyncStashCheckbox.setVisible(true);
      mySyncStashCheckbox.setText(GctBundle.getString("clouddebug.stashbuttontext"));
      mySyncStashCheckbox.setSelected(true);
      myWarningLabel.setVisible(false);
      myWarningLabel2.setVisible(false);
      myInfoPanel.setVisible(true);
    } else if (mySyncResult.needsSync()) {
      setOKButtonText(
          isContinued()
              ? GctBundle.getString("clouddebug.continuesession")
              : GctBundle.getString("clouddebug.attach"));
      mySyncStashCheckbox.setVisible(true);
      assert mySyncResult.getTargetSyncSHA() != null;
      mySyncStashCheckbox.setText("Sync to " + mySyncResult.getTargetSyncSHA().substring(0, 7));
      mySyncStashCheckbox.setSelected(true);
      myWarningLabel.setVisible(false);
      myWarningLabel2.setVisible(false);
      myInfoPanel.setVisible(true);
    } else if (mySyncResult.needsSync() && mySyncResult.getTargetSyncSHA() == null) {
      setOKButtonText(
          isContinued()
              ? GctBundle.getString("clouddebug.continueanyway")
              : GctBundle.getString("clouddebug.attach.anyway"));
      myWarningLabel.setVisible(true);
      myWarningLabel2.setVisible(true);
      myInfoPanel.setVisible(true);
      myWarningLabel2.setText(GctBundle.getString("clouddebug.no.matching.sha"));
    } else if (!mySyncResult.hasRemoteRepository()) {
      setOKButtonText(
          isContinued()
              ? GctBundle.getString("clouddebug.continueanyway")
              : GctBundle.getString("clouddebug.attach.anyway"));
      myWarningLabel.setVisible(true);
      myWarningLabel2.setVisible(true);
      myInfoPanel.setVisible(true);
      if (mySyncResult.getRepositoryType() != null) {
        myWarningLabel2.setText(
            GctBundle.getString(
                "clouddebug.repositories.are.not.supported", mySyncResult.getRepositoryType()));
      } else {
        myWarningLabel2.setText(GctBundle.getString("clouddebug.no.remote.repository"));
      }
    } else {
      setOKButtonText(
          isContinued()
              ? GctBundle.getString("clouddebug.continuesession")
              : GctBundle.getString("clouddebug.attach"));
      mySyncStashCheckbox.setVisible(false);
      myWarningLabel.setVisible(false);
      myWarningLabel2.setVisible(false);
      myInfoPanel.setVisible(true);
    }
  }