IDEA-238356 Generic classes don't work in renderers - validation

GitOrigin-RevId: 2517d517f0c28463c43273345273bcdd39875cdc
This commit is contained in:
Egor Ushakov
2020-04-22 12:49:59 +00:00
committed by intellij-monorepo-bot
parent 7f869e4c84
commit 5f7efad07b
2 changed files with 22 additions and 16 deletions
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2020 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.debugger.settings;
import com.intellij.debugger.JavaDebuggerBundle;
@@ -27,8 +13,13 @@ import com.intellij.debugger.ui.JavaDebuggerSupport;
import com.intellij.debugger.ui.tree.render.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentValidator;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiTypeCodeFragmentImpl;
import com.intellij.ui.*;
@@ -129,12 +120,26 @@ class CompoundRendererConfigurable extends JPanel {
}
}
}, myProject);
myClassNameField.getEditorTextField().addFocusListener(new FocusAdapter() {
EditorTextField editorTextField = myClassNameField.getEditorTextField();
editorTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(@NotNull FocusEvent e) {
updateContext(myClassNameField.getText());
}
});
ComponentValidator validator = new ComponentValidator(myProject).withValidator(() -> {
String text = myClassNameField.getText();
if (StringUtil.containsAnyChar(text, "<>")) {
return new ValidationInfo(JavaDebuggerBundle.message("error.compound.renderer.configurable.fqn.generic"), editorTextField);
}
return null;
}).installOn(editorTextField);
myClassNameField.addDocumentListener(new DocumentListener() {
@Override
public void documentChanged(@NotNull DocumentEvent event) {
validator.revalidate();
}
});
myAppendDefaultChildren = new JBCheckBox(JavaDebuggerBundle.message("label.compound.renderer.configurable.append.default.children"));
@@ -220,6 +220,7 @@ label.compound.renderer.configurable.use.default.renderer=Use default renderer
label.compound.renderer.configurable.use.expression=Use following expression:
label.compound.renderer.configurable.use.expression.list=Use list of expressions:
label.compound.renderer.configurable.apply.to=Apply renderer to objects of type (fully-qualified name):
error.compound.renderer.configurable.fqn.generic=Generic type is not allowed
label.compound.renderer.configurable.when.rendering=When rendering a node
label.compound.renderer.configurable.when.expanding=When expanding a node
label.compound.renderer.configurable.test.can.expand=Test if a node can be expanded (optional):