|
From: Keith D. (JIRA) <no...@at...> - 2007-08-10 14:23:24
|
[ http://opensource.atlassian.com/projects/spring/browse/RCP-60?page=
=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Keith Donald updated RCP-60:
----------------------------
Assignee: (was: Keith Donald)
Description:=20
FileChooser allows the addition of an accessory component.
I created a simple patch and a more comlicated one which allows
this for FileChooserUtils.
I removed the static JFileChooser member (since an added
accessory component would have been there even if you
wouldn't want it).
--simple
=C2=A0import java.awt.Component;
=C2=A0import java.io.File;
+import javax.swing.JComponent;
=C2=A0import javax.swing.JFileChooser;
=C2=A0/**
@@ -27,20 +28,34 @@
=C2=A0 * @author Keith Donald
=C2=A0 */
=C2=A0public class FileChooserUtils {
- =C2=A0 =C2=A0private static JFileChooser fileChooser;
=C2=A0 =C2=A0 =C2=A0private FileChooserUtils() {
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0public static File showFileChooser(Component parent, St=
ring=20
defaultExtension, String approveButtonName,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription)=
{
- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fileChooser =3D=3D null) {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser =3D new JFileChooser=
();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser fileChooser =3D new JFileChooser(=
);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFileFi=
lter();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(paren=
t, approveButtonName);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE_OPTI=
ON) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelectedFi=
le();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0}
+
+ =C2=A0 =C2=A0public static File showFileChooser(Component parent, String=
=20
defaultExtension, String approveButtonName,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JCom=
ponent accessory ) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser =C2=A0fileChooser =3D new JFileCh=
ooser();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultF=
ileFilter();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription=
);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setAccessory(accessory);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(=
parent, approveButtonName);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE=
_OPTION) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelec=
tedFile();
@@ -49,4 +64,9 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}
+
+
+
+
+
=C2=A0}
\ No newline at end of file
--complicated
Index: FileChooserUtils.java
=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
RCS file:=20
/cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclient=
/filechooser/FileChooserUtils.java,v
retrieving revision 1.5
diff -u -r1.5 FileChooserUtils.java
--- FileChooserUtils.java=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A031 Oct 2=
004 18:58:46 -0000=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A01.5
+++ FileChooserUtils.java=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A03 Dec 20=
04 13:35:07 -0000
@@ -18,6 +18,7 @@
=C2=A0import java.awt.Component;
=C2=A0import java.io.File;
=C2=A0
+import javax.swing.JComponent;
=C2=A0import javax.swing.JFileChooser;
=C2=A0
=C2=A0/**
@@ -27,20 +28,26 @@
=C2=A0 * @author Keith Donald
=C2=A0 */
=C2=A0public class FileChooserUtils {
- =C2=A0 =C2=A0private static JFileChooser fileChooser;
-
+=20
0; =C2=A0
=C2=A0 =C2=A0 =C2=A0private FileChooserUtils() {
=C2=A0 =C2=A0 =C2=A0}
=C2=A0
=C2=A0 =C2=A0 =C2=A0public static File showFileChooser(Component parent, St=
ring=20
defaultExtension, String approveButtonName,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription)=
{
- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fileChooser =3D=3D null) {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser =3D new JFileChooser=
();
+ =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0JFileChooser fileChooser =3D createFileCho=
oser(parent,defaultExtension,=20
approveButtonName, fileTypeDescription, null );
+ =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0int returnVal =3D fileChooser.showDialog(p=
arent, approveButtonName);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE_OPTI=
ON) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelectedFi=
le();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
- =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFileFi=
lter();
- =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
- =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
- =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0
+ =C2=A0 =C2=A0
+ =C2=A0 =C2=A0public static File showFileChooser(Component parent, String=
=20
defaultExtension, String approveButtonName,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JCom=
ponent accessory ) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser fileChooser =3D createFileChooser=
(parent,defaultExtension,=20
approveButtonName, fileTypeDescription, accessory );
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(=
parent, approveButtonName);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE=
_OPTION) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelec=
tedFile();
@@ -49,4 +56,17 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0static JFileChooser createFileChooser( Component parent, Str=
ing=20
defaultExtension, String approveButtonName,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JCom=
ponent accessory ){
+ =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0JFileChooser fileChooser =3D new JFileChoo=
ser();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFileFi=
lter();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if( accessory !=3D null ){
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0file=
Chooser.setAccessory(accessory);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=20
0; =C2=A0 =C2=A0 =C2=A0return fileChooser; =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
+ =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0
=C2=A0}
\ No newline at end of file
was:
FileChooser allows the addition of an accessory component.
I created a simple patch and a more comlicated one which allows
this for FileChooserUtils.
I removed the static JFileChooser member (since an added
accessory component would have been there even if you
wouldn't want it).
--simple
=C2=A0import java.awt.Component;
=C2=A0import java.io.File;
+import javax.swing.JComponent;
=C2=A0import javax.swing.JFileChooser;
=C2=A0/**
@@ -27,20 +28,34 @@
=C2=A0 * @author Keith Donald
=C2=A0 */
=C2=A0public class FileChooserUtils {
- =C2=A0 =C2=A0private static JFileChooser fileChooser;
=C2=A0 =C2=A0 =C2=A0private FileChooserUtils() {
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0public static File showFileChooser(Component parent, St=
ring=20
defaultExtension, String approveButtonName,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription)=
{
- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fileChooser =3D=3D null) {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser =3D new JFileChooser=
();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser fileChooser =3D new JFileChooser(=
);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFileFi=
lter();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(paren=
t, approveButtonName);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE_OPTI=
ON) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelectedFi=
le();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0}
+
+ =C2=A0 =C2=A0public static File showFileChooser(Component parent, String=
=20
defaultExtension, String approveButtonName,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JCom=
ponent accessory ) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser =C2=A0fileChooser =3D new JFileCh=
ooser();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultF=
ileFilter();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription=
);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setAccessory(accessory);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(=
parent, approveButtonName);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE=
_OPTION) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelec=
tedFile();
@@ -49,4 +64,9 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}
+
+
+
+
+
=C2=A0}
\ No newline at end of file
--complicated
Index: FileChooserUtils.java
=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
RCS file:=20
/cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclient=
/filechooser/FileChooserUtils.java,v
retrieving revision 1.5
diff -u -r1.5 FileChooserUtils.java
--- FileChooserUtils.java=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A031 Oct 2=
004 18:58:46 -0000=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A01.5
+++ FileChooserUtils.java=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A03 Dec 20=
04 13:35:07 -0000
@@ -18,6 +18,7 @@
=C2=A0import java.awt.Component;
=C2=A0import java.io.File;
=C2=A0
+import javax.swing.JComponent;
=C2=A0import javax.swing.JFileChooser;
=C2=A0
=C2=A0/**
@@ -27,20 +28,26 @@
=C2=A0 * @author Keith Donald
=C2=A0 */
=C2=A0public class FileChooserUtils {
- =C2=A0 =C2=A0private static JFileChooser fileChooser;
-
+ =C2=A0 =C2=A0
=C2=A0 =C2=A0 =C2=A0private FileChooserUtils() {
=C2=A0 =C2=A0 =C2=A0}
=C2=A0
=C2=A0 =C2=A0 =C2=A0public static File showFileChooser(Component parent, St=
ring=20
defaultExtension, String approveButtonName,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription)=
{
- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fileChooser =3D=3D null) {
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser =3D new JFileChooser=
();
+ =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0JFileChooser fileChooser =3D createFileCho=
oser(parent,defaultExtension,=20
approveButtonName, fileTypeDescription, null );
+ =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0int returnVal =3D fileChooser.showDialog(p=
arent, approveButtonName);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE_OPTI=
ON) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelectedFi=
le();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
- =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFileFi=
lter();
- =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
- =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
- =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0
+ =C2=A0 =C2=A0
+ =C2=A0 =C2=A0public static File showFileChooser(Component parent, String=
=20
defaultExtension, String approveButtonName,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JCom=
ponent accessory ) {
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser fileChooser =3D createFileChooser=
(parent,defaultExtension,=20
approveButtonName, fileTypeDescription, accessory );
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(=
parent, approveButtonName);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE=
_OPTION) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelec=
tedFile();
@@ -49,4 +56,17 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0static JFileChooser createFileChooser( Component parent, Str=
ing=20
defaultExtension, String approveButtonName,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JCom=
ponent accessory ){
+ =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0JFileChooser fileChooser =3D new JFileChoo=
ser();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFileFi=
lter();
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if( accessory !=3D null ){
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0file=
Chooser.setAccessory(accessory);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser; =C2=A0 =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
+ =C2=A0 =C2=A0}
+ =C2=A0 =C2=A0
=C2=A0}
\ No newline at end of file
> FileChooser - Utils with accessory component
> --------------------------------------------
>
> Key: RCP-60
> URL: http://opensource.atlassian.com/projects/spring/brow=
se/RCP-60
> Project: Spring Framework Rich Client Project
> Issue Type: Improvement
> Reporter: springtester
> Priority: Minor
>
> FileChooser allows the addition of an accessory component.
> I created a simple patch and a more comlicated one which allows
> this for FileChooserUtils.
> I removed the static JFileChooser member (since an added
> accessory component would have been there even if you
> wouldn't want it).
> --simple
> =C2=A0import java.awt.Component;
> =C2=A0import java.io.File;
> +import javax.swing.JComponent;
> =C2=A0import javax.swing.JFileChooser;
> =C2=A0/**
> @@ -27,20 +28,34 @@
> =C2=A0 * @author Keith Donald
> =C2=A0 */
> =C2=A0public class FileChooserUtils {
> - =C2=A0 =C2=A0private static JFileChooser fileChooser;
> =C2=A0 =C2=A0 =C2=A0private FileChooserUtils() {
> =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0public static File showFileChooser(Component parent, =
String=20
> defaultExtension, String approveButtonName,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescriptio=
n) {
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fileChooser =3D=3D null) {
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser =3D new JFileChoos=
er();
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser fileChooser =3D new JFileChoose=
r();
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFile=
Filter();
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialog(par=
ent, approveButtonName);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE_OP=
TION) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelected=
File();
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> + =C2=A0 =C2=A0}
> +
> + =C2=A0 =C2=A0public static File showFileChooser(Component parent, Strin=
g=20
> defaultExtension, String approveButtonName,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JC=
omponent accessory ) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser =C2=A0fileChooser =3D new JFile=
Chooser();
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new Defaul=
tFileFilter();
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescripti=
on);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setAccessory(accessory);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialo=
g(parent, approveButtonName);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPRO=
VE_OPTION) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSel=
ectedFile();
> @@ -49,4 +64,9 @@
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0}
> +
> +
> +
> +
> +
> =C2=A0}
> \ No newline at end of file
> --complicated
> Index: FileChooserUtils.java
> =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
> RCS file:=20
> /cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclie=
nt/filechooser/FileChooserUtils.java,v
> retrieving revision 1.5
> diff -u -r1.5 FileChooserUtils.java
> --- FileChooserUtils.java=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A031 Oct=
2004 18:58:46 -0000=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A01.5
> +++ FileChooserUtils.java=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A03 Dec =
2004 13:35:07 -0000
> @@ -18,6 +18,7 @@
> =C2=A0import java.awt.Component;
> =C2=A0import java.io.File;
> =C2=A0
> +import javax.swing.JComponent;
> =C2=A0import javax.swing.JFileChooser;
> =C2=A0
> =C2=A0/**
> @@ -27,20 +28,26 @@
> =C2=A0 * @author Keith Donald
> =C2=A0 */
> =C2=A0public class FileChooserUtils {
> - =C2=A0 =C2=A0private static JFileChooser fileChooser;
> -
> +=20
> 0; =C2=A0
> =C2=A0 =C2=A0 =C2=A0private FileChooserUtils() {
> =C2=A0 =C2=A0 =C2=A0}
> =C2=A0
> =C2=A0 =C2=A0 =C2=A0public static File showFileChooser(Component parent, =
String=20
> defaultExtension, String approveButtonName,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescriptio=
n) {
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fileChooser =3D=3D null) {
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser =3D new JFileChoos=
er();
> + =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0JFileChooser fileChooser =3D createFileC=
hooser(parent,defaultExtension,=20
> approveButtonName, fileTypeDescription, null );
> + =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0int returnVal =3D fileChooser.showDialog=
(parent, approveButtonName);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPROVE_OP=
TION) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSelected=
File();
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFile=
Filter();
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0else {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> + =C2=A0 =C2=A0}
> + =C2=A0 =C2=A0
> + =C2=A0 =C2=A0
> + =C2=A0 =C2=A0public static File showFileChooser(Component parent, Strin=
g=20
> defaultExtension, String approveButtonName,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JC=
omponent accessory ) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0JFileChooser fileChooser =3D createFileChoos=
er(parent,defaultExtension,=20
> approveButtonName, fileTypeDescription, accessory );
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int returnVal =3D fileChooser.showDialo=
g(parent, approveButtonName);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (returnVal =3D=3D JFileChooser.APPRO=
VE_OPTION) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return fileChooser.getSel=
ectedFile();
> @@ -49,4 +56,17 @@
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return null;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0}
> + =C2=A0 =C2=A0static JFileChooser createFileChooser( Component parent, S=
tring=20
> defaultExtension, String approveButtonName,
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0String fileTypeDescription, JC=
omponent accessory ){
> + =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0JFileChooser fileChooser =3D new JFileCh=
ooser();
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0DefaultFileFilter filter =3D new DefaultFile=
Filter();
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.addExtension(defaultExtension);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0filter.setDescription(fileTypeDescription);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0fileChooser.setFileFilter(filter);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if( accessory !=3D null ){
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi=
leChooser.setAccessory(accessory);
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +=20
> 0; =C2=A0 =C2=A0 =C2=A0return fileChooser; =C2=A0 =C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
> + =C2=A0 =C2=A0}
> + =C2=A0 =C2=A0
> =C2=A0}
> \ No newline at end of file
--=20
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: htt=
p://opensource.atlassian.com/projects/spring/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Lieven D. (JIRA) <no...@sp...> - 2008-10-09 20:47:28
|
[ http://jira.springframework.org/browse/RCP-60?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lieven Doclo updated RCP-60:
----------------------------
Fix Version/s: 1.x
> FileChooser - Utils with accessory component
> --------------------------------------------
>
> Key: RCP-60
> URL: http://jira.springframework.org/browse/RCP-60
> Project: Spring Framework Rich Client Project
> Issue Type: Improvement
> Reporter: springtester
> Priority: Minor
> Fix For: 1.x
>
>
> FileChooser allows the addition of an accessory component.
> I created a simple patch and a more comlicated one which allows
> this for FileChooserUtils.
> I removed the static JFileChooser member (since an added
> accessory component would have been there even if you
> wouldn't want it).
> --simple
> import java.awt.Component;
> import java.io.File;
> +import javax.swing.JComponent;
> import javax.swing.JFileChooser;
> /**
> @@ -27,20 +28,34 @@
> * @author Keith Donald
> */
> public class FileChooserUtils {
> - private static JFileChooser fileChooser;
> private FileChooserUtils() {
> }
> public static File showFileChooser(Component parent, String
> defaultExtension, String approveButtonName,
> String fileTypeDescription) {
> - if (fileChooser == null) {
> - fileChooser = new JFileChooser();
> + JFileChooser fileChooser = new JFileChooser();
> + DefaultFileFilter filter = new DefaultFileFilter();
> + filter.addExtension(defaultExtension);
> + filter.setDescription(fileTypeDescription);
> + fileChooser.setFileFilter(filter);
> + int returnVal = fileChooser.showDialog(parent, approveButtonName);
> + if (returnVal == JFileChooser.APPROVE_OPTION) {
> + return fileChooser.getSelectedFile();
> }
> + else {
> + return null;
> + }
> + }
> +
> + public static File showFileChooser(Component parent, String
> defaultExtension, String approveButtonName,
> + String fileTypeDescription, JComponent accessory ) {
> + JFileChooser fileChooser = new JFileChooser();
> DefaultFileFilter filter = new DefaultFileFilter();
> filter.addExtension(defaultExtension);
> filter.setDescription(fileTypeDescription);
> fileChooser.setFileFilter(filter);
> + fileChooser.setAccessory(accessory);
> int returnVal = fileChooser.showDialog(parent, approveButtonName);
> if (returnVal == JFileChooser.APPROVE_OPTION) {
> return fileChooser.getSelectedFile();
> @@ -49,4 +64,9 @@
> return null;
> }
> }
> +
> +
> +
> +
> +
> }
> \ No newline at end of file
> --complicated
> Index: FileChooserUtils.java
> ===================================================================
> RCS file:
> /cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclient/filechooser/FileChooserUtils.java,v
> retrieving revision 1.5
> diff -u -r1.5 FileChooserUtils.java
> --- FileChooserUtils.java 31 Oct 2004 18:58:46 -0000 1.5
> +++ FileChooserUtils.java 3 Dec 2004 13:35:07 -0000
> @@ -18,6 +18,7 @@
> import java.awt.Component;
> import java.io.File;
>
> +import javax.swing.JComponent;
> import javax.swing.JFileChooser;
>
> /**
> @@ -27,20 +28,26 @@
> * @author Keith Donald
> */
> public class FileChooserUtils {
> - private static JFileChooser fileChooser;
> -
> +
> 0;
> private FileChooserUtils() {
> }
>
> public static File showFileChooser(Component parent, String
> defaultExtension, String approveButtonName,
> String fileTypeDescription) {
> - if (fileChooser == null) {
> - fileChooser = new JFileChooser();
> + JFileChooser fileChooser = createFileChooser(parent,defaultExtension,
> approveButtonName, fileTypeDescription, null );
> + int returnVal = fileChooser.showDialog(parent, approveButtonName);
> + if (returnVal == JFileChooser.APPROVE_OPTION) {
> + return fileChooser.getSelectedFile();
> }
> - DefaultFileFilter filter = new DefaultFileFilter();
> - filter.addExtension(defaultExtension);
> - filter.setDescription(fileTypeDescription);
> - fileChooser.setFileFilter(filter);
> + else {
> + return null;
> + }
> + }
> +
> +
> + public static File showFileChooser(Component parent, String
> defaultExtension, String approveButtonName,
> + String fileTypeDescription, JComponent accessory ) {
> + JFileChooser fileChooser = createFileChooser(parent,defaultExtension,
> approveButtonName, fileTypeDescription, accessory );
> int returnVal = fileChooser.showDialog(parent, approveButtonName);
> if (returnVal == JFileChooser.APPROVE_OPTION) {
> return fileChooser.getSelectedFile();
> @@ -49,4 +56,17 @@
> return null;
> }
> }
> + static JFileChooser createFileChooser( Component parent, String
> defaultExtension, String approveButtonName,
> + String fileTypeDescription, JComponent accessory ){
> + JFileChooser fileChooser = new JFileChooser();
> + DefaultFileFilter filter = new DefaultFileFilter();
> + filter.addExtension(defaultExtension);
> + filter.setDescription(fileTypeDescription);
> + fileChooser.setFileFilter(filter);
> + if( accessory != null ){
> + fileChooser.setAccessory(accessory);
> + }
> +
> 0; return fileChooser;
> + }
> +
> }
> \ No newline at end of file
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.springframework.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|