src/Tools/jEdit/src/plugin.scala
changeset 46761 b0a797158e34
parent 46740 852baa599351
child 46771 06a9b24c4a36
     1.1 --- a/src/Tools/jEdit/src/plugin.scala	Fri Mar 02 19:05:13 2012 +0100
     1.2 +++ b/src/Tools/jEdit/src/plugin.scala	Fri Mar 02 21:22:42 2012 +0100
     1.3 @@ -344,32 +344,36 @@
     1.4        val view = jEdit.getActiveView()
     1.5  
     1.6        val buffers = Isabelle.jedit_buffers().toList
     1.7 -      def loaded_buffer(name: String): Boolean =
     1.8 -        buffers.exists(buffer => Isabelle.buffer_name(buffer) == name)
     1.9 +      if (buffers.forall(_.isLoaded)) {
    1.10 +        def loaded_buffer(name: String): Boolean =
    1.11 +          buffers.exists(buffer => Isabelle.buffer_name(buffer) == name)
    1.12  
    1.13 -      val thys =
    1.14 -        for (buffer <- buffers; model <- Isabelle.document_model(buffer))
    1.15 -          yield model.name
    1.16 -      val files = Isabelle.thy_info.dependencies(thys).map(_._1.node).
    1.17 -        filter(file => !loaded_buffer(file) && Isabelle.thy_load.check_file(view, file))
    1.18 +        val thys =
    1.19 +          for (buffer <- buffers; model <- Isabelle.document_model(buffer))
    1.20 +            yield model.name
    1.21 +
    1.22 +        // FIXME avoid I/O in Swing thread!?!
    1.23 +        val files = Isabelle.thy_info.dependencies(thys).map(_._1.node).
    1.24 +          filter(file => !loaded_buffer(file) && Isabelle.thy_load.check_file(view, file))
    1.25  
    1.26 -      if (!files.isEmpty) {
    1.27 -        val files_list = new ListView(files.sorted)
    1.28 -        for (i <- 0 until files.length)
    1.29 -          files_list.selection.indices += i
    1.30 +        if (!files.isEmpty) {
    1.31 +          val files_list = new ListView(files.sorted)
    1.32 +          for (i <- 0 until files.length)
    1.33 +            files_list.selection.indices += i
    1.34  
    1.35 -        val answer =
    1.36 -          Library.confirm_dialog(view,
    1.37 -            "Auto loading of required files",
    1.38 -            JOptionPane.YES_NO_OPTION,
    1.39 -            "The following files are required to resolve theory imports.",
    1.40 -            "Reload selected files now?",
    1.41 -            new ScrollPane(files_list))
    1.42 -        if (answer == 0)
    1.43 -          for {
    1.44 -            file <- files
    1.45 -            if files_list.selection.items.contains(file)
    1.46 -          } jEdit.openFile(null: View, file)
    1.47 +          val answer =
    1.48 +            Library.confirm_dialog(view,
    1.49 +              "Auto loading of required files",
    1.50 +              JOptionPane.YES_NO_OPTION,
    1.51 +              "The following files are required to resolve theory imports.",
    1.52 +              "Reload selected files now?",
    1.53 +              new ScrollPane(files_list))
    1.54 +          if (answer == 0) {
    1.55 +            files.foreach(file =>
    1.56 +              if (files_list.selection.items.contains(file))
    1.57 +                jEdit.openFile(null: View, file))
    1.58 +          }
    1.59 +        }
    1.60        }
    1.61      }
    1.62