From dc8bf216c42d8e44ce890c3e53fcb6c5573e110e Mon Sep 17 00:00:00 2001 From: Robert Grider Date: Tue, 5 Sep 2017 08:54:02 -0500 Subject: [PATCH] Only set model path when file exists and is not "empty.nlogo" --- netlogo-gui/src/main/window/ReconfigureWorkspaceUI.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/netlogo-gui/src/main/window/ReconfigureWorkspaceUI.scala b/netlogo-gui/src/main/window/ReconfigureWorkspaceUI.scala index df54b5f437..dfc9ce546c 100644 --- a/netlogo-gui/src/main/window/ReconfigureWorkspaceUI.scala +++ b/netlogo-gui/src/main/window/ReconfigureWorkspaceUI.scala @@ -4,7 +4,7 @@ package org.nlogo.window import java.awt.Container import java.net.URI -import java.nio.file.Paths +import java.nio.file.{ Files, Paths } import org.nlogo.window.Events.{ AfterLoadEvent, BeforeLoadEvent, LoadBeginEvent, LoadEndEvent, LoadModelEvent, LoadWidgetsEvent } @@ -23,7 +23,10 @@ object ReconfigureWorkspaceUI { def getLinkParent = linkParent def loadHelper(modelURI: URI, modelType: ModelType, model: Model, compilerServices: CompilerServices) { - val uriOption = Try(Paths.get(modelURI).toString).toOption + val uriOption = Try(Paths.get(modelURI)).toOption + .filterNot(p => p.getFileName.toString.startsWith("empty.nlogo")) + .filter(p => Files.isRegularFile(p)) + .map(_.toString) val beforeEvents = List( new BeforeLoadEvent(uriOption, modelType), new LoadBeginEvent())