Created
November 27, 2019 01:28
-
-
Save AndyObtiva/4178fcb5939d29b6b5400732fd3bd65e to your computer and use it in GitHub Desktop.
Glimmer Computed Value Data Binding Sample
This file contains hidden or 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
class HelloComputed | |
extend Glimmer | |
include_package 'org.eclipse.swt' | |
include_package 'org.eclipse.swt.widgets' | |
include_package 'org.eclipse.swt.layout' | |
contact = Contact.new( | |
first_name: "Barry", | |
last_name: "McKibbin", | |
year_of_birth: 1985 | |
) | |
shell { | |
text "Hello Computed" | |
composite { | |
layout ( | |
GridLayout.new(2, true).tap {|layout| | |
layout.horizontalSpacing = 20 | |
layout.verticalSpacing = 10 | |
} | |
) | |
label {text "First &Name: "} | |
text { | |
text bind(contact, :first_name) | |
layoutData GridData.new.tap { |data| | |
data.horizontalAlignment = GridData::FILL | |
data.grabExcessHorizontalSpace = true | |
} | |
} | |
label {text "&Last Name: "} | |
text { | |
text bind(contact, :last_name) | |
layoutData GridData.new.tap { |data| | |
data.horizontalAlignment = GridData::FILL | |
data.grabExcessHorizontalSpace = true | |
} | |
} | |
label {text "&Year of Birth: "} | |
text { | |
text bind(contact, :year_of_birth) | |
layoutData GridData.new.tap { |data| | |
data.horizontalAlignment = GridData::FILL | |
data.grabExcessHorizontalSpace = true | |
} | |
} | |
label {text "Name: "} | |
label { | |
text bind(contact, :name, computed_by: [:first_name, :last_name]) | |
layoutData GridData.new.tap { |data| | |
data.horizontalAlignment = GridData::FILL | |
data.grabExcessHorizontalSpace = true | |
} | |
} | |
label {text "Age: "} | |
label { | |
text bind(contact, :age, :fixnum, computed_by: [:year_of_birth]) | |
layoutData GridData.new.tap { |data| | |
data.horizontalAlignment = GridData::FILL | |
data.grabExcessHorizontalSpace = true | |
} | |
} | |
} | |
}.open | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment