From 756e7fb6070ee91cd95044403ce4efc55b9f10bd Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 11 Jan 2019 14:42:33 +0100 Subject: [PATCH] SSR: load filter values before adding listeners to prevent modifying values (IDEA-205240) --- .../plugin/ui/filters/CountFilter.java | 17 +++++++---------- .../plugin/ui/filters/FilterEditor.java | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/CountFilter.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/CountFilter.java index 556491c17f31..e891f074086a 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/CountFilter.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/CountFilter.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.structuralsearch.plugin.ui.filters; import com.intellij.psi.PsiElement; @@ -69,15 +69,6 @@ public class CountFilter extends FilterAction { private final JLabel myMinLabel = new JLabel("min="); private final JLabel myMaxLabel = new JLabel("max="); - { - myMinField.getValueEditor().addListener(newValue -> { - if (myMinField.getValueEditor().isValid(newValue) && myMaxField.getValue() < newValue) myMaxField.setValue(newValue); - }); - myMaxField.getValueEditor().addListener(newValue -> { - if (myMaxField.getValueEditor().isValid(newValue) && myMinField.getValue() > newValue) myMinField.setValue(newValue); - }); - } - @Override protected void layoutComponents() { final GroupLayout layout = new GroupLayout(this); @@ -99,6 +90,12 @@ public class CountFilter extends FilterAction { .addComponent(myMaxLabel) .addComponent(myMaxField) ); + myMinField.getValueEditor().addListener(newValue -> { + if (myMinField.getValueEditor().isValid(newValue) && myMaxField.getValue() < newValue) myMaxField.setValue(newValue); + }); + myMaxField.getValueEditor().addListener(newValue -> { + if (myMaxField.getValueEditor().isValid(newValue) && myMinField.getValue() > newValue) myMinField.setValue(newValue); + }); } @Override diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/FilterEditor.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/FilterEditor.java index 9e5b92bfeadd..9bb061a97994 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/FilterEditor.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/filters/FilterEditor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.structuralsearch.plugin.ui.filters; import com.intellij.structuralsearch.MatchVariableConstraint; @@ -29,8 +29,8 @@ public abstract class FilterEditor extends JBTableRowEditor { @Override public final void prepareEditor(JTable table, int row) { - layoutComponents(); loadValues(); + layoutComponents(); } protected abstract void layoutComponents();