This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text(_ emitTo signal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def bindableText(text: Text): Target[String] = { | |
new Target[String] { | |
def bind(value: Signal[String]) = observe(value) { newValue => | |
text.setText(newValue) | |
true // keep observing | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def textToSource(text: Text): Source[String] = { | |
new Source[String] { | |
override def emitTo(channel: Var[String]) { | |
text.addModifyListener(new ModifyListener() { | |
override def modifyText(event: ModifyEvent) = { | |
channel.update(text.getText) | |
} | |
}) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def textbox(output: Var[String])(setups: (Text => Any)*)(parent: Composite) = { | |
val text = new Text(parent, SWT.BORDER) | |
text setText (output.now) | |
text emitTo output | |
setupAndReturn(text, setups) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Temperature { | |
implicit def unboxText2Double(s: String) = if (s != "") java.lang.Double.parseDouble(s) else 0.0 | |
implicit def convertDouble2String(d: Double) = d.toString | |
val fahrenheit = new Var[String]("0") | |
val celsius = new Var[String]("0") | |
val calcCelsius = Signal { | |
((5.0 / 9.0) * (fahrenheit() - 32)) toString | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def bindableText(text: Text): Target[String] = { | |
new Target[String] { | |
def bind(value: Signal[String]) = observe(value) { newValue => | |
if (!text.isFocusControl) // don't update the text that's editing | |
text.setText(newValue) | |
true // keep observing | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// outer scope | |
val myOutputSignal = Var[String]("") | |
// setup | |
textbox(signal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text bind signal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-startup | |
../../../plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar | |
--launcher.library | |
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.2.R36x_v20101019_1345 | |
-showsplash | |
org.eclipse.platform | |
--launcher.XXMaxPermSize | |
256m | |
--launcher.defaultAction | |
openFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait DateParsers extends RegexParsers { | |
def dateTime(pattern: String): Parser[DateTime] = new Parser[DateTime] { | |
val dateFormat = DateTimeFormat.forPattern(pattern) | |
val dateParser = dateFormat.getParser | |
def jodaParse(text: CharSequence, offset: Int) = { | |
val mutableDateTime = new MutableDateTime | |
val newPos = dateFormat.parseInto(mutableDateTime, text, offset); | |
(mutableDateTime.toDateTime, newPos) | |
} |