How to get current project in configurable / form component

Answered

I'm trying to create a SearchableConfigurable with a AddEditDeleteListPanel with a FileChooser or FileChooserModal (haven't gotten far enough to know which one to use. Examples?)

I'm creating a FileChooserDescriptorFactory.createSingleFolderDescriptor() to create a file descriptor and i need a way to select the root folder otherwise when the chooser launches I get the last directory I used in finder on OS X.

I'm currently stuck trying to get the current project in order to get the content root so I can set that as the root of the file chooser.

Am I going about this the right way? I've been looking for examples some of the open source plugins, but so far haven't found the same use case.

Any help would be greatly appreciated!

1
7 comments

Works most of the time for me. 

final Project project = ProjectUtil.guessCurrentProject(getMainFormPanel());

 

0

You can register it as project configurable and add a project as constructor parameter. 

com.intellij.openapi.options.Configurable well documented btw

0

Thanks for the help! I was able to get my UI component working by using the constructor parameter. I'll take another look at the documentation. I haven't done any plugin dev for quite a while so just wrapping my head around how everything works again.

 

0
Avatar
Permanently deleted user

Hi Charlie, good question! I have a project configurable that produces a Settings Window but doesn't have a constructor. How were you able to add the current project as a parameter to the constructor? Thanks

0

Hi Richard,

I registered a project configurable in the plugin.xml as suggested and the Project object is injected into the constructor. Then I passed the project down into the UI panel.

You can see the configurable here. You will probably have to create the constructor in order to get the project.

https://github.com/nek4life/sfcc-studio/blob/master/src/main/java/com/binarysushi/studio/configuration/StudioCartridgeConfigurable.java

Hope that helps!

 

1
Avatar
Permanently deleted user

Hi Charlie, yes, that's very helpful! I got it now, thank you!

0

Awesome! Glad you were able to figure it out.

0

Please sign in to leave a comment.