Dialog management for a settings window
I have a configuration screen for my plugin that loads when the user clicks on the icon that appears on the IntelliJ settings page. This works great and my JPanel displays and the user can interract with it fine. However, I have a button on this panel that brings up a JDialog. This doesn't work so well. The dialog seems to not be able to obtain focus and the user cannot properly interract with it. (I also tried a JFrame) Is this not the right way to do this for an IntelliJ plugin? It seems that there's some rules or design issues with dialog management in IntelliJ that I'm not aware of and I can't find any doc that talks about it.
请先登录再写评论。
Hello Marc,
MS> I have a configuration screen for my plugin that loads when the user
MS> clicks on the icon that appears on the IntelliJ settings page. This
MS> works great and my JPanel displays and the user can interract with
MS> it fine. However, I have a button on this panel that brings up a
MS> JDialog. This doesn't work so well. The dialog seems to not be able
MS> to obtain focus and the user cannot properly interract with it. (I
MS> also tried a JFrame) Is this not the right way to do this for an
MS> IntelliJ plugin? It seems that there's some rules or design issues
MS> with dialog management in IntelliJ that I'm not aware of and I can't
MS> find any doc that talks about it.
The common design rule is to use DialogWrapper as the common base class for
dialogs. We know that it works. :) You can find plenty of examples of its
use in the plugins provided in the development kit.
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"
I spent hours trying to get DialogWrapper to work, but I failed. However second solution you did mention on the forum worked very well:
DialogBuilder dialogBuilder = new DialogBuilder(project);
dialogBuilder.setTitle("New Task");
TaskForm newTaskForm = new TaskForm();
dialogBuilder.setCenterPanel(newTaskForm.getContainer());
if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE)
{
...
}
S.
Hello Sergiy,
>> The common design rule is to use DialogWrapper as the
>> common base class for
>> dialogs. We know that it works. :) You can find
>> plenty of examples of its
>> use in the plugins provided in the development kit.
SD> I spent hours trying to get DialogWrapper to work, but I failed.
Why?
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"
Dmitry Jemerov wrote:
>>> The common design rule is to use DialogWrapper as the
>>> common base class for
>>> dialogs. We know that it works. :) You can find
>>> plenty of examples of its
>>> use in the plugins provided in the development kit.
I guess the most common mistake is not to call init().
Sascha
Correct. I found an example in devkit sources, NewActionDialog and didn't check constructors properly. Too much code there.
Thought overriding abstract methods will be enough.
Sergiy
Thanks for the tip! It works a lot better now. :)
Is this something that's documented somewhere? I'm still very new to writing IntelliJ plugins and it seems that there's a lot of documentation still missing on how to do things. Too bad there's no book on it because I'd buy it immediately.
Hello Marc,
MS> Is this something that's documented somewhere? I'm still very new
MS> to writing IntelliJ plugins and it seems that there's a lot of
MS> documentation still missing on how to do things.
That's true. For many things the openapi forum / newsgroup is the best available
source of knowledge.
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"
Using DialogWrapper makes code much cleaner, I have to confess :)
Just don't forget to call init().
Idea's plugin system is much more simple than for example Eclipse's one so don't be scared by the fact that not many things are documented.