arcadia 0.10.0 → 0.11.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.
@@ -1,17 +1,23 @@
1
1
  #coderay.classes=annotation,attribute_name,attribute_name_fat,attribute_value,attribute_value_fat,bin,char,class,class_variable,color,comment,constant,content,definition,delimiter,directive,doc,doctype,doc_string,entity,error,escape,exception,float,function,global_variable,hex,important,include,inline,inline_delimiter,instance_variable,integer,interpreted,keyword,key,label,local_variable,modifier,oct,operator_fat,pre_constant,pre_type,predefined,preprocessor,pseudo_class,regexp,reserved,shell,string,symbol,tag,tag_fat,tag_special,type,variable,value,xml_text,insert,delete,change,head,
2
2
 
3
3
 
4
- coderay.classes=reserved,method,class,char,comment,instance_variable,constant,string,content,integer
5
- coderay.hightlight.reserved.foreground=>>>hightlight.reserved.foreground
6
- coderay.hightlight.reserved.style=bold
4
+ coderay.classes=keyword,method,class,char,comment,instance_variable,class_variable,symbol,constant,string,content,integer
5
+ #coderay.hightlight.reserved.foreground=>>>hightlight.reserved.foreground
6
+ #coderay.hightlight.reserved.style=bold
7
+ coderay.hightlight.keyword.foreground=>>>hightlight.reserved.foreground
8
+ coderay.hightlight.keyword.style=bold
7
9
  coderay.hightlight.method.foreground=>>>hightlight.method.foreground
8
10
  coderay.hightlight.method.style=bold
11
+ #coderay.hightlight.ident.style=bold
12
+ #coderay.hightlight.delimiter.style=bold
9
13
  coderay.hightlight.class.foreground=>>>hightlight.class.foreground
10
14
  coderay.hightlight.class.style=bold
11
15
  coderay.hightlight.module_name.foreground=>>>hightlight.class.foreground
12
16
  coderay.hightlight.module_name.style=bold
13
17
  coderay.hightlight.instance_variable.foreground=>>>hightlight.instance_variable.foreground
14
18
  coderay.hightlight.instance_variable.style=bold
19
+ coderay.hightlight.class_variable.foreground=>>>hightlight.class_variable.foreground
20
+ coderay.hightlight.class_variable.style=bold
15
21
  coderay.hightlight.constant.foreground=>>>hightlight.constant.foreground
16
22
  coderay.hightlight.constant.style=bold
17
23
  coderay.hightlight.global_variable.foreground=>>>hightlight.global_variable.foreground
@@ -39,3 +45,5 @@ coderay.hightlight.directive.style=bold
39
45
  coderay.hightlight.type.foreground=>>>hightlight.reserved.foreground
40
46
  coderay.hightlight.type.style=bold
41
47
  coderay.hightlight.operator.style=bold
48
+ coderay.hightlight.predefined_type.foreground=>>>hightlight.class.foreground
49
+ coderay.hightlight.exception.foreground=>>>hightlight.exception.foreground
@@ -2,4 +2,4 @@ language=java
2
2
  exts=java
3
3
  scanner=coderay
4
4
  @include=coderay.tokens
5
- coderay.classes=keyword,directive,type,pre_type,operator,delimiter,method,class,char,comment,instance_variable,constant,string,content,integer
5
+ coderay.classes=keyword,directive,type,predefined_type,operator,delimiter,method,class,char,comment,instance_variable,constant,string,content,integer,exception
@@ -1,6 +1,6 @@
1
1
  language=ruby
2
2
 
3
- exts=rb,rbw
3
+ exts=rb,rbw,gemspec
4
4
 
5
5
  scanner=coderay
6
6
  #scanner=re
@@ -194,7 +194,7 @@ class WrapperContainer < TkFrame
194
194
  @selected_class = nil
195
195
  @selected_require = nil
196
196
  @selected_class_obj = nil
197
- Arcadia.instance.layout.domain(Arcadia.instance['conf']['palette.frame'])['root'].top_text('')
197
+ Arcadia.instance.layout.domain(Arcadia.instance['conf']['palette.frame'])['root'].top_text_clear
198
198
  end
199
199
 
200
200
  def add_palette(_lib_obj)
@@ -1570,9 +1570,12 @@ class RubyDebug < ArcadiaExt
1570
1570
 
1571
1571
  def on_exit_query(_event)
1572
1572
  if @rdc && @rdc.is_alive?
1573
- query = (Tk.messageBox('icon' => 'question', 'type' => 'yesno',
1573
+ query = (Arcadia.dialog(self, 'icon' => 'question', 'type' => 'yes_no',
1574
1574
  'title' => '(Arcadia) Debug',
1575
1575
  'message' => "Debug in course, do you want to exit?")=='yes')
1576
+ # query = (Tk.messageBox('icon' => 'question', 'type' => 'yesno',
1577
+ # 'title' => '(Arcadia) Debug',
1578
+ # 'message' => "Debug in course, do you want to exit?")=='yes')
1576
1579
  if query
1577
1580
  debug_quit
1578
1581
  _event.can_exit=true
@@ -1657,10 +1660,15 @@ class RubyDebug < ArcadiaExt
1657
1660
  if @rdc
1658
1661
  if @rdc.is_alive?
1659
1662
  Thread.new{
1660
- Tk.messageBox('icon' => 'info',
1661
- 'type' => 'ok',
1662
- 'title' => '(Arcadia) Debug',
1663
- 'message' => "Debug in course, stop it before exit")
1663
+ Arcadia.dialog(self,
1664
+ 'type'=>'ok',
1665
+ 'title' => "(Arcadia) Debug",
1666
+ 'msg'=>"Debug in course, stop it before exit",
1667
+ 'level'=>'info')
1668
+ # Tk.messageBox('icon' => 'info',
1669
+ # 'type' => 'ok',
1670
+ # 'title' => '(Arcadia) Debug',
1671
+ # 'message' => "Debug in course, stop it before exit")
1664
1672
  }
1665
1673
  else
1666
1674
  begin
@@ -4,7 +4,7 @@ frames.labels=Search in files
4
4
  frames.names=search_in_files
5
5
  active=yes
6
6
  require=ext/ae-search-in-files/ae-search-in-files
7
- class=SearchInFilesService
7
+ class=SearchInFiles
8
8
 
9
9
  font=courier 10
10
10
  font.bold=courier 10 bold
@@ -3,20 +3,13 @@
3
3
  # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
4
  #
5
5
 
6
- class SearchInFilesService < ArcadiaExt
6
+ class SearchInFiles < ArcadiaExt
7
7
 
8
8
  def on_before_build(_event)
9
- Arcadia.attach_listener(SearchInFilesListener.new(self),SearchInFilesEvent)
10
- end
11
-
12
- end
13
-
14
- class SearchInFilesListener
15
- def initialize(_service)
16
- @service = _service
17
9
  create_find 'Search in files'
10
+ Arcadia.attach_listener(self, SearchInFilesEvent)
18
11
  end
19
-
12
+
20
13
  def on_before_search_in_files(_event)
21
14
  if _event.what.nil?
22
15
  if _event.dir
@@ -32,9 +25,9 @@ class SearchInFilesListener
32
25
 
33
26
  #def on_after_search_in_files(_event)
34
27
  #end
35
-
28
+
36
29
  def create_find title
37
- @find = FindFrame.new(@service.arcadia.layout.root)
30
+ @find = FindFrame.new(self.arcadia.layout.root)
38
31
  @find.on_close=proc{@find.hide}
39
32
  @find.hide
40
33
  @find.b_go.bind('1', proc{update_all_combo;do_find}) # add trigger to button
@@ -89,9 +82,9 @@ class SearchInFilesListener
89
82
  return if @find.e_what.text.strip.length == 0 || @find.e_filter.text.strip.length == 0 || @find.e_dir.text.strip.length == 0
90
83
  @find.hide
91
84
  if !defined?(@search_output)
92
- @search_output = SearchOutput.new(@service)
85
+ @search_output = SearchOutput.new(self)
93
86
  end
94
- @service.frame.show_anyway
87
+ self.frame.show_anyway
95
88
  Thread.new do
96
89
  begin
97
90
  MonitorLastUsedDir.set_last @find.e_dir.text # save it away TODO make it into a message
@@ -101,7 +94,7 @@ class SearchInFilesListener
101
94
  _files = Dir[_filter]
102
95
  _node = @search_output.new_result(_search_title, _files.length)
103
96
  progress_stop=false
104
- progress_bar = TkProgressframe.new(@service.arcadia.layout.root, _files.length)
97
+ progress_bar = TkProgressframe.new(self.arcadia.layout.root, _files.length)
105
98
  progress_bar.title('Searching')
106
99
  progress_bar.on_cancel=proc{progress_stop=true}
107
100
  #@progress_bar.on_cancel=proc{cancel}
@@ -129,7 +122,7 @@ class SearchInFilesListener
129
122
  #Arcadia.new_error_msg(self, e.message)
130
123
  ensure
131
124
  progress_bar.destroy if progress_bar
132
- @service.frame.show_anyway
125
+ self.frame.show_anyway
133
126
  end
134
127
  end
135
128
  end
@@ -343,6 +336,7 @@ class FindFrame < TkFloatTitledFrame
343
336
  super
344
337
  self.focus
345
338
  @e_what.focus
339
+ @e_what_entry.select_throw
346
340
  @e_what_entry.selection_range(0,'end')
347
341
  end
348
342
  end
@@ -4,7 +4,7 @@ frames.labels=Ack in files
4
4
  frames.names=ack_in_files
5
5
  active=yes
6
6
  require=ext/ae-search-in-files/ext/ack-in-files/ack-in-files
7
- class=AckInFilesService
7
+ class=AckInFiles
8
8
  font=courier 10
9
9
  font.bold=courier 10 bold
10
10
  color.background=#ffffff
@@ -3,16 +3,11 @@
3
3
  # by Roger D. Pack
4
4
  #
5
5
 
6
- class AckInFilesService < ArcadiaExt
7
- def on_before_build(_event)
8
- Arcadia.attach_listener(AckInFilesListener.new(self),AckInFilesEvent)
9
- end
10
- end
6
+ class AckInFiles < SearchInFiles
11
7
 
12
- class AckInFilesListener < SearchInFilesListener
13
- def initialize(_service)
14
- @service = _service
8
+ def on_before_build(_event)
15
9
  create_find 'Ack in files'
10
+ Arcadia.attach_listener(self, AckInFilesEvent)
16
11
  end
17
12
 
18
13
  def on_before_ack_in_files(_event)
@@ -23,9 +18,9 @@ class AckInFilesListener < SearchInFilesListener
23
18
  return if @find.e_what.text.strip.length == 0 || @find.e_filter.text.strip.length == 0 || @find.e_dir.text.strip.length == 0
24
19
  @find.hide
25
20
  if !defined?(@search_output)
26
- @search_output = SearchOutput.new(@service)
21
+ @search_output = SearchOutput.new(self)
27
22
  else
28
- @service.frame.show
23
+ self.frame.show
29
24
  end
30
25
  begin
31
26
  # unfortunately, it uses regex instead of glob. Oh well.
@@ -40,13 +35,13 @@ class AckInFilesListener < SearchInFilesListener
40
35
  _filter = @find.e_dir.text+'/**/'+@find.e_filter.text
41
36
  _node = @search_output.new_result(_search_title, '')
42
37
  progress_stop=false
43
- @progress_bar = TkProgressframe.new(@service.arcadia.layout.root, 2)
38
+ @progress_bar = TkProgressframe.new(self.arcadia.layout.root, 2)
44
39
  @progress_bar.title('Running')
45
40
 
46
41
  answer = `#{command}`
47
42
  answer_lines = answer.split("\n")
48
43
  @progress_bar.destroy # destroy the old one
49
- @progress_bar = TkProgressframe.new(@service.arcadia.layout.root, answer_lines.length)
44
+ @progress_bar = TkProgressframe.new(self.arcadia.layout.root, answer_lines.length)
50
45
  @progress_bar.title('Parsing')
51
46
  @progress_bar.on_cancel=proc{progress_stop=true}
52
47
 
data/lib/a-commons.rb CHANGED
@@ -12,45 +12,45 @@ require 'singleton'
12
12
 
13
13
 
14
14
  class AbstractFrameWrapper
15
- # def AbstractFrameWrapper.inherited(sub)
16
- # unless sub.respond_to? :hinner_frame
17
- # raise NoMethodError, "#{sub} needs to respond to `:hinner_frame'"
18
- # end
19
- # unless sub.respond_to? :title
20
- # raise NoMethodError, "#{sub} needs to respond to `:title'"
21
- # end
22
- #
23
- # unless sub.respond_to? :show
24
- # raise NoMethodError, "#{sub} needs to respond to `:show'"
25
- # end
26
- #
27
- # unless sub.respond_to? :hide
28
- # raise NoMethodError, "#{sub} needs to respond to `:hide'"
29
- # end
30
- #
31
- # unless sub.respond_to? :free
32
- # raise NoMethodError, "#{sub} needs to respond to `:free'"
33
- # end
34
- # end
15
+ # def AbstractFrameWrapper.inherited(sub)
16
+ # unless sub.respond_to? :hinner_frame
17
+ # raise NoMethodError, "#{sub} needs to respond to `:hinner_frame'"
18
+ # end
19
+ # unless sub.respond_to? :title
20
+ # raise NoMethodError, "#{sub} needs to respond to `:title'"
21
+ # end
22
+ #
23
+ # unless sub.respond_to? :show
24
+ # raise NoMethodError, "#{sub} needs to respond to `:show'"
25
+ # end
26
+ #
27
+ # unless sub.respond_to? :hide
28
+ # raise NoMethodError, "#{sub} needs to respond to `:hide'"
29
+ # end
30
+ #
31
+ # unless sub.respond_to? :free
32
+ # raise NoMethodError, "#{sub} needs to respond to `:free'"
33
+ # end
34
+ # end
35
35
 
36
36
  def initialize
37
37
  unless sub.respond_to? :hinner_frame
38
- raise NoMethodError, "#{sub} needs to respond to `:hinner_frame'"
38
+ raise NoMethodError, "#{sub} needs to respond to `:hinner_frame'"
39
39
  end
40
40
  unless sub.respond_to? :title
41
- raise NoMethodError, "#{sub} needs to respond to `:title'"
41
+ raise NoMethodError, "#{sub} needs to respond to `:title'"
42
42
  end
43
-
43
+
44
44
  unless sub.respond_to? :show
45
- raise NoMethodError, "#{sub} needs to respond to `:show'"
45
+ raise NoMethodError, "#{sub} needs to respond to `:show'"
46
46
  end
47
-
47
+
48
48
  unless sub.respond_to? :hide
49
- raise NoMethodError, "#{sub} needs to respond to `:hide'"
49
+ raise NoMethodError, "#{sub} needs to respond to `:hide'"
50
50
  end
51
-
51
+
52
52
  unless sub.respond_to? :free
53
- raise NoMethodError, "#{sub} needs to respond to `:free'"
53
+ raise NoMethodError, "#{sub} needs to respond to `:free'"
54
54
  end
55
55
  end
56
56
 
@@ -58,12 +58,12 @@ end
58
58
 
59
59
  #module AbstractFrameWrapper
60
60
  # def hinner_frame
61
- # raise NoMethodError, "#{self} needs to respond to `:hinner_frame'"
61
+ # raise NoMethodError, "#{self} needs to respond to `:hinner_frame'"
62
62
  # end
63
63
  #end
64
64
 
65
65
  class FixedFrameWrapper < AbstractFrameWrapper
66
- # include AbstractFrameWrapper
66
+ # include AbstractFrameWrapper
67
67
  attr_accessor :domain
68
68
  attr_reader :name
69
69
  attr_reader :title
@@ -77,27 +77,31 @@ class FixedFrameWrapper < AbstractFrameWrapper
77
77
  @index = _index
78
78
  fixed_frame_forge
79
79
  end
80
-
80
+
81
81
  def fixed_frame_forge
82
82
  @fixed_frame = Arcadia.layout.register_panel(self) if @fixed_frame.nil?
83
83
  end
84
84
  private :fixed_frame_forge
85
-
85
+
86
86
  def hinner_frame
87
87
  fixed_frame_forge
88
88
  @fixed_frame
89
89
  end
90
-
90
+
91
91
  def root
92
92
  fixed_frame_forge
93
- Arcadia.layout.domain(@domain)['root']
93
+ if Arcadia.layout.domain(@domain)
94
+ Arcadia.layout.domain(@domain)['root']
95
+ else
96
+ Arcadia.layout.domain('nil')['root']
97
+ end
94
98
  end
95
-
96
- # def top_text(_top_text=nil)
97
- # fixed_frame_forge
98
- # Arcadia.layout.domain(@domain)['root'].top_text(_top_text)
99
- # #@arcadia.layout.domain_for_frame(@domain, @name)['root'].top_text(_title)
100
- # end
99
+
100
+ # def top_text(_top_text=nil)
101
+ # fixed_frame_forge
102
+ # Arcadia.layout.domain(@domain)['root'].top_text(_top_text)
103
+ # #@arcadia.layout.domain_for_frame(@domain, @name)['root'].top_text(_title)
104
+ # end
101
105
 
102
106
  def show
103
107
  fixed_frame_forge
@@ -113,10 +117,10 @@ class FixedFrameWrapper < AbstractFrameWrapper
113
117
  Arcadia.layout.register_panel(self, self.hinner_frame)
114
118
  end
115
119
  end
116
-
120
+
117
121
  def hide
118
122
  end
119
-
123
+
120
124
  def raised?
121
125
  Arcadia.layout.raised?(@domain, @name)
122
126
  end
@@ -132,7 +136,7 @@ class FixedFrameWrapper < AbstractFrameWrapper
132
136
  def resize
133
137
  Arcadia.layout.domain(@domain)['root'].resize
134
138
  end
135
-
139
+
136
140
  def free
137
141
  Arcadia.layout.unregister_panel(self)
138
142
  @fixed_frame = nil
@@ -141,7 +145,7 @@ end
141
145
 
142
146
 
143
147
  class FloatFrameWrapper < AbstractFrameWrapper
144
- # include AbstractFrameWrapper
148
+ # include AbstractFrameWrapper
145
149
  def initialize(_arcadia, _geometry=nil, _title=nil)
146
150
  @arcadia = _arcadia
147
151
  @geometry = _geometry
@@ -152,27 +156,27 @@ class FloatFrameWrapper < AbstractFrameWrapper
152
156
  def float_frame_forge
153
157
  if @obj.nil?
154
158
  a = @geometry.scan(/[+-]*\d\d*%*/)
155
- p_height = TkWinfo.screenheight(@arcadia.layout.root)
156
- p_width = TkWinfo.screenwidth(@arcadia.layout.root)
159
+ p_height = TkWinfo.screenheight(@arcadia.layout.root)
160
+ p_width = TkWinfo.screenwidth(@arcadia.layout.root)
157
161
  if a[0][-1..-1]=='%'
158
162
  n = a[0][0..-2].to_i.abs
159
- a[0] = (p_width/100*n).to_i
163
+ a[0] = (p_width/100*n).to_i
160
164
  end
161
165
  if a[1][-1..-1]=='%'
162
166
  n = a[1][0..-2].to_i.abs
163
- a[1] = (p_height/100*n).to_i
167
+ a[1] = (p_height/100*n).to_i
164
168
  end
165
169
  if a[2][-1..-1]=='%'
166
170
  n = a[2][0..-2].to_i.abs
167
- a[2] = (p_width/100*n).to_i
171
+ a[2] = (p_width/100*n).to_i
168
172
  end
169
173
  if a[3][-1..-1]=='%'
170
174
  n = a[3][0..-2].to_i.abs
171
- a[3] = (p_height/100*n).to_i
175
+ a[3] = (p_height/100*n).to_i
172
176
  end
173
-
177
+
174
178
  args = {'width'=>a[0], 'height'=>a[1], 'x'=>a[2], 'y'=>a[3]}
175
- @obj = @arcadia.layout.new_float_frame(args)
179
+ @obj = @arcadia.layout.add_float_frame(args)
176
180
  @obj.title(@title) if @title
177
181
  end
178
182
  end
@@ -181,7 +185,7 @@ class FloatFrameWrapper < AbstractFrameWrapper
181
185
  float_frame_forge
182
186
  @obj.frame if @obj
183
187
  end
184
-
188
+
185
189
  def title(_title=nil)
186
190
  float_frame_forge
187
191
  @obj.title(_title) if @obj
@@ -189,16 +193,16 @@ class FloatFrameWrapper < AbstractFrameWrapper
189
193
 
190
194
  def show
191
195
  float_frame_forge
192
- @obj.show if @obj
196
+ @obj.show if @obj
193
197
  end
194
-
198
+
195
199
  def hide
196
200
  float_frame_forge
197
- @obj.hide if @obj
201
+ @obj.hide if @obj
198
202
  end
199
-
203
+
200
204
  def free
201
- @obj.destroy if @obj
205
+ @obj.destroy if @obj
202
206
  @obj = nil
203
207
  end
204
208
  end
@@ -209,10 +213,6 @@ class ArcadiaExt
209
213
  def initialize(_arcadia, _name=nil)
210
214
  @arcadia = _arcadia
211
215
  @arcadia.register(self)
212
- Arcadia.attach_listener(self, BuildEvent)
213
- Arcadia.attach_listener(self, InitializeEvent)
214
- Arcadia.attach_listener(self, ExitQueryEvent)
215
- Arcadia.attach_listener(self, FinalizeEvent)
216
216
  @name = _name
217
217
  @frames = Array.new
218
218
  @frames_points = conf_array("#{_name}.frames")
@@ -221,39 +221,74 @@ class ArcadiaExt
221
221
  @float_frames = Array.new
222
222
  @float_geometries = conf_array("#{_name}.float_frames")
223
223
  @float_labels = conf_array("#{_name}.float_labels")
224
+ Arcadia.attach_listener(self, BuildEvent)
225
+ Arcadia.attach_listener(self, InitializeEvent)
226
+ Arcadia.attach_listener(self, ExitQueryEvent)
227
+ Arcadia.attach_listener(self, FinalizeEvent)
224
228
  #ObjectSpace.define_finalizer(self, self.method(:finalize).to_proc)
225
229
  end
226
-
227
-
230
+
231
+
228
232
  def conf_array(_name)
229
233
  res = []
230
234
  value = @arcadia['conf'][_name]
231
235
  res.concat(value.split(',')) if value
232
236
  res
233
237
  end
234
-
238
+
239
+ def array_conf(_name, _array)
240
+ value = ''
241
+ _array.each{|e|
242
+ if value.length > 0
243
+ value = "#{value},#{e}"
244
+ else
245
+ value = "#{e}"
246
+ end
247
+ }
248
+ @arcadia['conf'][_name]=value
249
+ value
250
+ end
251
+
252
+ def add_to_conf_property(_name, _value)
253
+ a = conf_array(_name)
254
+ if !a.include?(_value)
255
+ a << _value
256
+ array_conf(_name,a)
257
+ end
258
+ end
259
+
260
+ def del_from_conf_property(_name, _value)
261
+ a = conf_array(_name)
262
+ a.delete(_value)
263
+ array_conf(_name,a)
264
+ end
265
+
235
266
  def frame_def_visible?(_n=0)
236
267
  @arcadia.layout.domains.include?(@frames_points[_n])
237
268
  #@frames_points[_n] != '-1.-1'
238
269
  end
239
-
270
+
240
271
  def frame_visible?(_n=0)
241
272
  @frames[_n] != nil && @frames[_n].hinner_frame && TkWinfo.mapped?(@frames[_n].hinner_frame)
242
273
  end
243
-
274
+
244
275
  def frame(_n=0,create_if_not_exist=true)
245
- if @frames[_n] == nil && @frames_points[_n] && create_if_not_exist
246
- (@frames_labels[_n].nil?)? _label = @name : _label = @frames_labels[_n]
247
- (@frames_names[_n].nil?)? _name = @name : _name = @frames_names[_n]
248
- @frames[_n] = FixedFrameWrapper.new(self, @frames_points[_n], _name, _label, _n)
249
- end
276
+ if @frames_points[_n].nil?
277
+ @frames_points[_n] = '0.0'
278
+ Arcadia['conf']["#{@name}.frames"]+=',0.0'
279
+ end
280
+ if @frames[_n] == nil && @frames_points[_n] && create_if_not_exist
281
+ (@frames_labels[_n].nil?)? _label = @name : _label = @frames_labels[_n]
282
+ (@frames_names[_n].nil?)? _name = @name : _name = @frames_names[_n]
283
+ @frames[_n] = FixedFrameWrapper.new(self, @frames_points[_n], _name, _label, _n)
284
+ end
250
285
  return @frames[_n]
251
286
  end
252
-
287
+
253
288
  def frame_domain(_n=0)
254
289
  if conf('frames')
255
- frs = conf('frames').split(',')
256
- else
290
+ frs = conf('frames').split(',')
291
+ else
257
292
  frs = Array.new
258
293
  end
259
294
  ret = nil
@@ -265,8 +300,8 @@ class ArcadiaExt
265
300
 
266
301
  def frame_domain_default(_n=0)
267
302
  if conf_default('frames')
268
- frs = conf_default('frames').split(',')
269
- else
303
+ frs = conf_default('frames').split(',')
304
+ else
270
305
  frs = Array.new
271
306
  end
272
307
  ret = nil
@@ -277,19 +312,19 @@ class ArcadiaExt
277
312
  end
278
313
 
279
314
  def float_frame(_n=0, _args=nil)
280
- if @float_frames[_n].nil?
281
- (@float_labels[_n].nil?)? _label = @name : _label = @float_labels[_n]
282
- @float_frames[_n] = FloatFrameWrapper.new(@arcadia, @float_geometries[_n], _label)
283
- end
284
- @float_frames[_n]
315
+ if @float_frames[_n].nil?
316
+ (@float_labels[_n].nil?)? _label = @name : _label = @float_labels[_n]
317
+ @float_frames[_n] = FloatFrameWrapper.new(@arcadia, @float_geometries[_n], _label)
318
+ end
319
+ @float_frames[_n]
285
320
  end
286
321
 
287
322
  def conf(_property)
288
- @arcadia['conf'][@name+'.'+_property]
323
+ @arcadia['conf'][@name+'.'+_property]
289
324
  end
290
325
 
291
326
  def conf_default(_property)
292
- @arcadia['conf_without_local'][@name+'.'+_property]
327
+ @arcadia['conf_without_local'][@name+'.'+_property]
293
328
  end
294
329
 
295
330
  def restore_default_conf(_property)
@@ -297,17 +332,17 @@ class ArcadiaExt
297
332
  @arcadia['conf'][@name+'.'+_property] = @arcadia['conf_without_local'][@name+'.'+_property]
298
333
  end
299
334
  end
300
-
301
- # def conf_global(_property)
302
- # @arcadia['conf'][_property]
303
- # end
304
-
335
+
336
+ # def conf_global(_property)
337
+ # @arcadia['conf'][_property]
338
+ # end
339
+
305
340
  def exec(_method, _args=nil)
306
341
  if self.respond_to(_method)
307
342
  self.send(_method, _args)
308
343
  end
309
344
  end
310
-
345
+
311
346
  def maximized?(_n=0)
312
347
  ret= false
313
348
  ret=@frames[_n].maximized? if @frames[_n]
@@ -317,23 +352,164 @@ class ArcadiaExt
317
352
  def maximize(_n=0)
318
353
  @frames[_n].maximize if @frames[_n]
319
354
  end
320
-
355
+
321
356
  def resize(_n=0)
322
357
  @frames[_n].resize if @frames[_n]
323
358
  end
324
359
  end
325
360
 
361
+ class ArcadiaExtPlus < ArcadiaExt
362
+ attr_reader :index
363
+
364
+ def initialize(_arcadia, _name=nil)
365
+ @@instances = {} if !defined?(@@instances)
366
+ @@main_instance = {} if !defined?(@@main_instance)
367
+ @@active_instance = {} if !defined?(@@active_instance)
368
+ @@instances[self.class] = [] if @@instances[self.class] == nil
369
+ @@instances[self.class] << self
370
+ @@main_instance[self.class] = self if @@main_instance[self.class] == nil
371
+ Arcadia.attach_listener(self, ActivateInstanceEvent)
372
+ super(_arcadia, _name)
373
+ if self.frame != nil
374
+ self.frame.hinner_frame.bind_append("Enter", proc{activate})
375
+ if @@main_instance[self.class] == self
376
+ frame.root.add_state_button(
377
+ self.name,
378
+ 'Duplicate',
379
+ proc{duplicate},
380
+ PLUS_EX_GIF,
381
+ 'left')
382
+ activate(self, false)
383
+ else
384
+ frame.root.add_state_button(
385
+ self.name,
386
+ 'Destroy',
387
+ proc{deduplicate},
388
+ MINUS_EX_GIF,
389
+ 'left')
390
+ activate(self, false)
391
+ end
392
+ end
393
+ end
394
+
395
+ def ArcadiaExtPlus.instances(_class)
396
+ @@instances[_class]
397
+ end
398
+
399
+ def active_instance
400
+ @@active_instance[self.class]
401
+ end
402
+
403
+ def main_instance
404
+ @@main_instance[self.class]
405
+ end
406
+
407
+ def activate(_obj=self, _raise_event=true)
408
+ @@active_instance[self.class] = _obj
409
+ @@active_instance[self.class].frame.root.shift_on if @@active_instance[self.class].frame != nil
410
+ instances.each{|i|
411
+ i.frame.root.shift_off if i != @@active_instance[self.class] && i.frame != nil && i.frame.root != @@active_instance[self.class].frame.root
412
+ }
413
+ ActivateInstanceEvent.new(Arcadia.instance, 'name'=>self.name).go! if _raise_event
414
+ end
415
+
416
+ def activate_main
417
+ activate(@@main_instance[self.class])
418
+ end
419
+
420
+ def active?
421
+ @@active_instance[self.class] == self
422
+ end
423
+
424
+ def instances
425
+ @@instances[self.class]
426
+ end
427
+
428
+ def instance_index
429
+ instances.index(self)
430
+ end
431
+
432
+ def new_name
433
+ #"#{main_instance.name}#{instances.length}"
434
+ name = main_instance.name
435
+ i=0
436
+ while exist_name?(name)
437
+ i+=1
438
+ name = "#{main_instance.name}#{i}"
439
+ end
440
+ name
441
+ end
442
+
443
+ def exist_name?(_name)
444
+ exist = false
445
+ instances.each{|i|
446
+ exist = exist || i.name == _name
447
+ break if exist
448
+ }
449
+ exist
450
+ end
451
+
452
+ def duplicate(_name=new_name)
453
+ #create conf properties
454
+ Arcadia.conf_group_copy(@@main_instance[self.class].name, _name)
455
+ instance = clone(_name)
456
+ #initialize
457
+ Arcadia.process_event(InitializeEvent.new(Arcadia.instance), [instance])
458
+ add_to_conf_property("#{main_instance.name}.clones", _name)
459
+ end
460
+
461
+ def clone(_name)
462
+ #create
463
+ instance = self.class.new(Arcadia.instance, _name)
464
+ #build
465
+ Arcadia.process_event(BuildEvent.new(Arcadia.instance), [instance])
466
+ Arcadia.attach_listener(instance, ClearCacheInstanceEvent)
467
+ Arcadia.attach_listener(instance, DestroyInstanceEvent)
468
+ instance
469
+ end
470
+
471
+ def on_destroy_instance(_event)
472
+ Arcadia.detach_listener(self)
473
+ @arcadia.unregister(self)
474
+ @frames.each{|f| f.free }
475
+ end
476
+
477
+ # def on_before_layout_raising_frame(_event)
478
+ # if _event.extension_name == @name
479
+ # activate
480
+ # end
481
+ # end
482
+
483
+ def deduplicate
484
+ if (Arcadia.dialog(self, 'type'=>'yes_no',
485
+ 'msg'=>"Shure delete '#{@name}'?",
486
+ 'title' => "(Arcadia) Delete #{@name}",
487
+ 'level' => 'question')=='yes')
488
+ exit_query_event = Arcadia.process_event(ExitQueryEvent.new(self, 'can_exit'=>true))
489
+ if exit_query_event.can_exit
490
+ activate_main
491
+ @@instances[self.class].delete(self) if @@instances[self.class]
492
+ Arcadia.del_conf_group(Arcadia['conf'],@name)
493
+ Arcadia.del_conf_group(Arcadia['pers'],@name)
494
+ del_from_conf_property("#{main_instance.name}.clones", @name)
495
+ Arcadia.process_event(ClearCacheInstanceEvent.new(Arcadia.instance), [self])
496
+ Arcadia.process_event(DestroyInstanceEvent.new(Arcadia.instance), [self])
497
+ end
498
+ end
499
+ end
500
+
501
+ end
326
502
 
327
503
  class ObserverCallback
328
- def initialize(_publisher, _subscriber, _method_update_to_call=:update)
329
- @publisher = _publisher
330
- @subscriber = _subscriber
331
- @method=_method_update_to_call
332
- @publisher.add_observer(self)
333
- end
334
- def update(*args)
335
- @subscriber.send(@method,*args)
336
- end
504
+ def initialize(_publisher, _subscriber, _method_update_to_call=:update)
505
+ @publisher = _publisher
506
+ @subscriber = _subscriber
507
+ @method=_method_update_to_call
508
+ @publisher.add_observer(self)
509
+ end
510
+ def update(*args)
511
+ @subscriber.send(@method,*args)
512
+ end
337
513
  end
338
514
 
339
515
  # +------------------------------------------+
@@ -346,7 +522,7 @@ class Event
346
522
  attr_reader :time
347
523
  def initialize(_sender, _args=nil)
348
524
  @sender = _sender
349
- if _args
525
+ if _args
350
526
  _args.each do |key, value|
351
527
  self.send(key+'=', value)
352
528
  end
@@ -363,7 +539,7 @@ class Event
363
539
  @breaked = false
364
540
  @sender = _sender
365
541
  @channel = '0'
366
- if _args
542
+ if _args
367
543
  _args.each do |key, value|
368
544
  #self.send(key, value)
369
545
  self.send(key.to_s+'=', value) if self.respond_to?(key.to_s)
@@ -372,11 +548,11 @@ class Event
372
548
  @time = Time.new
373
549
  @results = Array.new
374
550
  end
375
-
551
+
376
552
  def add_finalize_callback(_proc)
377
- ObjectSpace.define_finalizer(self, _proc)
553
+ ObjectSpace.define_finalizer(self, _proc)
378
554
  end
379
-
555
+
380
556
  def add_result(_sender, _args=nil)
381
557
  if self.class::Result
382
558
  res = self.class::Result.new(_sender, _args)
@@ -386,39 +562,64 @@ class Event
386
562
  @results << res
387
563
  res
388
564
  end
389
-
565
+
390
566
  def is_breaked?
391
567
  @breaked
392
568
  end
393
-
569
+
394
570
  def break
395
571
  @breaked = true
396
572
  end
397
-
573
+
398
574
  end
399
575
 
400
576
  module EventBus #(or SourceEvent)
401
- def process_event(_event)
577
+ def process_event(_event, _listeners=nil)
578
+ # _listener rapresent a filter on @@listeners if != nil
402
579
  return _event if !defined?(@@listeners)
403
580
  event_classes = _event_class_stack(_event.class)
404
581
  #before fase
405
582
  event_classes.each do |_c|
406
- _process_fase(_c, _event, 'before')
583
+ if _listeners.nil?
584
+ _process_fase(_c, _event, @@listeners[_c], 'before')
585
+ else
586
+ listeners_to_process = []
587
+ _listeners.each{|lis|
588
+ listeners_to_process << lis if @@listeners[_c] && @@listeners[_c].include?(lis)
589
+ }
590
+ _process_fase(_c, _event, listeners_to_process, 'before')
591
+ end
407
592
  break if _event.is_breaked? # not responding to this means "you need to pass in an instance, not a class name
408
593
  end unless _event.is_breaked?
409
594
  # fase
410
595
  event_classes.each do |_c|
411
- _process_fase(_c, _event)
596
+ if _listeners.nil?
597
+ _process_fase(_c, _event, @@listeners[_c])
598
+ else
599
+ listeners_to_process = []
600
+ _listeners.each{|lis|
601
+ listeners_to_process << lis if @@listeners[_c] && @@listeners[_c].include?(lis)
602
+ }
603
+ _process_fase(_c, _event, listeners_to_process)
604
+ end
412
605
  break if _event.is_breaked?
413
606
  end unless _event.is_breaked?
414
607
  #after fase
415
608
  event_classes.each do |_c|
416
- _process_fase(_c, _event, 'after')
609
+ if _listeners.nil?
610
+ _process_fase(_c, _event, @@listeners[_c], 'after')
611
+ else
612
+ listeners_to_process = []
613
+ _listeners.each{|lis|
614
+ listeners_to_process << lis if @@listeners[_c] && @@listeners[_c].include?(lis)
615
+ }
616
+ _process_fase(_c, _event, listeners_to_process, 'after')
617
+ end
417
618
  break if _event.is_breaked?
418
619
  end unless _event.is_breaked?
419
620
  _event
420
621
  end
421
-
622
+
422
623
  def broadcast_event(_event)
423
624
  return _event if !defined?(@@listeners)
424
625
  event_classes = _event_class_stack(_event.class)
@@ -426,47 +627,45 @@ module EventBus #(or SourceEvent)
426
627
  _broadcast_fase(_c, _event)
427
628
  end
428
629
  end
429
-
630
+
430
631
  def _event_class_stack(_class)
431
632
  #p "------> chiamato _event_class_stack for class #{_class}"
432
633
  res = Array.new
433
634
  cur_class = _class
434
635
  while cur_class != Object
435
- #p "#{cur_class} son on #{cur_class.superclass}"
436
- res << cur_class
437
- cur_class = cur_class.superclass
636
+ #p "#{cur_class} son on #{cur_class.superclass}"
637
+ res << cur_class
638
+ cur_class = cur_class.superclass
438
639
  end
439
640
  return res
440
641
  end
441
642
  private :_event_class_stack
442
-
443
- def _process_fase(_class, _event, _fase_name = nil)
444
- # _fase_name cicle
445
- return if @@listeners[_class].nil?
643
+
644
+ def _process_fase(_class, _event, _listeners=nil, _fase_name = nil)
645
+ return if _listeners.nil?
446
646
  _fase_name.nil?? suf = '':suf = _fase_name
447
- #method_name = 'on_'+suf+_class.to_s.downcase.gsub('event','')
448
647
  method_name = _method_name(_class, suf)
449
- #p _method_name(_event, suf)+' == '+method_name
450
- #p method_name
451
648
  if _class != _event.class
452
- #sub_method_name = 'on_'+suf+_event.class.to_s.downcase.gsub('event','')
453
649
  sub_method_name = _method_name(_event.class, suf)
454
- @@listeners[_class].each do|_listener|
455
- if _listener.respond_to?(sub_method_name)
456
- _listener.send(sub_method_name, _event)
457
- elsif _listener.respond_to?(method_name)
458
- _listener.send(method_name, _event)
459
- end
460
- break if _event.is_breaked?
650
+ _listeners.each do|_listener|
651
+ next if _listener.kind_of?(ArcadiaExtPlus) && !(_listener.active? || _class == ArcadiaSysEvent || _class.superclass == ArcadiaSysEvent || _event.class.kind_of?(ArcadiaSysEvent))
652
+ if _listener.respond_to?(sub_method_name)
653
+ _listener.send(sub_method_name, _event)
654
+ elsif _listener.respond_to?(method_name)
655
+ _listener.send(method_name, _event)
656
+ end
657
+ break if _event.is_breaked?
461
658
  end
462
659
  else
463
- @@listeners[_class].each do|_listener|
660
+ _listeners.each do|_listener|
661
+ next if _listener.kind_of?(ArcadiaExtPlus) && !(_listener.active? || (_event.kind_of?(ArcadiaSysEvent)))
464
662
  _listener.send(method_name, _event) if _listener.respond_to?(method_name)
465
663
  break if _event.is_breaked?
466
664
  end
467
665
  end
468
666
  end
469
667
  private :_process_fase
668
+
470
669
  def _method_name(_class, _suf='')
471
670
  _str = _class.to_s
472
671
  _pre = _str[0..1]
@@ -482,9 +681,9 @@ module EventBus #(or SourceEvent)
482
681
  sub_method_name = _method_name(_event.class)
483
682
  @@listeners[_class].each do|_listener|
484
683
  if _listener.respond_to?(sub_method_name)
485
- Thread.new{_listener.send(sub_method_name, _event)}
684
+ Thread.new{_listener.send(sub_method_name, _event)}
486
685
  elsif _listener.respond_to?(method_name)
487
- Thread.new{_listener.send(method_name, _event)}
686
+ Thread.new{_listener.send(method_name, _event)}
488
687
  end
489
688
  end
490
689
  else
@@ -497,12 +696,19 @@ module EventBus #(or SourceEvent)
497
696
  end
498
697
  private :_broadcast_fase
499
698
 
500
- def detach_listener(_listener, _class_event)
501
- if @@listeners[_class_event]
502
- @@listeners[_class_event].delete(_listener)
699
+ def detach_listener(_listener, _class_event=nil)
700
+ if _class_event != nil
701
+ if @@listeners[_class_event]
702
+ @@listeners[_class_event].delete(_listener)
703
+ end
704
+ else
705
+ #delete all the issues of listenere
706
+ @@listeners.each{|klass, header|
707
+ header.delete(_listener)
708
+ }
503
709
  end
504
710
  end
505
-
711
+
506
712
  def attach_listener(_listener, _class_event)
507
713
  @@listeners = {} unless defined? @@listeners
508
714
  @@listeners[_class_event] = [] unless @@listeners.has_key?(_class_event)
@@ -514,7 +720,7 @@ end
514
720
 
515
721
  module Cacheble
516
722
  def self.extended(_obj)
517
- _obj.__initialize_cache(_obj)
723
+ _obj.__initialize_cache(_obj)
518
724
  end
519
725
 
520
726
  def self.included(_obj)
@@ -524,15 +730,15 @@ module Cacheble
524
730
  def __initialize_cache(_obj)
525
731
  @@cache = Hash.new
526
732
  end
527
-
733
+
528
734
  def self.clear_cache
529
735
  @@cache.clear
530
736
  end
531
-
737
+
532
738
  def self.set_cache(_key, _value)
533
739
  @@cache[_key]=_value
534
740
  end
535
-
741
+
536
742
  def self.get_cache(_key, _value)
537
743
  @@cache[_key]
538
744
  end
@@ -569,12 +775,12 @@ module Configurable
569
775
  _line = ''
570
776
  end
571
777
  end
572
-
778
+
573
779
  var = _line.split('=')
574
780
  if var.length > 1
575
781
  _value = var[1].strip
576
782
  var[2..-1].collect{|x| _value=_value+'='+x} if var.length > 2
577
- if _link_hash
783
+ if _link_hash
578
784
  _value = resolve_value(_value, _link_hash)
579
785
  end
580
786
  r_hash[var[0].strip]=_value
@@ -584,18 +790,18 @@ module Configurable
584
790
  ensure
585
791
  f.close unless f.nil?
586
792
  end
587
- return r_hash
793
+ return r_hash
588
794
  else
589
795
  puts 'warning--file does not exist', _property_file
590
796
  end
591
797
  end
592
-
593
- # def one_line_format_as_hash(_line)
594
- # ret = Hash.new
595
- # end
596
- #
597
- # def hash_as_one_line_format(_name, _hash)
598
- # end
798
+
799
+ # def one_line_format_as_hash(_line)
800
+ # ret = Hash.new
801
+ # end
802
+ #
803
+ # def hash_as_one_line_format(_name, _hash)
804
+ # end
599
805
 
600
806
  def Configurable.properties_group(_group, _hash_source, _hash_suff='conf', _refresh=false)
601
807
  group_key="#{_hash_suff}.#{_group}"
@@ -615,21 +821,21 @@ module Configurable
615
821
  end
616
822
 
617
823
  def resolve_value(_value, _hash_source)
618
- if _value.length > 0
619
- _v, _vadd = _value.split(ADD_SYMBOL)
620
- else
621
- _v = _value
622
- end
623
- if _v.length > 3 && _v[0..2]==LINK_SYMBOL
624
- _v=_hash_source[_v[3..-1]] if _hash_source[_v[3..-1]]
625
- _v=_v+_vadd if _vadd
626
- end
627
- return _v
824
+ if _value.length > 0
825
+ _v, _vadd = _value.split(ADD_SYMBOL)
826
+ else
827
+ _v = _value
828
+ end
829
+ if _v.length > 3 && _v[0..2]==LINK_SYMBOL
830
+ _v=_hash_source[_v[3..-1]] if _hash_source[_v[3..-1]]
831
+ _v=_v+_vadd if _vadd
832
+ end
833
+ return _v
628
834
  end
629
-
835
+
630
836
  def resolve_properties_link(_hash_target, _hash_source)
631
837
  loop_level_max = 10
632
- # _hash_adding = Hash.new
838
+ # _hash_adding = Hash.new
633
839
  _keys_to_extend = Array.new
634
840
  _hash_target.each{|k,value|
635
841
  loop_level = 0
@@ -638,9 +844,9 @@ module Configurable
638
844
  else
639
845
  v= value
640
846
  end
641
- # p "value=#{value} class=#{value.class}"
642
- # p "v=#{v} class=#{v.class}"
643
- # p "vadd=#{vadd}"
847
+ # p "value=#{value} class=#{value.class}"
848
+ # p "v=#{v} class=#{v.class}"
849
+ # p "vadd=#{vadd}"
644
850
  while loop_level < loop_level_max && v.length > 3 && v[0..2]==LINK_SYMBOL
645
851
  if k[-1..-1]=='.'
646
852
  _keys_to_extend << k
@@ -667,15 +873,15 @@ module Configurable
667
873
  _hash_target.delete(k)
668
874
  end
669
875
  end
670
-
876
+
671
877
  def make_value(_self_context=self, _value='')
672
878
  value = _value.strip
673
879
  if value[0..0]=='!'
674
- value=_self_context.instance_eval(value[1..-1])
880
+ value=_self_context.instance_eval(value[1..-1])
675
881
  end
676
882
  value
677
883
  end
678
-
884
+
679
885
  end
680
886
 
681
887
  module Persistable
@@ -702,7 +908,7 @@ module Persistable
702
908
  begin
703
909
  if f
704
910
  if _persistent_key
705
- f.syswrite(_persistent_key+'='+_persistent_value+"\n")
911
+ f.syswrite(_persistent_key+'='+_persistent_value+"\n")
706
912
  end
707
913
  end
708
914
  ensure
@@ -710,7 +916,7 @@ module Persistable
710
916
  end
711
917
  end
712
918
  end
713
-
919
+
714
920
  end
715
921
 
716
922
  class Application
@@ -718,10 +924,10 @@ class Application
718
924
  include Configurable
719
925
  include Persistable
720
926
  ApplicationParams = Struct.new( "ApplicationParams",
721
- :name,
722
- :version,
723
- :config_file,
724
- :persistent_file
927
+ :name,
928
+ :version,
929
+ :config_file,
930
+ :persistent_file
725
931
  )
726
932
 
727
933
  def initialize(_ap=ApplicationParams.new)
@@ -742,47 +948,48 @@ class Application
742
948
  publish('pers', properties_file2hash(self['applicationParams'].persistent_file)) if self['applicationParams'].persistent_file
743
949
  yield(self) if block_given?
744
950
  end
745
-
951
+
746
952
  def Application.instance
747
953
  @@instance
748
954
  end
749
955
 
750
956
  def Application.conf(_property)
751
- @@instance['conf'][_property] if @@instance
957
+ @@instance['conf'][_property] if @@instance
752
958
  end
753
959
 
754
960
  def conf(_property)
755
- self['conf'][_property]
961
+ self['conf'][_property]
756
962
  end
757
-
963
+
758
964
  def Application.sys_info
759
965
  "[Platform = #{RUBY_PLATFORM}]\n[Ruby version = #{RUBY_VERSION}]"
760
966
  end
761
-
762
- def Application.conf_group(_group, _suff = 'conf')
763
- group_key="#{_hash_suff}.#{_group}"
764
- @@conf_groups = Hash.new if !defined?(@@conf_groups)
765
- if @@conf_groups[group_key].nil?
766
- @@conf_groups[group_key] = Hash.new
767
- glen=_group.length
768
- @@instance['conf'].keys.sort.each{|k|
769
- if k[0..glen] == "#{_group}."
770
- @@conf_groups[group_key][k[glen+1..-1]]=@@instance['conf'][k]
771
- elsif @@conf_groups[group_key].length > 0
772
- break
773
- end
774
- }
775
- end
776
- @@conf_groups[_group]
777
- end
967
+
968
+
969
+ # def Application.conf_group(_group, _suff = 'conf')
970
+ # group_key="#{_suff}.#{_group}"
971
+ # @@conf_groups = Hash.new if !defined?(@@conf_groups)
972
+ # if @@conf_groups[group_key].nil?
973
+ # @@conf_groups[group_key] = Hash.new
974
+ # glen=_group.length
975
+ # @@instance['conf'].keys.sort.each{|k|
976
+ # if k[0..glen] == "#{_group}."
977
+ # @@conf_groups[group_key][k[glen+1..-1]]=@@instance['conf'][k]
978
+ # elsif @@conf_groups[group_key].length > 0
979
+ # break
980
+ # end
981
+ # }
982
+ # end
983
+ # @@conf_groups[_group]
984
+ # end
778
985
 
779
986
  def Application.del_conf_group(_conf_hash, _group)
780
- glen=_group.length
781
- _conf_hash.keys.sort.each{|k|
782
- if k[0..glen] == "#{_group}."
783
- _conf_hash.delete(k)
784
- end
785
- }
987
+ glen=_group.length
988
+ _conf_hash.keys.sort.each{|k|
989
+ if k[0..glen] == "#{_group}."
990
+ _conf_hash.delete(k)
991
+ end
992
+ }
786
993
  end
787
994
 
788
995
  def Application.del_conf(_k)
@@ -804,60 +1011,60 @@ class Application
804
1011
  def local_file_config
805
1012
  File.join(local_dir, File.basename(self['applicationParams'].config_file))
806
1013
  end
807
-
1014
+
808
1015
  def update_local_config
809
- # local_dir is ~/arcadia
810
- if FileTest.exist?(local_file_config)
811
- if FileTest.writable?(local_dir)
812
- f = File.new(local_file_config, "w")
813
- begin
814
- if f
815
- properties = self['conf']
816
- if properties
817
- properties.keys.sort.each{|key|
818
- if self['conf_without_local'][key] == self['conf'][key] || (self['origin_conf'][key] && self['origin_conf'][key].include?('>>>')) # || self['local_conf'][key].nil?
819
- f.syswrite("# #{key}=#{self['origin_conf'][key]}\n") # write it as a comment since it isn't a real change
820
- elsif self['conf'][key]
821
- f.syswrite("#{key}=#{self['conf'][key]}\n")
822
- end
823
- }
824
- end
1016
+ # local_dir is ~/arcadia
1017
+ if FileTest.exist?(local_file_config)
1018
+ if FileTest.writable?(local_dir)
1019
+ f = File.new(local_file_config, "w")
1020
+ begin
1021
+ if f
1022
+ properties = self['conf']
1023
+ if properties
1024
+ properties.keys.sort.each{|key|
1025
+ if self['conf_without_local'][key] == self['conf'][key] || (self['origin_conf'][key] && self['origin_conf'][key].include?('>>>')) # || self['local_conf'][key].nil?
1026
+ f.syswrite("# #{key}=#{self['origin_conf'][key]}\n") # write it as a comment since it isn't a real change
1027
+ elsif self['conf'][key]
1028
+ f.syswrite("#{key}=#{self['conf'][key]}\n")
1029
+ end
1030
+ }
825
1031
  end
826
- ensure
827
- f.close unless f.nil?
828
1032
  end
1033
+ ensure
1034
+ f.close unless f.nil?
829
1035
  end
830
1036
  end
1037
+ end
831
1038
  end
832
-
1039
+
833
1040
  # this method load config file from local directory for personalizations
834
1041
  def load_local_config(_create_if_not_exist=true)
835
- if FileTest.exist?(local_file_config)
836
- self['local_conf']= self.properties_file2hash(local_file_config)
837
- self['conf'].update(self['local_conf'])
838
- elsif _create_if_not_exist
839
- if FileTest.writable?(local_dir)
840
- f = File.new(local_file_config, "w")
841
- begin
842
- if f
843
- p = self['conf']
844
- if p
845
- p.keys.sort.each{|key|
846
- f.syswrite('#'+key+'='+self['conf'][key]+"\n")
847
- }
848
- end
1042
+ if FileTest.exist?(local_file_config)
1043
+ self['local_conf']= self.properties_file2hash(local_file_config)
1044
+ self['conf'].update(self['local_conf'])
1045
+ elsif _create_if_not_exist
1046
+ if FileTest.writable?(local_dir)
1047
+ f = File.new(local_file_config, "w")
1048
+ begin
1049
+ if f
1050
+ p = self['conf']
1051
+ if p
1052
+ p.keys.sort.each{|key|
1053
+ f.syswrite('#'+key+'='+self['conf'][key]+"\n")
1054
+ }
849
1055
  end
850
- ensure
851
- f.close unless f.nil?
852
1056
  end
853
- else
854
- msg = "Locad dir "+'"'+local_dir+'"'+" must be writable!"
855
- Arcadia.dialog(self, 'type'=>'ok','title' => '(Arcadia)', 'msg' => msg, 'level'=>'error')
856
- exit
1057
+ ensure
1058
+ f.close unless f.nil?
857
1059
  end
1060
+ else
1061
+ msg = "Locad dir "+'"'+local_dir+'"'+" must be writable!"
1062
+ Arcadia.dialog(self, 'type'=>'ok','title' => '(Arcadia)', 'msg' => msg, 'level'=>'error')
1063
+ exit
858
1064
  end
1065
+ end
859
1066
  end
860
-
1067
+
861
1068
  def load_theme(_name=nil)
862
1069
  _theme_file = "conf/theme-#{_name}.conf" if !_name.nil?
863
1070
  if _theme_file && File.exist?(_theme_file)
@@ -868,13 +1075,13 @@ class Application
868
1075
  if _theme_res_file && File.exist?(_theme_res_file)
869
1076
  begin
870
1077
  require _theme_res_file
871
- rescue Exception => e
1078
+ rescue Exception => e
872
1079
  end
873
1080
 
874
1081
  end
875
- end
1082
+ end
876
1083
  end
877
-
1084
+
878
1085
  def local_dir
879
1086
  home = File.expand_path '~'
880
1087
  _local_dir = File.join(home,'.'+self['applicationParams'].name) if home
@@ -910,9 +1117,9 @@ class Application
910
1117
 
911
1118
  def []=(_name, _value)
912
1119
  @objs[_name] = _value
913
- # if @objs[_name]
914
- # @objs[_name] = _value
915
- # end
1120
+ # if @objs[_name]
1121
+ # @objs[_name] = _value
1122
+ # end
916
1123
  end
917
1124
 
918
1125