Custom URL Chooser Issue

Post here questions and problems related to oXygen frameworks/document types.
sanGeoff
Posts: 42
Joined: Mon Aug 18, 2014 11:50 pm

Custom URL Chooser Issue

Post 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);
}
};
sanGeoff
Posts: 42
Joined: Mon Aug 18, 2014 11:50 pm

Re: Custom URL Chooser Issue

Post 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); 
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: Custom URL Chooser Issue

Post 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
Post Reply