Getting java pop-up in front of oXygen (ANT)

Oxygen general issues.
jtakeda
Posts: 11
Joined: Sat Feb 25, 2017 1:18 am

Getting java pop-up in front of oXygen (ANT)

Post by jtakeda »

I'm using oXygen build 2018022209 and I'm using embedded java scripts to receive user input. I can't use oXygen editor variables for this, because some of the information (like passwords) needs to be secure and, as far as I can tell, passing an editor variable through to ANT in oXygen echoes out something like this:

Code: Select all


"/Applications/Oxygen XML Editor/.install4j/jre.bundle/Contents/Home/jre/bin/java" -Dapple.awt.UIElement=true -Xmx256m -classpath [code]
"/Applications/Oxygen XML Editor/tools/ant/lib/ant-launcher.jar" "-Dant.home=/Applications/Oxygen XML Editor/tools/ant" org.apache.tools.ant.launch.Launcher -f "path/to/my/build" "-Dpd="my/project/directory/editor/variable "-Dwebhelp.trial.license=no" "-Dpassword=mySecretPassword"[/code]

So, I'm using a Java popup instead like so in my ant build:

Code: Select all


        <script language="javascript">
<![CDATA[
var pw = new javax.swing.JPasswordField();
var choice = javax.swing.JOptionPane.showConfirmDialog(null, pw, "Enter Password..", javax.swing.JOptionPane.OK_CANCEL_OPTION, javax.swing.JOptionPane.PLAIN_MESSAGE);
if (choice == javax.swing.JOptionPane.OK_OPTION) {
// create ant property
var pwd = pw.getText();
project.setProperty("pwd", pwd);
} else {
javax.swing.JOptionPane.showMessageDialog(null, "ERROR: User cancelled input. Aborting.");
throw "Password required!";
};
if (pwd.isEmpty()) {
javax.swing.JOptionPane.showMessageDialog(null, "ERROR: No password entered! Aborting.");
throw "Password required!!";
}
]]>
</script>
However, the pop-up box looks like this: https://github.com/joeytakeda/misc/blob ... _forum.png where the pop-up box comes in behind the oXygen window. Is there any way to get this pop-up box to go in front of the oXygen window?

Thanks!
Joey
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting java pop-up in front of oXygen (ANT)

Post by Radu »

Hi Joey,

The first parameter you send as null to the JOptionPane is the parent component. Unfortunately once the DITA OT publishing starts, it runs in another process so you cannot pass to it a reference to the main Oxygen frame which runs in its own process.
A couple of possibilities you could try:

1) In your javascript code from the ANT build file also create a Swing JFrame without content, show it, and on top of the frame show your JOptionPane, then after the JOptionPane is closed hide also the parent Swing JFrame. But this might not fix the problem in all cases.

2) Create an Oxygen plugin which contributes a custom action which the end user would use to set an user and a password for some repository. Your plugin would store them somewhere in the user home folder, maybe encrypted with some custom encryption you have. Then your ANT build file could read that file in order to retrieve the user and password. In this way the end users would not need to enter their credentials every time they publish.
If you are interested in this approach I could try to tell you more about our plugins API.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
jtakeda
Posts: 11
Joined: Sat Feb 25, 2017 1:18 am

Re: Getting java pop-up in front of oXygen (ANT)

Post by jtakeda »

Hi Radu,

Thanks for the suggestions! I'm slightly confused by this bit, however:
The first parameter you send as null to the JOptionPane is the parent component. Unfortunately once the DITA OT publishing starts, it runs in another process so you cannot pass to it a reference to the main Oxygen frame which runs in its own process.
I'm not running DITA OT publishing, so can I pass a reference to main Oxygen frame, or am I misunderstanding?

Thanks!

Joey
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting java pop-up in front of oXygen (ANT)

Post by Radu »

Hi Joey,

Sorry about my phrasing, I meant to say "DITA OT or ANT publishing". So ANT publishing is also done in another Java process started from Oxygen and because it is another Java process it cannot receive a reference to the parent frame.
I will add an internal issue to potentially mask out in a future version in the command line we display parameters whose values have been computed using "$ask" editor variables of type password. But even if we do that the password parameter will still be passed as a plain string to the started ANT process.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
jtakeda
Posts: 11
Joined: Sat Feb 25, 2017 1:18 am

Re: Getting java pop-up in front of oXygen (ANT)

Post by jtakeda »

Hi Radu,

Ah, that makes sense. Thanks for clarifying.
In your javascript code from the ANT build file also create a Swing JFrame without content, show it, and on top of the frame show your JOptionPane, then after the JOptionPane is closed hide also the parent Swing JFrame. But this might not fix the problem in all cases.
That seemed to fix it!I added an empty JFrame and set it as the parent component. Posting code here for others:

Code: Select all

<![CDATA[
var frame = new javax.swing.JFrame();
frame.setAlwaysOnTop( true );
frame.setLocationByPlatform( true );
frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.pack();
frame.setVisible(true);
var pw = new javax.swing.JPasswordField();
var choice = javax.swing.JOptionPane.showConfirmDialog(frame, pw, "Enter Password..", javax.swing.JOptionPane.OK_CANCEL_OPTION, javax.swing.JOptionPane.PLAIN_MESSAGE);
if (choice == javax.swing.JOptionPane.OK_OPTION) {
// create ant property
var pwd = pw.getText();
project.setProperty("pwd", pwd);
} else {
javax.swing.JOptionPane.showMessageDialog(frame, "ERROR: User cancelled input. Aborting.");
throw "Password required!";
};
if (pwd.isEmpty()) {
javax.swing.JOptionPane.showMessageDialog(frame, "ERROR: No password entered! Aborting.");
throw "Password required!!";
}
]]>
Thanks!
Joey
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting java pop-up in front of oXygen (ANT)

Post by Radu »

Hi Joey,

Thanks for posting a solution which others may be interested in.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply