From sletellier@users.nuiton.org Fri Jul 6 10:24:11 2012 From: sletellier@users.nuiton.org To: jaxx-commits@list.nuiton.org Subject: [Jaxx-commits] r2385 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor Date: Fri, 06 Jul 2012 10:24:11 +0200 Message-ID: <20120706082411.3BC7815849@nuiton.codelutin.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6096661537983068621==" --===============6096661537983068621== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: sletellier Date: 2012-07-06 10:24:11 +0200 (Fri, 06 Jul 2012) New Revision: 2385 Url: http://nuiton.org/repositories/revision/jaxx/2385 Log: fixes #2171 : FileEditor dont keep input path Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditorHandl= er.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEdit= or.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jax= x 2012-07-05 16:08:24 UTC (rev 2384) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/FileEditor.jax= x 2012-07-06 08:24:11 UTC (rev 2385) @@ -24,9 +24,9 @@ java.io.File - java.beans.PropertyChangeEvent java.beans.PropertyChangeListener jaxx.runtime.swing.BaseActionPanel + org.apache.commons.lang3.StringUtils =20 @@ -37,8 +37,6 @@ =20 =20 - - =20 @@ -48,26 +46,28 @@ =20 =20 + onKeyReleased=3D'handler.setSelectedFile(pathField.getText())'= /> =20 @@ -34,10 +35,15 @@ public class FileEditorHandler { =20 public static final String SEPARATOR_REGEX =3D "\\s*,\\s*"; + public static File lastSelectedPath; + protected FileEditor view; =20 public FileEditorHandler(FileEditor view) { this.view =3D view; + if (lastSelectedPath =3D=3D null) { + lastSelectedPath =3D new File(System.getProperty("user.home")); + } } =20 public void openLocation() { @@ -45,7 +51,7 @@ // use last selected file File startFile =3D view.getSelectedFile(); String startPath =3D view.getStartPath(); - if (startFile =3D=3D null && startPath !=3D null) { + if (startFile =3D=3D null && StringUtils.isNotEmpty(startPath)) { =20 =20 // else filed start path @@ -53,7 +59,7 @@ } else { =20 // else start with user home - startFile =3D new File(System.getProperty("user.home")); + startFile =3D lastSelectedPath; } JFileChooser fc =3D new JFileChooser(startFile); =20 @@ -118,10 +124,26 @@ // get selected to display in ui File file =3D fc.getSelectedFile(); =20 - view.setSelectedFile(file); + setSelectedFile(file); } } =20 + public void setSelectedFile(String path) { + setSelectedFile(new File(path)); + } + + public void setSelectedFile(File file) { + view.setSelectedFile(file); + view.setStartPath(file.getPath()); + File dir =3D file; + if (dir.exists()) { + if (!dir.isDirectory()) { + dir =3D dir.getParentFile(); + } + lastSelectedPath =3D dir; + } + } + public static class ExtentionFileFiler extends FileFilter { protected String ext; protected String desciption; --===============6096661537983068621==--