All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.sciss.lucre.swing.impl.ComponentHolder.scala Maven / Gradle / Ivy

The newest version!
/*
 *  ComponentHolder.scala
 *  (LucreSwing)
 *
 *  Copyright (c) 2014-2019 Hanns Holger Rutz. All rights reserved.
 *
 *	This software is published under the GNU Lesser General Public License v2.1+
 *
 *
 *	For further information, please contact Hanns Holger Rutz at
 *	[email protected]
 */

package de.sciss.lucre.swing.impl

import de.sciss.lucre.swing.LucreSwing.requireEDT

trait ComponentHolder[C] {
//  type C = C1

  private var comp = Option.empty[C]

  final protected def component_=(c: C): Unit = {
    requireEDT()
    if(comp.nonEmpty) throw new IllegalStateException("Component has already been set")
    comp = Some(c)
  }

  final def component: C = {
    requireEDT()
    comp.getOrElse(throw new IllegalStateException("Called component before GUI was initialized"))
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy