[Polycasso-commit] SF.net SVN: polycasso:[177] trunk/polycasso/src/com/mebigfatguy/polycasso/ FileS
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-12-10 12:38:49
|
Revision: 177
http://polycasso.svn.sourceforge.net/polycasso/?rev=177&view=rev
Author: dbrosius
Date: 2009-12-10 12:38:41 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2009-12-10 12:34:34 UTC (rev 176)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2009-12-10 12:38:41 UTC (rev 177)
@@ -23,14 +23,28 @@
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
+/**
+ * a class for picking a save as file name given the specified file type
+ */
public class FileSelector {
FileType fileType;
+ /**
+ * constructs a selector of the given type
+ *
+ * @param type the type of save operation desired
+ */
public FileSelector(FileType type) {
fileType = type;
}
+ /**
+ * shows a dialog to pick a save target. Ensures that the proper extension
+ * is given for the file
+ *
+ * @return the path of the selected file or null if not selected
+ */
public String getFileName() {
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new PolyFilter());
@@ -50,8 +64,16 @@
return null;
}
+ /**
+ * a file filter class for filtering only the files with the correct file extensions
+ */
class PolyFilter extends FileFilter {
+ /**
+ * implements the interface to select only files with the appropriate extension
+ *
+ * @return if the file is selectable
+ */
@Override
public boolean accept(File file) {
if (file.isDirectory()) {
@@ -61,6 +83,11 @@
return (file.getPath().endsWith(fileType.getExtension()));
}
+ /**
+ * returns a string to be shown in the dialog for the file type desired
+ *
+ * @return the type string
+ */
@Override
public String getDescription() {
return fileType.getDescription();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|