Author: ruschein
Date: 2011-07-11 09:53:35 -0700 (Mon, 11 Jul 2011)
New Revision: 26136
Added:
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileChooserFilter.java
Modified:
core3/swing-util-api/trunk/pom.xml
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileUtil.java
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/internal/FileUtilImpl.java
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
Major cleanup.
Modified: core3/swing-util-api/trunk/pom.xml
===================================================================
--- core3/swing-util-api/trunk/pom.xml 2011-07-11 15:10:38 UTC (rev 26135)
+++ core3/swing-util-api/trunk/pom.xml 2011-07-11 16:53:35 UTC (rev 26136)
@@ -5,7 +5,7 @@
<groupId>org.cytoscape</groupId>
<artifactId>parent</artifactId>
<version>3.0.0-alpha7</version>
- <relativePath>../parent</relativePath>
+ <relativePath>../parent</relativePath>
</parent>
<properties>
@@ -22,37 +22,37 @@
<packaging>bundle</packaging>
- <scm>
-
<connection>scm:svn:http://chianti.ucsd.edu/svn/core3/swing-util-api/trunk</connection>
-
<developerConnection>scm:svn:svn+ssh://grenache.ucsd.edu/cellar/common/svn/core3/swing-util-api/trunk</developerConnection>
- <url>http://chianti.ucsd.edu/svn/core3/swing-util-api/trunk</url>
- </scm>
+ <scm>
+
<connection>scm:svn:http://chianti.ucsd.edu/svn/core3/swing-util-api/trunk</connection>
+
<developerConnection>scm:svn:svn+ssh://grenache.ucsd.edu/cellar/common/svn/core3/swing-util-api/trunk</developerConnection>
+ <url>http://chianti.ucsd.edu/svn/core3/swing-util-api/trunk</url>
+ </scm>
<repositories>
- <!-- bootstrap for cytoscape dependencies, namely the parent POM
snapshots -->
- <repository>
- <id>cytoscape_snapshots</id>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- <name>Cytoscape Snapshots</name>
-
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/</url>
- </repository>
- <!-- bootstrap for cytoscape dependencies, namely the parent POM
releases -->
- <repository>
- <id>cytoscape_releases</id>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- <name>Cytoscape Releases</name>
-
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/releases/</url>
- </repository>
+ <!-- bootstrap for cytoscape dependencies, namely the parent POM snapshots
-->
+ <repository>
+ <id>cytoscape_snapshots</id>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <name>Cytoscape Snapshots</name>
+
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/</url>
+ </repository>
+ <!-- bootstrap for cytoscape dependencies, namely the parent POM releases
-->
+ <repository>
+ <id>cytoscape_releases</id>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <name>Cytoscape Releases</name>
+
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/releases/</url>
+ </repository>
</repositories>
<build>
@@ -92,18 +92,17 @@
</plugin>
</plugins>
</build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.cytoscape</groupId>
- <artifactId>property-api</artifactId>
- <version>3.0.0-alpha4</version>
- </dependency>
- </dependencies>
-
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>property-api</artifactId>
+ <version>3.0.0-alpha4</version>
+ </dependency>
+ </dependencies>
</project>
Copied:
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileChooserFilter.java
(from rev 26100,
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/tunables/utils/FileChooserFilter.java)
===================================================================
---
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileChooserFilter.java
(rev 0)
+++
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileChooserFilter.java
2011-07-11 16:53:35 UTC (rev 26136)
@@ -0,0 +1,86 @@
+package org.cytoscape.util.swing;
+
+
+import java.io.File;
+import java.util.Arrays;
+import javax.swing.filechooser.FileFilter;
+
+
+public final class FileChooserFilter extends FileFilter {
+ private final String description;
+ private final String[] extensions;
+
+ /** @param description a short description of the acceptable file type
+ * @param extension the file extension of the acceptable file type
+ */
+ public FileChooserFilter(final String description, final String
extension) {
+ super();
+ this.description = description;
+ this.extensions = new String[] { extension };
+ }
+
+ /** @param description a short description of the acceptable file
type(s)
+ * @param extension the file extension of the acceptable file
type(s)
+ */
+ public FileChooserFilter(final String description, final String[]
extensions) {
+ super();
+ this.description = description;
+ this.extensions = extensions;
+ }
+
+ /** Accept or not the file from JFileChooser.
+ * @param file the file to be tested
+ */
+ public boolean accept(final File file) {
+ if (file.isDirectory())
+ return true;
+
+ String fileName = file.getName().toLowerCase();
+
+ if (extensions != null) {
+ for(int i = 0; i < extensions.length; i++) {
+ if (fileName.endsWith(extensions[i]))
+ return true;
+ }
+
+ for(int i = 0; i < extensions.length; i++) {
+ if (fileName.contains(extensions[i]))
+ return true;
+ }
+ } else
+ throw new IllegalArgumentException("No fileType
specified");
+
+ return false;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String[] getExtensions() {
+ return extensions;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof FileChooserFilter))
+ return false;
+
+ final FileChooserFilter otherFilter = (FileChooserFilter)other;
+ if (!otherFilter.description.equals(description))
+ return false;
+
+ if (otherFilter.extensions.length != extensions.length)
+ return false;
+
+ Arrays.sort(otherFilter.extensions);
+ Arrays.sort(extensions);
+
+ for (int i = 0; i < extensions.length; ++i) {
+ if (!extensions[i].equals(otherFilter.extensions[i]))
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
Modified:
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileUtil.java
===================================================================
---
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileUtil.java
2011-07-11 15:10:38 UTC (rev 26135)
+++
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/FileUtil.java
2011-07-11 16:53:35 UTC (rev 26136)
@@ -1,15 +1,8 @@
/*
File: FileUtil.java
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2006, 2011, The Cytoscape Consortium (www.cytoscape.org)
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
@@ -36,11 +29,13 @@
*/
package org.cytoscape.util.swing;
+
import java.awt.Component;
import java.awt.FileDialog;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collection;
/**
@@ -49,6 +44,8 @@
* instead of the Swing FileChooser.
*/
public interface FileUtil {
+ /** The Cytoscape property that stores the last save/load directory. */
+ final String LAST_DIRECTORY = "directory.last";
/**
*
@@ -76,113 +73,88 @@
* of rolling your own JFileChooser.
*
* @return the location of the selcted file
+ * @param parent the parent of the JFileChooser or FileDialog
* @param title the title of the dialog box
* @param load_save_custom a flag for the type of file dialog
+ * @param filters a non-empty collection of file filters
*/
- File getFile(String title, int load_save_custom);
+ File getFile(Component parent, String title, int load_save_custom,
+ Collection<FileChooserFilter> filters);
/**
* Returns a File object, this method should be used instead
* of rolling your own JFileChooser.
*
* @return the location of the selcted file
+ * @param parent the parent of the JFileChooser or FileDialog
* @param title the title of the dialog box
* @param load_save_custom a flag for the type of file dialog
- * @param filters an array of CyFileFilters that let you filter
+ * @param filters an array of FileChooserFilters that let you filter
* based on extension
* @param start_dir an alternate start dir, if null the default
* cytoscape MUD will be used
* @param custom_approve_text if this is a custom dialog, then
* custom text should be on the approve
* button.
+ * @param filters a non-empty collection of file filters
*/
- File getFile(String title, int load_save_custom,
- String start_dir, String
custom_approve_text) ;
+ File getFile(Component parent, String title, int load_save_custom,
String start_dir,
+ String custom_approve_text, Collection<FileChooserFilter>
filters);
-
- /**
- * Returns an array of File objects, this method should be used instead
- * of rolling your own JFileChooser.
- * @return the location of the selcted file
- * @param parent the parent component of the JFileChooser dialog
- * @param title the title of the dialog box
- * @param load_save_custom a flag for the type of file dialog
- * @param filters an array of CyFileFilters that let you filter
- * based on extension
- */
- File[] getFiles(Component parent, String title, int load_save_custom) ;
+ /**
+ * Returns an array of File objects, this method should be used instead
+ * of rolling your own JFileChooser.
+ * @return the location of the selcted file
+ * @param parent the parent of the JFileChooser or FileDialog
+ * @param title the title of the dialog box
+ * @param load_save_custom a flag for the type of file dialog
+ * @param filters a non-empty collection of file filters
+ */
+ File[] getFiles(Component parent, String title, int load_save_custom,
+ Collection<FileChooserFilter> filters);
-
/**
* Returns a list of File objects, this method should be used instead
* of rolling your own JFileChooser.
*
* @return and array of selected files, or null if none are selected
+ * @param parent the parent of the JFileChooser or FileDialog
* @param title the title of the dialog box
* @param load_save_custom a flag for the type of file dialog
- * @param filters an array of CyFileFilters that let you filter
+ * @param filters an array of FileChooserFilters that let you filter
* based on extension
* @param start_dir an alternate start dir, if null the default
* cytoscape MUD will be used
* @param custom_approve_text if this is a custom dialog, then
* custom text should be on the approve
* button.
+ * @param filters a non-empty collection of file filters
*/
- File[] getFiles(String title, int load_save_custom,
- String start_dir, String
custom_approve_text) ;
-
- /**
- * Returns a list of File objects, this method should be used instead
- * of rolling your own JFileChooser.
- *
- * @return and array of selected files, or null if none are selected
- * @param title the title of the dialog box
- * @param load_save_custom a flag for the type of file dialog
- * @param filters an array of CyFileFilters that let you filter
- * based on extension
- * @param start_dir an alternate start dir, if null the default
- * cytoscape MUD will be used
- * @param custom_approve_text if this is a custom dialog, then
- * custom text should be on the approve
- * button.
- * @param multiselect Enable selection of multiple files (Macs are
- * still limited to a single file because we use
- * FileDialog there -- is this fixed in Java 1.5?)
- */
- File[] getFiles(String title, int load_save_custom,
- String start_dir, String custom_approve_text, boolean multiselect) ;
-
- /**
- * Returns a list of File objects, this method should be used instead
- * of rolling your own JFileChooser.
- *
- * @return and array of selected files, or null if none are selected
- * @param parent the parent of the JFileChooser dialog
- * @param title the title of the dialog box
- * @param load_save_custom a flag for the type of file dialog
- * @param filters an array of CyFileFilters that let you filter
- * based on extension
- * @param start_dir an alternate start dir, if null the default
- * cytoscape MUD will be used
- * @param custom_approve_text if this is a custom dialog, then
- * custom text should be on the approve
- * button.
- * @param multiselect Enable selection of multiple files (Macs are
- * still limited to a single file because we use
- * FileDialog there -- is this fixed in Java 1.5?)
- */
File[] getFiles(Component parent, String title, int load_save_custom,
- String start_dir, String
custom_approve_text, boolean multiselect) ;
-
+ String start_dir, String custom_approve_text,
+ Collection<FileChooserFilter> filters);
+
/**
- * Get the most recently used directory.
+ * Returns a list of File objects, this method should be used instead
+ * of rolling your own JFileChooser.
+ *
+ * @return and array of selected files, or null if none are selected
+ * @param parent the parent of the JFileChooser or FileDialog
+ * @param title the title of the dialog box
+ * @param load_save_custom a flag for the type of file dialog
+ * @param filters an array of FileChooserFilters that let you filter
+ * based on extension
+ * @param start_dir an alternate start dir, if null the default
+ * cytoscape MUD will be used
+ * @param custom_approve_text if this is a custom dialog, then
+ * custom text should be on the approve
+ * button.
+ * @param multiselect Enable selection of multiple files (Macs are
+ * still limited to a single file because we use
+ * FileDialog there -- is this fixed in Java 1.5?)
+ * @param filters a non-empty collection of file filters
*/
- File getMRUD();
-
- /**
- * Set the most recently used directory.
- * @param mrud The most recently used directory.
- */
- void setMRUD(File mrud);
-
+ File[] getFiles(Component parent, String title, int load_save_custom,
+ String start_dir, String custom_approve_text, boolean
multiselect,
+ Collection<FileChooserFilter> filters);
}
Modified:
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/internal/FileUtilImpl.java
===================================================================
---
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/internal/FileUtilImpl.java
2011-07-11 15:10:38 UTC (rev 26135)
+++
core3/swing-util-api/trunk/src/main/java/org/cytoscape/util/swing/internal/FileUtilImpl.java
2011-07-11 16:53:35 UTC (rev 26136)
@@ -1,15 +1,8 @@
/*
File: FileUtil.java
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2006, 2011, The Cytoscape Consortium (www.cytoscape.org)
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
@@ -33,9 +26,10 @@
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
+*/
package org.cytoscape.util.swing.internal;
+
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Dialog;
@@ -43,38 +37,50 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.util.Collection;
+import java.util.Properties;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
+import org.cytoscape.property.CyProperty;
+import org.cytoscape.util.swing.FileChooserFilter;
import org.cytoscape.util.swing.FileUtil;
+
class FileUtilImpl implements FileUtil {
-
- private File mrud;
+ private final Properties coreProperties;
- FileUtilImpl() {
- mrud = new File(System.getProperty("user.dir"));
+ FileUtilImpl(final CyProperty<Properties> cyCoreProperty)
+ {
+ coreProperties = cyCoreProperty.getProperties();
}
-
+
/**
* {@inheritDoc}
*/
- public File getFile(String title, int load_save_custom) {
- return getFile(title, load_save_custom, null, null);
+ @Override
+ public File getFile(final Component parent, final String title, final
int load_save_custom,
+ final Collection<FileChooserFilter> filters)
+ {
+ return getFile(parent, title, load_save_custom, null, null,
filters);
}
/**
* {@inheritDoc}
*/
- public File getFile(String title, int load_save_custom, String
start_dir,
- String custom_approve_text) {
- File[] result = getFiles(title, load_save_custom, start_dir,
- custom_approve_text, false);
+ @Override
+ public File getFile(final Component parent, final String title, final
int load_save_custom,
+ final String start_dir, final String
custom_approve_text,
+ final Collection<FileChooserFilter> filters)
+ {
+ File[] result = getFiles(parent, title, load_save_custom,
start_dir,
+ custom_approve_text, false, filters);
return ((result == null) || (result.length <= 0)) ? null :
result[0];
}
@@ -82,83 +88,75 @@
/**
* {@inheritDoc}
*/
- public File[] getFiles(Component parent, String title, int
load_save_custom) {
- return getFiles(parent, title, load_save_custom, null, null,
true);
+ @Override
+ public File[] getFiles(final Component parent, final String title,
+ final int load_save_custom,
+ final Collection<FileChooserFilter> filters)
+ {
+ return getFiles(parent, title, load_save_custom, null, null,
true, filters);
}
/**
* {@inheritDoc}
*/
- public File[] getFiles(String title, int load_save_custom,
- String start_dir, String custom_approve_text) {
- return getFiles(null, title, load_save_custom, start_dir,
- custom_approve_text, true);
+ @Override
+ public File[] getFiles(final Component parent, final String title,
+ final int load_save_custom, final String
start_dir,
+ final String custom_approve_text,
+ final Collection<FileChooserFilter> filters)
+ {
+ return getFiles(parent, title, load_save_custom, start_dir,
+ custom_approve_text, true, filters);
}
/**
* {@inheritDoc}
*/
- public File[] getFiles(String title, int load_save_custom,
- String start_dir, String custom_approve_text, boolean
multiselect) {
- return getFiles(null, title, load_save_custom, start_dir,
- custom_approve_text, multiselect);
- }
-
- /**
- * {@inheritDoc}
- */
- public File[] getFiles(Component parent, String title,
- int load_save_custom, String start_dir, String
custom_approve_text,
- boolean multiselect) {
-
+ @Override
+ public File[] getFiles(final Component parent, final String title,
+ final int load_save_custom, final String
start_dir,
+ final String custom_approve_text, final boolean
multiselect,
+ final Collection<FileChooserFilter> filters)
+ {
if (parent == null)
- throw new NullPointerException("Parent component is
null");
+ throw new NullPointerException("\"parent\" must not be
null!");
File start = null;
if (start_dir == null)
- start = getMRUD();
+ start = new
File(coreProperties.getProperty(FileUtil.LAST_DIRECTORY,
+
System.getProperty("user.dir")));
else
start = new File(start_dir);
String osName = System.getProperty("os.name");
- // System.out.println( "Os name: "+osName );
- /* TODO -- FIX THIS!
if (osName.startsWith("Mac")) {
- // this is a Macintosh, use the AWT style file dialog
- FileDialog chooser;
- if ( parent instanceof Frame )
+ // This is a Macintosh, use the AWT style file dialog
+ FileDialog chooser;
+ if (parent instanceof Frame)
chooser = new FileDialog((Frame) parent, title,
load_save_custom);
- else
+ else
chooser = new FileDialog((Dialog) parent,
title, load_save_custom);
- // we can only set the one filter; therefore, create a
special
- // version of CyFileFilter that contains all extensions
- // TODO fix this so we actually use the filters we're
given
- // CyFileFilter fileFilter = new CyFileFilter(new
String[]{},new
- // String[]{},"All network files");
-
- // chooser.setFilenameFilter(fileFilter);
-
+ chooser.setFilenameFilter(new
CombinedFilenameFilter(filters));
chooser.setVisible(true);
if (chooser.getFile() != null) {
- File[] result = new File[1];
- result[0] = new File(chooser.getDirectory() +
"/"
- + chooser.getFile());
+ File[] results = new File[1];
+ results[0] = new File(chooser.getDirectory() +
File.separator
+ + chooser.getFile());
- if (chooser.getDirectory() != null) {
- setMRUD(new
File(chooser.getDirectory()));
- }
+ if (chooser.getDirectory() != null)
+
coreProperties.setProperty(FileUtil.LAST_DIRECTORY,
+
chooser.getDirectory());
- return result;
+ return results;
}
return null;
} else {
- */
- // this is not a mac, use the Swing based file dialog
+ // this is not a Mac, use the Swing based file dialog
final JFileChooser chooser = new JFileChooser(start);
// set multiple selection, if applicable
@@ -167,48 +165,61 @@
// set the dialog title
chooser.setDialogTitle(title);
- // add filters
- // TODO: fix Filter
- // for (int i = 0; i < filters.length; ++i) {
- // chooser.addChoosableFileFilter(filters[i]);
- // }
+ chooser.setAcceptAllFileFilterUsed(load_save_custom ==
LOAD);
- File[] result = null;
+ int i = 0;
+ FileChooserFilter defaultFilter = null;
+ for (final FileChooserFilter filter : filters) {
+ // If we're down to the last filter and we
haven't yet selected a default,
+ // do it now!
+ if (++i == filters.size() && defaultFilter ==
null)
+ defaultFilter = filter;
+
+ // If we haven't yet selected a default and our
filter's description starts
+ // with "All ", make it the default.
+ else if (defaultFilter == null &&
filter.getDescription().startsWith("All "))
+ defaultFilter = filter;
+
+
+ chooser.addChoosableFileFilter(filter);
+ }
+
+ File[] results = null;
File tmp = null;
// set the dialog type
if (load_save_custom == LOAD) {
if (chooser.showOpenDialog(parent) ==
JFileChooser.APPROVE_OPTION) {
if (multiselect)
- result =
chooser.getSelectedFiles();
+ results =
chooser.getSelectedFiles();
else if ((tmp =
chooser.getSelectedFile()) != null) {
- result = new File[1];
- result[0] = tmp;
+ results = new File[1];
+ results[0] = tmp;
}
}
} else if (load_save_custom == SAVE) {
if (chooser.showSaveDialog(parent) ==
JFileChooser.APPROVE_OPTION) {
if (multiselect)
- result =
chooser.getSelectedFiles();
+ results =
chooser.getSelectedFiles();
else if ((tmp =
chooser.getSelectedFile()) != null) {
- result = new File[1];
- result[0] = tmp;
+ results = new File[1];
+ results[0] = tmp;
}
- // FileDialog checks for overwrte, but
JFileChooser does
- // not, so we need to do
- // so ourselves
- for (int i = 0; i < result.length; i++)
{
- if (result[i].exists()) {
- int answer = JOptionPane
-
.showConfirmDialog(
-
chooser,
-
"The file '"
-
+ result[i].getName()
-
+ "' already exists, are you sure you want to overwrite
it?",
-
"File exists",
-
JOptionPane.YES_NO_OPTION,
-
JOptionPane.WARNING_MESSAGE);
- if (answer == 1)
+
+ // FileDialog checks for overwrites,
but JFileChooser does
+ // not, so we need to do so ourselves:
+ for (int k = 0; k < results.length;
++k) {
+ if (results[k].exists()) {
+ int answer =
+
JOptionPane.showConfirmDialog(
+ chooser,
+ "The
file '"
+ +
results[k].getName()
+ + "'
already exists, are you sure you want to overwrite it?",
+ "File
exists",
+
JOptionPane.YES_NO_OPTION,
+
JOptionPane.WARNING_MESSAGE);
+ if (answer ==
JOptionPane.YES_OPTION)
return null;
}
}
@@ -216,33 +227,38 @@
} else {
if (chooser.showDialog(parent,
custom_approve_text) == JFileChooser.APPROVE_OPTION) {
if (multiselect)
- result =
chooser.getSelectedFiles();
+ results =
chooser.getSelectedFiles();
else if ((tmp =
chooser.getSelectedFile()) != null) {
- result = new File[1];
- result[0] = tmp;
+ results = new File[1];
+ results[0] = tmp;
}
}
}
- if ((result != null) && (start_dir == null))
- setMRUD(chooser.getCurrentDirectory());
+ if (results != null && start_dir == null)
+
coreProperties.setProperty(FileUtil.LAST_DIRECTORY,
+
chooser.getCurrentDirectory().getPath());
- return result;
- //}
+ return results;
+ }
}
- /**
- * Get the most recently used directory.
- */
- public synchronized File getMRUD() {
- return mrud;
- }
+ private static final class CombinedFilenameFilter implements
FilenameFilter {
+ private final Collection<FileChooserFilter> filters;
- /**
- * Set the most recently used directory.
- */
- public synchronized void setMRUD(File mrud_new) {
- if ( mrud_new != null )
- mrud = mrud_new;
+ CombinedFilenameFilter(final Collection<FileChooserFilter>
filters) {
+ this.filters = filters;
+ }
+
+ @Override
+ public boolean accept(final File dir, final String name) {
+ final File path = new File(dir, name);
+ for (final FileChooserFilter filter : filters) {
+ if (filter.accept(path))
+ return true;
+ }
+
+ return false;
+ }
}
}
Modified:
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-07-11 15:10:38 UTC (rev 26135)
+++
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2011-07-11 16:53:35 UTC (rev 26136)
@@ -5,7 +5,6 @@
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd"
default-lazy-init="false">
-
<osgi:reference id="cytoscapePropertiesServiceRef"
interface="org.cytoscape.property.CyProperty"
filter="(cyPropertyName=coreSettings)" />
@@ -15,6 +14,4 @@
<osgi:service id="openBrowserService" ref="openBrowser"
interface="org.cytoscape.util.swing.OpenBrowser" />
-
-
</beans>
Modified:
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-07-11 15:10:38 UTC (rev 26135)
+++
core3/swing-util-api/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2011-07-11 16:53:35 UTC (rev 26136)
@@ -22,6 +22,7 @@
<context:annotation-config />
<bean name="fileUtil"
class="org.cytoscape.util.swing.internal.FileUtilImpl">
+ <constructor-arg ref="cytoscapePropertiesServiceRef" />
</bean>
<bean name="openBrowser"
class="org.cytoscape.util.swing.internal.OpenBrowserImpl">
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.