SSR: load filter values before adding listeners to prevent modifying values (IDEA-205240)

This commit is contained in:
Bas Leijdekkers
2019-01-12 15:42:03 +01:00
parent 7167d943d1
commit 756e7fb607
2 changed files with 9 additions and 12 deletions
@@ -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
@@ -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();