glimmer 0.1.11.470 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +104 -66
  3. data/bin/girb +1 -3
  4. data/bin/glimmer +1 -1
  5. data/lib/glimmer_application.rb +35 -76
  6. data/vendor/swt/linux/swt.jar +0 -0
  7. data/vendor/swt/mac/swt.jar +0 -0
  8. data/vendor/swt/windows/swt.jar +0 -0
  9. metadata +15 -55
  10. data/.coveralls.yml +0 -1
  11. data/.rspec +0 -2
  12. data/.ruby-gemset +0 -1
  13. data/.ruby-version +0 -1
  14. data/Gemfile +0 -14
  15. data/RELEASE.md +0 -15
  16. data/Rakefile +0 -43
  17. data/TODO.md +0 -12
  18. data/VERSION +0 -1
  19. data/bin/girb_runner.rb +0 -1
  20. data/glimmer.gemspec +0 -160
  21. data/images/Bitter-sweet.jpg +0 -0
  22. data/samples/contactmanager/contact.rb +0 -9
  23. data/samples/contactmanager/contact_manager.rb +0 -71
  24. data/samples/contactmanager/contact_manager_presenter.rb +0 -24
  25. data/samples/contactmanager/contact_repository.rb +0 -24
  26. data/samples/hello_combo.rb +0 -36
  27. data/samples/hello_list_multi_selection.rb +0 -46
  28. data/samples/hello_list_single_selection.rb +0 -36
  29. data/samples/hello_tab.rb +0 -26
  30. data/samples/hello_world.rb +0 -10
  31. data/samples/hellocomputed/contact.rb +0 -19
  32. data/samples/hellocomputed/hello_computed.rb +0 -68
  33. data/samples/login.rb +0 -92
  34. data/samples/tictactoe/tic_tac_toe.rb +0 -64
  35. data/samples/tictactoe/tic_tac_toe_board.rb +0 -146
  36. data/spec/lib/command_handlers/models/observable_model_spec.rb +0 -22
  37. data/spec/lib/command_handlers/models/r_widget_spec.rb +0 -52
  38. data/spec/lib/glimmer__combo_data_binding__spec.rb +0 -130
  39. data/spec/lib/glimmer__constant__spec.rb +0 -30
  40. data/spec/lib/glimmer__data_binding__spec.rb +0 -404
  41. data/spec/lib/glimmer__list_data_binding__spec.rb +0 -224
  42. data/spec/lib/glimmer__listeners__spec.rb +0 -60
  43. data/spec/lib/glimmer__shine_data_binding__spec.rb +0 -89
  44. data/spec/lib/glimmer__tab_item__spec.rb +0 -55
  45. data/spec/lib/glimmer__table_data_binding__spec.rb +0 -121
  46. data/spec/lib/glimmer__tree_data_binding__spec.rb +0 -113
  47. data/spec/lib/glimmer_spec.rb +0 -251
  48. data/spec/lib/xml/glimmer_xml_spec.rb +0 -154
  49. data/spec/samples/contactmanager/contact_manager_presenter_spec.rb +0 -81
  50. data/spec/samples/tictactoe/tic_tac_toe_spec.rb +0 -263
  51. data/spec/spec_helper.rb +0 -124
@@ -1,36 +0,0 @@
1
- require_relative "../lib/glimmer"
2
-
3
- class Person
4
- attr_accessor :country, :country_options
5
-
6
- def initialize
7
- self.country_options=["", "Canada", "US", "Mexico"]
8
- self.country = "Canada"
9
- end
10
-
11
- def reset_country
12
- self.country = "Canada"
13
- end
14
- end
15
-
16
- class HelloListSingleSelection
17
- include Glimmer
18
- def launch
19
- person = Person.new
20
- shell {
21
- composite {
22
- list {
23
- selection bind(person, :country)
24
- }
25
- button {
26
- text "Reset"
27
- on_widget_selected do
28
- person.reset_country
29
- end
30
- }
31
- }
32
- }.open
33
- end
34
- end
35
-
36
- HelloListSingleSelection.new.launch
@@ -1,26 +0,0 @@
1
- require_relative "../lib/glimmer"
2
-
3
- class HelloTab
4
- include Glimmer
5
- def launch
6
- shell {
7
- text "Hello Tab"
8
- tab_folder {
9
- tab_item {
10
- text "English"
11
- label {
12
- text "Hello World!"
13
- }
14
- }
15
- tab_item {
16
- text "French"
17
- label {
18
- text "Bonjour Univers!"
19
- }
20
- }
21
- }
22
- }.open
23
- end
24
- end
25
-
26
- HelloTab.new.launch
@@ -1,10 +0,0 @@
1
- require_relative "../lib/glimmer"
2
-
3
- include Glimmer
4
-
5
- shell {
6
- text "SWT"
7
- label {
8
- text "Hello World!"
9
- }
10
- }.open
@@ -1,19 +0,0 @@
1
- class Contact
2
- attr_accessor :first_name, :last_name, :year_of_birth
3
-
4
- def initialize(attribute_map)
5
- @first_name = attribute_map[:first_name]
6
- @last_name = attribute_map[:last_name]
7
- @year_of_birth = attribute_map[:year_of_birth]
8
- end
9
-
10
- def name
11
- "#{last_name}, #{first_name}"
12
- end
13
-
14
- def age
15
- Time.now.year - year_of_birth.to_i
16
- rescue
17
- 0
18
- end
19
- end
@@ -1,68 +0,0 @@
1
- require_relative "../../lib/glimmer"
2
- require_relative "contact"
3
-
4
- class HelloComputed
5
- extend Glimmer
6
-
7
- include_package 'org.eclipse.swt'
8
- include_package 'org.eclipse.swt.widgets'
9
- include_package 'org.eclipse.swt.layout'
10
-
11
- contact = Contact.new(
12
- first_name: "Barry",
13
- last_name: "McKibbin",
14
- year_of_birth: 1985
15
- )
16
-
17
- shell {
18
- text "Hello Computed"
19
- composite {
20
- layout (
21
- GridLayout.new(2, true).tap {|layout|
22
- layout.horizontalSpacing = 20
23
- layout.verticalSpacing = 10
24
- }
25
- )
26
- label {text "First &Name: "}
27
- text {
28
- text bind(contact, :first_name)
29
- layoutData GridData.new.tap { |data|
30
- data.horizontalAlignment = GridData::FILL
31
- data.grabExcessHorizontalSpace = true
32
- }
33
- }
34
- label {text "&Last Name: "}
35
- text {
36
- text bind(contact, :last_name)
37
- layoutData GridData.new.tap { |data|
38
- data.horizontalAlignment = GridData::FILL
39
- data.grabExcessHorizontalSpace = true
40
- }
41
- }
42
- label {text "&Year of Birth: "}
43
- text {
44
- text bind(contact, :year_of_birth)
45
- layoutData GridData.new.tap { |data|
46
- data.horizontalAlignment = GridData::FILL
47
- data.grabExcessHorizontalSpace = true
48
- }
49
- }
50
- label {text "Name: "}
51
- label {
52
- text bind(contact, :name, computed_by: [:first_name, :last_name])
53
- layoutData GridData.new.tap { |data|
54
- data.horizontalAlignment = GridData::FILL
55
- data.grabExcessHorizontalSpace = true
56
- }
57
- }
58
- label {text "Age: "}
59
- label {
60
- text bind(contact, :age, :fixnum, computed_by: [:year_of_birth])
61
- layoutData GridData.new.tap { |data|
62
- data.horizontalAlignment = GridData::FILL
63
- data.grabExcessHorizontalSpace = true
64
- }
65
- }
66
- }
67
- }.open
68
- end
@@ -1,92 +0,0 @@
1
- require "java"
2
- require "observer"
3
- require_relative "../lib/glimmer"
4
-
5
- #Presents login screen data
6
- class LoginPresenter
7
-
8
- attr_accessor :user_name
9
- attr_accessor :password
10
- attr_accessor :status
11
-
12
- def initialize
13
- @user_name = ""
14
- @password = ""
15
- @status = "Logged Out"
16
- end
17
-
18
- def status=(status)
19
- @status = status
20
-
21
- #TODO add feature to bind dependent properties to master property (2017-07-25 nested data binding)
22
- notify_observers("logged_in")
23
- notify_observers("logged_out")
24
- end
25
-
26
- def logged_in
27
- self.status == "Logged In"
28
- end
29
-
30
- def logged_out
31
- !self.logged_in
32
- end
33
-
34
- def login
35
- self.status = "Logged In"
36
- end
37
-
38
- def logout
39
- self.user_name = ""
40
- self.password = ""
41
- self.status = "Logged Out"
42
- end
43
-
44
- end
45
-
46
- #Login screen
47
- class Login
48
- include_package 'org.eclipse.swt'
49
- include_package 'org.eclipse.swt.layout'
50
-
51
- include Glimmer
52
-
53
- def launch
54
- presenter = LoginPresenter.new
55
- @shell = shell {
56
- text "Login"
57
- composite {
58
- layout GridLayout.new(2, false) #two columns with differing widths
59
-
60
- label { text "Username:" } # goes in column 1
61
- text { # goes in column 2
62
- text bind(presenter, :user_name)
63
- enabled bind(presenter, :logged_out)
64
- }
65
-
66
- label { text "Password:" }
67
- text(:password, :border) {
68
- text bind(presenter, :password)
69
- enabled bind(presenter, :logged_out)
70
- }
71
-
72
- label { text "Status:" }
73
- label { text bind(presenter, :status) }
74
-
75
- button {
76
- text "Login"
77
- enabled bind(presenter, :logged_out)
78
- on_widget_selected { presenter.login }
79
- }
80
-
81
- button {
82
- text "Logout"
83
- enabled bind(presenter, :logged_in)
84
- on_widget_selected { presenter.logout }
85
- }
86
- }
87
- }
88
- @shell.open
89
- end
90
- end
91
-
92
- Login.new.launch
@@ -1,64 +0,0 @@
1
- require_relative "../../lib/glimmer"
2
- require_relative "tic_tac_toe_board"
3
-
4
-
5
- class TicTacToe
6
-
7
- include_package 'org.eclipse.swt'
8
- include_package 'org.eclipse.swt.widgets'
9
- include_package 'org.eclipse.swt.layout'
10
-
11
- include Glimmer
12
-
13
- def initialize
14
- @tic_tac_toe_board = TicTacToeBoard.new
15
- @main =
16
- @shell = shell {
17
- text "Tic-Tac-Toe"
18
- composite {
19
- layout GridLayout.new(3,true)
20
- (1..3).each { |row_number|
21
- (1..3).each { |column_number|
22
- button {
23
- layout_data GridData.new(:fill.swt_constant, :fill.swt_constant, true, true)
24
- text bind(@tic_tac_toe_board.box(row_number, column_number), :sign)
25
- enabled bind(@tic_tac_toe_board.box(row_number, column_number), :empty)
26
- on_widget_selected {
27
- @tic_tac_toe_board.mark_box(row_number, column_number)
28
- }
29
- }
30
- }
31
- }
32
- }
33
- }
34
- @tic_tac_toe_board.extend(ObservableModel) #make board an observable model
35
- @tic_tac_toe_board.add_observer("game_status", self)
36
- end
37
-
38
- def update(game_status)
39
- display_win_message if game_status == TicTacToeBoard::WIN
40
- display_draw_message if game_status == TicTacToeBoard::DRAW
41
- end
42
-
43
- def display_win_message()
44
- display_game_over_message("Player #{@tic_tac_toe_board.winning_sign} has won!")
45
- end
46
-
47
- def display_draw_message()
48
- display_game_over_message("Draw!")
49
- end
50
-
51
- def display_game_over_message(message)
52
- message_box = MessageBox.new(@shell.widget)
53
- message_box.setText("Game Over")
54
- message_box.setMessage(message)
55
- message_box.open
56
- @tic_tac_toe_board.reset
57
- end
58
-
59
- def open
60
- @main.open
61
- end
62
- end
63
-
64
- TicTacToe.new.open
@@ -1,146 +0,0 @@
1
- class TicTacToeBox
2
- EMPTY = ""
3
- attr_accessor :sign, :empty
4
-
5
- def initialize
6
- reset
7
- end
8
-
9
- def mark_box(sign)
10
- self.sign = sign
11
- end
12
-
13
- def reset
14
- self.sign = EMPTY
15
- end
16
-
17
- def sign=(sign_symbol)
18
- @sign = sign_symbol
19
- self.empty = sign == EMPTY
20
- end
21
-
22
- def marked
23
- ! empty
24
- end
25
- end
26
-
27
- class TicTacToeBoard
28
- DRAW = :draw
29
- IN_PROGRESS = :in_progress
30
- WIN = :win
31
- attr :winning_sign
32
- attr_accessor :game_status
33
-
34
- def initialize
35
- @sign_state_machine = {nil => "X", "X" => "O", "O" => "X"}
36
- build_grid
37
- @winning_sign = TicTacToeBox::EMPTY
38
- @game_status = IN_PROGRESS
39
- end
40
-
41
- #row and column numbers are 1-based
42
- def mark_box(row_number, column_number)
43
- box(row_number, column_number).mark_box(current_sign)
44
- game_over? #updates winning sign
45
- end
46
-
47
- def current_sign
48
- @current_sign = @sign_state_machine[@current_sign]
49
- end
50
-
51
- def box(row_number, column_number)
52
- @grid[row_number-1][column_number-1]
53
- end
54
-
55
- def game_over?
56
- win? or draw?
57
- end
58
-
59
- def win?
60
- win = (row_win? or column_win? or diagonal_win?)
61
- self.game_status=WIN if win
62
- win
63
- end
64
-
65
- def reset
66
- (1..3).each do |row_number|
67
- (1..3).each do |column_number|
68
- box(row_number, column_number).reset
69
- end
70
- end
71
- @winning_sign = TicTacToeBox::EMPTY
72
- @current_sign = nil
73
- self.game_status=IN_PROGRESS
74
- end
75
-
76
- private
77
-
78
- def build_grid
79
- @grid = []
80
- 3.times do |row_index| #0-based
81
- @grid << []
82
- 3.times { @grid[row_index] << TicTacToeBox.new }
83
- end
84
- end
85
-
86
- def row_win?
87
- (1..3).each do |row_number|
88
- if row_has_same_sign(row_number)
89
- @winning_sign = box(row_number, 1).sign
90
- return true
91
- end
92
- end
93
- false
94
- end
95
-
96
- def column_win?
97
- (1..3).each do |column_number|
98
- if column_has_same_sign(column_number)
99
- @winning_sign = box(1, column_number).sign
100
- return true
101
- end
102
- end
103
- false
104
- end
105
-
106
- #needs refactoring if we ever decide to make the board size dynamic
107
- def diagonal_win?
108
- if (box(1,1).sign == box(2,2).sign) and (box(2,2).sign == box(3,3).sign) and box(1,1).marked
109
- @winning_sign = box(1,1).sign
110
- return true
111
- end
112
- if (box(3,1).sign == box(2,2).sign) and (box(2,2).sign == box(1,3).sign) and box(3,1).marked
113
- @winning_sign = box(3,1).sign
114
- return true
115
- end
116
- false
117
- end
118
-
119
- def draw?
120
- @board_full = true
121
- 3.times do |x|
122
- 3.times do |y|
123
- @board_full = false if box(x, y).empty
124
- end
125
- end
126
- self.game_status = DRAW if @board_full
127
- @board_full
128
- end
129
-
130
- def row_has_same_sign(number)
131
- row_sign = box(number, 1).sign
132
- [2, 3].each do |column|
133
- return false unless row_sign == (box(number, column).sign)
134
- end
135
- true if box(number, 1).marked
136
- end
137
-
138
- def column_has_same_sign(number)
139
- column_sign = box(1, number).sign
140
- [2, 3].each do |row|
141
- return false unless column_sign == (box(row, number).sign)
142
- end
143
- true if box(1, number).marked
144
- end
145
-
146
- end