src/Tools/jEdit/src/query_dockable.scala
changeset 56882 6d4b2f8f010c
parent 56881 15e18540df10
child 56883 38c6b70e5e53
equal deleted inserted replaced
56881:15e18540df10 56882:6d4b2f8f010c
   197         (snapshot, results, body) =>
   197         (snapshot, results, body) =>
   198           pretty_text_area.update(snapshot, results, Pretty.separate(body)))
   198           pretty_text_area.update(snapshot, results, Pretty.separate(body)))
   199 
   199 
   200     private def apply_query()
   200     private def apply_query()
   201     {
   201     {
   202       query_operation.apply_query(List(_selector.selection.item))
   202       query_operation.apply_query(List(selector.selection.item))
   203     }
   203     }
   204 
   204 
   205     private val query_label = new Label("Print:")
   205     private val query_label = new Label("Print:")
   206 
   206     def query: JComponent = apply_button.peer
   207     def query: JComponent = _selector.peer.asInstanceOf[JComponent]
       
   208 
   207 
   209 
   208 
   210     /* items */
   209     /* items */
   211 
   210 
   212     case class Item(name: String, description: String)
   211     case class Item(name: String, description: String)
   222         catch { case _: IndexOutOfBoundsException => }
   221         catch { case _: IndexOutOfBoundsException => }
   223         component
   222         component
   224       }
   223       }
   225     }
   224     }
   226 
   225 
   227     private var _selector_item: Option[String] = None
   226     private var selector_item: Option[String] = None
   228     private var _selector = new ComboBox[String](Nil)
   227     private var selector = new ComboBox[String](Nil)
   229 
   228 
   230     private def set_selector()
   229     private def set_selector()
   231     {
   230     {
   232       val items = Print_Operation.print_operations(PIDE.session).map(p => Item(p._1, p._2))
   231       val items = Print_Operation.print_operations(PIDE.session).map(p => Item(p._1, p._2))
   233 
   232 
   234       _selector =
   233       selector =
   235         new ComboBox(items.map(_.name)) {
   234         new ComboBox(items.map(_.name)) {
   236           _selector_item.foreach(item => selection.item = item)
   235           selector_item.foreach(item => selection.item = item)
   237           listenTo(selection)
   236           listenTo(selection)
   238           reactions += {
   237           reactions += {
   239             case SelectionChanged(_) =>
   238             case SelectionChanged(_) =>
   240               _selector_item = Some(selection.item)
   239               selector_item = Some(selection.item)
   241               apply_query()
   240               apply_query()
   242           }
   241           }
   243         }
   242         }
   244       _selector.renderer = new Renderer(_selector.renderer, items)
   243       selector.renderer = new Renderer(selector.renderer, items)
   245     }
   244     }
   246     set_selector()
   245     set_selector()
   247 
   246 
   248 
   247 
   249     /* GUI page */
   248     /* GUI page */
   259 
   258 
   260     def select
   259     def select
   261     {
   260     {
   262       set_selector()
   261       set_selector()
   263       control_panel.contents.clear
   262       control_panel.contents.clear
   264       control_panel.contents ++= List(query_label, _selector, apply_button, detach, zoom)
   263       control_panel.contents ++= List(query_label, selector, apply_button, detach, zoom)
   265     }
   264     }
   266 
   265 
   267     val page =
   266     val page =
   268       new TabbedPane.Page("Print Context", new BorderPanel {
   267       new TabbedPane.Page("Print Context", new BorderPanel {
   269         add(control_panel, BorderPanel.Position.North)
   268         add(control_panel, BorderPanel.Position.North)