glimmer-cs-gladiator 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,6 +31,7 @@ require 'views/glimmer/gladiator/file_lookup_list'
31
31
  require 'views/glimmer/gladiator/file_explorer_tree'
32
32
  require 'views/glimmer/gladiator/gladiator_menu_bar'
33
33
  require 'views/glimmer/gladiator/progress_shell'
34
+ require 'views/glimmer/gladiator/file_edit_menu'
34
35
 
35
36
  Clipboard.implementation = Clipboard::Java
36
37
  Clipboard.copy(Clipboard.paste) # pre-initialize library to avoid slowdown during use
@@ -61,6 +62,11 @@ module Glimmer
61
62
  # option :height, 240
62
63
  option :project_dir_path
63
64
 
65
+ attr_reader :find_text, :filter_text, :line_number_text, :split_orientation, :tab_folder_sash_form, :side_bar_sash_form, :file_area_and_editor_area_sash_form, :file_explorer_expand_item, :file_explorer_expand_item, :file_lookup_expand_item, :file_explorer_expand_item, :file_lookup_expand_item_height, :file_explorer_expand_item_height
66
+ attr_accessor :current_tab_item, :current_tab_folder, :current_text_editor, :tab_folder1, :tab_folder2, :maximized_pane, :maximized_editor
67
+ alias maximized_pane? maximized_pane
68
+ alias maximized_editor? maximized_editor
69
+
64
70
  def project_dir
65
71
  @project_dir ||= Dir.new(project_dir_path)
66
72
  end
@@ -83,10 +89,9 @@ module Glimmer
83
89
  pane_count && pane_count > 1
84
90
  end
85
91
 
86
- attr_reader :find_text, :filter_text, :line_number_text, :split_orientation, :tab_folder_sash_form, :side_bar_sash_form, :file_area_and_editor_area_sash_form, :file_explorer_expand_item, :file_explorer_expand_item, :file_lookup_expand_item, :file_explorer_expand_item, :file_lookup_expand_item_height, :file_explorer_expand_item_height
87
- attr_accessor :current_tab_item, :current_tab_folder, :current_text_editor, :tab_folder1, :tab_folder2, :maximized_pane, :maximized_editor
88
- alias maximized_pane? maximized_pane
89
- alias maximized_editor? maximized_editor
92
+ def app_mode?
93
+ project_dir_path == '.' && ENV['APP_MODE'].to_s == 'true' || !::Dir.glob(::File.join(project_dir_path, 'glimmer-cs-gladiator.jar')).empty?
94
+ end
90
95
 
91
96
  ## Uncomment before_body block to pre-initialize variables to use in body
92
97
  #
@@ -107,25 +112,26 @@ module Glimmer
107
112
  display_about_dialog
108
113
  }
109
114
  on_quit {
110
- project_dir.selected_child&.write_dirty_content
111
- display.swt_display.shells.each(&:close)
115
+ display.swt_display.shells.each { |shell|
116
+ gladiator = shell.get_data('custom_shell')
117
+ gladiator.project_dir.selected_child&.write_dirty_content
118
+ shell.close
119
+ }
112
120
  }
113
121
  on_swt_keydown { |key_event|
114
122
  focused_gladiator = display.focus_control.shell&.get_data('custom_shell')
115
123
  focused_gladiator.handle_display_shortcut(key_event) if !focused_gladiator.nil? && key_event.widget.shell == focused_gladiator&.swt_widget
116
124
  }
117
- on_swt_Close {
118
- project_dir.selected_child&.write_dirty_content
119
- }
120
125
  }
121
126
  end
122
127
 
123
128
  @default_foreground = :dark_blue
124
129
  @split_orientation = swt(:horizontal)
125
- @config_file_path = ::File.join(project_dir.path, '.gladiator')
126
- @config = {}
127
- load_config_ignore_paths
128
- # project_dir.all_children # pre-caches children
130
+ unless app_mode?
131
+ @config_file_path = ::File.join(project_dir.path, '.gladiator')
132
+ @config = {}
133
+ load_config_ignore_paths
134
+ end
129
135
  }
130
136
 
131
137
  ## Uncomment after_body block to setup observers for widgets in body
@@ -204,7 +210,7 @@ module Glimmer
204
210
  @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
205
211
  body_root.pack_same_size
206
212
  rescue => e
207
- puts e.full_message
213
+ Glimmer::Config.logger.error {e.full_message}
208
214
  end
209
215
  end
210
216
  @current_text_editor&.text_widget&.setFocus
@@ -235,19 +241,26 @@ module Glimmer
235
241
  observe(project_dir, 'selected_child.top_pixel') do
236
242
  save_config
237
243
  end
238
- load_config
244
+ load_config unless app_mode?
239
245
  }
240
246
 
241
247
  ## Add widget content inside custom shell body
242
248
  ## Top-most widget must be a shell or another custom shell
243
249
  #
244
250
  body {
245
- if !::Dir.glob(::File.join(project_dir_path, 'glimmer-cs-gladiator.jar')).empty?
246
- shell(:no_trim, :no_background) {
251
+ if app_mode?
252
+ shell {
253
+ text 'Gladiator'
254
+ minimum_size 250, 250
255
+ image ICON
247
256
  gladiator_menu_bar(gladiator: self, editing: false)
248
257
 
249
- on_swt_show {
250
- open_project
258
+ button {
259
+ text 'Open Project...'
260
+
261
+ on_widget_selected {
262
+ open_project
263
+ }
251
264
  }
252
265
  }
253
266
  else
@@ -694,8 +707,6 @@ module Glimmer
694
707
  @config = YAML.load(config_yaml)
695
708
  project_dir.ignore_paths = @config[:ignore_paths] if @config[:ignore_paths]
696
709
  project_dir.ignore_paths ||= ['packages', 'tmp']
697
- else
698
- @loaded_config = true
699
710
  end
700
711
  end
701
712
 
@@ -797,7 +808,7 @@ module Glimmer
797
808
  config_yaml = YAML.dump(@config)
798
809
  ::File.write(@config_file_path, config_yaml) unless config_yaml.to_s.empty?
799
810
  rescue => e
800
- puts e.full_message
811
+ Glimmer::Config.logger.error {e.full_message}
801
812
  end
802
813
 
803
814
  def navigate_to_next_tab_folder
@@ -907,6 +918,7 @@ module Glimmer
907
918
  async_exec {
908
919
  gladiator(project_dir_path: selected_directory) {
909
920
  on_swt_show {
921
+ body_root.close if app_mode?
910
922
  @progress_shell.close
911
923
  @progress_shell = nil
912
924
  }
@@ -0,0 +1,67 @@
1
+ module Glimmer
2
+ class Gladiator
3
+ class FileEditMenu
4
+ include Glimmer::UI::CustomWidget
5
+
6
+ # Either receives a gladiator instance for menu bar parent or file instance for text editor parent
7
+ options :gladiator, :file
8
+
9
+ body {
10
+ menu { |menu_proxy|
11
+ text '&Edit' unless menu_proxy.swt_menu_item.nil? # unless used on the text editor directly
12
+
13
+ menu_item {
14
+ text '&Undo'
15
+ # TODO disable if not undoable
16
+
17
+ on_widget_selected {
18
+ Command.undo(current_file)
19
+ }
20
+ }
21
+ menu_item {
22
+ text '&Redo'
23
+ # TODO disable if not redoable
24
+
25
+ on_widget_selected {
26
+ Command.redo(current_file)
27
+ }
28
+ }
29
+ menu_item(:separator)
30
+ menu_item {
31
+ text 'Cu&t'
32
+
33
+ on_widget_selected {
34
+ Command.do(current_file, :cut!)
35
+ }
36
+ }
37
+ menu_item {
38
+ text '&Copy'
39
+
40
+ on_widget_selected {
41
+ current_file.copy
42
+ }
43
+ }
44
+ menu_item {
45
+ text '&Paste'
46
+
47
+ on_widget_selected {
48
+ Command.do(current_file, :paste!)
49
+ }
50
+ }
51
+ menu_item(:separator)
52
+ menu_item {
53
+ text 'Select &All'
54
+
55
+ on_widget_selected {
56
+ current_file.select_all
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ def current_file
63
+ file.nil? ? gladiator.project_dir.selected_child : file
64
+ end
65
+ end
66
+ end
67
+ end
@@ -58,6 +58,7 @@ module Glimmer
58
58
  }
59
59
  }
60
60
  if editing
61
+ file_edit_menu(gladiator: gladiator)
61
62
  menu {
62
63
  text '&View'
63
64
  menu {
@@ -154,12 +155,8 @@ module Glimmer
154
155
  begin
155
156
  project_dir.selected_child.run
156
157
  rescue Exception => e
157
- dialog {
158
- text 'Run - Ruby - Error Encountered!'
159
- label {
160
- text e.full_message
161
- }
162
- }.open
158
+ Glimmer::Config.logger.error {e.full_message}
159
+ error_dialog(message: e.full_message).open
163
160
  end
164
161
  }
165
162
  }
@@ -182,6 +179,36 @@ module Glimmer
182
179
  gladiator.project_dir
183
180
  end
184
181
 
182
+ # Method-based error_dialog custom widget
183
+ def error_dialog(message:)
184
+ return if message.nil?
185
+ dialog(gladiator) { |dialog_proxy|
186
+ row_layout(:vertical) {
187
+ center true
188
+ }
189
+
190
+ text 'Error Launching'
191
+
192
+ styled_text(:border, :h_scroll, :v_scroll) {
193
+ layout_data {
194
+ width body_root.bounds.width*0.75
195
+ height body_root.bounds.height*0.75
196
+ }
197
+
198
+ text message
199
+ editable false
200
+ caret nil
201
+ }
202
+
203
+ button {
204
+ text 'Close'
205
+
206
+ on_widget_selected {
207
+ dialog_proxy.close
208
+ }
209
+ }
210
+ }
211
+ end
185
212
  end
186
213
 
187
214
  end
@@ -1,31 +1,29 @@
1
- module Glimmer
2
- class Gladiator
3
- class ProgressShell
4
- include Glimmer::UI::CustomShell
5
-
6
- option :gladiator
7
- option :progress_text, default: 'Work In Progress'
8
-
9
- body {
10
- shell(gladiator.body_root, :title) {
11
- fill_layout(:vertical) {
12
- margin_width 15
13
- margin_height 15
14
- spacing 5
15
- }
16
-
17
- text 'Gladiator'
18
-
19
- gladiator_menu_bar(gladiator: gladiator, editing: true)
20
-
21
- label(:center) {
22
- text progress_text
23
- font height: 20
24
- }
25
- # @progress_bar = progress_bar(:horizontal, :indeterminate)
26
- }
27
- }
28
-
29
- end
30
- end
31
- end
1
+ module Glimmer
2
+ class Gladiator
3
+ class ProgressShell
4
+ include Glimmer::UI::CustomShell
5
+
6
+ option :gladiator
7
+ option :progress_text, default: 'Work In Progress'
8
+
9
+ body {
10
+ shell(gladiator.body_root, :title) {
11
+ fill_layout(:vertical) {
12
+ margin_width 15
13
+ margin_height 15
14
+ spacing 5
15
+ }
16
+
17
+ text 'Gladiator'
18
+
19
+ label(:center) {
20
+ text progress_text
21
+ font height: 20
22
+ }
23
+ # @progress_bar = progress_bar(:horizontal, :indeterminate)
24
+ }
25
+ }
26
+
27
+ end
28
+ end
29
+ end
@@ -71,6 +71,9 @@ module Glimmer
71
71
  right_margin 5
72
72
  bottom_margin 5
73
73
  left_margin 5
74
+
75
+ file_edit_menu(file: file)
76
+
74
77
  drop_target(DND::DROP_COPY) {
75
78
  transfer [TextTransfer.getInstance].to_java(Transfer)
76
79
  on_drag_enter { |event|
@@ -139,6 +142,12 @@ module Glimmer
139
142
  elsif (OS.mac? && key_event.keyCode == swt(:home)) || (!OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :ctrl) && key_event.keyCode == swt(:end))
140
143
  file.end
141
144
  key_event.doit = false
145
+ elsif !OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :shift) && key_event.keyCode == swt(:home)
146
+ file.select_to_start_of_line
147
+ key_event.doit = false
148
+ elsif !OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :shift) && key_event.keyCode == swt(:end)
149
+ file.select_to_end_of_line
150
+ key_event.doit = false
142
151
  elsif (OS.mac? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a') || (!OS.mac? && key_event.keyCode == swt(:home))
143
152
  file.start_of_line
144
153
  key_event.doit = false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cs-gladiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-07 00:00:00.000000000 Z
11
+ date: 2021-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +146,7 @@ files:
146
146
  - lib/models/glimmer/gladiator/dir.rb
147
147
  - lib/models/glimmer/gladiator/file.rb
148
148
  - lib/views/glimmer/gladiator.rb
149
+ - lib/views/glimmer/gladiator/file_edit_menu.rb
149
150
  - lib/views/glimmer/gladiator/file_explorer_tree.rb
150
151
  - lib/views/glimmer/gladiator/file_lookup_list.rb
151
152
  - lib/views/glimmer/gladiator/gladiator_menu_bar.rb