src/Tools/jEdit/src/plugin.scala
changeset 61277 c9152a195899
parent 61024 7b7f01afab71
child 61278 4d2ea32e0f75
equal deleted inserted replaced
61276:8a4bd05c1735 61277:c9152a195899
   260         finally { delay_load_active.change(_ => false) }
   260         finally { delay_load_active.change(_ => false) }
   261       }
   261       }
   262     }
   262     }
   263 
   263 
   264 
   264 
       
   265   /* session build */
       
   266 
       
   267   def session_build(): Int =
       
   268   {
       
   269     val system_dialog = new System_Dialog
       
   270 
       
   271     try {
       
   272       val mode = Isabelle_System.getenv("JEDIT_BUILD_MODE")
       
   273       if (mode == "none")
       
   274         system_dialog.return_code(0)
       
   275       else {
       
   276         val system_mode = mode == "" || mode == "system"
       
   277         val dirs = Path.split(Isabelle_System.getenv("JEDIT_SESSION_DIRS"))
       
   278         val session = Isabelle_System.default_logic(
       
   279           Isabelle_System.getenv("JEDIT_LOGIC"),
       
   280           PIDE.options.string("jedit_logic"))
       
   281 
       
   282         if (Build.build(options = PIDE.options.value, build_heap = true, no_build = true,
       
   283             dirs = dirs, system_mode = system_mode, sessions = List(session)) == 0)
       
   284           system_dialog.return_code(0)
       
   285         else {
       
   286           system_dialog.title("Isabelle build (" +
       
   287             Isabelle_System.getenv("ML_IDENTIFIER") + " / " +
       
   288             "jdk-" + Platform.jvm_version + "_" + Platform.jvm_platform + ")")
       
   289           system_dialog.echo("Build started for Isabelle/" + session + " ...")
       
   290 
       
   291           val (out, rc) =
       
   292             try {
       
   293               ("",
       
   294                 Build.build(options = PIDE.options.value, progress = system_dialog,
       
   295                   build_heap = true, dirs = dirs, system_mode = system_mode,
       
   296                   sessions = List(session)))
       
   297             }
       
   298             catch {
       
   299               case exn: Throwable =>
       
   300                 (Output.error_text(Exn.message(exn)) + "\n", Exn.return_code(exn, 2))
       
   301             }
       
   302 
       
   303           system_dialog.echo(out + (if (rc == 0) "OK\n" else "Return code: " + rc + "\n"))
       
   304           system_dialog.return_code(rc)
       
   305         }
       
   306       }
       
   307     }
       
   308     catch {
       
   309       case exn: Throwable =>
       
   310         GUI.dialog(null, "Isabelle", GUI.scrollable_text(Exn.message(exn)))
       
   311         system_dialog.return_code(Exn.return_code(exn, 2))
       
   312     }
       
   313 
       
   314     system_dialog.join()
       
   315   }
       
   316 
       
   317 
   265   /* session phase */
   318   /* session phase */
   266 
   319 
   267   private val session_phase =
   320   private val session_phase =
   268     Session.Consumer[Session.Phase](getClass.getName) {
   321     Session.Consumer[Session.Phase](getClass.getName) {
   269       case Session.Inactive | Session.Failed =>
   322       case Session.Inactive | Session.Failed =>
   318     }
   371     }
   319 
   372 
   320     if (PIDE.startup_failure.isEmpty) {
   373     if (PIDE.startup_failure.isEmpty) {
   321       message match {
   374       message match {
   322         case msg: EditorStarted =>
   375         case msg: EditorStarted =>
   323           PIDE.session.start("Isabelle", Isabelle_Logic.session_args())
       
   324 
       
   325           if (Distribution.is_identified && !Distribution.is_official) {
   376           if (Distribution.is_identified && !Distribution.is_official) {
   326             GUI.warning_dialog(jEdit.getActiveView, "Isabelle version for testing",
   377             GUI.warning_dialog(jEdit.getActiveView, "Isabelle version for testing",
   327               "This is " + Distribution.version + ".",
   378               "This is " + Distribution.version + ".",
   328               "It is for testing only, not for production use.")
   379               "It is for testing only, not for production use.")
       
   380           }
       
   381 
       
   382           Simple_Thread.fork("session_build") {
       
   383             val rc = session_build()
       
   384             if (rc == 0) PIDE.session.start("Isabelle", Isabelle_Logic.session_args())
   329           }
   385           }
   330 
   386 
   331         case msg: BufferUpdate
   387         case msg: BufferUpdate
   332         if msg.getWhat == BufferUpdate.LOADED ||
   388         if msg.getWhat == BufferUpdate.LOADED ||
   333           msg.getWhat == BufferUpdate.PROPERTIES_CHANGED ||
   389           msg.getWhat == BufferUpdate.PROPERTIES_CHANGED ||