src/Tools/jEdit/src/jedit_thy_load.scala
changeset 44963 4662dddc2fd8
parent 44953 cdfe42f1267c
child 45007 cc86edb97c2c
     1.1 --- a/src/Tools/jEdit/src/jedit_thy_load.scala	Sun Sep 18 13:39:33 2011 +0200
     1.2 +++ b/src/Tools/jEdit/src/jedit_thy_load.scala	Sun Sep 18 13:47:12 2011 +0200
     1.3 @@ -9,11 +9,12 @@
     1.4  
     1.5  import isabelle._
     1.6  
     1.7 -import java.io.File
     1.8 +import java.io.{File, IOException}
     1.9  import javax.swing.text.Segment
    1.10  
    1.11 -import org.gjt.sp.jedit.io.{VFS, FileVFS, VFSManager}
    1.12 +import org.gjt.sp.jedit.io.{VFS, FileVFS, VFSFile, VFSManager}
    1.13  import org.gjt.sp.jedit.MiscUtilities
    1.14 +import org.gjt.sp.jedit.View
    1.15  
    1.16  
    1.17  class JEdit_Thy_Load extends Thy_Load
    1.18 @@ -31,6 +32,26 @@
    1.19      }
    1.20    }
    1.21  
    1.22 +  def check_file(view: View, path: String): Boolean =
    1.23 +  {
    1.24 +    val vfs = VFSManager.getVFSForPath(path)
    1.25 +    val session = vfs.createVFSSession(path, view)
    1.26 +
    1.27 +    try {
    1.28 +      session != null && {
    1.29 +        try {
    1.30 +          val file = vfs._getFile(session, path, view)
    1.31 +          file != null && file.isReadable && file.getType == VFSFile.FILE
    1.32 +        }
    1.33 +        catch { case _: IOException => false }
    1.34 +      }
    1.35 +    }
    1.36 +    finally {
    1.37 +      try { vfs._endVFSSession(session, view) }
    1.38 +      catch { case _: IOException => }
    1.39 +    }
    1.40 +  }
    1.41 +
    1.42    override def check_thy(name: Document.Node.Name): Thy_Header =
    1.43    {
    1.44      Swing_Thread.now {