Please consider editing your post and mark it as obsolete instead. Do you want to delete post?
Provide Auto-complete in a text field(JTextField)
Permanently deleted user
Created
I have created a custom dialog(JDialog) with two JTextField and I want to provide auto complete feature in those text fields Any suggestions how to do that?
Thanks Yann for replying. I m new to idea's UI, So can you please explain, How can I use com.intellij.ui.TextFieldWithAutoCompletion instead of JTextField in JDialog ? As far as I have tried JDialog requires javax.swing components.
If I use it, it does not show the dialog and fails with the following exception :
Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null java.lang.IllegalArgumentException: Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null at com.intellij.psi.PsiDocumentManager.getInstance(PsiDocumentManager.java) at com.intellij.ui.TextFieldWithAutoCompletionContributor.installCompletion(TextFieldWithAutoCompletionContributor.java:55) at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:68) at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:56)
This is my dialog constructor and the exception says: error is in the first line of the constructor.
I debugged it and saw that the project was not null but still gives me the same exception.
Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null
at com.intellij.psi.PsiDocumentManager.getInstance(PsiDocumentManager.java)
at com.intellij.ui.TextFieldWithAutoCompletionContributor.installCompletion(TextFieldWithAutoCompletionContributor.java:55)
at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:68)
at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:56)
public ExtractConceptDialog(Project project) { this.textField1 = new com.intellij.ui.TextFieldWithAutoCompletion(project,new TextFieldWithAutoCompletionListProvider(Arrays.asList("HEHEHEH","AAAAA","BBBBB","Step")) { @Nullable @Override protected Icon getIcon(Object o) { return null; }
Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null java.lang.IllegalArgumentException: Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null at com.intellij.psi.PsiDocumentManager.getInstance(PsiDocumentManager.java) at com.intellij.ui.TextFieldWithAutoCompletionContributor.installCompletion(TextFieldWithAutoCompletionContributor.java:55) at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:68) at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:56) at com.thoughtworks.gauge.extract.ExtractConceptDialog.$$$setupUI$$$(ExtractConceptDialog.java) at com.thoughtworks.gauge.extract.ExtractConceptDialog.<init>(ExtractConceptDialog.java:19) at com.thoughtworks.gauge.extract.ExtractConceptInfoCollector.getAllInfo(ExtractConceptInfoCollector.java:29) at com.thoughtworks.gauge.extract.ExtractConceptHandler.invoke(ExtractConceptHandler.java:29) at com.intellij.refactoring.actions.BaseRefactoringAction.actionPerformed(BaseRefactoringAction.java:122) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:614) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:663) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:513) at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:211) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:546) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
try using passed in Project parameter from com.intellij.refactoring.RefactoringActionHandler#invoke(com.intellij.openapi.project.Project, com.intellij.openapi.editor.Editor, com.intellij.psi.PsiFile, com.intellij.openapi.actionSystem.DataContext)
Got it working....... I was missing the option "Custom create" for the auto complete field in the GUI form, that was why it was getting null as project Now I m initializing the field with the project and it works.... Thanks Yann for helping
see com.intellij.ui.TextFieldWithAutoCompletion
Thanks Yann for replying.
I m new to idea's UI, So can you please explain,
How can I use com.intellij.ui.TextFieldWithAutoCompletion instead of JTextField in JDialog ?
As far as I have tried JDialog requires javax.swing components.
What is the problem exactly? It inherits from JComponent so it"s a Swing component you can use as JTextField.
If I use it, it does not show the dialog and fails with the following exception :
Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null
at com.intellij.psi.PsiDocumentManager.getInstance(PsiDocumentManager.java)
at com.intellij.ui.TextFieldWithAutoCompletionContributor.installCompletion(TextFieldWithAutoCompletionContributor.java:55)
at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:68)
at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:56)
you must pass in Project parameter
public ExtractConceptDialog(Project project) {
this.textField1 = new com.intellij.ui.TextFieldWithAutoCompletion(project,new TextFieldWithAutoCompletionListProvider(Arrays.asList("HEHEHEH","AAAAA","BBBBB","Step")) {
@Nullable
@Override
protected Icon getIcon(Object o) {
return null;
}
@NotNull
@Override
protected String getLookupString(Object o) {
return "Lookup";
}
@Nullable
@Override
protected String getTailText(Object o) {
return "Tail";
}
@Nullable
@Override
protected String getTypeText(Object o) {
return "Type";
}
@Override
public int compare(Object o, Object t1) {
return 0;
}
},true,"");
setContentPane(contentPane);
setModal(true);
}
how do you call
show the whole stacktrace of exception, please
Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'project' of com/intellij/psi/PsiDocumentManager.getInstance must not be null
at com.intellij.psi.PsiDocumentManager.getInstance(PsiDocumentManager.java)
at com.intellij.ui.TextFieldWithAutoCompletionContributor.installCompletion(TextFieldWithAutoCompletionContributor.java:55)
at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:68)
at com.intellij.ui.TextFieldWithAutoCompletion.<init>(TextFieldWithAutoCompletion.java:56)
at com.thoughtworks.gauge.extract.ExtractConceptDialog.$$$setupUI$$$(ExtractConceptDialog.java)
at com.thoughtworks.gauge.extract.ExtractConceptDialog.<init>(ExtractConceptDialog.java:19)
at com.thoughtworks.gauge.extract.ExtractConceptInfoCollector.getAllInfo(ExtractConceptInfoCollector.java:29)
at com.thoughtworks.gauge.extract.ExtractConceptHandler.invoke(ExtractConceptHandler.java:29)
at com.intellij.refactoring.actions.BaseRefactoringAction.actionPerformed(BaseRefactoringAction.java:122)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:614)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:663)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.d(IdeKeyEventDispatcher.java:513)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:211)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:546)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
try using passed in Project parameter from com.intellij.refactoring.RefactoringActionHandler#invoke(com.intellij.openapi.project.Project, com.intellij.openapi.editor.Editor, com.intellij.psi.PsiFile, com.intellij.openapi.actionSystem.DataContext)
Got it working.......
I was missing the option "Custom create" for the auto complete field in the GUI form, that was why it was getting null as project
Now I m initializing the field with the project and it works....
Thanks Yann for helping