Opening a customised StructureView

I'm trying to write a customised StructureView that will be opened with a keystroke - ie to complement, but not replace, the standard Java StructureView. The problem I am having is that I have no idea how to actually get the thing to display...

I've created a customised TreeBasedStructureViewBuilder and StructureViewModel, and so I'm calling

StructureView view = builder.createStructureView(editor, project);

but then by calling

view.getComponent().setVisible(true);

nothing actually happens.

Perhaps it has to be embedded within a tool window? Or am I on the wrong track completely?

Any help would be greatly appreciated :)

Thanks,
Darren

4 comments

Hello Darren,

DG> I'm trying to write a customised StructureView that will be opened
DG> with a keystroke - ie to complement, but not replace, the standard
DG> Java StructureView. The problem I am having is that I have no idea
DG> how to actually get the thing to display...
DG>
DG> I've created a customised TreeBasedStructureViewBuilder and
DG> StructureViewModel, and so I'm calling
DG>
DG> StructureView view = builder.createStructureView(editor, project);
DG>
DG> but then by calling
DG>
DG> view.getComponent().setVisible(true);
DG>
DG> nothing actually happens.
DG>
DG> Perhaps it has to be embedded within a tool window? Or am I on the
DG> wrong track completely?

You are on the right track, but the component will not be displayed because
it doesn't have any parent. If you need the structure view to be displayed
in a toolwindow, you'll need to create the toolwindow by yourself.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0

So is there a way to clone the file structure popup window and replace the StructureView inside with my new one? Or is it a case of adding the StructureView JComponent to a JPanel of your creation.

Cheers,
Darren

0

Hello Darren,

DG> So is there a way to clone the file structure popup window and
DG> replace the StructureView inside with my new one? Or is it a case of
DG> adding the StructureView JComponent to a JPanel of your creation.

The standard file structure popup is not a StructureView instance, although
it's based on the same underlying model. It's also not part of OpenAPI. So
if you want to have an additional popup similar to the file structure popup,
you'll need to implement the UI for it by yourself.

If the tree-like view similar to the Structure toolwindow is what you need,
you can put the component returned from StructureView.getComponent() into
a toolwindow or into a JPanel inside a dialog.

--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"


0

That makes things a lot clearer for me, thanks a lot :)

0

Please sign in to leave a comment.