<commit_before>package jsky.app.ot.gemini.editor.targetComponent.details

import java.awt._
import javax.swing.{JLabel, JPanel, JComponent}

import edu.gemini.pot.sp.ISPNode
import edu.gemini.shared.util.immutable.{ Option => GOption }
import edu.gemini.spModel.obs.context.ObsContext
import edu.gemini.spModel.target.SPTarget
import edu.gemini.spModel.target.system.{ConicTarget, NamedTarget}
import edu.gemini.spModel.target.system.ITarget.Tag
import jsky.app.ot.gemini.editor.targetComponent.MagnitudeEditor
import jsky.util.gui.{TextBoxWidgetWatcher, TextBoxWidget, DropDownListBoxWidgetWatcher, DropDownListBoxWidget}

import scalaz._, Scalaz._

final class NamedDetailEditor extends TargetDetailEditor(Tag.NAMED) with ReentrancyHack {

  private[this] var spt = new SPTarget // never null

  private def nt: NamedTarget = spt.getTarget.asInstanceOf[NamedTarget]

  // Editors

  val kind   = new TargetTypeEditor
  val valid  = new NamedValidAtEditor
  val coords = new CoordinateEditor

  val name = new TextBoxWidget <| { w =>
    w.setColumns(25)
    w.setMinimumSize(w.getPreferredSize)
    w.addWatcher(new TextBoxWidgetWatcher {

      def textBoxKeyPress(tbwe: TextBoxWidget): Unit =
        nonreentrant {
          spt.getTarget.setName(tbwe.getValue)
          spt.notifyOfGenericUpdate()
        }

      def textBoxAction(tbwe: TextBoxWidget): Unit = ()

    })
  }

  val solarObject = new DropDownListBoxWidget {
    setChoices(NamedTarget.SolarObject.values.asInstanceOf[Array[AnyRef]])
    addWatcher(new DropDownListBoxWidgetWatcher {
      def dropDownListBoxAction(w: DropDownListBoxWidget, index: Int, value: String) {
        nonreentrant {
          val o = w.getValue.asInstanceOf[NamedTarget.SolarObject]
          nt.setSolarObject(o)
          nt.setName(o.getDisplayValue)
          name.setText(o.getDisplayValue) // hmm
          spt.notifyOfGenericUpdate()
        }
      }
    })
  }

  val mags = new MagnitudeEditor {
    getComponent.asInstanceOf[JComponent] <| { c =>
      c.setBorder(titleBorder("Magnitudes"))
      c.getMinimumSize <| { s =>
        c.setMinimumSize(new Dimension(s.width, 100))
      }
    }
  }
<commit_msg>fixed name target mag v-height<commit_after>package jsky.app.ot.gemini.editor.targetComponent.details

import java.awt._
import javax.swing.{JLabel, JPanel, JComponent}

import edu.gemini.pot.sp.ISPNode
import edu.gemini.shared.util.immutable.{ Option => GOption }
import edu.gemini.spModel.obs.context.ObsContext
import edu.gemini.spModel.target.SPTarget
import edu.gemini.spModel.target.system.{ConicTarget, NamedTarget}
import edu.gemini.spModel.target.system.ITarget.Tag
import jsky.app.ot.gemini.editor.targetComponent.MagnitudeEditor
import jsky.util.gui.{TextBoxWidgetWatcher, TextBoxWidget, DropDownListBoxWidgetWatcher, DropDownListBoxWidget}

import scalaz._, Scalaz._

final class NamedDetailEditor extends TargetDetailEditor(Tag.NAMED) with ReentrancyHack {

  private[this] var spt = new SPTarget // never null

  private def nt: NamedTarget = spt.getTarget.asInstanceOf[NamedTarget]

  // Editors

  val kind   = new TargetTypeEditor
  val valid  = new NamedValidAtEditor
  val coords = new CoordinateEditor

  val name = new TextBoxWidget <| { w =>
    w.setColumns(25)
    w.setMinimumSize(w.getPreferredSize)
    w.addWatcher(new TextBoxWidgetWatcher {

      def textBoxKeyPress(tbwe: TextBoxWidget): Unit =
        nonreentrant {
          spt.getTarget.setName(tbwe.getValue)
          spt.notifyOfGenericUpdate()
        }

      def textBoxAction(tbwe: TextBoxWidget): Unit = ()

    })
  }

  val solarObject = new DropDownListBoxWidget {
    setChoices(NamedTarget.SolarObject.values.asInstanceOf[Array[AnyRef]])
    addWatcher(new DropDownListBoxWidgetWatcher {
      def dropDownListBoxAction(w: DropDownListBoxWidget, index: Int, value: String) {
        nonreentrant {
          val o = w.getValue.asInstanceOf[NamedTarget.SolarObject]
          nt.setSolarObject(o)
          nt.setName(o.getDisplayValue)
          name.setText(o.getDisplayValue) // hmm
          spt.notifyOfGenericUpdate()
        }
      }
    })
  }

  val mags = new MagnitudeEditor {
    getComponent.asInstanceOf[JComponent] <| { c =>
      c.setBorder(titleBorder("Magnitudes"))
      c.getMinimumSize <| { s =>
        c.setMinimumSize(new Dimension(s.width, 175))
      }
      c.setPreferredSize(c.getMinimumSize)
    }
  }

{'fraction_non_alphanumeric': 0.09786557674841054, 'fraction_numerical': 0.002270663033605813, 'mean_word_length': 3.545923632610939, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2150006', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1425, 'n_words': 245}