コード例 #1
0
 @Override
 public boolean isModified(CodeStyleSettings settings) {
   final StdArrangementSettings s = createSettings();
   return !Comparing.equal(getSettings(settings), s)
       || myForceArrangementPanel != null
           && settings.getCommonSettings(myLanguage).FORCE_REARRANGE_MODE
               != myForceArrangementPanel.getRearrangeMode();
 }
コード例 #2
0
 @Override
 public void apply(CodeStyleSettings settings) {
   CommonCodeStyleSettings commonSettings = settings.getCommonSettings(myLanguage);
   commonSettings.setArrangementSettings(createSettings());
   if (myForceArrangementPanel != null) {
     commonSettings.FORCE_REARRANGE_MODE = myForceArrangementPanel.getRearrangeMode();
   }
 }
コード例 #3
0
  @Override
  protected void resetImpl(CodeStyleSettings settings) {
    StdArrangementSettings s = getSettings(settings);
    if (s == null) {
      myGroupingRulesPanel.setRules(null);
      myMatchingRulesPanel.setSections(null);
    } else {
      List<ArrangementGroupingRule> groupings = s.getGroupings();
      myGroupingRulesPanel.setRules(ContainerUtilRt.newArrayList(groupings));
      myMatchingRulesPanel.setSections(copy(s.getSections()));
      if (s instanceof StdArrangementExtendableSettings) {
        myMatchingRulesPanel.setRulesAliases(
            ((StdArrangementExtendableSettings) s).getRuleAliases());
      }

      if (myForceArrangementPanel != null) {
        myForceArrangementPanel.setSelectedMode(
            settings.getCommonSettings(myLanguage).FORCE_REARRANGE_MODE);
      }
    }
  }
コード例 #4
0
  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);
  }