Author: tfmorris
Date: 2008-04-06 12:28:59-0700
New Revision: 14295
Modified:
trunk/src/app/src/org/argouml/uml/reveng/Import.java
trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java
Log:
All multiple disjoint source file selections.
Interpret no selection as selecting the current directory.
Fix error dialog display
Add Java 5 generics.
Modified: trunk/src/app/src/org/argouml/uml/reveng/Import.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/uml/reveng/Import.java?view=diff&rev=14295&p1=trunk/src/app/src/org/argouml/uml/reveng/Import.java&p2=trunk/src/app/src/org/argouml/uml/reveng/Import.java&r1=14294&r2=14295
==============================================================================
--- trunk/src/app/src/org/argouml/uml/reveng/Import.java (original)
+++ trunk/src/app/src/org/argouml/uml/reveng/Import.java 2008-04-06 12:28:59-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -66,6 +66,7 @@
import org.argouml.moduleloader.ModuleInterface;
import org.argouml.taskmgmt.ProgressEvent;
import org.argouml.taskmgmt.ProgressMonitor;
+import org.argouml.uml.reveng.java.JavaImport;
import org.argouml.util.SuffixFilter;
import org.argouml.util.UIUtils;
import org.tigris.gef.base.Globals;
@@ -93,8 +94,6 @@
*/
public class Import extends ImportCommon implements ImportSettings {
- private static final String SEPARATOR = "/";
-
private JComponent configPanel;
private JCheckBox descend;
@@ -130,7 +129,6 @@
private Frame myFrame;
-
/**
* The default extended configuration panel.
* TODO: This used to be provided by the abstract class FileImportSupport
@@ -554,15 +552,26 @@
private Import theImport;
- /*
+ /**
+ * Constructs a new ImportFileChooser opened to the given directory.
+ *
+ * @param imp the import manager
+ * @param currentDirectoryPath the directory path
* @see javax.swing.JFileChooser#JFileChooser(String)
*/
public ImportFileChooser(Import imp, String currentDirectoryPath) {
super(currentDirectoryPath);
theImport = imp;
+ initChooser();
}
- /*
+ /**
+ * Constructs a JFileChooser using the given current directory path and
+ * FileSystemView.
+ *
+ * @param imp the import manager
+ * @param currentDirectoryPath the directory path
+ * @param fsv the file system view
* @see javax.swing.JFileChooser#JFileChooser(String, FileSystemView)
*/
public ImportFileChooser(
@@ -571,17 +580,26 @@
FileSystemView fsv) {
super(currentDirectoryPath, fsv);
theImport = imp;
+ initChooser();
}
- /*
+ /**
+ * Constructs a new default ImportFileChooser.
+ *
+ * @param imp the import manager
* @see javax.swing.JFileChooser#JFileChooser()
*/
public ImportFileChooser(Import imp) {
super();
theImport = imp;
+ initChooser();
}
- /*
+ /**
+ * Constructs a JFileChooser using the given FileSystemView.
+ *
+ * @param imp the import manager
+ * @param fsv the file system view
* @see javax.swing.JFileChooser#JFileChooser(FileSystemView)
*/
public ImportFileChooser(
@@ -589,32 +607,51 @@
FileSystemView fsv) {
super(fsv);
theImport = imp;
+ initChooser();
}
+
+ private void initChooser() {
+ setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+ setMultiSelectionEnabled(true);
+ setSelectedFile(getCurrentDirectory());
+ }
+
/*
* @see javax.swing.JFileChooser#approveSelection()
*/
+ @Override
public void approveSelection() {
- theImport.setSelectedFile(getSelectedFile());
- if (getSelectedFile() != null) {
- String path = getSelectedFile().getParent();
- String filename =
- path + SEPARATOR + getSelectedFile().getName();
- Globals.setLastDirectory(path);
- if (filename != null) {
- theImport.disposeDialog();
- // TODO: This is only relevant for Java import
- // move out of normal control flow. The OK button of this
- // dialog transfers to Import.doFile
- new ImportClasspathDialog(theImport);
- return;
+ File[] files = getSelectedFiles();
+ File dir = getCurrentDirectory();
+ if (files.length == 0) {
+ files = new File[] {dir};
+ }
+ if (files.length == 1) {
+ File file = files[0];
+ if (file != null && file.isDirectory()) {
+ dir = file;
+ } else {
+ dir = file.getParentFile();
}
}
+ theImport.setSelectedFiles(files);
+ Globals.setLastDirectory(dir.getPath());
+ theImport.disposeDialog();
+
+ if (theImport.getCurrentModule() instanceof JavaImport) {
+ // The OK button of this
+ // dialog transfers to Import.doFile
+ new ImportClasspathDialog(theImport);
+ } else {
+ theImport.doFile();
+ }
}
/*
* @see javax.swing.JFileChooser#cancelSelection()
*/
+ @Override
public void cancelSelection() {
theImport.disposeDialog();
}
@@ -739,7 +776,7 @@
String message) {
// TODO: Create an error dialog or panel in our progress dialog
// for now we just use our old style separate error dialog
- JDialog problemsDialog = new ProblemsDialog(message);
+ JDialog problemsDialog = new ProblemsDialog(getFrame(), message);
problemsDialog.setTitle(title);
problemsDialog.setVisible(true);
// TODO: Only needed while we have a separate problem dialog
@@ -799,15 +836,15 @@
/**
* The constructor.
*/
- public ProblemsDialog() {
- this(problems.toString());
+ ProblemsDialog() {
+ this(getFrame(), problems.toString());
}
/**
* The constructor.
*/
- public ProblemsDialog(String errors) {
- super();
+ ProblemsDialog(Frame frame, String errors) {
+ super(frame);
setResizable(true);
setModal(true);
setTitle(Translator.localize("dialog.title.import-problems"));
@@ -855,7 +892,7 @@
disposeDialog();
}
- public void disposeDialog() {
+ private void disposeDialog() {
setVisible(false);
dispose();
}
Modified: trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java?view=diff&rev=14295&p1=trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java&p2=trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java&r1=14294&r2=14295
==============================================================================
--- trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java (original)
+++ trunk/src/app/src/org/argouml/uml/reveng/ImportCommon.java 2008-04-06 12:28:59-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2006-2007 The Regents of the University of California. All
+// Copyright (c) 2006-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -29,6 +29,7 @@
import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -91,7 +92,7 @@
*/
private DiagramInterface diagramInterface;
- private File selectedFile;
+ private File[] selectedFiles;
protected ImportCommon() {
super();
@@ -172,23 +173,25 @@
}
/**
- * Get the files. For old style modules, this asks the module for the list.
- * For new style modules we generate it ourselves based on their specified
+ * Get the files. We generate it based on their specified
* file suffixes.
* @param monitor progress monitor which can be used to cancel long running
* request
* @return the list of files to be imported
*/
- protected List getFileList(ProgressMonitor monitor) {
- List files;
- files =
+ protected List<File> getFileList(ProgressMonitor monitor) {
+ List<File> files = Arrays.asList(getSelectedFiles());
+ if (files.size() == 1) {
+ File file = files.get(0);
+ files =
FileImportUtils.getList(
- getSelectedFile(), isDescendSelected(), currentModule
- .getSuffixFilters(), monitor);
- if (getSelectedFile().isDirectory()) {
- setSrcPath(getSelectedFile().getAbsolutePath());
- } else {
- setSrcPath(null);
+ file, isDescendSelected(), currentModule
+ .getSuffixFilters(), monitor);
+ if (file.isDirectory()) {
+ setSrcPath(file.getAbsolutePath());
+ } else {
+ setSrcPath(null);
+ }
}
@@ -197,7 +200,7 @@
Object model =
ProjectManager.getManager().getCurrentProject().getModel();
for (int i = files.size() - 1; i >= 0; i--) {
- File f = (File) files.get(i);
+ File f = files.get(i);
String fn = f.getAbsolutePath();
String lm = String.valueOf(f.lastModified());
if (lm.equals(
@@ -272,14 +275,33 @@
return modules;
}
+ /**
+ * @param file the selected file
+ * @deprecated for 0.25.5 by tfmorris. Use
+ * {@link #setSelectedFiles(File[])}.
+ */
+ @Deprecated
protected void setSelectedFile(File file) {
- selectedFile = file;
+ selectedFiles = new File[] {file};
}
+ /**
+ * @return the first selected file.
+ * @deprecated for 0.25.4 by tfmorris. Use {@link #getSelectedFiles()}.
+ */
+ @Deprecated
protected File getSelectedFile() {
- return selectedFile;
+ return selectedFiles[0];
+ }
+
+ protected void setSelectedFiles(final File[] files) {
+ selectedFiles = files;
}
+ protected File[] getSelectedFiles() {
+ return Arrays.copyOf(selectedFiles, selectedFiles.length);
+ }
+
protected void setCurrentModule(ImportInterface module) {
currentModule = module;
}
@@ -292,8 +314,9 @@
* Returns the possible languages in which the user can import the sources.
* @return a list of Strings with the names of the languages available
*/
- public List getLanguages() {
- return Collections.unmodifiableList(new ArrayList(modules.keySet()));
+ public List<String> getLanguages() {
+ return Collections.unmodifiableList(
+ new ArrayList<String>(modules.keySet()));
}
/**
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.