svn commit: r15087 - trunk/src/argouml-app/src/org/argouml: uml/reveng uml/reveng/java util

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-06-26 12:41:05-0700
New Revision: 15087

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java
   trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java
   trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java
   trunk/src/argouml-app/src/org/argouml/util/FileFilters.java
   trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java

Log:
Issue 5183: Default file filter for classfile importer should include both .class and .jar

Refactor module-specific strings out of core ArgoUML

Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java?view=diff&rev=15087&p1=trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java&p2=trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java&r1=15086&r2=15087
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/FileImportUtils.java	2008-06-26 12:41:05-0700
@@ -145,10 +145,9 @@
         if (!(file instanceof File)) {

             return false;

         }

-        String fileName = ((File) file).getName();

 	if (filters != null) {

 	    for (int i = 0; i < filters.length; i++) {

-		if (fileName.endsWith(filters[i].getSuffix())) {

+		if (filters[i].accept((File) file)) {

 		    return true;

 		}

 	    }


Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java?view=diff&rev=15087&p1=trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java&p2=trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java&r1=15086&r2=15087
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java	2008-06-26 12:41:05-0700
@@ -520,6 +520,9 @@
             for (int i = 0; i < newFilters.length; i++) {
                 chooser.addChoosableFileFilter(newFilters[i]);
             }
+            if (newFilters.length > 0) {
+                chooser.setFileFilter(newFilters[0]);
+            }
         }
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java?view=diff&rev=15087&p1=trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java&p2=trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java&r1=15086&r2=15087
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/java/JavaImport.java	2008-06-26 12:41:05-0700
@@ -300,7 +300,10 @@
      * @see org.argouml.uml.reveng.ImportInterface#getSuffixFilters()
      */
     public SuffixFilter[] getSuffixFilters() {
-	SuffixFilter[] result = {FileFilters.JAVA_FILE_FILTER};
+        SuffixFilter[] result = {
+            new SuffixFilter("java", 
+                    Translator.localize("combobox.filefilter.java")),
+        };
 	return result;
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/util/FileFilters.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/util/FileFilters.java?view=diff&rev=15087&p1=trunk/src/argouml-app/src/org/argouml/util/FileFilters.java&p2=trunk/src/argouml-app/src/org/argouml/util/FileFilters.java&r1=15086&r2=15087
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/util/FileFilters.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/util/FileFilters.java	2008-06-26 12:41:05-0700
@@ -37,9 +37,6 @@
  */
 public class FileFilters {
 
-    ////////////////////////////////////////////////////////////////
-    // constants
-
     /**
      * This is a filter for uncompressed project format.
      */
@@ -86,18 +83,16 @@
     public static final SuffixFilter LOG_FILTER = new
         SuffixFilter("log", "Argo usage log");
 
-    /** Java Source File Filter */
+    /**
+     * Java Source File Filter
+     * 
+     * @deprecated for 0.26 by tfmorris. This will be removed from the core when
+     *             the Java importer is moved to a separate module.
+     */
+    @Deprecated
     public static final SuffixFilter JAVA_FILE_FILTER = new
         SuffixFilter("java", Translator.localize("combobox.filefilter.java"));
 
-    /** Java Class File Filter */
-    public static final SuffixFilter JAVA_CLASS_FILTER = new
-        SuffixFilter("class", "Java Class File");
-
-    /** Java JAR File Filter */
-    public static final SuffixFilter JAVA_JAR_FILTER = new
-        SuffixFilter("jar", "Java JAR File");
-
     /** 
      * This writes the GIF file.
      */
@@ -145,10 +140,6 @@
     public static final SuffixFilter SVG_FILTER = new
         SuffixFilter("svg", Translator.localize("combobox.filefilter.svg"));
 
-    /** Filter for IDL files */
-    public static final SuffixFilter IDL_FILTER = new
-		SuffixFilter("idl", "Interface Definition Language file");
-
     /**
      * Returns the suffix for which a FileFilter filters.
      * @param filter The FileFilter from which we want to know the suffix
@@ -162,4 +153,4 @@
         return null;
     }
 
-} /* end class FileFilters */
+} 

Modified: trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java?view=diff&rev=15087&p1=trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java&p2=trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java&r1=15086&r2=15087
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java	2008-06-26 12:41:05-0700
@@ -25,6 +25,7 @@
 package org.argouml.util;
 
 import java.io.File;
+
 import javax.swing.filechooser.FileFilter;
 
 /**
@@ -33,29 +34,32 @@
  */
 public class SuffixFilter extends FileFilter {
 
-    ////////////////////////////////////////////////////////////////
-    // instance varaibles
-
-    private final String suffix;
+    private final String[] suffixes;
     private final String desc;
 
-    ////////////////////////////////////////////////////////////////
-    // constructor
-
     /**
-     * The constructor.
+     * Construct a file filter files with the given suffix and description.
      *
-     * @param s the suffix string
+     * @param suffix the suffix string
      * @param d the file type description
      */
-    public SuffixFilter(String s, String d) {
-	suffix = s;
+    public SuffixFilter(String suffix, String d) {
+        suffixes = new String[] {suffix};
 	desc = d;
     }
 
-    ////////////////////////////////////////////////////////////////
-    // FileFilter API
-
+    /**
+     * Construct a filter for an array of suffixes
+     *
+     * @param s the suffixes string
+     * @param d the file type description
+     */
+    public SuffixFilter(String[] s, String d) {
+        suffixes = new String[s.length];
+        System.arraycopy(s, 0, suffixes, 0, s.length);
+        desc = d;
+    }
+    
     /*
      * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
      */
@@ -67,8 +71,10 @@
             return true;
         }
 	String extension = getExtension(f);
-	if (suffix.equalsIgnoreCase(extension)) {
-            return true;
+        for (String suffix : suffixes) {
+            if (suffix.equalsIgnoreCase(extension)) {
+                return true;
+            }
         }
 	return false;
     }
@@ -100,17 +106,29 @@
      * @see javax.swing.filechooser.FileFilter#getDescription()
      */
     public String getDescription() {
-	return desc + " (*." + suffix + ")";
+        String result = desc + " (";
+        for (int i = 0; i < suffixes.length - 1; i++) {
+            result = result + "." + suffixes[i] + ", ";
+        }
+        result = result + suffixes[suffixes.length - 1] + ")";
+        return result;
     }
 
     /**
-     * @return Returns the _suffix.
+     * @return Returns the default or preferred suffix for this type of file.
      */
     public String getSuffix() {
-        return suffix;
+        return suffixes[0];
     }
 
     /**
+     * @return Returns the list of all acceptable suffixes.
+     */
+    public String[] getSuffixes() {
+        return suffixes;
+    }
+    
+    /**
      * Adding this function enables easy selection of suffixfilters
      * e.g. in a combobox.
      *
@@ -120,4 +138,4 @@
         return getDescription();
     }
 
-} /* end class SuffixFilter */
+}
\ No newline at end of file
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.