Author: tchemit Date: 2013-03-08 20:07:19 +0100 (Fri, 08 Mar 2013) New Revision: 2600 Url: http://nuiton.org/projects/jaxx/repository/revisions/2600 Log: fixes #2578: When invoking fileEditor from a dialog with alwaysOnTopdoes not display in top Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditorHandler.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jaxx =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jaxx 2013-03-08 09:50:19 UTC (rev 2599) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jaxx 2013-03-08 19:07:19 UTC (rev 2600) @@ -23,9 +23,12 @@ --> <BaseActionPanel layout='{new BorderLayout()}'> <import> - java.io.File jaxx.runtime.swing.BaseActionPanel + org.apache.commons.lang3.StringUtils + + javax.swing.JDialog + java.io.File </import> <FileEditorHandler id='handler' constructorParams='this'/> @@ -45,31 +48,35 @@ <String id='extsDescription' javaBean='null'/> <script><![CDATA[ - protected File selectedFile; +protected File selectedFile; - public void setSelectedFile(File selectedFile) { - this.selectedFile = selectedFile; - if (selectedFile != null) { - setStartPath(selectedFile.getAbsolutePath()); - fireActionEvent(); - } - } - - public void setSelectedFile(String startPath) { - this.selectedFile = null; - setStartPath(startPath); +public void setSelectedFile(File selectedFile) { + this.selectedFile = selectedFile; + if (selectedFile != null) { + setStartPath(selectedFile.getAbsolutePath()); fireActionEvent(); } +} - public File getSelectedFile() { - if (selectedFile == null) { - if (StringUtils.isNotEmpty(startPath)) { - selectedFile = new File(startPath); - } +public void setSelectedFile(String startPath) { + this.selectedFile = null; + setStartPath(startPath); + fireActionEvent(); +} + +public File getSelectedFile() { + if (selectedFile == null) { + if (StringUtils.isNotEmpty(startPath)) { + selectedFile = new File(startPath); } - return selectedFile; } + return selectedFile; +} +public void setDialogOwner(JDialog dialogOwner) { + handler.setDialogOwner(dialogOwner); +} + ]]></script> <JTextField id='pathField' Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditorHandler.java =================================================================== --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditorHandler.java 2013-03-08 09:50:19 UTC (rev 2599) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditorHandler.java 2013-03-08 19:07:19 UTC (rev 2600) @@ -24,21 +24,29 @@ package jaxx.runtime.swing.editor; import com.google.common.io.Files; -import java.io.File; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; -import org.apache.commons.lang3.StringUtils; +import java.io.File; -/** - * @author sletellier <letellier@codelutin.com> - */ +/** @author sletellier <letellier@codelutin.com> */ public class FileEditorHandler { public static final String SEPARATOR_REGEX = "\\s*,\\s*"; + public static File lastSelectedPath; protected FileEditor view; + /** + * To set the dialog (see http://nuiton.org/issues/2578). + * + * @since 2.5.12 + */ + protected JDialog dialogOwner; + public FileEditorHandler(FileEditor view) { this.view = view; if (lastSelectedPath == null) { @@ -117,7 +125,15 @@ } // show dialog + // see http://nuiton.org/issues/2578 + boolean hackDialog = dialogOwner != null && dialogOwner.isAlwaysOnTop(); + if (hackDialog) { + dialogOwner.setAlwaysOnTop(false); + } int returnVal = fc.showOpenDialog(view); + if (hackDialog) { + dialogOwner.setAlwaysOnTop(true); + } if (returnVal == JFileChooser.APPROVE_OPTION) { // get selected to display in ui @@ -143,6 +159,10 @@ } } + protected void setDialogOwner(JDialog dialogOwner) { + this.dialogOwner = dialogOwner; + } + public static class ExtentionFileFiler extends FileFilter { protected String ext; protected String desciption;