@Override
  public void initComponent() {
    myMode = Registry.get("ide.tooltip.mode");

    myIsEnabled = Registry.get("ide.tooltip.callout");
    myIsEnabled.addListener(
        new RegistryValueListener.Adapter() {
          @Override
          public void afterValueChanged(RegistryValue value) {
            processEnabled();
          }
        },
        ApplicationManager.getApplication());

    Toolkit.getDefaultToolkit()
        .addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);

    ActionManager.getInstance()
        .addAnActionListener(
            new AnActionListener.Adapter() {
              @Override
              public void beforeActionPerformed(
                  AnAction action, DataContext dataContext, AnActionEvent event) {
                hideCurrent(null, action, event);
              }
            },
            ApplicationManager.getApplication());

    processEnabled();
  }
  public static boolean isTooltipRequest(KeyEvent keyEvent) {
    if (ourTooltipKeysProperty == null) {
      ourTooltipKeysProperty = Registry.get("ide.forcedShowTooltip");
      ourTooltipKeysProperty.addListener(
          new RegistryValueListener.Adapter() {
            @Override
            public void afterValueChanged(RegistryValue value) {
              updateTooltipRequestKey(value);
            }
          },
          Disposer.get("ui"));

      updateTooltipRequestKey(ourTooltipKeysProperty);
    }

    if (keyEvent.getID() != KeyEvent.KEY_PRESSED) return false;

    for (Integer each : ourTooltipKeys) {
      if ((keyEvent.getModifiers() & each.intValue()) == 0) return false;
    }

    for (Integer each : ourOtherTooltipKeys) {
      if ((keyEvent.getModifiers() & each.intValue()) > 0) return false;
    }

    final int code = keyEvent.getKeyCode();

    return code == KeyEvent.VK_META
        || code == KeyEvent.VK_CONTROL
        || code == KeyEvent.VK_SHIFT
        || code == KeyEvent.VK_ALT;
  }
  public void runPostStartupActivities() {
    if (postStartupActivityPassed()) {
      return;
    }

    final Application app = ApplicationManager.getApplication();

    if (!app.isHeadlessEnvironment()) {
      checkFsSanity();
      checkProjectRoots();
    }

    runActivities(myDumbAwarePostStartupActivities);

    DumbService.getInstance(myProject)
        .runWhenSmart(
            new Runnable() {
              @Override
              public void run() {
                app.assertIsDispatchThread();

                // myDumbAwarePostStartupActivities might be non-empty if new activities were
                // registered during dumb mode
                runActivities(myDumbAwarePostStartupActivities);

                //noinspection SynchronizeOnThis
                synchronized (StartupManagerImpl.this) {
                  if (!myNotDumbAwarePostStartupActivities.isEmpty()) {
                    while (!myNotDumbAwarePostStartupActivities.isEmpty()) {
                      queueSmartModeActivity(myNotDumbAwarePostStartupActivities.remove(0));
                    }

                    // return here later to set myPostStartupActivitiesPassed
                    DumbService.getInstance(myProject).runWhenSmart(this);
                  } else {
                    myPostStartupActivitiesPassed = true;
                  }
                }
              }
            });

    // otherwise will be stored - we must not create config files in tests
    if (!app.isUnitTestMode()) {
      Registry.get("ide.firstStartup").setValue(false);
    }
  }
  public void initComponent() {
    myModifiersValue = Registry.get("actionSystem.quickAccessModifiers");
    myModifiersValue.addListener(
        new RegistryValueListener.Adapter() {
          public void afterValueChanged(RegistryValue value) {
            applyModifiersFromRegistry();
          }
        },
        this);

    KeymapManager kmMgr = KeymapManager.getInstance();
    kmMgr.addKeymapManagerListener(this);

    activeKeymapChanged(kmMgr.getActiveKeymap());

    applyModifiersFromRegistry();
  }
  @NotNull
  private static Color[] generateColorSequence(@NotNull TextAttributesScheme colorsScheme) {
    String colorDump =
        ApplicationManager.getApplication().isUnitTestMode()
            ? UNIT_TEST_COLORS
            : Registry.get("rainbow.highlighter.colors").asString();

    final List<String> registryColors = StringUtil.split(colorDump, ",");
    if (!registryColors.isEmpty()) {
      return registryColors.stream().map(s -> ColorUtil.fromHex(s.trim())).toArray(Color[]::new);
    }

    List<Color> stopColors =
        ContainerUtil.map(
            RAINBOW_COLOR_KEYS, key -> colorsScheme.getAttributes(key).getForegroundColor());
    List<Color> colors =
        ColorGenerator.generateLinearColorSequence(stopColors, RAINBOW_COLORS_BETWEEN);
    return colors.toArray(new Color[colors.size()]);
  }
  /** @noinspection UnusedParameters */
  public PyCharmEduInitialConfigurator(
      MessageBus bus,
      CodeInsightSettings codeInsightSettings,
      final PropertiesComponent propertiesComponent,
      FileTypeManager fileTypeManager,
      final ProjectManagerEx projectManager) {
    if (!propertiesComponent.getBoolean(CONFIGURED, false)) {
      propertiesComponent.setValue(CONFIGURED, "true");
      propertiesComponent.setValue("toolwindow.stripes.buttons.info.shown", "true");
      UISettings uiSettings = UISettings.getInstance();
      uiSettings.HIDE_TOOL_STRIPES = false;
      uiSettings.SHOW_MEMORY_INDICATOR = false;
      uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
      uiSettings.SHOW_MAIN_TOOLBAR = false;
      uiSettings.SHOW_NAVIGATION_BAR = false;
      codeInsightSettings.REFORMAT_ON_PASTE = CodeInsightSettings.NO_REFORMAT;

      Registry.get("ide.new.settings.dialog").setValue(true);

      GeneralSettings.getInstance().setShowTipsOnStartup(false);

      EditorSettingsExternalizable.getInstance().setVirtualSpace(false);
      EditorSettingsExternalizable.getInstance().getOptions().ARE_LINE_NUMBERS_SHOWN = true;
      final CodeStyleSettings settings =
          CodeStyleSettingsManager.getInstance().getCurrentSettings();
      settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
      settings.getCommonSettings(PythonLanguage.getInstance()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS =
          true;
      uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
      uiSettings.SHOW_MEMORY_INDICATOR = false;
      final String ignoredFilesList = fileTypeManager.getIgnoredFilesList();
      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  ApplicationManager.getApplication()
                      .runWriteAction(
                          new Runnable() {
                            @Override
                            public void run() {
                              FileTypeManager.getInstance()
                                  .setIgnoredFilesList(ignoredFilesList + ";*$py.class");
                            }
                          });
                }
              });
      PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP = false;
    }

    if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {

      bus.connect()
          .subscribe(
              AppLifecycleListener.TOPIC,
              new AppLifecycleListener.Adapter() {
                @Override
                public void welcomeScreenDisplayed() {

                  ApplicationManager.getApplication()
                      .invokeLater(
                          new Runnable() {
                            @Override
                            public void run() {
                              if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {
                                GeneralSettings.getInstance().setShowTipsOnStartup(false);
                                propertiesComponent.setValue(DISPLAYED_PROPERTY, "true");

                                patchKeymap();
                              }
                            }
                          });
                }
              });
    }

    bus.connect()
        .subscribe(
            ProjectManager.TOPIC,
            new ProjectManagerAdapter() {
              @Override
              public void projectOpened(final Project project) {
                if (project.isDefault()) return;
                if (FileChooserUtil.getLastOpenedFile(project) == null) {
                  FileChooserUtil.setLastOpenedFile(project, VfsUtil.getUserHomeDir());
                }

                patchProjectAreaExtensions(project);

                StartupManager.getInstance(project)
                    .runWhenProjectIsInitialized(
                        new DumbAwareRunnable() {
                          @Override
                          public void run() {
                            if (project.isDisposed()) return;

                            ToolWindowManager.getInstance(project)
                                .invokeLater(
                                    new Runnable() {
                                      int count = 0;

                                      public void run() {
                                        if (project.isDisposed()) return;
                                        if (count++
                                            < 3) { // we need to call this after
                                                   // ToolWindowManagerImpl.registerToolWindowsFromBeans
                                          ToolWindowManager.getInstance(project).invokeLater(this);
                                          return;
                                        }
                                        ToolWindow toolWindow =
                                            ToolWindowManager.getInstance(project)
                                                .getToolWindow("Project");
                                        if (toolWindow.getType() != ToolWindowType.SLIDING) {
                                          toolWindow.activate(null);
                                        }
                                      }
                                    });
                          }
                        });
              }
            });
  }
  @Override
  public void apply() {
    initComponent();
    UISettings settings = UISettings.getInstance();
    int _fontSize = getIntValue(myComponent.myFontSizeCombo, settings.FONT_SIZE);
    int _presentationFontSize =
        getIntValue(myComponent.myPresentationModeFontSize, settings.PRESENTATION_MODE_FONT_SIZE);
    boolean shouldUpdateUI = false;
    String _fontFace = (String) myComponent.myFontCombo.getSelectedItem();
    LafManager lafManager = LafManager.getInstance();
    if (_fontSize != settings.FONT_SIZE || !settings.FONT_FACE.equals(_fontFace)) {
      settings.FONT_SIZE = _fontSize;
      settings.FONT_FACE = _fontFace;
      shouldUpdateUI = true;
    }

    if (_presentationFontSize != settings.PRESENTATION_MODE_FONT_SIZE) {
      settings.PRESENTATION_MODE_FONT_SIZE = _presentationFontSize;
      shouldUpdateUI = true;
    }

    if (!myComponent.myAntialiasingInIDE.getSelectedItem().equals(settings.IDE_AA_TYPE)) {
      settings.IDE_AA_TYPE = (AntialiasingType) myComponent.myAntialiasingInIDE.getSelectedItem();
      shouldUpdateUI = true;
    }

    if (!myComponent.myAntialiasingInEditor.getSelectedItem().equals(settings.EDITOR_AA_TYPE)) {
      settings.EDITOR_AA_TYPE =
          (AntialiasingType) myComponent.myAntialiasingInEditor.getSelectedItem();
      shouldUpdateUI = true;
    }

    settings.ANIMATE_WINDOWS = myComponent.myAnimateWindowsCheckBox.isSelected();
    boolean update =
        settings.SHOW_TOOL_WINDOW_NUMBERS != myComponent.myWindowShortcutsCheckBox.isSelected();
    settings.SHOW_TOOL_WINDOW_NUMBERS = myComponent.myWindowShortcutsCheckBox.isSelected();
    update |= settings.HIDE_TOOL_STRIPES != !myComponent.myShowToolStripesCheckBox.isSelected();
    settings.HIDE_TOOL_STRIPES = !myComponent.myShowToolStripesCheckBox.isSelected();
    update |= settings.SHOW_ICONS_IN_MENUS != myComponent.myCbDisplayIconsInMenu.isSelected();
    settings.SHOW_ICONS_IN_MENUS = myComponent.myCbDisplayIconsInMenu.isSelected();
    update |=
        settings.SHOW_MEMORY_INDICATOR != myComponent.myShowMemoryIndicatorCheckBox.isSelected();
    settings.SHOW_MEMORY_INDICATOR = myComponent.myShowMemoryIndicatorCheckBox.isSelected();
    update |= settings.ALLOW_MERGE_BUTTONS != myComponent.myAllowMergeButtons.isSelected();
    settings.ALLOW_MERGE_BUTTONS = myComponent.myAllowMergeButtons.isSelected();
    update |= settings.CYCLE_SCROLLING != myComponent.myCycleScrollingCheckBox.isSelected();
    settings.CYCLE_SCROLLING = myComponent.myCycleScrollingCheckBox.isSelected();
    if (settings.OVERRIDE_NONIDEA_LAF_FONTS != myComponent.myOverrideLAFFonts.isSelected()) {
      shouldUpdateUI = true;
    }
    settings.OVERRIDE_NONIDEA_LAF_FONTS = myComponent.myOverrideLAFFonts.isSelected();
    settings.MOVE_MOUSE_ON_DEFAULT_BUTTON =
        myComponent.myMoveMouseOnDefaultButtonCheckBox.isSelected();
    settings.HIDE_NAVIGATION_ON_FOCUS_LOSS =
        myComponent.myHideNavigationPopupsCheckBox.isSelected();
    settings.DND_WITH_PRESSED_ALT_ONLY = myComponent.myAltDNDCheckBox.isSelected();

    update |= settings.DISABLE_MNEMONICS != myComponent.myDisableMnemonics.isSelected();
    settings.DISABLE_MNEMONICS = myComponent.myDisableMnemonics.isSelected();

    update |= settings.USE_SMALL_LABELS_ON_TABS != myComponent.myUseSmallLabelsOnTabs.isSelected();
    settings.USE_SMALL_LABELS_ON_TABS = myComponent.myUseSmallLabelsOnTabs.isSelected();

    update |= settings.WIDESCREEN_SUPPORT != myComponent.myWidescreenLayoutCheckBox.isSelected();
    settings.WIDESCREEN_SUPPORT = myComponent.myWidescreenLayoutCheckBox.isSelected();

    update |= settings.LEFT_HORIZONTAL_SPLIT != myComponent.myLeftLayoutCheckBox.isSelected();
    settings.LEFT_HORIZONTAL_SPLIT = myComponent.myLeftLayoutCheckBox.isSelected();

    update |= settings.RIGHT_HORIZONTAL_SPLIT != myComponent.myRightLayoutCheckBox.isSelected();
    settings.RIGHT_HORIZONTAL_SPLIT = myComponent.myRightLayoutCheckBox.isSelected();

    update |=
        settings.NAVIGATE_TO_PREVIEW
            != (myComponent.myNavigateToPreviewCheckBox.isVisible()
                && myComponent.myNavigateToPreviewCheckBox.isSelected());
    settings.NAVIGATE_TO_PREVIEW = myComponent.myNavigateToPreviewCheckBox.isSelected();

    ColorBlindness blindness = myComponent.myColorBlindnessPanel.getColorBlindness();
    boolean updateEditorScheme = false;
    if (settings.COLOR_BLINDNESS != blindness) {
      settings.COLOR_BLINDNESS = blindness;
      update = true;
      ComponentsPackage.getStateStore(ApplicationManager.getApplication())
          .reloadState(DefaultColorSchemesManager.class);
      updateEditorScheme = true;
    }

    update |=
        settings.DISABLE_MNEMONICS_IN_CONTROLS
            != myComponent.myDisableMnemonicInControlsCheckBox.isSelected();
    settings.DISABLE_MNEMONICS_IN_CONTROLS =
        myComponent.myDisableMnemonicInControlsCheckBox.isSelected();

    update |=
        settings.SHOW_ICONS_IN_QUICK_NAVIGATION
            != myComponent.myHideIconsInQuickNavigation.isSelected();
    settings.SHOW_ICONS_IN_QUICK_NAVIGATION = myComponent.myHideIconsInQuickNavigation.isSelected();

    if (!Comparing.equal(
        myComponent.myLafComboBox.getSelectedItem(), lafManager.getCurrentLookAndFeel())) {
      final UIManager.LookAndFeelInfo lafInfo =
          (UIManager.LookAndFeelInfo) myComponent.myLafComboBox.getSelectedItem();
      if (lafManager.checkLookAndFeel(lafInfo)) {
        update = shouldUpdateUI = true;
        final boolean wasDarcula = UIUtil.isUnderDarcula();
        lafManager.setCurrentLookAndFeel(lafInfo);
        //noinspection SSBasedInspection
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                if (UIUtil.isUnderDarcula()) {
                  DarculaInstaller.install();
                } else if (wasDarcula) {
                  DarculaInstaller.uninstall();
                }
              }
            });
      }
    }

    if (shouldUpdateUI) {
      lafManager.updateUI();
    }

    if (WindowManagerEx.getInstanceEx().isAlphaModeSupported()) {
      int delay = -1;
      try {
        delay = Integer.parseInt(myComponent.myAlphaModeDelayTextField.getText());
      } catch (NumberFormatException ignored) {
      }
      float ratio = myComponent.myAlphaModeRatioSlider.getValue() / 100f;
      if (myComponent.myEnableAlphaModeCheckBox.isSelected() != settings.ENABLE_ALPHA_MODE
          || delay != -1 && delay != settings.ALPHA_MODE_DELAY
          || ratio != settings.ALPHA_MODE_RATIO) {
        update = true;
        settings.ENABLE_ALPHA_MODE = myComponent.myEnableAlphaModeCheckBox.isSelected();
        settings.ALPHA_MODE_DELAY = delay;
        settings.ALPHA_MODE_RATIO = ratio;
      }
    }
    int tooltipDelay = Math.min(myComponent.myInitialTooltipDelaySlider.getValue(), 5000);
    if (tooltipDelay != Registry.intValue("ide.tooltip.initialDelay")) {
      update = true;
      Registry.get("ide.tooltip.initialDelay").setValue(tooltipDelay);
    }

    if (update) {
      settings.fireUISettingsChanged();
    }
    myComponent.updateCombo();

    EditorUtil.reinitSettings();

    if (updateEditorScheme) {
      EditorColorsManagerImpl.schemeChangedOrSwitched();
    }
  }