And I am using the PMD plugin for JDeveloper.
After the upgrade of JDeveloper to the latest version 11.1.1.0.1 the preferences are always gone.
So I wanted to import my settings again, but the file selector did not come up!
So looking into the log I saw the following stacktrace:
Exception occurred during event dispatching:
java.lang.ClassCastException: sun.awt.NullComponentPeer cannot be cast to sun.awt.X11.XChoicePeerwith the following code to open the dialog
at sun.awt.X11.XFileDialogPeer.init(XFileDialogPeer.java:264)
at sun.awt.X11.XFileDialogPeer.show(XFileDialogPeer.java:726)
final FileDialog fdlg = new FileDialog(new Frame(), "Import", FileDialog.LOAD);Looking throug a lot of (blog) post I could not get a fix for this.
fdlg.setVisible(true);
So the thing that intrigued by the fact that the JDeveloper File chooser was working.
But that was not the Java default file chooser.
Then the question arises how can I use the JDeveloper file chooser?
A quest was up to get through the knowledge where a description is on the JDeveloper File Chooser.
I finally found it in an extension I also did some work on, the search extension.
It is needed to use the following code:
public String getPath(String windowText, String currPath)With this also on Linux it will work to import or export files into the PMD plugin.
{
String returnPath = "";
URL url = URLFactory.newDirURL( Ide.getSystemDirectory() );
URLChooser chooser = DialogUtil.newURLChooser( url );
chooser.setSelectionMode( URLChooser.SINGLE_SELECTION );
chooser.setSelectionMode( URLChooser.FILES_ONLY);
int ret = chooser.showOpenDialog( Ide.getMainWindow(), windowText);
if ( ret == URLChooser.APPROVE_OPTION )
{
URL selectedURL = chooser.getSelectedURL();
returnPath = URLFileSystem.getPlatformPathName( selectedURL ) ;
}
return returnPath;
}