Author: thn Date: 2008-11-12 14:45:38-0800 New Revision: 16034 Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java
Log: make the selection of file filter functional, this is needed for the classfile importer since it has different file filters (plus completing the support for the case when no importer is available) 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=16034&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=16033&r2=16034 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java 2008-11-12 14:45:38-0800 @@ -609,6 +609,13 @@ } } theImport.setSelectedFiles(files); + try { + theImport.setSelectedSuffixFilter( + (SuffixFilter) getFileFilter()); + } catch (Exception e) { + // this is because of the (senseless?) "All files" FileFilter + theImport.setSelectedSuffixFilter(null); + } Globals.setLastDirectory(dir.getPath()); theImport.disposeDialog(); Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java?view=diff&rev=16034&p1=trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java&p2=trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java&r1=16033&r2=16034 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java 2008-11-12 14:45:38-0800 @@ -49,6 +49,7 @@ import org.argouml.uml.diagram.ArgoDiagram; import org.argouml.uml.diagram.static_structure.ClassDiagramGraphModel; import org.argouml.uml.diagram.static_structure.layout.ClassdiagramLayouter; +import org.argouml.util.SuffixFilter; import org.tigris.gef.base.Globals; /** @@ -95,6 +96,8 @@ private DiagramInterface diagramInterface; private File[] selectedFiles; + + private SuffixFilter selectedSuffixFilter; protected ImportCommon() { super(); @@ -104,16 +107,15 @@ .getImporters()) { modules.put(importer.getName(), importer); } - if (modules.size() == 0) { + if (modules.isEmpty()) { throw new RuntimeException("Internal error. " + "No importer modules found."); } - - // "Java" is a default module + // "Java" is the default module for historical reasons, + // but it's not required to be there currentModule = modules.get("Java"); if (currentModule == null) { - throw new RuntimeException("Internal error. " - + "Default import module not found"); + currentModule = modules.elements().nextElement(); } } @@ -162,10 +164,15 @@ List<File> files = Arrays.asList(getSelectedFiles()); if (files.size() == 1) { File file = files.get(0); + SuffixFilter suffixFilters[] = {selectedSuffixFilter}; + if (suffixFilters[0] == null) { + // not a SuffixFilter selected, so we take all + suffixFilters = currentModule.getSuffixFilters(); + } files = FileImportUtils.getList( - file, isDescendSelected(), currentModule - .getSuffixFilters(), monitor); + file, isDescendSelected(), + suffixFilters, monitor); if (file.isDirectory()) { setSrcPath(file.getAbsolutePath()); } else { @@ -277,6 +284,15 @@ selectedFiles = files; } + /** + * Set the selected (file) suffix filter. + * + * @param suffixFilter the (file) suffix filter + */ + protected void setSelectedSuffixFilter(final SuffixFilter suffixFilter) { + selectedSuffixFilter = suffixFilter; + } + protected File[] getSelectedFiles() { File[] copy = new File[selectedFiles.length]; for (int i = 0; i < selectedFiles.length; i++) 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=16034&p1=trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java&p2=trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java&r1=16033&r2=16034 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java (original) +++ trunk/src/argouml-app/src/org/argouml/util/SuffixFilter.java 2008-11-12 14:45:38-0800 @@ -106,12 +106,17 @@ * @see javax.swing.filechooser.FileFilter#getDescription() */ public String getDescription() { - String result = desc + " ("; - for (int i = 0; i < suffixes.length - 1; i++) { - result = result + "." + suffixes[i] + ", "; + StringBuffer result = new StringBuffer(desc); + result.append(" ("); + for (int i = 0; i < suffixes.length; i++) { + result.append('.'); + result.append(suffixes[i]); + if (i < suffixes.length - 1) { + result.append(", "); + } } - result = result + suffixes[suffixes.length - 1] + ")"; - return result; + result.append(')'); + return result.toString(); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
