private StdArrangementSettings createSettings() { final List<ArrangementGroupingRule> groupingRules = myGroupingRulesPanel.getRules(); final List<ArrangementSectionRule> sections = myMatchingRulesPanel.getSections(); final Collection<StdArrangementRuleAliasToken> tokens = myMatchingRulesPanel.getRulesAliases(); if (tokens != null) { return new StdArrangementExtendableSettings(groupingRules, sections, tokens); } return new StdArrangementSettings(groupingRules, sections); }
@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); } } }
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); }