@Override
 protected void paintComponent(Graphics g) {
   if (myFocusRequestor != null) {
     if (myFocusRequestor.isFocusOwner()) {
       myFocusRequestor = null;
     } else {
       myFocusRequestor.requestFocusInWindow();
     }
   }
   super.paintComponent(g);
 }
  public ArrangementSettingsPanel(@NotNull CodeStyleSettings settings, @NotNull Language language) {
    super(settings);
    myLanguage = language;
    Rearranger<?> rearranger = Rearranger.EXTENSION.forLanguage(language);

    assert rearranger instanceof ArrangementStandardSettingsAware;
    mySettingsAware = (ArrangementStandardSettingsAware) rearranger;

    final ArrangementColorsProvider colorsProvider;
    if (rearranger instanceof ArrangementColorsAware) {
      colorsProvider = new ArrangementColorsProviderImpl((ArrangementColorsAware) rearranger);
    } else {
      colorsProvider = new ArrangementColorsProviderImpl(null);
    }

    ArrangementStandardSettingsManager settingsManager =
        new ArrangementStandardSettingsManager(mySettingsAware, colorsProvider);

    myGroupingRulesPanel = new ArrangementGroupingRulesPanel(settingsManager, colorsProvider);
    myMatchingRulesPanel =
        new ArrangementMatchingRulesPanel(myLanguage, settingsManager, colorsProvider);

    myContent.add(
        myGroupingRulesPanel, new GridBag().coverLine().fillCellHorizontally().weightx(1));
    myContent.add(myMatchingRulesPanel, new GridBag().fillCell().weightx(1).weighty(1).coverLine());

    if (settings.getCommonSettings(myLanguage).isForceArrangeMenuAvailable()) {
      myForceArrangementPanel = new ForceArrangementPanel();
      myForceArrangementPanel.setSelectedMode(
          settings.getCommonSettings(language).FORCE_REARRANGE_MODE);
      myContent.add(
          myForceArrangementPanel.getPanel(),
          new GridBag().anchor(GridBagConstraints.WEST).coverLine().fillCellHorizontally());
    } else {
      myForceArrangementPanel = null;
    }

    final List<CompositeArrangementSettingsToken> groupingTokens =
        settingsManager.getSupportedGroupingTokens();
    myGroupingRulesPanel.setVisible(groupingTokens != null && !groupingTokens.isEmpty());

    registerShortcut(
        ArrangementConstants.MATCHING_RULE_ADD, CommonShortcuts.getNew(), myMatchingRulesPanel);
    registerShortcut(
        ArrangementConstants.MATCHING_RULE_REMOVE,
        CommonShortcuts.getDelete(),
        myMatchingRulesPanel);
    registerShortcut(
        ArrangementConstants.MATCHING_RULE_MOVE_UP, CommonShortcuts.MOVE_UP, myMatchingRulesPanel);
    registerShortcut(
        ArrangementConstants.MATCHING_RULE_MOVE_DOWN,
        CommonShortcuts.MOVE_DOWN,
        myMatchingRulesPanel);
    final CustomShortcutSet edit = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    registerShortcut(ArrangementConstants.MATCHING_RULE_EDIT, edit, myMatchingRulesPanel);

    registerShortcut(
        ArrangementConstants.GROUPING_RULE_MOVE_UP, CommonShortcuts.MOVE_UP, myGroupingRulesPanel);
    registerShortcut(
        ArrangementConstants.GROUPING_RULE_MOVE_DOWN,
        CommonShortcuts.MOVE_DOWN,
        myGroupingRulesPanel);
  }