Search in sources :

Example 6 with InputValidatorEx

use of com.intellij.openapi.ui.InputValidatorEx in project intellij-community by JetBrains.

the class InstanceFilterEditor method addClassFilter.

protected void addClassFilter() {
    String idString = Messages.showInputDialog(myProject, DebuggerBundle.message("add.instance.filter.dialog.prompt"), DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getQuestionIcon(), null, new InputValidatorEx() {

        @Nullable
        @Override
        public String getErrorText(String inputString) {
            try {
                //noinspection ResultOfMethodCallIgnored
                Long.parseLong(inputString);
                return null;
            } catch (NumberFormatException e) {
                return DebuggerBundle.message("add.instance.filter.dialog.error.numeric.value.expected");
            }
        }

        @Override
        public boolean checkInput(String inputString) {
            return getErrorText(inputString) == null;
        }

        @Override
        public boolean canClose(String inputString) {
            return getErrorText(inputString) == null;
        }
    });
    if (idString != null) {
        ClassFilter filter = createFilter(idString);
        myTableModel.addRow(filter);
        int row = myTableModel.getRowCount() - 1;
        myTable.getSelectionModel().setSelectionInterval(row, row);
        myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true));
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(myTable, true);
        });
    }
}
Also used : ClassFilter(com.intellij.ui.classFilter.ClassFilter) InputValidatorEx(com.intellij.openapi.ui.InputValidatorEx) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

InputValidatorEx (com.intellij.openapi.ui.InputValidatorEx)6 Nullable (org.jetbrains.annotations.Nullable)3 ProjectGroup (com.intellij.ide.ProjectGroup)1 ProjectGroupActionGroup (com.intellij.ide.ProjectGroupActionGroup)1 FileTemplate (com.intellij.ide.fileTemplates.FileTemplate)1 JavaCreateFromTemplateHandler (com.intellij.ide.fileTemplates.JavaCreateFromTemplateHandler)1 FileSystemTreeImpl (com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 ClassFilter (com.intellij.ui.classFilter.ClassFilter)1 JBList (com.intellij.ui.components.JBList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1