[kepler-code] r28804 - trunk/modules/gui/src/org/kepler/gui/kar
brooks at ecoinformatics.org
brooks at ecoinformatics.org
Mon Oct 17 10:48:31 PDT 2011
Author: brooks
Date: 2011-10-17 10:48:30 -0700 (Mon, 17 Oct 2011)
New Revision: 28804
Modified:
trunk/modules/gui/src/org/kepler/gui/kar/OpenArchiveAction.java
Log:
Print a message only once if the last directory cannot be found.
Modified: trunk/modules/gui/src/org/kepler/gui/kar/OpenArchiveAction.java
===================================================================
--- trunk/modules/gui/src/org/kepler/gui/kar/OpenArchiveAction.java 2011-10-17 14:03:43 UTC (rev 28803)
+++ trunk/modules/gui/src/org/kepler/gui/kar/OpenArchiveAction.java 2011-10-17 17:48:30 UTC (rev 28804)
@@ -39,6 +39,7 @@
import ptolemy.actor.gui.Tableau;
import ptolemy.actor.gui.TableauFrame;
import ptolemy.gui.JFileChooserBugFix;
+import ptolemy.gui.MessageHandler;
import ptolemy.kernel.util.InternalErrorException;
import ptolemy.kernel.util.Nameable;
import ptolemy.vergil.toolbox.FigureAction;
@@ -152,7 +153,23 @@
JFileChooser chooser = new JFileChooser();
if(_lastDirectoryUsed == null)
{
- _lastDirectoryUsed = LocalRepositoryManager.getInstance().getSaveRepository().getPath();
+ try {
+ LocalRepositoryManager repositoryManager = LocalRepositoryManager.getInstance();
+ if (repositoryManager == null) {
+ throw new InternalErrorException("Could not get instance from LocalRepositoryManager?");
+ }
+ File saveRepository = repositoryManager.getSaveRepository();
+ if (saveRepository == null) {
+ throw new InternalErrorException("Could not get the save repository from the LocalRepositoryManager \""
+ + repositoryManager + "\"? Perhaps LocalRepositoryManager.setLocalSaveRepo() was not called?");
+ }
+ _lastDirectoryUsed = LocalRepositoryManager.getInstance().getSaveRepository().getPath();
+ } catch (InternalErrorException ex) {
+ if (!_printedFailedLastDirectoryMessage) {
+ _printedFailedLastDirectoryMessage = true;
+ MessageHandler.message("Failed to get the last directory opened:" + ex);
+ }
+ }
}
chooser.setCurrentDirectory(new File(_lastDirectoryUsed));
chooser.setFileFilter(filter);
@@ -339,4 +356,6 @@
/** The directory for the last open. */
private static String _lastDirectoryUsed = null;
-}
\ No newline at end of file
+ /** True if a message about failing to find last directory was printed. */
+ private static boolean _printedFailedLastDirectoryMessage = false;
+}
More information about the Kepler-cvs
mailing list