FileChooser from ApplicationComponent
Hi, trying to open IDEA's FileChooser from within an ApplicationComponent for a one time initialization of my Plugin i.e. when first run.
FileChooser takes either a Project or a java.awt.component and since I can't guarantee that a project is open i'd like to find the the appropriate Component to pass into the FileChooser.
I've tried code like:
But obviously this doesn't work; not sure where to go from here.
Any advice welcome.
Thanks,
Martin
请先登录再写评论。
Hello Martin,
Please try using JOptionPane.getRootFrame().
MZ> Hi, trying to open IDEA's FileChooser from within an
MZ> ApplicationComponent for a one time initialization of my Plugin i.e.
MZ> when first run.
MZ>
MZ> FileChooser takes either a Project or a java.awt.component and since
MZ> I can't guarantee that a project is open i'd like to find the the
MZ> appropriate Component to pass into the FileChooser.
MZ>
MZ> I've tried code like:
MZ>
MZ>
public void initComponent() { MZ> Editor editor = (Editor) MZ> DataManager.getInstance().getDataContext().getData(DataConstants.EDI MZ> TOR); MZ> Container parent = editor.getComponent().getParent(); // This is MZ> not a java.awt.Component MZ> FileChooserDescriptor fileChooserDescriptor = new MZ> FileChooserDescriptor(true, true,true,true,true,true); MZ> FileChooser fileChooser = FileChooser.chooseFiles((Component) MZ> parent, fileChooserDescriptor); MZ> } MZ> ]]>MZ>
MZ> But obviously this doesn't work; not sure where to go from here.
--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"