Search in sources :

Example 1 with ArrangementUiComponent

use of com.intellij.psi.codeStyle.arrangement.std.ArrangementUiComponent in project intellij-community by JetBrains.

the class ArrangementMatchNodeComponentFactory method getComponent.

/**
   * Allows to build UI component for the given model.
   *
   * @param rendererTarget      target model element for which UI component should be built
   * @param rule                rule which contains given 'renderer target' condition and serves as
   *                            a data entry for the target list model
   * @param allowModification   flag which indicates whether given model can be changed at future
   * @return renderer for the given model
   */
@NotNull
public ArrangementUiComponent getComponent(@NotNull final ArrangementMatchCondition rendererTarget, @NotNull final StdArrangementMatchRule rule, final boolean allowModification) {
    final Ref<ArrangementUiComponent> ref = new Ref<>();
    rendererTarget.invite(new ArrangementMatchConditionVisitor() {

        @Override
        public void visit(@NotNull ArrangementAtomMatchCondition condition) {
            RemoveAtomConditionCallback callback = allowModification ? new RemoveAtomConditionCallback(rule) : null;
            ArrangementUiComponent component = new ArrangementAtomMatchConditionComponent(mySettingsManager, myColorsProvider, condition, callback);
            ref.set(component);
        }

        @Override
        public void visit(@NotNull ArrangementCompositeMatchCondition condition) {
            ref.set(new ArrangementAndMatchConditionComponent(rule, condition, ArrangementMatchNodeComponentFactory.this, mySettingsManager, allowModification));
        }
    });
    return ref.get();
}
Also used : ArrangementUiComponent(com.intellij.psi.codeStyle.arrangement.std.ArrangementUiComponent) Ref(com.intellij.openapi.util.Ref) ArrangementMatchConditionVisitor(com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor) ArrangementAtomMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition) ArrangementAtomMatchConditionComponent(com.intellij.application.options.codeStyle.arrangement.component.ArrangementAtomMatchConditionComponent) ArrangementCompositeMatchCondition(com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition) ArrangementAndMatchConditionComponent(com.intellij.application.options.codeStyle.arrangement.component.ArrangementAndMatchConditionComponent) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ArrangementAndMatchConditionComponent (com.intellij.application.options.codeStyle.arrangement.component.ArrangementAndMatchConditionComponent)1 ArrangementAtomMatchConditionComponent (com.intellij.application.options.codeStyle.arrangement.component.ArrangementAtomMatchConditionComponent)1 Ref (com.intellij.openapi.util.Ref)1 ArrangementAtomMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition)1 ArrangementCompositeMatchCondition (com.intellij.psi.codeStyle.arrangement.model.ArrangementCompositeMatchCondition)1 ArrangementMatchConditionVisitor (com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchConditionVisitor)1 ArrangementUiComponent (com.intellij.psi.codeStyle.arrangement.std.ArrangementUiComponent)1 NotNull (org.jetbrains.annotations.NotNull)1