@Test public void testDefaultGroupingFilter() { final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME); final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME); final StdArrangementSettings settings = new StdArrangementSettings(); settings.addGrouping(groupingRule); settings.addRule(rule); final StdArrangementSettings defaultSettings = new StdArrangementSettings(); defaultSettings.addGrouping(groupingRule); final Element holder = doSerializationTest(settings, defaultSettings); assertTrue(holder.getChildren().size() == 1); assertNull(holder.getChild("groups")); assertNotNull(holder.getChild("rules")); }
@Test public void testDefaultRulesFilter() { final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME); final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME); final StdArrangementSettings settings = new StdArrangementSettings(); settings.addGrouping(groupingRule); settings.addRule(rule); final StdArrangementSettings defaultSettings = new StdArrangementSettings(); defaultSettings.addRule(rule); final Element holder = doSerializationTest(settings, defaultSettings); assertTrue(holder.getChildren().size() == 1); assertNotNull(holder.getChild("groups")); assertNull(holder.getChild("rules")); }
@Test public void testEmptyRules() throws Exception { final StdArrangementSettings settings = new StdArrangementSettings(); settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME)); final StdArrangementSettings defaultSettings = new StdArrangementSettings(); final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME); defaultSettings.addRule(rule); final Element holder = doSerializationTest(settings, defaultSettings); assertTrue(holder.getChildren().size() == 2); final Element rules = holder.getChild("rules"); assertNotNull(rules); assertTrue(rules.getChildren().isEmpty()); }
@Override public List<ArrangementSectionRule> getExtendedSectionRules() { synchronized (myExtendedSectionRules) { if (myExtendedSectionRules.isEmpty()) { final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition = new THashMap<String, StdArrangementRuleAliasToken>(myRulesAliases.size()); for (StdArrangementRuleAliasToken alias : myRulesAliases) { final String id = alias.getId(); tokenIdToDefinition.put(id, alias); } final List<ArrangementSectionRule> sections = getSections(); for (ArrangementSectionRule section : sections) { final List<StdArrangementMatchRule> extendedRules = new ArrayList<StdArrangementMatchRule>(); for (StdArrangementMatchRule rule : section.getMatchRules()) { appendExpandedRules(rule, extendedRules, tokenIdToDefinition); } myExtendedSectionRules.add(ArrangementSectionRule.create(section.getStartComment(), section.getEndComment(), extendedRules)); } } } return myExtendedSectionRules; }
public void appendExpandedRules(@NotNull final StdArrangementMatchRule rule, @NotNull final List<StdArrangementMatchRule> rules, @NotNull final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition) { final List<StdArrangementMatchRule> sequence = getRuleSequence(rule, tokenIdToDefinition); if (sequence == null || sequence.isEmpty()) { rules.add(rule); return; } final ArrangementCompositeMatchCondition ruleTemplate = removeAliasRuleToken(rule.getMatcher().getCondition()); for (StdArrangementMatchRule matchRule : sequence) { final ArrangementCompositeMatchCondition extendedRule = ruleTemplate.clone(); extendedRule.addOperand(matchRule.getMatcher().getCondition()); rules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(extendedRule))); } }
private static void appendBufferedSectionRules(@NotNull List<ArrangementSectionRule> result, @NotNull List<StdArrangementMatchRule> buffer, @Nullable String currentSectionStart) { if (currentSectionStart == null) { return; } if (buffer.isEmpty()) { result.add(ArrangementSectionRule.create(currentSectionStart, null)); } else { result.add(ArrangementSectionRule.create(currentSectionStart, null, buffer.get(0))); for (int j = 1; j < buffer.size(); j++) { result.add(ArrangementSectionRule.create(buffer.get(j))); } buffer.clear(); } }
@Nullable protected String validate(int index) { if (myRulesModel.getSize() < index) { return null; } final Object target = myRulesModel.getElementAt(index); if (target instanceof StdArrangementMatchRule) { for (int i = 0; i < index; i++) { final Object element = myRulesModel.getElementAt(i); if (element instanceof StdArrangementMatchRule && target.equals(element)) { return ApplicationBundle.message("arrangement.settings.validation.duplicate.matching.rule"); } } } return null; }
public void appendExpandedRules(@Nonnull final StdArrangementMatchRule rule, @Nonnull final List<StdArrangementMatchRule> rules, @Nonnull final Map<String, StdArrangementRuleAliasToken> tokenIdToDefinition) { final List<StdArrangementMatchRule> sequence = getRuleSequence(rule, tokenIdToDefinition); if (sequence == null || sequence.isEmpty()) { rules.add(rule); return; } final ArrangementCompositeMatchCondition ruleTemplate = removeAliasRuleToken(rule.getMatcher().getCondition()); for (StdArrangementMatchRule matchRule : sequence) { final ArrangementCompositeMatchCondition extendedRule = ruleTemplate.clone(); extendedRule.addOperand(matchRule.getMatcher().getCondition()); rules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(extendedRule))); } }
private static void appendBufferedSectionRules(@Nonnull List<ArrangementSectionRule> result, @Nonnull List<StdArrangementMatchRule> buffer, @Nullable String currentSectionStart) { if (currentSectionStart == null) { return; } if (buffer.isEmpty()) { result.add(ArrangementSectionRule.create(currentSectionStart, null)); } else { result.add(ArrangementSectionRule.create(currentSectionStart, null, buffer.get(0))); for (int j = 1; j < buffer.size(); j++) { result.add(ArrangementSectionRule.create(buffer.get(j))); } buffer.clear(); } }
private static void and(@NotNull List<StdArrangementMatchRule> matchRules, @NotNull ArrangementSettingsToken... conditions) { if(conditions.length == 1) { matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(conditions[0], conditions[0])))); return; } ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition(); for(ArrangementSettingsToken condition : conditions) { composite.addOperand(new ArrangementAtomMatchCondition(condition, condition)); } matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(composite))); }
private static void and(@NotNull List<StdArrangementMatchRule> matchRules, @NotNull ArrangementSettingsToken... conditions) { if (conditions.length == 1) { matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition( conditions[0] )))); return; } ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition(); for (ArrangementSettingsToken condition : conditions) { composite.addOperand(new ArrangementAtomMatchCondition(condition)); } matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(composite))); }
@NotNull protected static StdArrangementMatchRule nameRule(@NotNull String nameFilter, @NotNull ArrangementSettingsToken... tokens) { if (tokens.length == 0) { return new StdArrangementMatchRule(new StdArrangementEntryMatcher(atom(nameFilter))); } else { ArrangementAtomMatchCondition[] conditions = new ArrangementAtomMatchCondition[tokens.length + 1]; conditions[0] = atom(nameFilter); for (int i = 0; i < tokens.length; i++) conditions[i + 1] = atom(tokens[i]); ArrangementMatchCondition compositeCondition = ArrangementUtil.combine(conditions); return new StdArrangementMatchRule(new StdArrangementEntryMatcher(compositeCondition)); } }
@NotNull protected static StdArrangementMatchRule rule(@NotNull ArrangementSettingsToken... conditions) { return rule(ContainerUtil.map(conditions, new Function<ArrangementSettingsToken, ArrangementAtomMatchCondition>() { @Override public ArrangementAtomMatchCondition fun(ArrangementSettingsToken it) { return atom(it); } })); }
protected List<ArrangementSectionRule> getSectionRules(List<?> rules) { List<ArrangementSectionRule> sectionRules = Collections.emptyList(); if (rules != null) sectionRules = ContainerUtil.map(rules, new Function<Object, ArrangementSectionRule>() { @Override public ArrangementSectionRule fun(Object o) { return o instanceof ArrangementSectionRule ? (ArrangementSectionRule)o : ArrangementSectionRule.create((StdArrangementMatchRule)o); } }); return sectionRules; }
private static StdArrangementMatchRule rule(boolean byName, @NotNull ArrangementSettingsToken... tokens) { final List<ArrangementAtomMatchCondition> conditions = new ArrayList<ArrangementAtomMatchCondition>(); for (ArrangementSettingsToken token : tokens) { conditions.add(new ArrangementAtomMatchCondition(token)); } final StdArrangementEntryMatcher matcher = new StdArrangementEntryMatcher(new ArrangementCompositeMatchCondition(conditions)); return byName ? new StdArrangementMatchRule(matcher, BY_NAME) : new StdArrangementMatchRule(matcher); }
private static StdArrangementRuleAliasToken visibilityToken() { final ArrayList<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>(); rules.add(rule(false, PUBLIC)); rules.add(rule(false, PROTECTED)); rules.add(rule(false, PRIVATE)); return new StdArrangementRuleAliasToken(VISIBILITY, VISIBILITY, rules); }
private static StdArrangementRuleAliasToken modifiersToken() { final ArrayList<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>(); rules.add(rule(false, PUBLIC, STATIC)); rules.add(rule(false, PROTECTED, STATIC)); rules.add(rule(false, PRIVATE, STATIC)); rules.add(rule(false, PUBLIC)); rules.add(rule(false, PROTECTED)); rules.add(rule(false, PRIVATE)); return new StdArrangementRuleAliasToken(MODIFIERS, MODIFIERS, rules); }
@Test public void all() { final StdArrangementSettings settings = new StdArrangementSettings(); settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME)); final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME)); doSerializationTest(settings, new StdArrangementSettings()); }
@Test public void testDefaultFilter() { final StdArrangementSettings settings = new StdArrangementSettings(); settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME)); final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME)); final Element holder = doSerializationTest(settings, settings); assertTrue(holder.getChildren().isEmpty()); }
@Test public void testEmptyGroupings() throws Exception { final StdArrangementSettings settings = new StdArrangementSettings(); final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME)); final StdArrangementSettings defaultSettings = new StdArrangementSettings(); defaultSettings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME)); final Element holder = doSerializationTest(settings, defaultSettings); assertTrue(holder.getChildren().size() == 2); final Element groups = holder.getChild("groups"); assertNotNull(groups); assertTrue(groups.getChildren().isEmpty()); }
public static StdArrangementSettings createByMatchRules(@NotNull List<ArrangementGroupingRule> groupingRules, @NotNull List<StdArrangementMatchRule> matchRules) { final List<ArrangementSectionRule> sectionRules = new ArrayList<ArrangementSectionRule>(); for (StdArrangementMatchRule rule : matchRules) { sectionRules.add(ArrangementSectionRule.create(rule)); } return new StdArrangementSettings(groupingRules, sectionRules); }
public static StdArrangementExtendableSettings createByMatchRules(@NotNull List<ArrangementGroupingRule> groupingRules, @NotNull List<StdArrangementMatchRule> matchRules, @NotNull Collection<StdArrangementRuleAliasToken> rulesAliases) { final List<ArrangementSectionRule> sectionRules = new ArrayList<ArrangementSectionRule>(); for (StdArrangementMatchRule rule : matchRules) { sectionRules.add(ArrangementSectionRule.create(rule)); } return new StdArrangementExtendableSettings(groupingRules, sectionRules, rulesAliases); }
@Override protected StdArrangementRuleAliasToken clone() { final List<StdArrangementMatchRule> newValue = new ArrayList<StdArrangementMatchRule>(myDefinitionRules.size()); for (StdArrangementMatchRule rule : myDefinitionRules) { newValue.add(rule.clone()); } return new StdArrangementRuleAliasToken(getName(), newValue); }
public List<ArrangementSectionRule> getSections() { if (getModel().getSize() <= 0) { return Collections.emptyList(); } final List<ArrangementSectionRule> result = ContainerUtil.newArrayList(); final List<StdArrangementMatchRule> buffer = ContainerUtil.newArrayList(); String currentSectionStart = null; for (int i = 0; i < getModel().getSize(); i++) { final Object element = getModel().getElementAt(i); if (element instanceof StdArrangementMatchRule) { final ArrangementSectionRuleData sectionRule = mySectionRuleManager == null ? null : mySectionRuleManager.getSectionRuleData((StdArrangementMatchRule)element); if (sectionRule != null) { if (sectionRule.isSectionStart()) { appendBufferedSectionRules(result, buffer, currentSectionStart); currentSectionStart = sectionRule.getText(); } else { result.add(ArrangementSectionRule.create(StringUtil.notNullize(currentSectionStart), sectionRule.getText(), buffer)); buffer.clear(); currentSectionStart = null; } } else { if (currentSectionStart == null) { result.add(ArrangementSectionRule.create((StdArrangementMatchRule)element)); } else { buffer.add((StdArrangementMatchRule)element); } } } } appendBufferedSectionRules(result, buffer, currentSectionStart); return result; }
@NotNull public StdArrangementMatchRule createDefaultSectionRule() { final ArrangementAtomMatchCondition type = new ArrangementAtomMatchCondition(START_SECTION); final ArrangementAtomMatchCondition text = new ArrangementAtomMatchCondition(TEXT, createDefaultSectionText()); final ArrangementMatchCondition condition = ArrangementUtil.combine(type, text); return new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition)); }
public List<StdArrangementMatchRule> getRuleSequences() { final List<StdArrangementMatchRule> rulesSequences = new ArrayList<StdArrangementMatchRule>(); for (int i = 0; i < getModel().getSize(); i++) { Object element = getModel().getElementAt(i); if (element instanceof StdArrangementMatchRule) { rulesSequences.add((StdArrangementMatchRule)element); } } return rulesSequences; }
public void setRuleSequences(Collection<StdArrangementMatchRule> sequences) { myComponents.clear(); getModel().clear(); if (sequences == null) { return; } for (StdArrangementMatchRule rule : sequences) { getModel().add(rule); } }
public ArrangementAndMatchConditionComponent(@NotNull StdArrangementMatchRule rule, @NotNull ArrangementCompositeMatchCondition setting, @NotNull ArrangementMatchNodeComponentFactory factory, @NotNull ArrangementStandardSettingsManager manager, boolean allowModification) { mySetting = setting; setOpaque(false); setLayout(new GridBagLayout()); final Map<ArrangementSettingsToken, ArrangementMatchCondition> operands = ContainerUtilRt.newHashMap(); ArrangementMatchConditionVisitor visitor = new ArrangementMatchConditionVisitor() { @Override public void visit(@NotNull ArrangementAtomMatchCondition condition) { operands.put(condition.getType(), condition); } @Override public void visit(@NotNull ArrangementCompositeMatchCondition condition) { assert false; } }; for (ArrangementMatchCondition operand : setting.getOperands()) { operand.invite(visitor); } List<ArrangementSettingsToken> ordered = manager.sort(operands.keySet()); GridBagConstraints constraints = new GridBag().anchor(GridBagConstraints.EAST).insets(0, 0, 0, ArrangementConstants.HORIZONTAL_GAP); for (ArrangementSettingsToken key : ordered) { ArrangementMatchCondition operand = operands.get(key); assert operand != null; ArrangementUiComponent component = factory.getComponent(operand, rule, allowModification); myComponents.add(component); myAvailableTokens.addAll(component.getAvailableTokens()); JComponent uiComponent = component.getUiComponent(); add(uiComponent, constraints); } }
@NotNull public static StdArrangementMatchRule attrArrangementRule(@NotNull String nameFilter, @NotNull String namespaceFilter, @NotNull ArrangementSettingsToken orderType) { return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine( new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter), new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter) )), orderType); }
@Override public void apply(CodeStyleSettings settings) { final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(XmlFileType.INSTANCE); indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.INDENT_SIZE; XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class); xmlSettings.XML_ALIGN_ATTRIBUTES = false; xmlSettings.XML_SPACE_INSIDE_EMPTY_TAG = true; xmlSettings.XML_KEEP_LINE_BREAKS = false; final AndroidXmlCodeStyleSettings androidSettings = AndroidXmlCodeStyleSettings.getInstance(settings); androidSettings.USE_CUSTOM_SETTINGS = true; androidSettings.LAYOUT_SETTINGS = new AndroidXmlCodeStyleSettings.LayoutSettings(); androidSettings.MANIFEST_SETTINGS = new AndroidXmlCodeStyleSettings.ManifestSettings(); androidSettings.VALUE_RESOURCE_FILE_SETTINGS = new AndroidXmlCodeStyleSettings.ValueResourceFileSettings(); androidSettings.OTHER_SETTINGS = new AndroidXmlCodeStyleSettings.OtherSettings(); // arrangement final List<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>(); rules.add(attrArrangementRule("xmlns:android", "", KEEP)); rules.add(attrArrangementRule("xmlns:.*", "", BY_NAME)); rules.add(attrArrangementRule(".*:id", SdkConstants.NS_RESOURCES, KEEP)); rules.add(attrArrangementRule(".*:name", SdkConstants.NS_RESOURCES, KEEP)); rules.add(attrArrangementRule("name", "^$", KEEP)); rules.add(attrArrangementRule("style", "^$", KEEP)); rules.add(attrArrangementRule(".*", "^$", BY_NAME)); rules.add(attrArrangementRule(".*:layout_width", SdkConstants.NS_RESOURCES, KEEP)); rules.add(attrArrangementRule(".*:layout_height", SdkConstants.NS_RESOURCES, KEEP)); rules.add(attrArrangementRule(".*:layout_.*", SdkConstants.NS_RESOURCES, BY_NAME)); rules.add(attrArrangementRule(".*:width", SdkConstants.NS_RESOURCES, BY_NAME)); rules.add(attrArrangementRule(".*:height", SdkConstants.NS_RESOURCES, BY_NAME)); rules.add(attrArrangementRule(".*", SdkConstants.NS_RESOURCES, BY_NAME)); rules.add(attrArrangementRule(".*", ".*", BY_NAME)); // TODO: Should sort name:"color",namespace:"" to the end (primarily for color state lists) final CommonCodeStyleSettings xmlCommonSettings = settings.getCommonSettings(XMLLanguage.INSTANCE); xmlCommonSettings.setArrangementSettings( StdArrangementSettings.createByMatchRules(ContainerUtil.<ArrangementGroupingRule>emptyList(), rules)); xmlCommonSettings.FORCE_REARRANGE_MODE = CommonCodeStyleSettings.REARRANGE_ALWAYS; }
private static void and(@NotNull List<StdArrangementMatchRule> matchRules, @NotNull ArrangementSettingsToken... conditions) { if (conditions.length == 1) { matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition( conditions[0], conditions[0] )))); return; } ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition(); for (ArrangementSettingsToken condition : conditions) { composite.addOperand(new ArrangementAtomMatchCondition(condition, condition)); } matchRules.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(composite))); }
@Test public void all() { StdArrangementSettings settings = new StdRulePriorityAwareSettings(); settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME)); ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD); settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME)); Element holder = new Element("holder"); ArrangementSettingsSerializer instance = DefaultArrangementSettingsSerializer.INSTANCE; instance.serialize(settings, holder); ArrangementSettings restored = instance.deserialize(holder); assertEquals(settings, restored); }
@Override public void serialize(@NotNull ArrangementSettings s, @NotNull Element holder) { if (!(s instanceof StdArrangementSettings)) { return; } StdArrangementSettings settings = (StdArrangementSettings)s; List<ArrangementGroupingRule> groupings = settings.getGroupings(); if (!groupings.isEmpty()) { Element groupingsElement = new Element(GROUPS_ELEMENT_NAME); holder.addContent(groupingsElement); for (ArrangementGroupingRule group : groupings) { Element groupElement = new Element(GROUP_ELEMENT_NAME); groupingsElement.addContent(groupElement); groupElement.addContent(new Element(TYPE_ELEMENT_NAME).setText(group.getGroupingType().getId())); groupElement.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(group.getOrderType().getId())); } } List<StdArrangementMatchRule> rules = settings.getRules(); if (!rules.isEmpty()) { Element rulesElement = new Element(RULES_ELEMENT_NAME); holder.addContent(rulesElement); for (StdArrangementMatchRule rule : rules) { rulesElement.addContent(serialize(rule)); } } }
@NotNull public List<StdArrangementMatchRule> getRules() { if (getModel().getSize() <= 0) { return Collections.emptyList(); } List<StdArrangementMatchRule> result = new ArrayList<StdArrangementMatchRule>(); for (int i = 0; i < getModel().getSize(); i++) { Object element = getModel().getElementAt(i); if (element instanceof StdArrangementMatchRule) { result.add((StdArrangementMatchRule)element); } } return result; }
@NotNull private static List<StdArrangementMatchRule> copy(@NotNull List<StdArrangementMatchRule> rules) { List<StdArrangementMatchRule> result = new ArrayList<StdArrangementMatchRule>(); for (StdArrangementMatchRule rule : rules) { result.add(rule.clone()); } return result; }
public ArrangementAndMatchConditionComponent(@NotNull StdArrangementMatchRule rule, @NotNull ArrangementCompositeMatchCondition setting, @NotNull ArrangementMatchNodeComponentFactory factory, @NotNull ArrangementStandardSettingsManager manager) { mySetting = setting; setOpaque(false); setLayout(new GridBagLayout()); final Map<ArrangementSettingsToken, ArrangementMatchCondition> operands = ContainerUtilRt.newHashMap(); ArrangementMatchConditionVisitor visitor = new ArrangementMatchConditionVisitor() { @Override public void visit(@NotNull ArrangementAtomMatchCondition condition) { operands.put(condition.getType(), condition); } @Override public void visit(@NotNull ArrangementCompositeMatchCondition condition) { assert false; } }; for (ArrangementMatchCondition operand : setting.getOperands()) { operand.invite(visitor); } List<ArrangementSettingsToken> ordered = manager.sort(operands.keySet()); GridBagConstraints constraints = new GridBag().anchor(GridBagConstraints.EAST).insets(0, 0, 0, ArrangementConstants.HORIZONTAL_GAP); for (ArrangementSettingsToken key : ordered) { ArrangementMatchCondition operand = operands.get(key); assert operand != null; ArrangementUiComponent component = factory.getComponent(operand, rule, true); myComponents.add(component); myAvailableTokens.addAll(component.getAvailableTokens()); JComponent uiComponent = component.getUiComponent(); add(uiComponent, constraints); } }
public static StdArrangementSettings createByMatchRules(@Nonnull List<ArrangementGroupingRule> groupingRules, @Nonnull List<StdArrangementMatchRule> matchRules) { final List<ArrangementSectionRule> sectionRules = new ArrayList<ArrangementSectionRule>(); for (StdArrangementMatchRule rule : matchRules) { sectionRules.add(ArrangementSectionRule.create(rule)); } return new StdArrangementSettings(groupingRules, sectionRules); }