Page 1 of 1

Custom URL Chooser Issue

Posted: Wed Dec 17, 2014 11:29 pm
by sanGeoff
Can someone help me troubleshoot my issue with a Custom URL chooser? I have created a custom URL chooser and it works for the most part when using the open URL or insert functions. If however I call the URL choosers from a properties editor (the thing that pops up when you click on an opening tag) it doesn’t quite work.

I have a custom modal JDialog that I create and then show. My code always blocks until I have selected a path in my dialog as it should. When calling the URL choosers from a properties editor, as soon as I set my custom JDialog to visible, the properties editor and brow dialog disappear and will never get the URL chosen.

The action code essentially looks like this:

Code: Select all

 Action TFS_browse_Action = new AbstractAction("CMS") {
URL url;

@Override
public void actionPerformed(ActionEvent arg0) {
Frame frame = (Frame) pluginWorkspaceAccess.getParentFrame();
final JDialog temp = new JDialog(frame, "CMS File Chooser", true);
temp.setVisible(true);
if(url != null)
fileChooser.urlChosen(url);
}
};

Re: Custom URL Chooser Issue

Posted: Thu Dec 18, 2014 1:22 am
by sanGeoff
Hum, looks like I was able to get it to work by casing the frame to a window and using the JAVA document modal. Not sure if it’s the correct way though.

Code: Select all

 new JDialog((Window)frame, "Searching", ModalityType.DOCUMENT_MODAL); 

Re: Custom URL Chooser Issue

Posted: Thu Dec 18, 2014 9:53 am
by alex_jitianu
Hello,

The properties dialog is a non modal dialog. It also has a custom behavior to automatically hide when it loses focus to a component outside its hierarchy. I think that's what is happening in your case. You should be able to fix it by using the focused window as the parent for your dialog:

Code: Select all


Window parentWindow = (Window) pluginWorkspaceAccess.getParentFrame();
Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
if (focusedWindow != null) {
parentWindow = focusedWindow;
}
JDialog temp = new JDialog(parentWindow , "CMS File Chooser", true);
Best regards,
Alex